Myles Watson | 3426195 | 2010-03-19 02:33:40 +0000 | [diff] [blame] | 1 | #include <lib.h> /* Prototypes */ |
Stefan Reinauer | 7ce8c54 | 2005-12-02 21:52:30 +0000 | [diff] [blame] | 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 | { |
Stefan Reinauer | 704b596 | 2010-08-30 17:53:13 +0000 | [diff] [blame] | 9 | #if CONFIG_CACHE_AS_RAM |
Stefan Reinauer | f2b7a43 | 2010-03-30 22:21:06 +0000 | [diff] [blame] | 10 | printk(BIOS_DEBUG, "%s%02x\n", strval, val); |
Stefan Reinauer | 7ce8c54 | 2005-12-02 21:52:30 +0000 | [diff] [blame] | 11 | #else |
Stefan Reinauer | 64ed2b7 | 2010-03-31 14:47:43 +0000 | [diff] [blame] | 12 | print_debug(strval); print_debug_hex8(val); print_debug("\n"); |
Stefan Reinauer | 7ce8c54 | 2005-12-02 21:52:30 +0000 | [diff] [blame] | 13 | #endif |
| 14 | } |
| 15 | |
Eric Biederman | 8ca8d76 | 2003-04-22 19:02:15 +0000 | [diff] [blame] | 16 | /* Setup SDRAM */ |
Stefan Reinauer | 7ce8c54 | 2005-12-02 21:52:30 +0000 | [diff] [blame] | 17 | #if RAMINIT_SYSINFO == 1 |
| 18 | void sdram_initialize(int controllers, const struct mem_controller *ctrl, void *sysinfo) |
| 19 | #else |
Eric Biederman | 2c018fb | 2003-07-21 20:13:45 +0000 | [diff] [blame] | 20 | void sdram_initialize(int controllers, const struct mem_controller *ctrl) |
Stefan Reinauer | 7ce8c54 | 2005-12-02 21:52:30 +0000 | [diff] [blame] | 21 | #endif |
Eric Biederman | 8ca8d76 | 2003-04-22 19:02:15 +0000 | [diff] [blame] | 22 | { |
Eric Biederman | 2c018fb | 2003-07-21 20:13:45 +0000 | [diff] [blame] | 23 | int i; |
Eric Biederman | 8ca8d76 | 2003-04-22 19:02:15 +0000 | [diff] [blame] | 24 | /* Set the registers we can set once to reasonable values */ |
Eric Biederman | 2c018fb | 2003-07-21 20:13:45 +0000 | [diff] [blame] | 25 | for(i = 0; i < controllers; i++) { |
Stefan Reinauer | f2b7a43 | 2010-03-30 22:21:06 +0000 | [diff] [blame] | 26 | print_debug_sdram_8("Ram1.", i); |
Stefan Reinauer | 7ce8c54 | 2005-12-02 21:52:30 +0000 | [diff] [blame] | 27 | |
| 28 | #if RAMINIT_SYSINFO == 1 |
Stefan Reinauer | f2b7a43 | 2010-03-30 22:21:06 +0000 | [diff] [blame] | 29 | sdram_set_registers(ctrl + i, sysinfo); |
Stefan Reinauer | 7ce8c54 | 2005-12-02 21:52:30 +0000 | [diff] [blame] | 30 | #else |
Eric Biederman | 2c018fb | 2003-07-21 20:13:45 +0000 | [diff] [blame] | 31 | sdram_set_registers(ctrl + i); |
Stefan Reinauer | 7ce8c54 | 2005-12-02 21:52:30 +0000 | [diff] [blame] | 32 | #endif |
Eric Biederman | 2c018fb | 2003-07-21 20:13:45 +0000 | [diff] [blame] | 33 | } |
Eric Biederman | 8ca8d76 | 2003-04-22 19:02:15 +0000 | [diff] [blame] | 34 | |
Eric Biederman | 8ca8d76 | 2003-04-22 19:02:15 +0000 | [diff] [blame] | 35 | /* Now setup those things we can auto detect */ |
Eric Biederman | 2c018fb | 2003-07-21 20:13:45 +0000 | [diff] [blame] | 36 | for(i = 0; i < controllers; i++) { |
Stefan Reinauer | f2b7a43 | 2010-03-30 22:21:06 +0000 | [diff] [blame] | 37 | print_debug_sdram_8("Ram2.", i); |
Stefan Reinauer | 7ce8c54 | 2005-12-02 21:52:30 +0000 | [diff] [blame] | 38 | |
| 39 | #if RAMINIT_SYSINFO == 1 |
Stefan Reinauer | f2b7a43 | 2010-03-30 22:21:06 +0000 | [diff] [blame] | 40 | sdram_set_spd_registers(ctrl + i, sysinfo); |
Stefan Reinauer | 7ce8c54 | 2005-12-02 21:52:30 +0000 | [diff] [blame] | 41 | #else |
| 42 | sdram_set_spd_registers(ctrl + i); |
| 43 | #endif |
| 44 | |
Eric Biederman | 2c018fb | 2003-07-21 20:13:45 +0000 | [diff] [blame] | 45 | } |
Eric Biederman | 8ca8d76 | 2003-04-22 19:02:15 +0000 | [diff] [blame] | 46 | |
Eric Biederman | 8ca8d76 | 2003-04-22 19:02:15 +0000 | [diff] [blame] | 47 | /* Now that everything is setup enable the SDRAM. |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 48 | * Some chipsets do the work for us while on others |
Eric Biederman | 8ca8d76 | 2003-04-22 19:02:15 +0000 | [diff] [blame] | 49 | * we need to it by hand. |
| 50 | */ |
Stefan Reinauer | 64ed2b7 | 2010-03-31 14:47:43 +0000 | [diff] [blame] | 51 | print_debug("Ram3\n"); |
Stefan Reinauer | 7ce8c54 | 2005-12-02 21:52:30 +0000 | [diff] [blame] | 52 | |
| 53 | #if RAMINIT_SYSINFO == 1 |
| 54 | sdram_enable(controllers, ctrl, sysinfo); |
| 55 | #else |
Eric Biederman | 2c018fb | 2003-07-21 20:13:45 +0000 | [diff] [blame] | 56 | sdram_enable(controllers, ctrl); |
Stefan Reinauer | 7ce8c54 | 2005-12-02 21:52:30 +0000 | [diff] [blame] | 57 | #endif |
Eric Biederman | 8ca8d76 | 2003-04-22 19:02:15 +0000 | [diff] [blame] | 58 | |
Stefan Reinauer | 64ed2b7 | 2010-03-31 14:47:43 +0000 | [diff] [blame] | 59 | print_debug("Ram4\n"); |
Eric Biederman | 8ca8d76 | 2003-04-22 19:02:15 +0000 | [diff] [blame] | 60 | } |