blob: c344ea3281ea2b6908b3a1dd03eb864ddb2d355d [file] [log] [blame]
Yinghai Luafd34e62006-02-16 17:22:19 +00001#include <console/console.h>
2#include <device/pci.h>
3#include <device/pci_ids.h>
4#include <string.h>
5#include <stdint.h>
Stefan Reinauer9a16e3e2010-03-29 14:45:36 +00006#include <cpu/amd/multicore.h>
Yinghai Luafd34e62006-02-16 17:22:19 +00007
Yinghai Lu6d74d762006-10-04 23:57:49 +00008#include <cpu/amd/amdk8_sysconf.h>
Carl-Daniel Hailfinger2ee67792008-10-01 12:52:52 +00009#include <stdlib.h>
Yinghai Lu6d74d762006-10-04 23:57:49 +000010
Yinghai Luafd34e62006-02-16 17:22:19 +000011// Global variables for MB layouts and these will be shared by irqtable mptable and acpi_tables
12//busnum is default
Yinghai Luafd34e62006-02-16 17:22:19 +000013unsigned char bus_bcm5780[7];
14unsigned char bus_bcm5785_0 = 1;
15unsigned char bus_bcm5785_1 = 8;
16unsigned char bus_bcm5785_1_1 = 9;
17unsigned apicid_bcm5785[3];
18
Paul Menzel6a4e9b52013-10-18 09:42:55 +020019unsigned pci1234x[] = { //Here you only need to set value in pci1234 for HT-IO that could be installed or not
20 //You may need to preset pci1234 for HTIO board, please refer to src/northbridge/amd/amdk8/get_sblk_pci1234.c for detail
21 0x0000ff0,
Yinghai Lu6d74d762006-10-04 23:57:49 +000022// 0x0000ff0,
23// 0x0000ff0,
24// 0x0000ff0,
25// 0x0000ff0,
26// 0x0000ff0,
27// 0x0000ff0,
28// 0x0000ff0
29};
Paul Menzel6a4e9b52013-10-18 09:42:55 +020030
31unsigned hcdnx[] = { //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
32 0x20202020,
Yinghai Lu6d74d762006-10-04 23:57:49 +000033// 0x20202020,
34// 0x20202020,
35// 0x20202020,
36// 0x20202020,
37// 0x20202020,
38// 0x20202020,
39// 0x20202020,
40};
Paul Menzel6a4e9b52013-10-18 09:42:55 +020041
Yinghai Luafd34e62006-02-16 17:22:19 +000042unsigned sbdn2;
43
Yinghai Luafd34e62006-02-16 17:22:19 +000044static unsigned get_bus_conf_done = 0;
45
46void get_bus_conf(void)
47{
48
49 unsigned apicid_base;
50
Paul Menzel6a4e9b52013-10-18 09:42:55 +020051 device_t dev;
52 int i;
Yinghai Luafd34e62006-02-16 17:22:19 +000053
Paul Menzel6a4e9b52013-10-18 09:42:55 +020054 if (get_bus_conf_done == 1)
55 return; //do it only once
Yinghai Luafd34e62006-02-16 17:22:19 +000056
Paul Menzel6a4e9b52013-10-18 09:42:55 +020057 get_bus_conf_done = 1;
Yinghai Luafd34e62006-02-16 17:22:19 +000058
Paul Menzel6a4e9b52013-10-18 09:42:55 +020059 sysconf.hc_possible_num = ARRAY_SIZE(pci1234x);
60 for (i = 0; i < sysconf.hc_possible_num; i++) {
61 sysconf.pci1234[i] = pci1234x[i];
62 sysconf.hcdn[i] = hcdnx[i];
63 }
Yinghai Luafd34e62006-02-16 17:22:19 +000064
Paul Menzel6a4e9b52013-10-18 09:42:55 +020065 get_sblk_pci1234();
Yinghai Luafd34e62006-02-16 17:22:19 +000066
Paul Menzel6a4e9b52013-10-18 09:42:55 +020067 sysconf.sbdn = (sysconf.hcdn[0] >> 8) & 0xff;
68 sbdn2 = sysconf.hcdn[0] & 0xff; // bcm5780
Yinghai Luafd34e62006-02-16 17:22:19 +000069
Yinghai Lu6d74d762006-10-04 23:57:49 +000070 bus_bcm5785_0 = (sysconf.pci1234[0] >> 16) & 0xff;
Yinghai Luafd34e62006-02-16 17:22:19 +000071 bus_bcm5780[0] = bus_bcm5785_0;
72
Paul Menzel6a4e9b52013-10-18 09:42:55 +020073 /* bcm5785 */
74 dev = dev_find_slot(bus_bcm5785_0, PCI_DEVFN(sysconf.sbdn, 0));
75 if (dev) {
76 bus_bcm5785_1 = pci_read_config8(dev, PCI_SECONDARY_BUS);
77 dev = dev_find_slot(bus_bcm5785_1, PCI_DEVFN(0x0d, 0));
78 if (dev) {
79 bus_bcm5785_1_1 =
80 pci_read_config8(dev, PCI_SECONDARY_BUS);
Yinghai Luafd34e62006-02-16 17:22:19 +000081 }
Paul Menzel6a4e9b52013-10-18 09:42:55 +020082 } else {
83 printk(BIOS_DEBUG,
84 "ERROR - could not find PCI %02x:07.0, using defaults\n",
85 bus_bcm5785_0);
Yinghai Luafd34e62006-02-16 17:22:19 +000086 }
87
Paul Menzel6a4e9b52013-10-18 09:42:55 +020088 /* bcm5780 */
89 for (i = 1; i < 7; i++) {
90 dev =
91 dev_find_slot(bus_bcm5780[0], PCI_DEVFN(sbdn2 + i - 1, 0));
92 if (dev) {
93 bus_bcm5780[i] =
94 pci_read_config8(dev, PCI_SECONDARY_BUS);
95 } else {
96 printk(BIOS_DEBUG,
97 "ERROR - could not find PCI %02x:01.0, using defaults\n",
98 bus_bcm5780[i]);
99 }
100 }
Yinghai Luafd34e62006-02-16 17:22:19 +0000101
102/*I/O APICs: APIC ID Version State Address*/
Timothy Pearsond4bbfe82015-10-27 16:48:36 -0500103 if (IS_ENABLED(CONFIG_LOGICAL_CPUS))
104 apicid_base = get_apicid_base(3);
105 else
106 apicid_base = CONFIG_MAX_PHYSICAL_CPUS;
Paul Menzel6a4e9b52013-10-18 09:42:55 +0200107 for (i = 0; i < 3; i++)
108 apicid_bcm5785[i] = apicid_base + i;
Yinghai Luafd34e62006-02-16 17:22:19 +0000109}