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 */
20 unsigned long desc_name;
21 unsigned short desc_type;
25 struct gliutable gliu0table[] = {
26 {.desc_name=MSR_GLIU0_BASE1, .desc_type= BM,.hi= MSR_MC + 0x0,.lo= 0x0FFF80}, /* 0-7FFFF to MC */
27 {.desc_name=MSR_GLIU0_BASE2, .desc_type= BM,.hi= MSR_MC + 0x0,.lo=(0x80 << 20) + 0x0FFFE0}, /* 80000-9ffff to Mc */
28 {.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 */
29 {.desc_name=MSR_GLIU0_SYSMEM, .desc_type= R_SYSMEM,.hi= MSR_MC,.lo= 0x0}, /* Catch and fix dynamicly. */
30 {.desc_name=MSR_GLIU0_DMM, .desc_type= BMO_DMM,.hi= MSR_MC,.lo= 0x0}, /* Catch and fix dynamicly. */
31 {.desc_name=MSR_GLIU0_SMM, .desc_type= BMO_SMM,.hi= MSR_MC,.lo= 0x0}, /* Catch and fix dynamicly. */
32 {.desc_name=GLIU0_GLD_MSR_COH,.desc_type= OTHER,.hi= 0x0,.lo= GL0_CPU},
33 {.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}, /* Catch and fix dynamicly. */
41 {.desc_name=MSR_GLIU1_DMM,.desc_type= BM_DMM,.hi= MSR_GL0,.lo= 0x0}, /* Catch and fix dynamicly. */
42 {.desc_name=MSR_GLIU1_SMM,.desc_type= BM_SMM,.hi= MSR_GL0,.lo= 0x0}, /* Catch 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};
56 struct msrinit ClockGatingDefault [] = {
57 {GLIU0_GLD_MSR_PM, {.hi=0x00,.lo=0x0005}},
58 /* MC must stay off in SDR mode. It is turned on in CPUBug??? lotus #77.142 */
59 {MC_GLD_MSR_PM, {.hi=0x00,.lo=0x0000}},
60 {GLIU1_GLD_MSR_PM, {.hi=0x00,.lo=0x0005}},
61 {VG_GLD_MSR_PM, {.hi=0x00,.lo=0x0000}}, /* lotus #77.163 */
62 {GP_GLD_MSR_PM, {.hi=0x00,.lo=0x0001}},
63 {DF_GLD_MSR_PM, {.hi=0x00,.lo=0x0155}},
64 {GLCP_GLD_MSR_PM, {.hi=0x00,.lo=0x0015}},
65 {GLPCI_GLD_MSR_PM, {.hi=0x00,.lo=0x0015}},
66 {FG_GLD_MSR_PM, {.hi=0x00,.lo=0x0000}}, /* Always on */
67 {0xffffffff, {0xffffffff, 0xffffffff}},
71 struct msrinit ClockGatingAllOn[] = {
72 {GLIU0_GLD_MSR_PM, {.hi=0x00,.lo=0x0FFFFFFFF}},
73 {MC_GLD_MSR_PM, {.hi=0x00,.lo=0x0FFFFFFFF}},
74 {GLIU1_GLD_MSR_PM, {.hi=0x00,.lo=0x0FFFFFFFF}},
75 {VG_GLD_MSR_PM, {.hi=0x00, .lo=0x00}},
76 {GP_GLD_MSR_PM, {.hi=0x00,.lo=0x000000001}},
77 {DF_GLD_MSR_PM, {.hi=0x00,.lo=0x0FFFFFFFF}},
78 {GLCP_GLD_MSR_PM, {.hi=0x00,.lo=0x0FFFFFFFF}},
79 {GLPCI_GLD_MSR_PM, {.hi=0x00,.lo=0x0FFFFFFFF}},
80 {FG_GLD_MSR_PM, {.hi=0x00,.lo=0x0000}},
81 {0xffffffff, {0xffffffff, 0xffffffff}},
85 struct msrinit ClockGatingPerformance[] = {
86 {VG_GLD_MSR_PM, {.hi=0x00,.lo=0x0000}}, /* lotus #77.163 */
87 {GP_GLD_MSR_PM, {.hi=0x00,.lo=0x0001}},
88 {DF_GLD_MSR_PM, {.hi=0x00,.lo=0x0155}},
89 {GLCP_GLD_MSR_PM, {.hi=0x00,.lo=0x0015}},
90 {0xffffffff, {0xffffffff, 0xffffffff}},
93 /* SET GeodeLink PRIORITY */
94 struct msrinit GeodeLinkPriorityTable [] = {
95 {CPU_GLD_MSR_CONFIG, {.hi=0x00,.lo=0x0220}}, /* CPU Priority. */
96 {DF_GLD_MSR_MASTER_CONF, {.hi=0x00,.lo=0x0000}}, /* DF Priority. */
97 {VG_GLD_MSR_CONFIG, {.hi=0x00,.lo=0x0720}}, /* VG Primary and Secondary Priority. */
98 {GP_GLD_MSR_CONFIG, {.hi=0x00,.lo=0x0010}}, /* Graphics Priority. */
99 {GLPCI_GLD_MSR_CONFIG, {.hi=0x00,.lo=0x0027}}, /* GLPCI Priority + PID */
100 {GLCP_GLD_MSR_CONF, {.hi=0x00,.lo=0x0001}}, /* GLCP Priority + PID */
101 {VIP_GLD_MSR_CONFIG, {.hi=0x00,.lo=0x0622}}, /* VIP PID */
102 {AES_GLD_MSR_CONFIG, {.hi=0x00,.lo=0x0013}}, /* AES PID */
103 {0x0FFFFFFFF, {0x0FFFFFFFF, 0x0FFFFFFFF}}, /* END */
106 /* do we have dmi or not? assume NO per AMD */
109 static void writeglmsr(struct gliutable *gl)
115 wrmsr(gl->desc_name, msr); /* MSR - see table above */
116 printk(BIOS_DEBUG, "%s: write msr 0x%08lx, val 0x%08x:0x%08x\n", __func__, gl->desc_name, msr.hi, msr.lo);
117 /* they do this, so we do this */
118 msr = rdmsr(gl->desc_name);
119 printk(BIOS_DEBUG, "%s: AFTER write msr 0x%08lx, val 0x%08x:0x%08x\n", __func__, gl->desc_name, msr.hi, msr.lo);
122 static void 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. */
137 static void SysmemInit(struct gliutable *gl)
140 int sizembytes, sizebytes;
142 /* Figure out how much RAM is in the machine and alocate all to the
143 * system. We will adjust for SMM and DMM now and Frame Buffer later.
145 sizembytes = sizeram();
146 printk(BIOS_DEBUG, "%s: enable for %dm bytes\n", __func__, sizembytes);
147 sizebytes = sizembytes << 20;
149 sizebytes -= SMM_SIZE*1024 +1;
152 sizebytes -= DMM_SIZE * 1024 + 1;
155 msr.hi = (gl->hi & 0xFFFFFF00) | (sizebytes >> 24);
156 /* set up sizebytes to fit into msr.lo */
157 sizebytes <<= 8; /* what? well, we want bits 23:12 in bits 31:20. */
158 sizebytes &= 0xfff00000;
161 wrmsr(gl->desc_name, msr); /* MSR - see table above */
162 msr = rdmsr(gl->desc_name);
163 printk(BIOS_DEBUG, "%s: AFTER write msr 0x%08lx, val 0x%08x:0x%08x\n", __func__,
164 gl->desc_name, msr.hi, msr.lo);
167 static void DMMGL0Init(struct gliutable *gl)
170 int sizebytes = sizeram()<<20;
176 printk(BIOS_DEBUG, "%s: %d bytes\n", __func__, sizebytes);
178 sizebytes -= DMM_SIZE*1024;
179 offset = sizebytes - DMM_OFFSET;
180 printk(BIOS_DEBUG, "%s: offset is 0x%08lx\n", __func__, offset);
182 msr.hi = (gl->hi) | (offset << 8);
183 /* I don't think this is needed */
184 msr.hi &= 0xffffff00;
185 msr.hi |= (DMM_OFFSET >> 24);
186 msr.lo = DMM_OFFSET << 8;
187 msr.lo |= ((~(DMM_SIZE*1024)+1)>>12)&0xfffff;
189 wrmsr(gl->desc_name, msr); /* MSR - See table above */
190 msr = rdmsr(gl->desc_name);
191 printk(BIOS_DEBUG, "%s: AFTER write msr 0x%08lx, val 0x%08x:0x%08x\n", __func__, gl->desc_name, msr.hi, msr.lo);
194 static void DMMGL1Init(struct gliutable *gl)
201 printk(BIOS_DEBUG, "%s:\n", __func__ );
204 /* I don't think this is needed */
205 msr.hi &= 0xffffff00;
206 msr.hi |= (DMM_OFFSET >> 24);
207 msr.lo = DMM_OFFSET << 8;
208 /* hmm. AMD source has SMM here ... SMM, not DMM? We think DMM */
209 printk(BIOS_ERR, "%s: warning, using DMM_SIZE even though AMD used SMM_SIZE\n", __func__);
210 msr.lo |= ((~(DMM_SIZE*1024)+1)>>12)&0xfffff;
212 wrmsr(gl->desc_name, msr); /* MSR - See table above */
213 msr = rdmsr(gl->desc_name);
214 printk(BIOS_DEBUG, "%s: AFTER write msr 0x%08lx, val 0x%08x:0x%08x\n", __func__, gl->desc_name, msr.hi, msr.lo);
217 static void SMMGL0Init(struct gliutable *gl)
220 int sizebytes = sizeram()<<20;
223 sizebytes -= SMM_SIZE*1024;
226 sizebytes -= DMM_SIZE * 1024;
228 printk(BIOS_DEBUG, "%s: %d bytes\n", __func__, sizebytes);
230 offset = sizebytes - SMM_OFFSET;
231 printk(BIOS_DEBUG, "%s: offset is 0x%08lx\n", __func__, offset);
234 msr.hi = offset << 8;
235 msr.hi |= SMM_OFFSET>>24;
237 msr.lo = SMM_OFFSET << 8;
238 msr.lo |= ((~(SMM_SIZE*1024)+1)>>12)&0xfffff;
240 wrmsr(gl->desc_name, msr); /* MSR - See table above */
241 msr = rdmsr(gl->desc_name);
242 printk(BIOS_DEBUG, "%s: AFTER write msr 0x%08lx, val 0x%08x:0x%08x\n", __func__, gl->desc_name, msr.hi, msr.lo);
245 static void SMMGL1Init(struct gliutable *gl)
248 printk(BIOS_DEBUG, "%s:\n", __func__ );
251 /* I don't think this is needed */
252 msr.hi &= 0xffffff00;
253 msr.hi |= (SMM_OFFSET >> 24);
254 msr.lo = SMM_OFFSET << 8;
255 msr.lo |= ((~(SMM_SIZE*1024)+1)>>12)&0xfffff;
257 wrmsr(gl->desc_name, msr); /* MSR - See table above */
258 msr = rdmsr(gl->desc_name);
259 printk(BIOS_DEBUG, "%s: AFTER write msr 0x%08lx, val 0x%08x:0x%08x\n", __func__, gl->desc_name, msr.hi, msr.lo);
262 static void GLIUInit(struct gliutable *gl)
264 while (gl->desc_type != GL_END){
265 switch(gl->desc_type){
267 /* For Unknown types: Write then read MSR */
269 case SC_SHADOW: /* Check for a Shadow entry */
273 case R_SYSMEM: /* check for a SYSMEM entry */
277 case BMO_DMM: /* check for a DMM entry */
281 case BM_DMM : /* check for a DMM entry */
285 case BMO_SMM : /* check for a SMM entry */
289 case BM_SMM : /* check for a SMM entry */
297 /* Set up GLPCI settings for reads/write into memory.
300 * R1: 1MB - Top of System Memory
302 * R3: Framebuffer? - not set up yet
305 static void GLPCIInit(void)
307 struct gliutable *gl = 0;
312 /* R0 - GLPCI settings for Conventional Memory space. */
313 msr.hi = (0x09F000 >> 12) << GLPCI_RC_UPPER_TOP_SHIFT; /* 640 */
315 msr.lo |= GLPCI_RC_LOWER_EN_SET+ GLPCI_RC_LOWER_PF_SET + GLPCI_RC_LOWER_WC_SET;
319 /* R1 - GLPCI settings for SysMem space. */
320 /* Get systop from GLIU0 SYSTOP Descriptor */
321 for(i = 0; gliu0table[i].desc_name != GL_END; i++) {
322 if (gliu0table[i].desc_type == R_SYSMEM) {
328 unsigned long pah, pal;
329 msrnum = gl->desc_name;
331 /* example R_SYSMEM value: 20:00:00:0f:fb:f0:01:00
332 * translates to a base of 0x00100000 and top of 0xffbf0000
333 * base of 1M and top of around 256M
335 /* we have to create a page-aligned (4KB page) address for base and top
336 * so we need a high page aligned addresss (pah) and low page aligned address (pal)
337 * pah is from msr.hi << 12 | msr.low >> 20. pal is msr.lo << 12
339 printk(BIOS_DEBUG, "GLPCI r1: system msr.lo 0x%08x msr.hi 0x%08x\n", msr.lo, msr.hi);
340 pah = ((msr.hi &0xff) << 12) | ((msr.lo >> 20) & 0xfff);
341 /* we have the page address. Now make it a page-aligned address */
347 msr.lo |= GLPCI_RC_LOWER_EN_SET | GLPCI_RC_LOWER_PF_SET | GLPCI_RC_LOWER_WC_SET;
348 printk(BIOS_DEBUG, "GLPCI r1: system msr.lo 0x%08x msr.hi 0x%08x\n", msr.lo, msr.hi);
353 /* R2 - GLPCI settings for SMM space. */
354 msr.hi = ((SMM_OFFSET+(SMM_SIZE*1024-1)) >> 12) << GLPCI_RC_UPPER_TOP_SHIFT;
355 msr.lo = (SMM_OFFSET >> 12) << GLPCI_RC_LOWER_BASE_SHIFT;
356 msr.lo |= GLPCI_RC_LOWER_EN_SET | GLPCI_RC_LOWER_PF_SET;
360 /* this is done elsewhere already, but it does no harm to do it more than once */
361 /* write serialize memory hole to PCI. Need to to unWS when something is shadowed regardless of cachablility. */
362 msr.lo = 0x021212121; /* cache disabled and write serialized */
363 msr.hi = 0x021212121; /* cache disabled and write serialized */
365 msrnum = CPU_RCONF_A0_BF;
368 msrnum = CPU_RCONF_C0_DF;
371 msrnum = CPU_RCONF_E0_FF;
374 /* Set Non-Cacheable Read Only for NorthBound Transactions to Memory. The Enable bit is handled in the Shadow setup. */
375 msrnum = GLPCI_A0_BF;
380 msrnum = GLPCI_C0_DF;
385 msrnum = GLPCI_E0_FF;
391 msrnum = CPU_DM_CONFIG0;
393 msr.hi &= ~ (7 << DM_CONFIG0_UPPER_WSREQ_SHIFT);
394 msr.hi |= 2 << DM_CONFIG0_UPPER_WSREQ_SHIFT ; /* reduce to 1 for safe mode. */
397 /* we are ignoring the 5530 case for now, and perhaps forever. */
402 msr.hi |= GLPCI_ARB_UPPER_PRE0_SET | GLPCI_ARB_UPPER_PRE1_SET;
403 msr.lo |= GLPCI_ARB_LOWER_IIE_SET;
409 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 .) */
410 msr.lo |= GLPCI_CTRL_LOWER_LDE_SET;
412 msr.lo &= ~ (0x03 << GLPCI_CTRL_LOWER_IRFC_SHIFT);
413 msr.lo |= 0x02 << GLPCI_CTRL_LOWER_IRFC_SHIFT;
415 msr.lo &= ~ (0x07 << GLPCI_CTRL_LOWER_IRFT_SHIFT);
416 msr.lo |= 0x06 << GLPCI_CTRL_LOWER_IRFT_SHIFT;
418 msr.hi &= ~ (0x0f << GLPCI_CTRL_UPPER_FTH_SHIFT);
419 msr.hi |= 0x0F << GLPCI_CTRL_UPPER_FTH_SHIFT;
421 msr.hi &= ~ (0x0f << GLPCI_CTRL_UPPER_RTH_SHIFT);
422 msr.hi |= 0x0F << GLPCI_CTRL_UPPER_RTH_SHIFT;
424 msr.hi &= ~ (0x0f << GLPCI_CTRL_UPPER_SBRTH_SHIFT);
425 msr.hi |= 0x0F << GLPCI_CTRL_UPPER_SBRTH_SHIFT;
427 msr.hi &= ~ (0x03 << GLPCI_CTRL_UPPER_WTO_SHIFT);
428 msr.hi |= 0x06 << GLPCI_CTRL_UPPER_WTO_SHIFT;
430 msr.hi &= ~ (0x03 << GLPCI_CTRL_UPPER_ILTO_SHIFT);
431 msr.hi |= 0x00 << GLPCI_CTRL_UPPER_ILTO_SHIFT;
434 /* Set GLPCI Latency Timer. */
437 msr.hi |= 0x1F << GLPCI_CTRL_UPPER_LAT_SHIFT; /* Change once 1.x is gone. */
441 msrnum = GLPCI_SPARE;
444 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;
448 /* Enable Clock Gating. */
449 static void ClockGatingInit (void)
452 struct msrinit *gating = ClockGatingDefault;
456 mov cx, TOKEN_CLK_GATE
457 NOSTACK bx, GetNVRAMValueBX
458 cmp al, TVALUE_CG_OFF
461 cmp al, TVALUE_CG_DEFAULT
464 lea si, ClockGatingDefault
468 lea si, ClockGatingAllOn
472 lea si, ClockGatingPerformance
475 for(i = 0; gating->msrnum != 0xffffffff; i++) {
476 msr = rdmsr(gating->msrnum);
477 printk(BIOS_DEBUG, "%s: MSR 0x%08lx is 0x%08x:0x%08x\n", __func__, gating->msrnum, msr.hi, msr.lo);
478 msr.hi |= gating->msr.hi;
479 msr.lo |= gating->msr.lo;
480 printk(BIOS_DEBUG, "%s: MSR 0x%08lx will be set to 0x%08x:0x%08x\n", __func__,
481 gating->msrnum, msr.hi, msr.lo);
482 wrmsr(gating->msrnum, msr); /* MSR - See the table above */
487 static void GeodeLinkPriority(void)
490 struct msrinit *prio = GeodeLinkPriorityTable;
493 for(i = 0; prio->msrnum != 0xffffffff; i++) {
494 msr = rdmsr(prio->msrnum);
495 printk(BIOS_DEBUG, "%s: MSR 0x%08lx is 0x%08x:0x%08x\n", __func__, prio->msrnum, msr.hi, msr.lo);
496 msr.hi |= prio->msr.hi;
498 msr.lo |= prio->msr.lo;
499 printk(BIOS_DEBUG, "%s: MSR 0x%08lx will be set to 0x%08x:0x%08x\n", __func__,
500 prio->msrnum, msr.hi, msr.lo);
501 wrmsr(prio->msrnum, msr); /* MSR - See the table above */
506 /* Get the GLIU0 shadow register settings.
508 * If the setShadow function is used then all shadow descriptors
511 static uint64_t getShadow(void)
514 msr = rdmsr(MSR_GLIU0_SHADOW);
515 return ( ( (uint64_t) msr.hi ) << 32 ) | msr.lo;
518 /* Set the cache RConf registers for the memory hole.
520 * Keeps all cache shadow descriptors sync'ed.
521 * This is part of the PCI lockup solution.
523 * Entry: EDX:EAX is the shadow settings.
525 static void setShadowRCONF(uint32_t shadowHi, uint32_t shadowLo)
527 /* ok this is whacky bit translation time. */
531 shadowByte = (uint8_t) (shadowLo >> 16);
533 /* load up D000 settings in edx. */
534 for (bit = 8; (bit > 4); bit--) {
536 msr.hi |= 1; /* cache disable PCI/Shadow memory */
537 if (shadowByte && (1 << bit))
538 msr.hi |= 0x20; /* write serialize PCI memory */
541 /* load up C000 settings in eax. */
542 for ( ; bit; bit--) {
544 msr.lo |= 1; /* cache disable PCI/Shadow memory */
545 if (shadowByte && (1 << bit))
546 msr.lo |= 0x20; /* write serialize PCI memory */
549 wrmsr(CPU_RCONF_C0_DF, msr);
551 shadowByte = (uint8_t) (shadowLo >> 24);
553 /* load up F000 settings in edx. */
554 for (bit = 8; (bit > 4); bit--) {
556 msr.hi |= 1; /* cache disable PCI/Shadow memory */
557 if (shadowByte && (1 << bit))
558 msr.hi |= 0x20; /* write serialize PCI memory */
561 /* load up E000 settings in eax. */
562 for ( ; bit; bit--) {
564 msr.lo |= 1; /* cache disable PCI/Shadow memory */
565 if (shadowByte && (1 << bit))
566 msr.lo |= 0x20; /* write serialize PCI memory */
569 wrmsr(CPU_RCONF_E0_FF, msr);
572 /* Set the GLPCI registers for the memory hole.
573 * Keeps all cache shadow descriptors sync'ed.
574 * Entry: EDX:EAX is the shadow settings
576 static void setShadowGLPCI(uint32_t shadowHi, uint32_t shadowLo)
580 /* Set the Enable Register. */
581 msr = rdmsr(GLPCI_REN);
582 msr.lo &= 0xFFFF00FF;
583 msr.lo |= ( (shadowLo & 0xFFFF0000) >> 8);
584 wrmsr(GLPCI_REN, msr);
587 /* Set the GLIU SC register settings. Scans descriptor tables for SC_SHADOW.
588 * Keeps all shadow descriptors sync'ed.
589 * Entry: EDX:EAX is the shadow settings
591 static void setShadow(uint64_t shadowSettings)
595 struct gliutable* pTable;
596 uint32_t shadowLo, shadowHi;
598 shadowLo = (uint32_t) shadowSettings;
599 shadowHi = (uint32_t) (shadowSettings >> 32);
601 setShadowRCONF(shadowHi, shadowLo);
602 setShadowGLPCI(shadowHi, shadowLo);
604 for(i = 0; gliutables[i]; i++) {
605 for (pTable = gliutables[i]; pTable->desc_type != GL_END; pTable++) {
606 if (pTable->desc_type == SC_SHADOW) {
608 msr = rdmsr(pTable->desc_name);
609 msr.lo = (uint32_t) shadowSettings;
610 msr.hi &= 0xFFFF0000; /* maintain PDID in upper EDX */
611 msr.hi |= ((uint32_t) (shadowSettings >> 32)) & 0x0000FFFF;
612 wrmsr(pTable->desc_name, msr); /* MSR - See the table above */
619 /* Set up a stack for ease of further testing. */
620 static void shadowRom(void)
622 uint64_t shadowSettings = getShadow();
623 shadowSettings &= (uint64_t) 0xFFFF00000000FFFFULL; /* Disable read & writes */
624 shadowSettings |= (uint64_t) 0x0000FFFFFFFF0000ULL; /* Enable reads for C0000-FFFFF */
625 setShadow(shadowSettings);
628 /* Set up RCONF_DEFAULT and any other RCONF registers needed.
630 * DEVRC_RCONF_DEFAULT:
631 * ROMRC(63:56) = 04h ; write protect ROMBASE
632 * ROMBASE(36:55) = 0FFFC0h ; Top of PCI/bottom of rom chipselect area
633 * DEVRC(35:28) = 39h ; cache disabled in PCI memory + WS bit on + Write Combine + write burst.
634 * SYSTOP(27:8) = top of system memory
635 * SYSRC(7:0) = 00h ; writeback, can set to 08h to make writethrough
637 #define SYSMEM_RCONF_WRITETHROUGH 8
638 #define DEVRC_RCONF_DEFAULT 0x21
639 #define ROMBASE_RCONF_DEFAULT 0xFFFC0000
640 #define ROMRC_RCONF_DEFAULT 0x25
642 static void RCONFInit(void)
644 struct gliutable *gl = 0;
647 uint8_t SysMemCacheProp;
649 /* Locate SYSMEM entry in GLIU0table */
650 for(i = 0; gliu0table[i].desc_name != GL_END; i++) {
651 if (gliu0table[i].desc_type == R_SYSMEM) {
657 post_code(0xCE); /* POST_RCONFInitError */
662 /* found the descriptor... get its contents */
663 msr = rdmsr(gl->desc_name);
665 /* 20 bit address - The bottom 12 bits go into bits 20-31 in eax, the
666 * top 8 bits go into 0-7 of edx.
668 msr.lo = (msr.lo & 0xFFFFFF00) | (msr.hi & 0xFF);
669 msr.lo = ((msr.lo << 12) | (msr.lo >> 20)) & 0x000FFFFF;
670 msr.lo <<= RCONF_DEFAULT_LOWER_SYSTOP_SHIFT; /* 8 */
672 /* Set Default SYSMEM region properties */
673 msr.lo &= ~SYSMEM_RCONF_WRITETHROUGH; /* 8 (or ~8) */
675 /* Set PCI space cache properties */
676 msr.hi = (DEVRC_RCONF_DEFAULT >> 4); /* only need the bottom bits and lets clean the rest of edx */
677 msr.lo |= (DEVRC_RCONF_DEFAULT << 28);
679 /* Set the ROMBASE. This is usually FFFC0000h */
680 msr.hi |= (ROMBASE_RCONF_DEFAULT >> 12) << RCONF_DEFAULT_UPPER_ROMBASE_SHIFT;
682 /* Set ROMBASE cache properties. */
683 msr.hi |= ((ROMRC_RCONF_DEFAULT >> 8) | (ROMRC_RCONF_DEFAULT << 24));
685 /* now program RCONF_DEFAULT */
686 wrmsr(CPU_RCONF_DEFAULT, msr);
688 /* RCONF_BYPASS: Cache tablewalk properties and SMM/DMM header access properties. */
689 /* Set to match system memory cache properties. */
690 msr = rdmsr(CPU_RCONF_DEFAULT);
691 SysMemCacheProp = (uint8_t) (msr.lo & 0xFF);
692 msr = rdmsr(CPU_RCONF_BYPASS);
693 msr.lo = (msr.lo & 0xFFFF0000) | (SysMemCacheProp << 8) | SysMemCacheProp;
694 wrmsr(CPU_RCONF_BYPASS, msr);
697 /* Core Logic initialization: Host bridge. */
698 void northbridgeinit(void)
702 printk(BIOS_DEBUG, "Enter %s\n", __func__);
704 for(i = 0; gliutables[i]; i++)
705 GLIUInit(gliutables[i]);
711 /* GeodeROM ensures that the BIOS waits the required 1 second before */
712 /* allowing anything to access PCI */
717 /* The cacheInit function in GeodeROM tests cache and, among other things,
718 * makes sure all INVD instructions are treated as WBINVD. We do this
719 * because we've found some programs which require this behavior.
720 * That subset of cacheInit() is implemented here:
722 msr = rdmsr(CPU_DM_CONFIG0);
723 msr.lo |= DM_CONFIG0_LOWER_WBINVD_SET;
724 wrmsr(CPU_DM_CONFIG0, msr);
726 /* Now that the descriptor to memory is set up. */
727 /* The memory controller needs one read to synch its lines before it can be used. */
733 /* CPUBugsFix -- called elsewhere */
734 printk(BIOS_DEBUG, "Exit %s\n", __func__);