printk_foo -> printk(BIOS_FOO, ...)
[coreboot.git] / src / mainboard / tyan / s2892 / get_bus_conf.c
1 #include <console/console.h>
2 #include <device/pci.h>
3 #include <device/pci_ids.h>
4 #include <string.h>
5 #include <stdint.h>
6 #if CONFIG_LOGICAL_CPUS==1
7 #include <cpu/amd/dualcore.h>
8 #endif
9
10 #include <cpu/amd/amdk8_sysconf.h>
11 #include <stdlib.h>
12
13 // Global variables for MB layouts and these will be shared by irqtable mptable and acpi_tables
14 //busnum is default
15         unsigned char bus_isa;
16         unsigned char bus_ck804_0; //1
17         unsigned char bus_ck804_1; //2
18         unsigned char bus_ck804_2; //3
19         unsigned char bus_ck804_3; //4
20         unsigned char bus_ck804_4; //5
21         unsigned char bus_ck804_5; //6
22         unsigned char bus_8131_0;  //7
23         unsigned char bus_8131_1;  //8
24         unsigned char bus_8131_2;  //9
25         unsigned apicid_ck804;
26         unsigned apicid_8131_1;
27         unsigned apicid_8131_2;
28
29 unsigned pci1234x[] =
30 {        //Here you only need to set value in pci1234 for HT-IO that could be installed or not
31          //You may need to preset pci1234 for HTIO board, please refer to src/northbridge/amd/amdk8/get_sblk_pci1234.c for detail
32         0x0000ff0,
33         0x0000ff0,
34 //        0x0000ff0,
35 //        0x0000ff0,
36 //        0x0000ff0,
37 //        0x0000ff0,
38 //        0x0000ff0,
39 //        0x0000ff0
40 };
41 unsigned hcdnx[] =
42 { //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
43         0x20202020,
44         0x20202020,
45 //        0x20202020,
46 //        0x20202020,
47 //        0x20202020,
48 //        0x20202020,
49 //        0x20202020,
50 //        0x20202020,
51 };
52
53 unsigned sbdn3;
54
55 extern void get_sblk_pci1234(void);
56
57 static unsigned get_bus_conf_done = 0;
58
59 void get_bus_conf(void)
60 {
61
62         unsigned apicid_base;
63         unsigned sbdn;
64
65         device_t dev;
66         int i;
67
68         if(get_bus_conf_done==1) return; //do it only once
69
70         get_bus_conf_done = 1;
71
72         sysconf.hc_possible_num = ARRAY_SIZE(pci1234x);
73         for(i=0;i<sysconf.hc_possible_num; i++) {
74                 sysconf.pci1234[i] = pci1234x[i];
75                 sysconf.hcdn[i] = hcdnx[i];
76         }
77
78         get_sblk_pci1234();
79
80         sysconf.sbdn = (sysconf.hcdn[0] & 0xff); // first byte of first chain
81         sbdn = sysconf.sbdn;
82
83         sbdn3 = (sysconf.hcdn[1] & 0xff); // first byte of second chain
84
85         bus_ck804_0 = (sysconf.pci1234[0] >> 16) & 0xff;
86
87
88                 /* CK804 */
89                 dev = dev_find_slot(bus_ck804_0, PCI_DEVFN(sbdn + 0x09,0));
90                 if (dev) {
91                         bus_ck804_1 = pci_read_config8(dev, PCI_SECONDARY_BUS);
92                         bus_ck804_4 = pci_read_config8(dev, PCI_SUBORDINATE_BUS);
93                         bus_ck804_4++;
94                 }
95                 else {
96                         printk(BIOS_DEBUG, "ERROR - could not find PCI 1:%02x.0, using defaults\n", sbdn + 0x09);
97
98                         bus_ck804_1 = 2;
99                         bus_ck804_4 = 3;
100                 }
101
102                 dev = dev_find_slot(bus_ck804_0, PCI_DEVFN(sbdn + 0x0d,0));
103                 if (dev) {
104                         bus_ck804_4 = pci_read_config8(dev, PCI_SECONDARY_BUS);
105                         bus_ck804_5 = pci_read_config8(dev, PCI_SUBORDINATE_BUS);
106                         bus_ck804_5++;
107                 }
108                 else {
109                         printk(BIOS_DEBUG, "ERROR - could not find PCI 1:%02x.0, using defaults\n",sbdn + 0x0d);
110
111                         bus_ck804_5 = bus_ck804_4+1;
112                 }
113
114                 dev = dev_find_slot(bus_ck804_0, PCI_DEVFN(sbdn+ 0x0e,0));
115                 if (dev) {
116                         bus_ck804_5 = pci_read_config8(dev, PCI_SECONDARY_BUS);
117                         bus_isa = pci_read_config8(dev, PCI_SUBORDINATE_BUS);
118                         bus_isa++;
119                 }
120                 else {
121                         printk(BIOS_DEBUG, "ERROR - could not find PCI 1:%02x.0, using defaults\n", sbdn+ 0x0e);
122                 }
123
124                 bus_8131_0 = (sysconf.pci1234[1] >> 16) & 0xff;
125                 /* 8131-1 */
126                 dev = dev_find_slot(bus_8131_0, PCI_DEVFN(sbdn3,0));
127                 if (dev) {
128                         bus_8131_1 = pci_read_config8(dev, PCI_SECONDARY_BUS);
129                         bus_8131_2 = pci_read_config8(dev, PCI_SUBORDINATE_BUS);
130                         bus_8131_2++;
131                 }
132                 else {
133                         printk(BIOS_DEBUG, "ERROR - could not find PCI %02x:01.0, using defaults\n", bus_8131_0);
134
135                         bus_8131_1 = bus_8131_0+1;
136                         bus_8131_2 = bus_8131_0+2;
137                 }
138                 /* 8131-2 */
139                 dev = dev_find_slot(bus_8131_0, PCI_DEVFN(sbdn3+1,0));
140                 if (dev) {
141                         bus_8131_2 = pci_read_config8(dev, PCI_SECONDARY_BUS);
142                         bus_isa = pci_read_config8(dev, PCI_SUBORDINATE_BUS);
143                         bus_isa++;
144                 }
145                 else {
146                         printk(BIOS_DEBUG, "ERROR - could not find PCI %02x:02.0, using defaults\n", bus_8131_0);
147
148                         bus_8131_2 = bus_8131_1+1;
149                         bus_isa = bus_8131_1+2;
150                 }
151
152
153
154 /*I/O APICs:    APIC ID Version State           Address*/
155 #if CONFIG_LOGICAL_CPUS==1
156         apicid_base = get_apicid_base(3);
157 #else
158         apicid_base = CONFIG_MAX_PHYSICAL_CPUS;
159 #endif
160         apicid_ck804 = apicid_base+0;
161         apicid_8131_1 = apicid_base+1;
162         apicid_8131_2 = apicid_base+2;
163 }