2 * This file is part of the coreboot project.
4 * Copyright (C) 2006 AMD
5 * Written by Yinghai Lu <yinghailu@gmail.com> for AMD.
7 * Copyright (C) 2006 MSI
8 * Written by bxshi <bingxunshi@gmail.com> for MSI.
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
24 #include <console/console.h>
25 #include <device/pci.h>
26 #include <device/pci_ids.h>
29 #if CONFIG_LOGICAL_CPUS==1
30 #include <cpu/amd/dualcore.h>
33 #include <cpu/amd/amdk8_sysconf.h>
36 #include "mb_sysconf.h"
38 // Global variables for MB layouts and these will be shared by irqtable mptable and acpi_tables
39 struct mb_sysconf_t mb_sysconf;
41 static unsigned pci1234x[] =
42 { //Here you only need to set value in pci1234 for HT-IO that could be installed or not
43 //You may need to preset pci1234 for HTIO board, please refer to src/northbridge/amd/amdk8/get_sblk_pci1234.c for detail
53 static unsigned hcdnx[] =
54 { //HT Chain device num, actually it is unit id base of every ht device in chain, assume every chain only have 4 ht device at most
65 extern void get_sblk_pci1234(void);
67 static unsigned get_bus_conf_done = 0;
69 void get_bus_conf(void)
76 struct mb_sysconf_t *m;
78 if(get_bus_conf_done==1) return; //do it only once
80 get_bus_conf_done = 1;
82 sysconf.mb = &mb_sysconf;
86 sysconf.hc_possible_num = ARRAY_SIZE(pci1234x);
88 for(i=0;i<sysconf.hc_possible_num; i++) {
89 sysconf.pci1234[i] = pci1234x[i];
90 sysconf.hcdn[i] = hcdnx[i];
95 sysconf.sbdn = (sysconf.hcdn[0] >> 8) & 0xff;
96 m->sbdn2 = sysconf.hcdn[0] & 0xff; // bcm5780
98 m->bus_bcm5785_0 = (sysconf.pci1234[0] >> 16) & 0xff;
99 m->bus_bcm5780[0] = m->bus_bcm5785_0;
102 dev = dev_find_slot(m->bus_bcm5785_0, PCI_DEVFN(sysconf.sbdn,0));
104 m->bus_bcm5785_1 = pci_read_config8(dev, PCI_SECONDARY_BUS);
105 dev = dev_find_slot(m->bus_bcm5785_1, PCI_DEVFN(0xd,0));
107 m->bus_bcm5785_1_1 = pci_read_config8(dev, PCI_SECONDARY_BUS);
108 #if CONFIG_HT_CHAIN_END_UNITID_BASE >= CONFIG_HT_CHAIN_UNITID_BASE
109 m->bus_isa = pci_read_config8(dev, PCI_SUBORDINATE_BUS);
111 printk_debug("bus_isa=%d\n",m->bus_isa);
116 printk_debug("ERROR - could not find PCI %02x:%02x.0, using defaults\n", m->bus_bcm5785_0, sysconf.sbdn);
120 for(i = 1; i < 7; i++) {
121 dev = dev_find_slot(m->bus_bcm5780[0], PCI_DEVFN(m->sbdn2 + i - 1,0));
123 m->bus_bcm5780[i] = pci_read_config8(dev, PCI_SECONDARY_BUS);
124 #if CONFIG_HT_CHAIN_END_UNITID_BASE < CONFIG_HT_CHAIN_UNITID_BASE
125 m->bus_isa = pci_read_config8(dev, PCI_SUBORDINATE_BUS);
127 printk_debug("bus_isa=%d\n",m->bus_isa);
132 printk_debug("ERROR - could not find PCI %02x:%02x.0, using defaults\n", m->bus_bcm5780[0], m->sbdn2+i-1);
137 /*I/O APICs: APIC ID Version State Address*/
138 #if CONFIG_LOGICAL_CPUS==1
139 apicid_base = get_apicid_base(3);
141 apicid_base = CONFIG_MAX_PHYSICAL_CPUS;
144 m->apicid_bcm5785[i] = apicid_base+i;