blob: 93abea4b5bb9b68516ccc0157f417b6338549d6b [file] [log] [blame]
Timothy Pearsond3b2bbe2010-03-01 10:56:51 +00001/*
2 * This file is part of the coreboot project.
3 *
4 * Written by Stefan Reinauer <stepan@openbios.org>.
Stefan Reinauer14e22772010-04-27 06:56:47 +00005 * ACPI FADT, FACS, and DSDT table support added by
Timothy Pearsond3b2bbe2010-03-01 10:56:51 +00006 *
7 * Copyright (C) 2004 Stefan Reinauer <stepan@openbios.org>
8 * Copyright (C) 2005 Nick Barker <nick.barker9@btinternet.com>
9 * Copyright (C) 2007, 2008 Rudolf Marek <r.marek@assembler.cz>
10 * Copyright (C) 2009 Harald Gutmann <harald.gutmann@gmx.net>
11 *
12 * This program is free software; you can redistribute it and/or modify
Uwe Hermann2bb4acf2010-03-01 17:19:55 +000013 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; version 2 of the License.
Timothy Pearsond3b2bbe2010-03-01 10:56:51 +000015 *
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.
Timothy Pearsond3b2bbe2010-03-01 10:56:51 +000020 */
21
22#include <console/console.h>
23#include <string.h>
24#include <arch/acpi.h>
25#include <arch/smp/mpspec.h>
26#include <device/device.h>
27#include <device/pci_ids.h>
Vladimir Serbinenko47432542014-10-05 14:54:26 +020028#include <cpu/amd/powernow.h>
Timothy Pearsond3b2bbe2010-03-01 10:56:51 +000029#include <device/pci.h>
30#include <cpu/amd/amdfam10_sysconf.h>
31#include "mb_sysconf.h"
32
Timothy Pearsond3b2bbe2010-03-01 10:56:51 +000033unsigned long acpi_fill_madt(unsigned long current)
34{
35 unsigned int gsi_base = 0x18;
36 struct mb_sysconf_t *m;
37 //extern unsigned char bus_mcp55[8];
38 //extern unsigned apicid_mcp55;
Stefan Reinauer14e22772010-04-27 06:56:47 +000039
Timothy Pearsond3b2bbe2010-03-01 10:56:51 +000040 unsigned sbdn;
41 struct resource *res;
Elyes HAOUAS9740bcb2018-05-04 22:07:08 +020042 struct device *dev;
Timothy Pearsond3b2bbe2010-03-01 10:56:51 +000043
44 get_bus_conf();
45 sbdn = sysconf.sbdn;
46 m = sysconf.mb;
Stefan Reinauer14e22772010-04-27 06:56:47 +000047
Timothy Pearsond3b2bbe2010-03-01 10:56:51 +000048 /* Create all subtables for processors. */
49 current = acpi_create_madt_lapics(current);
50
51 /* Write SB IOAPIC. */
52 dev = dev_find_slot(m->bus_mcp55[0], PCI_DEVFN(sbdn+ 0x1,0));
53 if (dev) {
54 res = find_resource(dev, PCI_BASE_ADDRESS_1);
55 if (res) {
56 current += acpi_create_madt_ioapic((acpi_madt_ioapic_t *) current,
57 m->apicid_mcp55, res->base, 0);
58 }
59 }
60
61 /* Write NB IOAPIC. */
62 dev = dev_find_slot(m->bus_mcp55[0], PCI_DEVFN(sbdn+ 0x12,1));
63 if (dev) {
64 res = find_resource(dev, PCI_BASE_ADDRESS_1);
65 if (res) {
66 current += acpi_create_madt_ioapic((acpi_madt_ioapic_t *) current,
67 m->apicid_mcp55++, res->base, gsi_base);
68 }
69 }
70
71 /* IRQ9 ACPI active low. */
72 current += acpi_create_madt_irqoverride((acpi_madt_irqoverride_t *)
73 current, 0, 9, 9, MP_IRQ_TRIGGER_LEVEL | MP_IRQ_POLARITY_LOW);
74
75 /* IRQ0 -> APIC IRQ2. */
76 current += acpi_create_madt_irqoverride((acpi_madt_irqoverride_t *)
Stefan Reinauer14e22772010-04-27 06:56:47 +000077 current, 0, 0, 2, 0x0);
Timothy Pearsond3b2bbe2010-03-01 10:56:51 +000078
79 /* Create all subtables for processors. */
80 current = acpi_create_madt_lapic_nmis(current,
81 MP_IRQ_TRIGGER_EDGE | MP_IRQ_POLARITY_HIGH, 1);
82
83 return current;
84}