1 #include <console/console.h>
2 #include <device/pci.h>
3 #include <device/pci_ids.h>
7 #if CONFIG_LOGICAL_CPUS==1
8 #include <cpu/amd/dualcore.h>
12 // Global variables for MB layouts and these will be shared by irqtable mptable and acpi_tables
14 unsigned char bus_isa = 7;
15 unsigned char bus_8111_0 = 1;
16 unsigned char bus_8111_1 = 4;
17 unsigned char bus_8131[7][3]; // another 6 8131
19 unsigned apicid_8131[7][2];
22 unsigned pci1234[] = { //Here you only need to set value in pci1234 for HT-IO that could be installed or not
23 //You may need to preset pci1234 for HTIO board, please refer to src/northbridge/amd/amdk8/get_sblk_pci1234.c for detail
33 unsigned hc_possible_num;
35 unsigned hcdn[] = { //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
46 unsigned sbdnx[7]; // for all 8131
48 extern void get_sblk_pci1234(void);
50 static unsigned get_bus_conf_done = 0;
52 void get_bus_conf(void)
61 if (get_bus_conf_done == 1)
62 return; //do it only once
64 get_bus_conf_done = 1;
66 hc_possible_num = ARRAY_SIZE(pci1234);
71 sbdn = ((hcdn[0] >> 8) & 0xff); // first byte of first chain
72 sbdnx[0] = (hcdn[0] & 0xff);
74 for (i = 0; i < hc_possible_num; i++) {
75 sbdnx[i * 2 + 1] = hcdn[i] & 0xff;
76 sbdnx[i * 2 + 2] = (hcdn[i] >> 8) & 0xff;
79 bus_8131[0][0] = (pci1234[0] >> 16) & 0xff;
80 bus_8111_0 = bus_8131[0][0];
83 dev = dev_find_slot(bus_8111_0, PCI_DEVFN(sbdn, 0));
85 bus_8111_1 = pci_read_config8(dev, PCI_SECONDARY_BUS);
86 bus_isa = pci_read_config8(dev, PCI_SUBORDINATE_BUS);
88 // printk_debug("bus_isa=%d\n",bus_isa);
91 ("ERROR - could not find PCI %02x:03.0, using defaults\n",
98 dev = dev_find_slot(bus_8131[0][0], PCI_DEVFN(sbdnx[1], 0));
100 bus_8131[0][1] = pci_read_config8(dev, PCI_SECONDARY_BUS);
103 ("ERROR - could not find PCI %02x:01.0, using defaults\n",
109 dev = dev_find_slot(bus_8131[0][0], PCI_DEVFN(sbdnx[1] + 1, 0));
111 bus_8131[0][2] = pci_read_config8(dev, PCI_SECONDARY_BUS);
112 bus_isa = pci_read_config8(dev, PCI_SUBORDINATE_BUS);
116 ("ERROR - could not find PCI %02x:02.0, using defaults\n",
120 apicid_base = get_apicid_base(15);
122 apicid_8111 = apicid_base++;
124 apicid_8131[0][0] = apicid_base++;
126 apicid_8131[0][1] = apicid_base++;
130 for (i = 1; i < 4; i++) {
131 if (pci1234[i] & 0x1) {
132 int j = (i - 1) * 2 + 1;
133 bus_8131[j][0] = (pci1234[i] >> 16) & 0xff;
135 dev = dev_find_slot(bus_8131[j][0], PCI_DEVFN(sbdnx[j], 0));
137 bus_8131[j][1] = pci_read_config8(dev, PCI_SECONDARY_BUS);
139 apicid_8131[j][0] = apicid_base++;
140 dev = dev_find_slot(bus_8131[j][0], PCI_DEVFN(sbdnx[j] + 1, 0));
142 bus_8131[j][2] = pci_read_config8(dev, PCI_SECONDARY_BUS);
144 apicid_8131[j][1] = apicid_base++;
146 bus_8131[j + 1][0] = bus_8131[j][0];
148 dev = dev_find_slot(bus_8131[j + 1][0], PCI_DEVFN(sbdnx[j + 1], 0));
150 bus_8131[j + 1][1] = pci_read_config8(dev, PCI_SECONDARY_BUS);
152 apicid_8131[j + 1][0] = apicid_base++;
154 dev = dev_find_slot(bus_8131[i + 1][0], PCI_DEVFN(sbdnx[j + 1] + 1, 0));
156 bus_8131[j + 1][2] = pci_read_config8(dev, PCI_SECONDARY_BUS);
157 bus_isa = pci_read_config8(dev, PCI_SUBORDINATE_BUS);
161 apicid_8131[j + 1][0] = apicid_base++;