2 #include <device/pci_def.h>
4 #include <device/pnp_def.h>
6 #include <console/console.h>
7 #include "lib/ramtest.c"
8 #include "superio/winbond/w83627hf/w83627hf_early_serial.c"
9 #include "cpu/x86/bist.h"
10 #include "cpu/x86/msr.h"
11 #include <cpu/amd/gx2def.h>
13 #define SERIAL_DEV PNP_DEV(0x2e, W83627HF_SP1)
15 #include "southbridge/amd/cs5536/cs5536_early_smbus.c"
16 #include "southbridge/amd/cs5536/cs5536_early_setup.c"
18 static inline int spd_read_byte(unsigned device, unsigned address)
20 return smbus_read_byte(device, address);
23 #include "northbridge/amd/gx2/raminit.h"
25 static inline unsigned int fls(unsigned int x)
29 __asm__("bsfl %1,%0\n\t"
32 "1:" : "=r" (r) : "g" (x));
36 /* sdram parameters for OLPC:
41 d0_MB=1 (module banks)
42 d0_cb=4 (component banks)
43 do_psz=4KB (page size)
44 Trc=10 (clocks) (ref2act)
51 static void sdram_set_spd_registers(const struct mem_controller *ctrl)
53 /* Total size of DIMM = 2^row address (byte 3) * 2^col address (byte 4) *
54 * component Banks (byte 17) * module banks, side (byte 5) *
55 * width in bits (byte 6,7)
56 * = Density per side (byte 31) * number of sides (byte 5) */
57 /* 1. Initialize GLMC registers base on SPD values, do one DIMM for now */
59 unsigned char module_banks, val;
61 msr = rdmsr(MC_CF07_DATA);
63 /* get module banks (sides) per dimm, SPD byte 5 */
66 msr.hi &= ~(1 << CF07_UPPER_D0_MB_SHIFT);
67 msr.hi |= (module_banks << CF07_UPPER_D0_MB_SHIFT);
69 /* get component banks per module bank, SPD byte 17 */
72 msr.hi &= ~(0x1 << CF07_UPPER_D0_CB_SHIFT);
73 msr.hi |= (val << CF07_UPPER_D0_CB_SHIFT);
75 /* get the module bank density, SPD byte 31 */
76 /* this is multiples of 8 MB */
77 /* actually it is 2^x*4, where x is the value you put in */
78 /* for OLPC, set default size */
79 /* dimm size - hardcoded 128Mb */
81 msr.hi &= ~(0xf << CF07_UPPER_D0_SZ_SHIFT);
82 msr.hi |= (val << CF07_UPPER_D0_SZ_SHIFT);
84 /* page size = 2^col address */
85 val = 2; /* 4096 bytes */
86 msr.hi &= ~(0x7 << CF07_UPPER_D0_PSZ_SHIFT);
87 msr.hi |= (val << CF07_UPPER_D0_PSZ_SHIFT);
89 print_debug("computed msr.hi ");
90 print_debug_hex32(msr.hi);
93 /* this is a standard value, DOES NOT PROBABLY MATCH FROM ABOVE */
94 /* well, it may be close. It's about 200,000 ticks */
96 wrmsr(MC_CF07_DATA, msr);
98 /* timing and mode ... */
100 msr = rdmsr(0x20000019);
102 /* per standard bios settings */
115 /* the msr value reported by quanta is very, very different.
116 * we will go with that value for now.
120 wrmsr(0x20000019, msr);
124 #include "northbridge/amd/gx2/raminit.c"
125 #include "lib/generic_sdram.c"
127 #define PLLMSRhi 0x00001490
128 #define PLLMSRlo 0x02000030
129 #define PLLMSRlo1 ((0xde << 16) | (1 << 26) | (1 << 24))
130 #define PLLMSRlo2 ((1<<14) |(1<<13) | (1<<0))
131 #include "northbridge/amd/gx2/pll_reset.c"
132 #include "cpu/amd/model_gx2/cpureginit.c"
133 #include "cpu/amd/model_gx2/syspreinit.c"
134 #include "cpu/amd/model_lx/msrinit.c"
136 static void gpio_init(void)
140 /* Make sure events enable for gpio 12 is off */
142 m = inl(GPIOL_EVENTS_ENABLE);
145 outl(m, GPIOL_EVENTS_ENABLE);
148 void main(unsigned long bist)
150 static const struct mem_controller memctrl [] = {
151 {.channel0 = {(0xa<<3)|0, (0xa<<3)|1}}
157 cs5536_early_setup();
159 /* NOTE: must do this AFTER the early_setup!
160 * it is counting on some early MSR setup
163 cs5536_setup_onchipuart(1);
168 /* Halt if there was a built in self test failure */
169 report_bist_failure(bist);
174 print_err("done cpuRegInit\n");
176 sdram_initialize(1, memctrl);
178 /* Check all of memory */
179 //ram_check(0x00000000, 640*1024);