4 #include <device/pci_def.h>
6 #include <device/pnp_def.h>
7 #include <arch/romcc_io.h>
9 #include "pc80/serial.c"
10 #include "arch/i386/lib/console.c"
11 #include "ram/ramtest.c"
12 //#include "superio/winbond/w83627hf/w83627hf_early_serial.c"
13 #include "cpu/x86/bist.h"
14 #include "cpu/x86/msr.h"
15 #include <cpu/amd/lxdef.h>
17 //#define SERIAL_DEV PNP_DEV(0x2e, W83627HF_SP1)
19 #include "southbridge/amd/cs5536/cs5536_early_smbus.c"
20 #include "southbridge/amd/cs5536/cs5536_early_setup.c"
22 static inline int spd_read_byte(unsigned device, unsigned address)
24 return smbus_read_byte(device, address);
27 #include "northbridge/amd/lx/raminit.h"
29 static inline unsigned int fls(unsigned int x)
33 __asm__("bsfl %1,%0\n\t"
36 "1:" : "=r" (r) : "g" (x));
40 static void sdram_set_spd_registers(const struct mem_controller *ctrl)
42 /* Total size of DIMM = 2^row address (byte 3) * 2^col address (byte 4) *
43 * component Banks (byte 17) * module banks, side (byte 5) *
44 * width in bits (byte 6,7)
45 * = Density per side (byte 31) * number of sides (byte 5) */
46 /* 1. Initialize GLMC registers base on SPD values, do one DIMM for now */
48 unsigned char module_banks, val;
53 wrmsr(MC_CF07_DATA, msr); //GX3
55 /* timing and mode ... */
57 //msr = rdmsr(0x20000019);
59 /* per standard bios settings */
72 * the msr value reported by quanta is very, very different.
73 * we will go with that value for now.
75 //msr.lo = 0x286332a3;
77 //wrmsr(0x20000019, msr); //GX3
81 #include "northbridge/amd/lx/raminit.c"
82 #include "sdram/generic_sdram.c"
84 /* CPU and GLIU mult/div */
85 #define PLLMSRhi 0x0000039C
86 /* Hold Count - how long we will sit in reset */
87 #define PLLMSRlo 0x00DE0000
89 #include "northbridge/amd/lx/pll_reset.c"
90 #include "cpu/amd/model_lx/cpureginit.c"
91 #include "cpu/amd/model_lx/syspreinit.c"
93 static void msr_init(void)
95 __builtin_wrmsr(0x10000020, 0xfff80, 0x20000000);
96 __builtin_wrmsr(0x10000021, 0x80fffe0, 0x20000000);
98 __builtin_wrmsr(0x40000020, 0xfff80, 0x20000000);
99 __builtin_wrmsr(0x40000021, 0x80fffe0, 0x20000000);
103 static void main(unsigned long bist)
105 static const struct mem_controller memctrl [] = {
106 {.channel0 = {(0xa<<3)|0, (0xa<<3)|1}}
109 SystemPreInit(); //GX3 OK
113 cs5536_early_setup(); //GX3 OK
115 /* NOTE: must do this AFTER the early_setup!
116 * it is counting on some early MSR setup
119 cs5536_setup_onchipuart(); //GX3 OK
121 uart_init(); //GX3 OK
122 console_init(); //GX3 OK
124 pll_reset(); //GX3 OK
126 cpuRegInit(); //GX3 OK
128 print_err("done cpuRegInit\n");
130 sdram_initialize(1, memctrl); //GX3 OK almost
132 /* Check all of memory */
133 //ram_check(0x00000000, 640*1024);