Factor out common mptable code to mptable_init().
[coreboot.git] / src / mainboard / intel / mtarvon / mptable.c
1 /*
2  * This file is part of the coreboot project.
3  *
4  * Copyright (C) 2008 Arastra, Inc.
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 version 2 as
8  * published by the Free Software Foundation.
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 /* This code is based on src/mainboard/intel/jarrell/mptable.c */
21
22 #include <console/console.h>
23 #include <arch/smp/mpspec.h>
24 #include <arch/ioapic.h>
25 #include <device/pci.h>
26 #include <string.h>
27 #include <stdint.h>
28
29 static void *smp_write_config_table(void *v)
30 {
31         struct mp_config_table *mc;
32         u8 bus_isa = 7;
33         u8 bus_pci = 6;
34         u8 bus_pcie_a = 1;
35
36         mc = (void *)(((char *)v) + SMP_FLOATING_TABLE_LEN);
37
38         mptable_init(mc, "Mt. Arvon   ", LAPIC_ADDR);
39
40         smp_write_processors(mc);
41
42         /* Define bus numbers */
43         smp_write_bus(mc, 0, "PCI   ");
44         smp_write_bus(mc, bus_pci, "PCI   ");
45         smp_write_bus(mc, bus_pcie_a, "PCI   ");
46         smp_write_bus(mc, bus_isa, "ISA   ");
47
48         /* IOAPIC handling */
49         smp_write_ioapic(mc, 0x01, 0x20, IO_APIC_ADDR);
50
51         mptable_add_isa_interrupts(mc, bus_isa, 0x1, 0);
52
53         /* Standard local interrupt assignments */
54         smp_write_lintsrc(mc, mp_ExtINT, MP_IRQ_TRIGGER_DEFAULT|MP_IRQ_POLARITY_DEFAULT,
55                 bus_isa, 0x00, MP_APIC_ALL, 0x00);
56         smp_write_lintsrc(mc, mp_NMI, MP_IRQ_TRIGGER_DEFAULT|MP_IRQ_POLARITY_DEFAULT,
57                 bus_isa, 0x00, MP_APIC_ALL, 0x01);
58
59         /* Internal PCI devices */
60         smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW,
61                          0, (0x01<<2)|0, 0x01, 0x10); /* DMA controller */
62         smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW,
63                          0, (0x02<<2)|0, 0x01, 0x10); /* PCIe port A */
64         smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW,
65                          0, (0x03<<2)|0, 0x01, 0x10); /* PCIe port A1 */
66         smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW,
67                          0, (0x1c<<2)|0, 0x01, 0x10); /* PCIe port B0 */
68         smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW,
69                          0, (0x1c<<2)|1, 0x01, 0x11); /* PCIe port B1 */
70         smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW,
71                          0, (0x1c<<2)|2, 0x01, 0x12); /* PCIe port B2 */
72         smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW,
73                          0, (0x1c<<2)|3, 0x01, 0x13); /* PCIe port B3 */
74         smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW,
75                          0, (0x1d<<2)|0, 0x01, 0x10); /* UHCI0/EHCI */
76         smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW,
77                          0, (0x1d<<2)|1, 0x01, 0x11); /* UHCI1 */
78         smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW,
79                          0, (0x1e<<2)|0, 0x01, 0x10); /* Audio */
80         smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW,
81                          0, (0x1e<<2)|1, 0x01, 0x11); /* Modem */
82         smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW,
83                          0, (0x1f<<2)|1, 0x01, 0x11); /* SATA/SMBus */
84         smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW,
85                          0, (0x1f<<2)|3, 0x01, 0x13); /* ? */
86
87         /* PCI slot */
88         smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW,
89                 bus_pci, 0x00, 0x01, 0x10);
90         smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW,
91                 bus_pci, 0x01, 0x01, 0x11);
92         smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW,
93                 bus_pci, 0x02, 0x01, 0x12);
94         smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW,
95                 bus_pci, 0x03, 0x01, 0x13);
96
97         /* PCIe port A slot */
98         smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW,
99                 bus_pcie_a, 0x00, 0x01, 0x10);
100         smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW,
101                 bus_pcie_a, 0x01, 0x01, 0x11);
102         smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW,
103                 bus_pcie_a, 0x02, 0x01, 0x12);
104         smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW,
105                 bus_pcie_a, 0x03, 0x01, 0x13);
106
107         /* There is no extension information... */
108
109         /* Compute the checksums */
110         mc->mpe_checksum = smp_compute_checksum(smp_next_mpc_entry(mc), mc->mpe_length);
111
112         mc->mpc_checksum = smp_compute_checksum(mc, mc->mpc_length);
113         printk(BIOS_DEBUG, "Wrote the mp table end at: %p - %p\n",
114                 mc, smp_next_mpe_entry(mc));
115         return smp_next_mpe_entry(mc);
116 }
117
118 unsigned long write_smp_table(unsigned long addr)
119 {
120         void *v;
121         v = smp_write_floating_table(addr);
122         return (unsigned long)smp_write_config_table(v);
123 }
124