blob: cdb06cd73fa324d1d2fc88e918f68b125ca8db83 [file] [log] [blame]
Stefan Reinauer7ce8c542005-12-02 21:52:30 +00001
2#ifndef RAMINIT_SYSINFO
3 #define RAMINIT_SYSINFO 0
4#endif
5
6static inline void print_debug_sdram_8(const char *strval, uint32_t val)
7{
8#if CONFIG_USE_INIT
9 printk_debug("%s%02x\r\n", strval, val);
10#else
11 print_debug(strval); print_debug_hex8(val); print_debug("\r\n");
12#endif
13}
14
Eric Biederman8ca8d762003-04-22 19:02:15 +000015void sdram_no_memory(void)
16{
17 print_err("No memory!!\r\n");
18 while(1) {
19 hlt();
20 }
21}
22
23/* Setup SDRAM */
Stefan Reinauer7ce8c542005-12-02 21:52:30 +000024#if RAMINIT_SYSINFO == 1
25void sdram_initialize(int controllers, const struct mem_controller *ctrl, void *sysinfo)
26#else
Eric Biederman2c018fb2003-07-21 20:13:45 +000027void sdram_initialize(int controllers, const struct mem_controller *ctrl)
Stefan Reinauer7ce8c542005-12-02 21:52:30 +000028#endif
Eric Biederman8ca8d762003-04-22 19:02:15 +000029{
Eric Biederman2c018fb2003-07-21 20:13:45 +000030 int i;
Eric Biederman8ca8d762003-04-22 19:02:15 +000031 /* Set the registers we can set once to reasonable values */
Eric Biederman2c018fb2003-07-21 20:13:45 +000032 for(i = 0; i < controllers; i++) {
Stefan Reinauer7ce8c542005-12-02 21:52:30 +000033 print_debug_sdram_8("Ram1.",i);
34
35 #if RAMINIT_SYSINFO == 1
36 sdram_set_registers(ctrl + i , sysinfo);
37 #else
Eric Biederman2c018fb2003-07-21 20:13:45 +000038 sdram_set_registers(ctrl + i);
Stefan Reinauer7ce8c542005-12-02 21:52:30 +000039 #endif
Eric Biederman2c018fb2003-07-21 20:13:45 +000040 }
Eric Biederman8ca8d762003-04-22 19:02:15 +000041
Eric Biederman8ca8d762003-04-22 19:02:15 +000042 /* Now setup those things we can auto detect */
Eric Biederman2c018fb2003-07-21 20:13:45 +000043 for(i = 0; i < controllers; i++) {
Stefan Reinauer7ce8c542005-12-02 21:52:30 +000044 print_debug_sdram_8("Ram2.",i);
45
46 #if RAMINIT_SYSINFO == 1
47 sdram_set_spd_registers(ctrl + i , sysinfo);
48 #else
49 sdram_set_spd_registers(ctrl + i);
50 #endif
51
Eric Biederman2c018fb2003-07-21 20:13:45 +000052 }
Eric Biederman8ca8d762003-04-22 19:02:15 +000053
Eric Biederman8ca8d762003-04-22 19:02:15 +000054 /* Now that everything is setup enable the SDRAM.
Stefan Reinauerbba53ed2008-08-01 11:36:40 +000055 * Some chipsets do the work for us while on others
Eric Biederman8ca8d762003-04-22 19:02:15 +000056 * we need to it by hand.
57 */
Eric Biederman2c018fb2003-07-21 20:13:45 +000058 print_debug("Ram3\r\n");
Stefan Reinauer7ce8c542005-12-02 21:52:30 +000059
60 #if RAMINIT_SYSINFO == 1
61 sdram_enable(controllers, ctrl, sysinfo);
62 #else
Eric Biederman2c018fb2003-07-21 20:13:45 +000063 sdram_enable(controllers, ctrl);
Stefan Reinauer7ce8c542005-12-02 21:52:30 +000064 #endif
Eric Biederman8ca8d762003-04-22 19:02:15 +000065
66 print_debug("Ram4\r\n");
Eric Biederman8ca8d762003-04-22 19:02:15 +000067}