blob: 2b96ca86c5c674bc538378b2c7a660b285204ea4 [file] [log] [blame]
Uwe Hermann20a98c92009-06-05 23:02:43 +00001/*
2 * This file is part of the coreboot project.
3 *
4 * LinuxBIOS ACPI Table support
5 * written by Stefan Reinauer <stepan@openbios.org>
Uwe Hermann0ffff342009-06-07 13:46:50 +00006 * ACPI FADT, FACS, and DSDT table support added by
Uwe Hermann20a98c92009-06-05 23:02:43 +00007 * Nick Barker <nick.barker9@btinternet.com>, and those portions
8 * (C) Copyright 2004 Nick Barker
9 * (C) Copyright 2005 Stefan Reinauer
10 * (C) Copyright 2009 One Laptop per Child, Association, Inc.
11 *
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; version 2 of the License.
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
Uwe Hermann20a98c92009-06-05 23:02:43 +000020 */
21
22/*
Uwe Hermann0ffff342009-06-07 13:46:50 +000023 * Most parts of this file copied from asus\a8v-e_se\acpi_tables.c,
24 * acpi_is_wakeup() is from Rudolf's S3 patch and SSDT was added.
Uwe Hermann20a98c92009-06-05 23:02:43 +000025 */
26
27#include <console/console.h>
28#include <string.h>
29#include <arch/acpi.h>
30#include <device/device.h>
31#include <device/pci_ids.h>
Uwe Hermann5df41682010-09-25 16:17:20 +000032#include "northbridge/via/vx800/vx800.h"
Uwe Hermann20a98c92009-06-05 23:02:43 +000033
Uwe Hermann0ffff342009-06-07 13:46:50 +000034extern u32 wake_vec;
Uwe Hermann0ffff342009-06-07 13:46:50 +000035
Uwe Hermann20a98c92009-06-05 23:02:43 +000036/*
Uwe Hermann0ffff342009-06-07 13:46:50 +000037 * These four macros are copied from <arch/smp/mpspec.h>, I have to do this
Uwe Hermann607614d2010-11-18 20:12:13 +000038 * since the "CONFIG_GENERATE_MP_TABLE = 0", and also since
Uwe Hermann0ffff342009-06-07 13:46:50 +000039 * mainboard/via/... have no mptable.c (so that I can not set
Uwe Hermann607614d2010-11-18 20:12:13 +000040 * "CONFIG_GENERATE_MP_TABLE = 1" as many other mainboards.
Uwe Hermann0ffff342009-06-07 13:46:50 +000041 * So I have to copy these four to here. acpi_fill_madt() needs this.
42 */
Uwe Hermann20a98c92009-06-05 23:02:43 +000043#define MP_IRQ_POLARITY_HIGH 0x1
44#define MP_IRQ_POLARITY_LOW 0x3
45#define MP_IRQ_TRIGGER_EDGE 0x4
46#define MP_IRQ_TRIGGER_LEVEL 0xc
47
Uwe Hermann20a98c92009-06-05 23:02:43 +000048unsigned long acpi_fill_mcfg(unsigned long current)
49{
Uwe Hermann0ffff342009-06-07 13:46:50 +000050 /* NO MCFG in VX855, no PCI-E. */
Uwe Hermann20a98c92009-06-05 23:02:43 +000051 return current;
52}
53
Uwe Hermann0ffff342009-06-07 13:46:50 +000054unsigned long acpi_create_madt_lapic_nmis(unsigned long current, u16 flags,
55 u8 lint)
Uwe Hermann20a98c92009-06-05 23:02:43 +000056{
57 device_t cpu;
58 int cpu_index = 0;
59
Uwe Hermann0ffff342009-06-07 13:46:50 +000060 for (cpu = all_devices; cpu; cpu = cpu->next) {
Uwe Hermann20a98c92009-06-05 23:02:43 +000061 if ((cpu->path.type != DEVICE_PATH_APIC) ||
Stefan Reinauer0aa37c42013-02-12 15:20:54 -080062 (cpu->bus->dev->path.type != DEVICE_PATH_CPU_CLUSTER)) {
Uwe Hermann20a98c92009-06-05 23:02:43 +000063 continue;
64 }
Uwe Hermann0ffff342009-06-07 13:46:50 +000065 if (!cpu->enabled)
Uwe Hermann20a98c92009-06-05 23:02:43 +000066 continue;
Uwe Hermann0ffff342009-06-07 13:46:50 +000067 current += acpi_create_madt_lapic_nmi((acpi_madt_lapic_nmi_t *)
68 current, cpu_index, flags, lint);
Uwe Hermann20a98c92009-06-05 23:02:43 +000069 cpu_index++;
70 }
71 return current;
72}
73
74unsigned long acpi_fill_madt(unsigned long current)
75{
Uwe Hermann20a98c92009-06-05 23:02:43 +000076 /* Create all subtables for processors. */
77 current = acpi_create_madt_lapics(current);
78
79 /* Write SB IOAPIC. */
80 current += acpi_create_madt_ioapic((acpi_madt_ioapic_t *) current,
Uwe Hermann0ffff342009-06-07 13:46:50 +000081 VX800SB_APIC_ID, VX800SB_APIC_BASE, 0);
Uwe Hermann20a98c92009-06-05 23:02:43 +000082
83 /* IRQ0 -> APIC IRQ2. */
84 current += acpi_create_madt_irqoverride((acpi_madt_irqoverride_t *)
Uwe Hermann0ffff342009-06-07 13:46:50 +000085 current, 0, 0, 2, 0x0);
Uwe Hermann20a98c92009-06-05 23:02:43 +000086
87 /* IRQ9 ACPI active low. */
88 current += acpi_create_madt_irqoverride((acpi_madt_irqoverride_t *)
89 current, 0, 9, 9, MP_IRQ_TRIGGER_LEVEL | MP_IRQ_POLARITY_LOW);
90
91 /* Create all subtables for processors. */
92 current = acpi_create_madt_lapic_nmis(current,
Uwe Hermann0ffff342009-06-07 13:46:50 +000093 MP_IRQ_TRIGGER_EDGE | MP_IRQ_POLARITY_HIGH, 1);
Uwe Hermann20a98c92009-06-05 23:02:43 +000094
95 return current;
96}