Unify Local APIC address definitions
[coreboot.git] / src / mainboard / supermicro / x6dai_g / 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
8 static void *smp_write_config_table(void *v)
9 {
10         struct mp_config_table *mc;
11         int bus_isa;
12         unsigned char bus_6300;
13
14         mc = (void *)(((char *)v) + SMP_FLOATING_TABLE_LEN);
15
16         mptable_init(mc, LOCAL_APIC_ADDR);
17
18         smp_write_processors(mc);
19
20         {
21                 device_t dev;
22
23                 /* southbridge */
24                 dev = dev_find_slot(0, PCI_DEVFN(0x1e,0));
25                 if (dev) {
26                         bus_6300 = pci_read_config8(dev, PCI_SECONDARY_BUS);
27                 }
28                 else {
29                         printk(BIOS_DEBUG, "ERROR - could not find PCI 0:1e.0, using defaults\n");
30                         bus_6300 = 5;
31                 }
32         }
33
34         mptable_write_buses(mc, NULL, &bus_isa);
35
36         /* IOAPIC handling */
37
38         smp_write_ioapic(mc, 2, 0x20, IO_APIC_ADDR);
39         smp_write_ioapic(mc, 3, 0x20, IO_APIC_ADDR + 0x10000);
40
41         mptable_add_isa_interrupts(mc, bus_isa, 0x2, 0);
42
43         smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW,
44                 0x00, 0x74, 0x02, 0x10);
45         smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW,
46                 0x00, 0x77, 0x02, 0x17);
47         smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW,
48                 0x00, 0x75, 0x02, 0x13);
49         smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW,
50                 0x00, 0x7c, 0x02, 0x12);
51         smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW,
52                 0x00, 0x7d, 0x02, 0x11);
53         smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW,
54                 0x00, 0x7d, 0x02, 0x11);
55         /* Slot 1 function 0 */
56         smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW,
57                 4, 0x04, 0x03, 0x00);
58         /* Slot 2 function 0 */
59         smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW,
60                 4, 0x0c, 0x03, 0x01);
61         /* Slot 3 function 0 */
62         smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW,
63                 bus_6300, 0x20, 0x02, 0x14);
64         /* Slot 4 function 0 */
65         smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW,
66                 bus_6300, 0x08, 0x02, 0x15);
67         /* On board NIC */
68         smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW,
69                 bus_6300, 0x0c, 0x02, 0x16);
70
71         /* Standard local interrupt assignments */
72 //      smp_write_lintsrc(mc, mp_ExtINT, MP_IRQ_TRIGGER_EDGE|MP_IRQ_POLARITY_HIGH,
73 //              bus_isa, 0x00, MP_APIC_ALL, 0x00);
74         smp_write_lintsrc(mc, mp_NMI, MP_IRQ_TRIGGER_EDGE|MP_IRQ_POLARITY_HIGH,
75                 bus_isa, 0x00, MP_APIC_ALL, 0x01);
76
77         /* There is no extension information... */
78
79         /* Compute the checksums */
80         return mptable_finalize(mc);
81 }
82
83 unsigned long write_smp_table(unsigned long addr)
84 {
85         void *v;
86         v = smp_write_floating_table(addr, 0);
87         return (unsigned long)smp_write_config_table(v);
88 }
89