blob: ad6687e63d4ca82313ac353544267adda9eab366 [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.
Josef Kellermannbfa7ee52011-05-11 07:47:43 +000016 */
17
18#include <console/console.h>
19#include <string.h>
20#include <arch/acpi.h>
21#include <arch/ioapic.h>
22#include <arch/smp/mpspec.h>
23#include <device/pci.h>
24#include <device/pci_ids.h>
25#include <cpu/x86/msr.h>
26#include <cpu/amd/mtrr.h>
27#include <cpu/amd/amdk8_sysconf.h>
28#include <../../../northbridge/amd/amdk8/acpi.h>
29#include <arch/cpu.h>
Vladimir Serbinenko47432542014-10-05 14:54:26 +020030#include <cpu/amd/powernow.h>
Josef Kellermannbfa7ee52011-05-11 07:47:43 +000031#include <southbridge/amd/rs690/rs690.h>
Vladimir Serbinenko6985d4e2014-09-21 14:31:19 +020032#include "mainboard.h"
33#include <cbmem.h>
Josef Kellermannbfa7ee52011-05-11 07:47:43 +000034
Josef Kellermannbfa7ee52011-05-11 07:47:43 +000035#define GLOBAL_VARS_SIZE 0x100
36
37typedef struct {
38 /* Miscellaneous */
39 u16 osys;
40 u16 linx;
41 u32 pcba;
42 u8 mpen;
43 u8 reserv[247];
44} __attribute__((packed)) global_vars_t;
45
46static void acpi_write_gvars(global_vars_t *gvars)
47{
48 device_t dev;
49 struct resource *res;
50
51 memset((void *)gvars, 0, GLOBAL_VARS_SIZE);
52
53 gvars->pcba = EXT_CONF_BASE_ADDRESS;
54 dev = dev_find_slot(0, PCI_DEVFN(0,0));
55 res = probe_resource(dev, 0x1C);
56 if( res )
57 gvars->pcba = res->base;
58
59 gvars->mpen = 1;
60}
61
Josef Kellermannbfa7ee52011-05-11 07:47:43 +000062unsigned long acpi_fill_madt(unsigned long current)
63{
64 /* create all subtables for processors */
65 current = acpi_create_madt_lapics(current);
66
67 /* Write SB600 IOAPIC, only one */
68 current += acpi_create_madt_ioapic((acpi_madt_ioapic_t *) current, 2,
69 IO_APIC_ADDR, 0);
Patrick Georgie1667822012-05-05 15:29:32 +020070#if !CONFIG_LINT01_CONVERSION
Josef Kellermannbfa7ee52011-05-11 07:47:43 +000071 current += acpi_create_madt_irqoverride((acpi_madt_irqoverride_t *)
72 current, 0, 0, 2, 0);
73
74 current += acpi_create_madt_irqoverride((acpi_madt_irqoverride_t *)
75 current, 0, 9, 9, MP_IRQ_TRIGGER_LEVEL | MP_IRQ_POLARITY_LOW);
76#else
77 /* 0: mean bus 0--->ISA */
78 /* 0: PIC 0 */
79 /* 2: APIC 2 */
Kyösti Mälkkid8747572014-06-26 05:30:54 +030080 /* 5 mean: 0101 --> Edge-triggered, Active high */
Josef Kellermannbfa7ee52011-05-11 07:47:43 +000081
82 /* create all subtables for processors */
83 current = acpi_create_madt_lapic_nmis(current, MP_IRQ_TRIGGER_EDGE | MP_IRQ_POLARITY_HIGH, 1);
84 /* 1: LINT1 connect to NMI */
85 set_nbcfg_enable_bits(dev_find_slot(0, PCI_DEVFN(0x18, 0)), 0x68, 1 << 16, 1 << 16); // Local Interrupt Conversion Enable
86#endif
87 return current;
88}
89
Alexander Couzensa90dad12015-04-12 21:49:46 +020090void mainboard_inject_dsdt(device_t device)
Josef Kellermannbfa7ee52011-05-11 07:47:43 +000091{
Vladimir Serbinenko6985d4e2014-09-21 14:31:19 +020092 global_vars_t *gnvs = cbmem_add (CBMEM_ID_ACPI_GNVS, GLOBAL_VARS_SIZE);
Stefan Reinauer5ff7c132011-10-31 12:56:45 -070093
Vladimir Serbinenko6985d4e2014-09-21 14:31:19 +020094 if (gnvs) {
Vladimir Serbinenko6985d4e2014-09-21 14:31:19 +020095 memset(gnvs, 0, sizeof(*gnvs));
96 acpi_write_gvars(gnvs);
Stefan Reinauer5ff7c132011-10-31 12:56:45 -070097
Vladimir Serbinenko6985d4e2014-09-21 14:31:19 +020098 /* Add it to SSDT. */
Vladimir Serbinenkof8457982014-11-04 21:18:25 +010099 acpigen_write_scope("\\");
100 acpigen_write_name_dword("NVSA", (u32) gnvs);
101 acpigen_pop_len();
Josef Kellermannbfa7ee52011-05-11 07:47:43 +0000102 }
Josef Kellermannbfa7ee52011-05-11 07:47:43 +0000103}