blob: a637637a84856e387d60b9345aa0e4f9d49e0307 [file] [log] [blame]
Jonathan A. Kollaschebbfbd52011-08-05 14:43:08 -05001/*
2 * ACPI support
3 * written by Stefan Reinauer <stepan@openbios.org>
4 * (C) 2005 Stefan Reinauer
5 *
6 *
7 * Copyright 2005 AMD
8 * 2005.9 yhlu modify that to more dynamic for AMD Opteron Based MB
9 */
10
Jonathan A. Kollaschebbfbd52011-08-05 14:43:08 -050011#include <arch/acpi.h>
Jonathan A. Kollaschebbfbd52011-08-05 14:43:08 -050012#include <arch/smp/mpspec.h>
13#include <device/pci.h>
Jonathan A. Kollasch7a75aff2015-06-23 09:15:08 -050014#include <assert.h>
Jonathan A. Kollaschebbfbd52011-08-05 14:43:08 -050015
16/* APIC */
17unsigned long acpi_fill_madt(unsigned long current)
18{
Elyes HAOUAS9740bcb2018-05-04 22:07:08 +020019 struct device *dev;
Jonathan A. Kollaschb6795252013-10-11 14:58:39 -050020 struct resource *res;
Jonathan A. Kollaschebbfbd52011-08-05 14:43:08 -050021
22 /* create all subtables for processors */
23 current = acpi_create_madt_lapics(current);
24
25 /* Write NVIDIA CK804 IOAPIC. */
26 dev = dev_find_slot(0x0, PCI_DEVFN(0x1,0));
Jonathan A. Kollaschb6795252013-10-11 14:58:39 -050027 ASSERT(dev != NULL);
28
29 res = find_resource(dev, PCI_BASE_ADDRESS_1);
30 ASSERT(res != NULL);
31
32 current += acpi_create_madt_ioapic((acpi_madt_ioapic_t *)current,
33 CONFIG_MAX_CPUS * CONFIG_MAX_PHYSICAL_CPUS, res->base, 0);
34
35 /* Initialize interrupt mapping if mptable.c didn't. */
Jonathan A. Kollaschebbfbd52011-08-05 14:43:08 -050036#if (!CONFIG_GENERATE_MP_TABLE)
37#error untested config
Jonathan A. Kollaschb6795252013-10-11 14:58:39 -050038 pci_write_config32(dev, 0x7c, 0x0120d218);
39 pci_write_config32(dev, 0x80, 0x12008a00);
40 pci_write_config32(dev, 0x84, 0x0000007d);
Jonathan A. Kollaschebbfbd52011-08-05 14:43:08 -050041#endif
Jonathan A. Kollaschebbfbd52011-08-05 14:43:08 -050042
Jonathan A. Kollaschebbfbd52011-08-05 14:43:08 -050043 /* IRQ9 */
44 current += acpi_create_madt_irqoverride((acpi_madt_irqoverride_t *)
45 current, 0, 9, 9, MP_IRQ_TRIGGER_LEVEL | MP_IRQ_POLARITY_LOW);
46
47 /* create all subtables for processors */
48 /* acpi_create_madt_lapic_nmis returns current, not size. */
49 current = acpi_create_madt_lapic_nmis(current,
50 MP_IRQ_TRIGGER_EDGE | MP_IRQ_POLARITY_HIGH, 1);
51
52 return current;
53}