Elyes HAOUAS | 132384a | 2020-05-07 07:19:50 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-or-later */ |
| 2 | |
Tobias Diedrich | e87c38e | 2010-11-27 09:40:16 +0000 | [diff] [blame] | 3 | /* |
Tobias Diedrich | e87c38e | 2010-11-27 09:40:16 +0000 | [diff] [blame] | 4 | * Based on src/southbridge/via/vt8237r/vt8237_fadt.c |
Tobias Diedrich | e87c38e | 2010-11-27 09:40:16 +0000 | [diff] [blame] | 5 | */ |
| 6 | |
Furquan Shaikh | 76cedd2 | 2020-05-02 10:24:23 -0700 | [diff] [blame] | 7 | #include <acpi/acpi.h> |
Tobias Diedrich | e87c38e | 2010-11-27 09:40:16 +0000 | [diff] [blame] | 8 | #include <device/device.h> |
| 9 | #include <device/pci.h> |
Elyes HAOUAS | 26071aa | 2019-02-15 08:21:33 +0100 | [diff] [blame] | 10 | #include <version.h> |
| 11 | |
Tobias Diedrich | e87c38e | 2010-11-27 09:40:16 +0000 | [diff] [blame] | 12 | #include "i82371eb.h" |
| 13 | |
| 14 | /** |
| 15 | * Create the Fixed ACPI Description Tables (FADT) for any board with this SB. |
| 16 | * Reference: ACPIspec40a, 5.2.9, page 118 |
| 17 | */ |
Kyösti Mälkki | 8ad52ff | 2020-05-30 14:50:50 +0300 | [diff] [blame] | 18 | void acpi_fill_fadt(acpi_fadt_t *fadt) |
Tobias Diedrich | e87c38e | 2010-11-27 09:40:16 +0000 | [diff] [blame] | 19 | { |
Tobias Diedrich | e87c38e | 2010-11-27 09:40:16 +0000 | [diff] [blame] | 20 | fadt->sci_int = 9; |
Kyösti Mälkki | c328a68 | 2019-11-23 07:23:40 +0200 | [diff] [blame] | 21 | |
Kyösti Mälkki | 0a9e72e | 2019-08-11 01:22:28 +0300 | [diff] [blame] | 22 | if (permanent_smi_handler()) { |
Kyösti Mälkki | c328a68 | 2019-11-23 07:23:40 +0200 | [diff] [blame] | 23 | /* TODO: SMI handler is not implemented. */ |
| 24 | fadt->smi_cmd = 0x00; |
| 25 | } |
Tobias Diedrich | e87c38e | 2010-11-27 09:40:16 +0000 | [diff] [blame] | 26 | |
| 27 | fadt->pm1a_evt_blk = DEFAULT_PMBASE; |
Tobias Diedrich | e87c38e | 2010-11-27 09:40:16 +0000 | [diff] [blame] | 28 | fadt->pm1a_cnt_blk = DEFAULT_PMBASE + PMCNTRL; |
Tobias Diedrich | e87c38e | 2010-11-27 09:40:16 +0000 | [diff] [blame] | 29 | |
Tobias Diedrich | e87c38e | 2010-11-27 09:40:16 +0000 | [diff] [blame] | 30 | fadt->pm_tmr_blk = DEFAULT_PMBASE + PMTMR; |
| 31 | fadt->gpe0_blk = DEFAULT_PMBASE + GPSTS; |
Tobias Diedrich | e87c38e | 2010-11-27 09:40:16 +0000 | [diff] [blame] | 32 | |
| 33 | /* *_len define register width in bytes */ |
| 34 | fadt->pm1_evt_len = 4; |
| 35 | fadt->pm1_cnt_len = 2; |
Tobias Diedrich | e87c38e | 2010-11-27 09:40:16 +0000 | [diff] [blame] | 36 | fadt->pm_tmr_len = 4; |
| 37 | fadt->gpe0_blk_len = 4; |
| 38 | |
Tobias Diedrich | e87c38e | 2010-11-27 09:40:16 +0000 | [diff] [blame] | 39 | fadt->p_lvl2_lat = 101; /* >100 means c2 not supported */ |
| 40 | fadt->p_lvl3_lat = 1001; /* >1000 means c3 not supported */ |
Tobias Diedrich | e87c38e | 2010-11-27 09:40:16 +0000 | [diff] [blame] | 41 | fadt->duty_offset = 1; /* bit 1:3 in PCNTRL reg (pmbase+0x10) */ |
| 42 | fadt->duty_width = 3; /* this width is in bits */ |
Elyes HAOUAS | 2119d0b | 2020-02-16 10:01:33 +0100 | [diff] [blame] | 43 | fadt->day_alrm = 0x0d; /* rtc CMOS RAM offset */ |
Tobias Diedrich | e87c38e | 2010-11-27 09:40:16 +0000 | [diff] [blame] | 44 | fadt->mon_alrm = 0x0; /* not supported */ |
| 45 | fadt->century = 0x0; /* not supported */ |
| 46 | /* |
| 47 | * bit meaning |
| 48 | * 0 1: We have user-visible legacy devices |
| 49 | * 1 1: 8042 |
| 50 | * 2 0: VGA is ok to probe |
| 51 | * 3 1: MSI are not supported |
| 52 | */ |
| 53 | fadt->iapc_boot_arch = 0xb; |
| 54 | /* |
| 55 | * bit meaning |
| 56 | * 0 WBINVD |
| 57 | * Processors in new ACPI-compatible systems are required to |
| 58 | * support this function and indicate this to OSPM by setting |
| 59 | * this field. |
| 60 | * 1 WBINVD_FLUSH |
| 61 | * If set, indicates that the hardware flushes all caches on the |
| 62 | * WBINVD instruction and maintains memory coherency, but does |
| 63 | * not guarantee the caches are invalidated. |
| 64 | * 2 PROC_C1 |
| 65 | * C1 power state (x86 hlt instruction) is supported on all cpus |
| 66 | * 3 P_LVL2_UP |
| 67 | * 0: C2 only on uniprocessor, 1: C2 on uni- and multiprocessor |
| 68 | * 4 PWR_BUTTON |
| 69 | * 0: pwr button is fixed feature |
| 70 | * 1: pwr button has control method device if present |
| 71 | * 5 SLP_BUTTON |
| 72 | * 0: sleep button is fixed feature |
| 73 | * 1: sleep button has control method device if present |
| 74 | * 6 FIX_RTC |
| 75 | * 0: RTC wake status supported in fixed register spce |
| 76 | * 7 RTC_S4 |
| 77 | * 1: RTC can wake from S4 |
| 78 | * 8 TMR_VAL_EXT |
| 79 | * 1: pmtimer is 32bit, 0: pmtimer is 24bit |
| 80 | * 9 DCK_CAP |
| 81 | * 1: system supports docking station |
| 82 | * 10 RESET_REG_SUPPORT |
| 83 | * 1: fadt describes reset register for system reset |
| 84 | * 11 SEALED_CASE |
| 85 | * 1: No expansion possible, sealed case |
| 86 | * 12 HEADLESS |
| 87 | * 1: Video output, keyboard and mouse are not connected |
| 88 | * 13 CPU_SW_SLP |
| 89 | * 1: Special processor instruction needs to be executed |
| 90 | * after writing SLP_TYP |
| 91 | * 14 PCI_EXP_WAK |
| 92 | * 1: PM1 regs support PCIEXP_WAKE_(STS|EN), must be set |
| 93 | * on platforms with pci express support |
| 94 | * 15 USE_PLATFORM_CLOCK |
| 95 | * 1: OS should prefer platform clock over processor internal |
| 96 | * clock. |
| 97 | * 16 S4_RTC_STS_VALID |
| 98 | * 17 REMOTE_POWER_ON_CAPABLE |
| 99 | * 1: platform correctly supports OSPM leaving GPE wake events |
| 100 | * armed prior to an S5 transition. |
| 101 | * 18 FORCE_APIC_CLUSTER_MODEL |
| 102 | * 19 FORCE_APIC_PHYSICAL_DESTINATION_MODE |
| 103 | */ |
Angel Pons | 79572e4 | 2020-07-13 00:17:43 +0200 | [diff] [blame] | 104 | fadt->flags |= 0xa5; |
Tobias Diedrich | e87c38e | 2010-11-27 09:40:16 +0000 | [diff] [blame] | 105 | |
Elyes HAOUAS | 04071f4 | 2020-07-20 17:05:24 +0200 | [diff] [blame] | 106 | fadt->x_pm1a_evt_blk.space_id = ACPI_ADDRESS_SPACE_IO; |
Tobias Diedrich | e87c38e | 2010-11-27 09:40:16 +0000 | [diff] [blame] | 107 | fadt->x_pm1a_evt_blk.bit_width = fadt->pm1_evt_len * 8; |
| 108 | fadt->x_pm1a_evt_blk.bit_offset = 0; |
Angel Pons | 12a4d05 | 2020-07-14 01:31:27 +0200 | [diff] [blame] | 109 | fadt->x_pm1a_evt_blk.access_size = ACPI_ACCESS_SIZE_WORD_ACCESS; |
Tobias Diedrich | e87c38e | 2010-11-27 09:40:16 +0000 | [diff] [blame] | 110 | fadt->x_pm1a_evt_blk.addrl = fadt->pm1a_evt_blk; |
| 111 | fadt->x_pm1a_evt_blk.addrh = 0x0; |
| 112 | |
Elyes HAOUAS | 04071f4 | 2020-07-20 17:05:24 +0200 | [diff] [blame] | 113 | fadt->x_pm1a_cnt_blk.space_id = ACPI_ADDRESS_SPACE_IO; |
Tobias Diedrich | e87c38e | 2010-11-27 09:40:16 +0000 | [diff] [blame] | 114 | fadt->x_pm1a_cnt_blk.bit_width = fadt->pm1_cnt_len * 8; |
| 115 | fadt->x_pm1a_cnt_blk.bit_offset = 0; |
Patrick Rudolph | c02bda0 | 2020-02-28 10:19:41 +0100 | [diff] [blame] | 116 | fadt->x_pm1a_cnt_blk.access_size = ACPI_ACCESS_SIZE_WORD_ACCESS; |
Tobias Diedrich | e87c38e | 2010-11-27 09:40:16 +0000 | [diff] [blame] | 117 | fadt->x_pm1a_cnt_blk.addrl = fadt->pm1a_cnt_blk; |
| 118 | fadt->x_pm1a_cnt_blk.addrh = 0x0; |
| 119 | |
Elyes HAOUAS | 04071f4 | 2020-07-20 17:05:24 +0200 | [diff] [blame] | 120 | fadt->x_pm_tmr_blk.space_id = ACPI_ADDRESS_SPACE_IO; |
Tobias Diedrich | e87c38e | 2010-11-27 09:40:16 +0000 | [diff] [blame] | 121 | fadt->x_pm_tmr_blk.bit_width = fadt->pm_tmr_len * 8; |
| 122 | fadt->x_pm_tmr_blk.bit_offset = 0; |
Patrick Rudolph | c02bda0 | 2020-02-28 10:19:41 +0100 | [diff] [blame] | 123 | fadt->x_pm_tmr_blk.access_size = ACPI_ACCESS_SIZE_DWORD_ACCESS; |
Tobias Diedrich | e87c38e | 2010-11-27 09:40:16 +0000 | [diff] [blame] | 124 | fadt->x_pm_tmr_blk.addrl = fadt->pm_tmr_blk; |
| 125 | fadt->x_pm_tmr_blk.addrh = 0x0; |
| 126 | |
Elyes HAOUAS | 04071f4 | 2020-07-20 17:05:24 +0200 | [diff] [blame] | 127 | fadt->x_gpe0_blk.space_id = ACPI_ADDRESS_SPACE_IO; |
Tobias Diedrich | e87c38e | 2010-11-27 09:40:16 +0000 | [diff] [blame] | 128 | fadt->x_gpe0_blk.bit_width = fadt->gpe0_blk_len * 8; |
| 129 | fadt->x_gpe0_blk.bit_offset = 0; |
Patrick Rudolph | c02bda0 | 2020-02-28 10:19:41 +0100 | [diff] [blame] | 130 | fadt->x_gpe0_blk.access_size = ACPI_ACCESS_SIZE_BYTE_ACCESS; |
Tobias Diedrich | e87c38e | 2010-11-27 09:40:16 +0000 | [diff] [blame] | 131 | fadt->x_gpe0_blk.addrl = fadt->gpe0_blk; |
| 132 | fadt->x_gpe0_blk.addrh = 0x0; |
Tobias Diedrich | e87c38e | 2010-11-27 09:40:16 +0000 | [diff] [blame] | 133 | } |