1 /* SPDX-License-Identifier: GPL-2.0 */
3 * Copyright 2019 Google LLC
14 * struct acpi_pmc_upriv - holds common data for the x86 PMC
16 * @pmc_bar0: Base address 0 of PMC
17 * @pmc_bar1: Base address 2 of PMC
18 * @acpi_base: Base address of ACPI block
19 * @pm1_sts: PM1 status
21 * @pm1_cnt: PM1 control
22 * @gpe_cfg: Address of GPE_CFG register
23 * @gpe0_dwx_mask: Mask to use for each GPE0 (typically 7 or 0xf)
24 * @gpe0_dwx_shift_base: Base shift value to use for GPE0 (0 or 4)
25 * @gpe0_sts_req: GPE0 status register offset
26 * @gpe0_en_req: GPE0 enable register offset
27 * @gpe0_sts: GPE0 status values
28 * @gpe0_en: GPE0 enable values
29 * @gpe0_dw: GPE0 DW values
30 * @gpe0_count: Number of GPE0 registers
31 * @tco1_sts: TCO1 status
32 * @tco2_sts: TCO2 status
33 * @prsts: Power and reset status
34 * @gen_pmcon1: General power mgmt configuration 1
35 * @gen_pmcon2: General power mgmt configuration 2
36 * @gen_pmcon3: General power mgmt configuration 3
38 struct acpi_pmc_upriv {
47 u32 gpe0_dwx_shift_base;
50 u32 gpe0_sts[GPE0_REG_MAX];
51 u32 gpe0_en[GPE0_REG_MAX];
52 u32 gpe0_dw[GPE0_REG_MAX];
64 * init() - Set up the PMC for use
66 * This reads the current state of the PMC. Most of the state is read
67 * automatically by the uclass since it is common.
71 * @dev: PMC device to use
72 * @return 0 if OK, -ve on error
74 int (*init)(struct udevice *dev);
77 * prev_sleep_state() - Get the previous sleep state (optional)
79 * This reads various state registers and returns the sleep state from
80 * which the system woke. If this method is not provided, the uclass
81 * will return a calculated value.
85 * @dev: PMC device to use
86 * @prev_sleep_state: Previous sleep state as calculated by the uclass.
87 * The method can use this as the return value or calculate its
90 * @return enum acpi_sleep_state indicating the previous sleep state
91 * (ACPI_S0, ACPI_S3 or ACPI_S5), or -ve on error
93 int (*prev_sleep_state)(struct udevice *dev, int prev_sleep_state);
96 * disable_tco() - Disable the timer/counter
98 * Disables the timer/counter in the PMC
102 * @dev: PMC device to use
105 int (*disable_tco)(struct udevice *dev);
108 * global_reset_set_enable() - Enable/Disable global reset
110 * Enable or disable global reset. If global reset is enabled, both hard
111 * reset and soft reset will trigger global reset, where both host and
112 * TXE are reset. This is cleared on cold boot, hard reset, soft reset
117 * @dev: PMC device to use
118 * @enable: true to enable global reset, false to disable
121 int (*global_reset_set_enable)(struct udevice *dev, bool enable);
124 #define acpi_pmc_get_ops(dev) ((struct acpi_pmc_ops *)(dev)->driver->ops)
127 * init() - Set up the PMC for use
129 * This reads the current state of the PMC. This reads in the common registers,
130 * then calls the device's init() method to read the SoC-specific registers.
132 * @return 0 if OK, -ve on error
134 int pmc_init(struct udevice *dev);
137 * pmc_prev_sleep_state() - Get the previous sleep state
139 * This reads various state registers and returns the sleep state from
140 * which the system woke.
142 * @return enum acpi_sleep_state indicating the previous sleep state
143 * (ACPI_S0, ACPI_S3 or ACPI_S5), or -ve on error
145 int pmc_prev_sleep_state(struct udevice *dev);
148 * pmc_disable_tco() - Disable the timer/counter
150 * Disables the timer/counter in the PMC
152 * @dev: PMC device to use
155 int pmc_disable_tco(struct udevice *dev);
158 * pmc_global_reset_set_enable() - Enable/Disable global reset
160 * Enable or disable global reset. If global reset is enabled, both hard
161 * reset and soft reset will trigger global reset, where both host and
162 * TXE are reset. This is cleared on cold boot, hard reset, soft reset
165 * @dev: PMC device to use
166 * @enable: true to enable global reset, false to disable
169 int pmc_global_reset_set_enable(struct udevice *dev, bool enable);
171 int pmc_ofdata_to_uc_platdata(struct udevice *dev);
173 int pmc_disable_tco_base(ulong tco_base);
175 void pmc_dump_info(struct udevice *dev);
178 * pmc_gpe_init() - Set up general-purpose events
181 * @return 0 if OK, -ve on error
183 int pmc_gpe_init(struct udevice *dev);