xref: /openbmc/linux/drivers/pmdomain/amlogic/meson-ee-pwrc.c (revision b97d6790d03b763eca08847a9a5869a4291b9f9a)
1e2ad626fSUlf Hansson // SPDX-License-Identifier: GPL-2.0+
2e2ad626fSUlf Hansson /*
3e2ad626fSUlf Hansson  * Copyright (c) 2019 BayLibre, SAS
4e2ad626fSUlf Hansson  * Author: Neil Armstrong <narmstrong@baylibre.com>
5e2ad626fSUlf Hansson  */
6e2ad626fSUlf Hansson 
7e2ad626fSUlf Hansson #include <linux/platform_device.h>
8e2ad626fSUlf Hansson #include <linux/pm_domain.h>
9e2ad626fSUlf Hansson #include <linux/bitfield.h>
10e2ad626fSUlf Hansson #include <linux/regmap.h>
11e2ad626fSUlf Hansson #include <linux/mfd/syscon.h>
12e2ad626fSUlf Hansson #include <linux/of.h>
13e2ad626fSUlf Hansson #include <linux/reset-controller.h>
14e2ad626fSUlf Hansson #include <linux/reset.h>
15e2ad626fSUlf Hansson #include <linux/clk.h>
16e2ad626fSUlf Hansson #include <linux/module.h>
17e2ad626fSUlf Hansson #include <dt-bindings/power/meson8-power.h>
18e2ad626fSUlf Hansson #include <dt-bindings/power/meson-axg-power.h>
19e2ad626fSUlf Hansson #include <dt-bindings/power/meson-g12a-power.h>
20e2ad626fSUlf Hansson #include <dt-bindings/power/meson-gxbb-power.h>
21e2ad626fSUlf Hansson #include <dt-bindings/power/meson-sm1-power.h>
22e2ad626fSUlf Hansson 
23e2ad626fSUlf Hansson /* AO Offsets */
24e2ad626fSUlf Hansson 
25e2ad626fSUlf Hansson #define GX_AO_RTI_GEN_PWR_SLEEP0	(0x3a << 2)
26e2ad626fSUlf Hansson #define GX_AO_RTI_GEN_PWR_ISO0		(0x3b << 2)
27e2ad626fSUlf Hansson 
28e2ad626fSUlf Hansson /*
29e2ad626fSUlf Hansson  * Meson8/Meson8b/Meson8m2 only expose the power management registers of the
30e2ad626fSUlf Hansson  * AO-bus as syscon. 0x3a from GX translates to 0x02, 0x3b translates to 0x03
31e2ad626fSUlf Hansson  * and so on.
32e2ad626fSUlf Hansson  */
33e2ad626fSUlf Hansson #define MESON8_AO_RTI_GEN_PWR_SLEEP0	(0x02 << 2)
34e2ad626fSUlf Hansson #define MESON8_AO_RTI_GEN_PWR_ISO0	(0x03 << 2)
35e2ad626fSUlf Hansson 
36e2ad626fSUlf Hansson /* HHI Offsets */
37e2ad626fSUlf Hansson 
38e2ad626fSUlf Hansson #define HHI_MEM_PD_REG0			(0x40 << 2)
39e2ad626fSUlf Hansson #define HHI_VPU_MEM_PD_REG0		(0x41 << 2)
40e2ad626fSUlf Hansson #define HHI_VPU_MEM_PD_REG1		(0x42 << 2)
41e2ad626fSUlf Hansson #define HHI_VPU_MEM_PD_REG3		(0x43 << 2)
42e2ad626fSUlf Hansson #define HHI_VPU_MEM_PD_REG4		(0x44 << 2)
43e2ad626fSUlf Hansson #define HHI_AUDIO_MEM_PD_REG0		(0x45 << 2)
44e2ad626fSUlf Hansson #define HHI_NANOQ_MEM_PD_REG0		(0x46 << 2)
45e2ad626fSUlf Hansson #define HHI_NANOQ_MEM_PD_REG1		(0x47 << 2)
46e2ad626fSUlf Hansson #define HHI_VPU_MEM_PD_REG2		(0x4d << 2)
47e2ad626fSUlf Hansson 
48e2ad626fSUlf Hansson #define G12A_HHI_NANOQ_MEM_PD_REG0	(0x43 << 2)
49e2ad626fSUlf Hansson #define G12A_HHI_NANOQ_MEM_PD_REG1	(0x44 << 2)
50e2ad626fSUlf Hansson 
51e2ad626fSUlf Hansson struct meson_ee_pwrc;
52e2ad626fSUlf Hansson struct meson_ee_pwrc_domain;
53e2ad626fSUlf Hansson 
54e2ad626fSUlf Hansson struct meson_ee_pwrc_mem_domain {
55e2ad626fSUlf Hansson 	unsigned int reg;
56e2ad626fSUlf Hansson 	unsigned int mask;
57e2ad626fSUlf Hansson };
58e2ad626fSUlf Hansson 
59e2ad626fSUlf Hansson struct meson_ee_pwrc_top_domain {
60e2ad626fSUlf Hansson 	unsigned int sleep_reg;
61e2ad626fSUlf Hansson 	unsigned int sleep_mask;
62e2ad626fSUlf Hansson 	unsigned int iso_reg;
63e2ad626fSUlf Hansson 	unsigned int iso_mask;
64e2ad626fSUlf Hansson };
65e2ad626fSUlf Hansson 
66e2ad626fSUlf Hansson struct meson_ee_pwrc_domain_desc {
67e2ad626fSUlf Hansson 	char *name;
68e2ad626fSUlf Hansson 	unsigned int reset_names_count;
69e2ad626fSUlf Hansson 	unsigned int clk_names_count;
70e2ad626fSUlf Hansson 	struct meson_ee_pwrc_top_domain *top_pd;
71e2ad626fSUlf Hansson 	unsigned int mem_pd_count;
72e2ad626fSUlf Hansson 	struct meson_ee_pwrc_mem_domain *mem_pd;
73e2ad626fSUlf Hansson 	bool (*is_powered_off)(struct meson_ee_pwrc_domain *pwrc_domain);
74e2ad626fSUlf Hansson };
75e2ad626fSUlf Hansson 
76e2ad626fSUlf Hansson struct meson_ee_pwrc_domain_data {
77e2ad626fSUlf Hansson 	unsigned int count;
78e2ad626fSUlf Hansson 	struct meson_ee_pwrc_domain_desc *domains;
79e2ad626fSUlf Hansson };
80e2ad626fSUlf Hansson 
81e2ad626fSUlf Hansson /* TOP Power Domains */
82e2ad626fSUlf Hansson 
83e2ad626fSUlf Hansson static struct meson_ee_pwrc_top_domain gx_pwrc_vpu = {
84e2ad626fSUlf Hansson 	.sleep_reg = GX_AO_RTI_GEN_PWR_SLEEP0,
85e2ad626fSUlf Hansson 	.sleep_mask = BIT(8),
86e2ad626fSUlf Hansson 	.iso_reg = GX_AO_RTI_GEN_PWR_SLEEP0,
87e2ad626fSUlf Hansson 	.iso_mask = BIT(9),
88e2ad626fSUlf Hansson };
89e2ad626fSUlf Hansson 
90e2ad626fSUlf Hansson static struct meson_ee_pwrc_top_domain meson8_pwrc_vpu = {
91e2ad626fSUlf Hansson 	.sleep_reg = MESON8_AO_RTI_GEN_PWR_SLEEP0,
92e2ad626fSUlf Hansson 	.sleep_mask = BIT(8),
93e2ad626fSUlf Hansson 	.iso_reg = MESON8_AO_RTI_GEN_PWR_SLEEP0,
94e2ad626fSUlf Hansson 	.iso_mask = BIT(9),
95e2ad626fSUlf Hansson };
96e2ad626fSUlf Hansson 
97e2ad626fSUlf Hansson #define SM1_EE_PD(__bit)					\
98e2ad626fSUlf Hansson 	{							\
99e2ad626fSUlf Hansson 		.sleep_reg = GX_AO_RTI_GEN_PWR_SLEEP0, 		\
100e2ad626fSUlf Hansson 		.sleep_mask = BIT(__bit), 			\
101e2ad626fSUlf Hansson 		.iso_reg = GX_AO_RTI_GEN_PWR_ISO0, 		\
102e2ad626fSUlf Hansson 		.iso_mask = BIT(__bit), 			\
103e2ad626fSUlf Hansson 	}
104e2ad626fSUlf Hansson 
105e2ad626fSUlf Hansson static struct meson_ee_pwrc_top_domain sm1_pwrc_vpu = SM1_EE_PD(8);
106e2ad626fSUlf Hansson static struct meson_ee_pwrc_top_domain sm1_pwrc_nna = SM1_EE_PD(16);
107e2ad626fSUlf Hansson static struct meson_ee_pwrc_top_domain sm1_pwrc_usb = SM1_EE_PD(17);
108e2ad626fSUlf Hansson static struct meson_ee_pwrc_top_domain sm1_pwrc_pci = SM1_EE_PD(18);
109e2ad626fSUlf Hansson static struct meson_ee_pwrc_top_domain sm1_pwrc_ge2d = SM1_EE_PD(19);
110e2ad626fSUlf Hansson 
111e2ad626fSUlf Hansson static struct meson_ee_pwrc_top_domain g12a_pwrc_nna = {
112e2ad626fSUlf Hansson 	.sleep_reg = GX_AO_RTI_GEN_PWR_SLEEP0,
113e2ad626fSUlf Hansson 	.sleep_mask = BIT(16) | BIT(17),
114e2ad626fSUlf Hansson 	.iso_reg = GX_AO_RTI_GEN_PWR_ISO0,
115e2ad626fSUlf Hansson 	.iso_mask = BIT(16) | BIT(17),
116e2ad626fSUlf Hansson };
117e2ad626fSUlf Hansson 
118e2ad626fSUlf Hansson /* Memory PD Domains */
119e2ad626fSUlf Hansson 
120e2ad626fSUlf Hansson #define VPU_MEMPD(__reg)					\
121e2ad626fSUlf Hansson 	{ __reg, GENMASK(1, 0) },				\
122e2ad626fSUlf Hansson 	{ __reg, GENMASK(3, 2) },				\
123e2ad626fSUlf Hansson 	{ __reg, GENMASK(5, 4) },				\
124e2ad626fSUlf Hansson 	{ __reg, GENMASK(7, 6) },				\
125e2ad626fSUlf Hansson 	{ __reg, GENMASK(9, 8) },				\
126e2ad626fSUlf Hansson 	{ __reg, GENMASK(11, 10) },				\
127e2ad626fSUlf Hansson 	{ __reg, GENMASK(13, 12) },				\
128e2ad626fSUlf Hansson 	{ __reg, GENMASK(15, 14) },				\
129e2ad626fSUlf Hansson 	{ __reg, GENMASK(17, 16) },				\
130e2ad626fSUlf Hansson 	{ __reg, GENMASK(19, 18) },				\
131e2ad626fSUlf Hansson 	{ __reg, GENMASK(21, 20) },				\
132e2ad626fSUlf Hansson 	{ __reg, GENMASK(23, 22) },				\
133e2ad626fSUlf Hansson 	{ __reg, GENMASK(25, 24) },				\
134e2ad626fSUlf Hansson 	{ __reg, GENMASK(27, 26) },				\
135e2ad626fSUlf Hansson 	{ __reg, GENMASK(29, 28) },				\
136e2ad626fSUlf Hansson 	{ __reg, GENMASK(31, 30) }
137e2ad626fSUlf Hansson 
138e2ad626fSUlf Hansson #define VPU_HHI_MEMPD(__reg)					\
139e2ad626fSUlf Hansson 	{ __reg, BIT(8) },					\
140e2ad626fSUlf Hansson 	{ __reg, BIT(9) },					\
141e2ad626fSUlf Hansson 	{ __reg, BIT(10) },					\
142e2ad626fSUlf Hansson 	{ __reg, BIT(11) },					\
143e2ad626fSUlf Hansson 	{ __reg, BIT(12) },					\
144e2ad626fSUlf Hansson 	{ __reg, BIT(13) },					\
145e2ad626fSUlf Hansson 	{ __reg, BIT(14) },					\
146e2ad626fSUlf Hansson 	{ __reg, BIT(15) }
147e2ad626fSUlf Hansson 
148e2ad626fSUlf Hansson static struct meson_ee_pwrc_mem_domain axg_pwrc_mem_vpu[] = {
149e2ad626fSUlf Hansson 	VPU_MEMPD(HHI_VPU_MEM_PD_REG0),
150e2ad626fSUlf Hansson 	VPU_HHI_MEMPD(HHI_MEM_PD_REG0),
151e2ad626fSUlf Hansson };
152e2ad626fSUlf Hansson 
153e2ad626fSUlf Hansson static struct meson_ee_pwrc_mem_domain g12a_pwrc_mem_vpu[] = {
154e2ad626fSUlf Hansson 	VPU_MEMPD(HHI_VPU_MEM_PD_REG0),
155e2ad626fSUlf Hansson 	VPU_MEMPD(HHI_VPU_MEM_PD_REG1),
156e2ad626fSUlf Hansson 	VPU_MEMPD(HHI_VPU_MEM_PD_REG2),
157e2ad626fSUlf Hansson 	VPU_HHI_MEMPD(HHI_MEM_PD_REG0),
158e2ad626fSUlf Hansson };
159e2ad626fSUlf Hansson 
160e2ad626fSUlf Hansson static struct meson_ee_pwrc_mem_domain gxbb_pwrc_mem_vpu[] = {
161e2ad626fSUlf Hansson 	VPU_MEMPD(HHI_VPU_MEM_PD_REG0),
162e2ad626fSUlf Hansson 	VPU_MEMPD(HHI_VPU_MEM_PD_REG1),
163e2ad626fSUlf Hansson 	VPU_HHI_MEMPD(HHI_MEM_PD_REG0),
164e2ad626fSUlf Hansson };
165e2ad626fSUlf Hansson 
166e2ad626fSUlf Hansson static struct meson_ee_pwrc_mem_domain meson_pwrc_mem_eth[] = {
167e2ad626fSUlf Hansson 	{ HHI_MEM_PD_REG0, GENMASK(3, 2) },
168e2ad626fSUlf Hansson };
169e2ad626fSUlf Hansson 
170e2ad626fSUlf Hansson static struct meson_ee_pwrc_mem_domain meson8_pwrc_audio_dsp_mem[] = {
171e2ad626fSUlf Hansson 	{ HHI_MEM_PD_REG0, GENMASK(1, 0) },
172e2ad626fSUlf Hansson };
173e2ad626fSUlf Hansson 
174e2ad626fSUlf Hansson static struct meson_ee_pwrc_mem_domain meson8_pwrc_mem_vpu[] = {
175e2ad626fSUlf Hansson 	VPU_MEMPD(HHI_VPU_MEM_PD_REG0),
176e2ad626fSUlf Hansson 	VPU_MEMPD(HHI_VPU_MEM_PD_REG1),
177e2ad626fSUlf Hansson 	VPU_HHI_MEMPD(HHI_MEM_PD_REG0),
178e2ad626fSUlf Hansson };
179e2ad626fSUlf Hansson 
180e2ad626fSUlf Hansson static struct meson_ee_pwrc_mem_domain sm1_pwrc_mem_vpu[] = {
181e2ad626fSUlf Hansson 	VPU_MEMPD(HHI_VPU_MEM_PD_REG0),
182e2ad626fSUlf Hansson 	VPU_MEMPD(HHI_VPU_MEM_PD_REG1),
183e2ad626fSUlf Hansson 	VPU_MEMPD(HHI_VPU_MEM_PD_REG2),
184e2ad626fSUlf Hansson 	VPU_MEMPD(HHI_VPU_MEM_PD_REG3),
185e2ad626fSUlf Hansson 	{ HHI_VPU_MEM_PD_REG4, GENMASK(1, 0) },
186e2ad626fSUlf Hansson 	{ HHI_VPU_MEM_PD_REG4, GENMASK(3, 2) },
187e2ad626fSUlf Hansson 	{ HHI_VPU_MEM_PD_REG4, GENMASK(5, 4) },
188e2ad626fSUlf Hansson 	{ HHI_VPU_MEM_PD_REG4, GENMASK(7, 6) },
189e2ad626fSUlf Hansson 	VPU_HHI_MEMPD(HHI_MEM_PD_REG0),
190e2ad626fSUlf Hansson };
191e2ad626fSUlf Hansson 
192e2ad626fSUlf Hansson static struct meson_ee_pwrc_mem_domain sm1_pwrc_mem_nna[] = {
193e2ad626fSUlf Hansson 	{ HHI_NANOQ_MEM_PD_REG0, 0xff },
194e2ad626fSUlf Hansson 	{ HHI_NANOQ_MEM_PD_REG1, 0xff },
195e2ad626fSUlf Hansson };
196e2ad626fSUlf Hansson 
197e2ad626fSUlf Hansson static struct meson_ee_pwrc_mem_domain sm1_pwrc_mem_usb[] = {
198e2ad626fSUlf Hansson 	{ HHI_MEM_PD_REG0, GENMASK(31, 30) },
199e2ad626fSUlf Hansson };
200e2ad626fSUlf Hansson 
201e2ad626fSUlf Hansson static struct meson_ee_pwrc_mem_domain sm1_pwrc_mem_pcie[] = {
202e2ad626fSUlf Hansson 	{ HHI_MEM_PD_REG0, GENMASK(29, 26) },
203e2ad626fSUlf Hansson };
204e2ad626fSUlf Hansson 
205e2ad626fSUlf Hansson static struct meson_ee_pwrc_mem_domain sm1_pwrc_mem_ge2d[] = {
206e2ad626fSUlf Hansson 	{ HHI_MEM_PD_REG0, GENMASK(25, 18) },
207e2ad626fSUlf Hansson };
208e2ad626fSUlf Hansson 
209e2ad626fSUlf Hansson static struct meson_ee_pwrc_mem_domain axg_pwrc_mem_audio[] = {
210e2ad626fSUlf Hansson 	{ HHI_MEM_PD_REG0, GENMASK(5, 4) },
211e2ad626fSUlf Hansson };
212e2ad626fSUlf Hansson 
213e2ad626fSUlf Hansson static struct meson_ee_pwrc_mem_domain sm1_pwrc_mem_audio[] = {
214e2ad626fSUlf Hansson 	{ HHI_MEM_PD_REG0, GENMASK(5, 4) },
215e2ad626fSUlf Hansson 	{ HHI_AUDIO_MEM_PD_REG0, GENMASK(1, 0) },
216e2ad626fSUlf Hansson 	{ HHI_AUDIO_MEM_PD_REG0, GENMASK(3, 2) },
217e2ad626fSUlf Hansson 	{ HHI_AUDIO_MEM_PD_REG0, GENMASK(5, 4) },
218e2ad626fSUlf Hansson 	{ HHI_AUDIO_MEM_PD_REG0, GENMASK(7, 6) },
219e2ad626fSUlf Hansson 	{ HHI_AUDIO_MEM_PD_REG0, GENMASK(13, 12) },
220e2ad626fSUlf Hansson 	{ HHI_AUDIO_MEM_PD_REG0, GENMASK(15, 14) },
221e2ad626fSUlf Hansson 	{ HHI_AUDIO_MEM_PD_REG0, GENMASK(17, 16) },
222e2ad626fSUlf Hansson 	{ HHI_AUDIO_MEM_PD_REG0, GENMASK(19, 18) },
223e2ad626fSUlf Hansson 	{ HHI_AUDIO_MEM_PD_REG0, GENMASK(21, 20) },
224e2ad626fSUlf Hansson 	{ HHI_AUDIO_MEM_PD_REG0, GENMASK(23, 22) },
225e2ad626fSUlf Hansson 	{ HHI_AUDIO_MEM_PD_REG0, GENMASK(25, 24) },
226e2ad626fSUlf Hansson 	{ HHI_AUDIO_MEM_PD_REG0, GENMASK(27, 26) },
227e2ad626fSUlf Hansson };
228e2ad626fSUlf Hansson 
229e2ad626fSUlf Hansson static struct meson_ee_pwrc_mem_domain g12a_pwrc_mem_nna[] = {
230e2ad626fSUlf Hansson 	{ G12A_HHI_NANOQ_MEM_PD_REG0, GENMASK(31, 0) },
231*fc14784cSTomeu Vizoso 	{ G12A_HHI_NANOQ_MEM_PD_REG1, GENMASK(31, 0) },
232e2ad626fSUlf Hansson };
233e2ad626fSUlf Hansson 
234e2ad626fSUlf Hansson #define VPU_PD(__name, __top_pd, __mem, __is_pwr_off, __resets, __clks)	\
235e2ad626fSUlf Hansson 	{								\
236e2ad626fSUlf Hansson 		.name = __name,						\
237e2ad626fSUlf Hansson 		.reset_names_count = __resets,				\
238e2ad626fSUlf Hansson 		.clk_names_count = __clks,				\
239e2ad626fSUlf Hansson 		.top_pd = __top_pd,					\
240e2ad626fSUlf Hansson 		.mem_pd_count = ARRAY_SIZE(__mem),			\
241e2ad626fSUlf Hansson 		.mem_pd = __mem,					\
242e2ad626fSUlf Hansson 		.is_powered_off = __is_pwr_off,				\
243e2ad626fSUlf Hansson 	}
244e2ad626fSUlf Hansson 
245e2ad626fSUlf Hansson #define TOP_PD(__name, __top_pd, __mem, __is_pwr_off)			\
246e2ad626fSUlf Hansson 	{								\
247e2ad626fSUlf Hansson 		.name = __name,						\
248e2ad626fSUlf Hansson 		.top_pd = __top_pd,					\
249e2ad626fSUlf Hansson 		.mem_pd_count = ARRAY_SIZE(__mem),			\
250e2ad626fSUlf Hansson 		.mem_pd = __mem,					\
251e2ad626fSUlf Hansson 		.is_powered_off = __is_pwr_off,				\
252e2ad626fSUlf Hansson 	}
253e2ad626fSUlf Hansson 
254e2ad626fSUlf Hansson #define MEM_PD(__name, __mem)						\
255e2ad626fSUlf Hansson 	TOP_PD(__name, NULL, __mem, NULL)
256e2ad626fSUlf Hansson 
257e2ad626fSUlf Hansson static bool pwrc_ee_is_powered_off(struct meson_ee_pwrc_domain *pwrc_domain);
258e2ad626fSUlf Hansson 
259e2ad626fSUlf Hansson static struct meson_ee_pwrc_domain_desc axg_pwrc_domains[] = {
260e2ad626fSUlf Hansson 	[PWRC_AXG_VPU_ID]  = VPU_PD("VPU", &gx_pwrc_vpu, axg_pwrc_mem_vpu,
261e2ad626fSUlf Hansson 				     pwrc_ee_is_powered_off, 5, 2),
262e2ad626fSUlf Hansson 	[PWRC_AXG_ETHERNET_MEM_ID] = MEM_PD("ETH", meson_pwrc_mem_eth),
263e2ad626fSUlf Hansson 	[PWRC_AXG_AUDIO_ID] = MEM_PD("AUDIO", axg_pwrc_mem_audio),
264e2ad626fSUlf Hansson };
265e2ad626fSUlf Hansson 
266e2ad626fSUlf Hansson static struct meson_ee_pwrc_domain_desc g12a_pwrc_domains[] = {
267e2ad626fSUlf Hansson 	[PWRC_G12A_VPU_ID]  = VPU_PD("VPU", &gx_pwrc_vpu, g12a_pwrc_mem_vpu,
268e2ad626fSUlf Hansson 				     pwrc_ee_is_powered_off, 11, 2),
269e2ad626fSUlf Hansson 	[PWRC_G12A_ETH_ID] = MEM_PD("ETH", meson_pwrc_mem_eth),
270e2ad626fSUlf Hansson 	[PWRC_G12A_NNA_ID] = TOP_PD("NNA", &g12a_pwrc_nna, g12a_pwrc_mem_nna,
271e2ad626fSUlf Hansson 				    pwrc_ee_is_powered_off),
272e2ad626fSUlf Hansson };
273e2ad626fSUlf Hansson 
274e2ad626fSUlf Hansson static struct meson_ee_pwrc_domain_desc gxbb_pwrc_domains[] = {
275e2ad626fSUlf Hansson 	[PWRC_GXBB_VPU_ID]  = VPU_PD("VPU", &gx_pwrc_vpu, gxbb_pwrc_mem_vpu,
276e2ad626fSUlf Hansson 				     pwrc_ee_is_powered_off, 12, 2),
277e2ad626fSUlf Hansson 	[PWRC_GXBB_ETHERNET_MEM_ID] = MEM_PD("ETH", meson_pwrc_mem_eth),
278e2ad626fSUlf Hansson };
279e2ad626fSUlf Hansson 
280e2ad626fSUlf Hansson static struct meson_ee_pwrc_domain_desc meson8_pwrc_domains[] = {
281e2ad626fSUlf Hansson 	[PWRC_MESON8_VPU_ID]  = VPU_PD("VPU", &meson8_pwrc_vpu,
282e2ad626fSUlf Hansson 				       meson8_pwrc_mem_vpu,
283e2ad626fSUlf Hansson 				       pwrc_ee_is_powered_off, 0, 1),
284e2ad626fSUlf Hansson 	[PWRC_MESON8_ETHERNET_MEM_ID] = MEM_PD("ETHERNET_MEM",
285e2ad626fSUlf Hansson 					       meson_pwrc_mem_eth),
286e2ad626fSUlf Hansson 	[PWRC_MESON8_AUDIO_DSP_MEM_ID] = MEM_PD("AUDIO_DSP_MEM",
287e2ad626fSUlf Hansson 						meson8_pwrc_audio_dsp_mem),
288e2ad626fSUlf Hansson };
289e2ad626fSUlf Hansson 
290e2ad626fSUlf Hansson static struct meson_ee_pwrc_domain_desc meson8b_pwrc_domains[] = {
291e2ad626fSUlf Hansson 	[PWRC_MESON8_VPU_ID]  = VPU_PD("VPU", &meson8_pwrc_vpu,
292e2ad626fSUlf Hansson 				       meson8_pwrc_mem_vpu,
293e2ad626fSUlf Hansson 				       pwrc_ee_is_powered_off, 11, 1),
294e2ad626fSUlf Hansson 	[PWRC_MESON8_ETHERNET_MEM_ID] = MEM_PD("ETHERNET_MEM",
295e2ad626fSUlf Hansson 					       meson_pwrc_mem_eth),
296e2ad626fSUlf Hansson 	[PWRC_MESON8_AUDIO_DSP_MEM_ID] = MEM_PD("AUDIO_DSP_MEM",
297e2ad626fSUlf Hansson 						meson8_pwrc_audio_dsp_mem),
298e2ad626fSUlf Hansson };
299e2ad626fSUlf Hansson 
300e2ad626fSUlf Hansson static struct meson_ee_pwrc_domain_desc sm1_pwrc_domains[] = {
301e2ad626fSUlf Hansson 	[PWRC_SM1_VPU_ID]  = VPU_PD("VPU", &sm1_pwrc_vpu, sm1_pwrc_mem_vpu,
302e2ad626fSUlf Hansson 				    pwrc_ee_is_powered_off, 11, 2),
303e2ad626fSUlf Hansson 	[PWRC_SM1_NNA_ID]  = TOP_PD("NNA", &sm1_pwrc_nna, sm1_pwrc_mem_nna,
304e2ad626fSUlf Hansson 				    pwrc_ee_is_powered_off),
305e2ad626fSUlf Hansson 	[PWRC_SM1_USB_ID]  = TOP_PD("USB", &sm1_pwrc_usb, sm1_pwrc_mem_usb,
306e2ad626fSUlf Hansson 				    pwrc_ee_is_powered_off),
307e2ad626fSUlf Hansson 	[PWRC_SM1_PCIE_ID] = TOP_PD("PCI", &sm1_pwrc_pci, sm1_pwrc_mem_pcie,
308e2ad626fSUlf Hansson 				    pwrc_ee_is_powered_off),
309e2ad626fSUlf Hansson 	[PWRC_SM1_GE2D_ID] = TOP_PD("GE2D", &sm1_pwrc_ge2d, sm1_pwrc_mem_ge2d,
310e2ad626fSUlf Hansson 				    pwrc_ee_is_powered_off),
311e2ad626fSUlf Hansson 	[PWRC_SM1_AUDIO_ID] = MEM_PD("AUDIO", sm1_pwrc_mem_audio),
312e2ad626fSUlf Hansson 	[PWRC_SM1_ETH_ID] = MEM_PD("ETH", meson_pwrc_mem_eth),
313e2ad626fSUlf Hansson };
314e2ad626fSUlf Hansson 
315e2ad626fSUlf Hansson struct meson_ee_pwrc_domain {
316e2ad626fSUlf Hansson 	struct generic_pm_domain base;
317e2ad626fSUlf Hansson 	bool enabled;
318e2ad626fSUlf Hansson 	struct meson_ee_pwrc *pwrc;
319e2ad626fSUlf Hansson 	struct meson_ee_pwrc_domain_desc desc;
320e2ad626fSUlf Hansson 	struct clk_bulk_data *clks;
321e2ad626fSUlf Hansson 	int num_clks;
322e2ad626fSUlf Hansson 	struct reset_control *rstc;
323e2ad626fSUlf Hansson 	int num_rstc;
324e2ad626fSUlf Hansson };
325e2ad626fSUlf Hansson 
326e2ad626fSUlf Hansson struct meson_ee_pwrc {
327e2ad626fSUlf Hansson 	struct regmap *regmap_ao;
328e2ad626fSUlf Hansson 	struct regmap *regmap_hhi;
329e2ad626fSUlf Hansson 	struct meson_ee_pwrc_domain *domains;
330e2ad626fSUlf Hansson 	struct genpd_onecell_data xlate;
331e2ad626fSUlf Hansson };
332e2ad626fSUlf Hansson 
pwrc_ee_is_powered_off(struct meson_ee_pwrc_domain * pwrc_domain)333e2ad626fSUlf Hansson static bool pwrc_ee_is_powered_off(struct meson_ee_pwrc_domain *pwrc_domain)
334e2ad626fSUlf Hansson {
335e2ad626fSUlf Hansson 	u32 reg;
336e2ad626fSUlf Hansson 
337e2ad626fSUlf Hansson 	regmap_read(pwrc_domain->pwrc->regmap_ao,
338e2ad626fSUlf Hansson 		    pwrc_domain->desc.top_pd->sleep_reg, &reg);
339e2ad626fSUlf Hansson 
340e2ad626fSUlf Hansson 	return (reg & pwrc_domain->desc.top_pd->sleep_mask);
341e2ad626fSUlf Hansson }
342e2ad626fSUlf Hansson 
meson_ee_pwrc_off(struct generic_pm_domain * domain)343e2ad626fSUlf Hansson static int meson_ee_pwrc_off(struct generic_pm_domain *domain)
344e2ad626fSUlf Hansson {
345e2ad626fSUlf Hansson 	struct meson_ee_pwrc_domain *pwrc_domain =
346e2ad626fSUlf Hansson 		container_of(domain, struct meson_ee_pwrc_domain, base);
347e2ad626fSUlf Hansson 	int i;
348e2ad626fSUlf Hansson 
349e2ad626fSUlf Hansson 	if (pwrc_domain->desc.top_pd)
350e2ad626fSUlf Hansson 		regmap_update_bits(pwrc_domain->pwrc->regmap_ao,
351e2ad626fSUlf Hansson 				   pwrc_domain->desc.top_pd->sleep_reg,
352e2ad626fSUlf Hansson 				   pwrc_domain->desc.top_pd->sleep_mask,
353e2ad626fSUlf Hansson 				   pwrc_domain->desc.top_pd->sleep_mask);
354e2ad626fSUlf Hansson 	udelay(20);
355e2ad626fSUlf Hansson 
356e2ad626fSUlf Hansson 	for (i = 0 ; i < pwrc_domain->desc.mem_pd_count ; ++i)
357e2ad626fSUlf Hansson 		regmap_update_bits(pwrc_domain->pwrc->regmap_hhi,
358e2ad626fSUlf Hansson 				   pwrc_domain->desc.mem_pd[i].reg,
359e2ad626fSUlf Hansson 				   pwrc_domain->desc.mem_pd[i].mask,
360e2ad626fSUlf Hansson 				   pwrc_domain->desc.mem_pd[i].mask);
361e2ad626fSUlf Hansson 
362e2ad626fSUlf Hansson 	udelay(20);
363e2ad626fSUlf Hansson 
364e2ad626fSUlf Hansson 	if (pwrc_domain->desc.top_pd)
365e2ad626fSUlf Hansson 		regmap_update_bits(pwrc_domain->pwrc->regmap_ao,
366e2ad626fSUlf Hansson 				   pwrc_domain->desc.top_pd->iso_reg,
367e2ad626fSUlf Hansson 				   pwrc_domain->desc.top_pd->iso_mask,
368e2ad626fSUlf Hansson 				   pwrc_domain->desc.top_pd->iso_mask);
369e2ad626fSUlf Hansson 
370e2ad626fSUlf Hansson 	if (pwrc_domain->num_clks) {
371e2ad626fSUlf Hansson 		msleep(20);
372e2ad626fSUlf Hansson 		clk_bulk_disable_unprepare(pwrc_domain->num_clks,
373e2ad626fSUlf Hansson 					   pwrc_domain->clks);
374e2ad626fSUlf Hansson 	}
375e2ad626fSUlf Hansson 
376e2ad626fSUlf Hansson 	return 0;
377e2ad626fSUlf Hansson }
378e2ad626fSUlf Hansson 
meson_ee_pwrc_on(struct generic_pm_domain * domain)379e2ad626fSUlf Hansson static int meson_ee_pwrc_on(struct generic_pm_domain *domain)
380e2ad626fSUlf Hansson {
381e2ad626fSUlf Hansson 	struct meson_ee_pwrc_domain *pwrc_domain =
382e2ad626fSUlf Hansson 		container_of(domain, struct meson_ee_pwrc_domain, base);
383e2ad626fSUlf Hansson 	int i, ret;
384e2ad626fSUlf Hansson 
385e2ad626fSUlf Hansson 	if (pwrc_domain->desc.top_pd)
386e2ad626fSUlf Hansson 		regmap_update_bits(pwrc_domain->pwrc->regmap_ao,
387e2ad626fSUlf Hansson 				   pwrc_domain->desc.top_pd->sleep_reg,
388e2ad626fSUlf Hansson 				   pwrc_domain->desc.top_pd->sleep_mask, 0);
389e2ad626fSUlf Hansson 	udelay(20);
390e2ad626fSUlf Hansson 
391e2ad626fSUlf Hansson 	for (i = 0 ; i < pwrc_domain->desc.mem_pd_count ; ++i)
392e2ad626fSUlf Hansson 		regmap_update_bits(pwrc_domain->pwrc->regmap_hhi,
393e2ad626fSUlf Hansson 				   pwrc_domain->desc.mem_pd[i].reg,
394e2ad626fSUlf Hansson 				   pwrc_domain->desc.mem_pd[i].mask, 0);
395e2ad626fSUlf Hansson 
396e2ad626fSUlf Hansson 	udelay(20);
397e2ad626fSUlf Hansson 
398e2ad626fSUlf Hansson 	ret = reset_control_assert(pwrc_domain->rstc);
399e2ad626fSUlf Hansson 	if (ret)
400e2ad626fSUlf Hansson 		return ret;
401e2ad626fSUlf Hansson 
402e2ad626fSUlf Hansson 	if (pwrc_domain->desc.top_pd)
403e2ad626fSUlf Hansson 		regmap_update_bits(pwrc_domain->pwrc->regmap_ao,
404e2ad626fSUlf Hansson 				   pwrc_domain->desc.top_pd->iso_reg,
405e2ad626fSUlf Hansson 				   pwrc_domain->desc.top_pd->iso_mask, 0);
406e2ad626fSUlf Hansson 
407e2ad626fSUlf Hansson 	ret = reset_control_deassert(pwrc_domain->rstc);
408e2ad626fSUlf Hansson 	if (ret)
409e2ad626fSUlf Hansson 		return ret;
410e2ad626fSUlf Hansson 
411e2ad626fSUlf Hansson 	return clk_bulk_prepare_enable(pwrc_domain->num_clks,
412e2ad626fSUlf Hansson 				       pwrc_domain->clks);
413e2ad626fSUlf Hansson }
414e2ad626fSUlf Hansson 
meson_ee_pwrc_init_domain(struct platform_device * pdev,struct meson_ee_pwrc * pwrc,struct meson_ee_pwrc_domain * dom)415e2ad626fSUlf Hansson static int meson_ee_pwrc_init_domain(struct platform_device *pdev,
416e2ad626fSUlf Hansson 				     struct meson_ee_pwrc *pwrc,
417e2ad626fSUlf Hansson 				     struct meson_ee_pwrc_domain *dom)
418e2ad626fSUlf Hansson {
419e2ad626fSUlf Hansson 	int ret;
420e2ad626fSUlf Hansson 
421e2ad626fSUlf Hansson 	dom->pwrc = pwrc;
422e2ad626fSUlf Hansson 	dom->num_rstc = dom->desc.reset_names_count;
423e2ad626fSUlf Hansson 	dom->num_clks = dom->desc.clk_names_count;
424e2ad626fSUlf Hansson 
425e2ad626fSUlf Hansson 	if (dom->num_rstc) {
426e2ad626fSUlf Hansson 		int count = reset_control_get_count(&pdev->dev);
427e2ad626fSUlf Hansson 
428e2ad626fSUlf Hansson 		if (count != dom->num_rstc)
429e2ad626fSUlf Hansson 			dev_warn(&pdev->dev, "Invalid resets count %d for domain %s\n",
430e2ad626fSUlf Hansson 				 count, dom->desc.name);
431e2ad626fSUlf Hansson 
432e2ad626fSUlf Hansson 		dom->rstc = devm_reset_control_array_get_exclusive(&pdev->dev);
433e2ad626fSUlf Hansson 		if (IS_ERR(dom->rstc))
434e2ad626fSUlf Hansson 			return PTR_ERR(dom->rstc);
435e2ad626fSUlf Hansson 	}
436e2ad626fSUlf Hansson 
437e2ad626fSUlf Hansson 	if (dom->num_clks) {
438e2ad626fSUlf Hansson 		int ret = devm_clk_bulk_get_all(&pdev->dev, &dom->clks);
439e2ad626fSUlf Hansson 		if (ret < 0)
440e2ad626fSUlf Hansson 			return ret;
441e2ad626fSUlf Hansson 
442e2ad626fSUlf Hansson 		if (dom->num_clks != ret) {
443e2ad626fSUlf Hansson 			dev_warn(&pdev->dev, "Invalid clocks count %d for domain %s\n",
444e2ad626fSUlf Hansson 				 ret, dom->desc.name);
445e2ad626fSUlf Hansson 			dom->num_clks = ret;
446e2ad626fSUlf Hansson 		}
447e2ad626fSUlf Hansson 	}
448e2ad626fSUlf Hansson 
449e2ad626fSUlf Hansson 	dom->base.name = dom->desc.name;
450e2ad626fSUlf Hansson 	dom->base.power_on = meson_ee_pwrc_on;
451e2ad626fSUlf Hansson 	dom->base.power_off = meson_ee_pwrc_off;
452e2ad626fSUlf Hansson 
453e2ad626fSUlf Hansson 	/*
454e2ad626fSUlf Hansson          * TOFIX: This is a special case for the VPU power domain, which can
455e2ad626fSUlf Hansson 	 * be enabled previously by the bootloader. In this case the VPU
456e2ad626fSUlf Hansson          * pipeline may be functional but no driver maybe never attach
457e2ad626fSUlf Hansson          * to this power domain, and if the domain is disabled it could
458e2ad626fSUlf Hansson          * cause system errors. This is why the pm_domain_always_on_gov
459e2ad626fSUlf Hansson          * is used here.
460e2ad626fSUlf Hansson          * For the same reason, the clocks should be enabled in case
461e2ad626fSUlf Hansson          * we need to power the domain off, otherwise the internal clocks
462e2ad626fSUlf Hansson          * prepare/enable counters won't be in sync.
463e2ad626fSUlf Hansson          */
464e2ad626fSUlf Hansson 	if (dom->num_clks && dom->desc.is_powered_off && !dom->desc.is_powered_off(dom)) {
465e2ad626fSUlf Hansson 		ret = clk_bulk_prepare_enable(dom->num_clks, dom->clks);
466e2ad626fSUlf Hansson 		if (ret)
467e2ad626fSUlf Hansson 			return ret;
468e2ad626fSUlf Hansson 
469e2ad626fSUlf Hansson 		dom->base.flags = GENPD_FLAG_ALWAYS_ON;
470e2ad626fSUlf Hansson 		ret = pm_genpd_init(&dom->base, NULL, false);
471e2ad626fSUlf Hansson 		if (ret)
472e2ad626fSUlf Hansson 			return ret;
473e2ad626fSUlf Hansson 	} else {
474e2ad626fSUlf Hansson 		ret = pm_genpd_init(&dom->base, NULL,
475e2ad626fSUlf Hansson 				    (dom->desc.is_powered_off ?
476e2ad626fSUlf Hansson 				     dom->desc.is_powered_off(dom) : true));
477e2ad626fSUlf Hansson 		if (ret)
478e2ad626fSUlf Hansson 			return ret;
479e2ad626fSUlf Hansson 	}
480e2ad626fSUlf Hansson 
481e2ad626fSUlf Hansson 	return 0;
482e2ad626fSUlf Hansson }
483e2ad626fSUlf Hansson 
meson_ee_pwrc_probe(struct platform_device * pdev)484e2ad626fSUlf Hansson static int meson_ee_pwrc_probe(struct platform_device *pdev)
485e2ad626fSUlf Hansson {
486e2ad626fSUlf Hansson 	const struct meson_ee_pwrc_domain_data *match;
487e2ad626fSUlf Hansson 	struct regmap *regmap_ao, *regmap_hhi;
488e2ad626fSUlf Hansson 	struct device_node *parent_np;
489e2ad626fSUlf Hansson 	struct meson_ee_pwrc *pwrc;
490e2ad626fSUlf Hansson 	int i, ret;
491e2ad626fSUlf Hansson 
492e2ad626fSUlf Hansson 	match = of_device_get_match_data(&pdev->dev);
493e2ad626fSUlf Hansson 	if (!match) {
494e2ad626fSUlf Hansson 		dev_err(&pdev->dev, "failed to get match data\n");
495e2ad626fSUlf Hansson 		return -ENODEV;
496e2ad626fSUlf Hansson 	}
497e2ad626fSUlf Hansson 
498e2ad626fSUlf Hansson 	pwrc = devm_kzalloc(&pdev->dev, sizeof(*pwrc), GFP_KERNEL);
499e2ad626fSUlf Hansson 	if (!pwrc)
500e2ad626fSUlf Hansson 		return -ENOMEM;
501e2ad626fSUlf Hansson 
502e2ad626fSUlf Hansson 	pwrc->xlate.domains = devm_kcalloc(&pdev->dev, match->count,
503e2ad626fSUlf Hansson 					   sizeof(*pwrc->xlate.domains),
504e2ad626fSUlf Hansson 					   GFP_KERNEL);
505e2ad626fSUlf Hansson 	if (!pwrc->xlate.domains)
506e2ad626fSUlf Hansson 		return -ENOMEM;
507e2ad626fSUlf Hansson 
508e2ad626fSUlf Hansson 	pwrc->domains = devm_kcalloc(&pdev->dev, match->count,
509e2ad626fSUlf Hansson 				     sizeof(*pwrc->domains), GFP_KERNEL);
510e2ad626fSUlf Hansson 	if (!pwrc->domains)
511e2ad626fSUlf Hansson 		return -ENOMEM;
512e2ad626fSUlf Hansson 
513e2ad626fSUlf Hansson 	pwrc->xlate.num_domains = match->count;
514e2ad626fSUlf Hansson 
515e2ad626fSUlf Hansson 	parent_np = of_get_parent(pdev->dev.of_node);
516e2ad626fSUlf Hansson 	regmap_hhi = syscon_node_to_regmap(parent_np);
517e2ad626fSUlf Hansson 	of_node_put(parent_np);
518e2ad626fSUlf Hansson 	if (IS_ERR(regmap_hhi)) {
519e2ad626fSUlf Hansson 		dev_err(&pdev->dev, "failed to get HHI regmap\n");
520e2ad626fSUlf Hansson 		return PTR_ERR(regmap_hhi);
521e2ad626fSUlf Hansson 	}
522e2ad626fSUlf Hansson 
523e2ad626fSUlf Hansson 	regmap_ao = syscon_regmap_lookup_by_phandle(pdev->dev.of_node,
524e2ad626fSUlf Hansson 						    "amlogic,ao-sysctrl");
525e2ad626fSUlf Hansson 	if (IS_ERR(regmap_ao)) {
526e2ad626fSUlf Hansson 		dev_err(&pdev->dev, "failed to get AO regmap\n");
527e2ad626fSUlf Hansson 		return PTR_ERR(regmap_ao);
528e2ad626fSUlf Hansson 	}
529e2ad626fSUlf Hansson 
530e2ad626fSUlf Hansson 	pwrc->regmap_ao = regmap_ao;
531e2ad626fSUlf Hansson 	pwrc->regmap_hhi = regmap_hhi;
532e2ad626fSUlf Hansson 
533e2ad626fSUlf Hansson 	platform_set_drvdata(pdev, pwrc);
534e2ad626fSUlf Hansson 
535e2ad626fSUlf Hansson 	for (i = 0 ; i < match->count ; ++i) {
536e2ad626fSUlf Hansson 		struct meson_ee_pwrc_domain *dom = &pwrc->domains[i];
537e2ad626fSUlf Hansson 
538e2ad626fSUlf Hansson 		memcpy(&dom->desc, &match->domains[i], sizeof(dom->desc));
539e2ad626fSUlf Hansson 
540e2ad626fSUlf Hansson 		ret = meson_ee_pwrc_init_domain(pdev, pwrc, dom);
541e2ad626fSUlf Hansson 		if (ret)
542e2ad626fSUlf Hansson 			return ret;
543e2ad626fSUlf Hansson 
544e2ad626fSUlf Hansson 		pwrc->xlate.domains[i] = &dom->base;
545e2ad626fSUlf Hansson 	}
546e2ad626fSUlf Hansson 
547e2ad626fSUlf Hansson 	return of_genpd_add_provider_onecell(pdev->dev.of_node, &pwrc->xlate);
548e2ad626fSUlf Hansson }
549e2ad626fSUlf Hansson 
meson_ee_pwrc_shutdown(struct platform_device * pdev)550e2ad626fSUlf Hansson static void meson_ee_pwrc_shutdown(struct platform_device *pdev)
551e2ad626fSUlf Hansson {
552e2ad626fSUlf Hansson 	struct meson_ee_pwrc *pwrc = platform_get_drvdata(pdev);
553e2ad626fSUlf Hansson 	int i;
554e2ad626fSUlf Hansson 
555e2ad626fSUlf Hansson 	for (i = 0 ; i < pwrc->xlate.num_domains ; ++i) {
556e2ad626fSUlf Hansson 		struct meson_ee_pwrc_domain *dom = &pwrc->domains[i];
557e2ad626fSUlf Hansson 
558e2ad626fSUlf Hansson 		if (dom->desc.is_powered_off && !dom->desc.is_powered_off(dom))
559e2ad626fSUlf Hansson 			meson_ee_pwrc_off(&dom->base);
560e2ad626fSUlf Hansson 	}
561e2ad626fSUlf Hansson }
562e2ad626fSUlf Hansson 
563e2ad626fSUlf Hansson static struct meson_ee_pwrc_domain_data meson_ee_g12a_pwrc_data = {
564e2ad626fSUlf Hansson 	.count = ARRAY_SIZE(g12a_pwrc_domains),
565e2ad626fSUlf Hansson 	.domains = g12a_pwrc_domains,
566e2ad626fSUlf Hansson };
567e2ad626fSUlf Hansson 
568e2ad626fSUlf Hansson static struct meson_ee_pwrc_domain_data meson_ee_axg_pwrc_data = {
569e2ad626fSUlf Hansson 	.count = ARRAY_SIZE(axg_pwrc_domains),
570e2ad626fSUlf Hansson 	.domains = axg_pwrc_domains,
571e2ad626fSUlf Hansson };
572e2ad626fSUlf Hansson 
573e2ad626fSUlf Hansson static struct meson_ee_pwrc_domain_data meson_ee_gxbb_pwrc_data = {
574e2ad626fSUlf Hansson 	.count = ARRAY_SIZE(gxbb_pwrc_domains),
575e2ad626fSUlf Hansson 	.domains = gxbb_pwrc_domains,
576e2ad626fSUlf Hansson };
577e2ad626fSUlf Hansson 
578e2ad626fSUlf Hansson static struct meson_ee_pwrc_domain_data meson_ee_m8_pwrc_data = {
579e2ad626fSUlf Hansson 	.count = ARRAY_SIZE(meson8_pwrc_domains),
580e2ad626fSUlf Hansson 	.domains = meson8_pwrc_domains,
581e2ad626fSUlf Hansson };
582e2ad626fSUlf Hansson 
583e2ad626fSUlf Hansson static struct meson_ee_pwrc_domain_data meson_ee_m8b_pwrc_data = {
584e2ad626fSUlf Hansson 	.count = ARRAY_SIZE(meson8b_pwrc_domains),
585e2ad626fSUlf Hansson 	.domains = meson8b_pwrc_domains,
586e2ad626fSUlf Hansson };
587e2ad626fSUlf Hansson 
588e2ad626fSUlf Hansson static struct meson_ee_pwrc_domain_data meson_ee_sm1_pwrc_data = {
589e2ad626fSUlf Hansson 	.count = ARRAY_SIZE(sm1_pwrc_domains),
590e2ad626fSUlf Hansson 	.domains = sm1_pwrc_domains,
591e2ad626fSUlf Hansson };
592e2ad626fSUlf Hansson 
593e2ad626fSUlf Hansson static const struct of_device_id meson_ee_pwrc_match_table[] = {
594e2ad626fSUlf Hansson 	{
595e2ad626fSUlf Hansson 		.compatible = "amlogic,meson8-pwrc",
596e2ad626fSUlf Hansson 		.data = &meson_ee_m8_pwrc_data,
597e2ad626fSUlf Hansson 	},
598e2ad626fSUlf Hansson 	{
599e2ad626fSUlf Hansson 		.compatible = "amlogic,meson8b-pwrc",
600e2ad626fSUlf Hansson 		.data = &meson_ee_m8b_pwrc_data,
601e2ad626fSUlf Hansson 	},
602e2ad626fSUlf Hansson 	{
603e2ad626fSUlf Hansson 		.compatible = "amlogic,meson8m2-pwrc",
604e2ad626fSUlf Hansson 		.data = &meson_ee_m8b_pwrc_data,
605e2ad626fSUlf Hansson 	},
606e2ad626fSUlf Hansson 	{
607e2ad626fSUlf Hansson 		.compatible = "amlogic,meson-axg-pwrc",
608e2ad626fSUlf Hansson 		.data = &meson_ee_axg_pwrc_data,
609e2ad626fSUlf Hansson 	},
610e2ad626fSUlf Hansson 	{
611e2ad626fSUlf Hansson 		.compatible = "amlogic,meson-gxbb-pwrc",
612e2ad626fSUlf Hansson 		.data = &meson_ee_gxbb_pwrc_data,
613e2ad626fSUlf Hansson 	},
614e2ad626fSUlf Hansson 	{
615e2ad626fSUlf Hansson 		.compatible = "amlogic,meson-g12a-pwrc",
616e2ad626fSUlf Hansson 		.data = &meson_ee_g12a_pwrc_data,
617e2ad626fSUlf Hansson 	},
618e2ad626fSUlf Hansson 	{
619e2ad626fSUlf Hansson 		.compatible = "amlogic,meson-sm1-pwrc",
620e2ad626fSUlf Hansson 		.data = &meson_ee_sm1_pwrc_data,
621e2ad626fSUlf Hansson 	},
622e2ad626fSUlf Hansson 	{ /* sentinel */ }
623e2ad626fSUlf Hansson };
624e2ad626fSUlf Hansson MODULE_DEVICE_TABLE(of, meson_ee_pwrc_match_table);
625e2ad626fSUlf Hansson 
626e2ad626fSUlf Hansson static struct platform_driver meson_ee_pwrc_driver = {
627e2ad626fSUlf Hansson 	.probe = meson_ee_pwrc_probe,
628e2ad626fSUlf Hansson 	.shutdown = meson_ee_pwrc_shutdown,
629e2ad626fSUlf Hansson 	.driver = {
630e2ad626fSUlf Hansson 		.name		= "meson_ee_pwrc",
631e2ad626fSUlf Hansson 		.of_match_table	= meson_ee_pwrc_match_table,
632e2ad626fSUlf Hansson 	},
633e2ad626fSUlf Hansson };
634e2ad626fSUlf Hansson module_platform_driver(meson_ee_pwrc_driver);
635e2ad626fSUlf Hansson MODULE_LICENSE("GPL v2");
636