1 #include <console/console.h>
4 #include <device/device.h>
5 #include <device/pci.h>
6 #include <device/pci_ids.h>
10 #include <cpu/amd/gx2def.h>
11 #include <cpu/x86/msr.h>
12 #include <cpu/x86/cache.h>
14 /* ***************************************************************************/
18 /* * GX2 BISTs need to be run before BTB or caches are enabled.*/
19 /* * BIST result left in registers on failure to be checked with FS2.*/
21 /* ***************************************************************************/
28 msrnum = CPU_DM_CONFIG0;
30 msr.lo |= DM_CONFIG0_LOWER_DCDIS_SET;
38 outb(POST_CPU_DM_BIST_FAILURE , 0x80); /* 0x29*/
39 msr = rdmsr(msrnum); /* read back for pass fail*/
40 msr.lo &= 0x0F3FF0000;
41 if (msr.lo != 0xfeff0000)
44 msrnum = CPU_DM_CONFIG0;
46 msr.lo &= ~ DM_CONFIG0_LOWER_DCDIS_SET;
52 msrnum = CPU_FP_UROM_BIST;
55 outb(POST_CPU_FPU_BIST_FAILURE, 0x80); /* 0x89*/
56 inb(0x80); /* IO delay*/
57 msr = rdmsr(msrnum); /* read back for pass fail*/
58 while ((msr.lo&0x884) != 0x884)
59 msr = rdmsr(msrnum); /* Endless loop if BIST is broken*/
60 if ((msr.lo&0x642) != 0x642)
63 msr.lo = msr.hi = 0; /* clear FPU BIST bits*/
64 msrnum = CPU_FP_UROM_BIST;
71 msrnum = CPU_PF_BTBRMA_BIST;
74 outb(POST_CPU_BTB_BIST_FAILURE , 0x80); /* 0x8A*/
75 msr = rdmsr(msrnum); /* read back for pass fail*/
76 if ((msr.lo & 0x3030) != 0x3030)
82 printk_err("BIST failed!\n");
85 /* ***************************************************************************/
87 /* ***************************************************************************/
89 cpuRegInit (int diagmode){
92 /* Turn on BTM for early debug based on setup. */
93 /*if (getnvram( TOKEN_BTM_DIAG_MODE) & 3) {*/
95 /* Set Diagnostic Mode */
96 msrnum = CPU_GLD_MSR_DIAG;
98 msr.lo = DIAG_SEL1_SET | DIAG_SET0_SET;
101 /* Set up GLCP to grab BTM data.*/
102 msrnum = 0x04C00000C; /* GLCP_DBGOUT MSR*/
104 msr.lo = 0x08; /* reset value (SCOPE_SEL = 0) causes FIFO toshift out,*/
105 wrmsr(msrnum, msr); /* exchange it to anything else to prevent this*/
107 /* ;Turn off debug clock*/
108 msrnum = 0x04C000016; /* DBG_CLK_CTL*/
109 msr.lo = 0x00; /* No clock*/
113 /* ;Set debug clock to CPU*/
114 msrnum = 0x04C000016; /* DBG_CLK_CTL*/
115 msr.lo = 0x01; /* CPU CLOCK*/
119 /* ;Set fifo ctl to BTM bits wide*/
120 msrnum = 0x04C00005E; /* FIFO_CTL*/
121 msr.lo = 0x003880000; /* Bit [25:24] are size (11=BTM, 10 = 64 bit, 01= 32 bit, 00 = 16bit)*/
122 wrmsr(msrnum, msr); /* Bit [23:21] are position (100 = CPU downto0)*/
123 /* Bit [19] sets it up in slow data mode.*/
125 /* ;enable fifo loading - BTM sizing will constrain*/
126 /* ; only valid BTM packets to load - this action should always be on*/
128 msrnum = 0x04C00006F; /* GLCP ACTION7 - load fifo*/
129 msr.lo = 0x00000F000; /* Any nibble all 1's will always trigger*/
130 msr.hi = 0x000000000; /* */
133 /* ;start storing diag data in the fifo*/
134 msrnum = 0x04C00005F; /* DIAG CTL*/
135 msr.lo = 0x080000000; /* enable actions*/
136 msr.hi = 0x000000000;
139 /* Set up delay on data lines, so that the hold time*/
141 msrnum = 0x04C00000D ; /* GLCP IO DELAY CONTROLS*/
142 msr.lo = 0x082b5ad68;
143 msr.hi = 0x080ad6b57; /* RGB delay = 0x07*/
146 /* Set up DF to output diag information on DF pins.*/
147 msrnum = DF_GLD_MSR_MASTER_CONF;
152 msrnum = 0x04C00000C ; /* GLCP_DBGOUT MSR*/
154 msr.lo = 0x0; /* reset value (SCOPE_SEL = 0) causes FIFO to shift out,*/
156 /* end of code for BTM */
159 /* Enable Suspend on Halt*/
160 msrnum = CPU_XC_CONFIG;
162 msr.lo |= XC_CONFIG_SUSP_ON_HLT;
165 /* ENable SUSP and allow TSC to run in Suspend */
166 /* to keep speed detection happy*/
167 msrnum = CPU_BC_CONF_0;
169 msr.lo |= TSC_SUSP_SET | SUSP_EN_SET;
172 /* Setup throttling to proper mode if it is ever enabled.*/
173 msrnum = 0x04C00001E;
174 msr.hi = 0x000000000;
175 msr.lo = 0x00000603C;
179 /* Only do this if we are building for 5535*/
183 /* Enable CIS mode B in FooGlue*/
184 msrnum = MSR_FG + 0x10;
187 msr.lo |= 2; /* ModeB*/
192 /* Disable DOT PLL. Graphics init will enable it if needed.*/
194 msrnum = GLCP_DOTPLL;
196 msr.lo |= DOTPPL_LOWER_PD_SET;
200 /* Set the Delay Control in GLCP*/
202 /* SetDelayControl();*/
216 /*if (getnvram( TOKEN_BIST_ENABLE) & == TVALUE_DISABLE) {*/
225 /* I hate to put this check here but it doesn't really work in cpubug.asm*/
226 msrnum = MSR_GLCP+0x17;
228 if (msr.lo < CPU_REV_2_1){
229 msrnum = CPU_PF_BTB_CONF;
231 msr.lo |= BTB_ENABLE_SET | RETURN_STACK_ENABLE_SET;
236 /* FPU impercise exceptions bit*/
238 /*if (getnvram( TOKEN_FPU_IE_ENABLE) != TVALUE_DISABLE) {*/
240 msrnum = CPU_FPU_MSR_MODE;
242 msr.lo |= FPU_IE_SET;
249 /* Allow NVRam to override DM Setup*/
250 /*if (getnvram( TOKEN_CACHE_DM_MODE) != 1) {*/
253 msrnum = CPU_DM_CONFIG0;
255 msr.lo |= DM_CONFIG0_LOWER_DCDIS_SET;
258 /* Allow NVRam to override IM Setup*/
259 /*if (getnvram( TOKEN_CACHE_IM_MODE) ==1) {*/
261 msrnum = CPU_IM_CONFIG;
263 msr.lo |= IM_CONFIG_LOWER_ICD_SET;
271 /* ***************************************************************************/
273 /* * MTestPinCheckBX*/
275 /* * Set MTEST pins to expected values from OPTIONS.INC/NVRAM*/
276 /* * This version is called when there isn't a stack available*/
278 /* ***************************************************************************/
280 MTestPinCheckBX (void){
284 /*if (getnvram( TOKEN_MTEST_ENABLE) ==TVALUE_DISABLE ) {*/
289 msrnum = MC_CFCLK_DBUG;
291 msr.hi |= CFCLK_UPPER_MTST_B2B_DIS_SET | CFCLK_UPPER_MTEST_EN_SET;
294 msrnum = GLCP_SYS_RSTPLL /* Get SDR/DDR mode from GLCP*/;
296 msr.lo >>= RSTPPL_LOWER_SDRMODE_SHIFT;
298 msrnum = MC_CFCLK_DBUG; /* Turn on SDR MTEST stuff*/
300 msr.lo |= CFCLK_LOWER_SDCLK_SET;
301 msr.hi |= CFCLK_UPPER_MTST_DQS_EN_SET;
305 /* Lock the cache down here.*/