2 * This file is part of the LinuxBIOS project.
4 * Copyright (C) 2006 Indrek Kruusa <indrek.kruusa@artecdesign.ee>
5 * Copyright (C) 2006 Ronald G. Minnich <rminnich@gmail.com>
6 * Copyright (C) 2007 Advanced Micro Devices, Inc.
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
23 /* ***************************************************************************/
27 /* * GX2 BISTs need to be run before BTB or caches are enabled.*/
28 /* * BIST result left in registers on failure to be checked with FS2.*/
30 /* ***************************************************************************/
37 msrnum = CPU_DM_CONFIG0;
39 msr.lo |= DM_CONFIG0_LOWER_DCDIS_SET;
47 outb(POST_CPU_DM_BIST_FAILURE, 0x80); /* 0x29*/
48 msr = rdmsr(msrnum); /* read back for pass fail*/
49 msr.lo &= 0x0F3FF0000;
50 if (msr.lo != 0xfeff0000)
53 msrnum = CPU_DM_CONFIG0;
55 msr.lo &= ~ DM_CONFIG0_LOWER_DCDIS_SET;
61 msrnum = CPU_FP_UROM_BIST;
64 outb(POST_CPU_FPU_BIST_FAILURE, 0x80); /* 0x89*/
65 inb(0x80); /* IO delay*/
66 msr = rdmsr(msrnum); /* read back for pass fail*/
67 while ((msr.lo&0x884) != 0x884)
68 msr = rdmsr(msrnum); /* Endless loop if BIST is broken*/
69 if ((msr.lo&0x642) != 0x642)
72 msr.lo = msr.hi = 0; /* clear FPU BIST bits*/
73 msrnum = CPU_FP_UROM_BIST;
80 msrnum = CPU_PF_BTBRMA_BIST;
83 outb(POST_CPU_BTB_BIST_FAILURE , 0x80); /* 0x8A*/
84 msr = rdmsr(msrnum); /* read back for pass fail*/
85 if ((msr.lo & 0x3030) != 0x3030)
91 print_err("BIST failed!\n");
94 /* ***************************************************************************/
96 /* ***************************************************************************/
102 //GX3 suspend: what is desired?
104 /* Enable Suspend on Halt*/
105 /*msrnum = CPU_XC_CONFIG;
107 msr.lo |= XC_CONFIG_SUSP_ON_HLT;
108 wrmsr(msrnum, msr);*/
110 /* ENable SUSP and allow TSC to run in Suspend */
111 /* to keep speed detection happy*/
112 /*msrnum = CPU_BC_CONF_0;
114 msr.lo |= TSC_SUSP_SET | SUSP_EN_SET;
115 wrmsr(msrnum, msr);*/
117 /* Setup throttling to proper mode if it is ever enabled.*/
118 msrnum = 0x04C00001E;
119 msr.hi = 0x000000000;
120 msr.lo = 0x00000603C;
121 wrmsr(msrnum, msr); // GX3 OK +/-
124 /* Only do this if we are building for 5535*/
129 /* Enable CIS mode B in FooGlue*/
130 msrnum = MSR_FG + 0x10;
133 msr.lo |= 2; /* ModeB*/
138 /* Disable DOT PLL. Graphics init will enable it if needed.*/
141 // GX3: Disable DOT PLL? No. Lets tick.
143 /* msrnum = GLCP_DOTPLL;
145 msr.lo |= DOTPPL_LOWER_PD_SET;
146 wrmsr(msrnum, msr); */
154 wrmsr(msrnum, msr); //GX3 OK
160 /*if (getnvram( TOKEN_BIST_ENABLE) & == TVALUE_DISABLE) {*/
169 /* I hate to put this check here but it doesn't really work in cpubug.asm*/
171 //GX3: BTB is enabled by default
173 /* msrnum = MSR_GLCP+0x17;
175 if (msr.lo >= CPU_REV_2_1){
176 msrnum = CPU_PF_BTB_CONF;
178 msr.lo |= BTB_ENABLE_SET | RETURN_STACK_ENABLE_SET;
185 /* FPU impercise exceptions bit*/
187 /*if (getnvram( TOKEN_FPU_IE_ENABLE) != TVALUE_DISABLE) {*/
191 // GX3: FPU impercise exceptions bit - what's that?
193 msrnum = CPU_FPU_MSR_MODE;
195 msr.lo |= FPU_IE_SET;
205 /* This code disables the data cache. Don't execute this
206 * unless you're testing something.
208 /* Allow NVRam to override DM Setup*/
209 /*if (getnvram( TOKEN_CACHE_DM_MODE) != 1) {*/
212 msrnum = CPU_DM_CONFIG0;
214 msr.lo |= DM_CONFIG0_LOWER_DCDIS_SET;
217 /* This code disables the instruction cache. Don't execute
218 * this unless you're testing something.
220 /* Allow NVRam to override IM Setup*/
221 /*if (getnvram( TOKEN_CACHE_IM_MODE) ==1) {*/
223 msrnum = CPU_IM_CONFIG;
225 msr.lo |= IM_CONFIG_LOWER_ICD_SET;
234 /* ***************************************************************************/
236 /* * MTestPinCheckBX*/
238 /* * Set MTEST pins to expected values from OPTIONS.INC/NVRAM*/
239 /* * This version is called when there isn't a stack available*/
241 /* ***************************************************************************/
243 MTestPinCheckBX (void){
247 /*if (getnvram( TOKEN_MTEST_ENABLE) ==TVALUE_DISABLE ) {*/
252 msrnum = MC_CFCLK_DBUG;
254 msr.hi |= CFCLK_UPPER_MTST_B2B_DIS_SET | CFCLK_UPPER_MTEST_EN_SET;
257 msrnum = GLCP_SYS_RSTPLL /* Get SDR/DDR mode from GLCP*/;
259 msr.lo >>= RSTPPL_LOWER_SDRMODE_SHIFT;
261 msrnum = MC_CFCLK_DBUG; /* Turn on SDR MTEST stuff*/
263 msr.lo |= CFCLK_LOWER_SDCLK_SET;
264 msr.hi |= CFCLK_UPPER_MTST_DQS_EN_SET;
268 /* Lock the cache down here.*/