blob: ce3d4178da0d53db26d84cbaa5ed08dd96685d87 [file] [log] [blame]
Timothy Pearson80572852015-01-23 20:35:48 -06001/*
Noah Glovsky7f268ea2016-04-27 13:09:15 -06002 * This file is part of the coreboot project.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 2 of the License.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
Timothy Pearson80572852015-01-23 20:35:48 -060013 * ACPI support
14 * written by Stefan Reinauer <stepan@openbios.org>
15 * (C) 2005 Stefan Reinauer
16 *
17 * Copyright 2005 AMD
18 * 2005.9 yhlu modify that to more dynamic for AMD Opteron Based MB
19 *
20 * Copyright (C) 2015 Timothy Pearson <tpearson@raptorengineeringinc.com>, Raptor Engineering
21 */
22
Timothy Pearson80572852015-01-23 20:35:48 -060023#include <string.h>
24#include <assert.h>
25#include <arch/acpi.h>
Kyösti Mälkkif1b58b72019-03-01 13:43:02 +020026#include <device/pci_ops.h>
Timothy Pearson80572852015-01-23 20:35:48 -060027#include <arch/smp/mpspec.h>
28#include <device/pci.h>
Timothy Pearson80572852015-01-23 20:35:48 -060029#include <cpu/amd/amdfam10_sysconf.h>
30
31/* APIC */
32unsigned long acpi_fill_madt(unsigned long current)
33{
Elyes HAOUAS02b05d12018-05-04 20:00:08 +020034 struct device *dev;
Timothy Pearson80572852015-01-23 20:35:48 -060035 struct resource *res;
36
37 /* create all subtables for processors */
38 current = acpi_create_madt_lapics(current);
39
40 /* Write NVIDIA CK804 IOAPIC. */
Kyösti Mälkkic70eed12018-05-22 02:18:00 +030041 dev = pcidev_on_root(sysconf.sbdn + 0x1, 0);
Timothy Pearson80572852015-01-23 20:35:48 -060042 ASSERT(dev != NULL);
43
44 res = find_resource(dev, PCI_BASE_ADDRESS_1);
45 ASSERT(res != NULL);
46
47 current += acpi_create_madt_ioapic((acpi_madt_ioapic_t *)current,
48 CONFIG_MAX_CPUS * CONFIG_MAX_PHYSICAL_CPUS, res->base, 0);
49
50 /* Initialize interrupt mapping if mptable.c didn't. */
51 if (!IS_ENABLED(CONFIG_GENERATE_MP_TABLE)) {
52 /* Copied from mptable.c */
53 /* Enable interrupts for commonly used devices (USB, SATA, etc.) */
54 pci_write_config32(dev, 0x7c, 0x0d800018);
55 pci_write_config32(dev, 0x80, 0xd8002009);
56 pci_write_config32(dev, 0x84, 0x00000001);
57 }
58
Timothy Pearson80572852015-01-23 20:35:48 -060059 /* IRQ9 */
60 current += acpi_create_madt_irqoverride((acpi_madt_irqoverride_t *)
61 current, 0, 9, 9, MP_IRQ_TRIGGER_LEVEL | MP_IRQ_POLARITY_HIGH);
62 /* IRQ14 */
63 current += acpi_create_madt_irqoverride((acpi_madt_irqoverride_t *)
64 current, 0, 14, 14, MP_IRQ_TRIGGER_EDGE | MP_IRQ_POLARITY_HIGH);
65 /* IRQ15 */
66 current += acpi_create_madt_irqoverride((acpi_madt_irqoverride_t *)
67 current, 0, 15, 15, MP_IRQ_TRIGGER_EDGE | MP_IRQ_POLARITY_HIGH);
68
69 /* create all subtables for processors */
70 /* acpi_create_madt_lapic_nmis returns current, not size. */
71 current = acpi_create_madt_lapic_nmis(current,
72 MP_IRQ_TRIGGER_EDGE | MP_IRQ_POLARITY_HIGH, 1);
73
74 return current;
75}