blob: f6cf1cfc097fa6d57fbbcab0770de519736002ef [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.
Ed Swierkb8e53eb2008-10-13 23:18:56 +000014 */
15
16#include <console/console.h>
17#include <arch/smp/mpspec.h>
Uwe Hermann74d1a6e2010-10-12 17:34:08 +000018#include <arch/ioapic.h>
Ed Swierkb8e53eb2008-10-13 23:18:56 +000019#include <device/pci.h>
20#include <string.h>
21#include <stdint.h>
22
Myles Watson08e0fb82010-03-22 16:33:25 +000023static void *smp_write_config_table(void *v)
Ed Swierkb8e53eb2008-10-13 23:18:56 +000024{
Ed Swierkb8e53eb2008-10-13 23:18:56 +000025 struct mp_config_table *mc;
Patrick Georgi7411eab2010-11-22 14:14:56 +000026 int bus_isa;
Ed Swierkb8e53eb2008-10-13 23:18:56 +000027 u8 bus_pea0 = 0;
28 u8 bus_pea1 = 0;
29 u8 bus_aioc;
30 device_t dev;
31
32 mc = (void *)(((char *)v) + SMP_FLOATING_TABLE_LEN);
Ed Swierkb8e53eb2008-10-13 23:18:56 +000033
Patrick Georgic8feedd2012-02-16 18:43:25 +010034 mptable_init(mc, LOCAL_APIC_ADDR);
Ed Swierkb8e53eb2008-10-13 23:18:56 +000035
36 smp_write_processors(mc);
37
Ed Swierkb8e53eb2008-10-13 23:18:56 +000038 /* AIOC bridge */
39 dev = dev_find_slot(0, PCI_DEVFN(0x04,0));
40 if (dev) {
41 bus_aioc = pci_read_config8(dev, PCI_SECONDARY_BUS);
Ed Swierkb8e53eb2008-10-13 23:18:56 +000042 }
43 else {
Stefan Reinauerc02b4fc2010-03-22 11:42:32 +000044 printk(BIOS_DEBUG, "ERROR - could not find PCI 0:04.0\n");
Ed Swierkb8e53eb2008-10-13 23:18:56 +000045 bus_aioc = 0;
Ed Swierkb8e53eb2008-10-13 23:18:56 +000046 }
47 /* PCIe A0 */
48 dev = dev_find_slot(0, PCI_DEVFN(0x02,0));
49 if (dev) {
50 bus_pea0 = pci_read_config8(dev, PCI_SECONDARY_BUS);
51 }
52 else {
Stefan Reinauerc02b4fc2010-03-22 11:42:32 +000053 printk(BIOS_DEBUG, "ERROR - could not find PCI 0:02.0\n");
Ed Swierkb8e53eb2008-10-13 23:18:56 +000054 bus_pea0 = 0;
55 }
56 /* PCIe A1 */
57 dev = dev_find_slot(0, PCI_DEVFN(0x03,0));
58 if (dev) {
59 bus_pea1 = pci_read_config8(dev, PCI_SECONDARY_BUS);
60 }
61 else {
Stefan Reinauerc02b4fc2010-03-22 11:42:32 +000062 printk(BIOS_DEBUG, "ERROR - could not find PCI 0:03.0\n");
Ed Swierkb8e53eb2008-10-13 23:18:56 +000063 bus_pea1 = 0;
64 }
65
Patrick Georgi7411eab2010-11-22 14:14:56 +000066 mptable_write_buses(mc, NULL, &bus_isa);
Ed Swierkb8e53eb2008-10-13 23:18:56 +000067
68 /* IOAPIC handling */
Kevin Paul Herbertbde6d302014-12-24 18:43:20 -080069 smp_write_ioapic(mc, 0x8, 0x20, VIO_APIC_VADDR);
Ed Swierkb8e53eb2008-10-13 23:18:56 +000070
Patrick Georgic5b87c82010-05-20 15:28:19 +000071 mptable_add_isa_interrupts(mc, bus_isa, 0x8, 0);
Ed Swierkb8e53eb2008-10-13 23:18:56 +000072
73 /* Standard local interrupt assignments */
Patrick Georgi6eb7a532011-10-07 21:42:52 +020074 mptable_lintsrc(mc, bus_isa);
Ed Swierkb8e53eb2008-10-13 23:18:56 +000075
76 /* IMCH/IICH PCI devices */
77 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW,
78 0, (0x01<<2)|0, 0x8, 0x10); /* DMA controller */
79 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW,
80 0, (0x02<<2)|0, 0x8, 0x10); /* PCIe port A bridge */
81 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW,
82 0, (0x03<<2)|0, 0x8, 0x10); /* PCIe port A1 bridge */
83 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW,
84 0, (0x04<<2)|0, 0x8, 0x10); /* AIOC PCI bridge */
85 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW,
86 0, (0x1d<<2)|0, 0x8, 0x10); /* UHCI/EHCI */
87 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW,
88 0, (0x1f<<2)|1, 0x8, 0x11); /* SATA/SMBus */
89
90 if (bus_pea0) {
91 /* PCIe slot 0 */
92 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_DEFAULT|MP_IRQ_POLARITY_DEFAULT,
93 bus_pea0, (0<<2)|0, 0x8, 0x10);
94 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_DEFAULT|MP_IRQ_POLARITY_DEFAULT,
95 bus_pea0, (0<<2)|1, 0x8, 0x11);
96 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_DEFAULT|MP_IRQ_POLARITY_DEFAULT,
97 bus_pea0, (0<<2)|2, 0x8, 0x12);
98 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_DEFAULT|MP_IRQ_POLARITY_DEFAULT,
99 bus_pea0, (0<<2)|3, 0x8, 0x13);
100 }
101
102 if (bus_pea1) {
103 /* PCIe slots 1-4 */
104 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_DEFAULT|MP_IRQ_POLARITY_DEFAULT,
105 bus_pea1, (0<<2)|0, 0x8, 0x10);
106 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_DEFAULT|MP_IRQ_POLARITY_DEFAULT,
107 bus_pea1, (0<<2)|1, 0x8, 0x11);
108 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_DEFAULT|MP_IRQ_POLARITY_DEFAULT,
109 bus_pea1, (0<<2)|2, 0x8, 0x12);
110 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_DEFAULT|MP_IRQ_POLARITY_DEFAULT,
111 bus_pea1, (0<<2)|3, 0x8, 0x13);
112 }
113
114 if (bus_aioc) {
115 /* AIOC PCI devices */
116 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_DEFAULT|MP_IRQ_POLARITY_DEFAULT,
117 bus_aioc, (0<<2)|0, 0x8, 0x10); /* GbE0 */
118 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_DEFAULT|MP_IRQ_POLARITY_DEFAULT,
119 bus_aioc, (1<<2)|0, 0x8, 0x11); /* GbE1 */
120 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_DEFAULT|MP_IRQ_POLARITY_DEFAULT,
121 bus_aioc, (2<<2)|0, 0x8, 0x12); /* GbE2 */
122 }
123
124 /* There is no extension information... */
125
126 /* Compute the checksums */
Patrick Georgib0a9c5c2011-10-07 23:01:55 +0200127 return mptable_finalize(mc);
Ed Swierkb8e53eb2008-10-13 23:18:56 +0000128}
129
130unsigned long write_smp_table(unsigned long addr)
131{
132 void *v;
Patrick Georgic75c79b2011-10-07 22:41:07 +0200133 v = smp_write_floating_table(addr, 0);
Ed Swierkb8e53eb2008-10-13 23:18:56 +0000134 return (unsigned long)smp_write_config_table(v);
135}