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