Since some people disapprove of white space cleanups mixed in regular commits
[coreboot.git] / src / mainboard / tyan / s2735 / mptable.c
1 #include <console/console.h>
2 #include <arch/smp/mpspec.h>
3 #include <device/pci.h>
4 #include <string.h>
5 #include <stdint.h>
6
7 static void *smp_write_config_table(void *v)
8 {
9         static const char sig[4] = "PCMP";
10         static const char oem[8] = "COREBOOT";
11         static const char productid[12] = "S2735       ";
12         struct mp_config_table *mc;
13
14         mc = (void *)(((char *)v) + SMP_FLOATING_TABLE_LEN);
15         memset(mc, 0, sizeof(*mc));
16
17         memcpy(mc->mpc_signature, sig, sizeof(sig));
18         mc->mpc_length = sizeof(*mc); /* initially just the header */
19         mc->mpc_spec = 0x04;
20         mc->mpc_checksum = 0; /* not yet computed */
21         memcpy(mc->mpc_oem, oem, sizeof(oem));
22         memcpy(mc->mpc_productid, productid, sizeof(productid));
23         mc->mpc_oemptr = 0;
24         mc->mpc_oemsize = 0;
25         mc->mpc_entry_count = 0; /* No entries yet... */
26         mc->mpc_lapic = LAPIC_ADDR;
27         mc->mpe_length = 0;
28         mc->mpe_checksum = 0;
29         mc->reserved = 0;
30
31         smp_write_processors(mc);
32
33
34 /*Bus:          Bus ID  Type*/
35         smp_write_bus(mc, 0, "PCI   ");
36         smp_write_bus(mc, 1, "PCI   ");
37         smp_write_bus(mc, 2, "PCI   ");
38         smp_write_bus(mc, 3, "PCI   ");
39         smp_write_bus(mc, 4, "PCI   ");
40         smp_write_bus(mc, 5, "ISA   ");
41 /*I/O APICs:    APIC ID Version State           Address*/
42         smp_write_ioapic(mc, 8, 0x20, 0xfec00000);
43         {
44                 device_t dev;
45                 struct resource *res;
46                 dev = dev_find_slot(1, PCI_DEVFN(0x1e,0));
47                 if (dev) {
48                         res = find_resource(dev, PCI_BASE_ADDRESS_0);
49                         if (res) {
50                                 smp_write_ioapic(mc, 0x09, 0x20, res->base);
51                         }
52                 }
53                 dev = dev_find_slot(1, PCI_DEVFN(0x1c,0));
54                 if (dev) {
55                         res = find_resource(dev, PCI_BASE_ADDRESS_0);
56                         if (res) {
57                                 smp_write_ioapic(mc, 0x0a, 0x20, res->base);
58                         }
59                 }
60         }
61 /*I/O Ints:     Type    Polarity    Trigger     Bus ID   IRQ    APIC ID PIN#
62 */
63         smp_write_intsrc(mc, mp_ExtINT, MP_IRQ_TRIGGER_EDGE|MP_IRQ_POLARITY_HIGH, 0x5, 0x0, 0x8, 0x0);
64         smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_EDGE|MP_IRQ_POLARITY_HIGH, 0x5, 0x1, 0x8, 0x1);
65         smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_EDGE|MP_IRQ_POLARITY_HIGH, 0x5, 0x0, 0x8, 0x2);
66         smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_EDGE|MP_IRQ_POLARITY_HIGH, 0x5, 0x3, 0x8, 0x3);
67         smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_EDGE|MP_IRQ_POLARITY_HIGH, 0x5, 0x4, 0x8, 0x4);
68         smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_EDGE|MP_IRQ_POLARITY_HIGH, 0x5, 0x6, 0x8, 0x6);
69         smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_EDGE|MP_IRQ_POLARITY_HIGH, 0x5, 0x8, 0x8, 0x8);
70         smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_EDGE|MP_IRQ_POLARITY_HIGH, 0x5, 0x9, 0x8, 0x9);
71         smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_EDGE|MP_IRQ_POLARITY_HIGH, 0x5, 0xc, 0x8, 0xc);
72         smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_EDGE|MP_IRQ_POLARITY_HIGH, 0x5, 0xd, 0x8, 0xd);
73         smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_EDGE|MP_IRQ_POLARITY_HIGH, 0x5, 0xe, 0x8, 0xe);
74         smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_EDGE|MP_IRQ_POLARITY_HIGH, 0x5, 0xf, 0x8, 0xf);
75 //USB
76         smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x0, 0x7c, 0x8, 0x12);
77         smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x0, 0x7d, 0x8, 0x11);
78         smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x0, 0x74, 0x8, 0x10);
79         smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x0, 0x75, 0x8, 0x13);
80         smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x0, 0x77, 0x8, 0x17);
81
82 //onboard ati
83         smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x4, 0x8, 0x8, 0x12);
84
85 //onboard intel 82551 10/100
86         smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x4, 0x4, 0x8, 0x11);
87
88 // onboard Intel 82547 1000
89         smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x2, 0x4, 0xa, 0x0);
90         smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x2, 0x5, 0xa, 0x1);
91
92 //Slot 4
93         smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x4, (0x3<<2)|0, 0x8, 0x12);
94         smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x4, (0x3<<2)|1, 0x8, 0x13);
95         smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x4, (0x3<<2)|2, 0x8, 0x10);
96         smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x4, (0x3<<2)|3, 0x8, 0x11);
97 //Slot 3
98         smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x4, (0x4<<2)|0, 0x8, 0x13);
99         smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x4, (0x4<<2)|1, 0x8, 0x10);
100         smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x4, (0x4<<2)|2, 0x8, 0x11);
101         smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x4, (0x4<<2)|3, 0x8, 0x12);
102 //Slot 1
103         smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x3, (0x3<<2)|0, 0x9, 0x0);
104         smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x3, (0x3<<2)|1, 0x9, 0x1);
105         smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x3, (0x3<<2)|2, 0x9, 0x2);
106         smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x3, (0x3<<2)|3, 0x9, 0x3);
107 //Slot 2
108         smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x3, (0x6<<2)|0, 0x9, 0x4);
109         smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x3, (0x6<<2)|1, 0x9, 0x5);
110         smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x3, (0x6<<2)|2, 0x9, 0x6);
111         smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x3, (0x6<<2)|3, 0x9, 0x7);
112
113 /*Local Ints:   Type    Polarity    Trigger     Bus ID   IRQ    APIC ID PIN#*/
114         smp_write_intsrc(mc, mp_ExtINT, MP_IRQ_TRIGGER_EDGE|MP_IRQ_POLARITY_HIGH, 0x0, 0x0, MP_APIC_ALL, 0x0);
115         smp_write_intsrc(mc, mp_NMI, MP_IRQ_TRIGGER_EDGE|MP_IRQ_POLARITY_HIGH, 0x0, 0x0, MP_APIC_ALL, 0x1);
116 /*
117 MP Config Extended Table Entries:
118
119 --
120 System Address Space
121  bus ID: 0 address type: I/O address
122  address base: 0x9000
123  address range: 0x6000
124 --
125 System Address Space
126  bus ID: 0 address type: I/O address
127  address base: 0x0
128  address range: 0x100
129 --
130 System Address Space
131  bus ID: 0 address type: memory address
132  address base: 0xa0000
133  address range: 0x20000
134 --
135 System Address Space
136  bus ID: 0 address type: memory address
137  address base: 0xfc700000
138  address range: 0x2500000
139 --
140 System Address Space
141  bus ID: 0 address type: prefetch address
142  address base: 0xff600000
143  address range: 0x500000
144 --
145 Bus Heirarchy
146  bus ID: 5 bus info: 0x01 parent bus ID: 0--
147 Compatibility Bus Address
148  bus ID: 0 address modifier: add
149  predefined range: 0x00000000--
150 Compatibility Bus Address
151  bus ID: 0 address modifier: add
152  predefined range: 0x00000001   // There is no extension information...
153 */
154         /* Compute the checksums */
155         mc->mpe_checksum = smp_compute_checksum(smp_next_mpc_entry(mc), mc->mpe_length);
156         mc->mpc_checksum = smp_compute_checksum(mc, mc->mpc_length);
157         printk(BIOS_DEBUG, "Wrote the mp table end at: %p - %p\n",
158                 mc, smp_next_mpe_entry(mc));
159         return smp_next_mpe_entry(mc);
160 }
161
162 unsigned long write_smp_table(unsigned long addr)
163 {
164         void *v;
165         v = smp_write_floating_table(addr);
166         return (unsigned long)smp_write_config_table(v);
167 }