blob: 13ebea4e0c1cc15891652a27ecf9283b1040aad5 [file] [log] [blame]
Angel Pons60ec3652020-04-03 01:22:13 +02001/* SPDX-License-Identifier: GPL-2.0-only */
2/* This file is part of the coreboot project. */
Stefan Reinauer1a08f582009-10-28 16:52:48 +00003
Stefan Reinauer1a08f582009-10-28 16:52:48 +00004#include <device/device.h>
Stefan Reinauer1a08f582009-10-28 16:52:48 +00005#include <arch/smp/mpspec.h>
Uwe Hermann74d1a6e2010-10-12 17:34:08 +00006#include <arch/ioapic.h>
Stefan Reinauer1a08f582009-10-28 16:52:48 +00007#include <stdint.h>
8
Stefan Reinauer53b0ea42010-03-22 11:50:52 +00009static void *smp_write_config_table(void *v)
Stefan Reinauer1a08f582009-10-28 16:52:48 +000010{
Elyes HAOUAS8da96e52016-09-22 21:20:54 +020011 struct mp_config_table *mc;
Patrick Georgi5244e1b2010-11-21 14:41:07 +000012 int isa_bus;
Stefan Reinauer1a08f582009-10-28 16:52:48 +000013
Elyes HAOUAS8da96e52016-09-22 21:20:54 +020014 mc = (void *)(((char *)v) + SMP_FLOATING_TABLE_LEN);
Stefan Reinauer1a08f582009-10-28 16:52:48 +000015
Patrick Georgic8feedd2012-02-16 18:43:25 +010016 mptable_init(mc, LOCAL_APIC_ADDR);
Stefan Reinauer1a08f582009-10-28 16:52:48 +000017
Elyes HAOUAS8da96e52016-09-22 21:20:54 +020018 smp_write_processors(mc);
Stefan Reinauer1a08f582009-10-28 16:52:48 +000019
Patrick Georgi5244e1b2010-11-21 14:41:07 +000020 mptable_write_buses(mc, NULL, &isa_bus);
Stefan Reinauer1a08f582009-10-28 16:52:48 +000021
22 /* I/O APICs: APIC ID Version State Address */
Kevin Paul Herbertbde6d302014-12-24 18:43:20 -080023 smp_write_ioapic(mc, 2, 0x20, VIO_APIC_VADDR);
Stefan Reinauer1a08f582009-10-28 16:52:48 +000024
25 /* Legacy Interrupts */
26
Patrick Georgic5b87c82010-05-20 15:28:19 +000027 mptable_add_isa_interrupts(mc, isa_bus, 0x2, 0);
Stefan Reinauer1a08f582009-10-28 16:52:48 +000028
29 /* Builtin devices on Bus 0 */
30 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x0, 0x8, 0x2, 0x10);
31 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x0, 0x7d, 0x2, 0x13);
32 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x0, 0x74, 0x2, 0x17);
33 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x0, 0x75, 0x2, 0x13);
34 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x0, 0x76, 0x2, 0x12);
35 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x0, 0x77, 0x2, 0x10);
36 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x0, 0x6c, 0x2, 0x10);
37 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x0, 0x70, 0x2, 0x10);
38 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x0, 0x71, 0x2, 0x11);
39
40 /* Firewire 4:0.0 */
41 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x4, 0x0, 0x2, 0x10);
42
43 /* Old riser card */
44 // riser slot top 5:8.0
45 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x5, 0x20, 0x2, 0x14);
46 // riser slot middle 5:9.0
47 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x5, 0x24, 0x2, 0x15);
48 // riser slot bottom 5:a.0
49 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x5, 0x28, 0x2, 0x16);
50
51 /* New Riser Card */
52 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x5, 0x30, 0x2, 0x14);
53 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x5, 0x34, 0x2, 0x15);
54 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x5, 0x38, 0x2, 0x16);
55
56 /* Onboard Ethernet */
57 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x1, 0x0, 0x2, 0x10);
58
59 /* Local Ints: Type Polarity Trigger Bus ID IRQ APIC ID PIN# */
Patrick Georgi6eb7a532011-10-07 21:42:52 +020060 mptable_lintsrc(mc, isa_bus);
Stefan Reinauer1a08f582009-10-28 16:52:48 +000061
62 /* Compute the checksums */
Patrick Georgib0a9c5c2011-10-07 23:01:55 +020063 return mptable_finalize(mc);
Stefan Reinauer1a08f582009-10-28 16:52:48 +000064}
65
66unsigned long write_smp_table(unsigned long addr)
67{
68 void *v;
Patrick Georgic75c79b2011-10-07 22:41:07 +020069 v = smp_write_floating_table(addr, 0);
Stefan Reinauer1a08f582009-10-28 16:52:48 +000070 return (unsigned long)smp_write_config_table(v);
71}