2 * This file is part of the coreboot project.
4 * Copyright (C) 2007 Advanced Micro Devices, Inc.
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21 #include <console/console.h>
24 #include <device/device.h>
25 #include <device/pci.h>
26 #include <device/pci_ids.h>
31 #include "northbridge.h"
32 #include <cpu/amd/lxdef.h>
33 #include <cpu/x86/msr.h>
34 #include <cpu/x86/cache.h>
37 unsigned long desc_name;
38 unsigned short desc_type;
42 struct gliutable gliu0table[] = {
43 {.desc_name = MSR_GLIU0_BASE1,.desc_type = BM,.hi = MSR_MC + 0x0,.lo = 0x0FFF80}, /* 0-7FFFF to MC */
44 {.desc_name = MSR_GLIU0_BASE2,.desc_type = BM,.hi = MSR_MC + 0x0,.lo = (0x80 << 20) + 0x0FFFE0}, /* 80000-9ffff to Mc */
45 {.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 */
46 {.desc_name = MSR_GLIU0_SYSMEM,.desc_type = R_SYSMEM,.hi = MSR_MC,.lo = 0x0}, /* Catch and fix dynamicly. */
47 {.desc_name = MSR_GLIU0_SMM,.desc_type = BMO_SMM,.hi = MSR_MC,.lo = 0x0}, /* Catch and fix dynamicly. */
48 {.desc_name = GLIU0_GLD_MSR_COH,.desc_type = OTHER,.hi = 0x0,.lo =
50 {.desc_name = GL_END,.desc_type = GL_END,.hi = 0x0,.lo = 0x0},
53 struct gliutable gliu1table[] = {
54 {.desc_name = MSR_GLIU1_BASE1,.desc_type = BM,.hi = MSR_GL0 + 0x0,.lo = 0x0FFF80}, /* 0-7FFFF to MC */
55 {.desc_name = MSR_GLIU1_BASE2,.desc_type = BM,.hi = MSR_GL0 + 0x0,.lo = (0x80 << 20) + 0x0FFFE0}, /* 80000-9ffff to Mc */
56 {.desc_name = MSR_GLIU1_SHADOW,.desc_type = SC_SHADOW,.hi = MSR_GL0 + 0x0,.lo = 0x03}, /* C0000-Fffff split to MC and PCI (sub decode) */
57 {.desc_name = MSR_GLIU1_SYSMEM,.desc_type = R_SYSMEM,.hi = MSR_GL0,.lo = 0x0}, /* Catch and fix dynamicly. */
58 {.desc_name = MSR_GLIU1_SMM,.desc_type = BM_SMM,.hi = MSR_GL0,.lo = 0x0}, /* Catch and fix dynamicly. */
59 {.desc_name = GLIU1_GLD_MSR_COH,.desc_type = OTHER,.hi = 0x0,.lo =
61 {.desc_name = MSR_GLIU1_FPU_TRAP,.desc_type = SCIO,.hi = (GL1_GLCP << 29) + 0x0,.lo = 0x033000F0}, /* FooGlue FPU 0xF0 */
62 {.desc_name = GL_END,.desc_type = GL_END,.hi = 0x0,.lo = 0x0},
65 struct gliutable *gliutables[] = { gliu0table, gliu1table, 0 };
72 struct msrinit ClockGatingDefault[] = {
73 {GLIU0_GLD_MSR_PM, {.hi = 0x00,.lo = 0x0005}},
74 {MC_GLD_MSR_PM, {.hi = 0x00,.lo = 0x0001}},
75 {VG_GLD_MSR_PM, {.hi = 0x00,.lo = 0x0015}},
76 {GP_GLD_MSR_PM, {.hi = 0x00,.lo = 0x0001}},
77 {DF_GLD_MSR_PM, {.hi = 0x00,.lo = 0x0555}},
78 {GLIU1_GLD_MSR_PM, {.hi = 0x00,.lo = 0x0005}},
79 {GLCP_GLD_MSR_PM, {.hi = 0x00,.lo = 0x0014}},
80 {GLPCI_GLD_MSR_PM, {.hi = 0x00,.lo = 0x0015}},
81 {VIP_GLD_MSR_PM, {.hi = 0x00,.lo = 0x0005}},
82 {AES_GLD_MSR_PM, {.hi = 0x00,.lo = 0x0015}},
83 {CPU_BC_PMODE_MSR, {.hi = 0x00,.lo = 0x70303}},
84 {0xffffffff, {0xffffffff, 0xffffffff}},
88 /* SET GeodeLink PRIORITY*/
90 struct msrinit GeodeLinkPriorityTable[] = {
91 {CPU_GLD_MSR_CONFIG, {.hi = 0x00,.lo = 0x0220}},
92 {DF_GLD_MSR_MASTER_CONF, {.hi = 0x00,.lo = 0x0000}},
93 {VG_GLD_MSR_CONFIG, {.hi = 0x00,.lo = 0x0720}},
94 {GP_GLD_MSR_CONFIG, {.hi = 0x00,.lo = 0x0010}},
95 {GLPCI_GLD_MSR_CONFIG, {.hi = 0x00,.lo = 0x0017}},
96 {GLCP_GLD_MSR_CONF, {.hi = 0x00,.lo = 0x0001}},
97 {VIP_GLD_MSR_CONFIG, {.hi = 0x00,.lo = 0x0622}},
98 {AES_GLD_MSR_CONFIG, {.hi = 0x00,.lo = 0x0013}},
99 {0x0FFFFFFFF, {0x0FFFFFFFF, 0x0FFFFFFFF}}, /* END */
102 extern int sizeram(void);
104 static void writeglmsr(struct gliutable *gl)
110 wrmsr(gl->desc_name, msr); // MSR - see table above
111 printk_debug("%s: MSR 0x%08x, val 0x%08x:0x%08x\n", __FUNCTION__, gl->desc_name, msr.hi, msr.lo); // GX3
114 static void ShadowInit(struct gliutable *gl)
118 msr = rdmsr(gl->desc_name);
125 extern int sizeram(void);
126 static void SysmemInit(struct gliutable *gl)
129 int sizembytes, sizebytes;
132 * Figure out how much RAM is in the machine and alocate all to the
133 * system. We will adjust for SMM now and Frame Buffer later.
135 sizembytes = sizeram();
136 printk_debug("%s: enable for %dMBytes\n", __FUNCTION__, sizembytes);
137 sizebytes = sizembytes << 20;
139 sizebytes -= ((SMM_SIZE * 1024) + 1);
140 printk_debug("usable RAM: %d bytes\n", sizebytes);
142 /* 20 bit address The bottom 12 bits go into bits 20-31 in msr.lo
143 The top 8 bits go into 0-7 of msr.hi. */
145 msr.hi = (gl->hi & 0xFFFFFF00) | (sizebytes >> 24);
146 sizebytes <<= 8; /* move bits 23:12 in bits 31:20. */
147 sizebytes &= 0xfff00000;
148 sizebytes |= 0x100; /* start at 1MB */
151 wrmsr(gl->desc_name, msr); // MSR - see table above
152 printk_debug("%s: MSR 0x%08x, val 0x%08x:0x%08x\n", __FUNCTION__,
153 gl->desc_name, msr.hi, msr.lo);
156 static void SMMGL0Init(struct gliutable *gl)
159 int sizebytes = sizeram() << 20;
162 sizebytes -= (SMM_SIZE * 1024);
164 printk_debug("%s: %d bytes\n", __FUNCTION__, sizebytes);
166 /* calculate the Two's complement offset */
167 offset = sizebytes - SMM_OFFSET;
168 offset = (offset >> 12) & 0x000fffff;
169 printk_debug("%s: offset is 0x%08x\n", __FUNCTION__, SMM_OFFSET);
171 msr.hi = offset << 8 | gl->hi;
172 msr.hi |= SMM_OFFSET >> 24;
174 msr.lo = SMM_OFFSET << 8;
175 msr.lo |= ((~(SMM_SIZE * 1024) + 1) >> 12) & 0xfffff;
177 wrmsr(gl->desc_name, msr); // MSR - See table above
178 printk_debug("%s: MSR 0x%08x, val 0x%08x:0x%08x\n", __FUNCTION__,
179 gl->desc_name, msr.hi, msr.lo);
182 static void SMMGL1Init(struct gliutable *gl)
185 printk_debug("%s:\n", __FUNCTION__);
188 /* I don't think this is needed */
189 msr.hi &= 0xffffff00;
190 msr.hi |= (SMM_OFFSET >> 24);
191 msr.lo = (SMM_OFFSET << 8) & 0xFFF00000;
192 msr.lo |= ((~(SMM_SIZE * 1024) + 1) >> 12) & 0xfffff;
194 wrmsr(gl->desc_name, msr); // MSR - See table above
195 printk_debug("%s: MSR 0x%08x, val 0x%08x:0x%08x\n", __FUNCTION__,
196 gl->desc_name, msr.hi, msr.lo);
199 static void GLIUInit(struct gliutable *gl)
202 while (gl->desc_type != GL_END) {
203 switch (gl->desc_type) {
205 /* For Unknown types: Write then read MSR */
207 case SC_SHADOW: /* Check for a Shadow entry */
211 case R_SYSMEM: /* check for a SYSMEM entry */
215 case BMO_SMM: /* check for a SMM entry */
219 case BM_SMM: /* check for a SMM entry */
228 /* ************************************************************************** */
232 /* * Set up GLPCI settings for reads/write into memory */
234 /* * R1: 1MB - Top of System Memory */
235 /* * R2: SMM Memory */
236 /* * R3: Framebuffer? - not set up yet */
243 /* ************************************************************************** */
244 static void GLPCIInit(void)
246 struct gliutable *gl = 0;
249 int msrnum, enable_preempt, enable_cpu_override;
250 int nic_grants_control, enable_bus_parking;
253 /* R0 - GLPCI settings for Conventional Memory space. */
255 msr.hi = (0x09F000 >> 12) << GLPCI_RC_UPPER_TOP_SHIFT; /* 640 */
258 GLPCI_RC_LOWER_EN_SET + GLPCI_RC_LOWER_PF_SET +
259 GLPCI_RC_LOWER_WC_SET;
264 /* R1 - GLPCI settings for SysMem space. */
266 /* Get systop from GLIU0 SYSTOP Descriptor */
267 for (i = 0; gliu0table[i].desc_name != GL_END; i++) {
268 if (gliu0table[i].desc_type == R_SYSMEM) {
274 unsigned long pah, pal;
275 msrnum = gl->desc_name;
277 /* example R_SYSMEM value: 20:00:00:0f:fb:f0:01:00
278 * translates to a base of 0x00100000 and top of 0xffbf0000
279 * base of 1M and top of around 256M
281 /* we have to create a page-aligned (4KB page) address for base and top */
282 /* So we need a high page aligned addresss (pah) and low page aligned address (pal)
283 * pah is from msr.hi << 12 | msr.low >> 20. pal is msr.lo << 12
285 pah = ((msr.hi & 0xFF) << 12) | ((msr.lo >> 20) & 0xFFF);
286 /* we have the page address. Now make it a page-aligned address */
293 GLPCI_RC_LOWER_EN_SET | GLPCI_RC_LOWER_PF_SET |
294 GLPCI_RC_LOWER_WC_SET;
295 printk_debug("GLPCI R1: system msr.lo 0x%08x msr.hi 0x%08x\n",
302 /* R2 - GLPCI settings for SMM space */
306 (SMM_SIZE * 1024 - 1)) >> 12) << GLPCI_RC_UPPER_TOP_SHIFT;
307 msr.lo = (SMM_OFFSET >> 12) << GLPCI_RC_LOWER_BASE_SHIFT;
308 msr.lo |= GLPCI_RC_LOWER_EN_SET | GLPCI_RC_LOWER_PF_SET;
309 printk_debug("GLPCI R2: system msr.lo 0x%08x msr.hi 0x%08x\n", msr.lo,
314 /* this is done elsewhere already, but it does no harm to do it more than once */
315 /* write serialize memory hole to PCI. Need to to unWS when something is shadowed regardless of cachablility. */
316 msr.lo = 0x021212121; /* cache disabled and write serialized */
317 msr.hi = 0x021212121; /* cache disabled and write serialized */
319 msrnum = CPU_RCONF_A0_BF;
322 msrnum = CPU_RCONF_C0_DF;
325 msrnum = CPU_RCONF_E0_FF;
328 /* Set Non-Cacheable Read Only for NorthBound Transactions to Memory. The Enable bit is handled in the Shadow setup. */
329 msrnum = GLPCI_A0_BF;
334 msrnum = GLPCI_C0_DF;
339 msrnum = GLPCI_E0_FF;
345 msrnum = CPU_DM_CONFIG0;
347 msr.hi &= ~(7 << DM_CONFIG0_UPPER_WSREQ_SHIFT);
348 msr.hi |= 2 << DM_CONFIG0_UPPER_WSREQ_SHIFT; /* reduce to 1 for safe mode */
351 /* we are ignoring the 5530 case for now, and perhaps forever. */
359 GLPCI_ARB_LOWER_PRE0_SET | GLPCI_ARB_LOWER_PRE1_SET |
360 GLPCI_ARB_LOWER_PRE2_SET | GLPCI_ARB_LOWER_CPRE_SET;
361 enable_cpu_override = GLPCI_ARB_LOWER_COV_SET;
362 enable_bus_parking = GLPCI_ARB_LOWER_PARK_SET;
364 (0x4 << GLPCI_ARB_UPPER_R2_SHIFT) | (0x3 <<
365 GLPCI_ARB_UPPER_H2_SHIFT);
370 msr.hi |= nic_grants_control;
371 msr.lo |= enable_cpu_override | enable_preempt | enable_bus_parking;
377 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 .) */
378 msr.lo |= GLPCI_CTRL_LOWER_LDE_SET;
380 msr.lo &= ~(0x03 << GLPCI_CTRL_LOWER_IRFC_SHIFT);
381 msr.lo |= 0x02 << GLPCI_CTRL_LOWER_IRFC_SHIFT;
383 msr.lo &= ~(0x07 << GLPCI_CTRL_LOWER_IRFT_SHIFT);
384 msr.lo |= 0x06 << GLPCI_CTRL_LOWER_IRFT_SHIFT;
386 msr.hi &= ~(0x0f << GLPCI_CTRL_UPPER_FTH_SHIFT);
387 msr.hi |= 0x0F << GLPCI_CTRL_UPPER_FTH_SHIFT;
389 msr.hi &= ~(0x0f << GLPCI_CTRL_UPPER_RTH_SHIFT);
390 msr.hi |= 0x0F << GLPCI_CTRL_UPPER_RTH_SHIFT;
392 msr.hi &= ~(0x0f << GLPCI_CTRL_UPPER_SBRTH_SHIFT);
393 msr.hi |= 0x0F << GLPCI_CTRL_UPPER_SBRTH_SHIFT;
395 msr.hi &= ~(0x03 << GLPCI_CTRL_UPPER_WTO_SHIFT);
396 msr.hi |= 0x06 << GLPCI_CTRL_UPPER_WTO_SHIFT;
398 msr.hi &= ~(0x03 << GLPCI_CTRL_UPPER_ILTO_SHIFT);
399 msr.hi |= 0x00 << GLPCI_CTRL_UPPER_ILTO_SHIFT;
402 /* Set GLPCI Latency Timer */
405 msr.hi |= 0x1F << GLPCI_CTRL_UPPER_LAT_SHIFT; /* Change once 1.x is gone */
409 msrnum = GLPCI_SPARE;
413 GLPCI_SPARE_LOWER_AILTO_SET | GLPCI_SPARE_LOWER_PPD_SET |
414 GLPCI_SPARE_LOWER_PPC_SET | GLPCI_SPARE_LOWER_MPC_SET |
415 GLPCI_SPARE_LOWER_NSE_SET | GLPCI_SPARE_LOWER_SUPO_SET;
419 /* ************************************************************************** */
421 /* * ClockGatingInit */
423 /* * Enable Clock Gating. */
429 /* ************************************************************************** */
430 static void ClockGatingInit(void)
433 struct msrinit *gating = ClockGatingDefault;
436 for (i = 0; gating->msrnum != 0xffffffff; i++) {
437 msr = rdmsr(gating->msrnum);
438 msr.hi |= gating->msr.hi;
439 msr.lo |= gating->msr.lo;
440 /* printk_debug("%s: MSR 0x%08x will be set to 0x%08x:0x%08x\n", __FUNCTION__,
441 gating->msrnum, msr.hi, msr.lo); */// GX3
442 wrmsr(gating->msrnum, msr); // MSR - See the table above
448 static void GeodeLinkPriority(void)
451 struct msrinit *prio = GeodeLinkPriorityTable;
454 for (i = 0; prio->msrnum != 0xffffffff; i++) {
455 msr = rdmsr(prio->msrnum);
456 msr.hi |= prio->msr.hi;
458 msr.lo |= prio->msr.lo;
459 /* printk_debug("%s: MSR 0x%08x will be set to 0x%08x:0x%08x\n", __FUNCTION__,
460 prio->msrnum, msr.hi, msr.lo); */// GX3
461 wrmsr(prio->msrnum, msr); // MSR - See the table above
467 * Get the GLIU0 shadow register settings
468 * If the setShadow function is used then all shadow descriptors
471 static uint64_t getShadow(void)
475 msr = rdmsr(MSR_GLIU0_SHADOW);
476 return (((uint64_t) msr.hi) << 32) | msr.lo;
480 * Set the cache RConf registers for the memory hole.
481 * Keeps all cache shadow descriptors sync'ed.
482 * This is part of the PCI lockup solution
483 * Entry: EDX:EAX is the shadow settings
485 static void setShadowRCONF(uint32_t shadowHi, uint32_t shadowLo)
488 // ok this is whacky bit translation time.
491 msr_t msr = { 0, 0 };
492 shadowByte = (uint8_t) (shadowLo >> 16);
494 // load up D000 settings in edx.
495 for (bit = 8; (bit > 4); bit--) {
497 msr.hi |= 1; // cache disable PCI/Shadow memory
498 if (shadowByte && (1 << bit))
499 msr.hi |= 0x20; // write serialize PCI memory
502 // load up C000 settings in eax.
505 msr.lo |= 1; // cache disable PCI/Shadow memory
506 if (shadowByte && (1 << bit))
507 msr.lo |= 0x20; // write serialize PCI memory
510 wrmsr(CPU_RCONF_C0_DF, msr);
512 shadowByte = (uint8_t) (shadowLo >> 24);
514 // load up F000 settings in edx.
515 for (bit = 8; (bit > 4); bit--) {
517 msr.hi |= 1; // cache disable PCI/Shadow memory
518 if (shadowByte && (1 << bit))
519 msr.hi |= 0x20; // write serialize PCI memory
522 // load up E000 settings in eax.
525 msr.lo |= 1; // cache disable PCI/Shadow memory
526 if (shadowByte && (1 << bit))
527 msr.lo |= 0x20; // write serialize PCI memory
530 wrmsr(CPU_RCONF_E0_FF, msr);
534 * Set the GLPCI registers for the memory hole.
535 * Keeps all cache shadow descriptors sync'ed.
536 * Entry: EDX:EAX is the shadow settings
538 static void setShadowGLPCI(uint32_t shadowHi, uint32_t shadowLo)
542 // Set the Enable Register.
543 msr = rdmsr(GLPCI_REN);
544 msr.lo &= 0xFFFF00FF;
545 msr.lo |= ((shadowLo & 0xFFFF0000) >> 8);
546 wrmsr(GLPCI_REN, msr);
550 * Set the GLIU SC register settings. Scans descriptor tables for SC_SHADOW.
551 * Keeps all shadow descriptors sync'ed.
552 * Entry: EDX:EAX is the shadow settings
554 static void setShadow(uint64_t shadowSettings)
558 struct gliutable *pTable;
559 uint32_t shadowLo, shadowHi;
561 shadowLo = (uint32_t) shadowSettings;
562 shadowHi = (uint32_t) (shadowSettings >> 32);
564 setShadowRCONF(shadowHi, shadowLo);
565 setShadowGLPCI(shadowHi, shadowLo);
567 for (i = 0; gliutables[i]; i++) {
568 for (pTable = gliutables[i]; pTable->desc_type != GL_END;
570 if (pTable->desc_type == SC_SHADOW) {
572 msr = rdmsr(pTable->desc_name);
573 msr.lo = (uint32_t) shadowSettings;
574 msr.hi &= 0xFFFF0000; // maintain PDID in upper EDX
576 ((uint32_t) (shadowSettings >> 32)) &
578 wrmsr(pTable->desc_name, msr); // MSR - See the table above
584 static void rom_shadow_settings(void)
587 uint64_t shadowSettings = getShadow();
588 shadowSettings &= (uint64_t) 0xFFFF00000000FFFFULL; // Disable read & writes
589 shadowSettings |= (uint64_t) 0x00000000F0000000ULL; // Enable reads for F0000-FFFFF
590 shadowSettings |= (uint64_t) 0x0000FFFFFFFF0000ULL; // Enable rw for C0000-CFFFF
591 setShadow(shadowSettings);
594 /***************************************************************************
597 * Set up RCONF_DEFAULT and any other RCONF registers needed
599 * DEVRC_RCONF_DEFAULT:
600 * ROMRC(63:56) = 04h ; write protect ROMBASE
601 * ROMBASE(36:55) = 0FFFC0h ; Top of PCI/bottom of rom chipselect area
602 * DEVRC(35:28) = 39h ; cache disabled in PCI memory + WS bit on + Write Combine + write burst.
603 * SYSTOP(27:8) = top of system memory
604 * SYSRC(7:0) = 00h ; writeback, can set to 08h to make writethrough
606 ***************************************************************************/
607 #define SYSMEM_RCONF_WRITETHROUGH 8
608 #define DEVRC_RCONF_DEFAULT 0x21
609 #define ROMBASE_RCONF_DEFAULT 0xFFFC0000
610 #define ROMRC_RCONF_DEFAULT 0x25
612 static void enable_L1_cache(void)
614 struct gliutable *gl = 0;
617 uint8_t SysMemCacheProp;
619 /* Locate SYSMEM entry in GLIU0table */
620 for (i = 0; gliu0table[i].desc_name != GL_END; i++) {
621 if (gliu0table[i].desc_type == R_SYSMEM) {
627 post_code(0xCE); /* POST_RCONFInitError */
631 msr = rdmsr(gl->desc_name);
633 /* 20 bit address - The bottom 12 bits go into bits 20-31 in eax, the
634 * top 8 bits go into 0-7 of edx.
636 msr.lo = (msr.lo & 0xFFFFFF00) | (msr.hi & 0xFF);
637 msr.lo = ((msr.lo << 12) | (msr.lo >> 20)) & 0x000FFFFF;
638 msr.lo <<= RCONF_DEFAULT_LOWER_SYSTOP_SHIFT; // 8
640 // Set Default SYSMEM region properties
641 msr.lo &= ~SYSMEM_RCONF_WRITETHROUGH; // NOT writethrough == writeback 8 (or ~8)
643 // Set PCI space cache properties
644 msr.hi = (DEVRC_RCONF_DEFAULT >> 4); // setting is split betwwen hi and lo...
645 msr.lo |= (DEVRC_RCONF_DEFAULT << 28);
647 // Set the ROMBASE. This is usually FFFC0000h
649 (ROMBASE_RCONF_DEFAULT >> 12) << RCONF_DEFAULT_UPPER_ROMBASE_SHIFT;
651 // Set ROMBASE cache properties.
652 msr.hi |= ((ROMRC_RCONF_DEFAULT >> 8) | (ROMRC_RCONF_DEFAULT << 24));
654 // now program RCONF_DEFAULT
655 wrmsr(CPU_RCONF_DEFAULT, msr);
656 printk_debug("CPU_RCONF_DEFAULT (1808): 0x%08X:0x%08X\n", msr.hi,
659 // RCONF_BYPASS: Cache tablewalk properties and SMM/DMM header access properties.
660 // Set to match system memory cache properties.
661 msr = rdmsr(CPU_RCONF_DEFAULT);
662 SysMemCacheProp = (uint8_t) (msr.lo & 0xFF);
663 msr = rdmsr(CPU_RCONF_BYPASS);
665 (msr.lo & 0xFFFF0000) | (SysMemCacheProp << 8) | SysMemCacheProp;
666 wrmsr(CPU_RCONF_BYPASS, msr);
668 printk_debug("CPU_RCONF_BYPASS (180A): 0x%08x : 0x%08x\n", msr.hi,
672 static void enable_L2_cache(void)
676 /* Instruction Memory Configuration register
677 * set EBE bit, required when L2 cache is enabled
679 msr = rdmsr(CPU_IM_CONFIG);
681 wrmsr(CPU_IM_CONFIG, msr);
683 /* Data Memory Subsystem Configuration register
684 * set EVCTONRPL bit, required when L2 cache is enabled in victim mode
686 msr = rdmsr(CPU_DM_CONFIG0);
688 wrmsr(CPU_DM_CONFIG0, msr);
690 /* invalidate L2 cache */
693 wrmsr(CPU_BC_L2_CONF, msr);
695 /* Enable L2 cache */
698 wrmsr(CPU_BC_L2_CONF, msr);
700 printk_debug("L2 cache enabled\n");
703 static void setup_lx_cache(void)
710 // Make sure all INVD instructions are treated as WBINVD. We do this
711 // because we've found some programs which require this behavior.
712 msr = rdmsr(CPU_DM_CONFIG0);
713 msr.lo |= DM_CONFIG0_LOWER_WBINVD_SET;
714 wrmsr(CPU_DM_CONFIG0, msr);
720 uint32_t get_systop(void)
722 struct gliutable *gl = 0;
727 for (i = 0; gliu0table[i].desc_name != GL_END; i++) {
728 if (gliu0table[i].desc_type == R_SYSMEM) {
734 msr = rdmsr(gl->desc_name);
735 systop = ((msr.hi & 0xFF) << 24) | ((msr.lo & 0xFFF00000) >> 8);
736 systop += 0x1000; /* 4K */
739 ((sizeram() - CONFIG_VIDEO_MB) * 1024) - SMM_SIZE - 1024;
744 /****************************************************************************/
745 /* * northbridge_init_early */
747 /* * Core Logic initialization: Host bridge*/
749 /* ***************************************************************************/
750 void northbridge_init_early(void)
754 printk_debug("Enter %s\n", __FUNCTION__);
756 for (i = 0; gliutables[i]; i++)
757 GLIUInit(gliutables[i]);
759 /* Now that the descriptor to memory is set up. */
760 /* The memory controller needs one read to synch its lines before it can be used. */
767 rom_shadow_settings();
773 __asm__ __volatile__("FINIT\n");
774 printk_debug("Exit %s\n", __FUNCTION__);