Unify Local APIC address definitions
[coreboot.git] / src / mainboard / tyan / s2885 / mptable.c
1 #include <console/console.h>
2 #include <arch/smp/mpspec.h>
3 #include <arch/ioapic.h>
4 #include <device/pci.h>
5 #include <string.h>
6 #include <stdint.h>
7 #include <cpu/amd/amdk8_sysconf.h>
8
9 extern  unsigned char bus_8131_0;
10 extern  unsigned char bus_8131_1;
11 extern  unsigned char bus_8131_2;
12 extern  unsigned char bus_8111_0;
13 extern  unsigned char bus_8111_1;
14 extern  unsigned char bus_8151_0;
15 extern  unsigned char bus_8151_1;
16 extern  unsigned apicid_8111;
17 extern  unsigned apicid_8131_1;
18 extern  unsigned apicid_8131_2;
19
20 extern  unsigned sbdn3;
21 extern  unsigned sbdn5;
22
23 static void *smp_write_config_table(void *v)
24 {
25         struct mp_config_table *mc;
26         int i, bus_isa;
27
28         mc = (void *)(((char *)v) + SMP_FLOATING_TABLE_LEN);
29
30         mptable_init(mc, LOCAL_APIC_ADDR);
31
32         smp_write_processors(mc);
33
34         get_bus_conf();
35
36         mptable_write_buses(mc, NULL, &bus_isa);
37
38 /*I/O APICs:    APIC ID Version State           Address*/
39         smp_write_ioapic(mc, apicid_8111, 0x11, IO_APIC_ADDR); //8111
40         {
41                 device_t dev;
42                 struct resource *res;
43                 dev = dev_find_slot(bus_8131_0, PCI_DEVFN(sbdn3,1));
44                 if (dev) {
45                         res = find_resource(dev, PCI_BASE_ADDRESS_0);
46                         if (res) {
47                                 smp_write_ioapic(mc, apicid_8131_1, 0x11, res->base);
48                         }
49                 }
50                 dev = dev_find_slot(bus_8131_0, PCI_DEVFN(sbdn3+1,1));
51                 if (dev) {
52                         res = find_resource(dev, PCI_BASE_ADDRESS_0);
53                         if (res) {
54                                 smp_write_ioapic(mc, apicid_8131_2, 0x11, res->base);
55                         }
56                 }
57         }
58
59         mptable_add_isa_interrupts(mc, bus_isa, apicid_8111, 0);
60
61 /*I/O Ints:     Type    Polarity    Trigger     Bus ID   IRQ    APIC ID PIN# */
62 //??? What
63         smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, bus_8111_0, ((sysconf.sbdn+1)<<2)|3, apicid_8111, 0x13);
64 //Onboard AMD AC97 Audio
65         smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, bus_8111_0, ((sysconf.sbdn+1)<<2)|1, apicid_8111, 0x11);
66 // Onboard AMD USB
67         smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, bus_8111_1, (0<<2)|3, apicid_8111, 0x13);
68
69 //  AGP Display Adapter
70         smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, bus_8151_1, 0x0, apicid_8111, 0x10);
71
72 //Onboard Serial ATA
73         smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, bus_8111_1, (0x0b<<2)|0, apicid_8111, 0x11);
74 //Onboard Firewire
75         smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, bus_8111_1, (0x0c<<2)|0, apicid_8111, 0x13);
76 //Onboard Broadcom NIC
77         smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, bus_8131_1, (9<<2)|0, apicid_8131_1, 0x0);
78
79 //Slot 5 PCI 32
80         for(i=0;i<4;i++) {
81                 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, bus_8111_1, (0x0a<<2)|i, apicid_8111, 0x10 + (0+i)%4); //16
82         }
83
84
85 //Slot 3 PCIX 100/66
86         for(i=0;i<4;i++) {
87                 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, bus_8131_1, (8<<2)|i, apicid_8131_1, (3+i)%4); //27
88         }
89
90
91 //Slot 4 PCIX 100/66
92         for(i=0;i<4;i++) {
93                 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, bus_8131_1, (7<<2)|i, apicid_8131_1, (2+i)%4); //26
94         }
95
96
97 //Slot 1 PCI-X 133/100/66
98         for(i=0;i<4;i++) {
99                 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, bus_8131_2, (3<<2)|i, apicid_8131_2, (0+i)%4); //28
100         }
101
102
103 //Slot 2 PCI-X 133/100/66
104         for(i=0;i<4;i++) {
105                 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, bus_8131_2, (6<<2)|i, apicid_8131_2, (1+i)%4); //29
106         }
107
108 /*Local Ints:   Type    Polarity    Trigger     Bus ID   IRQ    APIC ID PIN#*/
109         mptable_lintsrc(mc, bus_isa);
110         /* There is no extension information... */
111
112         /* Compute the checksums */
113         return mptable_finalize(mc);
114 }
115
116 unsigned long write_smp_table(unsigned long addr)
117 {
118         void *v;
119         v = smp_write_floating_table(addr, 0);
120         return (unsigned long)smp_write_config_table(v);
121 }