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>
32 #include "mb_sysconf.h"
34 /* Global variables for MB layouts and these will be shared by irqtable mptable and acpi_tables */
35 struct mb_sysconf_t mb_sysconf;
37 /* Here you only need to set value in pci1234 for HT-IO that could be
38 installed or not You may need to preset pci1234 for HTIO board, please
39 refer to src/northbridge/amd/amdfam10/get_sblk_pci1234.c for detail */
40 static u32 pci1234x[] = {
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,
45 0x0000ffc, 0x0000ffc, 0x0000ffc, 0x0000ffc, 0x0000ffc, 0x0000ffc,
50 /* HT Chain device num, actually it is unit id base of every ht device
51 in chain, assume every chain only have 4 ht device at most */
53 static unsigned hcdnx[] = {
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, 0x20202020, 0x20202020, 0x20202020,
60 0x20202020, 0x20202020,
65 extern void get_pci1234(void);
67 static u32 get_bus_conf_done = 0;
69 static u32 get_hcid(u32 i)
72 u32 busn = (sysconf.pci1234[i] >> 12) & 0xff;
73 u32 devn = sysconf.hcdn[i] & 0xff;
76 dev = dev_find_slot(busn, PCI_DEVFN(devn,0));
78 switch (dev->device) {
89 // we may need more way to find out hcid: subsystem id? GPIO read ?
90 // we need use id for 1. bus num, 2. mptable, 3. acpi table
94 void get_bus_conf(void)
100 struct mb_sysconf_t *m;
102 if(get_bus_conf_done == 1)
103 return; //do it only once
105 get_bus_conf_done = 1;
107 sysconf.mb = &mb_sysconf;
111 for(i=0;i<256; i++) {
115 sysconf.hc_possible_num = ARRAY_SIZE(pci1234x);
116 for(i=0;i<sysconf.hc_possible_num; i++) {
117 sysconf.pci1234[i] = pci1234x[i];
118 sysconf.hcdn[i] = hcdnx[i];
123 m->bus_type[0] = 1; //pci
125 sysconf.sbdn = (sysconf.hcdn[0] >> 8) & 0xff;
126 m->sbdn3 = sysconf.hcdn[0] & 0xff;
128 m->bus_8132_0 = (sysconf.pci1234[0] >> 12) & 0xff;
129 m->bus_8111_0 = m->bus_8132_0;
132 dev = dev_find_slot(m->bus_8111_0, PCI_DEVFN(sysconf.sbdn,0));
134 m->bus_8111_1 = pci_read_config8(dev, PCI_SECONDARY_BUS);
136 printk_debug("ERROR - could not find PCI %02x:%02x.0, using defaults\n", m->bus_8111_0, sysconf.sbdn);
140 dev = dev_find_slot(m->bus_8132_0, PCI_DEVFN(m->sbdn3,0));
142 m->bus_8132_1 = pci_read_config8(dev, PCI_SECONDARY_BUS);
144 printk_debug("ERROR - could not find PCI %02x:%02x.0, using defaults\n", m->bus_8132_0, m->sbdn3);
148 dev = dev_find_slot(m->bus_8132_0, PCI_DEVFN(m->sbdn3+1,0));
150 m->bus_8132_2 = pci_read_config8(dev, PCI_SECONDARY_BUS);
152 printk_debug("ERROR - could not find PCI %02x:%02x.0, using defaults\n", m->bus_8132_0, m->sbdn3+1);
155 for(i=0; i< sysconf.hc_possible_num; i++) {
156 if(!(sysconf.pci1234[i] & 0x1) ) continue;
158 u32 busn = (sysconf.pci1234[i] >> 12) & 0xff;
159 u32 busn_max = (sysconf.pci1234[i] >> 20) & 0xff;
160 for (j = busn; j <= busn_max; j++)
162 if(m->bus_isa <= busn_max)
163 m->bus_isa = busn_max + 1;
164 printk_debug("i=%d bus range: [%x, %x] bus_isa=%x\n",i, busn, busn_max, m->bus_isa);
169 for(i=1; i< sysconf.hc_possible_num; i++) {
170 if(!(sysconf.pci1234[i] & 0x1) ) continue;
172 // check hcid type here
173 sysconf.hcid[i] = get_hcid(i);
175 switch(sysconf.hcid[i]) {
180 m->bus_8132a[j][0] = (sysconf.pci1234[i] >> 12) & 0xff;
182 m->sbdn3a[j] = sysconf.hcdn[i] & 0xff;
185 dev = dev_find_slot(m->bus_8132a[j][0], PCI_DEVFN(m->sbdn3a[j],0));
187 m->bus_8132a[j][1] = pci_read_config8(dev, PCI_SECONDARY_BUS);
189 printk_debug("ERROR - could not find PCI %02x:%02x.0, using defaults\n", m->bus_8132a[j][0], m->sbdn3a[j]);
193 dev = dev_find_slot(m->bus_8132a[j][0], PCI_DEVFN(m->sbdn3a[j]+1,0));
195 m->bus_8132a[j][2] = pci_read_config8(dev, PCI_SECONDARY_BUS);
197 printk_debug("ERROR - could not find PCI %02x:%02x.0, using defaults\n", m->bus_8132a[j][0], m->sbdn3a[j]+1);
204 m->bus_8151[j][0] = (sysconf.pci1234[i] >> 12) & 0xff;
205 m->sbdn5[j] = sysconf.hcdn[i] & 0xff;
207 dev = dev_find_slot(m->bus_8151[j][0], PCI_DEVFN(m->sbdn5[j]+1, 0));
210 m->bus_8151[j][1] = pci_read_config8(dev, PCI_SECONDARY_BUS);
212 printk_debug("ERROR - could not find PCI %02x:%02x.0, using defaults\n", m->bus_8151[j][0], m->sbdn5[j]+1);
221 /*I/O APICs: APIC ID Version State Address*/
223 m->apicid_8111 = apicid_base + 0;
224 m->apicid_8132_1 = apicid_base + 1;
225 m->apicid_8132_2 = apicid_base + 2;
227 m->apicid_8132a[i][0] = apicid_base + 3 + i * 2;
228 m->apicid_8132a[i][1] = apicid_base + 3 + i * 2 + 1;