blob: 8e792b7ca2618e740a9af7457ed81e7ccafec4f4 [file] [log] [blame]
Stefan Reinauer7cfa7f92010-05-16 14:24:41 +00001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2007-2008 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.
Stefan Reinauer7cfa7f92010-05-16 14:24:41 +000015 */
16
Stefan Reinauer7cfa7f92010-05-16 14:24:41 +000017#include <device/device.h>
18#include <device/pci.h>
19#include <console/console.h>
20#include <arch/smp/mpspec.h>
Uwe Hermann74d1a6e2010-10-12 17:34:08 +000021#include <arch/ioapic.h>
Stefan Reinauer7cfa7f92010-05-16 14:24:41 +000022#include <string.h>
23#include <stdint.h>
24
25static void *smp_write_config_table(void *v)
26{
Stefan Reinauer7cfa7f92010-05-16 14:24:41 +000027 struct mp_config_table *mc;
Patrick Georgi5244e1b2010-11-21 14:41:07 +000028 int isa_bus;
Stefan Reinauer7cfa7f92010-05-16 14:24:41 +000029
30 mc = (void *)(((char *)v) + SMP_FLOATING_TABLE_LEN);
Stefan Reinauer7cfa7f92010-05-16 14:24:41 +000031
Patrick Georgic8feedd2012-02-16 18:43:25 +010032 mptable_init(mc, LOCAL_APIC_ADDR);
Stefan Reinauer7cfa7f92010-05-16 14:24:41 +000033
34 smp_write_processors(mc);
35
Patrick Georgi5244e1b2010-11-21 14:41:07 +000036 mptable_write_buses(mc, NULL, &isa_bus);
Stefan Reinauer7cfa7f92010-05-16 14:24:41 +000037
38 /* I/O APICs: APIC ID Version State Address */
Kevin Paul Herbertbde6d302014-12-24 18:43:20 -080039 smp_write_ioapic(mc, 2, 0x20, VIO_APIC_VADDR);
Stefan Reinauer7cfa7f92010-05-16 14:24:41 +000040
41 /* Legacy Interrupts */
Patrick Georgic5b87c82010-05-20 15:28:19 +000042 mptable_add_isa_interrupts(mc, isa_bus, 0x2, 0);
Stefan Reinauer7cfa7f92010-05-16 14:24:41 +000043
44 /* Builtin devices on Bus 0 */
45 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x0, 0x8, 0x2, 0x10);
46 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x0, 0x7d, 0x2, 0x13);
47 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x0, 0x74, 0x2, 0x17);
48 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x0, 0x75, 0x2, 0x13);
49 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x0, 0x76, 0x2, 0x12);
50 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x0, 0x77, 0x2, 0x10);
51 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x0, 0x6c, 0x2, 0x10);
52 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x0, 0x70, 0x2, 0x10);
53 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x0, 0x71, 0x2, 0x11);
54
55 /* Firewire 4:0.0 */
56 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x4, 0x0, 0x2, 0x10);
57
58 // riser slot top 5:8.0
59 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x5, 0x20, 0x2, 0x14);
60 // riser slot middle 5:9.0
61 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x5, 0x24, 0x2, 0x15);
62 // riser slot bottom 5:a.0
63 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x5, 0x28, 0x2, 0x16);
64
65 /* Onboard Ethernet */
66 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x1, 0x0, 0x2, 0x10);
67
68 /* Local Ints: Type Polarity Trigger Bus ID IRQ APIC ID PIN# */
Patrick Georgi6eb7a532011-10-07 21:42:52 +020069 mptable_lintsrc(mc, isa_bus);
Stefan Reinauer7cfa7f92010-05-16 14:24:41 +000070
71 /* Compute the checksums */
Patrick Georgib0a9c5c2011-10-07 23:01:55 +020072 return mptable_finalize(mc);
Stefan Reinauer7cfa7f92010-05-16 14:24:41 +000073}
74
75unsigned long write_smp_table(unsigned long addr)
76{
77 void *v;
Patrick Georgic75c79b2011-10-07 22:41:07 +020078 v = smp_write_floating_table(addr, 0);
Stefan Reinauer7cfa7f92010-05-16 14:24:41 +000079 return (unsigned long)smp_write_config_table(v);
80}