2010-03-19 03:33:40 +01:00
|
|
|
#include <lib.h> /* Prototypes */
|
2005-12-02 22:52:30 +01:00
|
|
|
|
|
|
|
#ifndef RAMINIT_SYSINFO
|
|
|
|
#define RAMINIT_SYSINFO 0
|
|
|
|
#endif
|
|
|
|
|
|
|
|
static inline void print_debug_sdram_8(const char *strval, uint32_t val)
|
|
|
|
{
|
2010-08-30 19:53:13 +02:00
|
|
|
#if CONFIG_CACHE_AS_RAM
|
2010-03-31 00:21:06 +02:00
|
|
|
printk(BIOS_DEBUG, "%s%02x\n", strval, val);
|
2005-12-02 22:52:30 +01:00
|
|
|
#else
|
2010-03-31 16:47:43 +02:00
|
|
|
print_debug(strval); print_debug_hex8(val); print_debug("\n");
|
2005-12-02 22:52:30 +01:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2003-04-22 21:02:15 +02:00
|
|
|
/* Setup SDRAM */
|
2005-12-02 22:52:30 +01:00
|
|
|
#if RAMINIT_SYSINFO == 1
|
|
|
|
void sdram_initialize(int controllers, const struct mem_controller *ctrl, void *sysinfo)
|
|
|
|
#else
|
2003-07-21 22:13:45 +02:00
|
|
|
void sdram_initialize(int controllers, const struct mem_controller *ctrl)
|
2005-12-02 22:52:30 +01:00
|
|
|
#endif
|
2003-04-22 21:02:15 +02:00
|
|
|
{
|
2003-07-21 22:13:45 +02:00
|
|
|
int i;
|
2003-04-22 21:02:15 +02:00
|
|
|
/* Set the registers we can set once to reasonable values */
|
2003-07-21 22:13:45 +02:00
|
|
|
for(i = 0; i < controllers; i++) {
|
2010-03-31 00:21:06 +02:00
|
|
|
print_debug_sdram_8("Ram1.", i);
|
2005-12-02 22:52:30 +01:00
|
|
|
|
|
|
|
#if RAMINIT_SYSINFO == 1
|
2010-03-31 00:21:06 +02:00
|
|
|
sdram_set_registers(ctrl + i, sysinfo);
|
2005-12-02 22:52:30 +01:00
|
|
|
#else
|
2003-07-21 22:13:45 +02:00
|
|
|
sdram_set_registers(ctrl + i);
|
2005-12-02 22:52:30 +01:00
|
|
|
#endif
|
2003-07-21 22:13:45 +02:00
|
|
|
}
|
2003-04-22 21:02:15 +02:00
|
|
|
|
|
|
|
/* Now setup those things we can auto detect */
|
2003-07-21 22:13:45 +02:00
|
|
|
for(i = 0; i < controllers; i++) {
|
2010-03-31 00:21:06 +02:00
|
|
|
print_debug_sdram_8("Ram2.", i);
|
2005-12-02 22:52:30 +01:00
|
|
|
|
|
|
|
#if RAMINIT_SYSINFO == 1
|
2010-03-31 00:21:06 +02:00
|
|
|
sdram_set_spd_registers(ctrl + i, sysinfo);
|
2005-12-02 22:52:30 +01:00
|
|
|
#else
|
|
|
|
sdram_set_spd_registers(ctrl + i);
|
|
|
|
#endif
|
|
|
|
|
2003-07-21 22:13:45 +02:00
|
|
|
}
|
2003-04-22 21:02:15 +02:00
|
|
|
|
|
|
|
/* Now that everything is setup enable the SDRAM.
|
2010-04-27 08:56:47 +02:00
|
|
|
* Some chipsets do the work for us while on others
|
2003-04-22 21:02:15 +02:00
|
|
|
* we need to it by hand.
|
|
|
|
*/
|
2010-03-31 16:47:43 +02:00
|
|
|
print_debug("Ram3\n");
|
2005-12-02 22:52:30 +01:00
|
|
|
|
|
|
|
#if RAMINIT_SYSINFO == 1
|
|
|
|
sdram_enable(controllers, ctrl, sysinfo);
|
|
|
|
#else
|
2003-07-21 22:13:45 +02:00
|
|
|
sdram_enable(controllers, ctrl);
|
2005-12-02 22:52:30 +01:00
|
|
|
#endif
|
2003-04-22 21:02:15 +02:00
|
|
|
|
2010-03-31 16:47:43 +02:00
|
|
|
print_debug("Ram4\n");
|
2003-04-22 21:02:15 +02:00
|
|
|
}
|