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