blob: 7ab47b4b37688706ece974fb876e65b4706caca2 [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 */
Felix Held0d192892024-02-06 16:55:29 +010021 u8 ioapic_id = smp_write_ioapic_from_hw(mc, IO_APIC_ADDR);
Stefan Reinauer1a08f582009-10-28 16:52:48 +000022
23 /* Legacy Interrupts */
24
Kyösti Mälkki860cff92021-06-07 22:20:57 +030025 mptable_add_isa_interrupts(mc, isa_bus, ioapic_id, 0);
Stefan Reinauer1a08f582009-10-28 16:52:48 +000026
27 /* Builtin devices on Bus 0 */
Kyösti Mälkki7742aed2021-06-07 22:18:35 +030028 smp_write_pci_intsrc(mc, mp_INT, 0x0, 0x02, 0, ioapic_id, 0x10);
29 smp_write_pci_intsrc(mc, mp_INT, 0x0, 0x1f, 1, ioapic_id, 0x13);
30 smp_write_pci_intsrc(mc, mp_INT, 0x0, 0x1d, 0, ioapic_id, 0x17);
31 smp_write_pci_intsrc(mc, mp_INT, 0x0, 0x1d, 1, ioapic_id, 0x13);
32 smp_write_pci_intsrc(mc, mp_INT, 0x0, 0x1d, 2, ioapic_id, 0x12);
33 smp_write_pci_intsrc(mc, mp_INT, 0x0, 0x1d, 3, ioapic_id, 0x10);
34 smp_write_pci_intsrc(mc, mp_INT, 0x0, 0x1b, 0, ioapic_id, 0x10);
35 smp_write_pci_intsrc(mc, mp_INT, 0x0, 0x1c, 0, ioapic_id, 0x10);
36 smp_write_pci_intsrc(mc, mp_INT, 0x0, 0x1c, 1, ioapic_id, 0x11);
Stefan Reinauer1a08f582009-10-28 16:52:48 +000037
38 /* Firewire 4:0.0 */
Kyösti Mälkki7742aed2021-06-07 22:18:35 +030039 smp_write_pci_intsrc(mc, mp_INT, 0x4, 0x00, 0, ioapic_id, 0x10);
Stefan Reinauer1a08f582009-10-28 16:52:48 +000040
41 /* Old riser card */
42 // riser slot top 5:8.0
Kyösti Mälkki7742aed2021-06-07 22:18:35 +030043 smp_write_pci_intsrc(mc, mp_INT, 0x5, 0x08, 0, ioapic_id, 0x14);
Stefan Reinauer1a08f582009-10-28 16:52:48 +000044 // riser slot middle 5:9.0
Kyösti Mälkki7742aed2021-06-07 22:18:35 +030045 smp_write_pci_intsrc(mc, mp_INT, 0x5, 0x09, 0, ioapic_id, 0x15);
Stefan Reinauer1a08f582009-10-28 16:52:48 +000046 // riser slot bottom 5:a.0
Kyösti Mälkki7742aed2021-06-07 22:18:35 +030047 smp_write_pci_intsrc(mc, mp_INT, 0x5, 0x0a, 0, ioapic_id, 0x16);
Stefan Reinauer1a08f582009-10-28 16:52:48 +000048
49 /* New Riser Card */
Kyösti Mälkki7742aed2021-06-07 22:18:35 +030050 smp_write_pci_intsrc(mc, mp_INT, 0x5, 0x0c, 0, ioapic_id, 0x14);
51 smp_write_pci_intsrc(mc, mp_INT, 0x5, 0x0d, 0, ioapic_id, 0x15);
52 smp_write_pci_intsrc(mc, mp_INT, 0x5, 0x0e, 0, ioapic_id, 0x16);
Stefan Reinauer1a08f582009-10-28 16:52:48 +000053
54 /* Onboard Ethernet */
Kyösti Mälkki7742aed2021-06-07 22:18:35 +030055 smp_write_pci_intsrc(mc, mp_INT, 0x1, 0x00, 0, ioapic_id, 0x10);
Stefan Reinauer1a08f582009-10-28 16:52:48 +000056
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}