remove erroneous cache disable.
[coreboot.git] / src / cpu / amd / model_gx2 / cpureginit.c
1
2
3 /* ***************************************************************************/
4 /* **/
5 /* *    BIST */
6 /* **/
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.*/
9 /* **/
10 /* ***************************************************************************/
11 static void
12 BIST(void){
13         int msrnum;
14         msr_t msr;
15
16         /* DM*/
17         msrnum = CPU_DM_CONFIG0;
18         msr = rdmsr(msrnum);
19         msr.lo |=  DM_CONFIG0_LOWER_DCDIS_SET;
20         wrmsr(msrnum, msr);
21         
22         msr.lo =  0x00000003F;
23         msr.hi =  0x000000000;
24         msrnum = CPU_DM_BIST;
25         wrmsr(msrnum, msr);
26
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)
31                 goto BISTFail;
32  
33         msrnum = CPU_DM_CONFIG0;
34         msr = rdmsr(msrnum);
35         msr.lo &=  ~ DM_CONFIG0_LOWER_DCDIS_SET;
36         wrmsr(msrnum, msr);
37
38         /* FPU*/
39         msr.lo =  0x000000131;
40         msr.hi = 0;
41         msrnum = CPU_FP_UROM_BIST;
42         wrmsr(msrnum, msr);
43
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)
50                 goto BISTFail;
51
52         msr.lo = msr.hi = 0;                            /*  clear FPU BIST bits*/
53         msrnum = CPU_FP_UROM_BIST;
54         wrmsr(msrnum, msr);
55
56
57         /* BTB*/
58         msr.lo =  0x000000303;
59         msr.hi =  0x000000000;
60         msrnum = CPU_PF_BTBRMA_BIST;
61         wrmsr(msrnum, msr);
62
63         outb(POST_CPU_BTB_BIST_FAILURE  , 0x80);                                /* 0x8A*/
64         msr = rdmsr(msrnum);                                                    /* read back for pass fail*/
65         if ((msr.lo & 0x3030) != 0x3030)
66                 goto BISTFail;
67
68         return;
69
70 BISTFail:
71         print_err("BIST failed!\n");
72         while(1);
73 }
74 /* ***************************************************************************/
75 /* *    cpuRegInit*/
76 /* ***************************************************************************/
77 void
78 cpuRegInit (void){
79         int msrnum;
80         msr_t msr;
81         /*  Turn on BTM for early debug based on setup. */
82         /*if (getnvram( TOKEN_BTM_DIAG_MODE) & 3) {*/
83         /*
84          * The following is only for diagnostics mode; do not use for OLPC
85          */
86         if (0) {
87                 /*  Set Diagnostic Mode */
88                 msrnum = CPU_GLD_MSR_DIAG;
89                 msr.hi =  0;
90                 msr.lo = DIAG_SEL1_SET | DIAG_SET0_SET;
91                 wrmsr(msrnum, msr);
92         
93                 /*  Set up GLCP to grab BTM data.*/
94                 msrnum = 0x04C00000C;           /*  GLCP_DBGOUT MSR*/
95                 msr.hi =  0x0;
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*/
98         
99                 /* ;Turn off debug clock*/
100                 msrnum = 0x04C000016;           /* DBG_CLK_CTL*/
101                 msr.lo =  0x00;                 /* No clock*/
102                 msr.hi =  0x00;
103                 wrmsr(msrnum, msr);
104         
105                 /* ;Set debug clock to CPU*/
106                 msrnum = 0x04C000016;           /* DBG_CLK_CTL*/
107                 msr.lo =  0x01;                 /* CPU CLOCK*/
108                 msr.hi =  0x00;
109                 wrmsr(msrnum, msr);
110         
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.*/
116         
117                 /* ;enable fifo loading - BTM sizing will constrain*/
118                 /* ; only valid BTM packets to load - this action should always be on*/
119         
120                 msrnum = 0x04C00006F;           /*  GLCP ACTION7 - load fifo*/
121                 msr.lo =  0x00000F000;          /*    Any nibble all 1's will always trigger*/
122                 msr.hi =  0x000000000;          /* */
123                 wrmsr(msrnum, msr);
124         
125                 /* ;start storing diag data in the fifo*/
126                 msrnum = 0x04C00005F;           /* DIAG CTL*/
127                 msr.lo =  0x080000000;          /*  enable actions*/
128                 msr.hi =  0x000000000;
129                 wrmsr(msrnum, msr);
130         
131                 /*  Set up delay on data lines, so that the hold time*/
132                 /*  is 1 ns.*/
133                 msrnum = 0x04C00000D ;  /*  GLCP IO DELAY CONTROLS*/
134                 msr.lo =  0x082b5ad68;
135                 msr.hi =  0x080ad6b57;  /*  RGB delay = 0x07*/
136                 wrmsr(msrnum, msr);
137         
138                 /*  Set up DF to output diag information on DF pins.*/
139                 msrnum = DF_GLD_MSR_MASTER_CONF;
140                 msr.lo =  0x0220;
141                 msr.hi = 0;
142                 wrmsr(msrnum, msr);
143         
144                 msrnum = 0x04C00000C ;  /*  GLCP_DBGOUT MSR*/
145                 msr.hi =  0x0;
146                 msr.lo =  0x0;                          /*  reset value (SCOPE_SEL = 0) causes FIFO to shift out,*/
147                 wrmsr(msrnum, msr);
148                 /* end of code for BTM */
149         }
150
151         /*  Enable Suspend on Halt*/
152         msrnum = CPU_XC_CONFIG;
153         msr = rdmsr(msrnum);
154         msr.lo |=  XC_CONFIG_SUSP_ON_HLT;
155         wrmsr(msrnum, msr);
156
157         /*  ENable SUSP and allow TSC to run in Suspend */
158         /*  to keep speed detection happy*/
159         msrnum = CPU_BC_CONF_0;
160         msr = rdmsr(msrnum);
161         msr.lo |=  TSC_SUSP_SET | SUSP_EN_SET;
162         wrmsr(msrnum, msr);
163
164         /*  Setup throttling to proper mode if it is ever enabled.*/
165         msrnum = 0x04C00001E;
166         msr.hi =  0x000000000;
167         msr.lo =  0x00000603C;
168         wrmsr(msrnum, msr);
169
170
171 /*  Only do this if we are building for 5535*/
172 /* */
173 /*  FooGlue Setup*/
174 /* */
175 #if 1
176         /*  Enable CIS mode B in FooGlue*/
177         msrnum = MSR_FG + 0x10;
178         msr = rdmsr(msrnum);
179         msr.lo &= ~3;
180         msr.lo |= 2;                    /*  ModeB*/
181         wrmsr(msrnum, msr);
182 #endif
183
184 /* */
185 /*  Disable DOT PLL. Graphics init will enable it if needed.*/
186 /* */
187         msrnum = GLCP_DOTPLL;
188         msr = rdmsr(msrnum);
189         msr.lo |= DOTPPL_LOWER_PD_SET;
190         wrmsr(msrnum, msr);
191
192 /* */
193 /*  Enable RSDC*/
194 /* */
195         msrnum = 0x1301 ;
196         msr = rdmsr(msrnum);
197         msr.lo |=  0x08;
198         wrmsr(msrnum, msr);
199
200
201 /* */
202 /*  BIST*/
203 /* */
204         /*if (getnvram( TOKEN_BIST_ENABLE) & == TVALUE_DISABLE) {*/
205         {
206 //              BIST();
207         }
208
209
210 /* */
211 /*  Enable BTB*/
212 /* */
213         /*  I hate to put this check here but it doesn't really work in cpubug.asm*/
214         msrnum = MSR_GLCP+0x17;
215         msr = rdmsr(msrnum);
216         if (msr.lo >= CPU_REV_2_1){
217                 msrnum = CPU_PF_BTB_CONF;
218                 msr = rdmsr(msrnum);
219                 msr.lo |= BTB_ENABLE_SET | RETURN_STACK_ENABLE_SET;
220                 wrmsr(msrnum, msr);
221         }
222
223 /* */
224 /*  FPU impercise exceptions bit*/
225 /* */
226         /*if (getnvram( TOKEN_FPU_IE_ENABLE) != TVALUE_DISABLE) {*/
227         {
228                 msrnum = CPU_FPU_MSR_MODE;
229                 msr = rdmsr(msrnum);
230                 msr.lo |= FPU_IE_SET;
231                 wrmsr(msrnum, msr);
232         }
233
234 #if 0
235         /* */
236         /*  Cache Overides*/
237         /* */
238         /* This code disables the data cache.  Don't execute this
239          * unless you're testing something.
240          */ 
241         /*  Allow NVRam to override DM Setup*/
242         /*if (getnvram( TOKEN_CACHE_DM_MODE) != 1) {*/
243         {
244
245                 msrnum = CPU_DM_CONFIG0;
246                 msr = rdmsr(msrnum);
247                 msr.lo |=  DM_CONFIG0_LOWER_DCDIS_SET;
248                 wrmsr(msrnum, msr);
249         }
250         /* This code disables the instruction cache.  Don't execute
251          * this unless you're testing something.
252         */ 
253         /*  Allow NVRam to override IM Setup*/
254         /*if (getnvram( TOKEN_CACHE_IM_MODE) ==1) {*/
255         {
256                 msrnum = CPU_IM_CONFIG;
257                 msr = rdmsr(msrnum);
258                 msr.lo |=  IM_CONFIG_LOWER_ICD_SET;
259                 wrmsr(msrnum, msr);
260         }
261 #endif
262 }
263
264
265
266
267 /* ***************************************************************************/
268 /* **/
269 /* *    MTestPinCheckBX*/
270 /* **/
271 /* *    Set MTEST pins to expected values from OPTIONS.INC/NVRAM*/
272 /* *  This version is called when there isn't a stack available*/
273 /* **/
274 /* ***************************************************************************/
275 static void
276 MTestPinCheckBX (void){
277         int msrnum;
278         msr_t msr;
279
280         /*if (getnvram( TOKEN_MTEST_ENABLE) ==TVALUE_DISABLE ) {*/
281                         /* return ; */
282         /* } */
283
284         /*  Turn on MTEST*/
285         msrnum = MC_CFCLK_DBUG;
286         msr = rdmsr(msrnum);
287         msr.hi |=  CFCLK_UPPER_MTST_B2B_DIS_SET | CFCLK_UPPER_MTEST_EN_SET;
288         wrmsr(msrnum, msr);
289
290         msrnum = GLCP_SYS_RSTPLL                        /*  Get SDR/DDR mode from GLCP*/;
291         msr = rdmsr(msrnum);
292         msr.lo >>=  RSTPPL_LOWER_SDRMODE_SHIFT;
293         if (msr.lo & 1) {
294                 msrnum = MC_CFCLK_DBUG;                 /*  Turn on SDR MTEST stuff*/
295                 msr = rdmsr(msrnum);
296                 msr.lo |=  CFCLK_LOWER_SDCLK_SET;
297                 msr.hi |=  CFCLK_UPPER_MTST_DQS_EN_SET;
298                 wrmsr(msrnum, msr);
299         }
300
301         /*  Lock the cache down here.*/
302         __asm__("wbinvd\n");
303
304 }