blob: e2d1c32159ac8d14e09f4f5f3961f5c5afcfce5d [file] [log] [blame]
Angel Ponsae593872020-04-04 18:50:57 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Marshall Dawson4ee83b22019-05-03 11:44:22 -06002
Felix Held14e34322020-11-14 00:30:21 +01003#ifndef AMD_BLOCK_ACPI_H
4#define AMD_BLOCK_ACPI_H
Marshall Dawson4ee83b22019-05-03 11:44:22 -06005
Raul E Rangel0f3bc812021-02-10 16:36:33 -07006#include <acpi/acpi.h>
Felix Helddea4e0f2021-09-22 20:05:53 +02007#include <amdblocks/gpio.h>
Felix Held3aaf8ef2024-01-26 14:19:56 +01008#include <device/device.h>
Raul E Rangel0f3bc812021-02-10 16:36:33 -07009#include <types.h>
Marshall Dawson4ee83b22019-05-03 11:44:22 -060010
Felix Held00792002024-01-26 14:41:14 +010011#define ACPI_SCI_IRQ 9
12
Marshall Dawson4ee83b22019-05-03 11:44:22 -060013/* ACPI MMIO registers 0xfed80800 */
Raul E Rangel12c6a582021-02-10 16:45:49 -070014#define MMIO_ACPI_PM1_EVT_BLK 0x00
15#define MMIO_ACPI_PM1_STS 0x00
16#define MMIO_ACPI_PM1_EN 0x02
Marshall Dawson4ee83b22019-05-03 11:44:22 -060017#define MMIO_ACPI_PM1_CNT_BLK 0x04
Felix Held30c1bb62021-11-22 20:29:04 +010018 /* sleep types defined in include/acpi/acpi.h */
Marshall Dawson4ee83b22019-05-03 11:44:22 -060019#define ACPI_PM1_CNT_SCIEN BIT(0)
20#define MMIO_ACPI_PM_TMR_BLK 0x08
Raul E Rangel12c6a582021-02-10 16:45:49 -070021#define MMIO_ACPI_GPE0_BLK 0x14
22#define MMIO_ACPI_GPE0_STS 0x14
23#define MMIO_ACPI_GPE0_EN 0x18
Marshall Dawson4ee83b22019-05-03 11:44:22 -060024
Aaron Durbin746e5982020-08-14 14:48:45 -060025/* Structure to maintain standard ACPI register state for reporting purposes. */
26struct 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. */
36void 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älkkib0db8132021-01-21 16:34:43 +020038void acpi_pm_gpe_add_events_print_events(void);
Aaron Durbin746e5982020-08-14 14:48:45 -060039/* Clear PM and GPE status registers. */
40void acpi_clear_pm_gpe_status(void);
41
Marshall Dawson4ee83b22019-05-03 11:44:22 -060042/*
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 */
46void set_pm1cnt_s5(void);
47void acpi_enable_sci(void);
48void acpi_disable_sci(void);
49
Kyösti Mälkkib0db8132021-01-21 16:34:43 +020050struct chipset_power_state {
51 struct acpi_pm_gpe_state gpe_state;
52 struct gpio_wake_state gpio_state;
53};
54
Felix Heldd9e82632024-01-26 14:22:31 +010055unsigned long soc_acpi_write_tables(const struct device *device, unsigned long current,
56 acpi_rsdp_t *rsdp);
57
Felix Held26577d22024-01-26 15:05:40 +010058unsigned long acpi_add_fsp_tables(unsigned long current, acpi_rsdp_t *rsdp);
59
Raul E Rangel0f3bc812021-02-10 16:36:33 -070060unsigned long southbridge_write_acpi_tables(const struct device *device, unsigned long current,
61 struct acpi_rsdp *rsdp);
62
Karthikeyan Ramasubramanian589ac692021-07-15 14:58:23 -060063void acpi_log_events(const struct chipset_power_state *ps);
Felix Held39feb7f2024-01-26 15:11:48 +010064
65unsigned long acpi_add_crat_table(unsigned long current, acpi_rsdp_t *rsdp);
Felix Helda4a2a4f2024-01-25 18:53:54 +010066unsigned long acpi_add_ivrs_table(unsigned long current, acpi_rsdp_t *rsdp);
Karthikeyan Ramasubramanian589ac692021-07-15 14:58:23 -060067
Felix Held14e34322020-11-14 00:30:21 +010068#endif /* AMD_BLOCK_ACPI_H */