Niklaus Giger | 6e5de26 | 2007-07-27 11:30:33 +0200 | [diff] [blame] | 1 | /* |
| 2 | *(C) Copyright 2005-2007 Netstal Maschinen AG |
| 3 | * Niklaus Giger (Niklaus.Giger@netstal.com) |
| 4 | * |
| 5 | * This source code is free software; you can redistribute it |
| 6 | * and/or modify it in source code form under the terms of the GNU |
| 7 | * General Public License as published by the Free Software |
| 8 | * Foundation; either version 2 of the License, or (at your option) |
| 9 | * any later version. |
| 10 | * |
| 11 | * This program is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | * GNU General Public License for more details. |
| 15 | * |
| 16 | * You should have received a copy of the GNU General Public License |
| 17 | * along with this program; if not, write to the Free Software |
| 18 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA |
| 19 | */ |
| 20 | |
| 21 | #include <common.h> |
| 22 | #include <ppc4xx.h> |
| 23 | #include <asm/processor.h> |
| 24 | #include <asm/io.h> |
| 25 | #include <asm-ppc/u-boot.h> |
| 26 | #include "../common/nm_bsp.c" |
| 27 | |
| 28 | DECLARE_GLOBAL_DATA_PTR; |
| 29 | |
Stefan Roese | 35d22f95 | 2007-08-10 10:42:25 +0200 | [diff] [blame] | 30 | #define HCU_MACH_VERSIONS_REGISTER (0x7C000000 + 0xF00000) |
| 31 | |
Stefan Roese | 35d22f95 | 2007-08-10 10:42:25 +0200 | [diff] [blame] | 32 | #define SDRAM_LEN 32*1024*1024 /* 32 MB -RAM */ |
| 33 | |
| 34 | #define DO_UGLY_SDRAM_WORKAROUND |
| 35 | |
| 36 | enum { |
| 37 | /* HW_GENERATION_HCU wird nicht mehr unterstuetzt */ |
| 38 | HW_GENERATION_HCU2 = 0x10, |
| 39 | HW_GENERATION_HCU3 = 0x10, |
| 40 | HW_GENERATION_HCU4 = 0x20, |
| 41 | HW_GENERATION_MCU = 0x08, |
| 42 | HW_GENERATION_MCU20 = 0x0a, |
| 43 | HW_GENERATION_MCU25 = 0x09, |
| 44 | }; |
| 45 | |
Niklaus Giger | 07bc205 | 2007-08-16 15:16:03 +0200 | [diff] [blame^] | 46 | void hcu_led_set(u32 value); |
Stefan Roese | 35d22f95 | 2007-08-10 10:42:25 +0200 | [diff] [blame] | 47 | long int spd_sdram(int(read_spd)(uint addr)); |
| 48 | |
Niklaus Giger | 6e5de26 | 2007-07-27 11:30:33 +0200 | [diff] [blame] | 49 | #ifdef CONFIG_SPD_EEPROM |
Stefan Roese | 35d22f95 | 2007-08-10 10:42:25 +0200 | [diff] [blame] | 50 | #define DEBUG |
Niklaus Giger | 6e5de26 | 2007-07-27 11:30:33 +0200 | [diff] [blame] | 51 | #endif |
| 52 | |
| 53 | #if defined(DEBUG) |
| 54 | void show_sdram_registers(void); |
| 55 | #endif |
| 56 | |
| 57 | /* |
| 58 | * This function is run very early, out of flash, and before devices are |
| 59 | * initialized. It is called by lib_ppc/board.c:board_init_f by virtue |
| 60 | * of being in the init_sequence array. |
| 61 | * |
| 62 | * The SDRAM has been initialized already -- start.S:start called |
| 63 | * init.S:init_sdram early on -- but it is not yet being used for |
| 64 | * anything, not even stack. So be careful. |
| 65 | */ |
| 66 | |
| 67 | #define CPC0_CR0 0xb1 /* Chip control register 0 */ |
| 68 | #define CPC0_CR1 0xb2 /* Chip control register 1 */ |
| 69 | /* Attention: If you want 1 microsecs times from the external oscillator |
| 70 | * use 0x00804051. But this causes problems with u-boot and linux! |
| 71 | */ |
| 72 | #define CPC0_CR1_VALUE 0x00004051 |
| 73 | #define CPC0_ECR 0xaa /* Edge condition register */ |
| 74 | #define EBC0_CFG 0x23 /* External Peripheral Control Register */ |
| 75 | #define CPC0_EIRR 0xb6 /* External Interrupt Register */ |
| 76 | |
| 77 | |
| 78 | int board_early_init_f (void) |
| 79 | { |
| 80 | /*-------------------------------------------------------------------+ |
| 81 | | Interrupt controller setup for the HCU4 board. |
| 82 | | Note: IRQ 0-15 405GP internally generated; high; level sensitive |
| 83 | | IRQ 16 405GP internally generated; low; level sensitive |
| 84 | | IRQ 17-24 RESERVED/UNUSED |
| 85 | | IRQ 31 (EXT IRQ 6) (unused) |
| 86 | +-------------------------------------------------------------------*/ |
| 87 | mtdcr (uicsr, 0xFFFFFFFF); /* clear all ints */ |
| 88 | mtdcr (uicer, 0x00000000); /* disable all ints */ |
| 89 | mtdcr (uiccr, 0x00000000); /* set all to be non-critical */ |
| 90 | mtdcr (uicpr, 0xFFFFFF87); /* set int polarities */ |
| 91 | mtdcr (uictr, 0x10000000); /* set int trigger levels */ |
| 92 | mtdcr (uicsr, 0xFFFFFFFF); /* clear all ints */ |
| 93 | |
| 94 | mtdcr(CPC0_CR1, CPC0_CR1_VALUE); |
| 95 | mtdcr(CPC0_ECR, 0x60606000); |
| 96 | mtdcr(CPC0_EIRR, 0x7c000000); |
| 97 | |
| 98 | return 0; |
| 99 | } |
| 100 | |
| 101 | #ifdef CONFIG_BOARD_PRE_INIT |
| 102 | int board_pre_init (void) |
| 103 | { |
| 104 | return board_early_init_f (); |
| 105 | } |
Niklaus Giger | 6e5de26 | 2007-07-27 11:30:33 +0200 | [diff] [blame] | 106 | #endif |
| 107 | |
Niklaus Giger | 6e5de26 | 2007-07-27 11:30:33 +0200 | [diff] [blame] | 108 | int checkboard (void) |
| 109 | { |
Stefan Roese | 35d22f95 | 2007-08-10 10:42:25 +0200 | [diff] [blame] | 110 | unsigned int j; |
| 111 | u16 *boardVersReg = (u16 *) HCU_MACH_VERSIONS_REGISTER; |
| 112 | u16 generation = *boardVersReg & 0xf0; |
| 113 | u16 index = *boardVersReg & 0x0f; |
| 114 | |
Niklaus Giger | 6e5de26 | 2007-07-27 11:30:33 +0200 | [diff] [blame] | 115 | /* Force /RTS to active. The board it not wired quite |
| 116 | correctly to use cts/rtc flow control, so just force the |
| 117 | /RST active and forget about it. */ |
| 118 | writeb (readb (0xef600404) | 0x03, 0xef600404); |
| 119 | printf ("\nNetstal Maschinen AG "); |
| 120 | if (generation == HW_GENERATION_HCU3) |
| 121 | printf ("HCU3: index %d\n\n", index); |
| 122 | else if (generation == HW_GENERATION_HCU4) |
| 123 | printf ("HCU4: index %d\n\n", index); |
Niklaus Giger | 07bc205 | 2007-08-16 15:16:03 +0200 | [diff] [blame^] | 124 | hcu_led_set(0); |
Stefan Roese | 35d22f95 | 2007-08-10 10:42:25 +0200 | [diff] [blame] | 125 | for (j = 0; j < 7; j++) { |
Niklaus Giger | 07bc205 | 2007-08-16 15:16:03 +0200 | [diff] [blame^] | 126 | hcu_led_set(1 << j); |
Stefan Roese | 35d22f95 | 2007-08-10 10:42:25 +0200 | [diff] [blame] | 127 | udelay(50 * 1000); |
Niklaus Giger | 6e5de26 | 2007-07-27 11:30:33 +0200 | [diff] [blame] | 128 | } |
Stefan Roese | 35d22f95 | 2007-08-10 10:42:25 +0200 | [diff] [blame] | 129 | |
Niklaus Giger | 6e5de26 | 2007-07-27 11:30:33 +0200 | [diff] [blame] | 130 | return 0; |
| 131 | } |
| 132 | |
Niklaus Giger | 07bc205 | 2007-08-16 15:16:03 +0200 | [diff] [blame^] | 133 | u32 hcu_led_get(void) |
Niklaus Giger | 6e5de26 | 2007-07-27 11:30:33 +0200 | [diff] [blame] | 134 | { |
Stefan Roese | 35d22f95 | 2007-08-10 10:42:25 +0200 | [diff] [blame] | 135 | return (~((*(u32 *)GPIO0_OR)) >> 23) & 0xff; |
Niklaus Giger | 6e5de26 | 2007-07-27 11:30:33 +0200 | [diff] [blame] | 136 | } |
| 137 | |
Niklaus Giger | 07bc205 | 2007-08-16 15:16:03 +0200 | [diff] [blame^] | 138 | /*---------------------------------------------------------------------------+ |
| 139 | * hcu_led_set value to be placed into the LEDs (max 6 bit) |
| 140 | *---------------------------------------------------------------------------*/ |
| 141 | void hcu_led_set(u32 value) |
Niklaus Giger | 6e5de26 | 2007-07-27 11:30:33 +0200 | [diff] [blame] | 142 | { |
| 143 | u32 tmp = ~value; |
| 144 | u32 *ledReg; |
Stefan Roese | 35d22f95 | 2007-08-10 10:42:25 +0200 | [diff] [blame] | 145 | |
| 146 | tmp = (tmp << 23) | 0x7FFFFF; |
| 147 | ledReg = (u32 *)GPIO0_OR; |
Niklaus Giger | 6e5de26 | 2007-07-27 11:30:33 +0200 | [diff] [blame] | 148 | *ledReg = tmp; |
| 149 | } |
| 150 | |
| 151 | /* |
| 152 | * sdram_init - Dummy implementation for start.S, spd_sdram or initdram |
| 153 | * used for HCUx |
| 154 | */ |
| 155 | void sdram_init(void) |
| 156 | { |
| 157 | return; |
| 158 | } |
| 159 | |
Niklaus Giger | 6e5de26 | 2007-07-27 11:30:33 +0200 | [diff] [blame] | 160 | #if defined(DEBUG) |
| 161 | void show_sdram_registers(void) |
| 162 | { |
| 163 | u32 value; |
Stefan Roese | 35d22f95 | 2007-08-10 10:42:25 +0200 | [diff] [blame] | 164 | |
Niklaus Giger | 6e5de26 | 2007-07-27 11:30:33 +0200 | [diff] [blame] | 165 | printf ("SDRAM Controller Registers --\n"); |
Stefan Roese | 3b3bff4 | 2007-08-14 16:36:29 +0200 | [diff] [blame] | 166 | mfsdram(mem_mcopt1, value); |
Niklaus Giger | 6e5de26 | 2007-07-27 11:30:33 +0200 | [diff] [blame] | 167 | printf (" SDRAM0_CFG : 0x%08x\n", value); |
Stefan Roese | 3b3bff4 | 2007-08-14 16:36:29 +0200 | [diff] [blame] | 168 | mfsdram(mem_status, value); |
Niklaus Giger | 6e5de26 | 2007-07-27 11:30:33 +0200 | [diff] [blame] | 169 | printf (" SDRAM0_STATUS: 0x%08x\n", value); |
Stefan Roese | 3b3bff4 | 2007-08-14 16:36:29 +0200 | [diff] [blame] | 170 | mfsdram(mem_mb0cf, value); |
Niklaus Giger | 6e5de26 | 2007-07-27 11:30:33 +0200 | [diff] [blame] | 171 | printf (" SDRAM0_B0CR : 0x%08x\n", value); |
Stefan Roese | 3b3bff4 | 2007-08-14 16:36:29 +0200 | [diff] [blame] | 172 | mfsdram(mem_mb1cf, value); |
Niklaus Giger | 6e5de26 | 2007-07-27 11:30:33 +0200 | [diff] [blame] | 173 | printf (" SDRAM0_B1CR : 0x%08x\n", value); |
Stefan Roese | 3b3bff4 | 2007-08-14 16:36:29 +0200 | [diff] [blame] | 174 | mfsdram(mem_sdtr1, value); |
Niklaus Giger | 6e5de26 | 2007-07-27 11:30:33 +0200 | [diff] [blame] | 175 | printf (" SDRAM0_TR : 0x%08x\n", value); |
Stefan Roese | 3b3bff4 | 2007-08-14 16:36:29 +0200 | [diff] [blame] | 176 | mfsdram(mem_rtr, value); |
Niklaus Giger | 6e5de26 | 2007-07-27 11:30:33 +0200 | [diff] [blame] | 177 | printf (" SDRAM0_RTR : 0x%08x\n", value); |
| 178 | } |
| 179 | #endif |
| 180 | |
Niklaus Giger | 6e5de26 | 2007-07-27 11:30:33 +0200 | [diff] [blame] | 181 | /* |
| 182 | * this is even after checkboard. It returns the size of the SDRAM |
| 183 | * that we have installed. This function is called by board_init_f |
| 184 | * in lib_ppc/board.c to initialize the memory and return what I |
| 185 | * found. These are default value, which will be overridden later. |
| 186 | */ |
| 187 | |
| 188 | long int fixed_hcu4_sdram (int board_type) |
| 189 | { |
| 190 | #ifdef DEBUG |
| 191 | printf (__FUNCTION__); |
| 192 | #endif |
| 193 | /* disable memory controller */ |
| 194 | mtdcr (memcfga, mem_mcopt1); |
| 195 | mtdcr (memcfgd, 0x00000000); |
| 196 | |
| 197 | udelay (500); |
| 198 | |
| 199 | /* Clear SDRAM0_BESR0 (Bus Error Syndrome Register) */ |
| 200 | mtdcr (memcfga, mem_besra); |
| 201 | mtdcr (memcfgd, 0xffffffff); |
| 202 | |
| 203 | /* Clear SDRAM0_BESR1 (Bus Error Syndrome Register) */ |
| 204 | mtdcr (memcfga, mem_besrb); |
| 205 | mtdcr (memcfgd, 0xffffffff); |
| 206 | |
| 207 | /* Clear SDRAM0_ECCCFG (disable ECC) */ |
| 208 | mtdcr (memcfga, mem_ecccf); |
| 209 | mtdcr (memcfgd, 0x00000000); |
| 210 | |
| 211 | /* Clear SDRAM0_ECCESR (ECC Error Syndrome Register) */ |
| 212 | mtdcr (memcfga, mem_eccerr); |
| 213 | mtdcr (memcfgd, 0xffffffff); |
| 214 | |
| 215 | /* Timing register: CASL=2, PTA=2, CTP=2, LDF=1, RFTA=5, RCD=2 |
| 216 | * TODO ngngng |
| 217 | */ |
| 218 | mtdcr (memcfga, mem_sdtr1); |
| 219 | mtdcr (memcfgd, 0x008a4015); |
| 220 | |
| 221 | /* Memory Bank 0 Config == BA=0x00000000, SZ=64M, AM=3, BE=1 |
| 222 | * TODO ngngng |
| 223 | */ |
| 224 | mtdcr (memcfga, mem_mb0cf); |
| 225 | mtdcr (memcfgd, 0x00062001); |
| 226 | |
| 227 | /* refresh timer = 0x400 */ |
| 228 | mtdcr (memcfga, mem_rtr); |
| 229 | mtdcr (memcfgd, 0x04000000); |
| 230 | |
| 231 | /* Power management idle timer set to the default. */ |
| 232 | mtdcr (memcfga, mem_pmit); |
| 233 | mtdcr (memcfgd, 0x07c00000); |
| 234 | |
| 235 | udelay (500); |
| 236 | |
| 237 | /* Enable banks (DCE=1, BPRF=1, ECCDD=1, EMDUL=1) TODO */ |
| 238 | mtdcr (memcfga, mem_mcopt1); |
| 239 | mtdcr (memcfgd, 0x90800000); |
| 240 | |
| 241 | #ifdef DEBUG |
| 242 | printf ("%s: done\n", __FUNCTION__); |
| 243 | #endif |
| 244 | return SDRAM_LEN; |
| 245 | } |
| 246 | |
| 247 | /*---------------------------------------------------------------------------+ |
Niklaus Giger | 07bc205 | 2007-08-16 15:16:03 +0200 | [diff] [blame^] | 248 | * hcu_serial_number |
Niklaus Giger | 6e5de26 | 2007-07-27 11:30:33 +0200 | [diff] [blame] | 249 | *---------------------------------------------------------------------------*/ |
Niklaus Giger | 07bc205 | 2007-08-16 15:16:03 +0200 | [diff] [blame^] | 250 | static u32 hcu_serial_number(void) |
Niklaus Giger | 6e5de26 | 2007-07-27 11:30:33 +0200 | [diff] [blame] | 251 | { |
| 252 | u32 *serial = (u32 *)CFG_FLASH_BASE; |
Stefan Roese | 35d22f95 | 2007-08-10 10:42:25 +0200 | [diff] [blame] | 253 | |
| 254 | if (*serial == 0xffffffff) |
Niklaus Giger | 6e5de26 | 2007-07-27 11:30:33 +0200 | [diff] [blame] | 255 | return get_ticks(); |
Stefan Roese | 35d22f95 | 2007-08-10 10:42:25 +0200 | [diff] [blame] | 256 | |
Niklaus Giger | 6e5de26 | 2007-07-27 11:30:33 +0200 | [diff] [blame] | 257 | return *serial; |
| 258 | } |
| 259 | |
| 260 | |
| 261 | /*---------------------------------------------------------------------------+ |
| 262 | * misc_init_r. |
| 263 | *---------------------------------------------------------------------------*/ |
| 264 | |
| 265 | int misc_init_r(void) |
| 266 | { |
| 267 | char *s = getenv("ethaddr"); |
| 268 | char *e; |
| 269 | int i; |
Niklaus Giger | 07bc205 | 2007-08-16 15:16:03 +0200 | [diff] [blame^] | 270 | u32 serial = hcu_serial_number(); |
Stefan Roese | 35d22f95 | 2007-08-10 10:42:25 +0200 | [diff] [blame] | 271 | |
Niklaus Giger | 6e5de26 | 2007-07-27 11:30:33 +0200 | [diff] [blame] | 272 | for (i = 0; i < 6; ++i) { |
| 273 | gd->bd->bi_enetaddr[i] = s ? simple_strtoul (s, &e, 16) : 0; |
| 274 | if (s) |
| 275 | s = (*e) ? e + 1 : e; |
| 276 | } |
Stefan Roese | 35d22f95 | 2007-08-10 10:42:25 +0200 | [diff] [blame] | 277 | |
Niklaus Giger | 6e5de26 | 2007-07-27 11:30:33 +0200 | [diff] [blame] | 278 | if (gd->bd->bi_enetaddr[3] == 0 && |
| 279 | gd->bd->bi_enetaddr[4] == 0 && |
| 280 | gd->bd->bi_enetaddr[5] == 0) { |
| 281 | char ethaddr[22]; |
| 282 | /* [0..3] Must be in sync with CONFIG_ETHADDR */ |
| 283 | gd->bd->bi_enetaddr[0] = 0x00; |
| 284 | gd->bd->bi_enetaddr[1] = 0x60; |
| 285 | gd->bd->bi_enetaddr[2] = 0x13; |
| 286 | gd->bd->bi_enetaddr[3] = (serial >> 16) & 0xff; |
| 287 | gd->bd->bi_enetaddr[4] = (serial >> 8) & 0xff; |
| 288 | gd->bd->bi_enetaddr[5] = (serial >> 0) & 0xff; |
| 289 | sprintf (ethaddr, "%02X:%02X:%02X:%02X:%02X:%02X\0", |
| 290 | gd->bd->bi_enetaddr[0], gd->bd->bi_enetaddr[1], |
| 291 | gd->bd->bi_enetaddr[2], gd->bd->bi_enetaddr[3], |
| 292 | gd->bd->bi_enetaddr[4], gd->bd->bi_enetaddr[5]) ; |
| 293 | printf("%s: Setting eth %s serial 0x%x\n", __FUNCTION__, |
| 294 | ethaddr, serial); |
| 295 | setenv ("ethaddr", ethaddr); |
| 296 | } |
| 297 | return 0; |
| 298 | } |
| 299 | |
Niklaus Giger | 6e5de26 | 2007-07-27 11:30:33 +0200 | [diff] [blame] | 300 | #ifdef DO_UGLY_SDRAM_WORKAROUND |
Stefan Roese | 35d22f95 | 2007-08-10 10:42:25 +0200 | [diff] [blame] | 301 | #include "i2c.h" |
| 302 | |
Niklaus Giger | 6e5de26 | 2007-07-27 11:30:33 +0200 | [diff] [blame] | 303 | void set_spd_default_value(unsigned int spd_addr,uchar def_val) |
| 304 | { |
| 305 | uchar value; |
| 306 | int res = i2c_read(SPD_EEPROM_ADDRESS, spd_addr, 1, &value, 1) ; |
Stefan Roese | 35d22f95 | 2007-08-10 10:42:25 +0200 | [diff] [blame] | 307 | |
Niklaus Giger | 6e5de26 | 2007-07-27 11:30:33 +0200 | [diff] [blame] | 308 | if (res == 0 && value == 0xff) { |
| 309 | res = i2c_write(SPD_EEPROM_ADDRESS, |
| 310 | spd_addr, 1, &def_val, 1) ; |
| 311 | #ifdef DEBUG |
| 312 | printf("%s: Setting spd offset %3d to %3d res %d\n", |
| 313 | __FUNCTION__, spd_addr, def_val, res); |
| 314 | #endif |
| 315 | } |
| 316 | } |
| 317 | #endif |
| 318 | |
| 319 | long int initdram(int board_type) |
| 320 | { |
| 321 | long dram_size = 0; |
| 322 | |
| 323 | #if !defined(CONFIG_SPD_EEPROM) |
| 324 | dram_size = fixed_hcu4_sdram(); |
| 325 | #else |
| 326 | #ifdef DO_UGLY_SDRAM_WORKAROUND |
| 327 | /* Workaround if you have no working I2C-EEPROM-SPD-configuration */ |
| 328 | i2c_init(CFG_I2C_SPEED, CFG_I2C_SLAVE); |
| 329 | set_spd_default_value(2, 4); /* SDRAM Type */ |
| 330 | set_spd_default_value(7, 0); /* module width, high byte */ |
| 331 | set_spd_default_value(12, 1); /* Refresh or 0x81 */ |
| 332 | |
| 333 | /* Only correct for HCU3 with 32 MB RAM*/ |
| 334 | /* Number of bytes used by module manufacturer */ |
| 335 | set_spd_default_value( 0, 128); |
| 336 | set_spd_default_value( 1, 11 ); /* Total SPD memory size */ |
| 337 | set_spd_default_value( 2, 4 ); /* Memory type */ |
| 338 | set_spd_default_value( 3, 12 ); /* Number of row address bits */ |
| 339 | set_spd_default_value( 4, 9 ); /* Number of column address bits */ |
| 340 | set_spd_default_value( 5, 1 ); /* Number of module rows */ |
| 341 | set_spd_default_value( 6, 32 ); /* Module data width, LSB */ |
| 342 | set_spd_default_value( 7, 0 ); /* Module data width, MSB */ |
| 343 | set_spd_default_value( 8, 1 ); /* Module interface signal levels */ |
| 344 | /* SDRAM cycle time for highest CL (Tclk) */ |
| 345 | set_spd_default_value( 9, 112); |
| 346 | /* SDRAM access time from clock for highest CL (Tac) */ |
| 347 | set_spd_default_value(10, 84 ); |
| 348 | set_spd_default_value(11, 2 ); /* Module configuration type */ |
| 349 | set_spd_default_value(12, 128); /* Refresh rate/type */ |
| 350 | set_spd_default_value(13, 16 ); /* Primary SDRAM width */ |
| 351 | set_spd_default_value(14, 8 ); /* Error Checking SDRAM width */ |
| 352 | /* SDRAM device attributes, min clock delay for back to back */ |
| 353 | /*random column addresses (Tccd) */ |
| 354 | set_spd_default_value(15, 1 ); |
| 355 | /* SDRAM device attributes, burst lengths supported */ |
| 356 | set_spd_default_value(16, 143); |
| 357 | /* SDRAM device attributes, number of banks on SDRAM device */ |
| 358 | set_spd_default_value(17, 4 ); |
| 359 | /* SDRAM device attributes, CAS latency */ |
| 360 | set_spd_default_value(18, 6 ); |
| 361 | /* SDRAM device attributes, CS latency */ |
| 362 | set_spd_default_value(19, 1 ); |
| 363 | /* SDRAM device attributes, WE latency */ |
| 364 | set_spd_default_value(20, 1 ); |
| 365 | set_spd_default_value(21, 0 ); /* SDRAM module attributes */ |
| 366 | /* SDRAM device attributes, general */ |
| 367 | set_spd_default_value(22, 14 ); |
| 368 | /* SDRAM cycle time for 2nd highest CL (Tclk) */ |
| 369 | set_spd_default_value(23, 117); |
| 370 | /* SDRAM access time from clock for2nd highest CL (Tac) */ |
| 371 | set_spd_default_value(24, 84 ); |
| 372 | /* SDRAM cycle time for 3rd highest CL (Tclk) */ |
| 373 | set_spd_default_value(25, 0 ); |
| 374 | /* SDRAM access time from clock for3rd highest CL (Tac) */ |
| 375 | set_spd_default_value(26, 0 ); |
| 376 | set_spd_default_value(27, 15 ); /* Minimum row precharge time (Trp) */ |
| 377 | /* Minimum row active to row active delay (Trrd) */ |
| 378 | set_spd_default_value(28, 14 ); |
| 379 | set_spd_default_value(29, 15 ); /* Minimum CAS to RAS delay (Trcd) */ |
| 380 | set_spd_default_value(30, 37 ); /* Minimum RAS pulse width (Tras) */ |
| 381 | set_spd_default_value(31, 8 ); /* Module bank density */ |
| 382 | /* Command and Address signal input setup time */ |
| 383 | set_spd_default_value(32, 21 ); |
| 384 | /* Command and Address signal input hold time */ |
| 385 | set_spd_default_value(33, 8 ); |
| 386 | set_spd_default_value(34, 21 ); /* Data signal input setup time */ |
| 387 | set_spd_default_value(35, 8 ); /* Data signal input hold time */ |
| 388 | #endif /* DO_UGLY_SDRAM_WORKAROUND */ |
| 389 | dram_size = spd_sdram(0); |
| 390 | #endif |
| 391 | |
| 392 | #ifdef DEBUG |
| 393 | show_sdram_registers(); |
| 394 | #endif |
| 395 | |
| 396 | #if defined(CFG_DRAM_TEST) |
| 397 | bcu4_testdram(dram_size); |
| 398 | printf("%s %d MB of SDRAM\n", __FUNCTION__, dram_size/(1024*1024)); |
| 399 | #endif |
Stefan Roese | 35d22f95 | 2007-08-10 10:42:25 +0200 | [diff] [blame] | 400 | |
Niklaus Giger | 6e5de26 | 2007-07-27 11:30:33 +0200 | [diff] [blame] | 401 | return dram_size; |
| 402 | } |