xref: /linux/drivers/clk/meson/axg-audio.c (revision 1610dd79d0f6202c5c1a91122255fa598679c13a)
11cd50181SJerome Brunet // SPDX-License-Identifier: (GPL-2.0 OR MIT)
21cd50181SJerome Brunet /*
31cd50181SJerome Brunet  * Copyright (c) 2018 BayLibre, SAS.
41cd50181SJerome Brunet  * Author: Jerome Brunet <jbrunet@baylibre.com>
51cd50181SJerome Brunet  */
61cd50181SJerome Brunet 
71cd50181SJerome Brunet #include <linux/clk.h>
81cd50181SJerome Brunet #include <linux/clk-provider.h>
91cd50181SJerome Brunet #include <linux/init.h>
101cd50181SJerome Brunet #include <linux/of_device.h>
111cd50181SJerome Brunet #include <linux/module.h>
121cd50181SJerome Brunet #include <linux/platform_device.h>
131cd50181SJerome Brunet #include <linux/regmap.h>
141cd50181SJerome Brunet #include <linux/reset.h>
151cd50181SJerome Brunet #include <linux/slab.h>
161cd50181SJerome Brunet 
171cd50181SJerome Brunet #include "axg-audio.h"
18889c2b7eSJerome Brunet #include "clk-input.h"
19889c2b7eSJerome Brunet #include "clk-regmap.h"
20889c2b7eSJerome Brunet #include "clk-phase.h"
21889c2b7eSJerome Brunet #include "sclk-div.h"
221cd50181SJerome Brunet 
23b18819c4SJerome Brunet #define AUD_MST_IN_COUNT	8
24b18819c4SJerome Brunet #define AUD_SLV_SCLK_COUNT	10
25b18819c4SJerome Brunet #define AUD_SLV_LRCLK_COUNT	10
261cd50181SJerome Brunet 
27b18819c4SJerome Brunet #define AUD_GATE(_name, _reg, _bit, _pname, _iflags)			\
28b18819c4SJerome Brunet struct clk_regmap aud_##_name = {					\
291cd50181SJerome Brunet 	.data = &(struct clk_regmap_gate_data){				\
301cd50181SJerome Brunet 		.offset = (_reg),					\
311cd50181SJerome Brunet 		.bit_idx = (_bit),					\
321cd50181SJerome Brunet 	},								\
331cd50181SJerome Brunet 	.hw.init = &(struct clk_init_data) {				\
34b18819c4SJerome Brunet 		.name = "aud_"#_name,					\
351cd50181SJerome Brunet 		.ops = &clk_regmap_gate_ops,				\
361cd50181SJerome Brunet 		.parent_names = (const char *[]){ _pname },		\
371cd50181SJerome Brunet 		.num_parents = 1,					\
381cd50181SJerome Brunet 		.flags = CLK_DUTY_CYCLE_PARENT | (_iflags),		\
391cd50181SJerome Brunet 	},								\
401cd50181SJerome Brunet }
411cd50181SJerome Brunet 
42b18819c4SJerome Brunet #define AUD_MUX(_name, _reg, _mask, _shift, _dflags, _pnames, _iflags)	\
43b18819c4SJerome Brunet struct clk_regmap aud_##_name = {					\
441cd50181SJerome Brunet 	.data = &(struct clk_regmap_mux_data){				\
451cd50181SJerome Brunet 		.offset = (_reg),					\
461cd50181SJerome Brunet 		.mask = (_mask),					\
471cd50181SJerome Brunet 		.shift = (_shift),					\
481cd50181SJerome Brunet 		.flags = (_dflags),					\
491cd50181SJerome Brunet 	},								\
501cd50181SJerome Brunet 	.hw.init = &(struct clk_init_data){				\
51b18819c4SJerome Brunet 		.name = "aud_"#_name,					\
521cd50181SJerome Brunet 		.ops = &clk_regmap_mux_ops,				\
531cd50181SJerome Brunet 		.parent_names = (_pnames),				\
541cd50181SJerome Brunet 		.num_parents = ARRAY_SIZE(_pnames),			\
551cd50181SJerome Brunet 		.flags = CLK_DUTY_CYCLE_PARENT | (_iflags),		\
561cd50181SJerome Brunet 	},								\
571cd50181SJerome Brunet }
581cd50181SJerome Brunet 
59b18819c4SJerome Brunet #define AUD_DIV(_name, _reg, _shift, _width, _dflags, _pname, _iflags)	\
60b18819c4SJerome Brunet struct clk_regmap aud_##_name = {					\
611cd50181SJerome Brunet 	.data = &(struct clk_regmap_div_data){				\
621cd50181SJerome Brunet 		.offset = (_reg),					\
631cd50181SJerome Brunet 		.shift = (_shift),					\
641cd50181SJerome Brunet 		.width = (_width),					\
651cd50181SJerome Brunet 		.flags = (_dflags),					\
661cd50181SJerome Brunet 	},								\
671cd50181SJerome Brunet 	.hw.init = &(struct clk_init_data){				\
68b18819c4SJerome Brunet 		.name = "aud_"#_name,					\
691cd50181SJerome Brunet 		.ops = &clk_regmap_divider_ops,				\
701cd50181SJerome Brunet 		.parent_names = (const char *[]) { _pname },		\
711cd50181SJerome Brunet 		.num_parents = 1,					\
721cd50181SJerome Brunet 		.flags = (_iflags),					\
731cd50181SJerome Brunet 	},								\
741cd50181SJerome Brunet }
751cd50181SJerome Brunet 
76b18819c4SJerome Brunet #define AUD_PCLK_GATE(_name, _bit)				\
77b18819c4SJerome Brunet 	AUD_GATE(_name, AUDIO_CLK_GATE_EN, _bit, "audio_pclk", 0)
781cd50181SJerome Brunet 
791cd50181SJerome Brunet /* Audio peripheral clocks */
80b18819c4SJerome Brunet static AUD_PCLK_GATE(ddr_arb,	   0);
81b18819c4SJerome Brunet static AUD_PCLK_GATE(pdm,	   1);
82b18819c4SJerome Brunet static AUD_PCLK_GATE(tdmin_a,	   2);
83b18819c4SJerome Brunet static AUD_PCLK_GATE(tdmin_b,	   3);
84b18819c4SJerome Brunet static AUD_PCLK_GATE(tdmin_c,	   4);
85b18819c4SJerome Brunet static AUD_PCLK_GATE(tdmin_lb,	   5);
86b18819c4SJerome Brunet static AUD_PCLK_GATE(tdmout_a,	   6);
87b18819c4SJerome Brunet static AUD_PCLK_GATE(tdmout_b,	   7);
88b18819c4SJerome Brunet static AUD_PCLK_GATE(tdmout_c,	   8);
89b18819c4SJerome Brunet static AUD_PCLK_GATE(frddr_a,	   9);
90b18819c4SJerome Brunet static AUD_PCLK_GATE(frddr_b,	   10);
91b18819c4SJerome Brunet static AUD_PCLK_GATE(frddr_c,	   11);
92b18819c4SJerome Brunet static AUD_PCLK_GATE(toddr_a,	   12);
93b18819c4SJerome Brunet static AUD_PCLK_GATE(toddr_b,	   13);
94b18819c4SJerome Brunet static AUD_PCLK_GATE(toddr_c,	   14);
95b18819c4SJerome Brunet static AUD_PCLK_GATE(loopback,	   15);
96b18819c4SJerome Brunet static AUD_PCLK_GATE(spdifin,	   16);
97b18819c4SJerome Brunet static AUD_PCLK_GATE(spdifout,	   17);
98b18819c4SJerome Brunet static AUD_PCLK_GATE(resample,	   18);
99b18819c4SJerome Brunet static AUD_PCLK_GATE(power_detect, 19);
10007500138SMaxime Jourdan static AUD_PCLK_GATE(spdifout_b,   21);
1011cd50181SJerome Brunet 
1021cd50181SJerome Brunet /* Audio Master Clocks */
1031cd50181SJerome Brunet static const char * const mst_mux_parent_names[] = {
104b18819c4SJerome Brunet 	"aud_mst_in0", "aud_mst_in1", "aud_mst_in2", "aud_mst_in3",
105b18819c4SJerome Brunet 	"aud_mst_in4", "aud_mst_in5", "aud_mst_in6", "aud_mst_in7",
1061cd50181SJerome Brunet };
1071cd50181SJerome Brunet 
108b18819c4SJerome Brunet #define AUD_MST_MUX(_name, _reg, _flag)				\
109b18819c4SJerome Brunet 	AUD_MUX(_name##_sel, _reg, 0x7, 24, _flag,		\
1101cd50181SJerome Brunet 		mst_mux_parent_names, CLK_SET_RATE_PARENT)
1111cd50181SJerome Brunet 
112b18819c4SJerome Brunet #define AUD_MST_MCLK_MUX(_name, _reg)				\
113b18819c4SJerome Brunet 	AUD_MST_MUX(_name, _reg, CLK_MUX_ROUND_CLOSEST)
11456dbabc0SJerome Brunet 
115b18819c4SJerome Brunet #define AUD_MST_SYS_MUX(_name, _reg)				\
116b18819c4SJerome Brunet 	AUD_MST_MUX(_name, _reg, 0)
11756dbabc0SJerome Brunet 
118b18819c4SJerome Brunet static AUD_MST_MCLK_MUX(mst_a_mclk,   AUDIO_MCLK_A_CTRL);
119b18819c4SJerome Brunet static AUD_MST_MCLK_MUX(mst_b_mclk,   AUDIO_MCLK_B_CTRL);
120b18819c4SJerome Brunet static AUD_MST_MCLK_MUX(mst_c_mclk,   AUDIO_MCLK_C_CTRL);
121b18819c4SJerome Brunet static AUD_MST_MCLK_MUX(mst_d_mclk,   AUDIO_MCLK_D_CTRL);
122b18819c4SJerome Brunet static AUD_MST_MCLK_MUX(mst_e_mclk,   AUDIO_MCLK_E_CTRL);
123b18819c4SJerome Brunet static AUD_MST_MCLK_MUX(mst_f_mclk,   AUDIO_MCLK_F_CTRL);
124b18819c4SJerome Brunet static AUD_MST_MCLK_MUX(spdifout_clk, AUDIO_CLK_SPDIFOUT_CTRL);
125b18819c4SJerome Brunet static AUD_MST_MCLK_MUX(pdm_dclk,     AUDIO_CLK_PDMIN_CTRL0);
126b18819c4SJerome Brunet static AUD_MST_SYS_MUX(spdifin_clk,   AUDIO_CLK_SPDIFIN_CTRL);
127b18819c4SJerome Brunet static AUD_MST_SYS_MUX(pdm_sysclk,    AUDIO_CLK_PDMIN_CTRL1);
12807500138SMaxime Jourdan static AUD_MST_MCLK_MUX(spdifout_b_clk, AUDIO_CLK_SPDIFOUT_B_CTRL);
12956dbabc0SJerome Brunet 
130b18819c4SJerome Brunet #define AUD_MST_DIV(_name, _reg, _flag)				\
131b18819c4SJerome Brunet 	AUD_DIV(_name##_div, _reg, 0, 16, _flag,		\
132b18819c4SJerome Brunet 		    "aud_"#_name"_sel", CLK_SET_RATE_PARENT)	\
1331cd50181SJerome Brunet 
134b18819c4SJerome Brunet #define AUD_MST_MCLK_DIV(_name, _reg)				\
135b18819c4SJerome Brunet 	AUD_MST_DIV(_name, _reg, CLK_DIVIDER_ROUND_CLOSEST)
13656dbabc0SJerome Brunet 
137b18819c4SJerome Brunet #define AUD_MST_SYS_DIV(_name, _reg)				\
138b18819c4SJerome Brunet 	AUD_MST_DIV(_name, _reg, 0)
1391cd50181SJerome Brunet 
140b18819c4SJerome Brunet static AUD_MST_MCLK_DIV(mst_a_mclk,   AUDIO_MCLK_A_CTRL);
141b18819c4SJerome Brunet static AUD_MST_MCLK_DIV(mst_b_mclk,   AUDIO_MCLK_B_CTRL);
142b18819c4SJerome Brunet static AUD_MST_MCLK_DIV(mst_c_mclk,   AUDIO_MCLK_C_CTRL);
143b18819c4SJerome Brunet static AUD_MST_MCLK_DIV(mst_d_mclk,   AUDIO_MCLK_D_CTRL);
144b18819c4SJerome Brunet static AUD_MST_MCLK_DIV(mst_e_mclk,   AUDIO_MCLK_E_CTRL);
145b18819c4SJerome Brunet static AUD_MST_MCLK_DIV(mst_f_mclk,   AUDIO_MCLK_F_CTRL);
146b18819c4SJerome Brunet static AUD_MST_MCLK_DIV(spdifout_clk, AUDIO_CLK_SPDIFOUT_CTRL);
147b18819c4SJerome Brunet static AUD_MST_MCLK_DIV(pdm_dclk,     AUDIO_CLK_PDMIN_CTRL0);
148b18819c4SJerome Brunet static AUD_MST_SYS_DIV(spdifin_clk,   AUDIO_CLK_SPDIFIN_CTRL);
149b18819c4SJerome Brunet static AUD_MST_SYS_DIV(pdm_sysclk,    AUDIO_CLK_PDMIN_CTRL1);
15007500138SMaxime Jourdan static AUD_MST_MCLK_DIV(spdifout_b_clk, AUDIO_CLK_SPDIFOUT_B_CTRL);
1511cd50181SJerome Brunet 
152b18819c4SJerome Brunet #define AUD_MST_MCLK_GATE(_name, _reg)				\
153b18819c4SJerome Brunet 	AUD_GATE(_name, _reg, 31,  "aud_"#_name"_div",	\
1541cd50181SJerome Brunet 		 CLK_SET_RATE_PARENT)
1551cd50181SJerome Brunet 
156b18819c4SJerome Brunet static AUD_MST_MCLK_GATE(mst_a_mclk,   AUDIO_MCLK_A_CTRL);
157b18819c4SJerome Brunet static AUD_MST_MCLK_GATE(mst_b_mclk,   AUDIO_MCLK_B_CTRL);
158b18819c4SJerome Brunet static AUD_MST_MCLK_GATE(mst_c_mclk,   AUDIO_MCLK_C_CTRL);
159b18819c4SJerome Brunet static AUD_MST_MCLK_GATE(mst_d_mclk,   AUDIO_MCLK_D_CTRL);
160b18819c4SJerome Brunet static AUD_MST_MCLK_GATE(mst_e_mclk,   AUDIO_MCLK_E_CTRL);
161b18819c4SJerome Brunet static AUD_MST_MCLK_GATE(mst_f_mclk,   AUDIO_MCLK_F_CTRL);
162b18819c4SJerome Brunet static AUD_MST_MCLK_GATE(spdifout_clk, AUDIO_CLK_SPDIFOUT_CTRL);
163b18819c4SJerome Brunet static AUD_MST_MCLK_GATE(spdifin_clk,  AUDIO_CLK_SPDIFIN_CTRL);
164b18819c4SJerome Brunet static AUD_MST_MCLK_GATE(pdm_dclk,     AUDIO_CLK_PDMIN_CTRL0);
165b18819c4SJerome Brunet static AUD_MST_MCLK_GATE(pdm_sysclk,   AUDIO_CLK_PDMIN_CTRL1);
16607500138SMaxime Jourdan static AUD_MST_MCLK_GATE(spdifout_b_clk, AUDIO_CLK_SPDIFOUT_B_CTRL);
1671cd50181SJerome Brunet 
1681cd50181SJerome Brunet /* Sample Clocks */
169b18819c4SJerome Brunet #define AUD_MST_SCLK_PRE_EN(_name, _reg)			\
170b18819c4SJerome Brunet 	AUD_GATE(mst_##_name##_sclk_pre_en, _reg, 31,		\
171b18819c4SJerome Brunet 		 "aud_mst_"#_name"_mclk", 0)
1721cd50181SJerome Brunet 
173b18819c4SJerome Brunet static AUD_MST_SCLK_PRE_EN(a, AUDIO_MST_A_SCLK_CTRL0);
174b18819c4SJerome Brunet static AUD_MST_SCLK_PRE_EN(b, AUDIO_MST_B_SCLK_CTRL0);
175b18819c4SJerome Brunet static AUD_MST_SCLK_PRE_EN(c, AUDIO_MST_C_SCLK_CTRL0);
176b18819c4SJerome Brunet static AUD_MST_SCLK_PRE_EN(d, AUDIO_MST_D_SCLK_CTRL0);
177b18819c4SJerome Brunet static AUD_MST_SCLK_PRE_EN(e, AUDIO_MST_E_SCLK_CTRL0);
178b18819c4SJerome Brunet static AUD_MST_SCLK_PRE_EN(f, AUDIO_MST_F_SCLK_CTRL0);
1791cd50181SJerome Brunet 
180b18819c4SJerome Brunet #define AUD_SCLK_DIV(_name, _reg, _div_shift, _div_width,		\
1811cd50181SJerome Brunet 			 _hi_shift, _hi_width, _pname, _iflags)		\
182b18819c4SJerome Brunet struct clk_regmap aud_##_name = {					\
1831cd50181SJerome Brunet 	.data = &(struct meson_sclk_div_data) {				\
1841cd50181SJerome Brunet 		.div = {						\
1851cd50181SJerome Brunet 			.reg_off = (_reg),				\
1861cd50181SJerome Brunet 			.shift   = (_div_shift),			\
1871cd50181SJerome Brunet 			.width   = (_div_width),			\
1881cd50181SJerome Brunet 		},							\
1891cd50181SJerome Brunet 		.hi = {							\
1901cd50181SJerome Brunet 			.reg_off = (_reg),				\
1911cd50181SJerome Brunet 			.shift   = (_hi_shift),				\
1921cd50181SJerome Brunet 			.width   = (_hi_width),				\
1931cd50181SJerome Brunet 		},							\
1941cd50181SJerome Brunet 	},								\
1951cd50181SJerome Brunet 	.hw.init = &(struct clk_init_data) {				\
196b18819c4SJerome Brunet 		.name = "aud_"#_name,					\
1971cd50181SJerome Brunet 		.ops = &meson_sclk_div_ops,				\
1981cd50181SJerome Brunet 		.parent_names = (const char *[]) { _pname },		\
1991cd50181SJerome Brunet 		.num_parents = 1,					\
2001cd50181SJerome Brunet 		.flags = (_iflags),					\
2011cd50181SJerome Brunet 	},								\
2021cd50181SJerome Brunet }
2031cd50181SJerome Brunet 
204b18819c4SJerome Brunet #define AUD_MST_SCLK_DIV(_name, _reg)					\
205b18819c4SJerome Brunet 	AUD_SCLK_DIV(mst_##_name##_sclk_div, _reg, 20, 10, 0, 0,	\
206b18819c4SJerome Brunet 		     "aud_mst_"#_name"_sclk_pre_en",			\
2071cd50181SJerome Brunet 		     CLK_SET_RATE_PARENT)
2081cd50181SJerome Brunet 
209b18819c4SJerome Brunet static AUD_MST_SCLK_DIV(a, AUDIO_MST_A_SCLK_CTRL0);
210b18819c4SJerome Brunet static AUD_MST_SCLK_DIV(b, AUDIO_MST_B_SCLK_CTRL0);
211b18819c4SJerome Brunet static AUD_MST_SCLK_DIV(c, AUDIO_MST_C_SCLK_CTRL0);
212b18819c4SJerome Brunet static AUD_MST_SCLK_DIV(d, AUDIO_MST_D_SCLK_CTRL0);
213b18819c4SJerome Brunet static AUD_MST_SCLK_DIV(e, AUDIO_MST_E_SCLK_CTRL0);
214b18819c4SJerome Brunet static AUD_MST_SCLK_DIV(f, AUDIO_MST_F_SCLK_CTRL0);
2151cd50181SJerome Brunet 
216b18819c4SJerome Brunet #define AUD_MST_SCLK_POST_EN(_name, _reg)				\
217b18819c4SJerome Brunet 	AUD_GATE(mst_##_name##_sclk_post_en, _reg, 30,		\
218b18819c4SJerome Brunet 		 "aud_mst_"#_name"_sclk_div", CLK_SET_RATE_PARENT)
2191cd50181SJerome Brunet 
220b18819c4SJerome Brunet static AUD_MST_SCLK_POST_EN(a, AUDIO_MST_A_SCLK_CTRL0);
221b18819c4SJerome Brunet static AUD_MST_SCLK_POST_EN(b, AUDIO_MST_B_SCLK_CTRL0);
222b18819c4SJerome Brunet static AUD_MST_SCLK_POST_EN(c, AUDIO_MST_C_SCLK_CTRL0);
223b18819c4SJerome Brunet static AUD_MST_SCLK_POST_EN(d, AUDIO_MST_D_SCLK_CTRL0);
224b18819c4SJerome Brunet static AUD_MST_SCLK_POST_EN(e, AUDIO_MST_E_SCLK_CTRL0);
225b18819c4SJerome Brunet static AUD_MST_SCLK_POST_EN(f, AUDIO_MST_F_SCLK_CTRL0);
2261cd50181SJerome Brunet 
227b18819c4SJerome Brunet #define AUD_TRIPHASE(_name, _reg, _width, _shift0, _shift1, _shift2, \
2281cd50181SJerome Brunet 			 _pname, _iflags)				\
229b18819c4SJerome Brunet struct clk_regmap aud_##_name = {					\
2301cd50181SJerome Brunet 	.data = &(struct meson_clk_triphase_data) {			\
2311cd50181SJerome Brunet 		.ph0 = {						\
2321cd50181SJerome Brunet 			.reg_off = (_reg),				\
2331cd50181SJerome Brunet 			.shift   = (_shift0),				\
2341cd50181SJerome Brunet 			.width   = (_width),				\
2351cd50181SJerome Brunet 		},							\
2361cd50181SJerome Brunet 		.ph1 = {						\
2371cd50181SJerome Brunet 			.reg_off = (_reg),				\
2381cd50181SJerome Brunet 			.shift   = (_shift1),				\
2391cd50181SJerome Brunet 			.width   = (_width),				\
2401cd50181SJerome Brunet 		},							\
2411cd50181SJerome Brunet 		.ph2 = {						\
2421cd50181SJerome Brunet 			.reg_off = (_reg),				\
2431cd50181SJerome Brunet 			.shift   = (_shift2),				\
2441cd50181SJerome Brunet 			.width   = (_width),				\
2451cd50181SJerome Brunet 		},							\
2461cd50181SJerome Brunet 	},								\
2471cd50181SJerome Brunet 	.hw.init = &(struct clk_init_data) {				\
248b18819c4SJerome Brunet 		.name = "aud_"#_name,					\
2491cd50181SJerome Brunet 		.ops = &meson_clk_triphase_ops,				\
2501cd50181SJerome Brunet 		.parent_names = (const char *[]) { _pname },		\
2511cd50181SJerome Brunet 		.num_parents = 1,					\
2521cd50181SJerome Brunet 		.flags = CLK_DUTY_CYCLE_PARENT | (_iflags),		\
2531cd50181SJerome Brunet 	},								\
2541cd50181SJerome Brunet }
2551cd50181SJerome Brunet 
256b18819c4SJerome Brunet #define AUD_MST_SCLK(_name, _reg)					\
257b18819c4SJerome Brunet 	AUD_TRIPHASE(mst_##_name##_sclk, _reg, 1, 0, 2, 4,		\
258b18819c4SJerome Brunet 		     "aud_mst_"#_name"_sclk_post_en", CLK_SET_RATE_PARENT)
2591cd50181SJerome Brunet 
260b18819c4SJerome Brunet static AUD_MST_SCLK(a, AUDIO_MST_A_SCLK_CTRL1);
261b18819c4SJerome Brunet static AUD_MST_SCLK(b, AUDIO_MST_B_SCLK_CTRL1);
262b18819c4SJerome Brunet static AUD_MST_SCLK(c, AUDIO_MST_C_SCLK_CTRL1);
263b18819c4SJerome Brunet static AUD_MST_SCLK(d, AUDIO_MST_D_SCLK_CTRL1);
264b18819c4SJerome Brunet static AUD_MST_SCLK(e, AUDIO_MST_E_SCLK_CTRL1);
265b18819c4SJerome Brunet static AUD_MST_SCLK(f, AUDIO_MST_F_SCLK_CTRL1);
2661cd50181SJerome Brunet 
267b18819c4SJerome Brunet #define AUD_MST_LRCLK_DIV(_name, _reg)					\
268b18819c4SJerome Brunet 	AUD_SCLK_DIV(mst_##_name##_lrclk_div, _reg, 0, 10, 10, 10,	\
269b18819c4SJerome Brunet 		     "aud_mst_"#_name"_sclk_post_en", 0)		\
2701cd50181SJerome Brunet 
271b18819c4SJerome Brunet static AUD_MST_LRCLK_DIV(a, AUDIO_MST_A_SCLK_CTRL0);
272b18819c4SJerome Brunet static AUD_MST_LRCLK_DIV(b, AUDIO_MST_B_SCLK_CTRL0);
273b18819c4SJerome Brunet static AUD_MST_LRCLK_DIV(c, AUDIO_MST_C_SCLK_CTRL0);
274b18819c4SJerome Brunet static AUD_MST_LRCLK_DIV(d, AUDIO_MST_D_SCLK_CTRL0);
275b18819c4SJerome Brunet static AUD_MST_LRCLK_DIV(e, AUDIO_MST_E_SCLK_CTRL0);
276b18819c4SJerome Brunet static AUD_MST_LRCLK_DIV(f, AUDIO_MST_F_SCLK_CTRL0);
2771cd50181SJerome Brunet 
278b18819c4SJerome Brunet #define AUD_MST_LRCLK(_name, _reg)					\
279b18819c4SJerome Brunet 	AUD_TRIPHASE(mst_##_name##_lrclk, _reg, 1, 1, 3, 5,		\
280b18819c4SJerome Brunet 		     "aud_mst_"#_name"_lrclk_div", CLK_SET_RATE_PARENT)
2811cd50181SJerome Brunet 
282b18819c4SJerome Brunet static AUD_MST_LRCLK(a, AUDIO_MST_A_SCLK_CTRL1);
283b18819c4SJerome Brunet static AUD_MST_LRCLK(b, AUDIO_MST_B_SCLK_CTRL1);
284b18819c4SJerome Brunet static AUD_MST_LRCLK(c, AUDIO_MST_C_SCLK_CTRL1);
285b18819c4SJerome Brunet static AUD_MST_LRCLK(d, AUDIO_MST_D_SCLK_CTRL1);
286b18819c4SJerome Brunet static AUD_MST_LRCLK(e, AUDIO_MST_E_SCLK_CTRL1);
287b18819c4SJerome Brunet static AUD_MST_LRCLK(f, AUDIO_MST_F_SCLK_CTRL1);
2881cd50181SJerome Brunet 
2891cd50181SJerome Brunet static const char * const tdm_sclk_parent_names[] = {
290b18819c4SJerome Brunet 	"aud_mst_a_sclk", "aud_mst_b_sclk", "aud_mst_c_sclk",
291b18819c4SJerome Brunet 	"aud_mst_d_sclk", "aud_mst_e_sclk", "aud_mst_f_sclk",
292b18819c4SJerome Brunet 	"aud_slv_sclk0", "aud_slv_sclk1", "aud_slv_sclk2",
293b18819c4SJerome Brunet 	"aud_slv_sclk3", "aud_slv_sclk4", "aud_slv_sclk5",
294b18819c4SJerome Brunet 	"aud_slv_sclk6", "aud_slv_sclk7", "aud_slv_sclk8",
295b18819c4SJerome Brunet 	"aud_slv_sclk9"
2961cd50181SJerome Brunet };
2971cd50181SJerome Brunet 
298b18819c4SJerome Brunet #define AUD_TDM_SCLK_MUX(_name, _reg)				\
299b18819c4SJerome Brunet 	AUD_MUX(tdm##_name##_sclk_sel, _reg, 0xf, 24,		\
3001cd50181SJerome Brunet 		    CLK_MUX_ROUND_CLOSEST,			\
3011cd50181SJerome Brunet 		    tdm_sclk_parent_names, 0)
3021cd50181SJerome Brunet 
303b18819c4SJerome Brunet static AUD_TDM_SCLK_MUX(in_a,  AUDIO_CLK_TDMIN_A_CTRL);
304b18819c4SJerome Brunet static AUD_TDM_SCLK_MUX(in_b,  AUDIO_CLK_TDMIN_B_CTRL);
305b18819c4SJerome Brunet static AUD_TDM_SCLK_MUX(in_c,  AUDIO_CLK_TDMIN_C_CTRL);
306b18819c4SJerome Brunet static AUD_TDM_SCLK_MUX(in_lb, AUDIO_CLK_TDMIN_LB_CTRL);
307b18819c4SJerome Brunet static AUD_TDM_SCLK_MUX(out_a, AUDIO_CLK_TDMOUT_A_CTRL);
308b18819c4SJerome Brunet static AUD_TDM_SCLK_MUX(out_b, AUDIO_CLK_TDMOUT_B_CTRL);
309b18819c4SJerome Brunet static AUD_TDM_SCLK_MUX(out_c, AUDIO_CLK_TDMOUT_C_CTRL);
3101cd50181SJerome Brunet 
311b18819c4SJerome Brunet #define AUD_TDM_SCLK_PRE_EN(_name, _reg)				\
312b18819c4SJerome Brunet 	AUD_GATE(tdm##_name##_sclk_pre_en, _reg, 31,			\
313b18819c4SJerome Brunet 		 "aud_tdm"#_name"_sclk_sel", CLK_SET_RATE_PARENT)
3141cd50181SJerome Brunet 
315b18819c4SJerome Brunet static AUD_TDM_SCLK_PRE_EN(in_a,  AUDIO_CLK_TDMIN_A_CTRL);
316b18819c4SJerome Brunet static AUD_TDM_SCLK_PRE_EN(in_b,  AUDIO_CLK_TDMIN_B_CTRL);
317b18819c4SJerome Brunet static AUD_TDM_SCLK_PRE_EN(in_c,  AUDIO_CLK_TDMIN_C_CTRL);
318b18819c4SJerome Brunet static AUD_TDM_SCLK_PRE_EN(in_lb, AUDIO_CLK_TDMIN_LB_CTRL);
319b18819c4SJerome Brunet static AUD_TDM_SCLK_PRE_EN(out_a, AUDIO_CLK_TDMOUT_A_CTRL);
320b18819c4SJerome Brunet static AUD_TDM_SCLK_PRE_EN(out_b, AUDIO_CLK_TDMOUT_B_CTRL);
321b18819c4SJerome Brunet static AUD_TDM_SCLK_PRE_EN(out_c, AUDIO_CLK_TDMOUT_C_CTRL);
3221cd50181SJerome Brunet 
323b18819c4SJerome Brunet #define AUD_TDM_SCLK_POST_EN(_name, _reg)				\
324b18819c4SJerome Brunet 	AUD_GATE(tdm##_name##_sclk_post_en, _reg, 30,			\
325b18819c4SJerome Brunet 		 "aud_tdm"#_name"_sclk_pre_en", CLK_SET_RATE_PARENT)
3261cd50181SJerome Brunet 
327b18819c4SJerome Brunet static AUD_TDM_SCLK_POST_EN(in_a,  AUDIO_CLK_TDMIN_A_CTRL);
328b18819c4SJerome Brunet static AUD_TDM_SCLK_POST_EN(in_b,  AUDIO_CLK_TDMIN_B_CTRL);
329b18819c4SJerome Brunet static AUD_TDM_SCLK_POST_EN(in_c,  AUDIO_CLK_TDMIN_C_CTRL);
330b18819c4SJerome Brunet static AUD_TDM_SCLK_POST_EN(in_lb, AUDIO_CLK_TDMIN_LB_CTRL);
331b18819c4SJerome Brunet static AUD_TDM_SCLK_POST_EN(out_a, AUDIO_CLK_TDMOUT_A_CTRL);
332b18819c4SJerome Brunet static AUD_TDM_SCLK_POST_EN(out_b, AUDIO_CLK_TDMOUT_B_CTRL);
333b18819c4SJerome Brunet static AUD_TDM_SCLK_POST_EN(out_c, AUDIO_CLK_TDMOUT_C_CTRL);
3341cd50181SJerome Brunet 
335b18819c4SJerome Brunet #define AUD_TDM_SCLK(_name, _reg)					\
336b18819c4SJerome Brunet 	struct clk_regmap aud_tdm##_name##_sclk = {			\
3371cd50181SJerome Brunet 	.data = &(struct meson_clk_phase_data) {			\
3381cd50181SJerome Brunet 		.ph = {							\
3391cd50181SJerome Brunet 			.reg_off = (_reg),				\
3401cd50181SJerome Brunet 			.shift   = 29,					\
3411cd50181SJerome Brunet 			.width   = 1,					\
3421cd50181SJerome Brunet 		},							\
3431cd50181SJerome Brunet 	},								\
3441cd50181SJerome Brunet 	.hw.init = &(struct clk_init_data) {				\
345b18819c4SJerome Brunet 		.name = "aud_tdm"#_name"_sclk",				\
3461cd50181SJerome Brunet 		.ops = &meson_clk_phase_ops,				\
3471cd50181SJerome Brunet 		.parent_names = (const char *[])			\
348b18819c4SJerome Brunet 		{ "aud_tdm"#_name"_sclk_post_en" },			\
3491cd50181SJerome Brunet 		.num_parents = 1,					\
3501cd50181SJerome Brunet 		.flags = CLK_DUTY_CYCLE_PARENT | CLK_SET_RATE_PARENT,	\
3511cd50181SJerome Brunet 	},								\
3521cd50181SJerome Brunet }
3531cd50181SJerome Brunet 
354b18819c4SJerome Brunet static AUD_TDM_SCLK(in_a,  AUDIO_CLK_TDMIN_A_CTRL);
355b18819c4SJerome Brunet static AUD_TDM_SCLK(in_b,  AUDIO_CLK_TDMIN_B_CTRL);
356b18819c4SJerome Brunet static AUD_TDM_SCLK(in_c,  AUDIO_CLK_TDMIN_C_CTRL);
357b18819c4SJerome Brunet static AUD_TDM_SCLK(in_lb, AUDIO_CLK_TDMIN_LB_CTRL);
358b18819c4SJerome Brunet static AUD_TDM_SCLK(out_a, AUDIO_CLK_TDMOUT_A_CTRL);
359b18819c4SJerome Brunet static AUD_TDM_SCLK(out_b, AUDIO_CLK_TDMOUT_B_CTRL);
360b18819c4SJerome Brunet static AUD_TDM_SCLK(out_c, AUDIO_CLK_TDMOUT_C_CTRL);
3611cd50181SJerome Brunet 
3621cd50181SJerome Brunet static const char * const tdm_lrclk_parent_names[] = {
363b18819c4SJerome Brunet 	"aud_mst_a_lrclk", "aud_mst_b_lrclk", "aud_mst_c_lrclk",
364b18819c4SJerome Brunet 	"aud_mst_d_lrclk", "aud_mst_e_lrclk", "aud_mst_f_lrclk",
365b18819c4SJerome Brunet 	"aud_slv_lrclk0", "aud_slv_lrclk1", "aud_slv_lrclk2",
366b18819c4SJerome Brunet 	"aud_slv_lrclk3", "aud_slv_lrclk4", "aud_slv_lrclk5",
367b18819c4SJerome Brunet 	"aud_slv_lrclk6", "aud_slv_lrclk7", "aud_slv_lrclk8",
368b18819c4SJerome Brunet 	"aud_slv_lrclk9"
3691cd50181SJerome Brunet };
3701cd50181SJerome Brunet 
371b18819c4SJerome Brunet #define AUD_TDM_LRLCK(_name, _reg)		       \
372b18819c4SJerome Brunet 	AUD_MUX(tdm##_name##_lrclk, _reg, 0xf, 20,     \
3731cd50181SJerome Brunet 		CLK_MUX_ROUND_CLOSEST,		       \
3741cd50181SJerome Brunet 		tdm_lrclk_parent_names, 0)
3751cd50181SJerome Brunet 
376b18819c4SJerome Brunet static AUD_TDM_LRLCK(in_a,  AUDIO_CLK_TDMIN_A_CTRL);
377b18819c4SJerome Brunet static AUD_TDM_LRLCK(in_b,  AUDIO_CLK_TDMIN_B_CTRL);
378b18819c4SJerome Brunet static AUD_TDM_LRLCK(in_c,  AUDIO_CLK_TDMIN_C_CTRL);
379b18819c4SJerome Brunet static AUD_TDM_LRLCK(in_lb, AUDIO_CLK_TDMIN_LB_CTRL);
380b18819c4SJerome Brunet static AUD_TDM_LRLCK(out_a, AUDIO_CLK_TDMOUT_A_CTRL);
381b18819c4SJerome Brunet static AUD_TDM_LRLCK(out_b, AUDIO_CLK_TDMOUT_B_CTRL);
382b18819c4SJerome Brunet static AUD_TDM_LRLCK(out_c, AUDIO_CLK_TDMOUT_C_CTRL);
3831cd50181SJerome Brunet 
38407500138SMaxime Jourdan /* G12a Pad control */
38507500138SMaxime Jourdan #define AUD_TDM_PAD_CTRL(_name, _reg, _shift, _parents)		\
38607500138SMaxime Jourdan 	AUD_MUX(tdm_##_name, _reg, 0x7, _shift, 0, _parents,	\
38707500138SMaxime Jourdan 		CLK_SET_RATE_NO_REPARENT)
38807500138SMaxime Jourdan 
38907500138SMaxime Jourdan static const char * const mclk_pad_ctrl_parent_names[] = {
39007500138SMaxime Jourdan 	"aud_mst_a_mclk", "aud_mst_b_mclk", "aud_mst_c_mclk",
39107500138SMaxime Jourdan 	"aud_mst_d_mclk", "aud_mst_e_mclk", "aud_mst_f_mclk",
39207500138SMaxime Jourdan };
39307500138SMaxime Jourdan 
39407500138SMaxime Jourdan static AUD_TDM_PAD_CTRL(mclk_pad_0, AUDIO_MST_PAD_CTRL0, 0,
39507500138SMaxime Jourdan 			mclk_pad_ctrl_parent_names);
39607500138SMaxime Jourdan static AUD_TDM_PAD_CTRL(mclk_pad_1, AUDIO_MST_PAD_CTRL0, 4,
39707500138SMaxime Jourdan 			mclk_pad_ctrl_parent_names);
39807500138SMaxime Jourdan 
39907500138SMaxime Jourdan static const char * const lrclk_pad_ctrl_parent_names[] = {
40007500138SMaxime Jourdan 	"aud_mst_a_lrclk", "aud_mst_b_lrclk", "aud_mst_c_lrclk",
40107500138SMaxime Jourdan 	"aud_mst_d_lrclk", "aud_mst_e_lrclk", "aud_mst_f_lrclk",
40207500138SMaxime Jourdan };
40307500138SMaxime Jourdan 
40407500138SMaxime Jourdan static AUD_TDM_PAD_CTRL(lrclk_pad_0, AUDIO_MST_PAD_CTRL1, 16,
40507500138SMaxime Jourdan 			lrclk_pad_ctrl_parent_names);
40607500138SMaxime Jourdan static AUD_TDM_PAD_CTRL(lrclk_pad_1, AUDIO_MST_PAD_CTRL1, 20,
40707500138SMaxime Jourdan 			lrclk_pad_ctrl_parent_names);
40807500138SMaxime Jourdan static AUD_TDM_PAD_CTRL(lrclk_pad_2, AUDIO_MST_PAD_CTRL1, 24,
40907500138SMaxime Jourdan 			lrclk_pad_ctrl_parent_names);
41007500138SMaxime Jourdan 
41107500138SMaxime Jourdan static const char * const sclk_pad_ctrl_parent_names[] = {
41207500138SMaxime Jourdan 	"aud_mst_a_sclk", "aud_mst_b_sclk", "aud_mst_c_sclk",
41307500138SMaxime Jourdan 	"aud_mst_d_sclk", "aud_mst_e_sclk", "aud_mst_f_sclk",
41407500138SMaxime Jourdan };
41507500138SMaxime Jourdan 
41607500138SMaxime Jourdan static AUD_TDM_PAD_CTRL(sclk_pad_0, AUDIO_MST_PAD_CTRL1, 0,
41707500138SMaxime Jourdan 			sclk_pad_ctrl_parent_names);
41807500138SMaxime Jourdan static AUD_TDM_PAD_CTRL(sclk_pad_1, AUDIO_MST_PAD_CTRL1, 4,
41907500138SMaxime Jourdan 			sclk_pad_ctrl_parent_names);
42007500138SMaxime Jourdan static AUD_TDM_PAD_CTRL(sclk_pad_2, AUDIO_MST_PAD_CTRL1, 8,
42107500138SMaxime Jourdan 			sclk_pad_ctrl_parent_names);
42207500138SMaxime Jourdan 
4231cd50181SJerome Brunet /*
4241cd50181SJerome Brunet  * Array of all clocks provided by this provider
4251cd50181SJerome Brunet  * The input clocks of the controller will be populated at runtime
4261cd50181SJerome Brunet  */
4271cd50181SJerome Brunet static struct clk_hw_onecell_data axg_audio_hw_onecell_data = {
4281cd50181SJerome Brunet 	.hws = {
429b18819c4SJerome Brunet 		[AUD_CLKID_DDR_ARB]		= &aud_ddr_arb.hw,
430b18819c4SJerome Brunet 		[AUD_CLKID_PDM]			= &aud_pdm.hw,
431b18819c4SJerome Brunet 		[AUD_CLKID_TDMIN_A]		= &aud_tdmin_a.hw,
432b18819c4SJerome Brunet 		[AUD_CLKID_TDMIN_B]		= &aud_tdmin_b.hw,
433b18819c4SJerome Brunet 		[AUD_CLKID_TDMIN_C]		= &aud_tdmin_c.hw,
434b18819c4SJerome Brunet 		[AUD_CLKID_TDMIN_LB]		= &aud_tdmin_lb.hw,
435b18819c4SJerome Brunet 		[AUD_CLKID_TDMOUT_A]		= &aud_tdmout_a.hw,
436b18819c4SJerome Brunet 		[AUD_CLKID_TDMOUT_B]		= &aud_tdmout_b.hw,
437b18819c4SJerome Brunet 		[AUD_CLKID_TDMOUT_C]		= &aud_tdmout_c.hw,
438b18819c4SJerome Brunet 		[AUD_CLKID_FRDDR_A]		= &aud_frddr_a.hw,
439b18819c4SJerome Brunet 		[AUD_CLKID_FRDDR_B]		= &aud_frddr_b.hw,
440b18819c4SJerome Brunet 		[AUD_CLKID_FRDDR_C]		= &aud_frddr_c.hw,
441b18819c4SJerome Brunet 		[AUD_CLKID_TODDR_A]		= &aud_toddr_a.hw,
442b18819c4SJerome Brunet 		[AUD_CLKID_TODDR_B]		= &aud_toddr_b.hw,
443b18819c4SJerome Brunet 		[AUD_CLKID_TODDR_C]		= &aud_toddr_c.hw,
444b18819c4SJerome Brunet 		[AUD_CLKID_LOOPBACK]		= &aud_loopback.hw,
445b18819c4SJerome Brunet 		[AUD_CLKID_SPDIFIN]		= &aud_spdifin.hw,
446b18819c4SJerome Brunet 		[AUD_CLKID_SPDIFOUT]		= &aud_spdifout.hw,
447b18819c4SJerome Brunet 		[AUD_CLKID_RESAMPLE]		= &aud_resample.hw,
448b18819c4SJerome Brunet 		[AUD_CLKID_POWER_DETECT]	= &aud_power_detect.hw,
449b18819c4SJerome Brunet 		[AUD_CLKID_MST_A_MCLK_SEL]	= &aud_mst_a_mclk_sel.hw,
450b18819c4SJerome Brunet 		[AUD_CLKID_MST_B_MCLK_SEL]	= &aud_mst_b_mclk_sel.hw,
451b18819c4SJerome Brunet 		[AUD_CLKID_MST_C_MCLK_SEL]	= &aud_mst_c_mclk_sel.hw,
452b18819c4SJerome Brunet 		[AUD_CLKID_MST_D_MCLK_SEL]	= &aud_mst_d_mclk_sel.hw,
453b18819c4SJerome Brunet 		[AUD_CLKID_MST_E_MCLK_SEL]	= &aud_mst_e_mclk_sel.hw,
454b18819c4SJerome Brunet 		[AUD_CLKID_MST_F_MCLK_SEL]	= &aud_mst_f_mclk_sel.hw,
455b18819c4SJerome Brunet 		[AUD_CLKID_MST_A_MCLK_DIV]	= &aud_mst_a_mclk_div.hw,
456b18819c4SJerome Brunet 		[AUD_CLKID_MST_B_MCLK_DIV]	= &aud_mst_b_mclk_div.hw,
457b18819c4SJerome Brunet 		[AUD_CLKID_MST_C_MCLK_DIV]	= &aud_mst_c_mclk_div.hw,
458b18819c4SJerome Brunet 		[AUD_CLKID_MST_D_MCLK_DIV]	= &aud_mst_d_mclk_div.hw,
459b18819c4SJerome Brunet 		[AUD_CLKID_MST_E_MCLK_DIV]	= &aud_mst_e_mclk_div.hw,
460b18819c4SJerome Brunet 		[AUD_CLKID_MST_F_MCLK_DIV]	= &aud_mst_f_mclk_div.hw,
461b18819c4SJerome Brunet 		[AUD_CLKID_MST_A_MCLK]		= &aud_mst_a_mclk.hw,
462b18819c4SJerome Brunet 		[AUD_CLKID_MST_B_MCLK]		= &aud_mst_b_mclk.hw,
463b18819c4SJerome Brunet 		[AUD_CLKID_MST_C_MCLK]		= &aud_mst_c_mclk.hw,
464b18819c4SJerome Brunet 		[AUD_CLKID_MST_D_MCLK]		= &aud_mst_d_mclk.hw,
465b18819c4SJerome Brunet 		[AUD_CLKID_MST_E_MCLK]		= &aud_mst_e_mclk.hw,
466b18819c4SJerome Brunet 		[AUD_CLKID_MST_F_MCLK]		= &aud_mst_f_mclk.hw,
467b18819c4SJerome Brunet 		[AUD_CLKID_SPDIFOUT_CLK_SEL]	= &aud_spdifout_clk_sel.hw,
468b18819c4SJerome Brunet 		[AUD_CLKID_SPDIFOUT_CLK_DIV]	= &aud_spdifout_clk_div.hw,
469b18819c4SJerome Brunet 		[AUD_CLKID_SPDIFOUT_CLK]	= &aud_spdifout_clk.hw,
470b18819c4SJerome Brunet 		[AUD_CLKID_SPDIFIN_CLK_SEL]	= &aud_spdifin_clk_sel.hw,
471b18819c4SJerome Brunet 		[AUD_CLKID_SPDIFIN_CLK_DIV]	= &aud_spdifin_clk_div.hw,
472b18819c4SJerome Brunet 		[AUD_CLKID_SPDIFIN_CLK]		= &aud_spdifin_clk.hw,
473b18819c4SJerome Brunet 		[AUD_CLKID_PDM_DCLK_SEL]	= &aud_pdm_dclk_sel.hw,
474b18819c4SJerome Brunet 		[AUD_CLKID_PDM_DCLK_DIV]	= &aud_pdm_dclk_div.hw,
475b18819c4SJerome Brunet 		[AUD_CLKID_PDM_DCLK]		= &aud_pdm_dclk.hw,
476b18819c4SJerome Brunet 		[AUD_CLKID_PDM_SYSCLK_SEL]	= &aud_pdm_sysclk_sel.hw,
477b18819c4SJerome Brunet 		[AUD_CLKID_PDM_SYSCLK_DIV]	= &aud_pdm_sysclk_div.hw,
478b18819c4SJerome Brunet 		[AUD_CLKID_PDM_SYSCLK]		= &aud_pdm_sysclk.hw,
479b18819c4SJerome Brunet 		[AUD_CLKID_MST_A_SCLK_PRE_EN]	= &aud_mst_a_sclk_pre_en.hw,
480b18819c4SJerome Brunet 		[AUD_CLKID_MST_B_SCLK_PRE_EN]	= &aud_mst_b_sclk_pre_en.hw,
481b18819c4SJerome Brunet 		[AUD_CLKID_MST_C_SCLK_PRE_EN]	= &aud_mst_c_sclk_pre_en.hw,
482b18819c4SJerome Brunet 		[AUD_CLKID_MST_D_SCLK_PRE_EN]	= &aud_mst_d_sclk_pre_en.hw,
483b18819c4SJerome Brunet 		[AUD_CLKID_MST_E_SCLK_PRE_EN]	= &aud_mst_e_sclk_pre_en.hw,
484b18819c4SJerome Brunet 		[AUD_CLKID_MST_F_SCLK_PRE_EN]	= &aud_mst_f_sclk_pre_en.hw,
485b18819c4SJerome Brunet 		[AUD_CLKID_MST_A_SCLK_DIV]	= &aud_mst_a_sclk_div.hw,
486b18819c4SJerome Brunet 		[AUD_CLKID_MST_B_SCLK_DIV]	= &aud_mst_b_sclk_div.hw,
487b18819c4SJerome Brunet 		[AUD_CLKID_MST_C_SCLK_DIV]	= &aud_mst_c_sclk_div.hw,
488b18819c4SJerome Brunet 		[AUD_CLKID_MST_D_SCLK_DIV]	= &aud_mst_d_sclk_div.hw,
489b18819c4SJerome Brunet 		[AUD_CLKID_MST_E_SCLK_DIV]	= &aud_mst_e_sclk_div.hw,
490b18819c4SJerome Brunet 		[AUD_CLKID_MST_F_SCLK_DIV]	= &aud_mst_f_sclk_div.hw,
491b18819c4SJerome Brunet 		[AUD_CLKID_MST_A_SCLK_POST_EN]	= &aud_mst_a_sclk_post_en.hw,
492b18819c4SJerome Brunet 		[AUD_CLKID_MST_B_SCLK_POST_EN]	= &aud_mst_b_sclk_post_en.hw,
493b18819c4SJerome Brunet 		[AUD_CLKID_MST_C_SCLK_POST_EN]	= &aud_mst_c_sclk_post_en.hw,
494b18819c4SJerome Brunet 		[AUD_CLKID_MST_D_SCLK_POST_EN]	= &aud_mst_d_sclk_post_en.hw,
495b18819c4SJerome Brunet 		[AUD_CLKID_MST_E_SCLK_POST_EN]	= &aud_mst_e_sclk_post_en.hw,
496b18819c4SJerome Brunet 		[AUD_CLKID_MST_F_SCLK_POST_EN]	= &aud_mst_f_sclk_post_en.hw,
497b18819c4SJerome Brunet 		[AUD_CLKID_MST_A_SCLK]		= &aud_mst_a_sclk.hw,
498b18819c4SJerome Brunet 		[AUD_CLKID_MST_B_SCLK]		= &aud_mst_b_sclk.hw,
499b18819c4SJerome Brunet 		[AUD_CLKID_MST_C_SCLK]		= &aud_mst_c_sclk.hw,
500b18819c4SJerome Brunet 		[AUD_CLKID_MST_D_SCLK]		= &aud_mst_d_sclk.hw,
501b18819c4SJerome Brunet 		[AUD_CLKID_MST_E_SCLK]		= &aud_mst_e_sclk.hw,
502b18819c4SJerome Brunet 		[AUD_CLKID_MST_F_SCLK]		= &aud_mst_f_sclk.hw,
503b18819c4SJerome Brunet 		[AUD_CLKID_MST_A_LRCLK_DIV]	= &aud_mst_a_lrclk_div.hw,
504b18819c4SJerome Brunet 		[AUD_CLKID_MST_B_LRCLK_DIV]	= &aud_mst_b_lrclk_div.hw,
505b18819c4SJerome Brunet 		[AUD_CLKID_MST_C_LRCLK_DIV]	= &aud_mst_c_lrclk_div.hw,
506b18819c4SJerome Brunet 		[AUD_CLKID_MST_D_LRCLK_DIV]	= &aud_mst_d_lrclk_div.hw,
507b18819c4SJerome Brunet 		[AUD_CLKID_MST_E_LRCLK_DIV]	= &aud_mst_e_lrclk_div.hw,
508b18819c4SJerome Brunet 		[AUD_CLKID_MST_F_LRCLK_DIV]	= &aud_mst_f_lrclk_div.hw,
509b18819c4SJerome Brunet 		[AUD_CLKID_MST_A_LRCLK]		= &aud_mst_a_lrclk.hw,
510b18819c4SJerome Brunet 		[AUD_CLKID_MST_B_LRCLK]		= &aud_mst_b_lrclk.hw,
511b18819c4SJerome Brunet 		[AUD_CLKID_MST_C_LRCLK]		= &aud_mst_c_lrclk.hw,
512b18819c4SJerome Brunet 		[AUD_CLKID_MST_D_LRCLK]		= &aud_mst_d_lrclk.hw,
513b18819c4SJerome Brunet 		[AUD_CLKID_MST_E_LRCLK]		= &aud_mst_e_lrclk.hw,
514b18819c4SJerome Brunet 		[AUD_CLKID_MST_F_LRCLK]		= &aud_mst_f_lrclk.hw,
515b18819c4SJerome Brunet 		[AUD_CLKID_TDMIN_A_SCLK_SEL]	= &aud_tdmin_a_sclk_sel.hw,
516b18819c4SJerome Brunet 		[AUD_CLKID_TDMIN_B_SCLK_SEL]	= &aud_tdmin_b_sclk_sel.hw,
517b18819c4SJerome Brunet 		[AUD_CLKID_TDMIN_C_SCLK_SEL]	= &aud_tdmin_c_sclk_sel.hw,
518b18819c4SJerome Brunet 		[AUD_CLKID_TDMIN_LB_SCLK_SEL]	= &aud_tdmin_lb_sclk_sel.hw,
519b18819c4SJerome Brunet 		[AUD_CLKID_TDMOUT_A_SCLK_SEL]	= &aud_tdmout_a_sclk_sel.hw,
520b18819c4SJerome Brunet 		[AUD_CLKID_TDMOUT_B_SCLK_SEL]	= &aud_tdmout_b_sclk_sel.hw,
521b18819c4SJerome Brunet 		[AUD_CLKID_TDMOUT_C_SCLK_SEL]	= &aud_tdmout_c_sclk_sel.hw,
522b18819c4SJerome Brunet 		[AUD_CLKID_TDMIN_A_SCLK_PRE_EN]	= &aud_tdmin_a_sclk_pre_en.hw,
523b18819c4SJerome Brunet 		[AUD_CLKID_TDMIN_B_SCLK_PRE_EN]	= &aud_tdmin_b_sclk_pre_en.hw,
524b18819c4SJerome Brunet 		[AUD_CLKID_TDMIN_C_SCLK_PRE_EN]	= &aud_tdmin_c_sclk_pre_en.hw,
525b18819c4SJerome Brunet 		[AUD_CLKID_TDMIN_LB_SCLK_PRE_EN] = &aud_tdmin_lb_sclk_pre_en.hw,
526b18819c4SJerome Brunet 		[AUD_CLKID_TDMOUT_A_SCLK_PRE_EN] = &aud_tdmout_a_sclk_pre_en.hw,
527b18819c4SJerome Brunet 		[AUD_CLKID_TDMOUT_B_SCLK_PRE_EN] = &aud_tdmout_b_sclk_pre_en.hw,
528b18819c4SJerome Brunet 		[AUD_CLKID_TDMOUT_C_SCLK_PRE_EN] = &aud_tdmout_c_sclk_pre_en.hw,
529b18819c4SJerome Brunet 		[AUD_CLKID_TDMIN_A_SCLK_POST_EN] = &aud_tdmin_a_sclk_post_en.hw,
530b18819c4SJerome Brunet 		[AUD_CLKID_TDMIN_B_SCLK_POST_EN] = &aud_tdmin_b_sclk_post_en.hw,
531b18819c4SJerome Brunet 		[AUD_CLKID_TDMIN_C_SCLK_POST_EN] = &aud_tdmin_c_sclk_post_en.hw,
532b18819c4SJerome Brunet 		[AUD_CLKID_TDMIN_LB_SCLK_POST_EN] = &aud_tdmin_lb_sclk_post_en.hw,
533b18819c4SJerome Brunet 		[AUD_CLKID_TDMOUT_A_SCLK_POST_EN] = &aud_tdmout_a_sclk_post_en.hw,
534b18819c4SJerome Brunet 		[AUD_CLKID_TDMOUT_B_SCLK_POST_EN] = &aud_tdmout_b_sclk_post_en.hw,
535b18819c4SJerome Brunet 		[AUD_CLKID_TDMOUT_C_SCLK_POST_EN] = &aud_tdmout_c_sclk_post_en.hw,
536b18819c4SJerome Brunet 		[AUD_CLKID_TDMIN_A_SCLK]	= &aud_tdmin_a_sclk.hw,
537b18819c4SJerome Brunet 		[AUD_CLKID_TDMIN_B_SCLK]	= &aud_tdmin_b_sclk.hw,
538b18819c4SJerome Brunet 		[AUD_CLKID_TDMIN_C_SCLK]	= &aud_tdmin_c_sclk.hw,
539b18819c4SJerome Brunet 		[AUD_CLKID_TDMIN_LB_SCLK]	= &aud_tdmin_lb_sclk.hw,
540b18819c4SJerome Brunet 		[AUD_CLKID_TDMOUT_A_SCLK]	= &aud_tdmout_a_sclk.hw,
541b18819c4SJerome Brunet 		[AUD_CLKID_TDMOUT_B_SCLK]	= &aud_tdmout_b_sclk.hw,
542b18819c4SJerome Brunet 		[AUD_CLKID_TDMOUT_C_SCLK]	= &aud_tdmout_c_sclk.hw,
543b18819c4SJerome Brunet 		[AUD_CLKID_TDMIN_A_LRCLK]	= &aud_tdmin_a_lrclk.hw,
544b18819c4SJerome Brunet 		[AUD_CLKID_TDMIN_B_LRCLK]	= &aud_tdmin_b_lrclk.hw,
545b18819c4SJerome Brunet 		[AUD_CLKID_TDMIN_C_LRCLK]	= &aud_tdmin_c_lrclk.hw,
546b18819c4SJerome Brunet 		[AUD_CLKID_TDMIN_LB_LRCLK]	= &aud_tdmin_lb_lrclk.hw,
547b18819c4SJerome Brunet 		[AUD_CLKID_TDMOUT_A_LRCLK]	= &aud_tdmout_a_lrclk.hw,
548b18819c4SJerome Brunet 		[AUD_CLKID_TDMOUT_B_LRCLK]	= &aud_tdmout_b_lrclk.hw,
549b18819c4SJerome Brunet 		[AUD_CLKID_TDMOUT_C_LRCLK]	= &aud_tdmout_c_lrclk.hw,
5501cd50181SJerome Brunet 		[NR_CLKS] = NULL,
5511cd50181SJerome Brunet 	},
5521cd50181SJerome Brunet 	.num = NR_CLKS,
5531cd50181SJerome Brunet };
5541cd50181SJerome Brunet 
55507500138SMaxime Jourdan /*
55607500138SMaxime Jourdan  * Array of all G12A clocks provided by this provider
55707500138SMaxime Jourdan  * The input clocks of the controller will be populated at runtime
55807500138SMaxime Jourdan  */
55907500138SMaxime Jourdan static struct clk_hw_onecell_data g12a_audio_hw_onecell_data = {
56007500138SMaxime Jourdan 	.hws = {
56107500138SMaxime Jourdan 		[AUD_CLKID_DDR_ARB]		= &aud_ddr_arb.hw,
56207500138SMaxime Jourdan 		[AUD_CLKID_PDM]			= &aud_pdm.hw,
56307500138SMaxime Jourdan 		[AUD_CLKID_TDMIN_A]		= &aud_tdmin_a.hw,
56407500138SMaxime Jourdan 		[AUD_CLKID_TDMIN_B]		= &aud_tdmin_b.hw,
56507500138SMaxime Jourdan 		[AUD_CLKID_TDMIN_C]		= &aud_tdmin_c.hw,
56607500138SMaxime Jourdan 		[AUD_CLKID_TDMIN_LB]		= &aud_tdmin_lb.hw,
56707500138SMaxime Jourdan 		[AUD_CLKID_TDMOUT_A]		= &aud_tdmout_a.hw,
56807500138SMaxime Jourdan 		[AUD_CLKID_TDMOUT_B]		= &aud_tdmout_b.hw,
56907500138SMaxime Jourdan 		[AUD_CLKID_TDMOUT_C]		= &aud_tdmout_c.hw,
57007500138SMaxime Jourdan 		[AUD_CLKID_FRDDR_A]		= &aud_frddr_a.hw,
57107500138SMaxime Jourdan 		[AUD_CLKID_FRDDR_B]		= &aud_frddr_b.hw,
57207500138SMaxime Jourdan 		[AUD_CLKID_FRDDR_C]		= &aud_frddr_c.hw,
57307500138SMaxime Jourdan 		[AUD_CLKID_TODDR_A]		= &aud_toddr_a.hw,
57407500138SMaxime Jourdan 		[AUD_CLKID_TODDR_B]		= &aud_toddr_b.hw,
57507500138SMaxime Jourdan 		[AUD_CLKID_TODDR_C]		= &aud_toddr_c.hw,
57607500138SMaxime Jourdan 		[AUD_CLKID_LOOPBACK]		= &aud_loopback.hw,
57707500138SMaxime Jourdan 		[AUD_CLKID_SPDIFIN]		= &aud_spdifin.hw,
57807500138SMaxime Jourdan 		[AUD_CLKID_SPDIFOUT]		= &aud_spdifout.hw,
57907500138SMaxime Jourdan 		[AUD_CLKID_RESAMPLE]		= &aud_resample.hw,
58007500138SMaxime Jourdan 		[AUD_CLKID_POWER_DETECT]	= &aud_power_detect.hw,
58107500138SMaxime Jourdan 		[AUD_CLKID_SPDIFOUT_B]		= &aud_spdifout_b.hw,
58207500138SMaxime Jourdan 		[AUD_CLKID_MST_A_MCLK_SEL]	= &aud_mst_a_mclk_sel.hw,
58307500138SMaxime Jourdan 		[AUD_CLKID_MST_B_MCLK_SEL]	= &aud_mst_b_mclk_sel.hw,
58407500138SMaxime Jourdan 		[AUD_CLKID_MST_C_MCLK_SEL]	= &aud_mst_c_mclk_sel.hw,
58507500138SMaxime Jourdan 		[AUD_CLKID_MST_D_MCLK_SEL]	= &aud_mst_d_mclk_sel.hw,
58607500138SMaxime Jourdan 		[AUD_CLKID_MST_E_MCLK_SEL]	= &aud_mst_e_mclk_sel.hw,
58707500138SMaxime Jourdan 		[AUD_CLKID_MST_F_MCLK_SEL]	= &aud_mst_f_mclk_sel.hw,
58807500138SMaxime Jourdan 		[AUD_CLKID_MST_A_MCLK_DIV]	= &aud_mst_a_mclk_div.hw,
58907500138SMaxime Jourdan 		[AUD_CLKID_MST_B_MCLK_DIV]	= &aud_mst_b_mclk_div.hw,
59007500138SMaxime Jourdan 		[AUD_CLKID_MST_C_MCLK_DIV]	= &aud_mst_c_mclk_div.hw,
59107500138SMaxime Jourdan 		[AUD_CLKID_MST_D_MCLK_DIV]	= &aud_mst_d_mclk_div.hw,
59207500138SMaxime Jourdan 		[AUD_CLKID_MST_E_MCLK_DIV]	= &aud_mst_e_mclk_div.hw,
59307500138SMaxime Jourdan 		[AUD_CLKID_MST_F_MCLK_DIV]	= &aud_mst_f_mclk_div.hw,
59407500138SMaxime Jourdan 		[AUD_CLKID_MST_A_MCLK]		= &aud_mst_a_mclk.hw,
59507500138SMaxime Jourdan 		[AUD_CLKID_MST_B_MCLK]		= &aud_mst_b_mclk.hw,
59607500138SMaxime Jourdan 		[AUD_CLKID_MST_C_MCLK]		= &aud_mst_c_mclk.hw,
59707500138SMaxime Jourdan 		[AUD_CLKID_MST_D_MCLK]		= &aud_mst_d_mclk.hw,
59807500138SMaxime Jourdan 		[AUD_CLKID_MST_E_MCLK]		= &aud_mst_e_mclk.hw,
59907500138SMaxime Jourdan 		[AUD_CLKID_MST_F_MCLK]		= &aud_mst_f_mclk.hw,
60007500138SMaxime Jourdan 		[AUD_CLKID_SPDIFOUT_CLK_SEL]	= &aud_spdifout_clk_sel.hw,
60107500138SMaxime Jourdan 		[AUD_CLKID_SPDIFOUT_CLK_DIV]	= &aud_spdifout_clk_div.hw,
60207500138SMaxime Jourdan 		[AUD_CLKID_SPDIFOUT_CLK]	= &aud_spdifout_clk.hw,
60307500138SMaxime Jourdan 		[AUD_CLKID_SPDIFOUT_B_CLK_SEL]	= &aud_spdifout_b_clk_sel.hw,
60407500138SMaxime Jourdan 		[AUD_CLKID_SPDIFOUT_B_CLK_DIV]	= &aud_spdifout_b_clk_div.hw,
60507500138SMaxime Jourdan 		[AUD_CLKID_SPDIFOUT_B_CLK]	= &aud_spdifout_b_clk.hw,
60607500138SMaxime Jourdan 		[AUD_CLKID_SPDIFIN_CLK_SEL]	= &aud_spdifin_clk_sel.hw,
60707500138SMaxime Jourdan 		[AUD_CLKID_SPDIFIN_CLK_DIV]	= &aud_spdifin_clk_div.hw,
60807500138SMaxime Jourdan 		[AUD_CLKID_SPDIFIN_CLK]		= &aud_spdifin_clk.hw,
60907500138SMaxime Jourdan 		[AUD_CLKID_PDM_DCLK_SEL]	= &aud_pdm_dclk_sel.hw,
61007500138SMaxime Jourdan 		[AUD_CLKID_PDM_DCLK_DIV]	= &aud_pdm_dclk_div.hw,
61107500138SMaxime Jourdan 		[AUD_CLKID_PDM_DCLK]		= &aud_pdm_dclk.hw,
61207500138SMaxime Jourdan 		[AUD_CLKID_PDM_SYSCLK_SEL]	= &aud_pdm_sysclk_sel.hw,
61307500138SMaxime Jourdan 		[AUD_CLKID_PDM_SYSCLK_DIV]	= &aud_pdm_sysclk_div.hw,
61407500138SMaxime Jourdan 		[AUD_CLKID_PDM_SYSCLK]		= &aud_pdm_sysclk.hw,
61507500138SMaxime Jourdan 		[AUD_CLKID_MST_A_SCLK_PRE_EN]	= &aud_mst_a_sclk_pre_en.hw,
61607500138SMaxime Jourdan 		[AUD_CLKID_MST_B_SCLK_PRE_EN]	= &aud_mst_b_sclk_pre_en.hw,
61707500138SMaxime Jourdan 		[AUD_CLKID_MST_C_SCLK_PRE_EN]	= &aud_mst_c_sclk_pre_en.hw,
61807500138SMaxime Jourdan 		[AUD_CLKID_MST_D_SCLK_PRE_EN]	= &aud_mst_d_sclk_pre_en.hw,
61907500138SMaxime Jourdan 		[AUD_CLKID_MST_E_SCLK_PRE_EN]	= &aud_mst_e_sclk_pre_en.hw,
62007500138SMaxime Jourdan 		[AUD_CLKID_MST_F_SCLK_PRE_EN]	= &aud_mst_f_sclk_pre_en.hw,
62107500138SMaxime Jourdan 		[AUD_CLKID_MST_A_SCLK_DIV]	= &aud_mst_a_sclk_div.hw,
62207500138SMaxime Jourdan 		[AUD_CLKID_MST_B_SCLK_DIV]	= &aud_mst_b_sclk_div.hw,
62307500138SMaxime Jourdan 		[AUD_CLKID_MST_C_SCLK_DIV]	= &aud_mst_c_sclk_div.hw,
62407500138SMaxime Jourdan 		[AUD_CLKID_MST_D_SCLK_DIV]	= &aud_mst_d_sclk_div.hw,
62507500138SMaxime Jourdan 		[AUD_CLKID_MST_E_SCLK_DIV]	= &aud_mst_e_sclk_div.hw,
62607500138SMaxime Jourdan 		[AUD_CLKID_MST_F_SCLK_DIV]	= &aud_mst_f_sclk_div.hw,
62707500138SMaxime Jourdan 		[AUD_CLKID_MST_A_SCLK_POST_EN]	= &aud_mst_a_sclk_post_en.hw,
62807500138SMaxime Jourdan 		[AUD_CLKID_MST_B_SCLK_POST_EN]	= &aud_mst_b_sclk_post_en.hw,
62907500138SMaxime Jourdan 		[AUD_CLKID_MST_C_SCLK_POST_EN]	= &aud_mst_c_sclk_post_en.hw,
63007500138SMaxime Jourdan 		[AUD_CLKID_MST_D_SCLK_POST_EN]	= &aud_mst_d_sclk_post_en.hw,
63107500138SMaxime Jourdan 		[AUD_CLKID_MST_E_SCLK_POST_EN]	= &aud_mst_e_sclk_post_en.hw,
63207500138SMaxime Jourdan 		[AUD_CLKID_MST_F_SCLK_POST_EN]	= &aud_mst_f_sclk_post_en.hw,
63307500138SMaxime Jourdan 		[AUD_CLKID_MST_A_SCLK]		= &aud_mst_a_sclk.hw,
63407500138SMaxime Jourdan 		[AUD_CLKID_MST_B_SCLK]		= &aud_mst_b_sclk.hw,
63507500138SMaxime Jourdan 		[AUD_CLKID_MST_C_SCLK]		= &aud_mst_c_sclk.hw,
63607500138SMaxime Jourdan 		[AUD_CLKID_MST_D_SCLK]		= &aud_mst_d_sclk.hw,
63707500138SMaxime Jourdan 		[AUD_CLKID_MST_E_SCLK]		= &aud_mst_e_sclk.hw,
63807500138SMaxime Jourdan 		[AUD_CLKID_MST_F_SCLK]		= &aud_mst_f_sclk.hw,
63907500138SMaxime Jourdan 		[AUD_CLKID_MST_A_LRCLK_DIV]	= &aud_mst_a_lrclk_div.hw,
64007500138SMaxime Jourdan 		[AUD_CLKID_MST_B_LRCLK_DIV]	= &aud_mst_b_lrclk_div.hw,
64107500138SMaxime Jourdan 		[AUD_CLKID_MST_C_LRCLK_DIV]	= &aud_mst_c_lrclk_div.hw,
64207500138SMaxime Jourdan 		[AUD_CLKID_MST_D_LRCLK_DIV]	= &aud_mst_d_lrclk_div.hw,
64307500138SMaxime Jourdan 		[AUD_CLKID_MST_E_LRCLK_DIV]	= &aud_mst_e_lrclk_div.hw,
64407500138SMaxime Jourdan 		[AUD_CLKID_MST_F_LRCLK_DIV]	= &aud_mst_f_lrclk_div.hw,
64507500138SMaxime Jourdan 		[AUD_CLKID_MST_A_LRCLK]		= &aud_mst_a_lrclk.hw,
64607500138SMaxime Jourdan 		[AUD_CLKID_MST_B_LRCLK]		= &aud_mst_b_lrclk.hw,
64707500138SMaxime Jourdan 		[AUD_CLKID_MST_C_LRCLK]		= &aud_mst_c_lrclk.hw,
64807500138SMaxime Jourdan 		[AUD_CLKID_MST_D_LRCLK]		= &aud_mst_d_lrclk.hw,
64907500138SMaxime Jourdan 		[AUD_CLKID_MST_E_LRCLK]		= &aud_mst_e_lrclk.hw,
65007500138SMaxime Jourdan 		[AUD_CLKID_MST_F_LRCLK]		= &aud_mst_f_lrclk.hw,
65107500138SMaxime Jourdan 		[AUD_CLKID_TDMIN_A_SCLK_SEL]	= &aud_tdmin_a_sclk_sel.hw,
65207500138SMaxime Jourdan 		[AUD_CLKID_TDMIN_B_SCLK_SEL]	= &aud_tdmin_b_sclk_sel.hw,
65307500138SMaxime Jourdan 		[AUD_CLKID_TDMIN_C_SCLK_SEL]	= &aud_tdmin_c_sclk_sel.hw,
65407500138SMaxime Jourdan 		[AUD_CLKID_TDMIN_LB_SCLK_SEL]	= &aud_tdmin_lb_sclk_sel.hw,
65507500138SMaxime Jourdan 		[AUD_CLKID_TDMOUT_A_SCLK_SEL]	= &aud_tdmout_a_sclk_sel.hw,
65607500138SMaxime Jourdan 		[AUD_CLKID_TDMOUT_B_SCLK_SEL]	= &aud_tdmout_b_sclk_sel.hw,
65707500138SMaxime Jourdan 		[AUD_CLKID_TDMOUT_C_SCLK_SEL]	= &aud_tdmout_c_sclk_sel.hw,
65807500138SMaxime Jourdan 		[AUD_CLKID_TDMIN_A_SCLK_PRE_EN]	= &aud_tdmin_a_sclk_pre_en.hw,
65907500138SMaxime Jourdan 		[AUD_CLKID_TDMIN_B_SCLK_PRE_EN]	= &aud_tdmin_b_sclk_pre_en.hw,
66007500138SMaxime Jourdan 		[AUD_CLKID_TDMIN_C_SCLK_PRE_EN]	= &aud_tdmin_c_sclk_pre_en.hw,
66107500138SMaxime Jourdan 		[AUD_CLKID_TDMIN_LB_SCLK_PRE_EN] = &aud_tdmin_lb_sclk_pre_en.hw,
66207500138SMaxime Jourdan 		[AUD_CLKID_TDMOUT_A_SCLK_PRE_EN] = &aud_tdmout_a_sclk_pre_en.hw,
66307500138SMaxime Jourdan 		[AUD_CLKID_TDMOUT_B_SCLK_PRE_EN] = &aud_tdmout_b_sclk_pre_en.hw,
66407500138SMaxime Jourdan 		[AUD_CLKID_TDMOUT_C_SCLK_PRE_EN] = &aud_tdmout_c_sclk_pre_en.hw,
66507500138SMaxime Jourdan 		[AUD_CLKID_TDMIN_A_SCLK_POST_EN] = &aud_tdmin_a_sclk_post_en.hw,
66607500138SMaxime Jourdan 		[AUD_CLKID_TDMIN_B_SCLK_POST_EN] = &aud_tdmin_b_sclk_post_en.hw,
66707500138SMaxime Jourdan 		[AUD_CLKID_TDMIN_C_SCLK_POST_EN] = &aud_tdmin_c_sclk_post_en.hw,
66807500138SMaxime Jourdan 		[AUD_CLKID_TDMIN_LB_SCLK_POST_EN] = &aud_tdmin_lb_sclk_post_en.hw,
66907500138SMaxime Jourdan 		[AUD_CLKID_TDMOUT_A_SCLK_POST_EN] = &aud_tdmout_a_sclk_post_en.hw,
67007500138SMaxime Jourdan 		[AUD_CLKID_TDMOUT_B_SCLK_POST_EN] = &aud_tdmout_b_sclk_post_en.hw,
67107500138SMaxime Jourdan 		[AUD_CLKID_TDMOUT_C_SCLK_POST_EN] = &aud_tdmout_c_sclk_post_en.hw,
67207500138SMaxime Jourdan 		[AUD_CLKID_TDMIN_A_SCLK]	= &aud_tdmin_a_sclk.hw,
67307500138SMaxime Jourdan 		[AUD_CLKID_TDMIN_B_SCLK]	= &aud_tdmin_b_sclk.hw,
67407500138SMaxime Jourdan 		[AUD_CLKID_TDMIN_C_SCLK]	= &aud_tdmin_c_sclk.hw,
67507500138SMaxime Jourdan 		[AUD_CLKID_TDMIN_LB_SCLK]	= &aud_tdmin_lb_sclk.hw,
67607500138SMaxime Jourdan 		[AUD_CLKID_TDMOUT_A_SCLK]	= &aud_tdmout_a_sclk.hw,
67707500138SMaxime Jourdan 		[AUD_CLKID_TDMOUT_B_SCLK]	= &aud_tdmout_b_sclk.hw,
67807500138SMaxime Jourdan 		[AUD_CLKID_TDMOUT_C_SCLK]	= &aud_tdmout_c_sclk.hw,
67907500138SMaxime Jourdan 		[AUD_CLKID_TDMIN_A_LRCLK]	= &aud_tdmin_a_lrclk.hw,
68007500138SMaxime Jourdan 		[AUD_CLKID_TDMIN_B_LRCLK]	= &aud_tdmin_b_lrclk.hw,
68107500138SMaxime Jourdan 		[AUD_CLKID_TDMIN_C_LRCLK]	= &aud_tdmin_c_lrclk.hw,
68207500138SMaxime Jourdan 		[AUD_CLKID_TDMIN_LB_LRCLK]	= &aud_tdmin_lb_lrclk.hw,
68307500138SMaxime Jourdan 		[AUD_CLKID_TDMOUT_A_LRCLK]	= &aud_tdmout_a_lrclk.hw,
68407500138SMaxime Jourdan 		[AUD_CLKID_TDMOUT_B_LRCLK]	= &aud_tdmout_b_lrclk.hw,
68507500138SMaxime Jourdan 		[AUD_CLKID_TDMOUT_C_LRCLK]	= &aud_tdmout_c_lrclk.hw,
68607500138SMaxime Jourdan 		[AUD_CLKID_TDM_MCLK_PAD0]	= &aud_tdm_mclk_pad_0.hw,
68707500138SMaxime Jourdan 		[AUD_CLKID_TDM_MCLK_PAD1]	= &aud_tdm_mclk_pad_1.hw,
68807500138SMaxime Jourdan 		[AUD_CLKID_TDM_LRCLK_PAD0]	= &aud_tdm_lrclk_pad_0.hw,
68907500138SMaxime Jourdan 		[AUD_CLKID_TDM_LRCLK_PAD1]	= &aud_tdm_lrclk_pad_1.hw,
69007500138SMaxime Jourdan 		[AUD_CLKID_TDM_LRCLK_PAD2]	= &aud_tdm_lrclk_pad_2.hw,
69107500138SMaxime Jourdan 		[AUD_CLKID_TDM_SCLK_PAD0]	= &aud_tdm_sclk_pad_0.hw,
69207500138SMaxime Jourdan 		[AUD_CLKID_TDM_SCLK_PAD1]	= &aud_tdm_sclk_pad_1.hw,
69307500138SMaxime Jourdan 		[AUD_CLKID_TDM_SCLK_PAD2]	= &aud_tdm_sclk_pad_2.hw,
69407500138SMaxime Jourdan 		[NR_CLKS] = NULL,
69507500138SMaxime Jourdan 	},
69607500138SMaxime Jourdan 	.num = NR_CLKS,
69707500138SMaxime Jourdan };
69807500138SMaxime Jourdan 
69907500138SMaxime Jourdan /* Convenience table to populate regmap in .probe()
70007500138SMaxime Jourdan  * Note that this table is shared between both AXG and G12A,
70107500138SMaxime Jourdan  * with spdifout_b clocks being exclusive to G12A. Since those
70207500138SMaxime Jourdan  * clocks are not declared within the AXG onecell table, we do not
70307500138SMaxime Jourdan  * feel the need to have separate AXG/G12A regmap tables.
70407500138SMaxime Jourdan  */
705b18819c4SJerome Brunet static struct clk_regmap *const aud_clk_regmaps[] = {
706b18819c4SJerome Brunet 	&aud_ddr_arb,
707b18819c4SJerome Brunet 	&aud_pdm,
708b18819c4SJerome Brunet 	&aud_tdmin_a,
709b18819c4SJerome Brunet 	&aud_tdmin_b,
710b18819c4SJerome Brunet 	&aud_tdmin_c,
711b18819c4SJerome Brunet 	&aud_tdmin_lb,
712b18819c4SJerome Brunet 	&aud_tdmout_a,
713b18819c4SJerome Brunet 	&aud_tdmout_b,
714b18819c4SJerome Brunet 	&aud_tdmout_c,
715b18819c4SJerome Brunet 	&aud_frddr_a,
716b18819c4SJerome Brunet 	&aud_frddr_b,
717b18819c4SJerome Brunet 	&aud_frddr_c,
718b18819c4SJerome Brunet 	&aud_toddr_a,
719b18819c4SJerome Brunet 	&aud_toddr_b,
720b18819c4SJerome Brunet 	&aud_toddr_c,
721b18819c4SJerome Brunet 	&aud_loopback,
722b18819c4SJerome Brunet 	&aud_spdifin,
723b18819c4SJerome Brunet 	&aud_spdifout,
724b18819c4SJerome Brunet 	&aud_resample,
725b18819c4SJerome Brunet 	&aud_power_detect,
72607500138SMaxime Jourdan 	&aud_spdifout_b,
727b18819c4SJerome Brunet 	&aud_mst_a_mclk_sel,
728b18819c4SJerome Brunet 	&aud_mst_b_mclk_sel,
729b18819c4SJerome Brunet 	&aud_mst_c_mclk_sel,
730b18819c4SJerome Brunet 	&aud_mst_d_mclk_sel,
731b18819c4SJerome Brunet 	&aud_mst_e_mclk_sel,
732b18819c4SJerome Brunet 	&aud_mst_f_mclk_sel,
733b18819c4SJerome Brunet 	&aud_mst_a_mclk_div,
734b18819c4SJerome Brunet 	&aud_mst_b_mclk_div,
735b18819c4SJerome Brunet 	&aud_mst_c_mclk_div,
736b18819c4SJerome Brunet 	&aud_mst_d_mclk_div,
737b18819c4SJerome Brunet 	&aud_mst_e_mclk_div,
738b18819c4SJerome Brunet 	&aud_mst_f_mclk_div,
739b18819c4SJerome Brunet 	&aud_mst_a_mclk,
740b18819c4SJerome Brunet 	&aud_mst_b_mclk,
741b18819c4SJerome Brunet 	&aud_mst_c_mclk,
742b18819c4SJerome Brunet 	&aud_mst_d_mclk,
743b18819c4SJerome Brunet 	&aud_mst_e_mclk,
744b18819c4SJerome Brunet 	&aud_mst_f_mclk,
745b18819c4SJerome Brunet 	&aud_spdifout_clk_sel,
746b18819c4SJerome Brunet 	&aud_spdifout_clk_div,
747b18819c4SJerome Brunet 	&aud_spdifout_clk,
748b18819c4SJerome Brunet 	&aud_spdifin_clk_sel,
749b18819c4SJerome Brunet 	&aud_spdifin_clk_div,
750b18819c4SJerome Brunet 	&aud_spdifin_clk,
751b18819c4SJerome Brunet 	&aud_pdm_dclk_sel,
752b18819c4SJerome Brunet 	&aud_pdm_dclk_div,
753b18819c4SJerome Brunet 	&aud_pdm_dclk,
754b18819c4SJerome Brunet 	&aud_pdm_sysclk_sel,
755b18819c4SJerome Brunet 	&aud_pdm_sysclk_div,
756b18819c4SJerome Brunet 	&aud_pdm_sysclk,
757b18819c4SJerome Brunet 	&aud_mst_a_sclk_pre_en,
758b18819c4SJerome Brunet 	&aud_mst_b_sclk_pre_en,
759b18819c4SJerome Brunet 	&aud_mst_c_sclk_pre_en,
760b18819c4SJerome Brunet 	&aud_mst_d_sclk_pre_en,
761b18819c4SJerome Brunet 	&aud_mst_e_sclk_pre_en,
762b18819c4SJerome Brunet 	&aud_mst_f_sclk_pre_en,
763b18819c4SJerome Brunet 	&aud_mst_a_sclk_div,
764b18819c4SJerome Brunet 	&aud_mst_b_sclk_div,
765b18819c4SJerome Brunet 	&aud_mst_c_sclk_div,
766b18819c4SJerome Brunet 	&aud_mst_d_sclk_div,
767b18819c4SJerome Brunet 	&aud_mst_e_sclk_div,
768b18819c4SJerome Brunet 	&aud_mst_f_sclk_div,
769b18819c4SJerome Brunet 	&aud_mst_a_sclk_post_en,
770b18819c4SJerome Brunet 	&aud_mst_b_sclk_post_en,
771b18819c4SJerome Brunet 	&aud_mst_c_sclk_post_en,
772b18819c4SJerome Brunet 	&aud_mst_d_sclk_post_en,
773b18819c4SJerome Brunet 	&aud_mst_e_sclk_post_en,
774b18819c4SJerome Brunet 	&aud_mst_f_sclk_post_en,
775b18819c4SJerome Brunet 	&aud_mst_a_sclk,
776b18819c4SJerome Brunet 	&aud_mst_b_sclk,
777b18819c4SJerome Brunet 	&aud_mst_c_sclk,
778b18819c4SJerome Brunet 	&aud_mst_d_sclk,
779b18819c4SJerome Brunet 	&aud_mst_e_sclk,
780b18819c4SJerome Brunet 	&aud_mst_f_sclk,
781b18819c4SJerome Brunet 	&aud_mst_a_lrclk_div,
782b18819c4SJerome Brunet 	&aud_mst_b_lrclk_div,
783b18819c4SJerome Brunet 	&aud_mst_c_lrclk_div,
784b18819c4SJerome Brunet 	&aud_mst_d_lrclk_div,
785b18819c4SJerome Brunet 	&aud_mst_e_lrclk_div,
786b18819c4SJerome Brunet 	&aud_mst_f_lrclk_div,
787b18819c4SJerome Brunet 	&aud_mst_a_lrclk,
788b18819c4SJerome Brunet 	&aud_mst_b_lrclk,
789b18819c4SJerome Brunet 	&aud_mst_c_lrclk,
790b18819c4SJerome Brunet 	&aud_mst_d_lrclk,
791b18819c4SJerome Brunet 	&aud_mst_e_lrclk,
792b18819c4SJerome Brunet 	&aud_mst_f_lrclk,
793b18819c4SJerome Brunet 	&aud_tdmin_a_sclk_sel,
794b18819c4SJerome Brunet 	&aud_tdmin_b_sclk_sel,
795b18819c4SJerome Brunet 	&aud_tdmin_c_sclk_sel,
796b18819c4SJerome Brunet 	&aud_tdmin_lb_sclk_sel,
797b18819c4SJerome Brunet 	&aud_tdmout_a_sclk_sel,
798b18819c4SJerome Brunet 	&aud_tdmout_b_sclk_sel,
799b18819c4SJerome Brunet 	&aud_tdmout_c_sclk_sel,
800b18819c4SJerome Brunet 	&aud_tdmin_a_sclk_pre_en,
801b18819c4SJerome Brunet 	&aud_tdmin_b_sclk_pre_en,
802b18819c4SJerome Brunet 	&aud_tdmin_c_sclk_pre_en,
803b18819c4SJerome Brunet 	&aud_tdmin_lb_sclk_pre_en,
804b18819c4SJerome Brunet 	&aud_tdmout_a_sclk_pre_en,
805b18819c4SJerome Brunet 	&aud_tdmout_b_sclk_pre_en,
806b18819c4SJerome Brunet 	&aud_tdmout_c_sclk_pre_en,
807b18819c4SJerome Brunet 	&aud_tdmin_a_sclk_post_en,
808b18819c4SJerome Brunet 	&aud_tdmin_b_sclk_post_en,
809b18819c4SJerome Brunet 	&aud_tdmin_c_sclk_post_en,
810b18819c4SJerome Brunet 	&aud_tdmin_lb_sclk_post_en,
811b18819c4SJerome Brunet 	&aud_tdmout_a_sclk_post_en,
812b18819c4SJerome Brunet 	&aud_tdmout_b_sclk_post_en,
813b18819c4SJerome Brunet 	&aud_tdmout_c_sclk_post_en,
814b18819c4SJerome Brunet 	&aud_tdmin_a_sclk,
815b18819c4SJerome Brunet 	&aud_tdmin_b_sclk,
816b18819c4SJerome Brunet 	&aud_tdmin_c_sclk,
817b18819c4SJerome Brunet 	&aud_tdmin_lb_sclk,
818b18819c4SJerome Brunet 	&aud_tdmout_a_sclk,
819b18819c4SJerome Brunet 	&aud_tdmout_b_sclk,
820b18819c4SJerome Brunet 	&aud_tdmout_c_sclk,
821b18819c4SJerome Brunet 	&aud_tdmin_a_lrclk,
822b18819c4SJerome Brunet 	&aud_tdmin_b_lrclk,
823b18819c4SJerome Brunet 	&aud_tdmin_c_lrclk,
824b18819c4SJerome Brunet 	&aud_tdmin_lb_lrclk,
825b18819c4SJerome Brunet 	&aud_tdmout_a_lrclk,
826b18819c4SJerome Brunet 	&aud_tdmout_b_lrclk,
827b18819c4SJerome Brunet 	&aud_tdmout_c_lrclk,
82807500138SMaxime Jourdan 	&aud_spdifout_b_clk_sel,
82907500138SMaxime Jourdan 	&aud_spdifout_b_clk_div,
83007500138SMaxime Jourdan 	&aud_spdifout_b_clk,
83107500138SMaxime Jourdan 	&aud_tdm_mclk_pad_0,
83207500138SMaxime Jourdan 	&aud_tdm_mclk_pad_1,
83307500138SMaxime Jourdan 	&aud_tdm_lrclk_pad_0,
83407500138SMaxime Jourdan 	&aud_tdm_lrclk_pad_1,
83507500138SMaxime Jourdan 	&aud_tdm_lrclk_pad_2,
83607500138SMaxime Jourdan 	&aud_tdm_sclk_pad_0,
83707500138SMaxime Jourdan 	&aud_tdm_sclk_pad_1,
83807500138SMaxime Jourdan 	&aud_tdm_sclk_pad_2,
8391cd50181SJerome Brunet };
8401cd50181SJerome Brunet 
841f03566d0SJerome Brunet static int devm_clk_get_enable(struct device *dev, char *id)
8421cd50181SJerome Brunet {
8431cd50181SJerome Brunet 	struct clk *clk;
8441cd50181SJerome Brunet 	int ret;
8451cd50181SJerome Brunet 
8461cd50181SJerome Brunet 	clk = devm_clk_get(dev, id);
8471cd50181SJerome Brunet 	if (IS_ERR(clk)) {
848f03566d0SJerome Brunet 		ret = PTR_ERR(clk);
849f03566d0SJerome Brunet 		if (ret != -EPROBE_DEFER)
8501cd50181SJerome Brunet 			dev_err(dev, "failed to get %s", id);
851f03566d0SJerome Brunet 		return ret;
8521cd50181SJerome Brunet 	}
8531cd50181SJerome Brunet 
8541cd50181SJerome Brunet 	ret = clk_prepare_enable(clk);
8551cd50181SJerome Brunet 	if (ret) {
8561cd50181SJerome Brunet 		dev_err(dev, "failed to enable %s", id);
857f03566d0SJerome Brunet 		return ret;
8581cd50181SJerome Brunet 	}
8591cd50181SJerome Brunet 
8601cd50181SJerome Brunet 	ret = devm_add_action_or_reset(dev,
8611cd50181SJerome Brunet 				       (void(*)(void *))clk_disable_unprepare,
8621cd50181SJerome Brunet 				       clk);
8631cd50181SJerome Brunet 	if (ret) {
8641cd50181SJerome Brunet 		dev_err(dev, "failed to add reset action on %s", id);
865f03566d0SJerome Brunet 		return ret;
8661cd50181SJerome Brunet 	}
8671cd50181SJerome Brunet 
868f03566d0SJerome Brunet 	return 0;
8691cd50181SJerome Brunet }
8701cd50181SJerome Brunet 
8711cd50181SJerome Brunet static int axg_register_clk_hw_input(struct device *dev,
8726d6d2a24SJerome Brunet 				     const char *name)
8731cd50181SJerome Brunet {
874f03566d0SJerome Brunet 	char *clk_name;
875f03566d0SJerome Brunet 	struct clk_hw *hw;
876f03566d0SJerome Brunet 	int err = 0;
8771cd50181SJerome Brunet 
878b18819c4SJerome Brunet 	clk_name = kasprintf(GFP_KERNEL, "aud_%s", name);
879f03566d0SJerome Brunet 	if (!clk_name)
880f03566d0SJerome Brunet 		return -ENOMEM;
8811cd50181SJerome Brunet 
882f03566d0SJerome Brunet 	hw = meson_clk_hw_register_input(dev, name, clk_name, 0);
883f03566d0SJerome Brunet 	if (IS_ERR(hw)) {
8841cd50181SJerome Brunet 		/* It is ok if an input clock is missing */
885f03566d0SJerome Brunet 		if (PTR_ERR(hw) == -ENOENT) {
8861cd50181SJerome Brunet 			dev_dbg(dev, "%s not provided", name);
8871cd50181SJerome Brunet 		} else {
888f03566d0SJerome Brunet 			err = PTR_ERR(hw);
8891cd50181SJerome Brunet 			if (err != -EPROBE_DEFER)
8901cd50181SJerome Brunet 				dev_err(dev, "failed to get %s clock", name);
8911cd50181SJerome Brunet 		}
892f03566d0SJerome Brunet 	}
893f03566d0SJerome Brunet 
894f03566d0SJerome Brunet 	kfree(clk_name);
895f03566d0SJerome Brunet 	return err;
8961cd50181SJerome Brunet }
8971cd50181SJerome Brunet 
8981cd50181SJerome Brunet static int axg_register_clk_hw_inputs(struct device *dev,
8991cd50181SJerome Brunet 				      const char *basename,
9006d6d2a24SJerome Brunet 				      unsigned int count)
9011cd50181SJerome Brunet {
9021cd50181SJerome Brunet 	char *name;
9031cd50181SJerome Brunet 	int i, ret;
9041cd50181SJerome Brunet 
9051cd50181SJerome Brunet 	for (i = 0; i < count; i++) {
9061cd50181SJerome Brunet 		name = kasprintf(GFP_KERNEL, "%s%d", basename, i);
9071cd50181SJerome Brunet 		if (!name)
9081cd50181SJerome Brunet 			return -ENOMEM;
9091cd50181SJerome Brunet 
9106d6d2a24SJerome Brunet 		ret = axg_register_clk_hw_input(dev, name);
9111cd50181SJerome Brunet 		kfree(name);
9121cd50181SJerome Brunet 		if (ret)
9131cd50181SJerome Brunet 			return ret;
9141cd50181SJerome Brunet 	}
9151cd50181SJerome Brunet 
9161cd50181SJerome Brunet 	return 0;
9171cd50181SJerome Brunet }
9181cd50181SJerome Brunet 
9191cd50181SJerome Brunet static const struct regmap_config axg_audio_regmap_cfg = {
9201cd50181SJerome Brunet 	.reg_bits	= 32,
9211cd50181SJerome Brunet 	.val_bits	= 32,
9221cd50181SJerome Brunet 	.reg_stride	= 4,
9231cd50181SJerome Brunet 	.max_register	= AUDIO_CLK_PDMIN_CTRL1,
9241cd50181SJerome Brunet };
9251cd50181SJerome Brunet 
92607500138SMaxime Jourdan struct audioclk_data {
92707500138SMaxime Jourdan 	struct clk_hw_onecell_data *hw_onecell_data;
92807500138SMaxime Jourdan };
92907500138SMaxime Jourdan 
9301cd50181SJerome Brunet static int axg_audio_clkc_probe(struct platform_device *pdev)
9311cd50181SJerome Brunet {
9321cd50181SJerome Brunet 	struct device *dev = &pdev->dev;
93307500138SMaxime Jourdan 	const struct audioclk_data *data;
9341cd50181SJerome Brunet 	struct regmap *map;
9351cd50181SJerome Brunet 	struct resource *res;
9361cd50181SJerome Brunet 	void __iomem *regs;
9371cd50181SJerome Brunet 	struct clk_hw *hw;
9381cd50181SJerome Brunet 	int ret, i;
9391cd50181SJerome Brunet 
94007500138SMaxime Jourdan 	data = of_device_get_match_data(dev);
94107500138SMaxime Jourdan 	if (!data)
94207500138SMaxime Jourdan 		return -EINVAL;
94307500138SMaxime Jourdan 
9441cd50181SJerome Brunet 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
9451cd50181SJerome Brunet 	regs = devm_ioremap_resource(dev, res);
9461cd50181SJerome Brunet 	if (IS_ERR(regs))
9471cd50181SJerome Brunet 		return PTR_ERR(regs);
9481cd50181SJerome Brunet 
9491cd50181SJerome Brunet 	map = devm_regmap_init_mmio(dev, regs, &axg_audio_regmap_cfg);
9501cd50181SJerome Brunet 	if (IS_ERR(map)) {
9511cd50181SJerome Brunet 		dev_err(dev, "failed to init regmap: %ld\n", PTR_ERR(map));
9521cd50181SJerome Brunet 		return PTR_ERR(map);
9531cd50181SJerome Brunet 	}
9541cd50181SJerome Brunet 
9551cd50181SJerome Brunet 	/* Get the mandatory peripheral clock */
956f03566d0SJerome Brunet 	ret = devm_clk_get_enable(dev, "pclk");
957f03566d0SJerome Brunet 	if (ret)
958f03566d0SJerome Brunet 		return ret;
9591cd50181SJerome Brunet 
9601cd50181SJerome Brunet 	ret = device_reset(dev);
9611cd50181SJerome Brunet 	if (ret) {
9621cd50181SJerome Brunet 		dev_err(dev, "failed to reset device\n");
9631cd50181SJerome Brunet 		return ret;
9641cd50181SJerome Brunet 	}
9651cd50181SJerome Brunet 
9661cd50181SJerome Brunet 	/* Register the peripheral input clock */
967b18819c4SJerome Brunet 	hw = meson_clk_hw_register_input(dev, "pclk", "audio_pclk", 0);
9681cd50181SJerome Brunet 	if (IS_ERR(hw))
9691cd50181SJerome Brunet 		return PTR_ERR(hw);
9701cd50181SJerome Brunet 
9711cd50181SJerome Brunet 	/* Register optional input master clocks */
9721cd50181SJerome Brunet 	ret = axg_register_clk_hw_inputs(dev, "mst_in",
9736d6d2a24SJerome Brunet 					 AUD_MST_IN_COUNT);
9741cd50181SJerome Brunet 	if (ret)
9751cd50181SJerome Brunet 		return ret;
9761cd50181SJerome Brunet 
9771cd50181SJerome Brunet 	/* Register optional input slave sclks */
9781cd50181SJerome Brunet 	ret = axg_register_clk_hw_inputs(dev, "slv_sclk",
9796d6d2a24SJerome Brunet 					 AUD_SLV_SCLK_COUNT);
9801cd50181SJerome Brunet 	if (ret)
9811cd50181SJerome Brunet 		return ret;
9821cd50181SJerome Brunet 
9831cd50181SJerome Brunet 	/* Register optional input slave lrclks */
9841cd50181SJerome Brunet 	ret = axg_register_clk_hw_inputs(dev, "slv_lrclk",
9856d6d2a24SJerome Brunet 					 AUD_SLV_LRCLK_COUNT);
9861cd50181SJerome Brunet 	if (ret)
9871cd50181SJerome Brunet 		return ret;
9881cd50181SJerome Brunet 
9891cd50181SJerome Brunet 	/* Populate regmap for the regmap backed clocks */
990b18819c4SJerome Brunet 	for (i = 0; i < ARRAY_SIZE(aud_clk_regmaps); i++)
991b18819c4SJerome Brunet 		aud_clk_regmaps[i]->map = map;
9921cd50181SJerome Brunet 
9931cd50181SJerome Brunet 	/* Take care to skip the registered input clocks */
99407500138SMaxime Jourdan 	for (i = AUD_CLKID_DDR_ARB; i < data->hw_onecell_data->num; i++) {
995*1610dd79SStephen Boyd 		const char *name;
996*1610dd79SStephen Boyd 
99707500138SMaxime Jourdan 		hw = data->hw_onecell_data->hws[i];
9981cd50181SJerome Brunet 		/* array might be sparse */
9991cd50181SJerome Brunet 		if (!hw)
10001cd50181SJerome Brunet 			continue;
10011cd50181SJerome Brunet 
1002*1610dd79SStephen Boyd 		name = hw->init->name;
1003*1610dd79SStephen Boyd 
10041cd50181SJerome Brunet 		ret = devm_clk_hw_register(dev, hw);
10051cd50181SJerome Brunet 		if (ret) {
1006*1610dd79SStephen Boyd 			dev_err(dev, "failed to register clock %s\n", name);
10071cd50181SJerome Brunet 			return ret;
10081cd50181SJerome Brunet 		}
10091cd50181SJerome Brunet 	}
10101cd50181SJerome Brunet 
10111cd50181SJerome Brunet 	return devm_of_clk_add_hw_provider(dev, of_clk_hw_onecell_get,
101207500138SMaxime Jourdan 					   data->hw_onecell_data);
10131cd50181SJerome Brunet }
10141cd50181SJerome Brunet 
101507500138SMaxime Jourdan static const struct audioclk_data axg_audioclk_data = {
101607500138SMaxime Jourdan 	.hw_onecell_data = &axg_audio_hw_onecell_data,
101707500138SMaxime Jourdan };
101807500138SMaxime Jourdan 
101907500138SMaxime Jourdan static const struct audioclk_data g12a_audioclk_data = {
102007500138SMaxime Jourdan 	.hw_onecell_data = &g12a_audio_hw_onecell_data,
102107500138SMaxime Jourdan };
102207500138SMaxime Jourdan 
10231cd50181SJerome Brunet static const struct of_device_id clkc_match_table[] = {
102407500138SMaxime Jourdan 	{
102507500138SMaxime Jourdan 		.compatible = "amlogic,axg-audio-clkc",
102607500138SMaxime Jourdan 		.data = &axg_audioclk_data
102707500138SMaxime Jourdan 	}, {
102807500138SMaxime Jourdan 		.compatible = "amlogic,g12a-audio-clkc",
102907500138SMaxime Jourdan 		.data = &g12a_audioclk_data
103007500138SMaxime Jourdan 	}, {}
10311cd50181SJerome Brunet };
10321cd50181SJerome Brunet MODULE_DEVICE_TABLE(of, clkc_match_table);
10331cd50181SJerome Brunet 
10341cd50181SJerome Brunet static struct platform_driver axg_audio_driver = {
10351cd50181SJerome Brunet 	.probe		= axg_audio_clkc_probe,
10361cd50181SJerome Brunet 	.driver		= {
10371cd50181SJerome Brunet 		.name	= "axg-audio-clkc",
10381cd50181SJerome Brunet 		.of_match_table = clkc_match_table,
10391cd50181SJerome Brunet 	},
10401cd50181SJerome Brunet };
10411cd50181SJerome Brunet module_platform_driver(axg_audio_driver);
10421cd50181SJerome Brunet 
104307500138SMaxime Jourdan MODULE_DESCRIPTION("Amlogic AXG/G12A Audio Clock driver");
10441cd50181SJerome Brunet MODULE_AUTHOR("Jerome Brunet <jbrunet@baylibre.com>");
10451cd50181SJerome Brunet MODULE_LICENSE("GPL v2");
1046