Add VIA CX700 support, plus VIA vt8454c reference board support.
[coreboot.git] / src / mainboard / via / vt8454c / mptable.c
1 /*
2  * This file is part of the coreboot project.
3  *
4  * Copyright (C) 2007-2009 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
9  * the License.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
19  * MA 02110-1301 USA
20  */
21
22 #include <device/device.h>
23 #include <device/pci.h>
24 #include <arch/smp/mpspec.h>
25 #include <cpu/x86/lapic.h>
26 #include <console/console.h>
27 #include <string.h>
28 #include <stdint.h>
29
30 void *smp_write_config_table(void *v)
31 {
32         static const char sig[4] = MPC_SIGNATURE;
33         static const char oem[8] = "COREBOOT";
34         static const char productid[12] = "VIA VT8454C ";
35         struct mp_config_table *mc;
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         /*Bus:          Bus ID  Type */
57         smp_write_bus(mc, 0, "PCI   ");
58         smp_write_bus(mc, 1, "PCI   ");
59         smp_write_bus(mc, 2, "PCI   ");
60         smp_write_bus(mc, 128, "PCI   ");
61         smp_write_bus(mc, 129, "ISA   ");
62
63         /* I/O APICs:   APIC ID Version State Address */
64         smp_write_ioapic(mc, 2, 17, 0xfec00000);
65
66         /* I/O Ints:    Type    Polarity    Trigger     Bus ID   IRQ    APIC ID PIN# */
67         smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL | MP_IRQ_POLARITY_LOW, 0x0, 0x40, 0x2, 0x14);
68         smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL | MP_IRQ_POLARITY_LOW, 0x0, 0x41, 0x2, 0x16);
69         smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL | MP_IRQ_POLARITY_LOW, 0x0, 0x42, 0x2, 0x15);
70         smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL | MP_IRQ_POLARITY_LOW, 0x0, 0x43, 0x2, 0x17);
71         smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL | MP_IRQ_POLARITY_LOW, 0x80, 0x4, 0x2, 0x11);
72         smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL | MP_IRQ_POLARITY_LOW, 0x1, 0x0, 0x2, 0x11);
73         smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL | MP_IRQ_POLARITY_LOW, 0x2, 0x10, 0x2, 0x11);
74         smp_write_intsrc(mc, mp_ExtINT, MP_IRQ_TRIGGER_DEFAULT | MP_IRQ_POLARITY_DEFAULT, 0x81, 0x0, 0x2, 0x0);
75         smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_DEFAULT | MP_IRQ_POLARITY_DEFAULT, 0x81, 0x1, 0x2, 0x1);
76         smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_DEFAULT | MP_IRQ_POLARITY_DEFAULT, 0x81, 0x0, 0x2, 0x2);
77         smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_DEFAULT | MP_IRQ_POLARITY_DEFAULT, 0x81, 0x3, 0x2, 0x3);
78         smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_DEFAULT | MP_IRQ_POLARITY_DEFAULT, 0x81, 0x4, 0x2, 0x4);
79         smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_DEFAULT | MP_IRQ_POLARITY_DEFAULT, 0x81, 0x6, 0x2, 0x6);
80         smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_DEFAULT | MP_IRQ_POLARITY_DEFAULT, 0x81, 0x7, 0x2, 0x7);
81         smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_EDGE | MP_IRQ_POLARITY_HIGH, 0x81, 0x8, 0x2, 0x8);
82         smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_DEFAULT | MP_IRQ_POLARITY_DEFAULT, 0x81, 0x9, 0x2, 0x9);
83         smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_DEFAULT | MP_IRQ_POLARITY_DEFAULT, 0x81, 0xc, 0x2, 0xc);
84         smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_DEFAULT | MP_IRQ_POLARITY_DEFAULT, 0x81, 0xd, 0x2, 0xd);
85         smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_DEFAULT | MP_IRQ_POLARITY_DEFAULT, 0x81, 0xe, 0x2, 0xe);
86         smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_DEFAULT | MP_IRQ_POLARITY_DEFAULT, 0x81, 0xf, 0x2, 0xf);
87
88         /*Local Ints:   Type    Polarity    Trigger     Bus ID   IRQ    APIC ID PIN# */
89         smp_write_intsrc(mc, mp_ExtINT, MP_IRQ_TRIGGER_DEFAULT | MP_IRQ_POLARITY_DEFAULT, 0x0, 0x0, MP_APIC_ALL, 0x0);
90         smp_write_intsrc(mc, mp_NMI, MP_IRQ_TRIGGER_DEFAULT | MP_IRQ_POLARITY_DEFAULT, 0x0, 0x0, MP_APIC_ALL, 0x1);
91
92         /* Compute the checksums */
93         mc->mpe_checksum = smp_compute_checksum(smp_next_mpc_entry(mc), mc->mpe_length);
94         mc->mpc_checksum = smp_compute_checksum(mc, mc->mpc_length);
95         printk_debug("Wrote the mp table end at: %p - %p\n", mc, smp_next_mpe_entry(mc));
96         return smp_next_mpe_entry(mc);
97 }
98
99 unsigned long write_smp_table(unsigned long addr)
100 {
101         void *v;
102         v = smp_write_floating_table(addr);
103         return (unsigned long)smp_write_config_table(v);
104 }