Stefan Reinauer | 7ce8c54 | 2005-12-02 21:52:30 +0000 | [diff] [blame] | 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 | |
Eric Biederman | 8ca8d76 | 2003-04-22 19:02:15 +0000 | [diff] [blame] | 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 */ |
Stefan Reinauer | 7ce8c54 | 2005-12-02 21:52:30 +0000 | [diff] [blame] | 24 | #if RAMINIT_SYSINFO == 1 |
| 25 | void sdram_initialize(int controllers, const struct mem_controller *ctrl, void *sysinfo) |
| 26 | #else |
Eric Biederman | 2c018fb | 2003-07-21 20:13:45 +0000 | [diff] [blame] | 27 | void sdram_initialize(int controllers, const struct mem_controller *ctrl) |
Stefan Reinauer | 7ce8c54 | 2005-12-02 21:52:30 +0000 | [diff] [blame] | 28 | #endif |
Eric Biederman | 8ca8d76 | 2003-04-22 19:02:15 +0000 | [diff] [blame] | 29 | { |
Eric Biederman | 2c018fb | 2003-07-21 20:13:45 +0000 | [diff] [blame] | 30 | int i; |
Eric Biederman | 8ca8d76 | 2003-04-22 19:02:15 +0000 | [diff] [blame] | 31 | /* Set the registers we can set once to reasonable values */ |
Eric Biederman | 2c018fb | 2003-07-21 20:13:45 +0000 | [diff] [blame] | 32 | for(i = 0; i < controllers; i++) { |
Stefan Reinauer | 7ce8c54 | 2005-12-02 21:52:30 +0000 | [diff] [blame] | 33 | print_debug_sdram_8("Ram1.",i); |
| 34 | |
| 35 | #if RAMINIT_SYSINFO == 1 |
| 36 | sdram_set_registers(ctrl + i , sysinfo); |
| 37 | #else |
Eric Biederman | 2c018fb | 2003-07-21 20:13:45 +0000 | [diff] [blame] | 38 | sdram_set_registers(ctrl + i); |
Stefan Reinauer | 7ce8c54 | 2005-12-02 21:52:30 +0000 | [diff] [blame] | 39 | #endif |
Eric Biederman | 2c018fb | 2003-07-21 20:13:45 +0000 | [diff] [blame] | 40 | } |
Eric Biederman | 8ca8d76 | 2003-04-22 19:02:15 +0000 | [diff] [blame] | 41 | |
Eric Biederman | 8ca8d76 | 2003-04-22 19:02:15 +0000 | [diff] [blame] | 42 | /* Now setup those things we can auto detect */ |
Eric Biederman | 2c018fb | 2003-07-21 20:13:45 +0000 | [diff] [blame] | 43 | for(i = 0; i < controllers; i++) { |
Stefan Reinauer | 7ce8c54 | 2005-12-02 21:52:30 +0000 | [diff] [blame] | 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 | |
Eric Biederman | 2c018fb | 2003-07-21 20:13:45 +0000 | [diff] [blame] | 52 | } |
Eric Biederman | 8ca8d76 | 2003-04-22 19:02:15 +0000 | [diff] [blame] | 53 | |
Eric Biederman | 8ca8d76 | 2003-04-22 19:02:15 +0000 | [diff] [blame] | 54 | /* Now that everything is setup enable the SDRAM. |
Stefan Reinauer | bba53ed | 2008-08-01 11:36:40 +0000 | [diff] [blame^] | 55 | * Some chipsets do the work for us while on others |
Eric Biederman | 8ca8d76 | 2003-04-22 19:02:15 +0000 | [diff] [blame] | 56 | * we need to it by hand. |
| 57 | */ |
Eric Biederman | 2c018fb | 2003-07-21 20:13:45 +0000 | [diff] [blame] | 58 | print_debug("Ram3\r\n"); |
Stefan Reinauer | 7ce8c54 | 2005-12-02 21:52:30 +0000 | [diff] [blame] | 59 | |
| 60 | #if RAMINIT_SYSINFO == 1 |
| 61 | sdram_enable(controllers, ctrl, sysinfo); |
| 62 | #else |
Eric Biederman | 2c018fb | 2003-07-21 20:13:45 +0000 | [diff] [blame] | 63 | sdram_enable(controllers, ctrl); |
Stefan Reinauer | 7ce8c54 | 2005-12-02 21:52:30 +0000 | [diff] [blame] | 64 | #endif |
Eric Biederman | 8ca8d76 | 2003-04-22 19:02:15 +0000 | [diff] [blame] | 65 | |
| 66 | print_debug("Ram4\r\n"); |
Eric Biederman | 8ca8d76 | 2003-04-22 19:02:15 +0000 | [diff] [blame] | 67 | } |