Unify Local APIC address definitions
[coreboot.git] / src / mainboard / tyan / s2891 / mptable.c
1 #include <console/console.h>
2 #include <arch/smp/mpspec.h>
3 #include <device/pci.h>
4 #include <string.h>
5 #include <stdint.h>
6 #include <cpu/amd/amdk8_sysconf.h>
7
8 extern  unsigned char bus_ck804_0; //1
9 extern  unsigned char bus_ck804_1; //2
10 extern  unsigned char bus_ck804_2; //3
11 extern  unsigned char bus_ck804_3; //4
12 extern  unsigned char bus_ck804_4; //5
13 extern  unsigned char bus_ck804_5; //6
14 extern  unsigned char bus_8131_0;  //7
15 extern  unsigned char bus_8131_1;  //8
16 extern  unsigned char bus_8131_2;  //9
17 extern  unsigned apicid_ck804;
18 extern  unsigned apicid_8131_1;
19 extern  unsigned apicid_8131_2;
20
21 extern  unsigned sbdn3;
22
23 static void *smp_write_config_table(void *v)
24 {
25         struct mp_config_table *mc;
26         unsigned sbdn;
27         int i, bus_isa;
28
29         mc = (void *)(((char *)v) + SMP_FLOATING_TABLE_LEN);
30
31         mptable_init(mc, LOCAL_APIC_ADDR);
32
33         smp_write_processors(mc);
34
35         get_bus_conf();
36         sbdn = sysconf.sbdn;
37
38         mptable_write_buses(mc, NULL, &bus_isa);
39
40 /*I/O APICs:    APIC ID Version State           Address*/
41         {
42                 device_t dev;
43                 struct resource *res;
44                 uint32_t dword;
45
46                 dev = dev_find_slot(bus_ck804_0, PCI_DEVFN(sbdn+ 0x1,0));
47                 if (dev) {
48                         res = find_resource(dev, PCI_BASE_ADDRESS_1);
49                         if (res) {
50                                 smp_write_ioapic(mc, apicid_ck804, 0x11, res->base);
51                         }
52
53         /* Initialize interrupt mapping*/
54
55                         dword = 0x0120d218;
56                         pci_write_config32(dev, 0x7c, dword);
57
58                         dword = 0x12008a00;
59                         pci_write_config32(dev, 0x80, dword);
60
61                         dword = 0x0000007d;
62                         pci_write_config32(dev, 0x84, dword);
63
64                 }
65
66                 dev = dev_find_slot(bus_8131_0, PCI_DEVFN(sbdn3,1));
67                 if (dev) {
68                         res = find_resource(dev, PCI_BASE_ADDRESS_0);
69                         if (res) {
70                                 smp_write_ioapic(mc, apicid_8131_1, 0x11, res->base);
71                         }
72                 }
73                 dev = dev_find_slot(bus_8131_0, PCI_DEVFN(sbdn3+1,1));
74                 if (dev) {
75                         res = find_resource(dev, PCI_BASE_ADDRESS_0);
76                         if (res) {
77                                 smp_write_ioapic(mc, apicid_8131_2, 0x11, res->base);
78                         }
79                 }
80
81         }
82
83         mptable_add_isa_interrupts(mc, bus_isa, apicid_ck804, 1);
84
85 // Onboard ck804 smbus
86         smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, bus_ck804_0, ((sbdn+1)<<2)|1, apicid_ck804, 0xa); // 10
87
88 // Onboard ck804 USB 1.1
89         smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, bus_ck804_0, ((sbdn+2)<<2)|0, apicid_ck804, 0x15); // 21
90
91 // Onboard ck804 USB 2
92         smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, bus_ck804_0, ((sbdn+2)<<2)|1, apicid_ck804, 0x14); // 20
93
94 // Onboard ck804 SATA 0
95         smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, bus_ck804_0, ((sbdn +7)<<2)|0, apicid_ck804, 0x17); // 23
96
97 // Onboard ck804 SATA 1
98         smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, bus_ck804_0, ((sbdn +8)<<2)|0, apicid_ck804, 0x16); // 22
99
100 //Slot PCIE x16
101         for(i=0;i<4;i++) {
102                 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, bus_ck804_5, (0x00<<2)|i, apicid_ck804, 0x10 + (2+i+4-sbdn%4)%4);
103         }
104
105 //Slot  PCIE x4
106         for(i=0;i<4;i++) {
107                 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, bus_ck804_4, (0x00<<2)|i, apicid_ck804, 0x10 + (1+i+4-sbdn%4)%4);
108         }
109
110 //Onboard ati
111         smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, bus_ck804_1, (7<<2)|0, apicid_ck804, 0x13); // 19
112
113 //Channel B of 8131
114
115
116 //Onboard Broadcom NIC
117         for(i=0;i<2;i++) {
118                 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, bus_8131_2, (9<<2)|i, apicid_8131_2, (0+i)%4); //28
119         }
120
121 //Channel A of 8131
122
123 //Slot 4 PCIX 133/100/66
124         for(i=0;i<4;i++) {
125                 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, bus_8131_1, (8<<2)|i, apicid_8131_1, (0+i)%4); //24
126         }
127
128 //Slot 3 PCIX 133/100/66 SoDIMM PCI
129         for(i=0;i<4;i++) {
130                 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, bus_8131_1, (0xa<<2)|i, apicid_8131_1, (2+i)%4); //26
131         }
132
133 /*Local Ints:   Type    Polarity    Trigger     Bus ID   IRQ    APIC ID PIN#*/
134         mptable_lintsrc(mc, bus_isa);
135         /* There is no extension information... */
136
137         /* Compute the checksums */
138         return mptable_finalize(mc);
139 }
140
141 unsigned long write_smp_table(unsigned long addr)
142 {
143         void *v;
144         v = smp_write_floating_table(addr, 0);
145         return (unsigned long)smp_write_config_table(v);
146 }