5930d2f43040d0f3c9f3b18d5f0986b2eb4ba9bf
[coreboot.git] / src / mainboard / intel / d945gclf / 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
7  * modify it under the terms of the GNU General Public License as
8  * published by 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 <device/device.h>
21 #include <device/pci.h>
22 #include <console/console.h>
23 #include <arch/smp/mpspec.h>
24 #include <arch/ioapic.h>
25 #include <string.h>
26 #include <stdint.h>
27
28 static void *smp_write_config_table(void *v)
29 {
30         static const char sig[4] = "PCMP";
31         static const char oem[8] = "COREBOOT";
32         static const char productid[12] = "D945GCLF    ";
33         struct mp_config_table *mc;
34         int i;
35         int max_pci_bus, isa_bus;
36
37         mc = (void *)(((char *)v) + SMP_FLOATING_TABLE_LEN);
38         memset(mc, 0, sizeof(*mc));
39
40         memcpy(mc->mpc_signature, sig, sizeof(sig));
41         mc->mpc_length = sizeof(*mc); /* initially just the header */
42         mc->mpc_spec = 0x04;
43         mc->mpc_checksum = 0; /* not yet computed */
44         memcpy(mc->mpc_oem, oem, sizeof(oem));
45         memcpy(mc->mpc_productid, productid, sizeof(productid));
46         mc->mpc_oemptr = 0;
47         mc->mpc_oemsize = 0;
48         mc->mpc_entry_count = 0; /* No entries yet... */
49         mc->mpc_lapic = LAPIC_ADDR;
50         mc->mpe_length = 0;
51         mc->mpe_checksum = 0;
52         mc->reserved = 0;
53
54         smp_write_processors(mc);
55
56         max_pci_bus = 5; // XXX read me from bridges.
57
58         /* ISA bus follows */
59         isa_bus = max_pci_bus + 1;
60
61         /* Bus:         Bus ID  Type */
62         for (i=0; i <= max_pci_bus; i++)
63                 smp_write_bus(mc, i, "PCI   ");
64
65         smp_write_bus(mc, isa_bus, "ISA   ");
66
67         /* I/O APICs:   APIC ID Version State           Address */
68         smp_write_ioapic(mc, 2, 0x20, IO_APIC_ADDR);
69
70         /* Legacy Interrupts */
71
72         mptable_add_isa_interrupts(mc, isa_bus, 0x2, 0);
73
74         /* Builtin devices on Bus 0 */
75         smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x0, 0x8, 0x2, 0x10);
76         smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x0, 0x7d, 0x2, 0x13);
77         smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x0, 0x74, 0x2, 0x17);
78         smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x0, 0x75, 0x2, 0x13);
79         smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x0, 0x76, 0x2, 0x12);
80         smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x0, 0x77, 0x2, 0x10);
81         smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x0, 0x6c, 0x2, 0x10);
82         smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x0, 0x70, 0x2, 0x10);
83         smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x0, 0x71, 0x2, 0x11);
84
85         /* Firewire 4:0.0 */
86         smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x4, 0x0, 0x2, 0x10);
87
88         /* Old riser card */
89         // riser slot top 5:8.0
90         smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x5, 0x20, 0x2, 0x14);
91         // riser slot middle 5:9.0
92         smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x5, 0x24, 0x2, 0x15);
93         // riser slot bottom 5:a.0
94         smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x5, 0x28, 0x2, 0x16);
95
96         /* New Riser Card */
97         smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x5, 0x30, 0x2, 0x14);
98         smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x5, 0x34, 0x2, 0x15);
99         smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x5, 0x38, 0x2, 0x16);
100
101         /* Onboard Ethernet */
102         smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x1, 0x0, 0x2, 0x10);
103
104         /* Local Ints:  Type    Polarity    Trigger     Bus ID   IRQ    APIC ID PIN# */
105         smp_write_intsrc(mc, mp_ExtINT, MP_IRQ_TRIGGER_DEFAULT|MP_IRQ_POLARITY_DEFAULT, isa_bus, 0x0, MP_APIC_ALL, 0x0);
106         smp_write_intsrc(mc, mp_NMI, MP_IRQ_TRIGGER_DEFAULT|MP_IRQ_POLARITY_DEFAULT, isa_bus, 0x0, MP_APIC_ALL, 0x1);
107
108         /* Compute the checksums */
109         mc->mpe_checksum = smp_compute_checksum(smp_next_mpc_entry(mc), mc->mpe_length);
110         mc->mpc_checksum = smp_compute_checksum(mc, mc->mpc_length);
111
112         printk(BIOS_DEBUG, "Wrote the mp table end at: %p - %p\n", mc, smp_next_mpe_entry(mc));
113
114         return smp_next_mpe_entry(mc);
115 }
116
117 unsigned long write_smp_table(unsigned long addr)
118 {
119         void *v;
120         v = smp_write_floating_table(addr);
121         return (unsigned long)smp_write_config_table(v);
122 }