blob: 3188af398d5bc3f93492c5ded320a71328a4bee6 [file] [log] [blame]
Harald Gutmann62cfe162009-06-19 12:03:40 +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
Harald Gutmann62cfe162009-06-19 12:03:40 +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 Hermannc70e9fc2010-02-15 23:10:19 +000013 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; version 2 of the License.
Harald Gutmann62cfe162009-06-19 12:03:40 +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.
Harald Gutmann62cfe162009-06-19 12:03:40 +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>
stepan8301d832010-12-08 07:07:33 +000028#include "northbridge/amd/amdk8/acpi.h"
Vladimir Serbinenko47432542014-10-05 14:54:26 +020029#include <cpu/amd/powernow.h>
Harald Gutmann62cfe162009-06-19 12:03:40 +000030#include <device/pci.h>
31#include <cpu/amd/amdk8_sysconf.h>
32
Harald Gutmann62cfe162009-06-19 12:03:40 +000033unsigned long acpi_fill_madt(unsigned long current)
34{
35 unsigned int gsi_base = 0x18;
36 extern unsigned char bus_mcp55[8];
37 extern unsigned apicid_mcp55;
Stefan Reinauer14e22772010-04-27 06:56:47 +000038
Harald Gutmann62cfe162009-06-19 12:03:40 +000039 unsigned sbdn;
40 struct resource *res;
41 device_t dev;
42
43 get_bus_conf();
44 sbdn = sysconf.sbdn;
Stefan Reinauer14e22772010-04-27 06:56:47 +000045
Harald Gutmann62cfe162009-06-19 12:03:40 +000046 /* Create all subtables for processors. */
47 current = acpi_create_madt_lapics(current);
48
49 /* Write SB IOAPIC. */
50 dev = dev_find_slot(bus_mcp55[0], PCI_DEVFN(sbdn+ 0x1,0));
51 if (dev) {
52 res = find_resource(dev, PCI_BASE_ADDRESS_1);
53 if (res) {
54 current += acpi_create_madt_ioapic((acpi_madt_ioapic_t *) current,
55 apicid_mcp55, res->base, 0);
56 }
57 }
58
59 /* Write NB IOAPIC. */
60 dev = dev_find_slot(bus_mcp55[0], PCI_DEVFN(sbdn+ 0x12,1));
61 if (dev) {
62 res = find_resource(dev, PCI_BASE_ADDRESS_1);
63 if (res) {
64 current += acpi_create_madt_ioapic((acpi_madt_ioapic_t *) current,
65 apicid_mcp55++, res->base, gsi_base);
66 }
67 }
68
69 /* IRQ9 ACPI active low. */
70 current += acpi_create_madt_irqoverride((acpi_madt_irqoverride_t *)
71 current, 0, 9, 9, MP_IRQ_TRIGGER_LEVEL | MP_IRQ_POLARITY_LOW);
72
73 /* IRQ0 -> APIC IRQ2. */
74 current += acpi_create_madt_irqoverride((acpi_madt_irqoverride_t *)
Stefan Reinauer14e22772010-04-27 06:56:47 +000075 current, 0, 0, 2, 0x0);
Harald Gutmann62cfe162009-06-19 12:03:40 +000076
77 /* Create all subtables for processors. */
78 current = acpi_create_madt_lapic_nmis(current,
79 MP_IRQ_TRIGGER_EDGE | MP_IRQ_POLARITY_HIGH, 1);
80
81 return current;
82}