Angel Pons | ae59387 | 2020-04-04 18:50:57 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Marshall Dawson | 4ee83b2 | 2019-05-03 11:44:22 -0600 | [diff] [blame] | 2 | |
Felix Held | 14e3432 | 2020-11-14 00:30:21 +0100 | [diff] [blame] | 3 | #ifndef AMD_BLOCK_ACPI_H |
| 4 | #define AMD_BLOCK_ACPI_H |
Marshall Dawson | 4ee83b2 | 2019-05-03 11:44:22 -0600 | [diff] [blame] | 5 | |
Raul E Rangel | 0f3bc81 | 2021-02-10 16:36:33 -0700 | [diff] [blame] | 6 | #include <acpi/acpi.h> |
Felix Held | dea4e0f | 2021-09-22 20:05:53 +0200 | [diff] [blame] | 7 | #include <amdblocks/gpio.h> |
Felix Held | 3aaf8ef | 2024-01-26 14:19:56 +0100 | [diff] [blame] | 8 | #include <device/device.h> |
Raul E Rangel | 0f3bc81 | 2021-02-10 16:36:33 -0700 | [diff] [blame] | 9 | #include <types.h> |
Marshall Dawson | 4ee83b2 | 2019-05-03 11:44:22 -0600 | [diff] [blame] | 10 | |
Felix Held | 0079200 | 2024-01-26 14:41:14 +0100 | [diff] [blame] | 11 | #define ACPI_SCI_IRQ 9 |
| 12 | |
Marshall Dawson | 4ee83b2 | 2019-05-03 11:44:22 -0600 | [diff] [blame] | 13 | /* ACPI MMIO registers 0xfed80800 */ |
Raul E Rangel | 12c6a58 | 2021-02-10 16:45:49 -0700 | [diff] [blame] | 14 | #define MMIO_ACPI_PM1_EVT_BLK 0x00 |
| 15 | #define MMIO_ACPI_PM1_STS 0x00 |
| 16 | #define MMIO_ACPI_PM1_EN 0x02 |
Marshall Dawson | 4ee83b2 | 2019-05-03 11:44:22 -0600 | [diff] [blame] | 17 | #define MMIO_ACPI_PM1_CNT_BLK 0x04 |
Felix Held | 30c1bb6 | 2021-11-22 20:29:04 +0100 | [diff] [blame] | 18 | /* sleep types defined in include/acpi/acpi.h */ |
Marshall Dawson | 4ee83b2 | 2019-05-03 11:44:22 -0600 | [diff] [blame] | 19 | #define ACPI_PM1_CNT_SCIEN BIT(0) |
| 20 | #define MMIO_ACPI_PM_TMR_BLK 0x08 |
Raul E Rangel | 12c6a58 | 2021-02-10 16:45:49 -0700 | [diff] [blame] | 21 | #define MMIO_ACPI_GPE0_BLK 0x14 |
| 22 | #define MMIO_ACPI_GPE0_STS 0x14 |
| 23 | #define MMIO_ACPI_GPE0_EN 0x18 |
Marshall Dawson | 4ee83b2 | 2019-05-03 11:44:22 -0600 | [diff] [blame] | 24 | |
Aaron Durbin | 746e598 | 2020-08-14 14:48:45 -0600 | [diff] [blame] | 25 | /* Structure to maintain standard ACPI register state for reporting purposes. */ |
| 26 | struct acpi_pm_gpe_state { |
| 27 | uint16_t pm1_sts; |
| 28 | uint16_t pm1_en; |
| 29 | uint32_t gpe0_sts; |
| 30 | uint32_t gpe0_en; |
| 31 | uint16_t previous_sx_state; |
| 32 | uint16_t aligning_field; |
| 33 | }; |
| 34 | |
| 35 | /* Fill object with the ACPI PM and GPE state. */ |
| 36 | void acpi_fill_pm_gpe_state(struct acpi_pm_gpe_state *state); |
| 37 | /* Save events to eventlog log and also print information on console. */ |
Kyösti Mälkki | b0db813 | 2021-01-21 16:34:43 +0200 | [diff] [blame] | 38 | void acpi_pm_gpe_add_events_print_events(void); |
Aaron Durbin | 746e598 | 2020-08-14 14:48:45 -0600 | [diff] [blame] | 39 | /* Clear PM and GPE status registers. */ |
| 40 | void acpi_clear_pm_gpe_status(void); |
| 41 | |
Marshall Dawson | 4ee83b2 | 2019-05-03 11:44:22 -0600 | [diff] [blame] | 42 | /* |
| 43 | * If a system reset is about to be requested, modify the PM1 register so it |
| 44 | * will never be misinterpreted as an S3 resume. |
| 45 | */ |
| 46 | void set_pm1cnt_s5(void); |
| 47 | void acpi_enable_sci(void); |
| 48 | void acpi_disable_sci(void); |
| 49 | |
Kyösti Mälkki | b0db813 | 2021-01-21 16:34:43 +0200 | [diff] [blame] | 50 | struct chipset_power_state { |
| 51 | struct acpi_pm_gpe_state gpe_state; |
| 52 | struct gpio_wake_state gpio_state; |
| 53 | }; |
| 54 | |
Felix Held | d9e8263 | 2024-01-26 14:22:31 +0100 | [diff] [blame] | 55 | unsigned long soc_acpi_write_tables(const struct device *device, unsigned long current, |
| 56 | acpi_rsdp_t *rsdp); |
| 57 | |
Felix Held | 26577d2 | 2024-01-26 15:05:40 +0100 | [diff] [blame] | 58 | unsigned long acpi_add_fsp_tables(unsigned long current, acpi_rsdp_t *rsdp); |
| 59 | |
Raul E Rangel | 0f3bc81 | 2021-02-10 16:36:33 -0700 | [diff] [blame] | 60 | unsigned long southbridge_write_acpi_tables(const struct device *device, unsigned long current, |
| 61 | struct acpi_rsdp *rsdp); |
| 62 | |
Karthikeyan Ramasubramanian | 589ac69 | 2021-07-15 14:58:23 -0600 | [diff] [blame] | 63 | void acpi_log_events(const struct chipset_power_state *ps); |
Felix Held | 39feb7f | 2024-01-26 15:11:48 +0100 | [diff] [blame] | 64 | |
| 65 | unsigned long acpi_add_crat_table(unsigned long current, acpi_rsdp_t *rsdp); |
Felix Held | a4a2a4f | 2024-01-25 18:53:54 +0100 | [diff] [blame] | 66 | unsigned long acpi_add_ivrs_table(unsigned long current, acpi_rsdp_t *rsdp); |
Karthikeyan Ramasubramanian | 589ac69 | 2021-07-15 14:58:23 -0600 | [diff] [blame] | 67 | |
Felix Held | 14e3432 | 2020-11-14 00:30:21 +0100 | [diff] [blame] | 68 | #endif /* AMD_BLOCK_ACPI_H */ |