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 */
103 static void writeglmsr(struct gliutable *gl)
109 wrmsr(gl->desc_name, msr); // MSR - see table above
110 printk_debug("%s: MSR 0x%08lx, val 0x%08x:0x%08x\n", __func__, gl->desc_name, msr.hi, msr.lo); // GX3
113 static void ShadowInit(struct gliutable *gl)
117 msr = rdmsr(gl->desc_name);
124 static void SysmemInit(struct gliutable *gl)
127 int sizembytes, sizebytes;
130 * Figure out how much RAM is in the machine and alocate all to the
131 * system. We will adjust for SMM now and Frame Buffer later.
133 sizembytes = sizeram();
134 printk_debug("%s: enable for %dMBytes\n", __func__, sizembytes);
135 sizebytes = sizembytes << 20;
137 sizebytes -= ((SMM_SIZE * 1024) + 1);
138 printk_debug("usable RAM: %d bytes\n", sizebytes);
140 /* 20 bit address The bottom 12 bits go into bits 20-31 in msr.lo
141 The top 8 bits go into 0-7 of msr.hi. */
143 msr.hi = (gl->hi & 0xFFFFFF00) | (sizebytes >> 24);
144 sizebytes <<= 8; /* move bits 23:12 in bits 31:20. */
145 sizebytes &= 0xfff00000;
146 sizebytes |= 0x100; /* start at 1MB */
149 wrmsr(gl->desc_name, msr); // MSR - see table above
150 printk_debug("%s: MSR 0x%08lx, val 0x%08x:0x%08x\n", __func__,
151 gl->desc_name, msr.hi, msr.lo);
154 static void SMMGL0Init(struct gliutable *gl)
157 int sizebytes = sizeram() << 20;
160 sizebytes -= (SMM_SIZE * 1024);
162 printk_debug("%s: %d bytes\n", __func__, sizebytes);
164 /* calculate the Two's complement offset */
165 offset = sizebytes - SMM_OFFSET;
166 offset = (offset >> 12) & 0x000fffff;
167 printk_debug("%s: offset is 0x%08x\n", __func__, SMM_OFFSET);
169 msr.hi = offset << 8 | gl->hi;
170 msr.hi |= SMM_OFFSET >> 24;
172 msr.lo = SMM_OFFSET << 8;
173 msr.lo |= ((~(SMM_SIZE * 1024) + 1) >> 12) & 0xfffff;
175 wrmsr(gl->desc_name, msr); // MSR - See table above
176 printk_debug("%s: MSR 0x%08lx, val 0x%08x:0x%08x\n", __func__,
177 gl->desc_name, msr.hi, msr.lo);
180 static void SMMGL1Init(struct gliutable *gl)
183 printk_debug("%s:\n", __func__);
186 /* I don't think this is needed */
187 msr.hi &= 0xffffff00;
188 msr.hi |= (SMM_OFFSET >> 24);
189 msr.lo = (SMM_OFFSET << 8) & 0xFFF00000;
190 msr.lo |= ((~(SMM_SIZE * 1024) + 1) >> 12) & 0xfffff;
192 wrmsr(gl->desc_name, msr); // MSR - See table above
193 printk_debug("%s: MSR 0x%08lx, val 0x%08x:0x%08x\n", __func__,
194 gl->desc_name, msr.hi, msr.lo);
197 static void GLIUInit(struct gliutable *gl)
200 while (gl->desc_type != GL_END) {
201 switch (gl->desc_type) {
203 /* For Unknown types: Write then read MSR */
205 case SC_SHADOW: /* Check for a Shadow entry */
209 case R_SYSMEM: /* check for a SYSMEM entry */
213 case BMO_SMM: /* check for a SMM entry */
217 case BM_SMM: /* check for a SMM entry */
226 /* ************************************************************************** */
230 /* * Set up GLPCI settings for reads/write into memory */
232 /* * R1: 1MB - Top of System Memory */
233 /* * R2: SMM Memory */
234 /* * R3: Framebuffer? - not set up yet */
241 /* ************************************************************************** */
242 static void GLPCIInit(void)
244 struct gliutable *gl = 0;
247 int msrnum, enable_preempt, enable_cpu_override;
248 int nic_grants_control, enable_bus_parking;
251 /* R0 - GLPCI settings for Conventional Memory space. */
253 msr.hi = (0x09F000 >> 12) << GLPCI_RC_UPPER_TOP_SHIFT; /* 640 */
256 GLPCI_RC_LOWER_EN_SET + GLPCI_RC_LOWER_PF_SET +
257 GLPCI_RC_LOWER_WC_SET;
262 /* R1 - GLPCI settings for SysMem space. */
264 /* Get systop from GLIU0 SYSTOP Descriptor */
265 for (i = 0; gliu0table[i].desc_name != GL_END; i++) {
266 if (gliu0table[i].desc_type == R_SYSMEM) {
272 unsigned long pah, pal;
273 msrnum = gl->desc_name;
275 /* example R_SYSMEM value: 20:00:00:0f:fb:f0:01:00
276 * translates to a base of 0x00100000 and top of 0xffbf0000
277 * base of 1M and top of around 256M
279 /* we have to create a page-aligned (4KB page) address for base and top */
280 /* So we need a high page aligned addresss (pah) and low page aligned address (pal)
281 * pah is from msr.hi << 12 | msr.low >> 20. pal is msr.lo << 12
283 pah = ((msr.hi & 0xFF) << 12) | ((msr.lo >> 20) & 0xFFF);
284 /* we have the page address. Now make it a page-aligned address */
291 GLPCI_RC_LOWER_EN_SET | GLPCI_RC_LOWER_PF_SET |
292 GLPCI_RC_LOWER_WC_SET;
293 printk_debug("GLPCI R1: system msr.lo 0x%08x msr.hi 0x%08x\n",
300 /* R2 - GLPCI settings for SMM space */
304 (SMM_SIZE * 1024 - 1)) >> 12) << GLPCI_RC_UPPER_TOP_SHIFT;
305 msr.lo = (SMM_OFFSET >> 12) << GLPCI_RC_LOWER_BASE_SHIFT;
306 msr.lo |= GLPCI_RC_LOWER_EN_SET | GLPCI_RC_LOWER_PF_SET;
307 printk_debug("GLPCI R2: system msr.lo 0x%08x msr.hi 0x%08x\n", msr.lo,
312 /* this is done elsewhere already, but it does no harm to do it more than once */
313 /* write serialize memory hole to PCI. Need to to unWS when something is shadowed regardless of cachablility. */
314 msr.lo = 0x021212121; /* cache disabled and write serialized */
315 msr.hi = 0x021212121; /* cache disabled and write serialized */
317 msrnum = CPU_RCONF_A0_BF;
320 msrnum = CPU_RCONF_C0_DF;
323 msrnum = CPU_RCONF_E0_FF;
326 /* Set Non-Cacheable Read Only for NorthBound Transactions to Memory. The Enable bit is handled in the Shadow setup. */
327 msrnum = GLPCI_A0_BF;
332 msrnum = GLPCI_C0_DF;
337 msrnum = GLPCI_E0_FF;
343 msrnum = CPU_DM_CONFIG0;
345 msr.hi &= ~(7 << DM_CONFIG0_UPPER_WSREQ_SHIFT);
346 msr.hi |= 2 << DM_CONFIG0_UPPER_WSREQ_SHIFT; /* reduce to 1 for safe mode */
349 /* we are ignoring the 5530 case for now, and perhaps forever. */
357 GLPCI_ARB_LOWER_PRE0_SET | GLPCI_ARB_LOWER_PRE1_SET |
358 GLPCI_ARB_LOWER_PRE2_SET | GLPCI_ARB_LOWER_CPRE_SET;
359 enable_cpu_override = GLPCI_ARB_LOWER_COV_SET;
360 enable_bus_parking = GLPCI_ARB_LOWER_PARK_SET;
362 (0x4 << GLPCI_ARB_UPPER_R2_SHIFT) | (0x3 <<
363 GLPCI_ARB_UPPER_H2_SHIFT);
368 msr.hi |= nic_grants_control;
369 msr.lo |= enable_cpu_override | enable_preempt | enable_bus_parking;
375 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 .) */
376 msr.lo |= GLPCI_CTRL_LOWER_LDE_SET;
378 msr.lo &= ~(0x03 << GLPCI_CTRL_LOWER_IRFC_SHIFT);
379 msr.lo |= 0x02 << GLPCI_CTRL_LOWER_IRFC_SHIFT;
381 msr.lo &= ~(0x07 << GLPCI_CTRL_LOWER_IRFT_SHIFT);
382 msr.lo |= 0x06 << GLPCI_CTRL_LOWER_IRFT_SHIFT;
384 msr.hi &= ~(0x0f << GLPCI_CTRL_UPPER_FTH_SHIFT);
385 msr.hi |= 0x0F << GLPCI_CTRL_UPPER_FTH_SHIFT;
387 msr.hi &= ~(0x0f << GLPCI_CTRL_UPPER_RTH_SHIFT);
388 msr.hi |= 0x0F << GLPCI_CTRL_UPPER_RTH_SHIFT;
390 msr.hi &= ~(0x0f << GLPCI_CTRL_UPPER_SBRTH_SHIFT);
391 msr.hi |= 0x0F << GLPCI_CTRL_UPPER_SBRTH_SHIFT;
393 msr.hi &= ~(0x03 << GLPCI_CTRL_UPPER_WTO_SHIFT);
394 msr.hi |= 0x06 << GLPCI_CTRL_UPPER_WTO_SHIFT;
396 msr.hi &= ~(0x03 << GLPCI_CTRL_UPPER_ILTO_SHIFT);
397 msr.hi |= 0x00 << GLPCI_CTRL_UPPER_ILTO_SHIFT;
400 /* Set GLPCI Latency Timer */
403 msr.hi |= 0x1F << GLPCI_CTRL_UPPER_LAT_SHIFT; /* Change once 1.x is gone */
407 msrnum = GLPCI_SPARE;
411 GLPCI_SPARE_LOWER_AILTO_SET | GLPCI_SPARE_LOWER_PPD_SET |
412 GLPCI_SPARE_LOWER_PPC_SET | GLPCI_SPARE_LOWER_MPC_SET |
413 GLPCI_SPARE_LOWER_NSE_SET | GLPCI_SPARE_LOWER_SUPO_SET;
417 /* ************************************************************************** */
419 /* * ClockGatingInit */
421 /* * Enable Clock Gating. */
427 /* ************************************************************************** */
428 static void ClockGatingInit(void)
431 struct msrinit *gating = ClockGatingDefault;
434 for (i = 0; gating->msrnum != 0xffffffff; i++) {
435 msr = rdmsr(gating->msrnum);
436 msr.hi |= gating->msr.hi;
437 msr.lo |= gating->msr.lo;
438 /* printk_debug("%s: MSR 0x%08x will be set to 0x%08x:0x%08x\n", __func__,
439 gating->msrnum, msr.hi, msr.lo); */// GX3
440 wrmsr(gating->msrnum, msr); // MSR - See the table above
446 static void GeodeLinkPriority(void)
449 struct msrinit *prio = GeodeLinkPriorityTable;
452 for (i = 0; prio->msrnum != 0xffffffff; i++) {
453 msr = rdmsr(prio->msrnum);
454 msr.hi |= prio->msr.hi;
456 msr.lo |= prio->msr.lo;
457 /* printk_debug("%s: MSR 0x%08x will be set to 0x%08x:0x%08x\n", __func__,
458 prio->msrnum, msr.hi, msr.lo); */// GX3
459 wrmsr(prio->msrnum, msr); // MSR - See the table above
465 * Get the GLIU0 shadow register settings
466 * If the setShadow function is used then all shadow descriptors
469 static uint64_t getShadow(void)
473 msr = rdmsr(MSR_GLIU0_SHADOW);
474 return (((uint64_t) msr.hi) << 32) | msr.lo;
478 * Set the cache RConf registers for the memory hole.
479 * Keeps all cache shadow descriptors sync'ed.
480 * This is part of the PCI lockup solution
481 * Entry: EDX:EAX is the shadow settings
483 static void setShadowRCONF(uint32_t shadowHi, uint32_t shadowLo)
486 // ok this is whacky bit translation time.
489 msr_t msr = { 0, 0 };
490 shadowByte = (uint8_t) (shadowLo >> 16);
492 // load up D000 settings in edx.
493 for (bit = 8; (bit > 4); bit--) {
495 msr.hi |= 1; // cache disable PCI/Shadow memory
496 if (shadowByte && (1 << bit))
497 msr.hi |= 0x20; // write serialize PCI memory
500 // load up C000 settings in eax.
503 msr.lo |= 1; // cache disable PCI/Shadow memory
504 if (shadowByte && (1 << bit))
505 msr.lo |= 0x20; // write serialize PCI memory
508 wrmsr(CPU_RCONF_C0_DF, msr);
510 shadowByte = (uint8_t) (shadowLo >> 24);
512 // load up F000 settings in edx.
513 for (bit = 8; (bit > 4); bit--) {
515 msr.hi |= 1; // cache disable PCI/Shadow memory
516 if (shadowByte && (1 << bit))
517 msr.hi |= 0x20; // write serialize PCI memory
520 // load up E000 settings in eax.
523 msr.lo |= 1; // cache disable PCI/Shadow memory
524 if (shadowByte && (1 << bit))
525 msr.lo |= 0x20; // write serialize PCI memory
528 wrmsr(CPU_RCONF_E0_FF, msr);
532 * Set the GLPCI registers for the memory hole.
533 * Keeps all cache shadow descriptors sync'ed.
534 * Entry: EDX:EAX is the shadow settings
536 static void setShadowGLPCI(uint32_t shadowHi, uint32_t shadowLo)
540 // Set the Enable Register.
541 msr = rdmsr(GLPCI_REN);
542 msr.lo &= 0xFFFF00FF;
543 msr.lo |= ((shadowLo & 0xFFFF0000) >> 8);
544 wrmsr(GLPCI_REN, msr);
548 * Set the GLIU SC register settings. Scans descriptor tables for SC_SHADOW.
549 * Keeps all shadow descriptors sync'ed.
550 * Entry: EDX:EAX is the shadow settings
552 static void setShadow(uint64_t shadowSettings)
556 struct gliutable *pTable;
557 uint32_t shadowLo, shadowHi;
559 shadowLo = (uint32_t) shadowSettings;
560 shadowHi = (uint32_t) (shadowSettings >> 32);
562 setShadowRCONF(shadowHi, shadowLo);
563 setShadowGLPCI(shadowHi, shadowLo);
565 for (i = 0; gliutables[i]; i++) {
566 for (pTable = gliutables[i]; pTable->desc_type != GL_END;
568 if (pTable->desc_type == SC_SHADOW) {
570 msr = rdmsr(pTable->desc_name);
571 msr.lo = (uint32_t) shadowSettings;
572 msr.hi &= 0xFFFF0000; // maintain PDID in upper EDX
574 ((uint32_t) (shadowSettings >> 32)) &
576 wrmsr(pTable->desc_name, msr); // MSR - See the table above
582 static void rom_shadow_settings(void)
585 uint64_t shadowSettings = getShadow();
586 shadowSettings &= (uint64_t) 0xFFFF00000000FFFFULL; // Disable read & writes
587 shadowSettings |= (uint64_t) 0x00000000F0000000ULL; // Enable reads for F0000-FFFFF
588 shadowSettings |= (uint64_t) 0x0000FFFFFFFF0000ULL; // Enable rw for C0000-CFFFF
589 setShadow(shadowSettings);
592 /***************************************************************************
595 * Set up RCONF_DEFAULT and any other RCONF registers needed
597 * DEVRC_RCONF_DEFAULT:
598 * ROMRC(63:56) = 04h ; write protect ROMBASE
599 * ROMBASE(36:55) = 0FFFC0h ; Top of PCI/bottom of rom chipselect area
600 * DEVRC(35:28) = 39h ; cache disabled in PCI memory + WS bit on + Write Combine + write burst.
601 * SYSTOP(27:8) = top of system memory
602 * SYSRC(7:0) = 00h ; writeback, can set to 08h to make writethrough
604 ***************************************************************************/
605 #define SYSMEM_RCONF_WRITETHROUGH 8
606 #define DEVRC_RCONF_DEFAULT 0x21
607 #define ROMBASE_RCONF_DEFAULT 0xFFFC0000
608 #define ROMRC_RCONF_DEFAULT 0x25
610 static void enable_L1_cache(void)
612 struct gliutable *gl = 0;
615 uint8_t SysMemCacheProp;
617 /* Locate SYSMEM entry in GLIU0table */
618 for (i = 0; gliu0table[i].desc_name != GL_END; i++) {
619 if (gliu0table[i].desc_type == R_SYSMEM) {
625 post_code(0xCE); /* POST_RCONFInitError */
629 msr = rdmsr(gl->desc_name);
631 /* 20 bit address - The bottom 12 bits go into bits 20-31 in eax, the
632 * top 8 bits go into 0-7 of edx.
634 msr.lo = (msr.lo & 0xFFFFFF00) | (msr.hi & 0xFF);
635 msr.lo = ((msr.lo << 12) | (msr.lo >> 20)) & 0x000FFFFF;
636 msr.lo <<= RCONF_DEFAULT_LOWER_SYSTOP_SHIFT; // 8
638 // Set Default SYSMEM region properties
639 msr.lo &= ~SYSMEM_RCONF_WRITETHROUGH; // NOT writethrough == writeback 8 (or ~8)
641 // Set PCI space cache properties
642 msr.hi = (DEVRC_RCONF_DEFAULT >> 4); // setting is split betwwen hi and lo...
643 msr.lo |= (DEVRC_RCONF_DEFAULT << 28);
645 // Set the ROMBASE. This is usually FFFC0000h
647 (ROMBASE_RCONF_DEFAULT >> 12) << RCONF_DEFAULT_UPPER_ROMBASE_SHIFT;
649 // Set ROMBASE cache properties.
650 msr.hi |= ((ROMRC_RCONF_DEFAULT >> 8) | (ROMRC_RCONF_DEFAULT << 24));
652 // now program RCONF_DEFAULT
653 wrmsr(CPU_RCONF_DEFAULT, msr);
654 printk_debug("CPU_RCONF_DEFAULT (1808): 0x%08X:0x%08X\n", msr.hi,
657 // RCONF_BYPASS: Cache tablewalk properties and SMM/DMM header access properties.
658 // Set to match system memory cache properties.
659 msr = rdmsr(CPU_RCONF_DEFAULT);
660 SysMemCacheProp = (uint8_t) (msr.lo & 0xFF);
661 msr = rdmsr(CPU_RCONF_BYPASS);
663 (msr.lo & 0xFFFF0000) | (SysMemCacheProp << 8) | SysMemCacheProp;
664 wrmsr(CPU_RCONF_BYPASS, msr);
666 printk_debug("CPU_RCONF_BYPASS (180A): 0x%08x : 0x%08x\n", msr.hi,
670 static void enable_L2_cache(void)
674 /* Instruction Memory Configuration register
675 * set EBE bit, required when L2 cache is enabled
677 msr = rdmsr(CPU_IM_CONFIG);
679 wrmsr(CPU_IM_CONFIG, msr);
681 /* Data Memory Subsystem Configuration register
682 * set EVCTONRPL bit, required when L2 cache is enabled in victim mode
684 msr = rdmsr(CPU_DM_CONFIG0);
686 wrmsr(CPU_DM_CONFIG0, msr);
688 /* invalidate L2 cache */
691 wrmsr(CPU_BC_L2_CONF, msr);
693 /* Enable L2 cache */
696 wrmsr(CPU_BC_L2_CONF, msr);
698 printk_debug("L2 cache enabled\n");
701 static void setup_lx_cache(void)
708 // Make sure all INVD instructions are treated as WBINVD. We do this
709 // because we've found some programs which require this behavior.
710 msr = rdmsr(CPU_DM_CONFIG0);
711 msr.lo |= DM_CONFIG0_LOWER_WBINVD_SET;
712 wrmsr(CPU_DM_CONFIG0, msr);
718 uint32_t get_systop(void)
720 struct gliutable *gl = 0;
725 for (i = 0; gliu0table[i].desc_name != GL_END; i++) {
726 if (gliu0table[i].desc_type == R_SYSMEM) {
732 msr = rdmsr(gl->desc_name);
733 systop = ((msr.hi & 0xFF) << 24) | ((msr.lo & 0xFFF00000) >> 8);
734 systop += 0x1000; /* 4K */
737 ((sizeram() - CONFIG_VIDEO_MB) * 1024) - SMM_SIZE - 1024;
742 /****************************************************************************/
743 /* * northbridge_init_early */
745 /* * Core Logic initialization: Host bridge*/
747 /* ***************************************************************************/
748 void northbridge_init_early(void)
751 printk_debug("Enter %s\n", __func__);
753 for (i = 0; gliutables[i]; i++)
754 GLIUInit(gliutables[i]);
756 /* Now that the descriptor to memory is set up. */
757 /* The memory controller needs one read to synch its lines before it can be used. */
764 rom_shadow_settings();
770 __asm__ __volatile__("FINIT\n");
771 printk_debug("Exit %s\n", __func__);