
I've tried something very close to what is done in tqm8xx but I don't manage to get something reliable : either it hangs or I get data abort.
After checking the datasheet, I don't understand how we can change the geometry of this SDRAM controler while running from SDRAM
No, you can't. That part must be done while you run from flash. Actually, this is done in cpu/arm926ejs/at91/lowlevel_init.S, in the table SMRDATA1.
So, with the current code base, you can't autodetect ram size on the atmel 926x.
I have the same problem, as I have boards that ship as either 64M or 128M. I'd configure for 128M and look for aliases, reconfiguring for 64M if needed. This can be done in lowlevel_init.S or by setting up a temporary C environment with sp in static RAM and doing it in C.
In both cases, this doesn't fit the current code base and some refactoring would be needed to go mainline.
/alessandro