939f21d0ca8192b677ff8d20d8bd8c2f9c6edb30
[coreboot.git] / src / mainboard / via / pc2500e / mptable.c
1 /*
2  * This file is part of the coreboot project.
3  *
4  * Copyright (C) 2007 AMD
5  * (Written by Yinghai Lu <yinghailu@amd.com> for AMD)
6  * Copyright (C) 2007 Philipp Degler <pdegler@rumms.uni-mannheim.de>
7  * (Thanks to LSRA University of Mannheim for their support)
8  * Copyright (C) 2008 Jonathan A. Kollasch <jakllsch@kollasch.net>
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program; if not, write to the Free Software
22  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
23  */
24
25 #include <console/console.h>
26 #include <arch/smp/mpspec.h>
27 #include <arch/ioapic.h>
28 #include <device/pci.h>
29 #include <string.h>
30 #include <stdint.h>
31 #include "southbridge/via/vt8237r/vt8237r.h"
32
33 static void *smp_write_config_table(void *v)
34 {
35         struct mp_config_table *mc;
36         int isa_bus;
37
38         mc = (void *)(((char *)v) + SMP_FLOATING_TABLE_LEN);
39
40         mptable_init(mc, LAPIC_ADDR);
41
42         smp_write_processors(mc);
43         mptable_write_buses(mc, NULL, &isa_bus);
44
45 /* I/O APICs:   APIC ID Version State           Address*/
46         smp_write_ioapic(mc, VT8237R_APIC_ID, 0x20, IO_APIC_ADDR);
47
48         /* Now, assemble the table. */
49         mptable_add_isa_interrupts(mc, isa_bus, VT8237R_APIC_ID, 0);
50
51 #define PCI_INT(bus, dev, fn, pin) \
52         smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, \
53                 bus, (((dev)<<2)|(fn)), VT8237R_APIC_ID, (pin))
54
55         // PCI slot 1
56         PCI_INT(0, 8, 0, 16);
57         PCI_INT(0, 8, 1, 17);
58         PCI_INT(0, 8, 2, 18);
59         PCI_INT(0, 8, 3, 19);
60
61         // PCI slot 2
62         PCI_INT(0, 9, 0, 17);
63         PCI_INT(0, 9, 1, 18);
64         PCI_INT(0, 9, 2, 19);
65         PCI_INT(0, 9, 3, 16);
66
67         // SATA
68         PCI_INT(0, 15, 1, 20);
69
70         // USB
71         PCI_INT(0, 16, 0, 21);
72         PCI_INT(0, 16, 1, 21);
73         PCI_INT(0, 16, 2, 21);
74         PCI_INT(0, 16, 3, 21);
75
76         // Audio
77         PCI_INT(0, 17, 2, 22);
78
79         // Ethernet
80         PCI_INT(0, 18, 0, 23);
81
82         /* Onboard VGA */
83         PCI_INT(1, 0, 0, 16);
84
85 /*Local Ints:   Type    Polarity    Trigger     Bus ID   IRQ    APIC ID PIN#*/
86         mptable_lintsrc(mc, 0);
87
88         /* There is no extension information... */
89
90         /* Compute the checksums */
91         return mptable_finalize(mc);
92 }
93
94 unsigned long write_smp_table(unsigned long addr)
95 {
96         void *v;
97         v = smp_write_floating_table(addr, 0);
98         return (unsigned long)smp_write_config_table(v);
99 }