Angel Pons | 236c637 | 2020-04-03 01:21:05 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Kyösti Mälkki | 9116270 | 2011-11-03 15:22:01 +0200 | [diff] [blame] | 2 | |
Kyösti Mälkki | f1b58b7 | 2019-03-01 13:43:02 +0200 | [diff] [blame] | 3 | #include <device/pci_ops.h> |
Furquan Shaikh | 76cedd2 | 2020-05-02 10:24:23 -0700 | [diff] [blame] | 4 | #include <acpi/acpi.h> |
Elyes HAOUAS | 26071aa | 2019-02-15 08:21:33 +0100 | [diff] [blame] | 5 | #include <version.h> |
Kyösti Mälkki | 9116270 | 2011-11-03 15:22:01 +0200 | [diff] [blame] | 6 | |
| 7 | /* FIXME: This needs to go into a separate .h file |
| 8 | * to be included by the ich7 smi handler, ich7 smi init |
| 9 | * code and the mainboard fadt. |
| 10 | */ |
| 11 | #define APM_CNT 0x0 /* ACPI mode only */ |
| 12 | #define CST_CONTROL 0x85 |
| 13 | #define PST_CONTROL 0x0 |
| 14 | #define ACPI_DISABLE 0xAA |
| 15 | #define ACPI_ENABLE 0x55 |
| 16 | #define S4_BIOS 0x77 |
| 17 | #define GNVS_UPDATE 0xea |
| 18 | |
Kyösti Mälkki | df63ff8 | 2020-05-30 14:50:50 +0300 | [diff] [blame] | 19 | void acpi_fill_fadt(acpi_fadt_t *fadt) |
Kyösti Mälkki | 9116270 | 2011-11-03 15:22:01 +0200 | [diff] [blame] | 20 | { |
Kyösti Mälkki | c70eed1 | 2018-05-22 02:18:00 +0300 | [diff] [blame] | 21 | u16 pmbase = pci_read_config16(pcidev_on_root(0x1f, 0), 0x40) & 0xfffe; |
Kyösti Mälkki | 9116270 | 2011-11-03 15:22:01 +0200 | [diff] [blame] | 22 | |
Kyösti Mälkki | 9116270 | 2011-11-03 15:22:01 +0200 | [diff] [blame] | 23 | fadt->sci_int = 0x9; |
Kyösti Mälkki | 06897d1 | 2019-11-23 07:23:40 +0200 | [diff] [blame] | 24 | |
Kyösti Mälkki | 0a9e72e | 2019-08-11 01:22:28 +0300 | [diff] [blame] | 25 | if (permanent_smi_handler()) { |
Kyösti Mälkki | 06897d1 | 2019-11-23 07:23:40 +0200 | [diff] [blame] | 26 | fadt->smi_cmd = APM_CNT; |
| 27 | fadt->acpi_enable = ACPI_ENABLE; |
| 28 | fadt->acpi_disable = ACPI_DISABLE; |
| 29 | fadt->pstate_cnt = PST_CONTROL; |
| 30 | } |
Kyösti Mälkki | 9116270 | 2011-11-03 15:22:01 +0200 | [diff] [blame] | 31 | |
| 32 | fadt->pm1a_evt_blk = pmbase; |
Kyösti Mälkki | 9116270 | 2011-11-03 15:22:01 +0200 | [diff] [blame] | 33 | fadt->pm1a_cnt_blk = pmbase + 0x4; |
Kyösti Mälkki | 9116270 | 2011-11-03 15:22:01 +0200 | [diff] [blame] | 34 | fadt->pm_tmr_blk = pmbase + 0x8; |
| 35 | fadt->gpe0_blk = pmbase + 0x28; |
Kyösti Mälkki | 9116270 | 2011-11-03 15:22:01 +0200 | [diff] [blame] | 36 | |
| 37 | fadt->pm1_evt_len = 4; |
| 38 | fadt->pm1_cnt_len = 2; |
Kyösti Mälkki | 9116270 | 2011-11-03 15:22:01 +0200 | [diff] [blame] | 39 | fadt->pm_tmr_len = 4; |
| 40 | fadt->gpe0_blk_len = 8; |
Kyösti Mälkki | 9116270 | 2011-11-03 15:22:01 +0200 | [diff] [blame] | 41 | fadt->p_lvl2_lat = 1; |
| 42 | fadt->p_lvl3_lat = 85; |
Kyösti Mälkki | 9116270 | 2011-11-03 15:22:01 +0200 | [diff] [blame] | 43 | fadt->duty_offset = 1; |
| 44 | fadt->duty_width = 0; |
| 45 | fadt->day_alrm = 0xd; |
| 46 | fadt->mon_alrm = 0x00; |
Elyes HAOUAS | 653eb15 | 2020-08-17 12:15:12 +0200 | [diff] [blame] | 47 | fadt->iapc_boot_arch = ACPI_FADT_LEGACY_DEVICES | ACPI_FADT_8042; |
Kyösti Mälkki | 9116270 | 2011-11-03 15:22:01 +0200 | [diff] [blame] | 48 | |
Angel Pons | a208c6c | 2020-07-13 00:02:34 +0200 | [diff] [blame] | 49 | fadt->flags |= ACPI_FADT_WBINVD | ACPI_FADT_C1_SUPPORTED | |
Kyösti Mälkki | 9116270 | 2011-11-03 15:22:01 +0200 | [diff] [blame] | 50 | ACPI_FADT_C2_MP_SUPPORTED | ACPI_FADT_SLEEP_BUTTON | |
Angel Pons | 79572e4 | 2020-07-13 00:17:43 +0200 | [diff] [blame] | 51 | ACPI_FADT_S4_RTC_WAKE | ACPI_FADT_PLATFORM_CLOCK; |
Kyösti Mälkki | 9116270 | 2011-11-03 15:22:01 +0200 | [diff] [blame] | 52 | |
Elyes HAOUAS | 04071f4 | 2020-07-20 17:05:24 +0200 | [diff] [blame] | 53 | fadt->x_pm1a_evt_blk.space_id = ACPI_ADDRESS_SPACE_IO; |
Elyes Haouas | a6e05382 | 2022-10-11 12:55:36 +0200 | [diff] [blame] | 54 | fadt->x_pm1a_evt_blk.bit_width = fadt->pm1_evt_len * 8; |
Kyösti Mälkki | 9116270 | 2011-11-03 15:22:01 +0200 | [diff] [blame] | 55 | fadt->x_pm1a_evt_blk.bit_offset = 0; |
Elyes HAOUAS | 04071f4 | 2020-07-20 17:05:24 +0200 | [diff] [blame] | 56 | fadt->x_pm1a_evt_blk.access_size = ACPI_ACCESS_SIZE_UNDEFINED; |
Kyösti Mälkki | 9116270 | 2011-11-03 15:22:01 +0200 | [diff] [blame] | 57 | fadt->x_pm1a_evt_blk.addrl = pmbase; |
| 58 | fadt->x_pm1a_evt_blk.addrh = 0x0; |
| 59 | |
Angel Pons | 94b0c79 | 2020-07-13 16:00:17 +0200 | [diff] [blame] | 60 | fadt->x_pm1a_cnt_blk.space_id = ACPI_ADDRESS_SPACE_IO; |
Elyes Haouas | 7008085 | 2022-10-11 13:09:35 +0200 | [diff] [blame] | 61 | fadt->x_pm1a_cnt_blk.bit_width = fadt->pm1_cnt_len * 8; |
Kyösti Mälkki | 9116270 | 2011-11-03 15:22:01 +0200 | [diff] [blame] | 62 | fadt->x_pm1a_cnt_blk.bit_offset = 0; |
Elyes HAOUAS | 04071f4 | 2020-07-20 17:05:24 +0200 | [diff] [blame] | 63 | fadt->x_pm1a_cnt_blk.access_size = ACPI_ACCESS_SIZE_UNDEFINED; |
Kyösti Mälkki | 9116270 | 2011-11-03 15:22:01 +0200 | [diff] [blame] | 64 | fadt->x_pm1a_cnt_blk.addrl = pmbase + 0x4; |
| 65 | fadt->x_pm1a_cnt_blk.addrh = 0x0; |
| 66 | |
Angel Pons | 94b0c79 | 2020-07-13 16:00:17 +0200 | [diff] [blame] | 67 | fadt->x_pm_tmr_blk.space_id = ACPI_ADDRESS_SPACE_IO; |
Elyes Haouas | 501b71e | 2022-10-11 13:15:37 +0200 | [diff] [blame^] | 68 | fadt->x_pm_tmr_blk.bit_width = fadt->pm_tmr_len * 8; |
Kyösti Mälkki | 9116270 | 2011-11-03 15:22:01 +0200 | [diff] [blame] | 69 | fadt->x_pm_tmr_blk.bit_offset = 0; |
Elyes HAOUAS | 04071f4 | 2020-07-20 17:05:24 +0200 | [diff] [blame] | 70 | fadt->x_pm_tmr_blk.access_size = ACPI_ACCESS_SIZE_UNDEFINED; |
Kyösti Mälkki | 9116270 | 2011-11-03 15:22:01 +0200 | [diff] [blame] | 71 | fadt->x_pm_tmr_blk.addrl = pmbase + 0x8; |
| 72 | fadt->x_pm_tmr_blk.addrh = 0x0; |
| 73 | |
Angel Pons | 94b0c79 | 2020-07-13 16:00:17 +0200 | [diff] [blame] | 74 | fadt->x_gpe0_blk.space_id = ACPI_ADDRESS_SPACE_IO; |
Kyösti Mälkki | 9116270 | 2011-11-03 15:22:01 +0200 | [diff] [blame] | 75 | fadt->x_gpe0_blk.bit_width = 64; |
| 76 | fadt->x_gpe0_blk.bit_offset = 0; |
Elyes HAOUAS | 04071f4 | 2020-07-20 17:05:24 +0200 | [diff] [blame] | 77 | fadt->x_gpe0_blk.access_size = ACPI_ACCESS_SIZE_UNDEFINED; |
Kyösti Mälkki | 9116270 | 2011-11-03 15:22:01 +0200 | [diff] [blame] | 78 | fadt->x_gpe0_blk.addrl = pmbase + 0x28; |
| 79 | fadt->x_gpe0_blk.addrh = 0x0; |
Kyösti Mälkki | 9116270 | 2011-11-03 15:22:01 +0200 | [diff] [blame] | 80 | } |