2 * This file is part of the coreboot project.
4 * Copyright (C) 2015 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; version 2 of the License.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
16 #include <console/console.h>
17 #include <cpu/x86/msr.h>
18 #include <cpu/amd/msr.h>
19 #include <cpu/x86/mtrr.h>
20 #include <cpu/amd/mtrr.h>
21 #include <device/device.h>
22 #include <device/pci.h>
24 #include <cpu/x86/pae.h>
25 #include <pc80/mc146818rtc.h>
26 #include <cpu/x86/lapic.h>
28 #include <cpu/x86/cache.h>
29 #include <arch/acpi.h>
32 #include <PspBaseLib.h>
34 void PSPProgBar3Msr(void *Buffer
);
36 void PSPProgBar3Msr(void *Buffer
)
41 Bar3Addr
= PspLibPciReadPspConfig(0x20);
43 printk(BIOS_DEBUG
, "Bar3=%llx\n", Tmp64
);
44 LibAmdMsrWrite(0xC00110A2, &Tmp64
, NULL
);
45 LibAmdMsrRead(0xC00110A2, &Tmp64
, NULL
);
48 static void model_15_init(struct device
*dev
)
50 printk(BIOS_DEBUG
, "Model 15 Init.\n");
56 #if IS_ENABLED(CONFIG_LOGICAL_CPUS)
61 /* Enable access to AMD RdDram and WrDram extension bits */
62 msr
= rdmsr(SYSCFG_MSR
);
63 msr
.lo
|= SYSCFG_MSR_MtrrFixDramModEn
;
64 msr
.lo
&= ~SYSCFG_MSR_MtrrFixDramEn
;
65 wrmsr(SYSCFG_MSR
, msr
);
67 // BSP: make a0000-bffff UC, c0000-fffff WB
70 msr
.lo
= msr
.hi
= 0x1e1e1e1e;
73 for (msrno
= 0x268; msrno
<= 0x26f; msrno
++)
76 msr
= rdmsr(SYSCFG_MSR
);
77 msr
.lo
&= ~SYSCFG_MSR_MtrrFixDramModEn
;
78 msr
.lo
|= SYSCFG_MSR_MtrrFixDramEn
;
79 wrmsr(SYSCFG_MSR
, msr
);
84 /* zero the machine check error status registers */
85 msr
= rdmsr(IA32_MCG_CAP
);
86 num_banks
= msr
.lo
& MCA_BANKS_MASK
;
89 for (i
= 0; i
< num_banks
; i
++)
90 wrmsr(IA32_MC0_STATUS
+ (i
* 4), msr
);
92 /* Enable the local CPU APICs */
95 #if IS_ENABLED(CONFIG_LOGICAL_CPUS)
96 siblings
= cpuid_ecx(0x80000008) & 0xff;
99 msr
= rdmsr_amd(CPU_ID_FEATURES_MSR
);
101 wrmsr_amd(CPU_ID_FEATURES_MSR
, msr
);
103 msr
= rdmsr_amd(CPU_ID_EXT_FEATURES_MSR
);
104 msr
.hi
|= 1 << (33 - 32);
105 wrmsr_amd(CPU_ID_EXT_FEATURES_MSR
, msr
);
107 printk(BIOS_DEBUG
, "siblings = %02d, ", siblings
);
109 PSPProgBar3Msr(NULL
);
111 /* DisableCf8ExtCfg */
112 msr
= rdmsr(NB_CFG_MSR
);
113 msr
.hi
&= ~(1 << (46 - 32));
114 wrmsr(NB_CFG_MSR
, msr
);
117 /* Write protect SMM space with SMMLOCK. */
118 msr
= rdmsr(HWCR_MSR
);
120 wrmsr(HWCR_MSR
, msr
);
123 static struct device_operations cpu_dev_ops
= {
124 .init
= model_15_init
,
127 static const struct cpu_device_id cpu_table
[] = {
128 { X86_VENDOR_AMD
, 0x660f00 },
129 { X86_VENDOR_AMD
, 0x660f01 },
133 static const struct cpu_driver model_15 __cpu_driver
= {
135 .id_table
= cpu_table
,