Factor out common mptable code to mptable_init().
[coreboot.git] / src / mainboard / tyan / s2735 / 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 isa_bus;
12
13         mc = (void *)(((char *)v) + SMP_FLOATING_TABLE_LEN);
14
15         mptable_init(mc, "S2735       ", LAPIC_ADDR);
16
17         smp_write_processors(mc);
18         mptable_write_buses(mc, NULL, &isa_bus);
19 /*I/O APICs:    APIC ID Version State           Address*/
20         smp_write_ioapic(mc, 8, 0x20, IO_APIC_ADDR);
21         {
22                 device_t dev;
23                 struct resource *res;
24                 dev = dev_find_slot(1, PCI_DEVFN(0x1e,0));
25                 if (dev) {
26                         res = find_resource(dev, PCI_BASE_ADDRESS_0);
27                         if (res) {
28                                 smp_write_ioapic(mc, 0x09, 0x20, res->base);
29                         }
30                 }
31                 dev = dev_find_slot(1, PCI_DEVFN(0x1c,0));
32                 if (dev) {
33                         res = find_resource(dev, PCI_BASE_ADDRESS_0);
34                         if (res) {
35                                 smp_write_ioapic(mc, 0x0a, 0x20, res->base);
36                         }
37                 }
38         }
39         mptable_add_isa_interrupts(mc, isa_bus, 0x8, 0);
40
41 /*I/O Ints:     Type    Polarity    Trigger     Bus ID   IRQ    APIC ID PIN#
42 */
43 //USB
44         smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x0, 0x7c, 0x8, 0x12);
45         smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x0, 0x7d, 0x8, 0x11);
46         smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x0, 0x74, 0x8, 0x10);
47         smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x0, 0x75, 0x8, 0x13);
48         smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x0, 0x77, 0x8, 0x17);
49
50 //onboard ati
51         smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x4, 0x8, 0x8, 0x12);
52
53 //onboard intel 82551 10/100
54         smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x4, 0x4, 0x8, 0x11);
55
56 // onboard Intel 82547 1000
57         smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x2, 0x4, 0xa, 0x0);
58         smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x2, 0x5, 0xa, 0x1);
59
60 //Slot 4
61         smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x4, (0x3<<2)|0, 0x8, 0x12);
62         smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x4, (0x3<<2)|1, 0x8, 0x13);
63         smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x4, (0x3<<2)|2, 0x8, 0x10);
64         smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x4, (0x3<<2)|3, 0x8, 0x11);
65 //Slot 3
66         smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x4, (0x4<<2)|0, 0x8, 0x13);
67         smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x4, (0x4<<2)|1, 0x8, 0x10);
68         smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x4, (0x4<<2)|2, 0x8, 0x11);
69         smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x4, (0x4<<2)|3, 0x8, 0x12);
70 //Slot 1
71         smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x3, (0x3<<2)|0, 0x9, 0x0);
72         smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x3, (0x3<<2)|1, 0x9, 0x1);
73         smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x3, (0x3<<2)|2, 0x9, 0x2);
74         smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x3, (0x3<<2)|3, 0x9, 0x3);
75 //Slot 2
76         smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x3, (0x6<<2)|0, 0x9, 0x4);
77         smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x3, (0x6<<2)|1, 0x9, 0x5);
78         smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x3, (0x6<<2)|2, 0x9, 0x6);
79         smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x3, (0x6<<2)|3, 0x9, 0x7);
80
81 /*Local Ints:   Type    Polarity    Trigger     Bus ID   IRQ    APIC ID PIN#*/
82         smp_write_intsrc(mc, mp_ExtINT, MP_IRQ_TRIGGER_EDGE|MP_IRQ_POLARITY_HIGH, 0x0, 0x0, MP_APIC_ALL, 0x0);
83         smp_write_intsrc(mc, mp_NMI, MP_IRQ_TRIGGER_EDGE|MP_IRQ_POLARITY_HIGH, 0x0, 0x0, MP_APIC_ALL, 0x1);
84 /*
85 MP Config Extended Table Entries:
86
87 --
88 System Address Space
89  bus ID: 0 address type: I/O address
90  address base: 0x9000
91  address range: 0x6000
92 --
93 System Address Space
94  bus ID: 0 address type: I/O address
95  address base: 0x0
96  address range: 0x100
97 --
98 System Address Space
99  bus ID: 0 address type: memory address
100  address base: 0xa0000
101  address range: 0x20000
102 --
103 System Address Space
104  bus ID: 0 address type: memory address
105  address base: 0xfc700000
106  address range: 0x2500000
107 --
108 System Address Space
109  bus ID: 0 address type: prefetch address
110  address base: 0xff600000
111  address range: 0x500000
112 --
113 Bus Heirarchy
114  bus ID: 5 bus info: 0x01 parent bus ID: 0--
115 Compatibility Bus Address
116  bus ID: 0 address modifier: add
117  predefined range: 0x00000000--
118 Compatibility Bus Address
119  bus ID: 0 address modifier: add
120  predefined range: 0x00000001   // There is no extension information...
121 */
122         /* Compute the checksums */
123         mc->mpe_checksum = smp_compute_checksum(smp_next_mpc_entry(mc), mc->mpe_length);
124         mc->mpc_checksum = smp_compute_checksum(mc, mc->mpc_length);
125         printk(BIOS_DEBUG, "Wrote the mp table end at: %p - %p\n",
126                 mc, smp_next_mpe_entry(mc));
127         return smp_next_mpe_entry(mc);
128 }
129
130 unsigned long write_smp_table(unsigned long addr)
131 {
132         void *v;
133         v = smp_write_floating_table(addr);
134         return (unsigned long)smp_write_config_table(v);
135 }