Remove inline from FAM10 CPU initialization functions.
[coreboot.git] / src / cpu / amd / quadcore / quadcore.c
1 /*
2  * This file is part of the coreboot project.
3  *
4  * Copyright (C) 2007 Advanced Micro Devices, Inc.
5  *
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.
9  *
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.
14  *
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
18  */
19
20
21 #ifndef SET_NB_CFG_54
22         #define SET_NB_CFG_54 1
23 #endif
24
25 #include "cpu/amd/quadcore/quadcore_id.c"
26
27 static u32 get_core_num_in_bsp(u32 nodeid)
28 {
29         u32 dword;
30         dword = pci_read_config32(NODE_PCI(nodeid, 3), 0xe8);
31         dword >>= 12;
32         dword &= 3;
33         return dword;
34 }
35
36 #if SET_NB_CFG_54 == 1
37 static u8 set_apicid_cpuid_lo(void)
38 {
39         // set the NB_CFG[54]=1; why the OS will be happy with that ???
40         msr_t msr;
41         msr = rdmsr(NB_CFG_MSR);
42         msr.hi |= (1<<(54-32)); // InitApicIdCpuIdLo
43         wrmsr(NB_CFG_MSR, msr);
44
45         return 1;
46 }
47 #else
48
49 static void set_apicid_cpuid_lo(void) { }
50
51 #endif
52
53
54 static void real_start_other_core(u32 nodeid, u32 cores)
55 {
56         u32 dword;
57
58         printk_debug("Start other core - nodeid: %02x  cores: %02x\n", nodeid, cores);
59
60         /* set PCI_DEV(0, 0x18+nodeid, 3), 0x44 bit 27 to redirect all MC4
61            accesses and error logging to core0 */
62         dword = pci_read_config32(NODE_PCI(nodeid, 3), 0x44);
63         dword |= 1 << 27;       // NbMcaToMstCpuEn bit
64         pci_write_config32(NODE_PCI(nodeid, 3), 0x44, dword);
65         // set PCI_DEV(0, 0x18+nodeid, 0), 0x68 bit 5 to start core1
66         dword = pci_read_config32(NODE_PCI(nodeid, 0), 0x68);
67         dword |= 1 << 5;
68         pci_write_config32(NODE_PCI(nodeid, 0), 0x68, dword);
69
70         if(cores > 1) {
71                 dword = pci_read_config32(NODE_PCI(nodeid, 0), 0x168);
72                 dword |= (1 << 0);      // core2
73                 if(cores > 2) {         // core3
74                         dword |= (1 << 1);
75                 }
76                 pci_write_config32(NODE_PCI(nodeid, 0), 0x168, dword);
77         }
78 }
79
80 //it is running on core0 of node0
81 static void start_other_cores(void)
82 {
83         u32 nodes;
84         u32 nodeid;
85
86         // disable quad_core
87         if (read_option(CMOS_VSTART_quad_core, CMOS_VLEN_quad_core, 0) != 0)  {
88                 printk_debug("Skip additional core init\n");
89                 return;
90         }
91
92         nodes = get_nodes();
93
94         for (nodeid = 0; nodeid < nodes; nodeid++) {
95                 u32 cores = get_core_num_in_bsp(nodeid);
96                 printk_debug("init node: %02x  cores: %02x \n", nodeid, cores);
97                 if (cores > 0) {
98                         real_start_other_core(nodeid, cores);
99                 }
100         }
101
102 }