YABEL update
[coreboot.git] / src / lib / generic_sdram.c
1
2 #ifndef RAMINIT_SYSINFO
3         #define RAMINIT_SYSINFO 0
4 #endif
5
6 static 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
15 void sdram_no_memory(void)
16 {
17         print_err("No memory!!\r\n");
18         while(1) { 
19                 hlt(); 
20         }
21 }
22
23 /* Setup SDRAM */
24 #if RAMINIT_SYSINFO == 1
25 void sdram_initialize(int controllers, const struct mem_controller *ctrl, void *sysinfo)
26 #else
27 void sdram_initialize(int controllers, const struct mem_controller *ctrl)
28 #endif
29 {
30         int i;
31         /* Set the registers we can set once to reasonable values */
32         for(i = 0; i < controllers; i++) {
33                 print_debug_sdram_8("Ram1.",i);
34
35         #if RAMINIT_SYSINFO == 1
36                 sdram_set_registers(ctrl + i , sysinfo);
37         #else
38                 sdram_set_registers(ctrl + i);
39         #endif
40         }
41
42         /* Now setup those things we can auto detect */
43         for(i = 0; i < controllers; i++) {
44                 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
52         }
53
54         /* Now that everything is setup enable the SDRAM.
55          * Some chipsets do the work for us while on others 
56          * we need to it by hand.
57          */
58         print_debug("Ram3\r\n");
59
60         #if RAMINIT_SYSINFO == 1
61         sdram_enable(controllers, ctrl, sysinfo);
62         #else
63         sdram_enable(controllers, ctrl);
64         #endif
65
66         print_debug("Ram4\r\n");
67 }