Timothy Pearson | ab95702 | 2015-10-28 02:59:40 -0500 | [diff] [blame] | 1 | /* |
| 2 | * ACPI support |
| 3 | * written by Stefan Reinauer <stepan@openbios.org> |
| 4 | * (C) 2005 Stefan Reinauer |
| 5 | * |
| 6 | * Copyright 2005 AMD |
| 7 | * 2005.9 yhlu modify that to more dynamic for AMD Opteron Based MB |
| 8 | * |
| 9 | * Copyright (C) 2015 Timothy Pearson <tpearson@raptorengineeringinc.com>, Raptor Engineering |
| 10 | */ |
| 11 | |
| 12 | #include <console/console.h> |
| 13 | #include <string.h> |
| 14 | #include <assert.h> |
| 15 | #include <arch/acpi.h> |
| 16 | #include <arch/io.h> |
| 17 | #include <arch/smp/mpspec.h> |
| 18 | #include <device/pci.h> |
| 19 | #include <device/pci_ids.h> |
| 20 | #include <cpu/x86/msr.h> |
| 21 | #include <cpu/amd/mtrr.h> |
Timothy Pearson | 7046024 | 2015-11-01 02:41:39 -0600 | [diff] [blame] | 22 | #include <cpu/amd/amdk8_sysconf.h> |
Timothy Pearson | ab95702 | 2015-10-28 02:59:40 -0500 | [diff] [blame] | 23 | |
| 24 | /* APIC */ |
| 25 | unsigned long acpi_fill_madt(unsigned long current) |
| 26 | { |
| 27 | device_t dev; |
| 28 | struct resource *res; |
| 29 | |
| 30 | /* create all subtables for processors */ |
| 31 | current = acpi_create_madt_lapics(current); |
| 32 | |
| 33 | /* Write NVIDIA CK804 IOAPIC. */ |
| 34 | dev = dev_find_slot(0x0, PCI_DEVFN(sysconf.sbdn + 0x1, 0)); |
| 35 | ASSERT(dev != NULL); |
| 36 | |
| 37 | res = find_resource(dev, PCI_BASE_ADDRESS_1); |
| 38 | ASSERT(res != NULL); |
| 39 | |
| 40 | current += acpi_create_madt_ioapic((acpi_madt_ioapic_t *)current, |
| 41 | CONFIG_MAX_CPUS * CONFIG_MAX_PHYSICAL_CPUS, res->base, 0); |
| 42 | |
| 43 | /* Initialize interrupt mapping if mptable.c didn't. */ |
| 44 | if (!IS_ENABLED(CONFIG_GENERATE_MP_TABLE)) { |
| 45 | /* Copied from mptable.c */ |
| 46 | /* Enable interrupts for commonly used devices (USB, SATA, etc.) */ |
| 47 | pci_write_config32(dev, 0x7c, 0x0d800018); |
| 48 | pci_write_config32(dev, 0x80, 0xd8002009); |
| 49 | pci_write_config32(dev, 0x84, 0x00000001); |
| 50 | } |
| 51 | |
| 52 | // /* IRQ of timer (override IRQ0 --> APIC IRQ2) */ |
| 53 | // current += acpi_create_madt_irqoverride((acpi_madt_irqoverride_t *) |
| 54 | // current, 0, 0, 2, 0); |
| 55 | /* IRQ9 */ |
| 56 | current += acpi_create_madt_irqoverride((acpi_madt_irqoverride_t *) |
| 57 | current, 0, 9, 9, MP_IRQ_TRIGGER_LEVEL | MP_IRQ_POLARITY_HIGH); |
| 58 | /* IRQ14 */ |
| 59 | current += acpi_create_madt_irqoverride((acpi_madt_irqoverride_t *) |
| 60 | current, 0, 14, 14, MP_IRQ_TRIGGER_EDGE | MP_IRQ_POLARITY_HIGH); |
| 61 | /* IRQ15 */ |
| 62 | current += acpi_create_madt_irqoverride((acpi_madt_irqoverride_t *) |
| 63 | current, 0, 15, 15, MP_IRQ_TRIGGER_EDGE | MP_IRQ_POLARITY_HIGH); |
| 64 | |
| 65 | /* create all subtables for processors */ |
| 66 | /* acpi_create_madt_lapic_nmis returns current, not size. */ |
| 67 | current = acpi_create_madt_lapic_nmis(current, |
| 68 | MP_IRQ_TRIGGER_EDGE | MP_IRQ_POLARITY_HIGH, 1); |
| 69 | |
| 70 | return current; |
| 71 | } |