3 /* ***************************************************************************/
7 /* * GX2 BISTs need to be run before BTB or caches are enabled.*/
8 /* * BIST result left in registers on failure to be checked with FS2.*/
10 /* ***************************************************************************/
17 msrnum = CPU_DM_CONFIG0;
19 msr.lo |= DM_CONFIG0_LOWER_DCDIS_SET;
27 outb(POST_CPU_DM_BIST_FAILURE, 0x80); /* 0x29*/
28 msr = rdmsr(msrnum); /* read back for pass fail*/
29 msr.lo &= 0x0F3FF0000;
30 if (msr.lo != 0xfeff0000)
33 msrnum = CPU_DM_CONFIG0;
35 msr.lo &= ~ DM_CONFIG0_LOWER_DCDIS_SET;
41 msrnum = CPU_FP_UROM_BIST;
44 outb(POST_CPU_FPU_BIST_FAILURE, 0x80); /* 0x89*/
45 inb(0x80); /* IO delay*/
46 msr = rdmsr(msrnum); /* read back for pass fail*/
47 while ((msr.lo&0x884) != 0x884)
48 msr = rdmsr(msrnum); /* Endless loop if BIST is broken*/
49 if ((msr.lo&0x642) != 0x642)
52 msr.lo = msr.hi = 0; /* clear FPU BIST bits*/
53 msrnum = CPU_FP_UROM_BIST;
60 msrnum = CPU_PF_BTBRMA_BIST;
63 outb(POST_CPU_BTB_BIST_FAILURE , 0x80); /* 0x8A*/
64 msr = rdmsr(msrnum); /* read back for pass fail*/
65 if ((msr.lo & 0x3030) != 0x3030)
71 print_err("BIST failed!\n");
74 /* ***************************************************************************/
76 /* ***************************************************************************/
81 /* Turn on BTM for early debug based on setup. */
82 /*if (getnvram( TOKEN_BTM_DIAG_MODE) & 3) {*/
84 * The following is only for diagnostics mode; do not use for OLPC
87 /* Set Diagnostic Mode */
88 msrnum = CPU_GLD_MSR_DIAG;
90 msr.lo = DIAG_SEL1_SET | DIAG_SET0_SET;
93 /* Set up GLCP to grab BTM data.*/
94 msrnum = 0x04C00000C; /* GLCP_DBGOUT MSR*/
96 msr.lo = 0x08; /* reset value (SCOPE_SEL = 0) causes FIFO toshift out,*/
97 wrmsr(msrnum, msr); /* exchange it to anything else to prevent this*/
99 /* ;Turn off debug clock*/
100 msrnum = 0x04C000016; /* DBG_CLK_CTL*/
101 msr.lo = 0x00; /* No clock*/
105 /* ;Set debug clock to CPU*/
106 msrnum = 0x04C000016; /* DBG_CLK_CTL*/
107 msr.lo = 0x01; /* CPU CLOCK*/
111 /* ;Set fifo ctl to BTM bits wide*/
112 msrnum = 0x04C00005E; /* FIFO_CTL*/
113 msr.lo = 0x003880000; /* Bit [25:24] are size (11=BTM, 10 = 64 bit, 01= 32 bit, 00 = 16bit)*/
114 wrmsr(msrnum, msr); /* Bit [23:21] are position (100 = CPU downto0)*/
115 /* Bit [19] sets it up in slow data mode.*/
117 /* ;enable fifo loading - BTM sizing will constrain*/
118 /* ; only valid BTM packets to load - this action should always be on*/
120 msrnum = 0x04C00006F; /* GLCP ACTION7 - load fifo*/
121 msr.lo = 0x00000F000; /* Any nibble all 1's will always trigger*/
122 msr.hi = 0x000000000; /* */
125 /* ;start storing diag data in the fifo*/
126 msrnum = 0x04C00005F; /* DIAG CTL*/
127 msr.lo = 0x080000000; /* enable actions*/
128 msr.hi = 0x000000000;
131 /* Set up delay on data lines, so that the hold time*/
133 msrnum = 0x04C00000D ; /* GLCP IO DELAY CONTROLS*/
134 msr.lo = 0x082b5ad68;
135 msr.hi = 0x080ad6b57; /* RGB delay = 0x07*/
138 /* Set up DF to output diag information on DF pins.*/
139 msrnum = DF_GLD_MSR_MASTER_CONF;
144 msrnum = 0x04C00000C ; /* GLCP_DBGOUT MSR*/
146 msr.lo = 0x0; /* reset value (SCOPE_SEL = 0) causes FIFO to shift out,*/
148 /* end of code for BTM */
151 /* Enable Suspend on Halt*/
152 msrnum = CPU_XC_CONFIG;
154 msr.lo |= XC_CONFIG_SUSP_ON_HLT;
157 /* ENable SUSP and allow TSC to run in Suspend */
158 /* to keep speed detection happy*/
159 msrnum = CPU_BC_CONF_0;
161 msr.lo |= TSC_SUSP_SET | SUSP_EN_SET;
164 /* Setup throttling to proper mode if it is ever enabled.*/
165 msrnum = 0x04C00001E;
166 msr.hi = 0x000000000;
167 msr.lo = 0x00000603C;
171 /* Only do this if we are building for 5535*/
176 /* Enable CIS mode B in FooGlue*/
177 msrnum = MSR_FG + 0x10;
180 msr.lo |= 2; /* ModeB*/
185 /* Disable DOT PLL. Graphics init will enable it if needed.*/
187 msrnum = GLCP_DOTPLL;
189 msr.lo |= DOTPPL_LOWER_PD_SET;
204 /*if (getnvram( TOKEN_BIST_ENABLE) & == TVALUE_DISABLE) {*/
213 /* I hate to put this check here but it doesn't really work in cpubug.asm*/
214 msrnum = MSR_GLCP+0x17;
216 if (msr.lo >= CPU_REV_2_1){
217 msrnum = CPU_PF_BTB_CONF;
219 msr.lo |= BTB_ENABLE_SET | RETURN_STACK_ENABLE_SET;
224 /* FPU impercise exceptions bit*/
226 /*if (getnvram( TOKEN_FPU_IE_ENABLE) != TVALUE_DISABLE) {*/
228 msrnum = CPU_FPU_MSR_MODE;
230 msr.lo |= FPU_IE_SET;
238 /* This code disables the data cache. Don't execute this
239 * unless you're testing something.
241 /* Allow NVRam to override DM Setup*/
242 /*if (getnvram( TOKEN_CACHE_DM_MODE) != 1) {*/
245 msrnum = CPU_DM_CONFIG0;
247 msr.lo |= DM_CONFIG0_LOWER_DCDIS_SET;
250 /* This code disables the instruction cache. Don't execute
251 * this unless you're testing something.
253 /* Allow NVRam to override IM Setup*/
254 /*if (getnvram( TOKEN_CACHE_IM_MODE) ==1) {*/
256 msrnum = CPU_IM_CONFIG;
258 msr.lo |= IM_CONFIG_LOWER_ICD_SET;
267 /* ***************************************************************************/
269 /* * MTestPinCheckBX*/
271 /* * Set MTEST pins to expected values from OPTIONS.INC/NVRAM*/
272 /* * This version is called when there isn't a stack available*/
274 /* ***************************************************************************/
276 MTestPinCheckBX (void){
280 /*if (getnvram( TOKEN_MTEST_ENABLE) ==TVALUE_DISABLE ) {*/
285 msrnum = MC_CFCLK_DBUG;
287 msr.hi |= CFCLK_UPPER_MTST_B2B_DIS_SET | CFCLK_UPPER_MTEST_EN_SET;
290 msrnum = GLCP_SYS_RSTPLL /* Get SDR/DDR mode from GLCP*/;
292 msr.lo >>= RSTPPL_LOWER_SDRMODE_SHIFT;
294 msrnum = MC_CFCLK_DBUG; /* Turn on SDR MTEST stuff*/
296 msr.lo |= CFCLK_LOWER_SDCLK_SET;
297 msr.hi |= CFCLK_UPPER_MTST_DQS_EN_SET;
301 /* Lock the cache down here.*/