1 /* SPDX-License-Identifier: GPL-2.0 */
3 * Copyright 2019 Google LLC
26 * struct acpi_pmc_upriv - holds common data for the x86 PMC
28 * @pmc_bar0: Base address 0 of PMC
29 * @pmc_bar1: Base address 2 of PMC
30 * @acpi_base: Base address of ACPI block
31 * @pm1_sts: PM1 status
33 * @pm1_cnt: PM1 control
34 * @gpe_cfg: Address of GPE_CFG register
35 * @gpe0_dwx_mask: Mask to use for each GPE0 (typically 7 or 0xf)
36 * @gpe0_dwx_shift_base: Base shift value to use for GPE0 (0 or 4)
37 * @gpe0_sts_req: GPE0 status register offset
38 * @gpe0_en_req: GPE0 enable register offset
39 * @gpe0_sts: GPE0 status values
40 * @gpe0_en: GPE0 enable values
41 * @gpe0_dw: GPE0 DW values
42 * @gpe0_count: Number of GPE0 registers
43 * @tco1_sts: TCO1 status
44 * @tco2_sts: TCO2 status
45 * @prsts: Power and reset status
46 * @gen_pmcon1: General power mgmt configuration 1
47 * @gen_pmcon2: General power mgmt configuration 2
48 * @gen_pmcon3: General power mgmt configuration 3
50 struct acpi_pmc_upriv {
59 u32 gpe0_dwx_shift_base;
62 u32 gpe0_sts[GPE0_REG_MAX];
63 u32 gpe0_en[GPE0_REG_MAX];
64 u32 gpe0_dw[GPE0_REG_MAX];
76 * init() - Set up the PMC for use
78 * This reads the current state of the PMC. Most of the state is read
79 * automatically by the uclass since it is common.
83 * @dev: PMC device to use
84 * @return 0 if OK, -ve on error
86 int (*init)(struct udevice *dev);
89 * prev_sleep_state() - Get the previous sleep state (optional)
91 * This reads various state registers and returns the sleep state from
92 * which the system woke. If this method is not provided, the uclass
93 * will return a calculated value.
97 * @dev: PMC device to use
98 * @prev_sleep_state: Previous sleep state as calculated by the uclass.
99 * The method can use this as the return value or calculate its
102 * @return enum acpi_sleep_state indicating the previous sleep state
103 * (ACPI_S0, ACPI_S3 or ACPI_S5), or -ve on error
105 int (*prev_sleep_state)(struct udevice *dev, int prev_sleep_state);
108 * disable_tco() - Disable the timer/counter
110 * Disables the timer/counter in the PMC
114 * @dev: PMC device to use
117 int (*disable_tco)(struct udevice *dev);
120 * global_reset_set_enable() - Enable/Disable global reset
122 * Enable or disable global reset. If global reset is enabled, both hard
123 * reset and soft reset will trigger global reset, where both host and
124 * TXE are reset. This is cleared on cold boot, hard reset, soft reset
129 * @dev: PMC device to use
130 * @enable: true to enable global reset, false to disable
133 int (*global_reset_set_enable)(struct udevice *dev, bool enable);
136 #define acpi_pmc_get_ops(dev) ((struct acpi_pmc_ops *)(dev)->driver->ops)
139 * init() - Set up the PMC for use
141 * This reads the current state of the PMC. This reads in the common registers,
142 * then calls the device's init() method to read the SoC-specific registers.
144 * @return 0 if OK, -ve on error
146 int pmc_init(struct udevice *dev);
149 * pmc_prev_sleep_state() - Get the previous sleep state
151 * This reads various state registers and returns the sleep state from
152 * which the system woke.
154 * @return enum acpi_sleep_state indicating the previous sleep state
155 * (ACPI_S0, ACPI_S3 or ACPI_S5), or -ve on error
157 int pmc_prev_sleep_state(struct udevice *dev);
160 * pmc_disable_tco() - Disable the timer/counter
162 * Disables the timer/counter in the PMC
164 * @dev: PMC device to use
167 int pmc_disable_tco(struct udevice *dev);
170 * pmc_global_reset_set_enable() - Enable/Disable global reset
172 * Enable or disable global reset. If global reset is enabled, both hard
173 * reset and soft reset will trigger global reset, where both host and
174 * TXE are reset. This is cleared on cold boot, hard reset, soft reset
177 * @dev: PMC device to use
178 * @enable: true to enable global reset, false to disable
181 int pmc_global_reset_set_enable(struct udevice *dev, bool enable);
183 int pmc_ofdata_to_uc_platdata(struct udevice *dev);
185 int pmc_disable_tco_base(ulong tco_base);
187 void pmc_dump_info(struct udevice *dev);
190 * pmc_gpe_init() - Set up general-purpose events
193 * @return 0 if OK, -ve on error
195 int pmc_gpe_init(struct udevice *dev);
197 #endif /* !__ASSEMBLY__ */