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/multicore.h>
33 #include <cpu/amd/amdk8_sysconf.h>
35 #include "mb_sysconf.h"
37 // Global variables for MB layouts and these will be shared by irqtable mptable and acpi_tables
38 struct mb_sysconf_t mb_sysconf;
40 static unsigned pci1234x[] =
41 { //Here you only need to set value in pci1234 for HT-IO that could be installed or not
42 //You may need to preset pci1234 for HTIO board, please refer to src/northbridge/amd/amdk8/get_sblk_pci1234.c for detail
52 static unsigned hcdnx[] =
53 { //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
66 static unsigned get_bus_conf_done = 0;
68 void get_bus_conf(void)
75 struct mb_sysconf_t *m;
77 if(get_bus_conf_done==1) return; //do it only once
79 get_bus_conf_done = 1;
81 sysconf.mb = &mb_sysconf;
85 sysconf.hc_possible_num = sizeof(pci1234x)/sizeof(pci1234x[0]);
87 for(i=0;i<sysconf.hc_possible_num; i++) {
88 sysconf.pci1234[i] = pci1234x[i];
89 sysconf.hcdn[i] = hcdnx[i];
94 sysconf.sbdn = (sysconf.hcdn[0] >> 8) & 0xff;
95 m->sbdn2 = sysconf.hcdn[0] & 0xff; // bcm5780
97 m->bus_bcm5785_0 = (sysconf.pci1234[0] >> 16) & 0xff;
98 m->bus_bcm5780[0] = m->bus_bcm5785_0;
101 printk(BIOS_DEBUG, "search for def %d.0 on bus %d\n",sysconf.sbdn,m->bus_bcm5785_0);
102 dev = dev_find_slot(m->bus_bcm5785_0, PCI_DEVFN(sysconf.sbdn,0));
104 printk(BIOS_DEBUG, "found dev %s...\n",dev_path(dev));
105 m->bus_bcm5785_1 = pci_read_config8(dev, PCI_SECONDARY_BUS);
106 printk(BIOS_DEBUG, "secondary is %d...\n",m->bus_bcm5785_1);
107 dev = dev_find_slot(m->bus_bcm5785_1, PCI_DEVFN(0xd,0));
108 printk(BIOS_DEBUG, "now found %s...\n",dev_path(dev));
110 m->bus_bcm5785_1_1 = pci_read_config8(dev, PCI_SECONDARY_BUS);
111 #if CONFIG_HT_CHAIN_END_UNITID_BASE >= CONFIG_HT_CHAIN_UNITID_BASE
112 m->bus_isa = pci_read_config8(dev, PCI_SUBORDINATE_BUS);
114 printk(BIOS_DEBUG, "bus_isa 1=%d\n",m->bus_isa);
119 printk(BIOS_DEBUG, "ERROR - could not find PCI %02x:%02x.0, using defaults\n", m->bus_bcm5785_0, sysconf.sbdn);
123 for(i = 1; i < 6; i++) {
124 dev = dev_find_slot(m->bus_bcm5780[0], PCI_DEVFN(m->sbdn2 + i - 1,0));
126 m->bus_bcm5780[i] = pci_read_config8(dev, PCI_SECONDARY_BUS);
127 #if CONFIG_HT_CHAIN_END_UNITID_BASE < CONFIG_HT_CHAIN_UNITID_BASE
128 m->bus_isa = pci_read_config8(dev, PCI_SUBORDINATE_BUS);
130 printk(BIOS_DEBUG, "bus_isa 2=%d\n",m->bus_isa);
135 printk(BIOS_DEBUG, "ERROR - could not find PCI %02x:%02x.0, using defaults\n", m->bus_bcm5780[0], m->sbdn2+i-1);
140 /*I/O APICs: APIC ID Version State Address*/
141 #if CONFIG_LOGICAL_CPUS==1
142 apicid_base = get_apicid_base(3);
144 apicid_base = CONFIG_MAX_PHYSICAL_CPUS;
147 m->apicid_bcm5785[i] = apicid_base+i;