/* Exception, Offset 0x3C */
0xfffffc04, 0xfffffc05, _NOT_USED_, _NOT_USED_ };
-int _initsdram(uint base, uint noMbytes){
+int _initsdram(uint base, uint *noMbytes){
volatile immap_t *immap = (immap_t *)CFG_IMMR;
volatile memctl8xx_t *mc = &immap->im_memctl;
+ volatile u32 *memptr;
mc->memc_mptpr = MPTPR_PTP_DIV16; /* (16-17) */
/* Lower 2 bits are not connected to chip */
mc->memc_mcr = 0x80002114; /* run upm a at 0x14 (16-15) */
- /* FIXME when not 32MB */
- /* CS1, base 0x0000000 - 32 Mbyte, use UPM A */
-
- mc->memc_or1 = 0xfe000000|OR_CSNT_SAM;
+ /* CS1, base 0x0000000 - 64 Mbyte, use UPM A */
+ mc->memc_or1 = 0xfc000000|OR_CSNT_SAM;
mc->memc_br1 = BR_MS_UPMA|BR_V; /* SDRAM base always 0 */
+ /* Test if we really have 64 MB SDRAM */
+ memptr = (u32*)0;
+ *memptr = 0;
+
+ memptr = (u32*)0x2000000; /* First u32 in upper 32 MB */
+ *memptr = 0x12345678;
+
+ memptr = (u32*)0;
+ if(*memptr==0x12345678){
+ /* Wrapped, only have 32 MB */
+ mc->memc_or1 = 0xfe000000|OR_CSNT_SAM;
+ *noMbytes=32;
+ }
+ else{
+ /* 64 MB */
+ *noMbytes=64;
+ }
+
/* Setup FPGA in UPMB */
upmconfig(UPMB, (uint *)fpga_table,sizeof(fpga_table)/sizeof(uint));
int initsdram(uint base, uint *noMbytes)
{
- uint m;
-
*noMbytes = 32;
#ifdef CONFIG_START_IN_RAM
return 0;
#else
- if(!_initsdram(base, m))
+ if(!_initsdram(base, noMbytes))
{
return 0;
*(i+1) = ~(j+(j<<18));
}
+#if defined(CONFIG_WATCHDOG)
+ watchdog_reset ();
+#endif /* CONFIG_WATCHDOG */
+
printf(".");
for(i=(u32*)0,j=0;(u32)i<U32_S;i+=2,j+=2){
}
#endif
+#if defined(CONFIG_WATCHDOG)
+ watchdog_reset ();
+#endif /* CONFIG_WATCHDOG */
+
/* Clear memory */
for(i=(u32*)0;(u32)i<U32_S;i++){
*i = 0;
}
#endif /* !start in ram */
+#if defined(CONFIG_WATCHDOG)
+ watchdog_reset ();
+#endif /* CONFIG_WATCHDOG */
+
return (sdramsz << 20);
}