blob: a195371cb920d527fb614fee3a5de353e4fcd9ee [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>
Raul E Rangel0f3bc812021-02-10 16:36:33 -07008#include <types.h>
Marshall Dawson4ee83b22019-05-03 11:44:22 -06009
10/* ACPI MMIO registers 0xfed80800 */
Raul E Rangel12c6a582021-02-10 16:45:49 -070011#define MMIO_ACPI_PM1_EVT_BLK 0x00
12#define MMIO_ACPI_PM1_STS 0x00
13#define MMIO_ACPI_PM1_EN 0x02
Marshall Dawson4ee83b22019-05-03 11:44:22 -060014#define MMIO_ACPI_PM1_CNT_BLK 0x04
Felix Held30c1bb62021-11-22 20:29:04 +010015 /* sleep types defined in include/acpi/acpi.h */
Marshall Dawson4ee83b22019-05-03 11:44:22 -060016#define ACPI_PM1_CNT_SCIEN BIT(0)
17#define MMIO_ACPI_PM_TMR_BLK 0x08
Raul E Rangel12c6a582021-02-10 16:45:49 -070018#define MMIO_ACPI_GPE0_BLK 0x14
19#define MMIO_ACPI_GPE0_STS 0x14
20#define MMIO_ACPI_GPE0_EN 0x18
Marshall Dawson4ee83b22019-05-03 11:44:22 -060021
Aaron Durbin746e5982020-08-14 14:48:45 -060022/* Structure to maintain standard ACPI register state for reporting purposes. */
23struct acpi_pm_gpe_state {
24 uint16_t pm1_sts;
25 uint16_t pm1_en;
26 uint32_t gpe0_sts;
27 uint32_t gpe0_en;
28 uint16_t previous_sx_state;
29 uint16_t aligning_field;
30};
31
32/* Fill object with the ACPI PM and GPE state. */
33void acpi_fill_pm_gpe_state(struct acpi_pm_gpe_state *state);
34/* Save events to eventlog log and also print information on console. */
Kyösti Mälkkib0db8132021-01-21 16:34:43 +020035void acpi_pm_gpe_add_events_print_events(void);
Aaron Durbin746e5982020-08-14 14:48:45 -060036/* Clear PM and GPE status registers. */
37void acpi_clear_pm_gpe_status(void);
38
Marshall Dawson4ee83b22019-05-03 11:44:22 -060039/*
40 * If a system reset is about to be requested, modify the PM1 register so it
41 * will never be misinterpreted as an S3 resume.
42 */
43void set_pm1cnt_s5(void);
44void acpi_enable_sci(void);
45void acpi_disable_sci(void);
46
Kyösti Mälkkib0db8132021-01-21 16:34:43 +020047struct chipset_power_state {
48 struct acpi_pm_gpe_state gpe_state;
49 struct gpio_wake_state gpio_state;
50};
51
Raul E Rangel0f3bc812021-02-10 16:36:33 -070052unsigned long southbridge_write_acpi_tables(const struct device *device, unsigned long current,
53 struct acpi_rsdp *rsdp);
54
Felix Held245adca2021-05-04 20:01:46 +020055uintptr_t add_agesa_fsp_acpi_table(guid_t guid, const char *name, acpi_rsdp_t *rsdp,
56 uintptr_t current);
57
Karthikeyan Ramasubramanian589ac692021-07-15 14:58:23 -060058void acpi_log_events(const struct chipset_power_state *ps);
Felix Helda4a2a4f2024-01-25 18:53:54 +010059unsigned long acpi_add_ivrs_table(unsigned long current, acpi_rsdp_t *rsdp);
Karthikeyan Ramasubramanian589ac692021-07-15 14:58:23 -060060
Felix Held14e34322020-11-14 00:30:21 +010061#endif /* AMD_BLOCK_ACPI_H */