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 | |
| 3 | #include <string.h> |
Kyösti Mälkki | f1b58b7 | 2019-03-01 13:43:02 +0200 | [diff] [blame] | 4 | #include <device/pci_ops.h> |
Furquan Shaikh | 76cedd2 | 2020-05-02 10:24:23 -0700 | [diff] [blame] | 5 | #include <acpi/acpi.h> |
Elyes HAOUAS | 26071aa | 2019-02-15 08:21:33 +0100 | [diff] [blame] | 6 | #include <version.h> |
Kyösti Mälkki | 9116270 | 2011-11-03 15:22:01 +0200 | [diff] [blame] | 7 | |
| 8 | /* FIXME: This needs to go into a separate .h file |
| 9 | * to be included by the ich7 smi handler, ich7 smi init |
| 10 | * code and the mainboard fadt. |
| 11 | */ |
| 12 | #define APM_CNT 0x0 /* ACPI mode only */ |
| 13 | #define CST_CONTROL 0x85 |
| 14 | #define PST_CONTROL 0x0 |
| 15 | #define ACPI_DISABLE 0xAA |
| 16 | #define ACPI_ENABLE 0x55 |
| 17 | #define S4_BIOS 0x77 |
| 18 | #define GNVS_UPDATE 0xea |
| 19 | |
Kyösti Mälkki | df63ff8 | 2020-05-30 14:50:50 +0300 | [diff] [blame^] | 20 | void acpi_fill_fadt(acpi_fadt_t *fadt) |
Kyösti Mälkki | 9116270 | 2011-11-03 15:22:01 +0200 | [diff] [blame] | 21 | { |
Kyösti Mälkki | c70eed1 | 2018-05-22 02:18:00 +0300 | [diff] [blame] | 22 | 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] | 23 | |
Kyösti Mälkki | df63ff8 | 2020-05-30 14:50:50 +0300 | [diff] [blame^] | 24 | fadt->preferred_pm_profile = PM_UNSPECIFIED; |
Kyösti Mälkki | 9116270 | 2011-11-03 15:22:01 +0200 | [diff] [blame] | 25 | |
| 26 | fadt->sci_int = 0x9; |
Kyösti Mälkki | 06897d1 | 2019-11-23 07:23:40 +0200 | [diff] [blame] | 27 | |
Kyösti Mälkki | 0a9e72e | 2019-08-11 01:22:28 +0300 | [diff] [blame] | 28 | if (permanent_smi_handler()) { |
Kyösti Mälkki | 06897d1 | 2019-11-23 07:23:40 +0200 | [diff] [blame] | 29 | fadt->smi_cmd = APM_CNT; |
| 30 | fadt->acpi_enable = ACPI_ENABLE; |
| 31 | fadt->acpi_disable = ACPI_DISABLE; |
| 32 | fadt->pstate_cnt = PST_CONTROL; |
| 33 | } |
Kyösti Mälkki | 9116270 | 2011-11-03 15:22:01 +0200 | [diff] [blame] | 34 | |
| 35 | fadt->pm1a_evt_blk = pmbase; |
| 36 | fadt->pm1b_evt_blk = 0x0; |
| 37 | fadt->pm1a_cnt_blk = pmbase + 0x4; |
| 38 | fadt->pm1b_cnt_blk = 0x0; |
| 39 | fadt->pm2_cnt_blk = 0x0; |
| 40 | fadt->pm_tmr_blk = pmbase + 0x8; |
| 41 | fadt->gpe0_blk = pmbase + 0x28; |
| 42 | fadt->gpe1_blk = 0; |
| 43 | |
| 44 | fadt->pm1_evt_len = 4; |
| 45 | fadt->pm1_cnt_len = 2; |
Elyes HAOUAS | 4682986 | 2016-10-07 17:35:50 +0200 | [diff] [blame] | 46 | /* XXX: pm2_cnt_len is probably wrong. find out right value (hint: it's != 0) */ |
Kyösti Mälkki | 9116270 | 2011-11-03 15:22:01 +0200 | [diff] [blame] | 47 | fadt->pm2_cnt_len = 0; |
| 48 | fadt->pm_tmr_len = 4; |
| 49 | fadt->gpe0_blk_len = 8; |
| 50 | fadt->gpe1_blk_len = 0; |
| 51 | fadt->gpe1_base = 0; |
Kyösti Mälkki | 9116270 | 2011-11-03 15:22:01 +0200 | [diff] [blame] | 52 | fadt->p_lvl2_lat = 1; |
| 53 | fadt->p_lvl3_lat = 85; |
| 54 | fadt->flush_size = 1024; |
| 55 | fadt->flush_stride = 16; |
| 56 | fadt->duty_offset = 1; |
| 57 | fadt->duty_width = 0; |
| 58 | fadt->day_alrm = 0xd; |
| 59 | fadt->mon_alrm = 0x00; |
| 60 | fadt->century = 0x00; |
| 61 | fadt->iapc_boot_arch = 0x03; |
| 62 | |
| 63 | fadt->flags = ACPI_FADT_WBINVD | ACPI_FADT_C1_SUPPORTED | |
| 64 | ACPI_FADT_C2_MP_SUPPORTED | ACPI_FADT_SLEEP_BUTTON | |
| 65 | ACPI_FADT_S4_RTC_WAKE | ACPI_FADT_PLATFORM_CLOCK; |
| 66 | |
| 67 | fadt->reset_reg.space_id = 0; |
| 68 | fadt->reset_reg.bit_width = 0; |
| 69 | fadt->reset_reg.bit_offset = 0; |
Elyes HAOUAS | 8ee161d | 2019-03-03 12:49:56 +0100 | [diff] [blame] | 70 | fadt->reset_reg.access_size = 0; |
Kyösti Mälkki | 9116270 | 2011-11-03 15:22:01 +0200 | [diff] [blame] | 71 | fadt->reset_reg.addrl = 0x0; |
| 72 | fadt->reset_reg.addrh = 0x0; |
| 73 | |
| 74 | fadt->reset_value = 0; |
Kyösti Mälkki | 9116270 | 2011-11-03 15:22:01 +0200 | [diff] [blame] | 75 | |
| 76 | fadt->x_pm1a_evt_blk.space_id = 1; |
| 77 | fadt->x_pm1a_evt_blk.bit_width = 32; |
| 78 | fadt->x_pm1a_evt_blk.bit_offset = 0; |
Elyes HAOUAS | 8ee161d | 2019-03-03 12:49:56 +0100 | [diff] [blame] | 79 | fadt->x_pm1a_evt_blk.access_size = 0; |
Kyösti Mälkki | 9116270 | 2011-11-03 15:22:01 +0200 | [diff] [blame] | 80 | fadt->x_pm1a_evt_blk.addrl = pmbase; |
| 81 | fadt->x_pm1a_evt_blk.addrh = 0x0; |
| 82 | |
| 83 | fadt->x_pm1b_evt_blk.space_id = 1; |
| 84 | fadt->x_pm1b_evt_blk.bit_width = 0; |
| 85 | fadt->x_pm1b_evt_blk.bit_offset = 0; |
Elyes HAOUAS | 8ee161d | 2019-03-03 12:49:56 +0100 | [diff] [blame] | 86 | fadt->x_pm1b_evt_blk.access_size = 0; |
Kyösti Mälkki | 9116270 | 2011-11-03 15:22:01 +0200 | [diff] [blame] | 87 | fadt->x_pm1b_evt_blk.addrl = 0x0; |
| 88 | fadt->x_pm1b_evt_blk.addrh = 0x0; |
| 89 | |
| 90 | fadt->x_pm1a_cnt_blk.space_id = 1; |
| 91 | fadt->x_pm1a_cnt_blk.bit_width = 16; |
| 92 | fadt->x_pm1a_cnt_blk.bit_offset = 0; |
Elyes HAOUAS | 8ee161d | 2019-03-03 12:49:56 +0100 | [diff] [blame] | 93 | fadt->x_pm1a_cnt_blk.access_size = 0; |
Kyösti Mälkki | 9116270 | 2011-11-03 15:22:01 +0200 | [diff] [blame] | 94 | fadt->x_pm1a_cnt_blk.addrl = pmbase + 0x4; |
| 95 | fadt->x_pm1a_cnt_blk.addrh = 0x0; |
| 96 | |
| 97 | fadt->x_pm1b_cnt_blk.space_id = 1; |
| 98 | fadt->x_pm1b_cnt_blk.bit_width = 0; |
| 99 | fadt->x_pm1b_cnt_blk.bit_offset = 0; |
Elyes HAOUAS | 8ee161d | 2019-03-03 12:49:56 +0100 | [diff] [blame] | 100 | fadt->x_pm1b_cnt_blk.access_size = 0; |
Kyösti Mälkki | 9116270 | 2011-11-03 15:22:01 +0200 | [diff] [blame] | 101 | fadt->x_pm1b_cnt_blk.addrl = 0x0; |
| 102 | fadt->x_pm1b_cnt_blk.addrh = 0x0; |
| 103 | |
| 104 | fadt->x_pm2_cnt_blk.space_id = 1; |
| 105 | fadt->x_pm2_cnt_blk.bit_width = 0; |
| 106 | fadt->x_pm2_cnt_blk.bit_offset = 0; |
Elyes HAOUAS | 8ee161d | 2019-03-03 12:49:56 +0100 | [diff] [blame] | 107 | fadt->x_pm2_cnt_blk.access_size = 0; |
Kyösti Mälkki | 9116270 | 2011-11-03 15:22:01 +0200 | [diff] [blame] | 108 | fadt->x_pm2_cnt_blk.addrl = 0x0; |
| 109 | fadt->x_pm2_cnt_blk.addrh = 0x0; |
| 110 | |
| 111 | fadt->x_pm_tmr_blk.space_id = 1; |
| 112 | fadt->x_pm_tmr_blk.bit_width = 32; |
| 113 | fadt->x_pm_tmr_blk.bit_offset = 0; |
Elyes HAOUAS | 8ee161d | 2019-03-03 12:49:56 +0100 | [diff] [blame] | 114 | fadt->x_pm_tmr_blk.access_size = 0; |
Kyösti Mälkki | 9116270 | 2011-11-03 15:22:01 +0200 | [diff] [blame] | 115 | fadt->x_pm_tmr_blk.addrl = pmbase + 0x8; |
| 116 | fadt->x_pm_tmr_blk.addrh = 0x0; |
| 117 | |
| 118 | fadt->x_gpe0_blk.space_id = 1; |
| 119 | fadt->x_gpe0_blk.bit_width = 64; |
| 120 | fadt->x_gpe0_blk.bit_offset = 0; |
Elyes HAOUAS | 8ee161d | 2019-03-03 12:49:56 +0100 | [diff] [blame] | 121 | fadt->x_gpe0_blk.access_size = 0; |
Kyösti Mälkki | 9116270 | 2011-11-03 15:22:01 +0200 | [diff] [blame] | 122 | fadt->x_gpe0_blk.addrl = pmbase + 0x28; |
| 123 | fadt->x_gpe0_blk.addrh = 0x0; |
| 124 | |
| 125 | fadt->x_gpe1_blk.space_id = 1; |
| 126 | fadt->x_gpe1_blk.bit_width = 0; |
| 127 | fadt->x_gpe1_blk.bit_offset = 0; |
Elyes HAOUAS | 8ee161d | 2019-03-03 12:49:56 +0100 | [diff] [blame] | 128 | fadt->x_gpe1_blk.access_size = 0; |
Kyösti Mälkki | 9116270 | 2011-11-03 15:22:01 +0200 | [diff] [blame] | 129 | fadt->x_gpe1_blk.addrl = 0x0; |
| 130 | fadt->x_gpe1_blk.addrh = 0x0; |
Kyösti Mälkki | 9116270 | 2011-11-03 15:22:01 +0200 | [diff] [blame] | 131 | } |