board_f: Drop return value from initdram()
[oweals/u-boot.git] / arch / powerpc / cpu / ppc4xx / 44x_spd_ddr2.c
index 71bb9d776fa59c24303d985d21a269e10938a344..87fd5e65e0210cdbce4b5f5e4cf46629b8b5bf91 100644 (file)
@@ -33,6 +33,8 @@
 
 #include "ecc.h"
 
+DECLARE_GLOBAL_DATA_PTR;
+
 #define PPC4xx_IBM_DDR2_DUMP_REGISTER(mnemonic)                                \
        do {                                                            \
                u32 data;                                               \
@@ -414,7 +416,7 @@ static unsigned char spd_read(uchar chip, uint addr)
  *              banks appropriately. If Auto Memory Configuration is
  *              not used, it is assumed that no DIMM is plugged
  *-----------------------------------------------------------------------------*/
-phys_size_t initdram(int board_type)
+int initdram(void)
 {
        unsigned char iic0_dimm_addr[] = SPD_EEPROM_ADDRESS;
        unsigned long dimm_populated[MAXDIMMS] = {SDRAM_NONE, SDRAM_NONE};
@@ -424,6 +426,16 @@ phys_size_t initdram(int board_type)
        int write_recovery;
        phys_size_t dram_size = 0;
 
+       if (IS_ENABLED(CONFIG_SYS_RAMBOOT)) {
+               /*
+                * Reduce RAM size to avoid overwriting memory used by
+                * current stack? Not sure what is happening.
+                */
+               gd->ram_size = sdram_memsize() / 2;
+
+               return 0;
+       }
+
        num_dimm_banks = sizeof(iic0_dimm_addr);
 
        /*------------------------------------------------------------------
@@ -642,7 +654,9 @@ phys_size_t initdram(int board_type)
         */
        set_mcsr(get_mcsr());
 
-       return sdram_memsize();
+       gd->ram_size = sdram_memsize();
+
+       return 0;
 }
 
 static void get_spd_info(unsigned long *dimm_populated,
@@ -2847,7 +2861,7 @@ static void test(void)
  *             time parameters.
  *             Configures the PPC405EX(r) and PPC460EX/GT
  *---------------------------------------------------------------------------*/
-phys_size_t initdram(int board_type)
+int initdram(void)
 {
        unsigned long val;
 
@@ -3003,7 +3017,9 @@ phys_size_t initdram(int board_type)
        set_mcsr(get_mcsr());
 #endif /* CONFIG_PPC4xx_DDR_AUTOCALIBRATION */
 
-       return (CONFIG_SYS_MBYTES_SDRAM << 20);
+       gd->ram_size = CONFIG_SYS_MBYTES_SDRAM << 20;
+
+       return 0;
 }
 #endif /* CONFIG_SPD_EEPROM */