Angel Pons | 60ec365 | 2020-04-03 01:22:13 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Stefan Reinauer | 1a08f58 | 2009-10-28 16:52:48 +0000 | [diff] [blame] | 2 | |
Stefan Reinauer | 1a08f58 | 2009-10-28 16:52:48 +0000 | [diff] [blame] | 3 | #include <device/device.h> |
Stefan Reinauer | 1a08f58 | 2009-10-28 16:52:48 +0000 | [diff] [blame] | 4 | #include <arch/smp/mpspec.h> |
Uwe Hermann | 74d1a6e | 2010-10-12 17:34:08 +0000 | [diff] [blame] | 5 | #include <arch/ioapic.h> |
Stefan Reinauer | 1a08f58 | 2009-10-28 16:52:48 +0000 | [diff] [blame] | 6 | |
Stefan Reinauer | 53b0ea4 | 2010-03-22 11:50:52 +0000 | [diff] [blame] | 7 | static void *smp_write_config_table(void *v) |
Stefan Reinauer | 1a08f58 | 2009-10-28 16:52:48 +0000 | [diff] [blame] | 8 | { |
Elyes HAOUAS | 8da96e5 | 2016-09-22 21:20:54 +0200 | [diff] [blame] | 9 | struct mp_config_table *mc; |
Patrick Georgi | 5244e1b | 2010-11-21 14:41:07 +0000 | [diff] [blame] | 10 | int isa_bus; |
Stefan Reinauer | 1a08f58 | 2009-10-28 16:52:48 +0000 | [diff] [blame] | 11 | |
Elyes HAOUAS | 8da96e5 | 2016-09-22 21:20:54 +0200 | [diff] [blame] | 12 | mc = (void *)(((char *)v) + SMP_FLOATING_TABLE_LEN); |
Stefan Reinauer | 1a08f58 | 2009-10-28 16:52:48 +0000 | [diff] [blame] | 13 | |
Kyösti Mälkki | dea42e0 | 2021-05-31 20:26:16 +0300 | [diff] [blame] | 14 | mptable_init(mc); |
Stefan Reinauer | 1a08f58 | 2009-10-28 16:52:48 +0000 | [diff] [blame] | 15 | |
Elyes HAOUAS | 8da96e5 | 2016-09-22 21:20:54 +0200 | [diff] [blame] | 16 | smp_write_processors(mc); |
Stefan Reinauer | 1a08f58 | 2009-10-28 16:52:48 +0000 | [diff] [blame] | 17 | |
Patrick Georgi | 5244e1b | 2010-11-21 14:41:07 +0000 | [diff] [blame] | 18 | mptable_write_buses(mc, NULL, &isa_bus); |
Stefan Reinauer | 1a08f58 | 2009-10-28 16:52:48 +0000 | [diff] [blame] | 19 | |
| 20 | /* I/O APICs: APIC ID Version State Address */ |
Kevin Paul Herbert | bde6d30 | 2014-12-24 18:43:20 -0800 | [diff] [blame] | 21 | smp_write_ioapic(mc, 2, 0x20, VIO_APIC_VADDR); |
Stefan Reinauer | 1a08f58 | 2009-10-28 16:52:48 +0000 | [diff] [blame] | 22 | |
| 23 | /* Legacy Interrupts */ |
| 24 | |
Patrick Georgi | c5b87c8 | 2010-05-20 15:28:19 +0000 | [diff] [blame] | 25 | mptable_add_isa_interrupts(mc, isa_bus, 0x2, 0); |
Stefan Reinauer | 1a08f58 | 2009-10-28 16:52:48 +0000 | [diff] [blame] | 26 | |
| 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 Georgi | 6eb7a53 | 2011-10-07 21:42:52 +0200 | [diff] [blame] | 58 | mptable_lintsrc(mc, isa_bus); |
Stefan Reinauer | 1a08f58 | 2009-10-28 16:52:48 +0000 | [diff] [blame] | 59 | |
| 60 | /* Compute the checksums */ |
Patrick Georgi | b0a9c5c | 2011-10-07 23:01:55 +0200 | [diff] [blame] | 61 | return mptable_finalize(mc); |
Stefan Reinauer | 1a08f58 | 2009-10-28 16:52:48 +0000 | [diff] [blame] | 62 | } |
| 63 | |
| 64 | unsigned long write_smp_table(unsigned long addr) |
| 65 | { |
| 66 | void *v; |
Patrick Georgi | c75c79b | 2011-10-07 22:41:07 +0200 | [diff] [blame] | 67 | v = smp_write_floating_table(addr, 0); |
Stefan Reinauer | 1a08f58 | 2009-10-28 16:52:48 +0000 | [diff] [blame] | 68 | return (unsigned long)smp_write_config_table(v); |
| 69 | } |