Marc Jones | ccfaf25 | 2020-09-28 12:06:36 -0600 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
| 2 | |
Marc Jones | ccfaf25 | 2020-09-28 12:06:36 -0600 | [diff] [blame] | 3 | #include <acpi/acpigen.h> |
| 4 | #include <arch/smp/mpspec.h> |
Felix Held | 97439ec | 2023-06-05 19:30:23 +0200 | [diff] [blame] | 5 | #include <arch/vga.h> |
Marc Jones | ccfaf25 | 2020-09-28 12:06:36 -0600 | [diff] [blame] | 6 | #include <assert.h> |
Marc Jones | ccfaf25 | 2020-09-28 12:06:36 -0600 | [diff] [blame] | 7 | #include <cpu/intel/turbo.h> |
| 8 | #include <device/mmio.h> |
| 9 | #include <device/pci.h> |
Marc Jones | 63e2a84 | 2020-12-02 11:33:02 -0700 | [diff] [blame] | 10 | #include <intelblocks/acpi.h> |
Marc Jones | ccfaf25 | 2020-09-28 12:06:36 -0600 | [diff] [blame] | 11 | #include <soc/acpi.h> |
Marc Jones | ccfaf25 | 2020-09-28 12:06:36 -0600 | [diff] [blame] | 12 | #include <soc/iomap.h> |
Marc Jones | ccfaf25 | 2020-09-28 12:06:36 -0600 | [diff] [blame] | 13 | #include <soc/msr.h> |
| 14 | #include <soc/pci_devs.h> |
| 15 | #include <soc/pm.h> |
| 16 | #include <soc/soc_util.h> |
Arthur Heymans | 83b2622 | 2020-11-06 11:50:55 +0100 | [diff] [blame] | 17 | #include <soc/util.h> |
Marc Jones | ccfaf25 | 2020-09-28 12:06:36 -0600 | [diff] [blame] | 18 | |
Marc Jones | ccfaf25 | 2020-09-28 12:06:36 -0600 | [diff] [blame] | 19 | int soc_madt_sci_irq_polarity(int sci) |
| 20 | { |
| 21 | if (sci >= 20) |
| 22 | return MP_IRQ_POLARITY_LOW; |
| 23 | else |
| 24 | return MP_IRQ_POLARITY_HIGH; |
| 25 | } |
| 26 | |
| 27 | uint32_t soc_read_sci_irq_select(void) |
| 28 | { |
| 29 | struct device *dev = PCH_DEV_PMC; |
| 30 | |
| 31 | if (!dev) |
| 32 | return 0; |
| 33 | |
| 34 | return pci_read_config32(dev, PMC_ACPI_CNT); |
| 35 | } |
| 36 | |
Marc Jones | 3fc0484 | 2020-10-19 16:08:27 -0600 | [diff] [blame] | 37 | void soc_fill_fadt(acpi_fadt_t *fadt) |
| 38 | { |
| 39 | const uint16_t pmbase = ACPI_BASE_ADDRESS; |
| 40 | |
| 41 | /* Fix flags set by common/block/acpi/acpi.c acpi_fill_fadt() */ |
| 42 | fadt->flags &= ~(ACPI_FADT_SEALED_CASE); |
| 43 | fadt->flags |= ACPI_FADT_SLEEP_TYPE; |
| 44 | |
| 45 | fadt->pm2_cnt_blk = pmbase + PM2_CNT; |
| 46 | fadt->pm_tmr_blk = pmbase + PM1_TMR; |
| 47 | |
| 48 | fadt->pm2_cnt_len = 1; |
| 49 | fadt->pm_tmr_len = 4; |
| 50 | |
Marc Jones | 3fc0484 | 2020-10-19 16:08:27 -0600 | [diff] [blame] | 51 | fadt->iapc_boot_arch = ACPI_FADT_LEGACY_DEVICES | ACPI_FADT_8042; |
| 52 | |
Kyösti Mälkki | 88decca | 2023-04-28 07:04:34 +0300 | [diff] [blame] | 53 | /* PM Extended Registers */ |
| 54 | fill_fadt_extended_pm_io(fadt); |
Marc Jones | 3fc0484 | 2020-10-19 16:08:27 -0600 | [diff] [blame] | 55 | } |
| 56 | |
Arthur Heymans | cd6fed2 | 2022-12-08 17:27:11 +0100 | [diff] [blame^] | 57 | void uncore_fill_ssdt(const struct device *device) |
Marc Jones | ccfaf25 | 2020-09-28 12:06:36 -0600 | [diff] [blame] | 58 | { |
Arthur Heymans | 83b2622 | 2020-11-06 11:50:55 +0100 | [diff] [blame] | 59 | const IIO_UDS *hob = get_iio_uds(); |
Marc Jones | ccfaf25 | 2020-09-28 12:06:36 -0600 | [diff] [blame] | 60 | |
Marc Jones | 2c70716 | 2020-10-31 15:29:14 -0600 | [diff] [blame] | 61 | /* Only add RTxx entries once. */ |
| 62 | if (device->bus->secondary != 0) |
| 63 | return; |
| 64 | |
Patrick Rudolph | ac02857 | 2023-07-14 17:44:33 +0200 | [diff] [blame] | 65 | for (int socket = 0, iio = 0; iio < hob->PlatformData.numofIIO; ++socket) { |
| 66 | if (!soc_cpu_is_enabled(socket)) |
| 67 | continue; |
| 68 | iio++; |
Marc Jones | ccfaf25 | 2020-09-28 12:06:36 -0600 | [diff] [blame] | 69 | IIO_RESOURCE_INSTANCE iio_resource = |
| 70 | hob->PlatformData.IIO_resource[socket]; |
| 71 | for (int stack = 0; stack <= PSTACK2; ++stack) { |
| 72 | const STACK_RES *ri = &iio_resource.StackRes[stack]; |
| 73 | char rtname[16]; |
Marc Jones | ccfaf25 | 2020-09-28 12:06:36 -0600 | [diff] [blame] | 74 | |
Arthur Heymans | cd6fed2 | 2022-12-08 17:27:11 +0100 | [diff] [blame^] | 75 | snprintf(rtname, sizeof(rtname), "\\_SB.PC%02x", socket * MAX_IIO_STACK + stack); |
| 76 | acpigen_write_scope(rtname); |
| 77 | |
| 78 | acpigen_write_name("_CRS"); |
| 79 | |
Marc Jones | ccfaf25 | 2020-09-28 12:06:36 -0600 | [diff] [blame] | 80 | printk(BIOS_DEBUG, "\tCreating ResourceTemplate %s for socket: %d, stack: %d\n", |
| 81 | rtname, socket, stack); |
| 82 | |
| 83 | acpigen_write_resourcetemplate_header(); |
| 84 | |
| 85 | /* bus resource */ |
| 86 | acpigen_resource_word(2, 0xc, 0, 0, ri->BusBase, ri->BusLimit, |
| 87 | 0x0, (ri->BusLimit - ri->BusBase + 1)); |
| 88 | |
| 89 | // additional io resources on socket 0 bus 0 |
| 90 | if (socket == 0 && stack == 0) { |
| 91 | /* ACPI 6.4.2.5 I/O Port Descriptor */ |
| 92 | acpigen_write_io16(0xCF8, 0xCFF, 0x1, 0x8, 1); |
| 93 | |
| 94 | /* IO decode CF8-CFF */ |
| 95 | acpigen_resource_word(1, 0xc, 0x3, 0, 0x0000, 0x03AF, |
| 96 | 0, 0x03B0); |
| 97 | acpigen_resource_word(1, 0xc, 0x3, 0, 0x03E0, 0x0CF7, |
| 98 | 0, 0x0918); |
| 99 | acpigen_resource_word(1, 0xc, 0x3, 0, 0x03B0, 0x03BB, |
| 100 | 0, 0x000C); |
| 101 | acpigen_resource_word(1, 0xc, 0x3, 0, 0x03C0, 0x03DF, |
| 102 | 0, 0x0020); |
| 103 | } |
| 104 | |
| 105 | /* IO resource */ |
| 106 | acpigen_resource_word(1, 0xc, 0x3, 0, ri->PciResourceIoBase, |
| 107 | ri->PciResourceIoLimit, 0x0, |
| 108 | (ri->PciResourceIoLimit - ri->PciResourceIoBase + 1)); |
| 109 | |
| 110 | // additional mem32 resources on socket 0 bus 0 |
| 111 | if (socket == 0 && stack == 0) { |
Felix Held | 97439ec | 2023-06-05 19:30:23 +0200 | [diff] [blame] | 112 | acpigen_resource_dword(0, 0xc, 3, 0, VGA_MMIO_BASE, |
| 113 | VGA_MMIO_LIMIT, 0x0, VGA_MMIO_SIZE); |
Marc Jones | ccfaf25 | 2020-09-28 12:06:36 -0600 | [diff] [blame] | 114 | acpigen_resource_dword(0, 0xc, 1, 0, SPI_BASE_ADDRESS, |
| 115 | (SPI_BASE_ADDRESS + SPI_BASE_SIZE - 1), 0x0, |
| 116 | SPI_BASE_SIZE); |
| 117 | } |
| 118 | |
| 119 | /* Mem32 resource */ |
| 120 | acpigen_resource_dword(0, 0xc, 1, 0, ri->PciResourceMem32Base, |
| 121 | ri->PciResourceMem32Limit, 0x0, |
| 122 | (ri->PciResourceMem32Limit - ri->PciResourceMem32Base + 1)); |
| 123 | |
| 124 | /* Mem64 resource */ |
| 125 | acpigen_resource_qword(0, 0xc, 1, 0, ri->PciResourceMem64Base, |
| 126 | ri->PciResourceMem64Limit, 0x0, |
| 127 | (ri->PciResourceMem64Limit - ri->PciResourceMem64Base + 1)); |
| 128 | |
| 129 | acpigen_write_resourcetemplate_footer(); |
Arthur Heymans | cd6fed2 | 2022-12-08 17:27:11 +0100 | [diff] [blame^] | 130 | |
| 131 | /* Scope */ |
| 132 | acpigen_pop_len(); |
Marc Jones | ccfaf25 | 2020-09-28 12:06:36 -0600 | [diff] [blame] | 133 | } |
| 134 | } |
Marc Jones | ccfaf25 | 2020-09-28 12:06:36 -0600 | [diff] [blame] | 135 | } |
| 136 | |
Marc Jones | 7a25fb8 | 2020-10-19 16:32:05 -0600 | [diff] [blame] | 137 | void soc_power_states_generation(int core, int cores_per_package) |
| 138 | { |
| 139 | } |