Angel Pons | 6ee7751 | 2020-07-12 15:47:07 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
| 2 | |
| 3 | #include <acpi/acpi.h> |
| 4 | #include <cpu/x86/smm.h> |
| 5 | #include <soc/acpi.h> |
| 6 | #include <soc/iomap.h> |
| 7 | #include <soc/pm.h> |
| 8 | #include "chip.h" |
| 9 | |
| 10 | void acpi_fill_fadt(acpi_fadt_t *fadt) |
| 11 | { |
| 12 | const uint16_t pmbase = ACPI_BASE_ADDRESS; |
| 13 | |
| 14 | fadt->sci_int = acpi_sci_irq(); |
| 15 | |
| 16 | if (permanent_smi_handler()) { |
| 17 | fadt->smi_cmd = APM_CNT; |
| 18 | fadt->acpi_enable = APM_CNT_ACPI_ENABLE; |
| 19 | fadt->acpi_disable = APM_CNT_ACPI_DISABLE; |
| 20 | } |
| 21 | |
| 22 | fadt->pm1a_evt_blk = pmbase + PM1_STS; |
Angel Pons | 6ee7751 | 2020-07-12 15:47:07 +0200 | [diff] [blame] | 23 | fadt->pm1a_cnt_blk = pmbase + PM1_CNT; |
Angel Pons | 6ee7751 | 2020-07-12 15:47:07 +0200 | [diff] [blame] | 24 | fadt->pm2_cnt_blk = pmbase + PM2A_CNT_BLK; |
| 25 | fadt->pm_tmr_blk = pmbase + PM1_TMR; |
| 26 | fadt->gpe0_blk = pmbase + GPE0_STS; |
Angel Pons | 6ee7751 | 2020-07-12 15:47:07 +0200 | [diff] [blame] | 27 | |
| 28 | fadt->pm1_evt_len = 4; |
| 29 | fadt->pm1_cnt_len = 2; |
| 30 | fadt->pm2_cnt_len = 1; |
| 31 | fadt->pm_tmr_len = 4; |
| 32 | fadt->gpe0_blk_len = 2 * (GPE0_EN - GPE0_STS); |
Angel Pons | 6ee7751 | 2020-07-12 15:47:07 +0200 | [diff] [blame] | 33 | fadt->p_lvl2_lat = 1; |
| 34 | fadt->p_lvl3_lat = 87; |
Angel Pons | 6ee7751 | 2020-07-12 15:47:07 +0200 | [diff] [blame] | 35 | fadt->duty_offset = 1; |
| 36 | fadt->duty_width = 0; |
| 37 | fadt->day_alrm = 0xd; |
| 38 | fadt->mon_alrm = 0x00; |
| 39 | fadt->century = 0x00; |
| 40 | fadt->iapc_boot_arch = ACPI_FADT_LEGACY_DEVICES | ACPI_FADT_8042; |
| 41 | |
Angel Pons | a208c6c | 2020-07-13 00:02:34 +0200 | [diff] [blame] | 42 | fadt->flags |= ACPI_FADT_WBINVD | ACPI_FADT_C1_SUPPORTED | |
Angel Pons | 6ee7751 | 2020-07-12 15:47:07 +0200 | [diff] [blame] | 43 | ACPI_FADT_C2_MP_SUPPORTED | ACPI_FADT_SLEEP_BUTTON | |
Angel Pons | 79572e4 | 2020-07-13 00:17:43 +0200 | [diff] [blame] | 44 | ACPI_FADT_SEALED_CASE | ACPI_FADT_S4_RTC_WAKE | |
| 45 | ACPI_FADT_PLATFORM_CLOCK; |
Angel Pons | 6ee7751 | 2020-07-12 15:47:07 +0200 | [diff] [blame] | 46 | |
Angel Pons | e5ef197 | 2020-07-26 22:25:38 +0200 | [diff] [blame] | 47 | fadt->x_pm1a_evt_blk.space_id = ACPI_ADDRESS_SPACE_IO; |
Angel Pons | 6ee7751 | 2020-07-12 15:47:07 +0200 | [diff] [blame] | 48 | fadt->x_pm1a_evt_blk.bit_width = fadt->pm1_evt_len * 8; |
| 49 | fadt->x_pm1a_evt_blk.bit_offset = 0; |
Angel Pons | 12a4d05 | 2020-07-14 01:31:27 +0200 | [diff] [blame] | 50 | fadt->x_pm1a_evt_blk.access_size = ACPI_ACCESS_SIZE_WORD_ACCESS; |
Angel Pons | 6ee7751 | 2020-07-12 15:47:07 +0200 | [diff] [blame] | 51 | fadt->x_pm1a_evt_blk.addrl = pmbase + PM1_STS; |
| 52 | fadt->x_pm1a_evt_blk.addrh = 0x0; |
| 53 | |
Angel Pons | e5ef197 | 2020-07-26 22:25:38 +0200 | [diff] [blame] | 54 | fadt->x_pm1a_cnt_blk.space_id = ACPI_ADDRESS_SPACE_IO; |
Angel Pons | 6ee7751 | 2020-07-12 15:47:07 +0200 | [diff] [blame] | 55 | fadt->x_pm1a_cnt_blk.bit_width = fadt->pm1_cnt_len * 8; |
| 56 | fadt->x_pm1a_cnt_blk.bit_offset = 0; |
| 57 | fadt->x_pm1a_cnt_blk.access_size = ACPI_ACCESS_SIZE_WORD_ACCESS; |
| 58 | fadt->x_pm1a_cnt_blk.addrl = pmbase + PM1_CNT; |
| 59 | fadt->x_pm1a_cnt_blk.addrh = 0x0; |
| 60 | |
Angel Pons | e5ef197 | 2020-07-26 22:25:38 +0200 | [diff] [blame] | 61 | fadt->x_pm2_cnt_blk.space_id = ACPI_ADDRESS_SPACE_IO; |
Angel Pons | 6ee7751 | 2020-07-12 15:47:07 +0200 | [diff] [blame] | 62 | fadt->x_pm2_cnt_blk.bit_width = fadt->pm2_cnt_len * 8; |
| 63 | fadt->x_pm2_cnt_blk.bit_offset = 0; |
| 64 | fadt->x_pm2_cnt_blk.access_size = ACPI_ACCESS_SIZE_BYTE_ACCESS; |
| 65 | fadt->x_pm2_cnt_blk.addrl = pmbase + PM2A_CNT_BLK; |
| 66 | fadt->x_pm2_cnt_blk.addrh = 0x0; |
| 67 | |
Angel Pons | e5ef197 | 2020-07-26 22:25:38 +0200 | [diff] [blame] | 68 | fadt->x_pm_tmr_blk.space_id = ACPI_ADDRESS_SPACE_IO; |
Angel Pons | 6ee7751 | 2020-07-12 15:47:07 +0200 | [diff] [blame] | 69 | fadt->x_pm_tmr_blk.bit_width = fadt->pm_tmr_len * 8; |
| 70 | fadt->x_pm_tmr_blk.bit_offset = 0; |
| 71 | fadt->x_pm_tmr_blk.access_size = ACPI_ACCESS_SIZE_DWORD_ACCESS; |
| 72 | fadt->x_pm_tmr_blk.addrl = pmbase + PM1_TMR; |
| 73 | fadt->x_pm_tmr_blk.addrh = 0x0; |
| 74 | |
| 75 | /* |
| 76 | * Windows 10 requires x_gpe0_blk to be set starting with FADT revision 5. |
| 77 | * The bit_width field intentionally overflows here. |
| 78 | * The OSPM can instead use the values in `fadt->gpe0_blk{,_len}`, which |
| 79 | * seems to work fine on Linux 5.0 and Windows 10. |
| 80 | */ |
Angel Pons | e5ef197 | 2020-07-26 22:25:38 +0200 | [diff] [blame] | 81 | fadt->x_gpe0_blk.space_id = ACPI_ADDRESS_SPACE_IO; |
Angel Pons | 6ee7751 | 2020-07-12 15:47:07 +0200 | [diff] [blame] | 82 | fadt->x_gpe0_blk.bit_width = fadt->gpe0_blk_len * 8; |
| 83 | fadt->x_gpe0_blk.bit_offset = 0; |
| 84 | fadt->x_gpe0_blk.access_size = ACPI_ACCESS_SIZE_BYTE_ACCESS; |
| 85 | fadt->x_gpe0_blk.addrl = pmbase + GPE0_STS; |
| 86 | fadt->x_gpe0_blk.addrh = 0x0; |
Angel Pons | 6ee7751 | 2020-07-12 15:47:07 +0200 | [diff] [blame] | 87 | } |