2 * This file is part of the coreboot project.
4 * Copyright (C) 2011 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.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 #include <console/console.h>
21 #include <cpu/x86/msr.h>
22 #include <cpu/amd/mtrr.h>
23 #include <device/device.h>
24 #include <device/pci.h>
26 #include <cpu/x86/msr.h>
27 #include <cpu/x86/pae.h>
28 #include <pc80/mc146818rtc.h>
29 #include <cpu/x86/lapic.h>
32 #include <cpu/x86/cache.h>
33 #include <cpu/x86/mtrr.h>
34 #include <cpu/amd/multicore.h>
35 #include <cpu/amd/amdfam12.h>
37 #define MCI_STATUS 0x401
39 msr_t rdmsr_amd(u32 index)
44 :"=a"(result.lo), "=d"(result.hi)
45 :"c"(index), "D"(0x9c5a203a)
50 void wrmsr_amd(u32 index, msr_t msr)
55 :"c"(index), "a"(msr.lo), "d"(msr.hi), "D"(0x9c5a203a)
59 static void model_12_init(device_t dev)
61 printk(BIOS_DEBUG, "Model 12 Init - a no-op.\n");
65 struct node_core_id id;
66 #if CONFIG_LOGICAL_CPUS == 1
70 // id = get_node_core_id(read_nb_cfg_54()); /* nb_cfg_54 can not be set */
71 // printk(BIOS_DEBUG, "nodeid = %02d, coreid = %02d\n", id.nodeid, id.coreid);
73 /* Turn on caching if we haven't already */
80 /* zero the machine check error status registers */
83 for (i = 0; i < 5; i++) {
84 wrmsr(MCI_STATUS + (i * 4), msr);
89 /* Enable the local cpu apics */
92 /* Set the processor name string */
93 // init_processor_name();
96 #if CONFIG_LOGICAL_CPUS == 1
97 siblings = cpuid_ecx(0x80000008) & 0xff;
100 msr = rdmsr_amd(CPU_ID_FEATURES_MSR);
102 wrmsr_amd(CPU_ID_FEATURES_MSR, msr);
104 msr = rdmsr_amd(CPU_ID_EXT_FEATURES_MSR);
105 msr.hi |= 1 << (33 - 32);
106 wrmsr_amd(CPU_ID_EXT_FEATURES_MSR, msr);
108 printk(BIOS_DEBUG, "siblings = %02d, ", siblings);
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_12_init,
127 static struct cpu_device_id cpu_table[] = {
128 { X86_VENDOR_AMD, 0x300f00 }, /* LN1_A0x */
129 { X86_VENDOR_AMD, 0x300f01 }, /* LN1_A1x */
130 { X86_VENDOR_AMD, 0x300f10 }, /* LN1_B0x */
131 { X86_VENDOR_AMD, 0x300f20 }, /* LN2_B0x */
135 static const struct cpu_driver model_12 __cpu_driver = {
137 .id_table = cpu_table,