Jon Harrison | cfb9cd2 | 2009-07-01 10:57:25 +0000 | [diff] [blame] | 1 | /* |
| 2 | * coreboot ACPI Table support |
| 3 | * written by Stefan Reinauer <stepan@openbios.org> |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 4 | * ACPI FADT, FACS, and DSDT table support added by |
Jon Harrison | cfb9cd2 | 2009-07-01 10:57:25 +0000 | [diff] [blame] | 5 | * Nick Barker <nick.barker9@btinternet.com>, and those portions |
| 6 | * (C) Copyright 2004 Nick Barker |
| 7 | * (C) Copyright 2005 Stefan Reinauer |
Jon Harrison | 1825be2 | 2009-08-17 17:09:46 +0000 | [diff] [blame] | 8 | * (C) Copyright 2009 Jon Harrison <bothlyn@blueyonder.co.uk> |
| 9 | * |
| 10 | * This program is free software; you can redistribute it and/or modify |
| 11 | * it under the terms of the GNU General Public License as published by |
| 12 | * the Free Software Foundation; version 2 of the License. |
| 13 | * |
| 14 | * This program is distributed in the hope that it will be useful, |
| 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 17 | * GNU General Public License for more details. |
| 18 | * |
| 19 | * You should have received a copy of the GNU General Public License |
| 20 | * along with this program; if not, write to the Free Software |
Paul Menzel | a46a712 | 2013-02-23 18:37:27 +0100 | [diff] [blame] | 21 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
Jon Harrison | 1825be2 | 2009-08-17 17:09:46 +0000 | [diff] [blame] | 22 | */ |
| 23 | |
| 24 | |
| 25 | /* |
| 26 | * Most parts of this file copied from via\epia-m\acpi_tables.c, |
| 27 | * and via\epia-m700\acpi_tables.c |
Jon Harrison | cfb9cd2 | 2009-07-01 10:57:25 +0000 | [diff] [blame] | 28 | */ |
| 29 | |
| 30 | #include <console/console.h> |
| 31 | #include <string.h> |
| 32 | #include <arch/acpi.h> |
Uwe Hermann | 74d1a6e | 2010-10-12 17:34:08 +0000 | [diff] [blame] | 33 | #include <arch/ioapic.h> |
Jon Harrison | 1825be2 | 2009-08-17 17:09:46 +0000 | [diff] [blame] | 34 | #include <device/device.h> |
| 35 | #include <device/pci.h> |
| 36 | #include <device/pci_ids.h> |
Uwe Hermann | 5df4168 | 2010-09-25 16:17:20 +0000 | [diff] [blame] | 37 | #include "southbridge/via/vt8237r/vt8237r.h" |
Jon Harrison | cfb9cd2 | 2009-07-01 10:57:25 +0000 | [diff] [blame] | 38 | |
Jon Harrison | 1825be2 | 2009-08-17 17:09:46 +0000 | [diff] [blame] | 39 | /* |
Uwe Hermann | 607614d | 2010-11-18 20:12:13 +0000 | [diff] [blame] | 40 | * These 8 macros are copied from <arch/smp/mpspec.h>, I have to do this |
| 41 | * since the "CONFIG_GENERATE_MP_TABLE = 0", and also since |
Jon Harrison | 1825be2 | 2009-08-17 17:09:46 +0000 | [diff] [blame] | 42 | * mainboard/via/... have no mptable.c (so that I can not set |
Uwe Hermann | 607614d | 2010-11-18 20:12:13 +0000 | [diff] [blame] | 43 | * "CONFIG_GENERATE_MP_TABLE = 1" as many other mainboards. |
Jon Harrison | 1825be2 | 2009-08-17 17:09:46 +0000 | [diff] [blame] | 44 | * So I have to copy these four to here. acpi_fill_madt() needs this. |
| 45 | */ |
| 46 | #define MP_IRQ_POLARITY_DEFAULT 0x0 |
| 47 | #define MP_IRQ_POLARITY_HIGH 0x1 |
| 48 | #define MP_IRQ_POLARITY_LOW 0x3 |
| 49 | #define MP_IRQ_POLARITY_MASK 0x3 |
| 50 | #define MP_IRQ_TRIGGER_DEFAULT 0x0 |
| 51 | #define MP_IRQ_TRIGGER_EDGE 0x4 |
| 52 | #define MP_IRQ_TRIGGER_LEVEL 0xc |
| 53 | #define MP_IRQ_TRIGGER_MASK 0xc |
| 54 | |
Jon Harrison | cfb9cd2 | 2009-07-01 10:57:25 +0000 | [diff] [blame] | 55 | unsigned long acpi_fill_mcfg(unsigned long current) |
| 56 | { |
| 57 | /* Nothing to do */ |
| 58 | return current; |
| 59 | } |
| 60 | |
| 61 | unsigned long acpi_fill_slit(unsigned long current) |
| 62 | { |
| 63 | // Not implemented |
| 64 | return current; |
| 65 | } |
| 66 | |
Jon Harrison | 1825be2 | 2009-08-17 17:09:46 +0000 | [diff] [blame] | 67 | unsigned long acpi_create_madt_lapic_nmis(unsigned long current, u16 flags, |
| 68 | u8 lint) |
| 69 | { |
| 70 | device_t cpu; |
| 71 | int cpu_index = 0; |
| 72 | |
| 73 | for (cpu = all_devices; cpu; cpu = cpu->next) { |
| 74 | if ((cpu->path.type != DEVICE_PATH_APIC) || |
Stefan Reinauer | 0aa37c4 | 2013-02-12 15:20:54 -0800 | [diff] [blame] | 75 | (cpu->bus->dev->path.type != DEVICE_PATH_CPU_CLUSTER)) { |
Jon Harrison | 1825be2 | 2009-08-17 17:09:46 +0000 | [diff] [blame] | 76 | continue; |
| 77 | } |
| 78 | if (!cpu->enabled) |
| 79 | continue; |
| 80 | current += acpi_create_madt_lapic_nmi((acpi_madt_lapic_nmi_t *) |
| 81 | current, cpu_index, flags, lint); |
| 82 | cpu_index++; |
| 83 | } |
| 84 | return current; |
| 85 | } |
| 86 | |
Jon Harrison | cfb9cd2 | 2009-07-01 10:57:25 +0000 | [diff] [blame] | 87 | unsigned long acpi_fill_madt(unsigned long current) |
| 88 | { |
Jon Harrison | 1825be2 | 2009-08-17 17:09:46 +0000 | [diff] [blame] | 89 | unsigned int gsi_base = 0x00; |
| 90 | |
| 91 | /* Create all subtables for processors. */ |
| 92 | current = acpi_create_madt_lapics(current); |
| 93 | |
| 94 | /* Write SB IOAPIC. */ |
| 95 | current += acpi_create_madt_ioapic((acpi_madt_ioapic_t *) current, |
Uwe Hermann | 74d1a6e | 2010-10-12 17:34:08 +0000 | [diff] [blame] | 96 | VT8237R_APIC_ID, IO_APIC_ADDR, gsi_base); |
Jon Harrison | 1825be2 | 2009-08-17 17:09:46 +0000 | [diff] [blame] | 97 | |
| 98 | /* IRQ0 -> APIC IRQ2. */ |
| 99 | current += acpi_create_madt_irqoverride((acpi_madt_irqoverride_t *) |
| 100 | current, 0, 0, 2, 0x0); |
| 101 | |
| 102 | /* IRQ9 ACPI active low. */ |
| 103 | current += acpi_create_madt_irqoverride((acpi_madt_irqoverride_t *) |
| 104 | current, 0, 9, 9, MP_IRQ_TRIGGER_LEVEL | MP_IRQ_POLARITY_LOW); |
| 105 | |
| 106 | /* Create all subtables for processors. */ |
| 107 | current = acpi_create_madt_lapic_nmis(current, |
| 108 | MP_IRQ_TRIGGER_EDGE | MP_IRQ_POLARITY_HIGH, 1); |
| 109 | |
Jon Harrison | cfb9cd2 | 2009-07-01 10:57:25 +0000 | [diff] [blame] | 110 | return current; |
| 111 | } |
| 112 | |
| 113 | unsigned long acpi_fill_srat(unsigned long current) |
| 114 | { |
| 115 | /* No NUMA, no SRAT */ |
| 116 | return current; |
| 117 | } |