blob: 30b41dcce298852cb9641e9c2a866d9eb7029fad [file] [log] [blame]
Angel Pons60ec3652020-04-03 01:22:13 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Stefan Reinauer1a08f582009-10-28 16:52:48 +00002
Stefan Reinauer1a08f582009-10-28 16:52:48 +00003#include <device/device.h>
Stefan Reinauer1a08f582009-10-28 16:52:48 +00004#include <arch/smp/mpspec.h>
Uwe Hermann74d1a6e2010-10-12 17:34:08 +00005#include <arch/ioapic.h>
Stefan Reinauer1a08f582009-10-28 16:52:48 +00006
Stefan Reinauer53b0ea42010-03-22 11:50:52 +00007static void *smp_write_config_table(void *v)
Stefan Reinauer1a08f582009-10-28 16:52:48 +00008{
Elyes HAOUAS8da96e52016-09-22 21:20:54 +02009 struct mp_config_table *mc;
Patrick Georgi5244e1b2010-11-21 14:41:07 +000010 int isa_bus;
Stefan Reinauer1a08f582009-10-28 16:52:48 +000011
Elyes HAOUAS8da96e52016-09-22 21:20:54 +020012 mc = (void *)(((char *)v) + SMP_FLOATING_TABLE_LEN);
Stefan Reinauer1a08f582009-10-28 16:52:48 +000013
Kyösti Mälkkidea42e02021-05-31 20:26:16 +030014 mptable_init(mc);
Stefan Reinauer1a08f582009-10-28 16:52:48 +000015
Elyes HAOUAS8da96e52016-09-22 21:20:54 +020016 smp_write_processors(mc);
Stefan Reinauer1a08f582009-10-28 16:52:48 +000017
Patrick Georgi5244e1b2010-11-21 14:41:07 +000018 mptable_write_buses(mc, NULL, &isa_bus);
Stefan Reinauer1a08f582009-10-28 16:52:48 +000019
20 /* I/O APICs: APIC ID Version State Address */
Kevin Paul Herbertbde6d302014-12-24 18:43:20 -080021 smp_write_ioapic(mc, 2, 0x20, VIO_APIC_VADDR);
Stefan Reinauer1a08f582009-10-28 16:52:48 +000022
23 /* Legacy Interrupts */
24
Patrick Georgic5b87c82010-05-20 15:28:19 +000025 mptable_add_isa_interrupts(mc, isa_bus, 0x2, 0);
Stefan Reinauer1a08f582009-10-28 16:52:48 +000026
27 /* Builtin devices on Bus 0 */
28 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x0, 0x8, 0x2, 0x10);
29 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x0, 0x7d, 0x2, 0x13);
30 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x0, 0x74, 0x2, 0x17);
31 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x0, 0x75, 0x2, 0x13);
32 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x0, 0x76, 0x2, 0x12);
33 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x0, 0x77, 0x2, 0x10);
34 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x0, 0x6c, 0x2, 0x10);
35 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x0, 0x70, 0x2, 0x10);
36 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x0, 0x71, 0x2, 0x11);
37
38 /* Firewire 4:0.0 */
39 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x4, 0x0, 0x2, 0x10);
40
41 /* Old riser card */
42 // riser slot top 5:8.0
43 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x5, 0x20, 0x2, 0x14);
44 // riser slot middle 5:9.0
45 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x5, 0x24, 0x2, 0x15);
46 // riser slot bottom 5:a.0
47 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x5, 0x28, 0x2, 0x16);
48
49 /* New Riser Card */
50 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x5, 0x30, 0x2, 0x14);
51 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x5, 0x34, 0x2, 0x15);
52 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x5, 0x38, 0x2, 0x16);
53
54 /* Onboard Ethernet */
55 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x1, 0x0, 0x2, 0x10);
56
57 /* Local Ints: Type Polarity Trigger Bus ID IRQ APIC ID PIN# */
Patrick Georgi6eb7a532011-10-07 21:42:52 +020058 mptable_lintsrc(mc, isa_bus);
Stefan Reinauer1a08f582009-10-28 16:52:48 +000059
60 /* Compute the checksums */
Patrick Georgib0a9c5c2011-10-07 23:01:55 +020061 return mptable_finalize(mc);
Stefan Reinauer1a08f582009-10-28 16:52:48 +000062}
63
64unsigned long write_smp_table(unsigned long addr)
65{
66 void *v;
Patrick Georgic75c79b2011-10-07 22:41:07 +020067 v = smp_write_floating_table(addr, 0);
Stefan Reinauer1a08f582009-10-28 16:52:48 +000068 return (unsigned long)smp_write_config_table(v);
69}