Timothy Pearson | 8057285 | 2015-01-23 20:35:48 -0600 | [diff] [blame] | 1 | /* |
Noah Glovsky | 7f268ea | 2016-04-27 13:09:15 -0600 | [diff] [blame] | 2 | * 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 Pearson | 8057285 | 2015-01-23 20:35:48 -0600 | [diff] [blame] | 13 | * 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 Pearson | 8057285 | 2015-01-23 20:35:48 -0600 | [diff] [blame] | 23 | #include <string.h> |
| 24 | #include <assert.h> |
| 25 | #include <arch/acpi.h> |
Kyösti Mälkki | f1b58b7 | 2019-03-01 13:43:02 +0200 | [diff] [blame] | 26 | #include <device/pci_ops.h> |
Timothy Pearson | 8057285 | 2015-01-23 20:35:48 -0600 | [diff] [blame] | 27 | #include <arch/smp/mpspec.h> |
| 28 | #include <device/pci.h> |
Timothy Pearson | 8057285 | 2015-01-23 20:35:48 -0600 | [diff] [blame] | 29 | #include <cpu/amd/amdfam10_sysconf.h> |
| 30 | |
| 31 | /* APIC */ |
| 32 | unsigned long acpi_fill_madt(unsigned long current) |
| 33 | { |
Elyes HAOUAS | 02b05d1 | 2018-05-04 20:00:08 +0200 | [diff] [blame] | 34 | struct device *dev; |
Timothy Pearson | 8057285 | 2015-01-23 20:35:48 -0600 | [diff] [blame] | 35 | 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älkki | c70eed1 | 2018-05-22 02:18:00 +0300 | [diff] [blame] | 41 | dev = pcidev_on_root(sysconf.sbdn + 0x1, 0); |
Timothy Pearson | 8057285 | 2015-01-23 20:35:48 -0600 | [diff] [blame] | 42 | 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 Pearson | 8057285 | 2015-01-23 20:35:48 -0600 | [diff] [blame] | 59 | /* 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 | } |