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; 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 <device/pci.h>
22 #include <device/pci_ids.h>
25 #if CONFIG_LOGICAL_CPUS==1
26 #include <cpu/amd/dualcore.h>
29 #include <cpu/amd/amdfam10_sysconf.h>
31 #include "mb_sysconf.h"
33 /* Global variables for MB layouts and these will be shared by irqtable mptable and acpi_tables */
34 struct mb_sysconf_t mb_sysconf;
36 /* Here you only need to set value in pci1234 for HT-IO that could be
37 installed or not You may need to preset pci1234 for HTIO board, please
38 refer to src/northbridge/amd/amdfam10/get_sblk_pci1234.c for detail */
39 static u32 pci1234x[] = {
40 0x0000ffc, 0x0000ffc, 0x0000ffc, 0x0000ffc, 0x0000ffc, 0x0000ffc,
41 0x0000ffc, 0x0000ffc, 0x0000ffc, 0x0000ffc, 0x0000ffc, 0x0000ffc,
42 0x0000ffc, 0x0000ffc, 0x0000ffc, 0x0000ffc, 0x0000ffc, 0x0000ffc,
43 0x0000ffc, 0x0000ffc, 0x0000ffc, 0x0000ffc, 0x0000ffc, 0x0000ffc,
44 0x0000ffc, 0x0000ffc, 0x0000ffc, 0x0000ffc, 0x0000ffc, 0x0000ffc,
49 /* HT Chain device num, actually it is unit id base of every ht device
50 in chain, assume every chain only have 4 ht device at most */
52 static unsigned hcdnx[] = {
53 0x20202020, 0x20202020, 0x20202020, 0x20202020, 0x20202020,
54 0x20202020, 0x20202020, 0x20202020, 0x20202020, 0x20202020,
55 0x20202020, 0x20202020, 0x20202020, 0x20202020, 0x20202020,
56 0x20202020, 0x20202020, 0x20202020, 0x20202020, 0x20202020,
57 0x20202020, 0x20202020, 0x20202020, 0x20202020, 0x20202020,
58 0x20202020, 0x20202020, 0x20202020, 0x20202020, 0x20202020,
59 0x20202020, 0x20202020,
64 extern void get_pci1234(void);
66 static u32 get_bus_conf_done = 0;
68 static u32 get_hcid(u32 i)
71 u32 busn = (sysconf.pci1234[i] >> 12) & 0xff;
72 u32 devn = sysconf.hcdn[i] & 0xff;
75 dev = dev_find_slot(busn, PCI_DEVFN(devn,0));
77 switch (dev->device) {
88 // we may need more way to find out hcid: subsystem id? GPIO read ?
89 // we need use id for 1. bus num, 2. mptable, 3. acpi table
93 void get_bus_conf(void)
99 struct mb_sysconf_t *m;
101 if(get_bus_conf_done == 1)
102 return; //do it only once
104 get_bus_conf_done = 1;
106 sysconf.mb = &mb_sysconf;
110 for(i=0;i<256; i++) {
114 sysconf.hc_possible_num = sizeof(pci1234x)/sizeof(pci1234x[0]);
115 for(i=0;i<sysconf.hc_possible_num; i++) {
116 sysconf.pci1234[i] = pci1234x[i];
117 sysconf.hcdn[i] = hcdnx[i];
122 m->bus_type[0] = 1; //pci
124 sysconf.sbdn = (sysconf.hcdn[0] >> 8) & 0xff;
125 m->sbdn3 = sysconf.hcdn[0] & 0xff;
127 m->bus_8132_0 = (sysconf.pci1234[0] >> 12) & 0xff;
128 m->bus_8111_0 = m->bus_8132_0;
131 dev = dev_find_slot(m->bus_8111_0, PCI_DEVFN(sysconf.sbdn,0));
133 m->bus_8111_1 = pci_read_config8(dev, PCI_SECONDARY_BUS);
135 printk_debug("ERROR - could not find PCI %02x:%02x.0, using defaults\n", m->bus_8111_0, sysconf.sbdn);
139 dev = dev_find_slot(m->bus_8132_0, PCI_DEVFN(m->sbdn3,0));
141 m->bus_8132_1 = pci_read_config8(dev, PCI_SECONDARY_BUS);
143 printk_debug("ERROR - could not find PCI %02x:%02x.0, using defaults\n", m->bus_8132_0, m->sbdn3);
147 dev = dev_find_slot(m->bus_8132_0, PCI_DEVFN(m->sbdn3+1,0));
149 m->bus_8132_2 = pci_read_config8(dev, PCI_SECONDARY_BUS);
151 printk_debug("ERROR - could not find PCI %02x:%02x.0, using defaults\n", m->bus_8132_0, m->sbdn3+1);
154 for(i=0; i< sysconf.hc_possible_num; i++) {
155 if(!(sysconf.pci1234[i] & 0x1) ) continue;
157 u32 busn = (sysconf.pci1234[i] >> 12) & 0xff;
158 u32 busn_max = (sysconf.pci1234[i] >> 20) & 0xff;
159 for (j = busn; j <= busn_max; j++)
161 if(m->bus_isa <= busn_max)
162 m->bus_isa = busn_max + 1;
163 printk_debug("i=%d bus range: [%x, %x] bus_isa=%x\n",i, busn, busn_max, m->bus_isa);
168 for(i=1; i< sysconf.hc_possible_num; i++) {
169 if(!(sysconf.pci1234[i] & 0x1) ) continue;
171 // check hcid type here
172 sysconf.hcid[i] = get_hcid(i);
174 switch(sysconf.hcid[i]) {
179 m->bus_8132a[j][0] = (sysconf.pci1234[i] >> 12) & 0xff;
181 m->sbdn3a[j] = sysconf.hcdn[i] & 0xff;
184 dev = dev_find_slot(m->bus_8132a[j][0], PCI_DEVFN(m->sbdn3a[j],0));
186 m->bus_8132a[j][1] = pci_read_config8(dev, PCI_SECONDARY_BUS);
188 printk_debug("ERROR - could not find PCI %02x:%02x.0, using defaults\n", m->bus_8132a[j][0], m->sbdn3a[j]);
192 dev = dev_find_slot(m->bus_8132a[j][0], PCI_DEVFN(m->sbdn3a[j]+1,0));
194 m->bus_8132a[j][2] = pci_read_config8(dev, PCI_SECONDARY_BUS);
196 printk_debug("ERROR - could not find PCI %02x:%02x.0, using defaults\n", m->bus_8132a[j][0], m->sbdn3a[j]+1);
203 m->bus_8151[j][0] = (sysconf.pci1234[i] >> 12) & 0xff;
204 m->sbdn5[j] = sysconf.hcdn[i] & 0xff;
206 dev = dev_find_slot(m->bus_8151[j][0], PCI_DEVFN(m->sbdn5[j]+1, 0));
209 m->bus_8151[j][1] = pci_read_config8(dev, PCI_SECONDARY_BUS);
211 printk_debug("ERROR - could not find PCI %02x:%02x.0, using defaults\n", m->bus_8151[j][0], m->sbdn5[j]+1);
220 /*I/O APICs: APIC ID Version State Address*/
222 m->apicid_8111 = apicid_base + 0;
223 m->apicid_8132_1 = apicid_base + 1;
224 m->apicid_8132_2 = apicid_base + 2;
226 m->apicid_8132a[i][0] = apicid_base + 3 + i * 2;
227 m->apicid_8132a[i][1] = apicid_base + 3 + i * 2 + 1;