Josef Kellermann | bfa7ee5 | 2011-05-11 07:47:43 +0000 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
| 4 | * Copyright (C) 2008 Advanced Micro Devices, Inc. |
| 5 | * Copyright (C) 2010 Siemens AG, Inc. |
| 6 | * (Written by Josef Kellermann <joseph.kellermann@heitec.de> for Siemens AG, Inc.) |
| 7 | * |
| 8 | * This program is free software; you can redistribute it and/or modify |
| 9 | * it under the terms of the GNU General Public License as published by |
| 10 | * the Free Software Foundation; version 2 of the License. |
| 11 | * |
| 12 | * This program is distributed in the hope that it will be useful, |
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 | * GNU General Public License for more details. |
| 16 | * |
| 17 | * You should have received a copy of the GNU General Public License |
| 18 | * along with this program; if not, write to the Free Software |
Patrick Georgi | b890a12 | 2015-03-26 15:17:45 +0100 | [diff] [blame] | 19 | * Foundation, Inc. |
Josef Kellermann | bfa7ee5 | 2011-05-11 07:47:43 +0000 | [diff] [blame] | 20 | */ |
| 21 | |
| 22 | #include <console/console.h> |
| 23 | #include <string.h> |
| 24 | #include <arch/acpi.h> |
| 25 | #include <arch/ioapic.h> |
| 26 | #include <arch/smp/mpspec.h> |
| 27 | #include <device/pci.h> |
| 28 | #include <device/pci_ids.h> |
| 29 | #include <cpu/x86/msr.h> |
| 30 | #include <cpu/amd/mtrr.h> |
| 31 | #include <cpu/amd/amdk8_sysconf.h> |
| 32 | #include <../../../northbridge/amd/amdk8/acpi.h> |
| 33 | #include <arch/cpu.h> |
Vladimir Serbinenko | 4743254 | 2014-10-05 14:54:26 +0200 | [diff] [blame] | 34 | #include <cpu/amd/powernow.h> |
Josef Kellermann | bfa7ee5 | 2011-05-11 07:47:43 +0000 | [diff] [blame] | 35 | #include <southbridge/amd/rs690/rs690.h> |
Vladimir Serbinenko | 6985d4e | 2014-09-21 14:31:19 +0200 | [diff] [blame] | 36 | #include "mainboard.h" |
| 37 | #include <cbmem.h> |
Josef Kellermann | bfa7ee5 | 2011-05-11 07:47:43 +0000 | [diff] [blame] | 38 | |
Josef Kellermann | bfa7ee5 | 2011-05-11 07:47:43 +0000 | [diff] [blame] | 39 | #define GLOBAL_VARS_SIZE 0x100 |
| 40 | |
| 41 | typedef struct { |
| 42 | /* Miscellaneous */ |
| 43 | u16 osys; |
| 44 | u16 linx; |
| 45 | u32 pcba; |
| 46 | u8 mpen; |
| 47 | u8 reserv[247]; |
| 48 | } __attribute__((packed)) global_vars_t; |
| 49 | |
| 50 | static void acpi_write_gvars(global_vars_t *gvars) |
| 51 | { |
| 52 | device_t dev; |
| 53 | struct resource *res; |
| 54 | |
| 55 | memset((void *)gvars, 0, GLOBAL_VARS_SIZE); |
| 56 | |
| 57 | gvars->pcba = EXT_CONF_BASE_ADDRESS; |
| 58 | dev = dev_find_slot(0, PCI_DEVFN(0,0)); |
| 59 | res = probe_resource(dev, 0x1C); |
| 60 | if( res ) |
| 61 | gvars->pcba = res->base; |
| 62 | |
| 63 | gvars->mpen = 1; |
| 64 | } |
| 65 | |
Josef Kellermann | bfa7ee5 | 2011-05-11 07:47:43 +0000 | [diff] [blame] | 66 | unsigned long acpi_fill_madt(unsigned long current) |
| 67 | { |
| 68 | /* create all subtables for processors */ |
| 69 | current = acpi_create_madt_lapics(current); |
| 70 | |
| 71 | /* Write SB600 IOAPIC, only one */ |
| 72 | current += acpi_create_madt_ioapic((acpi_madt_ioapic_t *) current, 2, |
| 73 | IO_APIC_ADDR, 0); |
Patrick Georgi | e166782 | 2012-05-05 15:29:32 +0200 | [diff] [blame] | 74 | #if !CONFIG_LINT01_CONVERSION |
Josef Kellermann | bfa7ee5 | 2011-05-11 07:47:43 +0000 | [diff] [blame] | 75 | current += acpi_create_madt_irqoverride((acpi_madt_irqoverride_t *) |
| 76 | current, 0, 0, 2, 0); |
| 77 | |
| 78 | current += acpi_create_madt_irqoverride((acpi_madt_irqoverride_t *) |
| 79 | current, 0, 9, 9, MP_IRQ_TRIGGER_LEVEL | MP_IRQ_POLARITY_LOW); |
| 80 | #else |
| 81 | /* 0: mean bus 0--->ISA */ |
| 82 | /* 0: PIC 0 */ |
| 83 | /* 2: APIC 2 */ |
Kyösti Mälkki | d874757 | 2014-06-26 05:30:54 +0300 | [diff] [blame] | 84 | /* 5 mean: 0101 --> Edge-triggered, Active high */ |
Josef Kellermann | bfa7ee5 | 2011-05-11 07:47:43 +0000 | [diff] [blame] | 85 | |
| 86 | /* create all subtables for processors */ |
| 87 | current = acpi_create_madt_lapic_nmis(current, MP_IRQ_TRIGGER_EDGE | MP_IRQ_POLARITY_HIGH, 1); |
| 88 | /* 1: LINT1 connect to NMI */ |
| 89 | set_nbcfg_enable_bits(dev_find_slot(0, PCI_DEVFN(0x18, 0)), 0x68, 1 << 16, 1 << 16); // Local Interrupt Conversion Enable |
| 90 | #endif |
| 91 | return current; |
| 92 | } |
| 93 | |
Alexander Couzens | a90dad1 | 2015-04-12 21:49:46 +0200 | [diff] [blame^] | 94 | void mainboard_inject_dsdt(device_t device) |
Josef Kellermann | bfa7ee5 | 2011-05-11 07:47:43 +0000 | [diff] [blame] | 95 | { |
Vladimir Serbinenko | 6985d4e | 2014-09-21 14:31:19 +0200 | [diff] [blame] | 96 | global_vars_t *gnvs = cbmem_add (CBMEM_ID_ACPI_GNVS, GLOBAL_VARS_SIZE); |
Stefan Reinauer | 5ff7c13 | 2011-10-31 12:56:45 -0700 | [diff] [blame] | 97 | |
Vladimir Serbinenko | 6985d4e | 2014-09-21 14:31:19 +0200 | [diff] [blame] | 98 | if (gnvs) { |
Vladimir Serbinenko | 6985d4e | 2014-09-21 14:31:19 +0200 | [diff] [blame] | 99 | memset(gnvs, 0, sizeof(*gnvs)); |
| 100 | acpi_write_gvars(gnvs); |
Stefan Reinauer | 5ff7c13 | 2011-10-31 12:56:45 -0700 | [diff] [blame] | 101 | |
Vladimir Serbinenko | 6985d4e | 2014-09-21 14:31:19 +0200 | [diff] [blame] | 102 | /* Add it to SSDT. */ |
Vladimir Serbinenko | f845798 | 2014-11-04 21:18:25 +0100 | [diff] [blame] | 103 | acpigen_write_scope("\\"); |
| 104 | acpigen_write_name_dword("NVSA", (u32) gnvs); |
| 105 | acpigen_pop_len(); |
Josef Kellermann | bfa7ee5 | 2011-05-11 07:47:43 +0000 | [diff] [blame] | 106 | } |
Josef Kellermann | bfa7ee5 | 2011-05-11 07:47:43 +0000 | [diff] [blame] | 107 | } |
Vladimir Serbinenko | 6985d4e | 2014-09-21 14:31:19 +0200 | [diff] [blame] | 108 | |