1 #include <console/console.h>
2 #include <device/pci.h>
3 #include <device/pci_ids.h>
6 #if CONFIG_LOGICAL_CPUS==1
7 #include <cpu/amd/dualcore.h>
10 #include <cpu/amd/amdk8_sysconf.h>
13 #include "mb_sysconf.h"
15 // Global variables for MB layouts and these will be shared by irqtable mptable and acpi_tables
16 struct mb_sysconf_t mb_sysconf;
18 static unsigned pci1234x[] =
19 { //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, // SB chain m
23 0x0000100, // co processor on socket 1
30 static unsigned hcdnx[] =
31 { //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
42 extern void get_sblk_pci1234(void);
44 static unsigned get_bus_conf_done = 0;
46 static unsigned get_hcid(unsigned i)
50 unsigned busn = (sysconf.pci1234[i] >> 16) & 0xff;
52 unsigned devn = sysconf.hcdn[i] & 0xff;
56 dev = dev_find_slot(busn, PCI_DEVFN(devn,0));
58 switch (dev->device) {
70 // we may need more way to find out hcid: subsystem id? GPIO read ?
72 // we need use id for 1. bus num, 2. mptable, 3. acpi table
77 void get_bus_conf(void)
84 struct mb_sysconf_t *m;
86 if(get_bus_conf_done == 1) return; //do it only once
88 get_bus_conf_done = 1;
90 sysconf.mb = &mb_sysconf;
94 sysconf.hc_possible_num = ARRAY_SIZE(pci1234x);
95 for(i=0;i<sysconf.hc_possible_num; i++) {
96 sysconf.pci1234[i] = pci1234x[i];
97 sysconf.hcdn[i] = hcdnx[i];
102 sysconf.sbdn = (sysconf.hcdn[0] >> 8) & 0xff;
103 m->sbdn3 = sysconf.hcdn[0] & 0xff;
105 m->bus_8132_0 = (sysconf.pci1234[0] >> 16) & 0xff;
106 m->bus_8111_0 = m->bus_8132_0;
109 dev = dev_find_slot(m->bus_8111_0, PCI_DEVFN(sysconf.sbdn,0));
111 m->bus_8111_1 = pci_read_config8(dev, PCI_SECONDARY_BUS);
112 #if CONFIG_HT_CHAIN_END_UNITID_BASE >= CONFIG_HT_CHAIN_UNITID_BASE
113 m->bus_isa = pci_read_config8(dev, PCI_SUBORDINATE_BUS);
115 // printk_debug("bus_isa=%d\n",bus_isa);
119 printk_debug("ERROR - could not find PCI %02x:%02x.0, using defaults\n", m->bus_8111_0, sysconf.sbdn);
123 dev = dev_find_slot(m->bus_8132_0, PCI_DEVFN(m->sbdn3,0));
125 m->bus_8132_1 = pci_read_config8(dev, PCI_SECONDARY_BUS);
128 printk_debug("ERROR - could not find PCI %02x:%02x.0, using defaults\n", m->bus_8132_0, m->sbdn3);
132 dev = dev_find_slot(m->bus_8132_0, PCI_DEVFN(m->sbdn3+1,0));
134 m->bus_8132_2 = pci_read_config8(dev, PCI_SECONDARY_BUS);
135 #if CONFIG_HT_CHAIN_END_UNITID_BASE < CONFIG_HT_CHAIN_UNITID_BASE
136 m->bus_isa = pci_read_config8(dev, PCI_SUBORDINATE_BUS);
138 // printk_debug("bus_isa=%d\n",bus_isa);
142 printk_debug("ERROR - could not find PCI %02x:%02x.0, using defaults\n", m->bus_8132_0, m->sbdn3+1);
147 for(i=1; i< sysconf.hc_possible_num; i++) {
148 if(!(sysconf.pci1234[i] & 0x1) ) continue;
150 // check hcid type here
151 sysconf.hcid[i] = get_hcid(i);
153 switch(sysconf.hcid[i]) {
158 m->bus_8132a[j][0] = (sysconf.pci1234[i] >> 16) & 0xff;
160 m->sbdn3a[j] = sysconf.hcdn[i] & 0xff;
163 dev = dev_find_slot(m->bus_8132a[j][0], PCI_DEVFN(m->sbdn3a[j],0));
165 m->bus_8132a[j][1] = pci_read_config8(dev, PCI_SECONDARY_BUS);
168 printk_debug("ERROR - could not find PCI %02x:%02x.0, using defaults\n", m->bus_8132a[j][0], m->sbdn3a[j]);
172 dev = dev_find_slot(m->bus_8132a[j][0], PCI_DEVFN(m->sbdn3a[j]+1,0));
174 m->bus_8132a[j][2] = pci_read_config8(dev, PCI_SECONDARY_BUS);
175 m->bus_isa = pci_read_config8(dev, PCI_SUBORDINATE_BUS);
177 // printk_debug("bus_isa=%d\n",bus_isa);
180 printk_debug("ERROR - could not find PCI %02x:%02x.0, using defaults\n", m->bus_8132a[j][0], m->sbdn3a[j]+1);
187 m->bus_8151[j][0] = (sysconf.pci1234[i] >> 16) & 0xff;
188 m->sbdn5[j] = sysconf.hcdn[i] & 0xff;
190 dev = dev_find_slot(m->bus_8151[j][0], PCI_DEVFN(m->sbdn5[j]+1, 0));
193 m->bus_8151[j][1] = pci_read_config8(dev, PCI_SECONDARY_BUS);
194 // printk_debug("bus_8151_1=%d\n",bus_8151[j][1]);
195 m->bus_isa = pci_read_config8(dev, PCI_SUBORDINATE_BUS);
199 printk_debug("ERROR - could not find PCI %02x:%02x.0, using defaults\n", m->bus_8151[j][0], m->sbdn5[j]+1);
209 /*I/O APICs: APIC ID Version State Address*/
210 #if CONFIG_LOGICAL_CPUS==1
211 apicid_base = get_apicid_base(3);
213 apicid_base = CONFIG_MAX_PHYSICAL_CPUS;
215 m->apicid_8111 = apicid_base+0;
216 m->apicid_8132_1 = apicid_base+1;
217 m->apicid_8132_2 = apicid_base+2;
219 m->apicid_8132a[i][0] = apicid_base + 3 + i*2;
220 m->apicid_8132a[i][1] = apicid_base + 3 + i*2 + 1;