9612a4c26cf5408a8333c9480c3ca271e0b86985
[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, 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         mptable_lintsrc(mc, 0x0);
83 /*
84 MP Config Extended Table Entries:
85
86 --
87 System Address Space
88  bus ID: 0 address type: I/O address
89  address base: 0x9000
90  address range: 0x6000
91 --
92 System Address Space
93  bus ID: 0 address type: I/O address
94  address base: 0x0
95  address range: 0x100
96 --
97 System Address Space
98  bus ID: 0 address type: memory address
99  address base: 0xa0000
100  address range: 0x20000
101 --
102 System Address Space
103  bus ID: 0 address type: memory address
104  address base: 0xfc700000
105  address range: 0x2500000
106 --
107 System Address Space
108  bus ID: 0 address type: prefetch address
109  address base: 0xff600000
110  address range: 0x500000
111 --
112 Bus Heirarchy
113  bus ID: 5 bus info: 0x01 parent bus ID: 0--
114 Compatibility Bus Address
115  bus ID: 0 address modifier: add
116  predefined range: 0x00000000--
117 Compatibility Bus Address
118  bus ID: 0 address modifier: add
119  predefined range: 0x00000001   // There is no extension information...
120 */
121         /* Compute the checksums */
122         return mptable_finalize(mc);
123 }
124
125 unsigned long write_smp_table(unsigned long addr)
126 {
127         void *v;
128         v = smp_write_floating_table(addr, 0);
129         return (unsigned long)smp_write_config_table(v);
130 }