blob: 87b40dd525178fb9475544000dbf29276f56504b [file] [log] [blame]
Ed Swierkb8e53eb2008-10-13 23:18:56 +00001/*
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
Paul Menzela46a7122013-02-23 18:37:27 +010017 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Ed Swierkb8e53eb2008-10-13 23:18:56 +000018 */
19
20#include <console/console.h>
21#include <arch/smp/mpspec.h>
Uwe Hermann74d1a6e2010-10-12 17:34:08 +000022#include <arch/ioapic.h>
Ed Swierkb8e53eb2008-10-13 23:18:56 +000023#include <device/pci.h>
24#include <string.h>
25#include <stdint.h>
26
Myles Watson08e0fb82010-03-22 16:33:25 +000027static void *smp_write_config_table(void *v)
Ed Swierkb8e53eb2008-10-13 23:18:56 +000028{
Ed Swierkb8e53eb2008-10-13 23:18:56 +000029 struct mp_config_table *mc;
Patrick Georgi7411eab2010-11-22 14:14:56 +000030 int bus_isa;
Ed Swierkb8e53eb2008-10-13 23:18:56 +000031 u8 bus_pea0 = 0;
32 u8 bus_pea1 = 0;
33 u8 bus_aioc;
34 device_t dev;
35
36 mc = (void *)(((char *)v) + SMP_FLOATING_TABLE_LEN);
Ed Swierkb8e53eb2008-10-13 23:18:56 +000037
Patrick Georgic8feedd2012-02-16 18:43:25 +010038 mptable_init(mc, LOCAL_APIC_ADDR);
Ed Swierkb8e53eb2008-10-13 23:18:56 +000039
40 smp_write_processors(mc);
41
Ed Swierkb8e53eb2008-10-13 23:18:56 +000042 /* AIOC bridge */
43 dev = dev_find_slot(0, PCI_DEVFN(0x04,0));
44 if (dev) {
45 bus_aioc = pci_read_config8(dev, PCI_SECONDARY_BUS);
Ed Swierkb8e53eb2008-10-13 23:18:56 +000046 }
47 else {
Stefan Reinauerc02b4fc2010-03-22 11:42:32 +000048 printk(BIOS_DEBUG, "ERROR - could not find PCI 0:04.0\n");
Ed Swierkb8e53eb2008-10-13 23:18:56 +000049 bus_aioc = 0;
Ed Swierkb8e53eb2008-10-13 23:18:56 +000050 }
51 /* PCIe A0 */
52 dev = dev_find_slot(0, PCI_DEVFN(0x02,0));
53 if (dev) {
54 bus_pea0 = pci_read_config8(dev, PCI_SECONDARY_BUS);
55 }
56 else {
Stefan Reinauerc02b4fc2010-03-22 11:42:32 +000057 printk(BIOS_DEBUG, "ERROR - could not find PCI 0:02.0\n");
Ed Swierkb8e53eb2008-10-13 23:18:56 +000058 bus_pea0 = 0;
59 }
60 /* PCIe A1 */
61 dev = dev_find_slot(0, PCI_DEVFN(0x03,0));
62 if (dev) {
63 bus_pea1 = pci_read_config8(dev, PCI_SECONDARY_BUS);
64 }
65 else {
Stefan Reinauerc02b4fc2010-03-22 11:42:32 +000066 printk(BIOS_DEBUG, "ERROR - could not find PCI 0:03.0\n");
Ed Swierkb8e53eb2008-10-13 23:18:56 +000067 bus_pea1 = 0;
68 }
69
Patrick Georgi7411eab2010-11-22 14:14:56 +000070 mptable_write_buses(mc, NULL, &bus_isa);
Ed Swierkb8e53eb2008-10-13 23:18:56 +000071
72 /* IOAPIC handling */
Kevin Paul Herbertbde6d302014-12-24 18:43:20 -080073 smp_write_ioapic(mc, 0x8, 0x20, VIO_APIC_VADDR);
Ed Swierkb8e53eb2008-10-13 23:18:56 +000074
Patrick Georgic5b87c82010-05-20 15:28:19 +000075 mptable_add_isa_interrupts(mc, bus_isa, 0x8, 0);
Ed Swierkb8e53eb2008-10-13 23:18:56 +000076
77 /* Standard local interrupt assignments */
Patrick Georgi6eb7a532011-10-07 21:42:52 +020078 mptable_lintsrc(mc, bus_isa);
Ed Swierkb8e53eb2008-10-13 23:18:56 +000079
80 /* IMCH/IICH PCI devices */
81 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW,
82 0, (0x01<<2)|0, 0x8, 0x10); /* DMA controller */
83 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW,
84 0, (0x02<<2)|0, 0x8, 0x10); /* PCIe port A bridge */
85 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW,
86 0, (0x03<<2)|0, 0x8, 0x10); /* PCIe port A1 bridge */
87 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW,
88 0, (0x04<<2)|0, 0x8, 0x10); /* AIOC PCI bridge */
89 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW,
90 0, (0x1d<<2)|0, 0x8, 0x10); /* UHCI/EHCI */
91 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW,
92 0, (0x1f<<2)|1, 0x8, 0x11); /* SATA/SMBus */
93
94 if (bus_pea0) {
95 /* PCIe slot 0 */
96 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_DEFAULT|MP_IRQ_POLARITY_DEFAULT,
97 bus_pea0, (0<<2)|0, 0x8, 0x10);
98 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_DEFAULT|MP_IRQ_POLARITY_DEFAULT,
99 bus_pea0, (0<<2)|1, 0x8, 0x11);
100 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_DEFAULT|MP_IRQ_POLARITY_DEFAULT,
101 bus_pea0, (0<<2)|2, 0x8, 0x12);
102 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_DEFAULT|MP_IRQ_POLARITY_DEFAULT,
103 bus_pea0, (0<<2)|3, 0x8, 0x13);
104 }
105
106 if (bus_pea1) {
107 /* PCIe slots 1-4 */
108 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_DEFAULT|MP_IRQ_POLARITY_DEFAULT,
109 bus_pea1, (0<<2)|0, 0x8, 0x10);
110 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_DEFAULT|MP_IRQ_POLARITY_DEFAULT,
111 bus_pea1, (0<<2)|1, 0x8, 0x11);
112 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_DEFAULT|MP_IRQ_POLARITY_DEFAULT,
113 bus_pea1, (0<<2)|2, 0x8, 0x12);
114 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_DEFAULT|MP_IRQ_POLARITY_DEFAULT,
115 bus_pea1, (0<<2)|3, 0x8, 0x13);
116 }
117
118 if (bus_aioc) {
119 /* AIOC PCI devices */
120 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_DEFAULT|MP_IRQ_POLARITY_DEFAULT,
121 bus_aioc, (0<<2)|0, 0x8, 0x10); /* GbE0 */
122 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_DEFAULT|MP_IRQ_POLARITY_DEFAULT,
123 bus_aioc, (1<<2)|0, 0x8, 0x11); /* GbE1 */
124 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_DEFAULT|MP_IRQ_POLARITY_DEFAULT,
125 bus_aioc, (2<<2)|0, 0x8, 0x12); /* GbE2 */
126 }
127
128 /* There is no extension information... */
129
130 /* Compute the checksums */
Patrick Georgib0a9c5c2011-10-07 23:01:55 +0200131 return mptable_finalize(mc);
Ed Swierkb8e53eb2008-10-13 23:18:56 +0000132}
133
134unsigned long write_smp_table(unsigned long addr)
135{
136 void *v;
Patrick Georgic75c79b2011-10-07 22:41:07 +0200137 v = smp_write_floating_table(addr, 0);
Ed Swierkb8e53eb2008-10-13 23:18:56 +0000138 return (unsigned long)smp_write_config_table(v);
139}