Unify Local APIC address definitions
[coreboot.git] / src / mainboard / iwave / iWRainbowG6 / mptable.c
1 /*
2  * This file is part of the coreboot project.
3  *
4  * Copyright (C) 2007-2008 coresystems GmbH
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; version 2 of the License.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18  */
19
20 #include <console/console.h>
21 #include <arch/smp/mpspec.h>
22 #include <device/pci.h>
23 #include <string.h>
24 #include <stdint.h>
25
26 void *smp_write_config_table(void *v)
27 {
28         struct mp_config_table *mc;
29         int isa_bus;
30
31         mc = (void *)(((char *)v) + SMP_FLOATING_TABLE_LEN);
32         mptable_init(mc, LOCAL_APIC_ADDR);
33
34         smp_write_processors(mc);
35         mptable_write_buses(mc, NULL, &isa_bus);
36
37         smp_write_ioapic(mc, 2, 0x20, 0xfec00000);
38         {
39                 device_t dev;
40                 struct resource *res;
41                 dev = dev_find_slot(1, PCI_DEVFN(0x1e,0));
42                 if (dev) {
43                         res = find_resource(dev, PCI_BASE_ADDRESS_0);
44                         if (res) {
45                                 smp_write_ioapic(mc, 3, 0x20, res->base);
46                         }
47                 }
48                 dev = dev_find_slot(1, PCI_DEVFN(0x1c,0));
49                 if (dev) {
50                         res = find_resource(dev, PCI_BASE_ADDRESS_0);
51                         if (res) {
52                                 smp_write_ioapic(mc, 4, 0x20, res->base);
53                         }
54                 }
55                 dev = dev_find_slot(4, PCI_DEVFN(0x1e,0));
56                 if (dev) {
57                         res = find_resource(dev, PCI_BASE_ADDRESS_0);
58                         if (res) {
59                                 smp_write_ioapic(mc, 5, 0x20, res->base);
60                         }
61                 }
62                 dev = dev_find_slot(4, PCI_DEVFN(0x1c,0));
63                 if (dev) {
64                         res = find_resource(dev, PCI_BASE_ADDRESS_0);
65                         if (res) {
66                                 smp_write_ioapic(mc, 8, 0x20, res->base);
67                         }
68                 }
69         }
70 /*I/O Ints:     Type    Polarity    Trigger     Bus ID   IRQ    APIC ID PIN#
71 */      smp_write_intsrc(mc, mp_ExtINT, MP_IRQ_TRIGGER_EDGE|MP_IRQ_POLARITY_DEFAULT, 0x1, 0x0, 0x1, 0x0);
72         smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_DEFAULT|MP_IRQ_POLARITY_DEFAULT, 0x1, 0x1, 0x1, 0x1);
73         smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_DEFAULT|MP_IRQ_POLARITY_DEFAULT, 0x1, 0x0, 0x1, 0x2);
74         smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_DEFAULT|MP_IRQ_POLARITY_DEFAULT, 0x1, 0x3, 0x1, 0x3);
75         smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_DEFAULT|MP_IRQ_POLARITY_DEFAULT, 0x1, 0x4, 0x1, 0x4);
76         smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_DEFAULT|MP_IRQ_POLARITY_DEFAULT, 0x1, 0x6, 0x1, 0x6);
77         smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_DEFAULT|MP_IRQ_POLARITY_DEFAULT, 0x1, 0x7, 0x1, 0x7);
78         smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_EDGE|MP_IRQ_POLARITY_HIGH, 0x1, 0x8, 0x1, 0x8);
79         smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_DEFAULT|MP_IRQ_POLARITY_DEFAULT, 0x1, 0x9, 0x1, 0x9);
80         smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_DEFAULT|MP_IRQ_POLARITY_DEFAULT, 0x1, 0xc, 0x1, 0xc);
81         smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_DEFAULT|MP_IRQ_POLARITY_DEFAULT, 0x1, 0xd, 0x1, 0xd);
82         smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_DEFAULT|MP_IRQ_POLARITY_DEFAULT, 0x1, 0xe, 0x1, 0xe);
83         smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x0, 0x8, 0x1, 0x10);
84         smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x0, 0x74, 0x1, 0x10);
85         smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x0, 0x75, 0x1, 0x11);
86         smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x0, 0x76, 0x1, 0x12);
87         smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x0, 0x77, 0x1, 0x13);
88         smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x0, 0x6c, 0x1, 0x10);
89         smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x0, 0x78, 0x1, 0x10);
90         smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x0, 0x79, 0x1, 0x11);
91         smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x0, 0x7a, 0x1, 0x12);
92 /*Local Ints:   Type    Polarity    Trigger     Bus ID   IRQ    APIC ID PIN#*/
93         mptable_lintsrc(mc, isa_bus);
94         /* There is no extension information... */
95
96         /* Compute the checksums */
97         return mptable_finalize(mc);
98 }
99
100 unsigned long write_smp_table(unsigned long addr)
101 {
102         void *v;
103         v = smp_write_floating_table(addr, 0);
104         return (unsigned long)smp_write_config_table(v);
105 }