Unify Local APIC address definitions
[coreboot.git] / src / mainboard / tyan / s2881 / 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 apicid_8111;
15 extern  unsigned apicid_8131_1;
16 extern  unsigned apicid_8131_2;
17
18 extern  unsigned sbdn3;
19
20 static void *smp_write_config_table(void *v)
21 {
22         struct mp_config_table *mc;
23         int i, bus_isa;
24
25         mc = (void *)(((char *)v) + SMP_FLOATING_TABLE_LEN);
26
27         mptable_init(mc, LOCAL_APIC_ADDR);
28
29         smp_write_processors(mc);
30
31         get_bus_conf();
32
33         mptable_write_buses(mc, NULL, &bus_isa);
34
35 /*I/O APICs:    APIC ID Version State           Address*/
36         smp_write_ioapic(mc, apicid_8111, 0x11, IO_APIC_ADDR);
37         {
38                 device_t dev;
39                 struct resource *res;
40                 dev = dev_find_slot(bus_8131_0, PCI_DEVFN(sbdn3,1));
41                 if (dev) {
42                         res = find_resource(dev, PCI_BASE_ADDRESS_0);
43                         if (res) {
44                                 smp_write_ioapic(mc, apicid_8131_1, 0x11, res->base);
45                         }
46                 }
47                 dev = dev_find_slot(bus_8131_0, PCI_DEVFN(sbdn3+1,1));
48                 if (dev) {
49                         res = find_resource(dev, PCI_BASE_ADDRESS_0);
50                         if (res) {
51                                 smp_write_ioapic(mc, apicid_8131_2, 0x11, res->base);
52                         }
53                 }
54
55         }
56
57         mptable_add_isa_interrupts(mc, bus_isa, apicid_8111, 0);
58
59 /*I/O Ints:     Type    Polarity    Trigger     Bus ID   IRQ    APIC ID PIN# */
60 //8111 LPC ????
61         smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, bus_8111_0, ((sysconf.sbdn+1)<<2)|0, apicid_8111, 0x13);
62
63 //On Board AMD USB ???
64         smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, bus_8111_1, (0<<2)|3, apicid_8111, 0x13);
65
66 //On Board ATI Display Adapter
67         smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, bus_8111_1, (6<<2)|0, apicid_8111, 0x12);
68
69 //On Board SI Serial ATA
70         smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, bus_8111_1, (5<<2)|0, apicid_8111, 0x11);
71
72 //Slot 3 PCIX 100/66
73         for(i=0;i<4;i++) {
74                 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
75         }
76
77 //On Board NIC and adaptec scsi
78         for(i=0;i<2;i++) {
79                 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, bus_8131_1, (9<<2)|i, apicid_8131_1, (0+i)%4); //24
80                 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, bus_8131_1, (0xa<<2)|i, apicid_8131_1, (0+i)%4); //24
81         }
82
83 //Slot 1 PCI-X 133/100/66 or Side 1 on raiser card
84         for(i=0;i<4;i++) {
85                 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
86         }
87
88         //Slot 1 PCI-X 133/100/66, Side 2 on raiser card
89         //Fix ME, IRQ Pins?
90         for(i=0;i<4;i++) {
91                 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, bus_8131_2, (4<<2)|i, apicid_8131_2, (1+i)%4); //28
92         }
93
94
95
96 /*Local Ints:   Type    Polarity    Trigger     Bus ID   IRQ    APIC ID PIN#*/
97         mptable_lintsrc(mc, bus_isa);
98         /* There is no extension information... */
99
100         /* Compute the checksums */
101         return mptable_finalize(mc);
102 }
103
104 unsigned long write_smp_table(unsigned long addr)
105 {
106         void *v;
107         v = smp_write_floating_table(addr, 0);
108         return (unsigned long)smp_write_config_table(v);
109 }