1 #include <console/console.h>
4 #include <device/device.h>
5 #include <device/pci.h>
6 #include <device/pci_ids.h>
11 #include "northbridge.h"
12 #include <cpu/amd/gx2def.h>
13 #include <cpu/x86/msr.h>
14 #include <cpu/x86/cache.h>
16 /* put this here for now, we are not sure where it belongs */
19 unsigned long desc_name;
20 unsigned short desc_type;
24 struct gliutable gliu0table[] = {
25 {.desc_name=MSR_GLIU0_BASE1, .desc_type= BM,.hi= MSR_MC + 0x0,.lo= 0x0FFF80}, /* 0-7FFFF to MC*/
26 {.desc_name=MSR_GLIU0_BASE2, .desc_type= BM,.hi= MSR_MC + 0x0,.lo=(0x80 << 20) + 0x0FFFE0}, /* 80000-9ffff to Mc*/
27 {.desc_name=MSR_GLIU0_SHADOW, .desc_type= SC_SHADOW,.hi= MSR_MC + 0x0,.lo= 0x03}, /* C0000-Fffff split to MC and PCI (sub decode) A0000-Bffff handled by SoftVideo*/
28 {.desc_name=MSR_GLIU0_SYSMEM, .desc_type= R_SYSMEM,.hi= MSR_MC,.lo= 0x0}, /* Catch and fix dynamicly.*/
29 {.desc_name=MSR_GLIU0_DMM, .desc_type= BMO_DMM,.hi= MSR_MC,.lo= 0x0}, /* Catch and fix dynamicly.*/
30 {.desc_name=MSR_GLIU0_SMM, .desc_type= BMO_SMM,.hi= MSR_MC,.lo= 0x0}, /* Catch and fix dynamicly.*/
31 {.desc_name=GLIU0_GLD_MSR_COH,.desc_type= OTHER,.hi= 0x0,.lo= GL0_CPU},
32 {.desc_name=GL_END, .desc_type= GL_END,.hi= 0x0,.lo= 0x0},
36 struct gliutable gliu1table[] = {
37 {.desc_name=MSR_GLIU1_BASE1,.desc_type= BM,.hi= MSR_GL0 + 0x0,.lo= 0x0FFF80}, /* 0-7FFFF to MC*/
38 {.desc_name=MSR_GLIU1_BASE2,.desc_type= BM,.hi= MSR_GL0 + 0x0,.lo= (0x80 << 20) +0x0FFFE0}, /* 80000-9ffff to Mc*/
39 {.desc_name=MSR_GLIU1_SHADOW,.desc_type= SC_SHADOW,.hi= MSR_GL0 + 0x0,.lo= 0x03}, /* C0000-Fffff split to MC and PCI (sub decode)*/
40 {.desc_name=MSR_GLIU1_SYSMEM,.desc_type= R_SYSMEM,.hi= MSR_GL0,.lo= 0x0}, /* Cat0xc and fix dynamicly.*/
41 {.desc_name=MSR_GLIU1_DMM,.desc_type= BM_DMM,.hi= MSR_GL0,.lo= 0x0}, /* Cat0xc and fix dynamicly.*/
42 {.desc_name=MSR_GLIU1_SMM,.desc_type= BM_SMM,.hi= MSR_GL0,.lo= 0x0}, /* Cat0xc and fix dynamicly.*/
43 {.desc_name=GLIU1_GLD_MSR_COH,.desc_type= OTHER,.hi= 0x0,.lo= GL1_GLIU0},
44 {.desc_name=MSR_GLIU1_FPU_TRAP,.desc_type= SCIO,.hi= (GL1_GLCP << 29) + 0x0,.lo= 0x033000F0}, /* FooGlue FPU 0xF0*/
45 {.desc_name=GL_END,.desc_type= GL_END,.hi= 0x0,.lo= 0x0},
48 struct gliutable *gliutables[] = {gliu0table, gliu1table, 0};
55 struct msrinit ClockGatingDefault [] = {
56 {GLIU0_GLD_MSR_PM, {.hi=0x00,.lo=0x0005}},
57 /* MC must stay off in SDR mode. It is turned on in CPUBug??? lotus #77.142*/
58 {MC_GLD_MSR_PM, {.hi=0x00,.lo=0x0000}},
59 {GLIU1_GLD_MSR_PM, {.hi=0x00,.lo=0x0005}},
60 {VG_GLD_MSR_PM, {.hi=0x00,.lo=0x0000}}, /* lotus #77.163*/
61 {GP_GLD_MSR_PM, {.hi=0x00,.lo=0x0001}},
62 {DF_GLD_MSR_PM, {.hi=0x00,.lo=0x0155}},
63 {GLCP_GLD_MSR_PM, {.hi=0x00,.lo=0x0015}},
64 {GLPCI_GLD_MSR_PM, {.hi=0x00,.lo=0x0015}},
65 {FG_GLD_MSR_PM, {.hi=0x00,.lo=0x0000}}, /* Always on*/
66 {0xffffffff, {0xffffffff, 0xffffffff}},
69 struct msrinit ClockGatingAllOn[] = {
70 {GLIU0_GLD_MSR_PM, {.hi=0x00,.lo=0x0FFFFFFFF}},
71 {MC_GLD_MSR_PM, {.hi=0x00,.lo=0x0FFFFFFFF}},
72 {GLIU1_GLD_MSR_PM, {.hi=0x00,.lo=0x0FFFFFFFF}},
73 {VG_GLD_MSR_PM, {.hi=0x00, .lo=0x00}},
74 {GP_GLD_MSR_PM, {.hi=0x00,.lo=0x000000001}},
75 {DF_GLD_MSR_PM, {.hi=0x00,.lo=0x0FFFFFFFF}},
76 {GLCP_GLD_MSR_PM, {.hi=0x00,.lo=0x0FFFFFFFF}},
77 {GLPCI_GLD_MSR_PM, {.hi=0x00,.lo=0x0FFFFFFFF}},
78 {FG_GLD_MSR_PM, {.hi=0x00,.lo=0x0000}},
79 {0xffffffff, {0xffffffff, 0xffffffff}},
83 struct msrinit ClockGatingPerformance[] = {
84 {VG_GLD_MSR_PM, {.hi=0x00,.lo=0x0000}}, /* lotus #77.163*/
85 {GP_GLD_MSR_PM, {.hi=0x00,.lo=0x0001}},
86 {DF_GLD_MSR_PM, {.hi=0x00,.lo=0x0155}},
87 {GLCP_GLD_MSR_PM, {.hi=0x00,.lo=0x0015}},
88 {0xffffffff, {0xffffffff, 0xffffffff}},
91 /* SET GeodeLink PRIORITY*/
93 struct msrinit GeodeLinkPriorityTable [] = {
94 {CPU_GLD_MSR_CONFIG, {.hi=0x00,.lo=0x0220}}, /* CPU Priority.*/
95 {DF_GLD_MSR_MASTER_CONF, {.hi=0x00,.lo=0x0000}}, /* DF Priority.*/
96 {VG_GLD_MSR_CONFIG, {.hi=0x00,.lo=0x0720}}, /* VG Primary and Secondary Priority.*/
97 {GP_GLD_MSR_CONFIG, {.hi=0x00,.lo=0x0010}}, /* Graphics Priority.*/
98 {GLPCI_GLD_MSR_CONFIG, {.hi=0x00,.lo=0x0027}}, /* GLPCI Priority + PID*/
99 {GLCP_GLD_MSR_CONF, {.hi=0x00,.lo=0x0001}}, /* GLCP Priority + PID*/
100 {VIP_GLD_MSR_CONFIG, {.hi=0x00,.lo=0x0622}}, /* VIP PID*/
101 {AES_GLD_MSR_CONFIG, {.hi=0x00,.lo=0x0013}}, /* AES PID*/
102 {0x0FFFFFFFF, {0x0FFFFFFFF, 0x0FFFFFFFF}}, /* END*/
105 /* do we have dmi or not? assume NO per AMD */
109 writeglmsr(struct gliutable *gl){
114 wrmsr(gl->desc_name, msr); // MSR - see table above
115 printk_debug("%s: write msr 0x%08x, val 0x%08x:0x%08x\n", __FUNCTION__, gl->desc_name, msr.hi, msr.lo);
116 /* they do this, so we do this */
117 msr = rdmsr(gl->desc_name);
118 printk_debug("%s: AFTER write msr 0x%08x, val 0x%08x:0x%08x\n", __FUNCTION__, gl->desc_name, msr.hi, msr.lo);
122 ShadowInit(struct gliutable *gl)
126 msr = rdmsr(gl->desc_name);
133 /* NOTE: transcribed from assembly code. There is the usual redundant assembly nonsense in here.
136 /* yes, this duplicates later code, but it seems that is how they want it done.
138 extern int sizeram(void);
140 SysmemInit(struct gliutable *gl)
143 int sizembytes, sizebytes;
146 * Figure out how much RAM is in the machine and alocate all to the
147 * system. We will adjust for SMM and DMM now and Frame Buffer later.
149 sizembytes = sizeram();
150 printk_debug("%s: enable for %dm bytes\n", __FUNCTION__, sizembytes);
151 sizebytes = sizembytes << 20;
153 sizebytes -= SMM_SIZE*1024 +1;
156 sizebytes -= DMM_SIZE * 1024 + 1;
159 msr.hi = (gl->hi & 0xFFFFFF00) | (sizebytes >> 24);
160 /* set up sizebytes to fit into msr.lo */
161 sizebytes <<= 8; /* what? well, we want bits 23:12 in bits 31:20. */
162 sizebytes &= 0xfff00000;
165 wrmsr(gl->desc_name, msr); // MSR - see table above
166 msr = rdmsr(gl->desc_name);
167 printk_debug("%s: AFTER write msr 0x%08x, val 0x%08x:0x%08x\n", __FUNCTION__,
168 gl->desc_name, msr.hi, msr.lo);
172 DMMGL0Init(struct gliutable *gl) {
174 int sizebytes = sizeram()<<20;
180 printk_debug("%s: %d bytes\n", __FUNCTION__, sizebytes);
182 sizebytes -= DMM_SIZE*1024;
183 offset = sizebytes - DMM_OFFSET;
184 printk_debug("%s: offset is 0x%08x\n", __FUNCTION__, offset);
186 msr.hi = (gl->hi) | (offset << 8);
187 /* I don't think this is needed */
188 msr.hi &= 0xffffff00;
189 msr.hi |= (DMM_OFFSET >> 24);
190 msr.lo = DMM_OFFSET << 8;
191 msr.lo |= ((~(DMM_SIZE*1024)+1)>>12)&0xfffff;
193 wrmsr(gl->desc_name, msr); // MSR - See table above
194 msr = rdmsr(gl->desc_name);
195 printk_debug("%s: AFTER write msr 0x%08x, val 0x%08x:0x%08x\n", __FUNCTION__, gl->desc_name, msr.hi, msr.lo);
199 DMMGL1Init(struct gliutable *gl) {
205 printk_debug("%s:\n", __FUNCTION__ );
208 /* I don't think this is needed */
209 msr.hi &= 0xffffff00;
210 msr.hi |= (DMM_OFFSET >> 24);
211 msr.lo = DMM_OFFSET << 8;
212 /* hmm. AMD source has SMM here ... SMM, not DMM? We think DMM */
213 printk_err("%s: warning, using DMM_SIZE even though AMD used SMM_SIZE\n", __FUNCTION__);
214 msr.lo |= ((~(DMM_SIZE*1024)+1)>>12)&0xfffff;
216 wrmsr(gl->desc_name, msr); // MSR - See table above
217 msr = rdmsr(gl->desc_name);
218 printk_debug("%s: AFTER write msr 0x%08x, val 0x%08x:0x%08x\n", __FUNCTION__, gl->desc_name, msr.hi, msr.lo);
221 SMMGL0Init(struct gliutable *gl) {
223 int sizebytes = sizeram()<<20;
226 sizebytes -= SMM_SIZE*1024;
229 sizebytes -= DMM_SIZE * 1024;
231 printk_debug("%s: %d bytes\n", __FUNCTION__, sizebytes);
233 offset = sizebytes - SMM_OFFSET;
234 printk_debug("%s: offset is 0x%08x\n", __FUNCTION__, offset);
237 msr.hi = offset << 8;
238 msr.hi |= SMM_OFFSET>>24;
240 msr.lo = SMM_OFFSET << 8;
241 msr.lo |= ((~(SMM_SIZE*1024)+1)>>12)&0xfffff;
243 wrmsr(gl->desc_name, msr); // MSR - See table above
244 msr = rdmsr(gl->desc_name);
245 printk_debug("%s: AFTER write msr 0x%08x, val 0x%08x:0x%08x\n", __FUNCTION__, gl->desc_name, msr.hi, msr.lo);
248 SMMGL1Init(struct gliutable *gl) {
250 printk_debug("%s:\n", __FUNCTION__ );
253 /* I don't think this is needed */
254 msr.hi &= 0xffffff00;
255 msr.hi |= (SMM_OFFSET >> 24);
256 msr.lo = SMM_OFFSET << 8;
257 msr.lo |= ((~(SMM_SIZE*1024)+1)>>12)&0xfffff;
259 wrmsr(gl->desc_name, msr); // MSR - See table above
260 msr = rdmsr(gl->desc_name);
261 printk_debug("%s: AFTER write msr 0x%08x, val 0x%08x:0x%08x\n", __FUNCTION__, gl->desc_name, msr.hi, msr.lo);
265 GLIUInit(struct gliutable *gl){
267 while (gl->desc_type != GL_END){
268 switch(gl->desc_type){
270 /* For Unknown types: Write then read MSR */
272 case SC_SHADOW: /* Check for a Shadow entry*/
276 case R_SYSMEM: /* check for a SYSMEM entry*/
280 case BMO_DMM: /* check for a DMM entry*/
284 case BM_DMM : /* check for a DMM entry*/
288 case BMO_SMM : /* check for a SMM entry*/
292 case BM_SMM : /* check for a SMM entry*/
300 /* ***************************************************************************/
304 /* * Set up GLPCI settings for reads/write into memory*/
306 /* * R1: 1MB - Top of System Memory*/
307 /* * R2: SMM Memory*/
308 /* * R3: Framebuffer? - not set up yet*/
315 /* ***************************************************************************/
316 static void GLPCIInit(void){
317 struct gliutable *gl = 0;
323 /* R0 - GLPCI settings for Conventional Memory space.*/
325 msr.hi = (0x09F000 >> 12) << GLPCI_RC_UPPER_TOP_SHIFT /* 640*/;
327 msr.lo |= GLPCI_RC_LOWER_EN_SET+ GLPCI_RC_LOWER_PF_SET + GLPCI_RC_LOWER_WC_SET;
332 /* R1 - GLPCI settings for SysMem space.*/
334 /* Get systop from GLIU0 SYSTOP Descriptor*/
335 for(i = 0; gliu0table[i].desc_name != GL_END; i++) {
336 if (gliu0table[i].desc_type == R_SYSMEM) {
342 unsigned long pah, pal;
343 msrnum = gl->desc_name;
345 /* example R_SYSMEM value: 20:00:00:0f:fb:f0:01:00
346 * translates to a base of 0x00100000 and top of 0xffbf0000
347 * base of 1M and top of around 256M
349 /* we have to create a page-aligned (4KB page) address for base and top */
350 /* So we need a high page aligned addresss (pah) and low page aligned address (pal)
351 * pah is from msr.hi << 12 | msr.low >> 20. pal is msr.lo << 12
353 printk_debug("GLPCI r1: system msr.lo 0x%08x msr.hi 0x%08x\n", msr.lo, msr.hi);
354 pah = ((msr.hi &0xff) << 12) | ((msr.lo >> 20) & 0xfff);
355 /* we have the page address. Now make it a page-aligned address */
361 msr.lo |= GLPCI_RC_LOWER_EN_SET | GLPCI_RC_LOWER_PF_SET | GLPCI_RC_LOWER_WC_SET;
362 printk_debug("GLPCI r1: system msr.lo 0x%08x msr.hi 0x%08x\n", msr.lo, msr.hi);
368 /* R2 - GLPCI settings for SMM space.*/
370 msr.hi = ((SMM_OFFSET+(SMM_SIZE*1024-1)) >> 12) << GLPCI_RC_UPPER_TOP_SHIFT;
371 msr.lo = (SMM_OFFSET >> 12) << GLPCI_RC_LOWER_BASE_SHIFT;
372 msr.lo |= GLPCI_RC_LOWER_EN_SET | GLPCI_RC_LOWER_PF_SET;
376 /* this is done elsewhere already, but it does no harm to do it more than once */
377 /* write serialize memory hole to PCI. Need to to unWS when something is shadowed regardless of cachablility.*/
378 msr.lo = 0x021212121 /* cache disabled and write serialized*/;
379 msr.hi = 0x021212121 /* cache disabled and write serialized*/;
381 msrnum = CPU_RCONF_A0_BF;
384 msrnum = CPU_RCONF_C0_DF;
387 msrnum = CPU_RCONF_E0_FF;
390 /* Set Non-Cacheable Read Only for NorthBound Transactions to Memory. The Enable bit is handled in the Shadow setup.*/
391 msrnum = GLPCI_A0_BF;
396 msrnum = GLPCI_C0_DF;
401 msrnum = GLPCI_E0_FF;
407 msrnum = CPU_DM_CONFIG0;
409 msr.hi &= ~ (7 << DM_CONFIG0_UPPER_WSREQ_SHIFT);
410 msr.hi |= 2 << DM_CONFIG0_UPPER_WSREQ_SHIFT ; /* reduce to 1 for safe mode.*/
413 /* we are ignoring the 5530 case for now, and perhaps forever. */
420 msr.hi |= GLPCI_ARB_UPPER_PRE0_SET | GLPCI_ARB_UPPER_PRE1_SET;
421 msr.lo |= GLPCI_ARB_LOWER_IIE_SET;
428 msr.lo |= GLPCI_CTRL_LOWER_ME_SET | GLPCI_CTRL_LOWER_OWC_SET | GLPCI_CTRL_LOWER_PCD_SET; /* (Out will be disabled in CPUBUG649 for < 2.0 parts .)*/
429 msr.lo |= GLPCI_CTRL_LOWER_LDE_SET;
431 msr.lo &= ~ (0x03 << GLPCI_CTRL_LOWER_IRFC_SHIFT);
432 msr.lo |= 0x02 << GLPCI_CTRL_LOWER_IRFC_SHIFT;
434 msr.lo &= ~ (0x07 << GLPCI_CTRL_LOWER_IRFT_SHIFT);
435 msr.lo |= 0x06 << GLPCI_CTRL_LOWER_IRFT_SHIFT;
437 msr.hi &= ~ (0x0f << GLPCI_CTRL_UPPER_FTH_SHIFT);
438 msr.hi |= 0x0F << GLPCI_CTRL_UPPER_FTH_SHIFT;
440 msr.hi &= ~ (0x0f << GLPCI_CTRL_UPPER_RTH_SHIFT);
441 msr.hi |= 0x0F << GLPCI_CTRL_UPPER_RTH_SHIFT;
443 msr.hi &= ~ (0x0f << GLPCI_CTRL_UPPER_SBRTH_SHIFT);
444 msr.hi |= 0x0F << GLPCI_CTRL_UPPER_SBRTH_SHIFT;
446 msr.hi &= ~ (0x03 << GLPCI_CTRL_UPPER_WTO_SHIFT);
447 msr.hi |= 0x06 << GLPCI_CTRL_UPPER_WTO_SHIFT;
449 msr.hi &= ~ (0x03 << GLPCI_CTRL_UPPER_ILTO_SHIFT);
450 msr.hi |= 0x00 << GLPCI_CTRL_UPPER_ILTO_SHIFT;
454 /* Set GLPCI Latency Timer.*/
457 msr.hi |= 0x1F << GLPCI_CTRL_UPPER_LAT_SHIFT; /* Change once 1.x is gone.*/
461 msrnum = GLPCI_SPARE;
464 msr.lo |= GLPCI_SPARE_LOWER_AILTO_SET | GLPCI_SPARE_LOWER_PPD_SET | GLPCI_SPARE_LOWER_PPC_SET | GLPCI_SPARE_LOWER_MPC_SET | GLPCI_SPARE_LOWER_NSE_SET | GLPCI_SPARE_LOWER_SUPO_SET;
471 /* ***************************************************************************/
473 /* * ClockGatingInit*/
475 /* * Enable Clock Gating.*/
481 /* ***************************************************************************/
483 ClockGatingInit (void){
485 struct msrinit *gating = ClockGatingDefault;
489 mov cx, TOKEN_CLK_GATE
490 NOSTACK bx, GetNVRAMValueBX
491 cmp al, TVALUE_CG_OFF
494 cmp al, TVALUE_CG_DEFAULT
497 lea si, ClockGatingDefault
501 lea si, ClockGatingAllOn
505 lea si, ClockGatingPerformance
508 for(i = 0; gating->msrnum != 0xffffffff; i++) {
509 msr = rdmsr(gating->msrnum);
510 printk_debug("%s: MSR 0x%08x is 0x%08x:0x%08x\n", __FUNCTION__, gating->msrnum, msr.hi, msr.lo);
511 msr.hi |= gating->msr.hi;
512 msr.lo |= gating->msr.lo;
513 printk_debug("%s: MSR 0x%08x will be set to 0x%08x:0x%08x\n", __FUNCTION__,
514 gating->msrnum, msr.hi, msr.lo);
515 wrmsr(gating->msrnum, msr); // MSR - See the table above
522 GeodeLinkPriority(void){
524 struct msrinit *prio = GeodeLinkPriorityTable;
527 for(i = 0; prio->msrnum != 0xffffffff; i++) {
528 msr = rdmsr(prio->msrnum);
529 printk_debug("%s: MSR 0x%08x is 0x%08x:0x%08x\n", __FUNCTION__, prio->msrnum, msr.hi, msr.lo);
530 msr.hi |= prio->msr.hi;
532 msr.lo |= prio->msr.lo;
533 printk_debug("%s: MSR 0x%08x will be set to 0x%08x:0x%08x\n", __FUNCTION__,
534 prio->msrnum, msr.hi, msr.lo);
535 wrmsr(prio->msrnum, msr); // MSR - See the table above
543 * Get the GLIU0 shadow register settings
544 * If the setShadow function is used then all shadow descriptors
547 static uint64_t getShadow(void)
550 msr = rdmsr(MSR_GLIU0_SHADOW);
551 return ( ( (uint64_t) msr.hi ) << 32 ) | msr.lo;
556 * Set the cache RConf registers for the memory hole.
557 * Keeps all cache shadow descriptors sync'ed.
558 * This is part of the PCI lockup solution
559 * Entry: EDX:EAX is the shadow settings
561 static void setShadowRCONF(uint32_t shadowHi, uint32_t shadowLo)
563 // ok this is whacky bit translation time.
567 shadowByte = (uint8_t) (shadowLo >> 16);
569 // load up D000 settings in edx.
570 for (bit = 8; (bit > 4); bit--) {
572 msr.hi |= 1; // cache disable PCI/Shadow memory
573 if (shadowByte && (1 << bit))
574 msr.hi |= 0x20; // write serialize PCI memory
577 // load up C000 settings in eax.
578 for ( ; bit; bit--) {
580 msr.lo |= 1; // cache disable PCI/Shadow memory
581 if (shadowByte && (1 << bit))
582 msr.lo |= 0x20; // write serialize PCI memory
585 wrmsr(CPU_RCONF_C0_DF, msr);
587 shadowByte = (uint8_t) (shadowLo >> 24);
589 // load up F000 settings in edx.
590 for (bit = 8; (bit > 4); bit--) {
592 msr.hi |= 1; // cache disable PCI/Shadow memory
593 if (shadowByte && (1 << bit))
594 msr.hi |= 0x20; // write serialize PCI memory
597 // load up E000 settings in eax.
598 for ( ; bit; bit--) {
600 msr.lo |= 1; // cache disable PCI/Shadow memory
601 if (shadowByte && (1 << bit))
602 msr.lo |= 0x20; // write serialize PCI memory
605 wrmsr(CPU_RCONF_E0_FF, msr);
610 * Set the GLPCI registers for the memory hole.
611 * Keeps all cache shadow descriptors sync'ed.
612 * Entry: EDX:EAX is the shadow settings
614 static void setShadowGLPCI(uint32_t shadowHi, uint32_t shadowLo)
618 // Set the Enable Register.
620 msr = rdmsr(GLPCI_REN);
621 msr.lo &= 0xFFFF00FF;
622 msr.lo |= ( (shadowLo & 0xFFFF0000) >> 8);
623 wrmsr(GLPCI_REN, msr);
628 * Set the GLIU SC register settings. Scans descriptor tables for SC_SHADOW.
629 * Keeps all shadow descriptors sync'ed.
630 * Entry: EDX:EAX is the shadow settings
632 static void setShadow(uint64_t shadowSettings)
636 struct gliutable* pTable;
637 uint32_t shadowLo, shadowHi;
639 shadowLo = (uint32_t) shadowSettings;
640 shadowHi = (uint32_t) (shadowSettings >> 32);
642 setShadowRCONF(shadowHi, shadowLo);
643 setShadowGLPCI(shadowHi, shadowLo);
645 for(i = 0; gliutables[i]; i++) {
646 for (pTable = gliutables[i]; pTable->desc_type != GL_END; pTable++) {
647 if (pTable->desc_type == SC_SHADOW) {
649 msr = rdmsr(pTable->desc_name);
650 msr.lo = (uint32_t) shadowSettings;
651 msr.hi &= 0xFFFF0000; // maintain PDID in upper EDX
652 msr.hi |= ((uint32_t) (shadowSettings >> 32)) & 0x0000FFFF;
653 wrmsr(pTable->desc_name, msr); // MSR - See the table above
660 /**************************************************************************
664 * Set up a stack for ease of further testing
670 **************************************************************************/
674 uint64_t shadowSettings = getShadow();
675 shadowSettings &= (uint64_t) 0xFFFF00000000FFFFULL; // Disable read & writes
676 shadowSettings |= (uint64_t) 0x00000000F0000000ULL; // Enable reads for F0000-FFFFF
677 setShadow(shadowSettings);
682 /***************************************************************************
685 * Set up RCONF_DEFAULT and any other RCONF registers needed
687 * DEVRC_RCONF_DEFAULT:
688 * ROMRC(63:56) = 04h ; write protect ROMBASE
689 * ROMBASE(36:55) = 0FFFC0h ; Top of PCI/bottom of rom chipselect area
690 * DEVRC(35:28) = 39h ; cache disabled in PCI memory + WS bit on + Write Combine + write burst.
691 * SYSTOP(27:8) = top of system memory
692 * SYSRC(7:0) = 00h ; writeback, can set to 08h to make writethrough
694 ***************************************************************************/
695 #define SYSMEM_RCONF_WRITETHROUGH 8
696 #define DEVRC_RCONF_DEFAULT 0x21
697 #define ROMBASE_RCONF_DEFAULT 0xFFFC0000
698 #define ROMRC_RCONF_DEFAULT 0x25
703 struct gliutable *gl = 0;
706 uint8_t SysMemCacheProp;
709 /* Locate SYSMEM entry in GLIU0table */
710 for(i = 0; gliu0table[i].desc_name != GL_END; i++) {
711 if (gliu0table[i].desc_type == R_SYSMEM) {
717 post_code(0xCE); /* POST_RCONFInitError */
722 /* found the descriptor... get its contents */
723 msr = rdmsr(gl->desc_name);
725 /* 20 bit address - The bottom 12 bits go into bits 20-31 in eax, the
726 * top 8 bits go into 0-7 of edx.
728 msr.lo = (msr.lo & 0xFFFFFF00) | (msr.hi & 0xFF);
729 msr.lo = ((msr.lo << 12) | (msr.lo >> 20)) & 0x000FFFFF;
730 msr.lo <<= RCONF_DEFAULT_LOWER_SYSTOP_SHIFT; // 8
732 // Set Default SYSMEM region properties
733 msr.lo &= ~SYSMEM_RCONF_WRITETHROUGH; // 8 (or ~8)
735 // Set PCI space cache properties
736 msr.hi = (DEVRC_RCONF_DEFAULT >> 4); // only need the bottom bits and lets clean the rest of edx
737 msr.lo |= (DEVRC_RCONF_DEFAULT << 28);
739 // Set the ROMBASE. This is usually FFFC0000h
740 msr.hi |= (ROMBASE_RCONF_DEFAULT >> 12) << RCONF_DEFAULT_UPPER_ROMBASE_SHIFT;
742 // Set ROMBASE cache properties.
743 msr.hi |= ((ROMRC_RCONF_DEFAULT >> 8) | (ROMRC_RCONF_DEFAULT << 24));
745 // now program RCONF_DEFAULT
746 wrmsr(CPU_RCONF_DEFAULT, msr);
748 // RCONF_BYPASS: Cache tablewalk properties and SMM/DMM header access properties.
749 // Set to match system memory cache properties.
750 msr = rdmsr(CPU_RCONF_DEFAULT);
751 SysMemCacheProp = (uint8_t) (msr.lo & 0xFF);
752 msr = rdmsr(CPU_RCONF_BYPASS);
753 msr.lo = (msr.lo & 0xFFFF0000) | (SysMemCacheProp << 8) | SysMemCacheProp;
754 wrmsr(CPU_RCONF_BYPASS, msr);
758 /* ***************************************************************************/
760 /* * northBridgeInit*/
762 /* * Core Logic initialization: Host bridge*/
768 /* ***************************************************************************/
771 northbridgeinit(void)
775 printk_debug("Enter %s\n", __FUNCTION__);
777 for(i = 0; gliutables[i]; i++)
778 GLIUInit(gliutables[i]);
784 // GeodeROM ensures that the BIOS waits the required 1 second before
785 // allowing anything to access PCI
790 // The cacheInit function in GeodeROM tests cache and, among other things,
791 // makes sure all INVD instructions are treated as WBINVD. We do this
792 // because we've found some programs which require this behavior.
793 // That subset of cacheInit() is implemented here:
794 msr = rdmsr(CPU_DM_CONFIG0);
795 msr.lo |= DM_CONFIG0_LOWER_WBINVD_SET;
796 wrmsr(CPU_DM_CONFIG0, msr);
798 /* Now that the descriptor to memory is set up.*/
799 /* The memory controller needs one read to synch its lines before it can be used.*/
805 /* CPUBugsFix -- called elsewhere */
806 printk_debug("Exit %s\n", __FUNCTION__);