blob: 1ff0c5d0e78deac4d8c5579818979b0b08e504fa [file] [log] [blame]
Josef Kellermannbfa7ee52011-05-11 07:47:43 +00001/*
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
Paul Menzela46a7122013-02-23 18:37:27 +010019 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Josef Kellermannbfa7ee52011-05-11 07:47:43 +000020 */
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 Serbinenko47432542014-10-05 14:54:26 +020034#include <cpu/amd/powernow.h>
Josef Kellermannbfa7ee52011-05-11 07:47:43 +000035#include <southbridge/amd/rs690/rs690.h>
Vladimir Serbinenko6985d4e2014-09-21 14:31:19 +020036#include "mainboard.h"
37#include <cbmem.h>
Josef Kellermannbfa7ee52011-05-11 07:47:43 +000038
Josef Kellermannbfa7ee52011-05-11 07:47:43 +000039#define GLOBAL_VARS_SIZE 0x100
40
41typedef 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
50static 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 Kellermannbfa7ee52011-05-11 07:47:43 +000066unsigned 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 Georgie1667822012-05-05 15:29:32 +020074#if !CONFIG_LINT01_CONVERSION
Josef Kellermannbfa7ee52011-05-11 07:47:43 +000075 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älkkid8747572014-06-26 05:30:54 +030084 /* 5 mean: 0101 --> Edge-triggered, Active high */
Josef Kellermannbfa7ee52011-05-11 07:47:43 +000085
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
Vladimir Serbinenko6985d4e2014-09-21 14:31:19 +020094void mainboard_inject_dsdt(void)
Josef Kellermannbfa7ee52011-05-11 07:47:43 +000095{
Vladimir Serbinenko6985d4e2014-09-21 14:31:19 +020096 global_vars_t *gnvs = cbmem_add (CBMEM_ID_ACPI_GNVS, GLOBAL_VARS_SIZE);
Stefan Reinauer5ff7c132011-10-31 12:56:45 -070097
Vladimir Serbinenko6985d4e2014-09-21 14:31:19 +020098 if (gnvs) {
Vladimir Serbinenko6985d4e2014-09-21 14:31:19 +020099 memset(gnvs, 0, sizeof(*gnvs));
100 acpi_write_gvars(gnvs);
Stefan Reinauer5ff7c132011-10-31 12:56:45 -0700101
Vladimir Serbinenko6985d4e2014-09-21 14:31:19 +0200102 /* Add it to SSDT. */
Vladimir Serbinenkof8457982014-11-04 21:18:25 +0100103 acpigen_write_scope("\\");
104 acpigen_write_name_dword("NVSA", (u32) gnvs);
105 acpigen_pop_len();
Josef Kellermannbfa7ee52011-05-11 07:47:43 +0000106 }
Josef Kellermannbfa7ee52011-05-11 07:47:43 +0000107}
Vladimir Serbinenko6985d4e2014-09-21 14:31:19 +0200108