Angel Pons | 91ca2dd | 2020-07-12 14:24:48 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
| 2 | |
| 3 | #include <acpi/acpi.h> |
Angel Pons | 91ca2dd | 2020-07-12 14:24:48 +0200 | [diff] [blame] | 4 | #include <soc/iomap.h> |
| 5 | #include <soc/pm.h> |
Angel Pons | 91ca2dd | 2020-07-12 14:24:48 +0200 | [diff] [blame] | 6 | |
| 7 | void acpi_fill_fadt(acpi_fadt_t *fadt) |
| 8 | { |
| 9 | const uint16_t pmbase = ACPI_BASE_ADDRESS; |
| 10 | |
Angel Pons | 91ca2dd | 2020-07-12 14:24:48 +0200 | [diff] [blame] | 11 | |
| 12 | fadt->pm1a_evt_blk = pmbase + PM1_STS; |
Angel Pons | 91ca2dd | 2020-07-12 14:24:48 +0200 | [diff] [blame] | 13 | fadt->pm1a_cnt_blk = pmbase + PM1_CNT; |
Angel Pons | 91ca2dd | 2020-07-12 14:24:48 +0200 | [diff] [blame] | 14 | fadt->pm2_cnt_blk = pmbase + PM2A_CNT_BLK; |
| 15 | fadt->pm_tmr_blk = pmbase + PM1_TMR; |
| 16 | fadt->gpe0_blk = pmbase + GPE0_STS; |
Angel Pons | 91ca2dd | 2020-07-12 14:24:48 +0200 | [diff] [blame] | 17 | |
| 18 | fadt->pm1_evt_len = 4; |
| 19 | fadt->pm1_cnt_len = 2; |
| 20 | fadt->pm2_cnt_len = 1; |
| 21 | fadt->pm_tmr_len = 4; |
| 22 | fadt->gpe0_blk_len = 2 * (GPE0_EN - GPE0_STS); |
Angel Pons | 91ca2dd | 2020-07-12 14:24:48 +0200 | [diff] [blame] | 23 | fadt->iapc_boot_arch = ACPI_FADT_LEGACY_DEVICES | ACPI_FADT_8042; |
| 24 | |
Angel Pons | a208c6c | 2020-07-13 00:02:34 +0200 | [diff] [blame] | 25 | fadt->flags |= ACPI_FADT_WBINVD | ACPI_FADT_C1_SUPPORTED | |
Michael Niewöhner | 2353cd9 | 2021-10-04 16:59:49 +0200 | [diff] [blame] | 26 | ACPI_FADT_SLEEP_BUTTON | |
Angel Pons | 79572e4 | 2020-07-13 00:17:43 +0200 | [diff] [blame] | 27 | ACPI_FADT_SEALED_CASE | ACPI_FADT_S4_RTC_WAKE | |
| 28 | ACPI_FADT_PLATFORM_CLOCK; |
Angel Pons | 91ca2dd | 2020-07-12 14:24:48 +0200 | [diff] [blame] | 29 | |
Elyes HAOUAS | 04071f4 | 2020-07-20 17:05:24 +0200 | [diff] [blame] | 30 | fadt->x_pm1a_evt_blk.space_id = ACPI_ADDRESS_SPACE_IO; |
Angel Pons | 91ca2dd | 2020-07-12 14:24:48 +0200 | [diff] [blame] | 31 | fadt->x_pm1a_evt_blk.bit_width = fadt->pm1_evt_len * 8; |
| 32 | fadt->x_pm1a_evt_blk.bit_offset = 0; |
Angel Pons | 12a4d05 | 2020-07-14 01:31:27 +0200 | [diff] [blame] | 33 | fadt->x_pm1a_evt_blk.access_size = ACPI_ACCESS_SIZE_WORD_ACCESS; |
Felix Held | 769b657 | 2022-10-14 18:32:52 +0200 | [diff] [blame] | 34 | fadt->x_pm1a_evt_blk.addrl = fadt->pm1a_evt_blk; |
Angel Pons | 91ca2dd | 2020-07-12 14:24:48 +0200 | [diff] [blame] | 35 | fadt->x_pm1a_evt_blk.addrh = 0x0; |
| 36 | |
Elyes HAOUAS | 04071f4 | 2020-07-20 17:05:24 +0200 | [diff] [blame] | 37 | fadt->x_pm1a_cnt_blk.space_id = ACPI_ADDRESS_SPACE_IO; |
Angel Pons | 91ca2dd | 2020-07-12 14:24:48 +0200 | [diff] [blame] | 38 | fadt->x_pm1a_cnt_blk.bit_width = fadt->pm1_cnt_len * 8; |
| 39 | fadt->x_pm1a_cnt_blk.bit_offset = 0; |
| 40 | fadt->x_pm1a_cnt_blk.access_size = ACPI_ACCESS_SIZE_WORD_ACCESS; |
Elyes Haouas | c60f3b2 | 2022-10-11 14:02:27 +0200 | [diff] [blame] | 41 | fadt->x_pm1a_cnt_blk.addrl = fadt->pm1a_cnt_blk; |
Angel Pons | 91ca2dd | 2020-07-12 14:24:48 +0200 | [diff] [blame] | 42 | fadt->x_pm1a_cnt_blk.addrh = 0x0; |
| 43 | |
Elyes HAOUAS | 04071f4 | 2020-07-20 17:05:24 +0200 | [diff] [blame] | 44 | fadt->x_pm2_cnt_blk.space_id = ACPI_ADDRESS_SPACE_IO; |
Angel Pons | 91ca2dd | 2020-07-12 14:24:48 +0200 | [diff] [blame] | 45 | fadt->x_pm2_cnt_blk.bit_width = fadt->pm2_cnt_len * 8; |
| 46 | fadt->x_pm2_cnt_blk.bit_offset = 0; |
| 47 | fadt->x_pm2_cnt_blk.access_size = ACPI_ACCESS_SIZE_BYTE_ACCESS; |
Felix Held | 96fa237 | 2022-10-14 18:41:03 +0200 | [diff] [blame] | 48 | fadt->x_pm2_cnt_blk.addrl = fadt->pm2_cnt_blk; |
Angel Pons | 91ca2dd | 2020-07-12 14:24:48 +0200 | [diff] [blame] | 49 | fadt->x_pm2_cnt_blk.addrh = 0x0; |
| 50 | |
Elyes HAOUAS | 04071f4 | 2020-07-20 17:05:24 +0200 | [diff] [blame] | 51 | fadt->x_pm_tmr_blk.space_id = ACPI_ADDRESS_SPACE_IO; |
Angel Pons | 91ca2dd | 2020-07-12 14:24:48 +0200 | [diff] [blame] | 52 | fadt->x_pm_tmr_blk.bit_width = fadt->pm_tmr_len * 8; |
| 53 | fadt->x_pm_tmr_blk.bit_offset = 0; |
| 54 | fadt->x_pm_tmr_blk.access_size = ACPI_ACCESS_SIZE_DWORD_ACCESS; |
Elyes Haouas | 987f1f4 | 2022-10-11 13:56:30 +0200 | [diff] [blame] | 55 | fadt->x_pm_tmr_blk.addrl = fadt->pm_tmr_blk; |
Angel Pons | 91ca2dd | 2020-07-12 14:24:48 +0200 | [diff] [blame] | 56 | fadt->x_pm_tmr_blk.addrh = 0x0; |
| 57 | |
| 58 | /* |
| 59 | * Windows 10 requires x_gpe0_blk to be set starting with FADT revision 5. |
| 60 | * The bit_width field intentionally overflows here. |
| 61 | * The OSPM can instead use the values in `fadt->gpe0_blk{,_len}`, which |
| 62 | * seems to work fine on Linux 5.0 and Windows 10. |
| 63 | */ |
Elyes HAOUAS | 04071f4 | 2020-07-20 17:05:24 +0200 | [diff] [blame] | 64 | fadt->x_gpe0_blk.space_id = ACPI_ADDRESS_SPACE_IO; |
Angel Pons | 91ca2dd | 2020-07-12 14:24:48 +0200 | [diff] [blame] | 65 | fadt->x_gpe0_blk.bit_width = fadt->gpe0_blk_len * 8; |
| 66 | fadt->x_gpe0_blk.bit_offset = 0; |
| 67 | fadt->x_gpe0_blk.access_size = ACPI_ACCESS_SIZE_BYTE_ACCESS; |
Elyes Haouas | c929f09 | 2022-10-11 13:40:51 +0200 | [diff] [blame] | 68 | fadt->x_gpe0_blk.addrl = fadt->gpe0_blk; |
Angel Pons | 91ca2dd | 2020-07-12 14:24:48 +0200 | [diff] [blame] | 69 | fadt->x_gpe0_blk.addrh = 0x0; |
Angel Pons | 91ca2dd | 2020-07-12 14:24:48 +0200 | [diff] [blame] | 70 | } |