Angel Pons | 2bd25bf | 2020-07-12 14:13:40 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
| 2 | |
| 3 | #include <device/pci_ops.h> |
| 4 | #include <acpi/acpi.h> |
Angel Pons | 2bd25bf | 2020-07-12 14:13:40 +0200 | [diff] [blame] | 5 | #include <southbridge/intel/lynxpoint/pch.h> |
| 6 | #include "chip.h" |
| 7 | |
| 8 | void acpi_fill_fadt(acpi_fadt_t *fadt) |
| 9 | { |
| 10 | struct device *dev = pcidev_on_root(0x1f, 0); |
| 11 | struct southbridge_intel_lynxpoint_config *cfg = dev->chip_info; |
| 12 | u16 pmbase = get_pmbase(); |
| 13 | |
Angel Pons | 2bd25bf | 2020-07-12 14:13:40 +0200 | [diff] [blame] | 14 | |
| 15 | fadt->pm1a_evt_blk = pmbase + PM1_STS; |
Angel Pons | 2bd25bf | 2020-07-12 14:13:40 +0200 | [diff] [blame] | 16 | fadt->pm1a_cnt_blk = pmbase + PM1_CNT; |
Angel Pons | 2bd25bf | 2020-07-12 14:13:40 +0200 | [diff] [blame] | 17 | fadt->pm2_cnt_blk = pmbase + PM2_CNT; |
| 18 | fadt->pm_tmr_blk = pmbase + PM1_TMR; |
| 19 | if (pch_is_lp()) |
| 20 | fadt->gpe0_blk = pmbase + LP_GPE0_STS_1; |
| 21 | else |
| 22 | fadt->gpe0_blk = pmbase + GPE0_STS; |
Angel Pons | 2bd25bf | 2020-07-12 14:13:40 +0200 | [diff] [blame] | 23 | |
| 24 | /* |
| 25 | * Some of the lengths here are doubled. This is because they describe |
| 26 | * blocks containing two registers, where the size of each register |
| 27 | * is found by halving the block length. See Table 5-34 and section |
| 28 | * 4.8.3 of the ACPI specification for details. |
| 29 | */ |
| 30 | fadt->pm1_evt_len = 2 * 2; |
| 31 | fadt->pm1_cnt_len = 2; |
| 32 | fadt->pm2_cnt_len = 1; |
| 33 | fadt->pm_tmr_len = 4; |
| 34 | if (pch_is_lp()) |
| 35 | fadt->gpe0_blk_len = 2 * 16; |
| 36 | else |
| 37 | fadt->gpe0_blk_len = 2 * 8; |
Angel Pons | 2bd25bf | 2020-07-12 14:13:40 +0200 | [diff] [blame] | 38 | |
Angel Pons | 2bd25bf | 2020-07-12 14:13:40 +0200 | [diff] [blame] | 39 | fadt->iapc_boot_arch = ACPI_FADT_LEGACY_DEVICES | ACPI_FADT_8042; |
| 40 | |
Angel Pons | a208c6c | 2020-07-13 00:02:34 +0200 | [diff] [blame] | 41 | fadt->flags |= ACPI_FADT_WBINVD | |
| 42 | ACPI_FADT_C1_SUPPORTED | |
Angel Pons | a208c6c | 2020-07-13 00:02:34 +0200 | [diff] [blame] | 43 | ACPI_FADT_SLEEP_BUTTON | |
Angel Pons | a208c6c | 2020-07-13 00:02:34 +0200 | [diff] [blame] | 44 | ACPI_FADT_SEALED_CASE | |
| 45 | ACPI_FADT_S4_RTC_WAKE | |
| 46 | ACPI_FADT_PLATFORM_CLOCK; |
Angel Pons | 2bd25bf | 2020-07-12 14:13:40 +0200 | [diff] [blame] | 47 | |
Angel Pons | cbcbb67 | 2020-10-23 00:11:26 +0200 | [diff] [blame] | 48 | if (cfg && cfg->docking_supported) |
Angel Pons | 2bd25bf | 2020-07-12 14:13:40 +0200 | [diff] [blame] | 49 | fadt->flags |= ACPI_FADT_DOCKING_SUPPORTED; |
| 50 | |
Angel Pons | 2bd25bf | 2020-07-12 14:13:40 +0200 | [diff] [blame] | 51 | fadt->x_pm1a_evt_blk.space_id = ACPI_ADDRESS_SPACE_IO; |
Angel Pons | e8c6586 | 2021-09-08 12:16:45 +0200 | [diff] [blame] | 52 | fadt->x_pm1a_evt_blk.bit_width = fadt->pm1_evt_len * 8; |
Angel Pons | 2bd25bf | 2020-07-12 14:13:40 +0200 | [diff] [blame] | 53 | fadt->x_pm1a_evt_blk.bit_offset = 0; |
| 54 | fadt->x_pm1a_evt_blk.access_size = ACPI_ACCESS_SIZE_WORD_ACCESS; |
Felix Held | 769b657 | 2022-10-14 18:32:52 +0200 | [diff] [blame] | 55 | fadt->x_pm1a_evt_blk.addrl = fadt->pm1a_evt_blk; |
Angel Pons | 2bd25bf | 2020-07-12 14:13:40 +0200 | [diff] [blame] | 56 | fadt->x_pm1a_evt_blk.addrh = 0x0; |
| 57 | |
Angel Pons | 2bd25bf | 2020-07-12 14:13:40 +0200 | [diff] [blame] | 58 | fadt->x_pm1a_cnt_blk.space_id = ACPI_ADDRESS_SPACE_IO; |
Angel Pons | e8c6586 | 2021-09-08 12:16:45 +0200 | [diff] [blame] | 59 | fadt->x_pm1a_cnt_blk.bit_width = fadt->pm1_cnt_len * 8; |
Angel Pons | 2bd25bf | 2020-07-12 14:13:40 +0200 | [diff] [blame] | 60 | fadt->x_pm1a_cnt_blk.bit_offset = 0; |
| 61 | fadt->x_pm1a_cnt_blk.access_size = ACPI_ACCESS_SIZE_WORD_ACCESS; |
Elyes Haouas | c60f3b2 | 2022-10-11 14:02:27 +0200 | [diff] [blame] | 62 | fadt->x_pm1a_cnt_blk.addrl = fadt->pm1a_cnt_blk; |
Angel Pons | 2bd25bf | 2020-07-12 14:13:40 +0200 | [diff] [blame] | 63 | fadt->x_pm1a_cnt_blk.addrh = 0x0; |
| 64 | |
Angel Pons | 2bd25bf | 2020-07-12 14:13:40 +0200 | [diff] [blame] | 65 | fadt->x_pm2_cnt_blk.space_id = ACPI_ADDRESS_SPACE_IO; |
Angel Pons | e8c6586 | 2021-09-08 12:16:45 +0200 | [diff] [blame] | 66 | fadt->x_pm2_cnt_blk.bit_width = fadt->pm2_cnt_len * 8; |
Angel Pons | 2bd25bf | 2020-07-12 14:13:40 +0200 | [diff] [blame] | 67 | fadt->x_pm2_cnt_blk.bit_offset = 0; |
| 68 | fadt->x_pm2_cnt_blk.access_size = ACPI_ACCESS_SIZE_BYTE_ACCESS; |
Felix Held | 96fa237 | 2022-10-14 18:41:03 +0200 | [diff] [blame] | 69 | fadt->x_pm2_cnt_blk.addrl = fadt->pm2_cnt_blk; |
Angel Pons | 2bd25bf | 2020-07-12 14:13:40 +0200 | [diff] [blame] | 70 | fadt->x_pm2_cnt_blk.addrh = 0x0; |
| 71 | |
| 72 | fadt->x_pm_tmr_blk.space_id = ACPI_ADDRESS_SPACE_IO; |
Angel Pons | e8c6586 | 2021-09-08 12:16:45 +0200 | [diff] [blame] | 73 | fadt->x_pm_tmr_blk.bit_width = fadt->pm_tmr_len * 8; |
Angel Pons | 2bd25bf | 2020-07-12 14:13:40 +0200 | [diff] [blame] | 74 | fadt->x_pm_tmr_blk.bit_offset = 0; |
| 75 | fadt->x_pm_tmr_blk.access_size = ACPI_ACCESS_SIZE_DWORD_ACCESS; |
Elyes Haouas | 987f1f4 | 2022-10-11 13:56:30 +0200 | [diff] [blame] | 76 | fadt->x_pm_tmr_blk.addrl = fadt->pm_tmr_blk; |
Angel Pons | 2bd25bf | 2020-07-12 14:13:40 +0200 | [diff] [blame] | 77 | fadt->x_pm_tmr_blk.addrh = 0x0; |
| 78 | |
| 79 | /* |
| 80 | * Windows 10 requires x_gpe0_blk to be set starting with FADT revision 5. |
| 81 | * The bit_width field intentionally overflows here. |
| 82 | * The OSPM can instead use the values in `fadt->gpe0_blk{,_len}`, which |
| 83 | * seems to work fine on Linux 5.0 and Windows 10. |
| 84 | */ |
| 85 | fadt->x_gpe0_blk.space_id = ACPI_ADDRESS_SPACE_IO; |
| 86 | fadt->x_gpe0_blk.bit_width = fadt->gpe0_blk_len * 8; |
| 87 | fadt->x_gpe0_blk.bit_offset = 0; |
| 88 | fadt->x_gpe0_blk.access_size = ACPI_ACCESS_SIZE_BYTE_ACCESS; |
| 89 | fadt->x_gpe0_blk.addrl = fadt->gpe0_blk; |
| 90 | fadt->x_gpe0_blk.addrh = 0x0; |
Angel Pons | 2bd25bf | 2020-07-12 14:13:40 +0200 | [diff] [blame] | 91 | } |