diff options
author | wdenk <wdenk> | 2004-01-06 22:38:14 +0000 |
---|---|---|
committer | wdenk <wdenk> | 2004-01-06 22:38:14 +0000 |
commit | c83bf6a2d00ef846c1fb2b0c60540f03ef203125 (patch) | |
tree | e410334c86d491dbbec765a5765eef9cccd3135a /board/utx8245/utx8245.c | |
parent | b299e41a0d34bf96202d9bbb72739bdd9414b0cc (diff) |
Add a common get_ram_size() function and modify the the
board-specific files to invoke that common implementation.
Diffstat (limited to 'board/utx8245/utx8245.c')
-rw-r--r-- | board/utx8245/utx8245.c | 64 |
1 files changed, 17 insertions, 47 deletions
diff --git a/board/utx8245/utx8245.c b/board/utx8245/utx8245.c index 38c427a4a02..39dc7fb77fe 100644 --- a/board/utx8245/utx8245.c +++ b/board/utx8245/utx8245.c @@ -49,11 +49,10 @@ int checkboard(void) long int initdram(int board_type) { #if 1 - int i, cnt; - volatile uchar *base = CFG_SDRAM_BASE; - volatile ulong *addr; - ulong save[SAVE_SZ]; - ulong val, ret = 0; + long size; + long new_bank0_end; + long mear1; + long emear1; /* write_bat(IBAT1, ((CFG_MAX_RAM_SIZE/2) | BATU_BL_256M | BATU_VS | BATU_VP), ( (CFG_MAX_RAM_SIZE/2)| BATL_PP_10 | BATL_MEMCOHERENCE)); @@ -61,48 +60,19 @@ long int initdram(int board_type) write_bat(DBAT1, ((CFG_MAX_RAM_SIZE/2) | BATU_BL_256M | BATU_VS | BATU_VP), ( (CFG_MAX_RAM_SIZE/2)| BATL_PP_10 | BATL_MEMCOHERENCE)); */ - for (i=0; i<SAVE_SZ; i++) { - save[i] = 0; /* clear table */ - } - - for (i=0, cnt=(CFG_MAX_RAM_SIZE / sizeof(long)) >> 1; cnt > 0; cnt >>= 1) { - addr = (volatile ulong *)base + cnt; - save[i++] = *addr; - *addr = ~cnt; - } - - addr = (volatile ulong *)base; - save[i] = *addr; - *addr = 0; - - if (*addr != 0) { - *addr = save[i]; - goto Done; - } - - for (cnt = 1; cnt < CFG_MAX_RAM_SIZE / sizeof(long); cnt <<= 1) { - addr = (volatile ulong *)base + cnt; - val = *addr; - *addr = save[--i]; - if (val != ~cnt) { - ulong new_bank0_end = cnt * sizeof(long) - 1; - ulong mear1 = mpc824x_mpc107_getreg(MEAR1); - ulong emear1 = mpc824x_mpc107_getreg(EMEAR1); - mear1 = (mear1 & 0xFFFFFF00) | - ((new_bank0_end & MICR_ADDR_MASK) >> MICR_ADDR_SHIFT); - emear1 = (emear1 & 0xFFFFFF00) | - ((new_bank0_end & MICR_ADDR_MASK) >> MICR_EADDR_SHIFT); - mpc824x_mpc107_setreg(MEAR1, mear1); - mpc824x_mpc107_setreg(EMEAR1, emear1); - - ret = cnt * sizeof(long); - goto Done; - } - } - - ret = CFG_MAX_RAM_SIZE; -Done: - return ret; + size = get_ram_size(CFG_SDRAM_BASE, CFG_MAX_RAM_SIZE); + + new_bank0_end = size - 1; + mear1 = mpc824x_mpc107_getreg(MEAR1); + emear1 = mpc824x_mpc107_getreg(EMEAR1); + mear1 = (mear1 & 0xFFFFFF00) | + ((new_bank0_end & MICR_ADDR_MASK) >> MICR_ADDR_SHIFT); + emear1 = (emear1 & 0xFFFFFF00) | + ((new_bank0_end & MICR_ADDR_MASK) >> MICR_EADDR_SHIFT); + mpc824x_mpc107_setreg(MEAR1, mear1); + mpc824x_mpc107_setreg(EMEAR1, emear1); + + return (size); #else return (CFG_MAX_RAM_SIZE); #endif |