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 | |
Eric Biederman | 8ca8d76 | 2003-04-22 19:02:15 +0000 | [diff] [blame] | 3 | /* Setup SDRAM */ |
Jonathan Kollasch | e5b7507 | 2010-10-07 23:02:06 +0000 | [diff] [blame] | 4 | #if CONFIG_RAMINIT_SYSINFO |
Stefan Reinauer | 7ce8c54 | 2005-12-02 21:52:30 +0000 | [diff] [blame] | 5 | void sdram_initialize(int controllers, const struct mem_controller *ctrl, void *sysinfo) |
| 6 | #else |
Eric Biederman | 2c018fb | 2003-07-21 20:13:45 +0000 | [diff] [blame] | 7 | void sdram_initialize(int controllers, const struct mem_controller *ctrl) |
Stefan Reinauer | 7ce8c54 | 2005-12-02 21:52:30 +0000 | [diff] [blame] | 8 | #endif |
Eric Biederman | 8ca8d76 | 2003-04-22 19:02:15 +0000 | [diff] [blame] | 9 | { |
Eric Biederman | 2c018fb | 2003-07-21 20:13:45 +0000 | [diff] [blame] | 10 | int i; |
Eric Biederman | 8ca8d76 | 2003-04-22 19:02:15 +0000 | [diff] [blame] | 11 | /* Set the registers we can set once to reasonable values */ |
Lee Leahy | 45fde70 | 2017-03-08 18:02:24 -0800 | [diff] [blame] | 12 | for (i = 0; i < controllers; i++) { |
Stefan Reinauer | d686522 | 2015-01-05 13:12:38 -0800 | [diff] [blame] | 13 | printk(BIOS_DEBUG, "Ram1.%02x\n", i); |
Stefan Reinauer | 7ce8c54 | 2005-12-02 21:52:30 +0000 | [diff] [blame] | 14 | |
Jonathan Kollasch | e5b7507 | 2010-10-07 23:02:06 +0000 | [diff] [blame] | 15 | #if CONFIG_RAMINIT_SYSINFO |
Stefan Reinauer | f2b7a43 | 2010-03-30 22:21:06 +0000 | [diff] [blame] | 16 | sdram_set_registers(ctrl + i, sysinfo); |
Stefan Reinauer | 7ce8c54 | 2005-12-02 21:52:30 +0000 | [diff] [blame] | 17 | #else |
Eric Biederman | 2c018fb | 2003-07-21 20:13:45 +0000 | [diff] [blame] | 18 | sdram_set_registers(ctrl + i); |
Stefan Reinauer | 7ce8c54 | 2005-12-02 21:52:30 +0000 | [diff] [blame] | 19 | #endif |
Eric Biederman | 2c018fb | 2003-07-21 20:13:45 +0000 | [diff] [blame] | 20 | } |
Eric Biederman | 8ca8d76 | 2003-04-22 19:02:15 +0000 | [diff] [blame] | 21 | |
Eric Biederman | 8ca8d76 | 2003-04-22 19:02:15 +0000 | [diff] [blame] | 22 | /* Now setup those things we can auto detect */ |
Lee Leahy | 45fde70 | 2017-03-08 18:02:24 -0800 | [diff] [blame] | 23 | for (i = 0; i < controllers; i++) { |
Stefan Reinauer | d686522 | 2015-01-05 13:12:38 -0800 | [diff] [blame] | 24 | printk(BIOS_DEBUG, "Ram2.%02x\n", i); |
Stefan Reinauer | 7ce8c54 | 2005-12-02 21:52:30 +0000 | [diff] [blame] | 25 | |
Jonathan Kollasch | e5b7507 | 2010-10-07 23:02:06 +0000 | [diff] [blame] | 26 | #if CONFIG_RAMINIT_SYSINFO |
Stefan Reinauer | f2b7a43 | 2010-03-30 22:21:06 +0000 | [diff] [blame] | 27 | sdram_set_spd_registers(ctrl + i, sysinfo); |
Stefan Reinauer | 7ce8c54 | 2005-12-02 21:52:30 +0000 | [diff] [blame] | 28 | #else |
| 29 | sdram_set_spd_registers(ctrl + i); |
| 30 | #endif |
| 31 | |
Eric Biederman | 2c018fb | 2003-07-21 20:13:45 +0000 | [diff] [blame] | 32 | } |
Eric Biederman | 8ca8d76 | 2003-04-22 19:02:15 +0000 | [diff] [blame] | 33 | |
Eric Biederman | 8ca8d76 | 2003-04-22 19:02:15 +0000 | [diff] [blame] | 34 | /* Now that everything is setup enable the SDRAM. |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 35 | * Some chipsets do the work for us while on others |
Eric Biederman | 8ca8d76 | 2003-04-22 19:02:15 +0000 | [diff] [blame] | 36 | * we need to it by hand. |
| 37 | */ |
Stefan Reinauer | d686522 | 2015-01-05 13:12:38 -0800 | [diff] [blame] | 38 | printk(BIOS_DEBUG, "Ram3\n"); |
Stefan Reinauer | 7ce8c54 | 2005-12-02 21:52:30 +0000 | [diff] [blame] | 39 | |
Jonathan Kollasch | e5b7507 | 2010-10-07 23:02:06 +0000 | [diff] [blame] | 40 | #if CONFIG_RAMINIT_SYSINFO |
Stefan Reinauer | 7ce8c54 | 2005-12-02 21:52:30 +0000 | [diff] [blame] | 41 | sdram_enable(controllers, ctrl, sysinfo); |
| 42 | #else |
Eric Biederman | 2c018fb | 2003-07-21 20:13:45 +0000 | [diff] [blame] | 43 | sdram_enable(controllers, ctrl); |
Stefan Reinauer | 7ce8c54 | 2005-12-02 21:52:30 +0000 | [diff] [blame] | 44 | #endif |
Eric Biederman | 8ca8d76 | 2003-04-22 19:02:15 +0000 | [diff] [blame] | 45 | |
Stefan Reinauer | d686522 | 2015-01-05 13:12:38 -0800 | [diff] [blame] | 46 | printk(BIOS_DEBUG, "Ram4\n"); |
Eric Biederman | 8ca8d76 | 2003-04-22 19:02:15 +0000 | [diff] [blame] | 47 | } |