printk_foo -> printk(BIOS_FOO, ...)
[coreboot.git] / src / lib / generic_sdram.c
1 #include <lib.h> /* Prototypes */
2
3 #ifndef RAMINIT_SYSINFO
4         #define RAMINIT_SYSINFO 0
5 #endif
6
7 static inline void print_debug_sdram_8(const char *strval, uint32_t val)
8 {
9 #if CONFIG_USE_INIT
10         printk(BIOS_DEBUG, "%s%02x\r\n", strval, val);
11 #else
12         print_debug(strval); print_debug_hex8(val); print_debug("\r\n");
13 #endif
14 }
15
16 /* Setup SDRAM */
17 #if RAMINIT_SYSINFO == 1
18 void sdram_initialize(int controllers, const struct mem_controller *ctrl, void *sysinfo)
19 #else
20 void sdram_initialize(int controllers, const struct mem_controller *ctrl)
21 #endif
22 {
23         int i;
24         /* Set the registers we can set once to reasonable values */
25         for(i = 0; i < controllers; i++) {
26                 print_debug_sdram_8("Ram1.",i);
27
28         #if RAMINIT_SYSINFO == 1
29                 sdram_set_registers(ctrl + i , sysinfo);
30         #else
31                 sdram_set_registers(ctrl + i);
32         #endif
33         }
34
35         /* Now setup those things we can auto detect */
36         for(i = 0; i < controllers; i++) {
37                 print_debug_sdram_8("Ram2.",i);
38
39         #if RAMINIT_SYSINFO == 1
40                 sdram_set_spd_registers(ctrl + i , sysinfo);
41         #else
42                 sdram_set_spd_registers(ctrl + i);
43         #endif
44
45         }
46
47         /* Now that everything is setup enable the SDRAM.
48          * Some chipsets do the work for us while on others 
49          * we need to it by hand.
50          */
51         print_debug("Ram3\r\n");
52
53         #if RAMINIT_SYSINFO == 1
54         sdram_enable(controllers, ctrl, sysinfo);
55         #else
56         sdram_enable(controllers, ctrl);
57         #endif
58
59         print_debug("Ram4\r\n");
60 }