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>
20 msr.whatever |= ID_CONFIG_SERIAL_SET;
28 msr = rdmsr(MC_GLD_MSR_PM);
34 /**************************************************************************
38 * Bugtool #465 and #609
40 * There is also fix code in cache and PCI functions. This bug is very is pervasive.
46 **************************************************************************/
53 * forces serialization of all load misses. Setting this bit prevents the
54 * DM pipe from backing up if a read request has to be held up waiting
55 * for PCI writes to complete.
57 msr = rdmsr(CPU_DM_CONFIG0);
58 msr.hi &= ~(7<<DM_CONFIG0_UPPER_WSREQ_SHIFT);
59 msr.hi |= (2<<DM_CONFIG0_UPPER_WSREQ_SHIFT);
60 msr.lo |= DM_CONFIG0_LOWER_MISSER_SET;
61 wrmsr(CPU_DM_CONFIG0, msr);
63 /* interlock instruction fetches to WS regions with data accesses.
64 * This prevents an instruction fetch from going out to PCI if the
65 * data side is about to make a request.
67 msr = rdmsr(CPU_IM_CONFIG);
68 msr.lo |= IM_CONFIG_LOWER_QWT_SET;
69 wrmsr(CPU_IM_CONFIG, msr);
71 /* write serialize memory hole to PCI. Need to unWS when something is
72 * shadowed regardless of cachablility.
76 wrmsr( CPU_RCONF_A0_BF, msr);
77 wrmsr( CPU_RCONF_C0_DF, msr);
78 wrmsr( CPU_RCONF_E0_FF, msr);
81 /****************************************************************************
87 * Fix CPUID instructions for < 3.0 CPUs
93 /****************************************************************************/
98 //static char *name = "Geode by NSC";
100 /* we'll do this the stupid way, for now, but that's the string they want. NO ONE KNOWS why you
101 * would do this -- the OS can figure this type of stuff out!
115 /* More CPUID to match AMD better. #792*/
117 msr.hi = 0x0C0C0A13D;
122 /* cpubug 1398: enable MC if we KNOW we have DDR*/
123 /**************************************************************************
127 * ClearQuest #IAENG1398
128 * The MC can not be enabled with SDR memory but can for DDR. Enable for
129 * DDR here if the setup token is "Default"
130 * Add this back to core by default once 2.0 CPUs are not supported.
135 **************************************************************************/
140 msr = rdmsr(MSR_GLCP+0x17);
141 if ((msr.lo & 0xff) <= CPU_REV_2_0) {
142 msr = rdmsr(GLCP_SYS_RSTPLL);
143 if (msr.lo & (1<<RSTPPL_LOWER_SDRMODE_SHIFT))
147 /* no CMOS/NVRAM to check, so enable MC Clock Gating */
148 msr = rdmsr(MC_GLD_MSR_PM);
149 msr.lo |= 3; /* enable MC clock gating.*/
150 wrmsr(MC_GLD_MSR_PM, msr);
155 printk_err(" NOT DOING eng2900: only shown to be a windows problem\n");
158 ;**************************************************************************
162 ;* Clear Quest IAENG00002900, VSS 118.150
164 ;* BTB issue causes blue screen in windows.
170 ;**************************************************************************
171 CPUbugIAENG2900 PROC NEAR PUBLIC
174 ; Clear bit 43, disables the sysenter/sysexit in CPUID3
180 mov cx, TOKEN_BTB_2900_SWAPSIF_ENABLE
181 NOSTACK bx, GetNVRAMValueBX
182 cmp ax, TVALUE_ENABLE
186 ;Disable enable_actions in DIAGCTL while setting up GLCP
187 mov ecx, MSR_GLCP + 005fh
192 ;Changing DBGCLKCTL register to GeodeLink
193 mov ecx, MSR_GLCP + 0016h
198 mov ecx, MSR_GLCP + 0016h
203 ;The code below sets up the RedCloud to stall for 4 GeodeLink clocks when CPU is snooped.
204 ;Because setting XSTATE to 0 overrides any other XSTATE action, the code will always
205 ;stall for 4 GeodeLink clocks after a snoop request goes away even if it occured a clock or two
206 ;later than a different snoop; the stall signal will never 'glitch high' for
207 ;only one or two CPU clocks with this code.
209 ;Send mb0 port 3 requests to upper GeodeLink diag bits [63:32]
210 mov ecx, MSR_GLIU0 + 2005h
215 ;set5m watches request ready from mb0 to CPU (snoop)
216 mov ecx, MSR_GLCP + 0045h
221 ;SET4M will be high when state is idle (XSTATE=11)
222 mov ecx, MSR_GLCP + 0044h
227 ;SET5n to watch for processor stalled state
228 mov ecx, MSR_GLCP + 004Dh
233 ;Writing action number 13: XSTATE=0 to occur when CPU is snooped unless we're stalled
234 mov ecx, MSR_GLCP + 0075h
239 ;Writing action number 11: inc XSTATE every GeodeLink clock unless we're idle
240 mov ecx, MSR_GLCP + 0073h
246 ;Writing action number 5: STALL_CPU_PIPE when exitting idle state or not in idle state
247 mov ecx, MSR_GLCP + 006Dh
252 ;Writing DIAGCTL Register to enable the stall action and to let set5m watch the upper GeodeLink diag bits.
253 mov ecx, MSR_GLCP + 005fh
268 /* GLPCI PIO Post Control shouldn't be enabled */
271 msr = rdmsr(GLPCI_SPARE);
272 msr.lo &= ~GLPCI_SPARE_LOWER_PPC_SET;
273 wrmsr(GLPCI_SPARE, msr);
278 /* per AMD, do this always */
282 /* Disable enable_actions in DIAGCTL while setting up GLCP */
283 wrmsr(MSR_GLCP + 0x005f, msr);
285 /* SET2M fires if VG pri is odd (3, not 2) and Ystate=0 */
286 msrnum = MSR_GLCP + 0x042;
287 /* msr.hi = 2d6b8000h */;
292 /* SET3M fires if MBUS changed and VG pri is odd */
293 msrnum = MSR_GLCP + 0x043;
298 /* Put VG request data on lower diag bus */
299 msrnum = MSR_GLIU0 + 0x2005;
304 /* Increment Y state if SET3M if true */
305 msrnum = MSR_GLCP + 0x074;
310 /* Set up MBUS action to PRI=3 read of MBIU */
311 msrnum = MSR_GLCP + 0x020;
316 /* Trigger MBUS action if VG=pri3 and Y=0, this blocks most PCI */
317 msrnum = MSR_GLCP + 0x071;
322 /* Writing DIAGCTL */
323 msrnum = MSR_GLCP + 0x005f;
328 /* Code to enable FS2 even when BTB and VGTEAR SWAPSiFs are enabled */
329 /* As per Todd Roberts in PBz1094 and PBz1095 */
330 /* Moved from CPUREG to CPUBUG per Tom Sylla */
331 msrnum = 0x04C000042; /* GLCP SETMCTL Register */;
333 msr.hi |= 8; /* Bit 35 = MCP_IN */
339 /****************************************************************************/
341 /** DisableMemoryReorder*/
344 /** The MC reordered transactions incorrectly and breaks coherency.*/
345 /** Disable reording and take a potential performance hit.*/
346 /** This is safe to do here and not in MC init since there is nothing*/
347 /** to maintain coherency with and the cache is not enabled yet.*/
354 /****************************************************************************/
355 void disablememoryreadorder(void)
358 msr = rdmsr(MC_CF8F_DATA);
360 msr.hi |= CF8F_UPPER_REORDER_DIS_SET;
361 wrmsr(MC_CF8F_DATA, msr);
370 msr = rdmsr(GLCP_CHIP_REVID);
374 printk_err("%s: rev < 0x20! bailing!\n");
377 printk_debug("Doing cpubug fixes for rev 0x%x\n", rev);
383 /* cs 5530 bug; ignore
397 printk_err("unknown rev %x, bailing\n", rev);
402 disablememoryreadorder();
403 printk_debug("Done cpubug fixes \n");