Uwe Hermann | 20a98c9 | 2009-06-05 23:02:43 +0000 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
| 4 | * LinuxBIOS ACPI Table support |
| 5 | * written by Stefan Reinauer <stepan@openbios.org> |
Uwe Hermann | 0ffff34 | 2009-06-07 13:46:50 +0000 | [diff] [blame] | 6 | * ACPI FADT, FACS, and DSDT table support added by |
Uwe Hermann | 20a98c9 | 2009-06-05 23:02:43 +0000 | [diff] [blame] | 7 | * 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 Hermann | 20a98c9 | 2009-06-05 23:02:43 +0000 | [diff] [blame] | 20 | */ |
| 21 | |
| 22 | /* |
Uwe Hermann | 0ffff34 | 2009-06-07 13:46:50 +0000 | [diff] [blame] | 23 | * 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 Hermann | 20a98c9 | 2009-06-05 23:02:43 +0000 | [diff] [blame] | 25 | */ |
| 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 Hermann | 5df4168 | 2010-09-25 16:17:20 +0000 | [diff] [blame] | 32 | #include "northbridge/via/vx800/vx800.h" |
Uwe Hermann | 20a98c9 | 2009-06-05 23:02:43 +0000 | [diff] [blame] | 33 | |
Uwe Hermann | 0ffff34 | 2009-06-07 13:46:50 +0000 | [diff] [blame] | 34 | extern u32 wake_vec; |
Uwe Hermann | 0ffff34 | 2009-06-07 13:46:50 +0000 | [diff] [blame] | 35 | |
Uwe Hermann | 20a98c9 | 2009-06-05 23:02:43 +0000 | [diff] [blame] | 36 | /* |
Uwe Hermann | 0ffff34 | 2009-06-07 13:46:50 +0000 | [diff] [blame] | 37 | * These four macros are copied from <arch/smp/mpspec.h>, I have to do this |
Uwe Hermann | 607614d | 2010-11-18 20:12:13 +0000 | [diff] [blame] | 38 | * since the "CONFIG_GENERATE_MP_TABLE = 0", and also since |
Uwe Hermann | 0ffff34 | 2009-06-07 13:46:50 +0000 | [diff] [blame] | 39 | * mainboard/via/... have no mptable.c (so that I can not set |
Uwe Hermann | 607614d | 2010-11-18 20:12:13 +0000 | [diff] [blame] | 40 | * "CONFIG_GENERATE_MP_TABLE = 1" as many other mainboards. |
Uwe Hermann | 0ffff34 | 2009-06-07 13:46:50 +0000 | [diff] [blame] | 41 | * So I have to copy these four to here. acpi_fill_madt() needs this. |
| 42 | */ |
Uwe Hermann | 20a98c9 | 2009-06-05 23:02:43 +0000 | [diff] [blame] | 43 | #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 Hermann | 20a98c9 | 2009-06-05 23:02:43 +0000 | [diff] [blame] | 48 | unsigned long acpi_fill_mcfg(unsigned long current) |
| 49 | { |
Uwe Hermann | 0ffff34 | 2009-06-07 13:46:50 +0000 | [diff] [blame] | 50 | /* NO MCFG in VX855, no PCI-E. */ |
Uwe Hermann | 20a98c9 | 2009-06-05 23:02:43 +0000 | [diff] [blame] | 51 | return current; |
| 52 | } |
| 53 | |
Uwe Hermann | 0ffff34 | 2009-06-07 13:46:50 +0000 | [diff] [blame] | 54 | unsigned long acpi_create_madt_lapic_nmis(unsigned long current, u16 flags, |
| 55 | u8 lint) |
Uwe Hermann | 20a98c9 | 2009-06-05 23:02:43 +0000 | [diff] [blame] | 56 | { |
| 57 | device_t cpu; |
| 58 | int cpu_index = 0; |
| 59 | |
Uwe Hermann | 0ffff34 | 2009-06-07 13:46:50 +0000 | [diff] [blame] | 60 | for (cpu = all_devices; cpu; cpu = cpu->next) { |
Uwe Hermann | 20a98c9 | 2009-06-05 23:02:43 +0000 | [diff] [blame] | 61 | if ((cpu->path.type != DEVICE_PATH_APIC) || |
Stefan Reinauer | 0aa37c4 | 2013-02-12 15:20:54 -0800 | [diff] [blame] | 62 | (cpu->bus->dev->path.type != DEVICE_PATH_CPU_CLUSTER)) { |
Uwe Hermann | 20a98c9 | 2009-06-05 23:02:43 +0000 | [diff] [blame] | 63 | continue; |
| 64 | } |
Uwe Hermann | 0ffff34 | 2009-06-07 13:46:50 +0000 | [diff] [blame] | 65 | if (!cpu->enabled) |
Uwe Hermann | 20a98c9 | 2009-06-05 23:02:43 +0000 | [diff] [blame] | 66 | continue; |
Uwe Hermann | 0ffff34 | 2009-06-07 13:46:50 +0000 | [diff] [blame] | 67 | current += acpi_create_madt_lapic_nmi((acpi_madt_lapic_nmi_t *) |
| 68 | current, cpu_index, flags, lint); |
Uwe Hermann | 20a98c9 | 2009-06-05 23:02:43 +0000 | [diff] [blame] | 69 | cpu_index++; |
| 70 | } |
| 71 | return current; |
| 72 | } |
| 73 | |
| 74 | unsigned long acpi_fill_madt(unsigned long current) |
| 75 | { |
Uwe Hermann | 20a98c9 | 2009-06-05 23:02:43 +0000 | [diff] [blame] | 76 | /* 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 Hermann | 0ffff34 | 2009-06-07 13:46:50 +0000 | [diff] [blame] | 81 | VX800SB_APIC_ID, VX800SB_APIC_BASE, 0); |
Uwe Hermann | 20a98c9 | 2009-06-05 23:02:43 +0000 | [diff] [blame] | 82 | |
| 83 | /* IRQ0 -> APIC IRQ2. */ |
| 84 | current += acpi_create_madt_irqoverride((acpi_madt_irqoverride_t *) |
Uwe Hermann | 0ffff34 | 2009-06-07 13:46:50 +0000 | [diff] [blame] | 85 | current, 0, 0, 2, 0x0); |
Uwe Hermann | 20a98c9 | 2009-06-05 23:02:43 +0000 | [diff] [blame] | 86 | |
| 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 Hermann | 0ffff34 | 2009-06-07 13:46:50 +0000 | [diff] [blame] | 93 | MP_IRQ_TRIGGER_EDGE | MP_IRQ_POLARITY_HIGH, 1); |
Uwe Hermann | 20a98c9 | 2009-06-05 23:02:43 +0000 | [diff] [blame] | 94 | |
| 95 | return current; |
| 96 | } |