blob: a48a43867326fc54e2a8511334e467d0b486ed2b [file] [log] [blame]
Jon Harrisoncfb9cd22009-07-01 10:57:25 +00001/*
2 * coreboot ACPI Table support
3 * written by Stefan Reinauer <stepan@openbios.org>
Stefan Reinauer14e22772010-04-27 06:56:47 +00004 * ACPI FADT, FACS, and DSDT table support added by
Jon Harrisoncfb9cd22009-07-01 10:57:25 +00005 * Nick Barker <nick.barker9@btinternet.com>, and those portions
6 * (C) Copyright 2004 Nick Barker
7 * (C) Copyright 2005 Stefan Reinauer
Jon Harrison1825be22009-08-17 17:09:46 +00008 * (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 Menzela46a7122013-02-23 18:37:27 +010021 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Jon Harrison1825be22009-08-17 17:09:46 +000022 */
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 Harrisoncfb9cd22009-07-01 10:57:25 +000028 */
29
30#include <console/console.h>
31#include <string.h>
32#include <arch/acpi.h>
Uwe Hermann74d1a6e2010-10-12 17:34:08 +000033#include <arch/ioapic.h>
Jon Harrison1825be22009-08-17 17:09:46 +000034#include <device/device.h>
35#include <device/pci.h>
36#include <device/pci_ids.h>
Uwe Hermann5df41682010-09-25 16:17:20 +000037#include "southbridge/via/vt8237r/vt8237r.h"
Jon Harrisoncfb9cd22009-07-01 10:57:25 +000038
Jon Harrison1825be22009-08-17 17:09:46 +000039/*
Uwe Hermann607614d2010-11-18 20:12:13 +000040 * 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 Harrison1825be22009-08-17 17:09:46 +000042 * mainboard/via/... have no mptable.c (so that I can not set
Uwe Hermann607614d2010-11-18 20:12:13 +000043 * "CONFIG_GENERATE_MP_TABLE = 1" as many other mainboards.
Jon Harrison1825be22009-08-17 17:09:46 +000044 * 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 Harrisoncfb9cd22009-07-01 10:57:25 +000055unsigned long acpi_fill_mcfg(unsigned long current)
56{
57 /* Nothing to do */
58 return current;
59}
60
61unsigned long acpi_fill_slit(unsigned long current)
62{
63 // Not implemented
64 return current;
65}
66
Jon Harrison1825be22009-08-17 17:09:46 +000067unsigned 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 Reinauer0aa37c42013-02-12 15:20:54 -080075 (cpu->bus->dev->path.type != DEVICE_PATH_CPU_CLUSTER)) {
Jon Harrison1825be22009-08-17 17:09:46 +000076 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 Harrisoncfb9cd22009-07-01 10:57:25 +000087unsigned long acpi_fill_madt(unsigned long current)
88{
Jon Harrison1825be22009-08-17 17:09:46 +000089 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 Hermann74d1a6e2010-10-12 17:34:08 +000096 VT8237R_APIC_ID, IO_APIC_ADDR, gsi_base);
Jon Harrison1825be22009-08-17 17:09:46 +000097
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 Harrisoncfb9cd22009-07-01 10:57:25 +0000110 return current;
111}
112
113unsigned long acpi_fill_srat(unsigned long current)
114{
115 /* No NUMA, no SRAT */
116 return current;
117}