1*41b08610SInochi Amaoto // SPDX-License-Identifier: GPL-2.0
2*41b08610SInochi Amaoto /*
3*41b08610SInochi Amaoto * Sophgo SG2044 clock controller driver
4*41b08610SInochi Amaoto *
5*41b08610SInochi Amaoto * Copyright (C) 2025 Inochi Amaoto <inochiama@gmail.com>
6*41b08610SInochi Amaoto */
7*41b08610SInochi Amaoto
8*41b08610SInochi Amaoto #include <linux/array_size.h>
9*41b08610SInochi Amaoto #include <linux/bitfield.h>
10*41b08610SInochi Amaoto #include <linux/bits.h>
11*41b08610SInochi Amaoto #include <linux/cleanup.h>
12*41b08610SInochi Amaoto #include <linux/clk.h>
13*41b08610SInochi Amaoto #include <linux/clk-provider.h>
14*41b08610SInochi Amaoto #include <linux/io.h>
15*41b08610SInochi Amaoto #include <linux/iopoll.h>
16*41b08610SInochi Amaoto #include <linux/math64.h>
17*41b08610SInochi Amaoto #include <linux/mfd/syscon.h>
18*41b08610SInochi Amaoto #include <linux/platform_device.h>
19*41b08610SInochi Amaoto #include <linux/regmap.h>
20*41b08610SInochi Amaoto #include <linux/spinlock.h>
21*41b08610SInochi Amaoto
22*41b08610SInochi Amaoto #include <dt-bindings/clock/sophgo,sg2044-clk.h>
23*41b08610SInochi Amaoto
24*41b08610SInochi Amaoto #define DIV_ASSERT BIT(0)
25*41b08610SInochi Amaoto #define DIV_FACTOR_REG_SOURCE BIT(3)
26*41b08610SInochi Amaoto #define DIV_BRANCH_EN BIT(4)
27*41b08610SInochi Amaoto
28*41b08610SInochi Amaoto #define DIV_ASSERT_TIME 2
29*41b08610SInochi Amaoto
30*41b08610SInochi Amaoto struct sg2044_div_internal {
31*41b08610SInochi Amaoto u32 offset;
32*41b08610SInochi Amaoto u32 initval;
33*41b08610SInochi Amaoto u8 shift;
34*41b08610SInochi Amaoto u8 width;
35*41b08610SInochi Amaoto u16 flags;
36*41b08610SInochi Amaoto };
37*41b08610SInochi Amaoto
38*41b08610SInochi Amaoto struct sg2044_mux_internal {
39*41b08610SInochi Amaoto const u32 *table;
40*41b08610SInochi Amaoto u32 offset;
41*41b08610SInochi Amaoto u16 shift;
42*41b08610SInochi Amaoto u16 flags;
43*41b08610SInochi Amaoto };
44*41b08610SInochi Amaoto
45*41b08610SInochi Amaoto struct sg2044_gate_internal {
46*41b08610SInochi Amaoto u32 offset;
47*41b08610SInochi Amaoto u16 shift;
48*41b08610SInochi Amaoto u16 flags;
49*41b08610SInochi Amaoto };
50*41b08610SInochi Amaoto
51*41b08610SInochi Amaoto struct sg2044_clk_common {
52*41b08610SInochi Amaoto struct clk_hw hw;
53*41b08610SInochi Amaoto void __iomem *base;
54*41b08610SInochi Amaoto spinlock_t *lock;
55*41b08610SInochi Amaoto unsigned int id;
56*41b08610SInochi Amaoto };
57*41b08610SInochi Amaoto
58*41b08610SInochi Amaoto struct sg2044_div {
59*41b08610SInochi Amaoto struct sg2044_clk_common common;
60*41b08610SInochi Amaoto struct sg2044_div_internal div;
61*41b08610SInochi Amaoto };
62*41b08610SInochi Amaoto
63*41b08610SInochi Amaoto struct sg2044_mux {
64*41b08610SInochi Amaoto struct sg2044_clk_common common;
65*41b08610SInochi Amaoto struct sg2044_mux_internal mux;
66*41b08610SInochi Amaoto struct notifier_block nb;
67*41b08610SInochi Amaoto u8 saved_parent;
68*41b08610SInochi Amaoto };
69*41b08610SInochi Amaoto
70*41b08610SInochi Amaoto struct sg2044_gate {
71*41b08610SInochi Amaoto struct sg2044_clk_common common;
72*41b08610SInochi Amaoto struct sg2044_gate_internal gate;
73*41b08610SInochi Amaoto };
74*41b08610SInochi Amaoto
75*41b08610SInochi Amaoto struct sg2044_clk_ctrl {
76*41b08610SInochi Amaoto spinlock_t lock;
77*41b08610SInochi Amaoto struct clk_hw_onecell_data data;
78*41b08610SInochi Amaoto };
79*41b08610SInochi Amaoto
80*41b08610SInochi Amaoto struct sg2044_clk_desc_data {
81*41b08610SInochi Amaoto struct sg2044_clk_common * const *pll;
82*41b08610SInochi Amaoto struct sg2044_clk_common * const *div;
83*41b08610SInochi Amaoto struct sg2044_clk_common * const *mux;
84*41b08610SInochi Amaoto struct sg2044_clk_common * const *gate;
85*41b08610SInochi Amaoto u16 num_pll;
86*41b08610SInochi Amaoto u16 num_div;
87*41b08610SInochi Amaoto u16 num_mux;
88*41b08610SInochi Amaoto u16 num_gate;
89*41b08610SInochi Amaoto };
90*41b08610SInochi Amaoto
91*41b08610SInochi Amaoto #define hw_to_sg2044_clk_common(_hw) \
92*41b08610SInochi Amaoto container_of((_hw), struct sg2044_clk_common, hw)
93*41b08610SInochi Amaoto
hw_to_sg2044_div(struct clk_hw * hw)94*41b08610SInochi Amaoto static inline struct sg2044_div *hw_to_sg2044_div(struct clk_hw *hw)
95*41b08610SInochi Amaoto {
96*41b08610SInochi Amaoto return container_of(hw_to_sg2044_clk_common(hw),
97*41b08610SInochi Amaoto struct sg2044_div, common);
98*41b08610SInochi Amaoto }
99*41b08610SInochi Amaoto
sg2044_div_get_reg_div(u32 reg,struct sg2044_div_internal * div)100*41b08610SInochi Amaoto static u32 sg2044_div_get_reg_div(u32 reg, struct sg2044_div_internal *div)
101*41b08610SInochi Amaoto {
102*41b08610SInochi Amaoto if ((reg & DIV_FACTOR_REG_SOURCE))
103*41b08610SInochi Amaoto return (reg >> div->shift) & clk_div_mask(div->width);
104*41b08610SInochi Amaoto
105*41b08610SInochi Amaoto return div->initval == 0 ? 1 : div->initval;
106*41b08610SInochi Amaoto }
107*41b08610SInochi Amaoto
_sg2044_div_recalc_rate(struct sg2044_clk_common * common,struct sg2044_div_internal * div,unsigned long parent_rate)108*41b08610SInochi Amaoto static unsigned long _sg2044_div_recalc_rate(struct sg2044_clk_common *common,
109*41b08610SInochi Amaoto struct sg2044_div_internal *div,
110*41b08610SInochi Amaoto unsigned long parent_rate)
111*41b08610SInochi Amaoto {
112*41b08610SInochi Amaoto u32 reg = readl(common->base + div->offset);
113*41b08610SInochi Amaoto u32 val = sg2044_div_get_reg_div(reg, div);
114*41b08610SInochi Amaoto
115*41b08610SInochi Amaoto return divider_recalc_rate(&common->hw, parent_rate, val, NULL,
116*41b08610SInochi Amaoto div->flags, div->width);
117*41b08610SInochi Amaoto }
118*41b08610SInochi Amaoto
sg2044_div_recalc_rate(struct clk_hw * hw,unsigned long parent_rate)119*41b08610SInochi Amaoto static unsigned long sg2044_div_recalc_rate(struct clk_hw *hw,
120*41b08610SInochi Amaoto unsigned long parent_rate)
121*41b08610SInochi Amaoto {
122*41b08610SInochi Amaoto struct sg2044_div *div = hw_to_sg2044_div(hw);
123*41b08610SInochi Amaoto
124*41b08610SInochi Amaoto return _sg2044_div_recalc_rate(&div->common, &div->div,
125*41b08610SInochi Amaoto parent_rate);
126*41b08610SInochi Amaoto }
127*41b08610SInochi Amaoto
_sg2044_div_determine_rate(struct sg2044_clk_common * common,struct sg2044_div_internal * div,struct clk_rate_request * req)128*41b08610SInochi Amaoto static int _sg2044_div_determine_rate(struct sg2044_clk_common *common,
129*41b08610SInochi Amaoto struct sg2044_div_internal *div,
130*41b08610SInochi Amaoto struct clk_rate_request *req)
131*41b08610SInochi Amaoto {
132*41b08610SInochi Amaoto if (div->flags & CLK_DIVIDER_READ_ONLY) {
133*41b08610SInochi Amaoto u32 reg = readl(common->base + div->offset);
134*41b08610SInochi Amaoto u32 val = sg2044_div_get_reg_div(reg, div);
135*41b08610SInochi Amaoto
136*41b08610SInochi Amaoto return divider_ro_determine_rate(&common->hw, req, NULL,
137*41b08610SInochi Amaoto div->width, div->flags,
138*41b08610SInochi Amaoto val);
139*41b08610SInochi Amaoto }
140*41b08610SInochi Amaoto
141*41b08610SInochi Amaoto return divider_determine_rate(&common->hw, req, NULL,
142*41b08610SInochi Amaoto div->width, div->flags);
143*41b08610SInochi Amaoto }
144*41b08610SInochi Amaoto
sg2044_div_determine_rate(struct clk_hw * hw,struct clk_rate_request * req)145*41b08610SInochi Amaoto static int sg2044_div_determine_rate(struct clk_hw *hw,
146*41b08610SInochi Amaoto struct clk_rate_request *req)
147*41b08610SInochi Amaoto {
148*41b08610SInochi Amaoto struct sg2044_div *div = hw_to_sg2044_div(hw);
149*41b08610SInochi Amaoto
150*41b08610SInochi Amaoto return _sg2044_div_determine_rate(&div->common, &div->div, req);
151*41b08610SInochi Amaoto }
152*41b08610SInochi Amaoto
sg2044_div_set_reg_div(struct sg2044_clk_common * common,struct sg2044_div_internal * div,u32 value)153*41b08610SInochi Amaoto static void sg2044_div_set_reg_div(struct sg2044_clk_common *common,
154*41b08610SInochi Amaoto struct sg2044_div_internal *div,
155*41b08610SInochi Amaoto u32 value)
156*41b08610SInochi Amaoto {
157*41b08610SInochi Amaoto void __iomem *addr = common->base + div->offset;
158*41b08610SInochi Amaoto u32 reg;
159*41b08610SInochi Amaoto
160*41b08610SInochi Amaoto reg = readl(addr);
161*41b08610SInochi Amaoto
162*41b08610SInochi Amaoto /* assert */
163*41b08610SInochi Amaoto reg &= ~DIV_ASSERT;
164*41b08610SInochi Amaoto writel(reg, addr);
165*41b08610SInochi Amaoto
166*41b08610SInochi Amaoto /* set value */
167*41b08610SInochi Amaoto reg = readl(addr);
168*41b08610SInochi Amaoto reg &= ~(clk_div_mask(div->width) << div->shift);
169*41b08610SInochi Amaoto reg |= (value << div->shift) | DIV_FACTOR_REG_SOURCE;
170*41b08610SInochi Amaoto writel(reg, addr);
171*41b08610SInochi Amaoto
172*41b08610SInochi Amaoto /* de-assert */
173*41b08610SInochi Amaoto reg |= DIV_ASSERT;
174*41b08610SInochi Amaoto writel(reg, addr);
175*41b08610SInochi Amaoto }
176*41b08610SInochi Amaoto
sg2044_div_set_rate(struct clk_hw * hw,unsigned long rate,unsigned long parent_rate)177*41b08610SInochi Amaoto static int sg2044_div_set_rate(struct clk_hw *hw,
178*41b08610SInochi Amaoto unsigned long rate, unsigned long parent_rate)
179*41b08610SInochi Amaoto {
180*41b08610SInochi Amaoto struct sg2044_div *div = hw_to_sg2044_div(hw);
181*41b08610SInochi Amaoto u32 value;
182*41b08610SInochi Amaoto
183*41b08610SInochi Amaoto value = divider_get_val(rate, parent_rate, NULL,
184*41b08610SInochi Amaoto div->div.width, div->div.flags);
185*41b08610SInochi Amaoto
186*41b08610SInochi Amaoto guard(spinlock_irqsave)(div->common.lock);
187*41b08610SInochi Amaoto
188*41b08610SInochi Amaoto sg2044_div_set_reg_div(&div->common, &div->div, value);
189*41b08610SInochi Amaoto
190*41b08610SInochi Amaoto return 0;
191*41b08610SInochi Amaoto }
192*41b08610SInochi Amaoto
sg2044_div_enable(struct clk_hw * hw)193*41b08610SInochi Amaoto static int sg2044_div_enable(struct clk_hw *hw)
194*41b08610SInochi Amaoto {
195*41b08610SInochi Amaoto struct sg2044_div *div = hw_to_sg2044_div(hw);
196*41b08610SInochi Amaoto void __iomem *addr = div->common.base + div->div.offset;
197*41b08610SInochi Amaoto u32 value;
198*41b08610SInochi Amaoto
199*41b08610SInochi Amaoto guard(spinlock_irqsave)(div->common.lock);
200*41b08610SInochi Amaoto
201*41b08610SInochi Amaoto value = readl(addr);
202*41b08610SInochi Amaoto value |= DIV_BRANCH_EN;
203*41b08610SInochi Amaoto writel(value, addr);
204*41b08610SInochi Amaoto
205*41b08610SInochi Amaoto return 0;
206*41b08610SInochi Amaoto }
207*41b08610SInochi Amaoto
sg2044_div_disable(struct clk_hw * hw)208*41b08610SInochi Amaoto static void sg2044_div_disable(struct clk_hw *hw)
209*41b08610SInochi Amaoto {
210*41b08610SInochi Amaoto struct sg2044_div *div = hw_to_sg2044_div(hw);
211*41b08610SInochi Amaoto void __iomem *addr = div->common.base + div->div.offset;
212*41b08610SInochi Amaoto u32 value;
213*41b08610SInochi Amaoto
214*41b08610SInochi Amaoto guard(spinlock_irqsave)(div->common.lock);
215*41b08610SInochi Amaoto
216*41b08610SInochi Amaoto value = readl(addr);
217*41b08610SInochi Amaoto value &= ~DIV_BRANCH_EN;
218*41b08610SInochi Amaoto writel(value, addr);
219*41b08610SInochi Amaoto }
220*41b08610SInochi Amaoto
sg2044_div_is_enabled(struct clk_hw * hw)221*41b08610SInochi Amaoto static int sg2044_div_is_enabled(struct clk_hw *hw)
222*41b08610SInochi Amaoto {
223*41b08610SInochi Amaoto struct sg2044_div *div = hw_to_sg2044_div(hw);
224*41b08610SInochi Amaoto
225*41b08610SInochi Amaoto return readl(div->common.base + div->div.offset) & DIV_BRANCH_EN;
226*41b08610SInochi Amaoto }
227*41b08610SInochi Amaoto
228*41b08610SInochi Amaoto static const struct clk_ops sg2044_gateable_div_ops = {
229*41b08610SInochi Amaoto .enable = sg2044_div_enable,
230*41b08610SInochi Amaoto .disable = sg2044_div_disable,
231*41b08610SInochi Amaoto .is_enabled = sg2044_div_is_enabled,
232*41b08610SInochi Amaoto .recalc_rate = sg2044_div_recalc_rate,
233*41b08610SInochi Amaoto .determine_rate = sg2044_div_determine_rate,
234*41b08610SInochi Amaoto .set_rate = sg2044_div_set_rate,
235*41b08610SInochi Amaoto };
236*41b08610SInochi Amaoto
237*41b08610SInochi Amaoto static const struct clk_ops sg2044_div_ops = {
238*41b08610SInochi Amaoto .recalc_rate = sg2044_div_recalc_rate,
239*41b08610SInochi Amaoto .determine_rate = sg2044_div_determine_rate,
240*41b08610SInochi Amaoto .set_rate = sg2044_div_set_rate,
241*41b08610SInochi Amaoto };
242*41b08610SInochi Amaoto
243*41b08610SInochi Amaoto static const struct clk_ops sg2044_div_ro_ops = {
244*41b08610SInochi Amaoto .recalc_rate = sg2044_div_recalc_rate,
245*41b08610SInochi Amaoto .determine_rate = sg2044_div_determine_rate,
246*41b08610SInochi Amaoto };
247*41b08610SInochi Amaoto
hw_to_sg2044_mux(struct clk_hw * hw)248*41b08610SInochi Amaoto static inline struct sg2044_mux *hw_to_sg2044_mux(struct clk_hw *hw)
249*41b08610SInochi Amaoto {
250*41b08610SInochi Amaoto return container_of(hw_to_sg2044_clk_common(hw),
251*41b08610SInochi Amaoto struct sg2044_mux, common);
252*41b08610SInochi Amaoto }
253*41b08610SInochi Amaoto
nb_to_sg2044_mux(struct notifier_block * nb)254*41b08610SInochi Amaoto static inline struct sg2044_mux *nb_to_sg2044_mux(struct notifier_block *nb)
255*41b08610SInochi Amaoto {
256*41b08610SInochi Amaoto return container_of(nb, struct sg2044_mux, nb);
257*41b08610SInochi Amaoto }
258*41b08610SInochi Amaoto
259*41b08610SInochi Amaoto static const u32 sg2044_mux_table[] = {0, 1};
260*41b08610SInochi Amaoto
sg2044_mux_notifier_cb(struct notifier_block * nb,unsigned long event,void * data)261*41b08610SInochi Amaoto static int sg2044_mux_notifier_cb(struct notifier_block *nb,
262*41b08610SInochi Amaoto unsigned long event,
263*41b08610SInochi Amaoto void *data)
264*41b08610SInochi Amaoto {
265*41b08610SInochi Amaoto struct sg2044_mux *mux = nb_to_sg2044_mux(nb);
266*41b08610SInochi Amaoto const struct clk_ops *ops = &clk_mux_ops;
267*41b08610SInochi Amaoto struct clk_notifier_data *ndata = data;
268*41b08610SInochi Amaoto struct clk_hw *hw = __clk_get_hw(ndata->clk);
269*41b08610SInochi Amaoto int ret = 0;
270*41b08610SInochi Amaoto
271*41b08610SInochi Amaoto if (event == PRE_RATE_CHANGE) {
272*41b08610SInochi Amaoto mux->saved_parent = ops->get_parent(hw);
273*41b08610SInochi Amaoto if (mux->saved_parent)
274*41b08610SInochi Amaoto ret = ops->set_parent(hw, 0);
275*41b08610SInochi Amaoto } else if (event == POST_RATE_CHANGE) {
276*41b08610SInochi Amaoto ret = ops->set_parent(hw, mux->saved_parent);
277*41b08610SInochi Amaoto }
278*41b08610SInochi Amaoto
279*41b08610SInochi Amaoto return notifier_from_errno(ret);
280*41b08610SInochi Amaoto }
281*41b08610SInochi Amaoto
hw_to_sg2044_gate(struct clk_hw * hw)282*41b08610SInochi Amaoto static inline struct sg2044_gate *hw_to_sg2044_gate(struct clk_hw *hw)
283*41b08610SInochi Amaoto {
284*41b08610SInochi Amaoto return container_of(hw_to_sg2044_clk_common(hw),
285*41b08610SInochi Amaoto struct sg2044_gate, common);
286*41b08610SInochi Amaoto }
287*41b08610SInochi Amaoto
288*41b08610SInochi Amaoto #define SG2044_CLK_COMMON_PDATA(_id, _name, _parents, _op, _flags) \
289*41b08610SInochi Amaoto { \
290*41b08610SInochi Amaoto .hw.init = CLK_HW_INIT_PARENTS_DATA(_name, _parents, \
291*41b08610SInochi Amaoto _op, (_flags)), \
292*41b08610SInochi Amaoto .id = (_id), \
293*41b08610SInochi Amaoto }
294*41b08610SInochi Amaoto
295*41b08610SInochi Amaoto #define SG2044_CLK_COMMON_PHWS(_id, _name, _parents, _op, _flags) \
296*41b08610SInochi Amaoto { \
297*41b08610SInochi Amaoto .hw.init = CLK_HW_INIT_PARENTS_HW(_name, _parents, \
298*41b08610SInochi Amaoto _op, (_flags)), \
299*41b08610SInochi Amaoto .id = (_id), \
300*41b08610SInochi Amaoto }
301*41b08610SInochi Amaoto
302*41b08610SInochi Amaoto #define DEFINE_SG2044_GATEABLE_DIV(_id, _name, _parent, _flags, \
303*41b08610SInochi Amaoto _div_offset, _div_shift, _div_width, \
304*41b08610SInochi Amaoto _div_flags, _div_initval) \
305*41b08610SInochi Amaoto struct sg2044_div _name = { \
306*41b08610SInochi Amaoto .common = SG2044_CLK_COMMON_PDATA(_id, #_name, _parent, \
307*41b08610SInochi Amaoto &sg2044_gateable_div_ops,\
308*41b08610SInochi Amaoto (_flags)), \
309*41b08610SInochi Amaoto .div = { \
310*41b08610SInochi Amaoto .offset = (_div_offset), \
311*41b08610SInochi Amaoto .initval = (_div_initval), \
312*41b08610SInochi Amaoto .shift = (_div_shift), \
313*41b08610SInochi Amaoto .width = (_div_width), \
314*41b08610SInochi Amaoto .flags = (_div_flags), \
315*41b08610SInochi Amaoto }, \
316*41b08610SInochi Amaoto }
317*41b08610SInochi Amaoto
318*41b08610SInochi Amaoto #define DEFINE_SG2044_DIV(_id, _name, _parent, _flags, \
319*41b08610SInochi Amaoto _div_offset, _div_shift, _div_width, \
320*41b08610SInochi Amaoto _div_flags, _div_initval) \
321*41b08610SInochi Amaoto struct sg2044_div _name = { \
322*41b08610SInochi Amaoto .common = SG2044_CLK_COMMON_PHWS(_id, #_name, _parent, \
323*41b08610SInochi Amaoto &sg2044_div_ops, \
324*41b08610SInochi Amaoto (_flags)), \
325*41b08610SInochi Amaoto .div = { \
326*41b08610SInochi Amaoto .offset = (_div_offset), \
327*41b08610SInochi Amaoto .initval = (_div_initval), \
328*41b08610SInochi Amaoto .shift = (_div_shift), \
329*41b08610SInochi Amaoto .width = (_div_width), \
330*41b08610SInochi Amaoto .flags = (_div_flags), \
331*41b08610SInochi Amaoto }, \
332*41b08610SInochi Amaoto }
333*41b08610SInochi Amaoto
334*41b08610SInochi Amaoto #define DEFINE_SG2044_DIV_PDATA(_id, _name, _parent, _flags, \
335*41b08610SInochi Amaoto _div_offset, _div_shift, _div_width, \
336*41b08610SInochi Amaoto _div_flags, _div_initval) \
337*41b08610SInochi Amaoto struct sg2044_div _name = { \
338*41b08610SInochi Amaoto .common = SG2044_CLK_COMMON_PDATA(_id, #_name, _parent, \
339*41b08610SInochi Amaoto &sg2044_div_ops, \
340*41b08610SInochi Amaoto (_flags)), \
341*41b08610SInochi Amaoto .div = { \
342*41b08610SInochi Amaoto .offset = (_div_offset), \
343*41b08610SInochi Amaoto .initval = (_div_initval), \
344*41b08610SInochi Amaoto .shift = (_div_shift), \
345*41b08610SInochi Amaoto .width = (_div_width), \
346*41b08610SInochi Amaoto .flags = (_div_flags), \
347*41b08610SInochi Amaoto }, \
348*41b08610SInochi Amaoto }
349*41b08610SInochi Amaoto
350*41b08610SInochi Amaoto #define DEFINE_SG2044_DIV_RO(_id, _name, _parent, _flags, \
351*41b08610SInochi Amaoto _div_offset, _div_shift, _div_width, \
352*41b08610SInochi Amaoto _div_flags, _div_initval) \
353*41b08610SInochi Amaoto struct sg2044_div _name = { \
354*41b08610SInochi Amaoto .common = SG2044_CLK_COMMON_PDATA(_id, #_name, _parent, \
355*41b08610SInochi Amaoto &sg2044_div_ro_ops, \
356*41b08610SInochi Amaoto (_flags)), \
357*41b08610SInochi Amaoto .div = { \
358*41b08610SInochi Amaoto .offset = (_div_offset), \
359*41b08610SInochi Amaoto .initval = (_div_initval), \
360*41b08610SInochi Amaoto .shift = (_div_shift), \
361*41b08610SInochi Amaoto .width = (_div_width), \
362*41b08610SInochi Amaoto .flags = (_div_flags) | CLK_DIVIDER_READ_ONLY,\
363*41b08610SInochi Amaoto }, \
364*41b08610SInochi Amaoto }
365*41b08610SInochi Amaoto
366*41b08610SInochi Amaoto #define DEFINE_SG2044_MUX(_id, _name, _parent, _flags, \
367*41b08610SInochi Amaoto _mux_offset, _mux_shift, \
368*41b08610SInochi Amaoto _mux_table, _mux_flags) \
369*41b08610SInochi Amaoto struct sg2044_mux _name = { \
370*41b08610SInochi Amaoto .common = SG2044_CLK_COMMON_PDATA(_id, #_name, _parent, \
371*41b08610SInochi Amaoto &clk_mux_ops, (_flags)),\
372*41b08610SInochi Amaoto .mux = { \
373*41b08610SInochi Amaoto .table = (_mux_table), \
374*41b08610SInochi Amaoto .offset = (_mux_offset), \
375*41b08610SInochi Amaoto .shift = (_mux_shift), \
376*41b08610SInochi Amaoto .flags = (_mux_flags), \
377*41b08610SInochi Amaoto }, \
378*41b08610SInochi Amaoto }
379*41b08610SInochi Amaoto
380*41b08610SInochi Amaoto #define DEFINE_SG2044_GATE(_id, _name, _parent, _flags, \
381*41b08610SInochi Amaoto _gate_offset, _gate_shift, _gate_flags) \
382*41b08610SInochi Amaoto struct sg2044_gate _name = { \
383*41b08610SInochi Amaoto .common = SG2044_CLK_COMMON_PHWS(_id, #_name, _parent, \
384*41b08610SInochi Amaoto &clk_gate_ops, (_flags)),\
385*41b08610SInochi Amaoto .gate = { \
386*41b08610SInochi Amaoto .offset = (_gate_offset), \
387*41b08610SInochi Amaoto .shift = (_gate_shift), \
388*41b08610SInochi Amaoto .flags = (_gate_flags), \
389*41b08610SInochi Amaoto }, \
390*41b08610SInochi Amaoto }
391*41b08610SInochi Amaoto
392*41b08610SInochi Amaoto static const struct clk_parent_data clk_fpll0_parent[] = {
393*41b08610SInochi Amaoto { .fw_name = "fpll0" },
394*41b08610SInochi Amaoto };
395*41b08610SInochi Amaoto
396*41b08610SInochi Amaoto static const struct clk_parent_data clk_fpll1_parent[] = {
397*41b08610SInochi Amaoto { .fw_name = "fpll1" },
398*41b08610SInochi Amaoto };
399*41b08610SInochi Amaoto
400*41b08610SInochi Amaoto static const struct clk_parent_data clk_fpll2_parent[] = {
401*41b08610SInochi Amaoto { .fw_name = "fpll2" },
402*41b08610SInochi Amaoto };
403*41b08610SInochi Amaoto
404*41b08610SInochi Amaoto static const struct clk_parent_data clk_dpll0_parent[] = {
405*41b08610SInochi Amaoto { .fw_name = "dpll0" },
406*41b08610SInochi Amaoto };
407*41b08610SInochi Amaoto
408*41b08610SInochi Amaoto static const struct clk_parent_data clk_dpll1_parent[] = {
409*41b08610SInochi Amaoto { .fw_name = "dpll1" },
410*41b08610SInochi Amaoto };
411*41b08610SInochi Amaoto
412*41b08610SInochi Amaoto static const struct clk_parent_data clk_dpll2_parent[] = {
413*41b08610SInochi Amaoto { .fw_name = "dpll2" },
414*41b08610SInochi Amaoto };
415*41b08610SInochi Amaoto
416*41b08610SInochi Amaoto static const struct clk_parent_data clk_dpll3_parent[] = {
417*41b08610SInochi Amaoto { .fw_name = "dpll3" },
418*41b08610SInochi Amaoto };
419*41b08610SInochi Amaoto
420*41b08610SInochi Amaoto static const struct clk_parent_data clk_dpll4_parent[] = {
421*41b08610SInochi Amaoto { .fw_name = "dpll4" },
422*41b08610SInochi Amaoto };
423*41b08610SInochi Amaoto
424*41b08610SInochi Amaoto static const struct clk_parent_data clk_dpll5_parent[] = {
425*41b08610SInochi Amaoto { .fw_name = "dpll5" },
426*41b08610SInochi Amaoto };
427*41b08610SInochi Amaoto
428*41b08610SInochi Amaoto static const struct clk_parent_data clk_dpll6_parent[] = {
429*41b08610SInochi Amaoto { .fw_name = "dpll6" },
430*41b08610SInochi Amaoto };
431*41b08610SInochi Amaoto
432*41b08610SInochi Amaoto static const struct clk_parent_data clk_dpll7_parent[] = {
433*41b08610SInochi Amaoto { .fw_name = "dpll7" },
434*41b08610SInochi Amaoto };
435*41b08610SInochi Amaoto
436*41b08610SInochi Amaoto static const struct clk_parent_data clk_mpll0_parent[] = {
437*41b08610SInochi Amaoto { .fw_name = "mpll0" },
438*41b08610SInochi Amaoto };
439*41b08610SInochi Amaoto
440*41b08610SInochi Amaoto static const struct clk_parent_data clk_mpll1_parent[] = {
441*41b08610SInochi Amaoto { .fw_name = "mpll1" },
442*41b08610SInochi Amaoto };
443*41b08610SInochi Amaoto
444*41b08610SInochi Amaoto static const struct clk_parent_data clk_mpll2_parent[] = {
445*41b08610SInochi Amaoto { .fw_name = "mpll2" },
446*41b08610SInochi Amaoto };
447*41b08610SInochi Amaoto
448*41b08610SInochi Amaoto static const struct clk_parent_data clk_mpll3_parent[] = {
449*41b08610SInochi Amaoto { .fw_name = "mpll3" },
450*41b08610SInochi Amaoto };
451*41b08610SInochi Amaoto
452*41b08610SInochi Amaoto static const struct clk_parent_data clk_mpll4_parent[] = {
453*41b08610SInochi Amaoto { .fw_name = "mpll4" },
454*41b08610SInochi Amaoto };
455*41b08610SInochi Amaoto
456*41b08610SInochi Amaoto static const struct clk_parent_data clk_mpll5_parent[] = {
457*41b08610SInochi Amaoto { .fw_name = "mpll5" },
458*41b08610SInochi Amaoto };
459*41b08610SInochi Amaoto
460*41b08610SInochi Amaoto static DEFINE_SG2044_GATEABLE_DIV(CLK_DIV_AP_SYS_FIXED, clk_div_ap_sys_fixed,
461*41b08610SInochi Amaoto clk_fpll0_parent, 0,
462*41b08610SInochi Amaoto 0x044, 16, 8,
463*41b08610SInochi Amaoto CLK_DIVIDER_ONE_BASED | CLK_DIVIDER_ALLOW_ZERO |
464*41b08610SInochi Amaoto CLK_IS_CRITICAL,
465*41b08610SInochi Amaoto 1);
466*41b08610SInochi Amaoto
467*41b08610SInochi Amaoto static DEFINE_SG2044_GATEABLE_DIV(CLK_DIV_AP_SYS_MAIN, clk_div_ap_sys_main,
468*41b08610SInochi Amaoto clk_mpll0_parent, 0,
469*41b08610SInochi Amaoto 0x040, 16, 8,
470*41b08610SInochi Amaoto CLK_DIVIDER_ONE_BASED | CLK_DIVIDER_ALLOW_ZERO |
471*41b08610SInochi Amaoto CLK_IS_CRITICAL,
472*41b08610SInochi Amaoto 1);
473*41b08610SInochi Amaoto
474*41b08610SInochi Amaoto static DEFINE_SG2044_GATEABLE_DIV(CLK_DIV_RP_SYS_FIXED, clk_div_rp_sys_fixed,
475*41b08610SInochi Amaoto clk_fpll0_parent, 0,
476*41b08610SInochi Amaoto 0x050, 16, 8,
477*41b08610SInochi Amaoto CLK_DIVIDER_ONE_BASED | CLK_DIVIDER_ALLOW_ZERO |
478*41b08610SInochi Amaoto CLK_IS_CRITICAL,
479*41b08610SInochi Amaoto 1);
480*41b08610SInochi Amaoto
481*41b08610SInochi Amaoto static DEFINE_SG2044_GATEABLE_DIV(CLK_DIV_RP_SYS_MAIN, clk_div_rp_sys_main,
482*41b08610SInochi Amaoto clk_mpll1_parent, 0,
483*41b08610SInochi Amaoto 0x04c, 16, 8,
484*41b08610SInochi Amaoto CLK_DIVIDER_ONE_BASED | CLK_DIVIDER_ALLOW_ZERO |
485*41b08610SInochi Amaoto CLK_IS_CRITICAL,
486*41b08610SInochi Amaoto 1);
487*41b08610SInochi Amaoto
488*41b08610SInochi Amaoto static DEFINE_SG2044_GATEABLE_DIV(CLK_DIV_TPU_SYS_FIXED, clk_div_tpu_sys_fixed,
489*41b08610SInochi Amaoto clk_fpll0_parent, 0,
490*41b08610SInochi Amaoto 0x058, 16, 8,
491*41b08610SInochi Amaoto CLK_DIVIDER_ONE_BASED | CLK_DIVIDER_ALLOW_ZERO |
492*41b08610SInochi Amaoto CLK_IS_CRITICAL,
493*41b08610SInochi Amaoto 2);
494*41b08610SInochi Amaoto
495*41b08610SInochi Amaoto static DEFINE_SG2044_GATEABLE_DIV(CLK_DIV_TPU_SYS_MAIN, clk_div_tpu_sys_main,
496*41b08610SInochi Amaoto clk_mpll2_parent, 0,
497*41b08610SInochi Amaoto 0x054, 16, 8,
498*41b08610SInochi Amaoto CLK_DIVIDER_ONE_BASED | CLK_DIVIDER_ALLOW_ZERO |
499*41b08610SInochi Amaoto CLK_IS_CRITICAL,
500*41b08610SInochi Amaoto 1);
501*41b08610SInochi Amaoto
502*41b08610SInochi Amaoto static DEFINE_SG2044_GATEABLE_DIV(CLK_DIV_NOC_SYS_FIXED, clk_div_noc_sys_fixed,
503*41b08610SInochi Amaoto clk_fpll0_parent, 0,
504*41b08610SInochi Amaoto 0x070, 16, 8,
505*41b08610SInochi Amaoto CLK_DIVIDER_ONE_BASED | CLK_DIVIDER_ALLOW_ZERO |
506*41b08610SInochi Amaoto CLK_IS_CRITICAL,
507*41b08610SInochi Amaoto 1);
508*41b08610SInochi Amaoto
509*41b08610SInochi Amaoto static DEFINE_SG2044_GATEABLE_DIV(CLK_DIV_NOC_SYS_MAIN, clk_div_noc_sys_main,
510*41b08610SInochi Amaoto clk_mpll3_parent, 0,
511*41b08610SInochi Amaoto 0x06c, 16, 8,
512*41b08610SInochi Amaoto CLK_DIVIDER_ONE_BASED | CLK_DIVIDER_ALLOW_ZERO |
513*41b08610SInochi Amaoto CLK_IS_CRITICAL,
514*41b08610SInochi Amaoto 1);
515*41b08610SInochi Amaoto
516*41b08610SInochi Amaoto static DEFINE_SG2044_GATEABLE_DIV(CLK_DIV_VC_SRC0_FIXED, clk_div_vc_src0_fixed,
517*41b08610SInochi Amaoto clk_fpll0_parent, 0,
518*41b08610SInochi Amaoto 0x078, 16, 8,
519*41b08610SInochi Amaoto CLK_DIVIDER_ONE_BASED | CLK_DIVIDER_ALLOW_ZERO |
520*41b08610SInochi Amaoto CLK_IS_CRITICAL,
521*41b08610SInochi Amaoto 2);
522*41b08610SInochi Amaoto
523*41b08610SInochi Amaoto static DEFINE_SG2044_GATEABLE_DIV(CLK_DIV_VC_SRC0_MAIN, clk_div_vc_src0_main,
524*41b08610SInochi Amaoto clk_mpll4_parent, 0,
525*41b08610SInochi Amaoto 0x074, 16, 8,
526*41b08610SInochi Amaoto CLK_DIVIDER_ONE_BASED | CLK_DIVIDER_ALLOW_ZERO |
527*41b08610SInochi Amaoto CLK_IS_CRITICAL,
528*41b08610SInochi Amaoto 1);
529*41b08610SInochi Amaoto
530*41b08610SInochi Amaoto static DEFINE_SG2044_GATEABLE_DIV(CLK_DIV_VC_SRC1_FIXED, clk_div_vc_src1_fixed,
531*41b08610SInochi Amaoto clk_fpll0_parent, 0,
532*41b08610SInochi Amaoto 0x080, 16, 8,
533*41b08610SInochi Amaoto CLK_DIVIDER_ONE_BASED | CLK_DIVIDER_ALLOW_ZERO |
534*41b08610SInochi Amaoto CLK_IS_CRITICAL,
535*41b08610SInochi Amaoto 3);
536*41b08610SInochi Amaoto
537*41b08610SInochi Amaoto static DEFINE_SG2044_GATEABLE_DIV(CLK_DIV_VC_SRC1_MAIN, clk_div_vc_src1_main,
538*41b08610SInochi Amaoto clk_mpll5_parent, 0,
539*41b08610SInochi Amaoto 0x07c, 16, 8,
540*41b08610SInochi Amaoto CLK_DIVIDER_ONE_BASED | CLK_DIVIDER_ALLOW_ZERO |
541*41b08610SInochi Amaoto CLK_IS_CRITICAL,
542*41b08610SInochi Amaoto 1);
543*41b08610SInochi Amaoto
544*41b08610SInochi Amaoto static DEFINE_SG2044_GATEABLE_DIV(CLK_DIV_CXP_MAC_FIXED, clk_div_cxp_mac_fixed,
545*41b08610SInochi Amaoto clk_fpll0_parent, 0,
546*41b08610SInochi Amaoto 0x088, 16, 8,
547*41b08610SInochi Amaoto CLK_DIVIDER_ONE_BASED | CLK_DIVIDER_ALLOW_ZERO |
548*41b08610SInochi Amaoto CLK_IS_CRITICAL,
549*41b08610SInochi Amaoto 2);
550*41b08610SInochi Amaoto
551*41b08610SInochi Amaoto static DEFINE_SG2044_GATEABLE_DIV(CLK_DIV_CXP_MAC_MAIN, clk_div_cxp_mac_main,
552*41b08610SInochi Amaoto clk_fpll1_parent, 0,
553*41b08610SInochi Amaoto 0x084, 16, 8,
554*41b08610SInochi Amaoto CLK_DIVIDER_ONE_BASED | CLK_DIVIDER_ALLOW_ZERO |
555*41b08610SInochi Amaoto CLK_IS_CRITICAL,
556*41b08610SInochi Amaoto 1);
557*41b08610SInochi Amaoto
558*41b08610SInochi Amaoto static DEFINE_SG2044_DIV_RO(CLK_DIV_DDR0_FIXED, clk_div_ddr0_fixed,
559*41b08610SInochi Amaoto clk_fpll0_parent, 0,
560*41b08610SInochi Amaoto 0x124, 16, 8,
561*41b08610SInochi Amaoto CLK_DIVIDER_ONE_BASED | CLK_DIVIDER_ALLOW_ZERO,
562*41b08610SInochi Amaoto 2);
563*41b08610SInochi Amaoto
564*41b08610SInochi Amaoto static DEFINE_SG2044_DIV_RO(CLK_DIV_DDR0_MAIN, clk_div_ddr0_main,
565*41b08610SInochi Amaoto clk_dpll0_parent, 0,
566*41b08610SInochi Amaoto 0x120, 16, 8,
567*41b08610SInochi Amaoto CLK_DIVIDER_ONE_BASED | CLK_DIVIDER_ALLOW_ZERO,
568*41b08610SInochi Amaoto 1);
569*41b08610SInochi Amaoto
570*41b08610SInochi Amaoto static DEFINE_SG2044_DIV_RO(CLK_DIV_DDR1_FIXED, clk_div_ddr1_fixed,
571*41b08610SInochi Amaoto clk_fpll0_parent, 0,
572*41b08610SInochi Amaoto 0x12c, 16, 8,
573*41b08610SInochi Amaoto CLK_DIVIDER_ONE_BASED | CLK_DIVIDER_ALLOW_ZERO,
574*41b08610SInochi Amaoto 2);
575*41b08610SInochi Amaoto
576*41b08610SInochi Amaoto static DEFINE_SG2044_DIV_RO(CLK_DIV_DDR1_MAIN, clk_div_ddr1_main,
577*41b08610SInochi Amaoto clk_dpll1_parent, 0,
578*41b08610SInochi Amaoto 0x128, 16, 8,
579*41b08610SInochi Amaoto CLK_DIVIDER_ONE_BASED | CLK_DIVIDER_ALLOW_ZERO,
580*41b08610SInochi Amaoto 1);
581*41b08610SInochi Amaoto
582*41b08610SInochi Amaoto static DEFINE_SG2044_DIV_RO(CLK_DIV_DDR2_FIXED, clk_div_ddr2_fixed,
583*41b08610SInochi Amaoto clk_fpll0_parent, 0,
584*41b08610SInochi Amaoto 0x134, 16, 8,
585*41b08610SInochi Amaoto CLK_DIVIDER_ONE_BASED | CLK_DIVIDER_ALLOW_ZERO,
586*41b08610SInochi Amaoto 2);
587*41b08610SInochi Amaoto
588*41b08610SInochi Amaoto static DEFINE_SG2044_DIV_RO(CLK_DIV_DDR2_MAIN, clk_div_ddr2_main,
589*41b08610SInochi Amaoto clk_dpll2_parent, 0,
590*41b08610SInochi Amaoto 0x130, 16, 8,
591*41b08610SInochi Amaoto CLK_DIVIDER_ONE_BASED | CLK_DIVIDER_ALLOW_ZERO,
592*41b08610SInochi Amaoto 1);
593*41b08610SInochi Amaoto
594*41b08610SInochi Amaoto static DEFINE_SG2044_DIV_RO(CLK_DIV_DDR3_FIXED, clk_div_ddr3_fixed,
595*41b08610SInochi Amaoto clk_fpll0_parent, 0,
596*41b08610SInochi Amaoto 0x13c, 16, 8,
597*41b08610SInochi Amaoto CLK_DIVIDER_ONE_BASED | CLK_DIVIDER_ALLOW_ZERO,
598*41b08610SInochi Amaoto 2);
599*41b08610SInochi Amaoto
600*41b08610SInochi Amaoto static DEFINE_SG2044_DIV_RO(CLK_DIV_DDR3_MAIN, clk_div_ddr3_main,
601*41b08610SInochi Amaoto clk_dpll3_parent, 0,
602*41b08610SInochi Amaoto 0x138, 16, 8,
603*41b08610SInochi Amaoto CLK_DIVIDER_ONE_BASED | CLK_DIVIDER_ALLOW_ZERO,
604*41b08610SInochi Amaoto 1);
605*41b08610SInochi Amaoto
606*41b08610SInochi Amaoto static DEFINE_SG2044_DIV_RO(CLK_DIV_DDR4_FIXED, clk_div_ddr4_fixed,
607*41b08610SInochi Amaoto clk_fpll0_parent, 0,
608*41b08610SInochi Amaoto 0x144, 16, 8,
609*41b08610SInochi Amaoto CLK_DIVIDER_ONE_BASED | CLK_DIVIDER_ALLOW_ZERO,
610*41b08610SInochi Amaoto 2);
611*41b08610SInochi Amaoto
612*41b08610SInochi Amaoto static DEFINE_SG2044_DIV_RO(CLK_DIV_DDR4_MAIN, clk_div_ddr4_main,
613*41b08610SInochi Amaoto clk_dpll4_parent, 0,
614*41b08610SInochi Amaoto 0x140, 16, 8,
615*41b08610SInochi Amaoto CLK_DIVIDER_ONE_BASED | CLK_DIVIDER_ALLOW_ZERO,
616*41b08610SInochi Amaoto 1);
617*41b08610SInochi Amaoto
618*41b08610SInochi Amaoto static DEFINE_SG2044_DIV_RO(CLK_DIV_DDR5_FIXED, clk_div_ddr5_fixed,
619*41b08610SInochi Amaoto clk_fpll0_parent, 0,
620*41b08610SInochi Amaoto 0x14c, 16, 8,
621*41b08610SInochi Amaoto CLK_DIVIDER_ONE_BASED | CLK_DIVIDER_ALLOW_ZERO,
622*41b08610SInochi Amaoto 2);
623*41b08610SInochi Amaoto
624*41b08610SInochi Amaoto static DEFINE_SG2044_DIV_RO(CLK_DIV_DDR5_MAIN, clk_div_ddr5_main,
625*41b08610SInochi Amaoto clk_dpll5_parent, 0,
626*41b08610SInochi Amaoto 0x148, 16, 8,
627*41b08610SInochi Amaoto CLK_DIVIDER_ONE_BASED | CLK_DIVIDER_ALLOW_ZERO,
628*41b08610SInochi Amaoto 1);
629*41b08610SInochi Amaoto
630*41b08610SInochi Amaoto static DEFINE_SG2044_DIV_RO(CLK_DIV_DDR6_FIXED, clk_div_ddr6_fixed,
631*41b08610SInochi Amaoto clk_fpll0_parent, 0,
632*41b08610SInochi Amaoto 0x154, 16, 8,
633*41b08610SInochi Amaoto CLK_DIVIDER_ONE_BASED | CLK_DIVIDER_ALLOW_ZERO,
634*41b08610SInochi Amaoto 2);
635*41b08610SInochi Amaoto
636*41b08610SInochi Amaoto static DEFINE_SG2044_DIV_RO(CLK_DIV_DDR6_MAIN, clk_div_ddr6_main,
637*41b08610SInochi Amaoto clk_dpll6_parent, 0,
638*41b08610SInochi Amaoto 0x150, 16, 8,
639*41b08610SInochi Amaoto CLK_DIVIDER_ONE_BASED | CLK_DIVIDER_ALLOW_ZERO,
640*41b08610SInochi Amaoto 1);
641*41b08610SInochi Amaoto
642*41b08610SInochi Amaoto static DEFINE_SG2044_DIV_RO(CLK_DIV_DDR7_FIXED, clk_div_ddr7_fixed,
643*41b08610SInochi Amaoto clk_fpll0_parent, 0,
644*41b08610SInochi Amaoto 0x15c, 16, 8,
645*41b08610SInochi Amaoto CLK_DIVIDER_ONE_BASED | CLK_DIVIDER_ALLOW_ZERO,
646*41b08610SInochi Amaoto 2);
647*41b08610SInochi Amaoto
648*41b08610SInochi Amaoto static DEFINE_SG2044_DIV_RO(CLK_DIV_DDR7_MAIN, clk_div_ddr7_main,
649*41b08610SInochi Amaoto clk_dpll7_parent, 0,
650*41b08610SInochi Amaoto 0x158, 16, 8,
651*41b08610SInochi Amaoto CLK_DIVIDER_ONE_BASED | CLK_DIVIDER_ALLOW_ZERO,
652*41b08610SInochi Amaoto 1);
653*41b08610SInochi Amaoto
654*41b08610SInochi Amaoto static DEFINE_SG2044_DIV_PDATA(CLK_DIV_TOP_50M, clk_div_top_50m,
655*41b08610SInochi Amaoto clk_fpll0_parent, 0,
656*41b08610SInochi Amaoto 0x048, 16, 8,
657*41b08610SInochi Amaoto CLK_DIVIDER_ONE_BASED | CLK_DIVIDER_ALLOW_ZERO,
658*41b08610SInochi Amaoto 40);
659*41b08610SInochi Amaoto
660*41b08610SInochi Amaoto static const struct clk_hw *clk_div_top_50m_parent[] = {
661*41b08610SInochi Amaoto &clk_div_top_50m.common.hw,
662*41b08610SInochi Amaoto };
663*41b08610SInochi Amaoto
664*41b08610SInochi Amaoto static DEFINE_SG2044_DIV_RO(CLK_DIV_TOP_AXI0, clk_div_top_axi0,
665*41b08610SInochi Amaoto clk_fpll0_parent, 0,
666*41b08610SInochi Amaoto 0x118, 16, 8,
667*41b08610SInochi Amaoto CLK_DIVIDER_ONE_BASED | CLK_DIVIDER_ALLOW_ZERO,
668*41b08610SInochi Amaoto 20);
669*41b08610SInochi Amaoto
670*41b08610SInochi Amaoto static const struct clk_hw *clk_div_top_axi0_parent[] = {
671*41b08610SInochi Amaoto &clk_div_top_axi0.common.hw,
672*41b08610SInochi Amaoto };
673*41b08610SInochi Amaoto
674*41b08610SInochi Amaoto static DEFINE_SG2044_DIV_PDATA(CLK_DIV_TOP_AXI_HSPERI, clk_div_top_axi_hsperi,
675*41b08610SInochi Amaoto clk_fpll0_parent, 0,
676*41b08610SInochi Amaoto 0x11c, 16, 8,
677*41b08610SInochi Amaoto CLK_DIVIDER_ONE_BASED | CLK_DIVIDER_ALLOW_ZERO,
678*41b08610SInochi Amaoto 8);
679*41b08610SInochi Amaoto
680*41b08610SInochi Amaoto static const struct clk_hw *clk_div_top_axi_hsperi_parent[] = {
681*41b08610SInochi Amaoto &clk_div_top_axi_hsperi.common.hw,
682*41b08610SInochi Amaoto };
683*41b08610SInochi Amaoto
684*41b08610SInochi Amaoto static DEFINE_SG2044_DIV(CLK_DIV_TIMER0, clk_div_timer0,
685*41b08610SInochi Amaoto clk_div_top_50m_parent, 0,
686*41b08610SInochi Amaoto 0x0d0, 16, 16,
687*41b08610SInochi Amaoto CLK_DIVIDER_ONE_BASED | CLK_DIVIDER_ALLOW_ZERO,
688*41b08610SInochi Amaoto 1);
689*41b08610SInochi Amaoto
690*41b08610SInochi Amaoto static DEFINE_SG2044_DIV(CLK_DIV_TIMER1, clk_div_timer1,
691*41b08610SInochi Amaoto clk_div_top_50m_parent, 0,
692*41b08610SInochi Amaoto 0x0d4, 16, 16,
693*41b08610SInochi Amaoto CLK_DIVIDER_ONE_BASED | CLK_DIVIDER_ALLOW_ZERO,
694*41b08610SInochi Amaoto 1);
695*41b08610SInochi Amaoto
696*41b08610SInochi Amaoto static DEFINE_SG2044_DIV(CLK_DIV_TIMER2, clk_div_timer2,
697*41b08610SInochi Amaoto clk_div_top_50m_parent, 0,
698*41b08610SInochi Amaoto 0x0d8, 16, 16,
699*41b08610SInochi Amaoto CLK_DIVIDER_ONE_BASED | CLK_DIVIDER_ALLOW_ZERO,
700*41b08610SInochi Amaoto 1);
701*41b08610SInochi Amaoto
702*41b08610SInochi Amaoto static DEFINE_SG2044_DIV(CLK_DIV_TIMER3, clk_div_timer3,
703*41b08610SInochi Amaoto clk_div_top_50m_parent, 0,
704*41b08610SInochi Amaoto 0x0dc, 16, 16,
705*41b08610SInochi Amaoto CLK_DIVIDER_ONE_BASED | CLK_DIVIDER_ALLOW_ZERO,
706*41b08610SInochi Amaoto 1);
707*41b08610SInochi Amaoto
708*41b08610SInochi Amaoto static DEFINE_SG2044_DIV(CLK_DIV_TIMER4, clk_div_timer4,
709*41b08610SInochi Amaoto clk_div_top_50m_parent, 0,
710*41b08610SInochi Amaoto 0x0e0, 16, 16,
711*41b08610SInochi Amaoto CLK_DIVIDER_ONE_BASED | CLK_DIVIDER_ALLOW_ZERO,
712*41b08610SInochi Amaoto 1);
713*41b08610SInochi Amaoto
714*41b08610SInochi Amaoto static DEFINE_SG2044_DIV(CLK_DIV_TIMER5, clk_div_timer5,
715*41b08610SInochi Amaoto clk_div_top_50m_parent, 0,
716*41b08610SInochi Amaoto 0x0e4, 16, 16,
717*41b08610SInochi Amaoto CLK_DIVIDER_ONE_BASED | CLK_DIVIDER_ALLOW_ZERO,
718*41b08610SInochi Amaoto 1);
719*41b08610SInochi Amaoto
720*41b08610SInochi Amaoto static DEFINE_SG2044_DIV(CLK_DIV_TIMER6, clk_div_timer6,
721*41b08610SInochi Amaoto clk_div_top_50m_parent, 0,
722*41b08610SInochi Amaoto 0x0e8, 16, 16,
723*41b08610SInochi Amaoto CLK_DIVIDER_ONE_BASED | CLK_DIVIDER_ALLOW_ZERO,
724*41b08610SInochi Amaoto 1);
725*41b08610SInochi Amaoto
726*41b08610SInochi Amaoto static DEFINE_SG2044_DIV(CLK_DIV_TIMER7, clk_div_timer7,
727*41b08610SInochi Amaoto clk_div_top_50m_parent, 0,
728*41b08610SInochi Amaoto 0x0ec, 16, 16,
729*41b08610SInochi Amaoto CLK_DIVIDER_ONE_BASED | CLK_DIVIDER_ALLOW_ZERO,
730*41b08610SInochi Amaoto 1);
731*41b08610SInochi Amaoto
732*41b08610SInochi Amaoto static DEFINE_SG2044_DIV_PDATA(CLK_DIV_CXP_TEST_PHY, clk_div_cxp_test_phy,
733*41b08610SInochi Amaoto clk_fpll0_parent, 0,
734*41b08610SInochi Amaoto 0x064, 16, 8,
735*41b08610SInochi Amaoto CLK_DIVIDER_ONE_BASED | CLK_DIVIDER_ALLOW_ZERO,
736*41b08610SInochi Amaoto 1);
737*41b08610SInochi Amaoto
738*41b08610SInochi Amaoto static DEFINE_SG2044_DIV_PDATA(CLK_DIV_CXP_TEST_ETH_PHY, clk_div_cxp_test_eth_phy,
739*41b08610SInochi Amaoto clk_fpll2_parent, 0,
740*41b08610SInochi Amaoto 0x068, 16, 8,
741*41b08610SInochi Amaoto CLK_DIVIDER_ONE_BASED | CLK_DIVIDER_ALLOW_ZERO,
742*41b08610SInochi Amaoto 1);
743*41b08610SInochi Amaoto
744*41b08610SInochi Amaoto static DEFINE_SG2044_DIV_PDATA(CLK_DIV_C2C0_TEST_PHY, clk_div_c2c0_test_phy,
745*41b08610SInochi Amaoto clk_fpll0_parent, 0,
746*41b08610SInochi Amaoto 0x05c, 16, 8,
747*41b08610SInochi Amaoto CLK_DIVIDER_ONE_BASED | CLK_DIVIDER_ALLOW_ZERO,
748*41b08610SInochi Amaoto 1);
749*41b08610SInochi Amaoto
750*41b08610SInochi Amaoto static DEFINE_SG2044_DIV_PDATA(CLK_DIV_C2C1_TEST_PHY, clk_div_c2c1_test_phy,
751*41b08610SInochi Amaoto clk_fpll0_parent, 0,
752*41b08610SInochi Amaoto 0x060, 16, 8,
753*41b08610SInochi Amaoto CLK_DIVIDER_ONE_BASED | CLK_DIVIDER_ALLOW_ZERO,
754*41b08610SInochi Amaoto 1);
755*41b08610SInochi Amaoto
756*41b08610SInochi Amaoto static DEFINE_SG2044_DIV_PDATA(CLK_DIV_PCIE_1G, clk_div_pcie_1g,
757*41b08610SInochi Amaoto clk_fpll1_parent, 0,
758*41b08610SInochi Amaoto 0x160, 16, 8,
759*41b08610SInochi Amaoto CLK_DIVIDER_ONE_BASED | CLK_DIVIDER_ALLOW_ZERO,
760*41b08610SInochi Amaoto 1);
761*41b08610SInochi Amaoto
762*41b08610SInochi Amaoto static DEFINE_SG2044_DIV_PDATA(CLK_DIV_UART_500M, clk_div_uart_500m,
763*41b08610SInochi Amaoto clk_fpll0_parent, 0,
764*41b08610SInochi Amaoto 0x0cc, 16, 8,
765*41b08610SInochi Amaoto CLK_DIVIDER_ONE_BASED | CLK_DIVIDER_ALLOW_ZERO,
766*41b08610SInochi Amaoto 4);
767*41b08610SInochi Amaoto
768*41b08610SInochi Amaoto static DEFINE_SG2044_DIV(CLK_DIV_GPIO_DB, clk_div_gpio_db,
769*41b08610SInochi Amaoto clk_div_top_axi0_parent, 0,
770*41b08610SInochi Amaoto 0x0f8, 16, 16,
771*41b08610SInochi Amaoto CLK_DIVIDER_ONE_BASED | CLK_DIVIDER_ALLOW_ZERO,
772*41b08610SInochi Amaoto 1000);
773*41b08610SInochi Amaoto
774*41b08610SInochi Amaoto static DEFINE_SG2044_DIV_PDATA(CLK_DIV_SD, clk_div_sd,
775*41b08610SInochi Amaoto clk_fpll0_parent, 0,
776*41b08610SInochi Amaoto 0x110, 16, 16,
777*41b08610SInochi Amaoto CLK_DIVIDER_ONE_BASED | CLK_DIVIDER_ALLOW_ZERO,
778*41b08610SInochi Amaoto 5);
779*41b08610SInochi Amaoto
780*41b08610SInochi Amaoto static DEFINE_SG2044_DIV(CLK_DIV_SD_100K, clk_div_sd_100k,
781*41b08610SInochi Amaoto clk_div_top_axi0_parent, 0,
782*41b08610SInochi Amaoto 0x114, 16, 16,
783*41b08610SInochi Amaoto CLK_DIVIDER_ONE_BASED | CLK_DIVIDER_ALLOW_ZERO,
784*41b08610SInochi Amaoto 1000);
785*41b08610SInochi Amaoto
786*41b08610SInochi Amaoto static DEFINE_SG2044_DIV_PDATA(CLK_DIV_EMMC, clk_div_emmc,
787*41b08610SInochi Amaoto clk_fpll0_parent, 0,
788*41b08610SInochi Amaoto 0x108, 16, 16,
789*41b08610SInochi Amaoto CLK_DIVIDER_ONE_BASED | CLK_DIVIDER_ALLOW_ZERO,
790*41b08610SInochi Amaoto 5);
791*41b08610SInochi Amaoto
792*41b08610SInochi Amaoto static DEFINE_SG2044_DIV(CLK_DIV_EMMC_100K, clk_div_emmc_100k,
793*41b08610SInochi Amaoto clk_div_top_axi0_parent, 0,
794*41b08610SInochi Amaoto 0x10c, 16, 16,
795*41b08610SInochi Amaoto CLK_DIVIDER_ONE_BASED | CLK_DIVIDER_ALLOW_ZERO,
796*41b08610SInochi Amaoto 1000);
797*41b08610SInochi Amaoto
798*41b08610SInochi Amaoto static DEFINE_SG2044_DIV_PDATA(CLK_DIV_EFUSE, clk_div_efuse,
799*41b08610SInochi Amaoto clk_fpll0_parent, 0,
800*41b08610SInochi Amaoto 0x0f4, 16, 8,
801*41b08610SInochi Amaoto CLK_DIVIDER_ONE_BASED | CLK_DIVIDER_ALLOW_ZERO,
802*41b08610SInochi Amaoto 80);
803*41b08610SInochi Amaoto
804*41b08610SInochi Amaoto static DEFINE_SG2044_DIV_PDATA(CLK_DIV_TX_ETH0, clk_div_tx_eth0,
805*41b08610SInochi Amaoto clk_fpll0_parent, 0,
806*41b08610SInochi Amaoto 0x0fc, 16, 8,
807*41b08610SInochi Amaoto CLK_DIVIDER_ONE_BASED | CLK_DIVIDER_ALLOW_ZERO,
808*41b08610SInochi Amaoto 16);
809*41b08610SInochi Amaoto
810*41b08610SInochi Amaoto static DEFINE_SG2044_DIV_PDATA(CLK_DIV_PTP_REF_I_ETH0, clk_div_ptp_ref_i_eth0,
811*41b08610SInochi Amaoto clk_fpll0_parent, 0,
812*41b08610SInochi Amaoto 0x100, 16, 8,
813*41b08610SInochi Amaoto CLK_DIVIDER_ONE_BASED | CLK_DIVIDER_ALLOW_ZERO,
814*41b08610SInochi Amaoto 40);
815*41b08610SInochi Amaoto
816*41b08610SInochi Amaoto static DEFINE_SG2044_DIV_PDATA(CLK_DIV_REF_ETH0, clk_div_ref_eth0,
817*41b08610SInochi Amaoto clk_fpll0_parent, 0,
818*41b08610SInochi Amaoto 0x104, 16, 8,
819*41b08610SInochi Amaoto CLK_DIVIDER_ONE_BASED | CLK_DIVIDER_ALLOW_ZERO,
820*41b08610SInochi Amaoto 80);
821*41b08610SInochi Amaoto
822*41b08610SInochi Amaoto static DEFINE_SG2044_DIV_PDATA(CLK_DIV_PKA, clk_div_pka,
823*41b08610SInochi Amaoto clk_fpll0_parent, 0,
824*41b08610SInochi Amaoto 0x0f0, 16, 8,
825*41b08610SInochi Amaoto CLK_DIVIDER_ONE_BASED | CLK_DIVIDER_ALLOW_ZERO,
826*41b08610SInochi Amaoto 2);
827*41b08610SInochi Amaoto
828*41b08610SInochi Amaoto static const struct clk_parent_data clk_mux_ddr0_parents[] = {
829*41b08610SInochi Amaoto { .hw = &clk_div_ddr0_fixed.common.hw },
830*41b08610SInochi Amaoto { .hw = &clk_div_ddr0_main.common.hw },
831*41b08610SInochi Amaoto };
832*41b08610SInochi Amaoto
833*41b08610SInochi Amaoto static DEFINE_SG2044_MUX(CLK_MUX_DDR0, clk_mux_ddr0,
834*41b08610SInochi Amaoto clk_mux_ddr0_parents,
835*41b08610SInochi Amaoto CLK_SET_RATE_PARENT | CLK_SET_RATE_NO_REPARENT,
836*41b08610SInochi Amaoto 0x020, 7, sg2044_mux_table, CLK_MUX_READ_ONLY);
837*41b08610SInochi Amaoto
838*41b08610SInochi Amaoto static const struct clk_parent_data clk_mux_ddr1_parents[] = {
839*41b08610SInochi Amaoto { .hw = &clk_div_ddr1_fixed.common.hw },
840*41b08610SInochi Amaoto { .hw = &clk_div_ddr1_main.common.hw },
841*41b08610SInochi Amaoto };
842*41b08610SInochi Amaoto
843*41b08610SInochi Amaoto static DEFINE_SG2044_MUX(CLK_MUX_DDR1, clk_mux_ddr1,
844*41b08610SInochi Amaoto clk_mux_ddr1_parents,
845*41b08610SInochi Amaoto CLK_SET_RATE_PARENT | CLK_SET_RATE_NO_REPARENT,
846*41b08610SInochi Amaoto 0x020, 8, sg2044_mux_table, CLK_MUX_READ_ONLY);
847*41b08610SInochi Amaoto
848*41b08610SInochi Amaoto static const struct clk_parent_data clk_mux_ddr2_parents[] = {
849*41b08610SInochi Amaoto { .hw = &clk_div_ddr2_fixed.common.hw },
850*41b08610SInochi Amaoto { .hw = &clk_div_ddr2_main.common.hw },
851*41b08610SInochi Amaoto };
852*41b08610SInochi Amaoto
853*41b08610SInochi Amaoto static DEFINE_SG2044_MUX(CLK_MUX_DDR2, clk_mux_ddr2,
854*41b08610SInochi Amaoto clk_mux_ddr2_parents,
855*41b08610SInochi Amaoto CLK_SET_RATE_PARENT | CLK_SET_RATE_NO_REPARENT,
856*41b08610SInochi Amaoto 0x020, 9, sg2044_mux_table, CLK_MUX_READ_ONLY);
857*41b08610SInochi Amaoto
858*41b08610SInochi Amaoto static const struct clk_parent_data clk_mux_ddr3_parents[] = {
859*41b08610SInochi Amaoto { .hw = &clk_div_ddr3_fixed.common.hw },
860*41b08610SInochi Amaoto { .hw = &clk_div_ddr3_main.common.hw },
861*41b08610SInochi Amaoto };
862*41b08610SInochi Amaoto
863*41b08610SInochi Amaoto static DEFINE_SG2044_MUX(CLK_MUX_DDR3, clk_mux_ddr3,
864*41b08610SInochi Amaoto clk_mux_ddr3_parents,
865*41b08610SInochi Amaoto CLK_SET_RATE_PARENT | CLK_SET_RATE_NO_REPARENT,
866*41b08610SInochi Amaoto 0x020, 10, sg2044_mux_table, CLK_MUX_READ_ONLY);
867*41b08610SInochi Amaoto
868*41b08610SInochi Amaoto static const struct clk_parent_data clk_mux_ddr4_parents[] = {
869*41b08610SInochi Amaoto { .hw = &clk_div_ddr4_fixed.common.hw },
870*41b08610SInochi Amaoto { .hw = &clk_div_ddr4_main.common.hw },
871*41b08610SInochi Amaoto };
872*41b08610SInochi Amaoto
873*41b08610SInochi Amaoto static DEFINE_SG2044_MUX(CLK_MUX_DDR4, clk_mux_ddr4,
874*41b08610SInochi Amaoto clk_mux_ddr4_parents,
875*41b08610SInochi Amaoto CLK_SET_RATE_PARENT | CLK_SET_RATE_NO_REPARENT,
876*41b08610SInochi Amaoto 0x020, 11, sg2044_mux_table, CLK_MUX_READ_ONLY);
877*41b08610SInochi Amaoto
878*41b08610SInochi Amaoto static const struct clk_parent_data clk_mux_ddr5_parents[] = {
879*41b08610SInochi Amaoto { .hw = &clk_div_ddr5_fixed.common.hw },
880*41b08610SInochi Amaoto { .hw = &clk_div_ddr5_main.common.hw },
881*41b08610SInochi Amaoto };
882*41b08610SInochi Amaoto
883*41b08610SInochi Amaoto static DEFINE_SG2044_MUX(CLK_MUX_DDR5, clk_mux_ddr5,
884*41b08610SInochi Amaoto clk_mux_ddr5_parents,
885*41b08610SInochi Amaoto CLK_SET_RATE_PARENT | CLK_SET_RATE_NO_REPARENT,
886*41b08610SInochi Amaoto 0x020, 12, sg2044_mux_table, CLK_MUX_READ_ONLY);
887*41b08610SInochi Amaoto
888*41b08610SInochi Amaoto static const struct clk_parent_data clk_mux_ddr6_parents[] = {
889*41b08610SInochi Amaoto { .hw = &clk_div_ddr6_fixed.common.hw },
890*41b08610SInochi Amaoto { .hw = &clk_div_ddr6_main.common.hw },
891*41b08610SInochi Amaoto };
892*41b08610SInochi Amaoto
893*41b08610SInochi Amaoto static DEFINE_SG2044_MUX(CLK_MUX_DDR6, clk_mux_ddr6,
894*41b08610SInochi Amaoto clk_mux_ddr6_parents,
895*41b08610SInochi Amaoto CLK_SET_RATE_PARENT | CLK_SET_RATE_NO_REPARENT,
896*41b08610SInochi Amaoto 0x020, 13, sg2044_mux_table, CLK_MUX_READ_ONLY);
897*41b08610SInochi Amaoto
898*41b08610SInochi Amaoto static const struct clk_parent_data clk_mux_ddr7_parents[] = {
899*41b08610SInochi Amaoto { .hw = &clk_div_ddr7_fixed.common.hw },
900*41b08610SInochi Amaoto { .hw = &clk_div_ddr7_main.common.hw },
901*41b08610SInochi Amaoto };
902*41b08610SInochi Amaoto
903*41b08610SInochi Amaoto static DEFINE_SG2044_MUX(CLK_MUX_DDR7, clk_mux_ddr7,
904*41b08610SInochi Amaoto clk_mux_ddr7_parents,
905*41b08610SInochi Amaoto CLK_SET_RATE_PARENT | CLK_SET_RATE_NO_REPARENT,
906*41b08610SInochi Amaoto 0x020, 14, sg2044_mux_table, CLK_MUX_READ_ONLY);
907*41b08610SInochi Amaoto
908*41b08610SInochi Amaoto static const struct clk_parent_data clk_mux_noc_sys_parents[] = {
909*41b08610SInochi Amaoto { .hw = &clk_div_noc_sys_fixed.common.hw },
910*41b08610SInochi Amaoto { .hw = &clk_div_noc_sys_main.common.hw },
911*41b08610SInochi Amaoto };
912*41b08610SInochi Amaoto
913*41b08610SInochi Amaoto static DEFINE_SG2044_MUX(CLK_MUX_NOC_SYS, clk_mux_noc_sys,
914*41b08610SInochi Amaoto clk_mux_noc_sys_parents,
915*41b08610SInochi Amaoto CLK_SET_RATE_PARENT | CLK_SET_RATE_NO_REPARENT,
916*41b08610SInochi Amaoto 0x020, 3, sg2044_mux_table, 0);
917*41b08610SInochi Amaoto
918*41b08610SInochi Amaoto static const struct clk_parent_data clk_mux_tpu_sys_parents[] = {
919*41b08610SInochi Amaoto { .hw = &clk_div_tpu_sys_fixed.common.hw },
920*41b08610SInochi Amaoto { .hw = &clk_div_tpu_sys_main.common.hw },
921*41b08610SInochi Amaoto };
922*41b08610SInochi Amaoto
923*41b08610SInochi Amaoto static DEFINE_SG2044_MUX(CLK_MUX_TPU_SYS, clk_mux_tpu_sys,
924*41b08610SInochi Amaoto clk_mux_tpu_sys_parents,
925*41b08610SInochi Amaoto CLK_SET_RATE_PARENT | CLK_SET_RATE_NO_REPARENT,
926*41b08610SInochi Amaoto 0x020, 2, sg2044_mux_table, 0);
927*41b08610SInochi Amaoto
928*41b08610SInochi Amaoto static const struct clk_parent_data clk_mux_rp_sys_parents[] = {
929*41b08610SInochi Amaoto { .hw = &clk_div_rp_sys_fixed.common.hw },
930*41b08610SInochi Amaoto { .hw = &clk_div_rp_sys_main.common.hw },
931*41b08610SInochi Amaoto };
932*41b08610SInochi Amaoto
933*41b08610SInochi Amaoto static DEFINE_SG2044_MUX(CLK_MUX_RP_SYS, clk_mux_rp_sys,
934*41b08610SInochi Amaoto clk_mux_rp_sys_parents,
935*41b08610SInochi Amaoto CLK_SET_RATE_PARENT | CLK_SET_RATE_NO_REPARENT,
936*41b08610SInochi Amaoto 0x020, 1, sg2044_mux_table, 0);
937*41b08610SInochi Amaoto
938*41b08610SInochi Amaoto static const struct clk_parent_data clk_mux_ap_sys_parents[] = {
939*41b08610SInochi Amaoto { .hw = &clk_div_ap_sys_fixed.common.hw },
940*41b08610SInochi Amaoto { .hw = &clk_div_ap_sys_main.common.hw },
941*41b08610SInochi Amaoto };
942*41b08610SInochi Amaoto
943*41b08610SInochi Amaoto static DEFINE_SG2044_MUX(CLK_MUX_AP_SYS, clk_mux_ap_sys,
944*41b08610SInochi Amaoto clk_mux_ap_sys_parents,
945*41b08610SInochi Amaoto CLK_SET_RATE_PARENT | CLK_SET_RATE_NO_REPARENT,
946*41b08610SInochi Amaoto 0x020, 0, sg2044_mux_table, 0);
947*41b08610SInochi Amaoto
948*41b08610SInochi Amaoto static const struct clk_parent_data clk_mux_vc_src0_parents[] = {
949*41b08610SInochi Amaoto { .hw = &clk_div_vc_src0_fixed.common.hw },
950*41b08610SInochi Amaoto { .hw = &clk_div_vc_src0_main.common.hw },
951*41b08610SInochi Amaoto };
952*41b08610SInochi Amaoto
953*41b08610SInochi Amaoto static DEFINE_SG2044_MUX(CLK_MUX_VC_SRC0, clk_mux_vc_src0,
954*41b08610SInochi Amaoto clk_mux_vc_src0_parents,
955*41b08610SInochi Amaoto CLK_SET_RATE_PARENT | CLK_SET_RATE_NO_REPARENT,
956*41b08610SInochi Amaoto 0x020, 4, sg2044_mux_table, 0);
957*41b08610SInochi Amaoto
958*41b08610SInochi Amaoto static const struct clk_parent_data clk_mux_vc_src1_parents[] = {
959*41b08610SInochi Amaoto { .hw = &clk_div_vc_src1_fixed.common.hw },
960*41b08610SInochi Amaoto { .hw = &clk_div_vc_src1_main.common.hw },
961*41b08610SInochi Amaoto };
962*41b08610SInochi Amaoto
963*41b08610SInochi Amaoto static DEFINE_SG2044_MUX(CLK_MUX_VC_SRC1, clk_mux_vc_src1,
964*41b08610SInochi Amaoto clk_mux_vc_src1_parents,
965*41b08610SInochi Amaoto CLK_SET_RATE_PARENT | CLK_SET_RATE_NO_REPARENT,
966*41b08610SInochi Amaoto 0x020, 5, sg2044_mux_table, 0);
967*41b08610SInochi Amaoto
968*41b08610SInochi Amaoto static const struct clk_parent_data clk_mux_cxp_mac_parents[] = {
969*41b08610SInochi Amaoto { .hw = &clk_div_cxp_mac_fixed.common.hw },
970*41b08610SInochi Amaoto { .hw = &clk_div_cxp_mac_main.common.hw },
971*41b08610SInochi Amaoto };
972*41b08610SInochi Amaoto
973*41b08610SInochi Amaoto static DEFINE_SG2044_MUX(CLK_MUX_CXP_MAC, clk_mux_cxp_mac,
974*41b08610SInochi Amaoto clk_mux_cxp_mac_parents,
975*41b08610SInochi Amaoto CLK_SET_RATE_PARENT | CLK_SET_RATE_NO_REPARENT,
976*41b08610SInochi Amaoto 0x020, 6, sg2044_mux_table, 0);
977*41b08610SInochi Amaoto
978*41b08610SInochi Amaoto static const struct clk_hw *clk_gate_ap_sys_parent[] = {
979*41b08610SInochi Amaoto &clk_mux_ap_sys.common.hw,
980*41b08610SInochi Amaoto };
981*41b08610SInochi Amaoto
982*41b08610SInochi Amaoto static DEFINE_SG2044_GATE(CLK_GATE_AP_SYS, clk_gate_ap_sys,
983*41b08610SInochi Amaoto clk_gate_ap_sys_parent,
984*41b08610SInochi Amaoto CLK_SET_RATE_PARENT | CLK_IS_CRITICAL,
985*41b08610SInochi Amaoto 0x000, 0, 0);
986*41b08610SInochi Amaoto
987*41b08610SInochi Amaoto static const struct clk_hw *clk_gate_rp_sys_parent[] = {
988*41b08610SInochi Amaoto &clk_mux_rp_sys.common.hw,
989*41b08610SInochi Amaoto };
990*41b08610SInochi Amaoto
991*41b08610SInochi Amaoto static DEFINE_SG2044_GATE(CLK_GATE_RP_SYS, clk_gate_rp_sys,
992*41b08610SInochi Amaoto clk_gate_rp_sys_parent,
993*41b08610SInochi Amaoto CLK_SET_RATE_PARENT | CLK_IS_CRITICAL,
994*41b08610SInochi Amaoto 0x000, 2, 0);
995*41b08610SInochi Amaoto
996*41b08610SInochi Amaoto static const struct clk_hw *clk_gate_tpu_sys_parent[] = {
997*41b08610SInochi Amaoto &clk_mux_tpu_sys.common.hw,
998*41b08610SInochi Amaoto };
999*41b08610SInochi Amaoto
1000*41b08610SInochi Amaoto static DEFINE_SG2044_GATE(CLK_GATE_TPU_SYS, clk_gate_tpu_sys,
1001*41b08610SInochi Amaoto clk_gate_tpu_sys_parent,
1002*41b08610SInochi Amaoto CLK_SET_RATE_PARENT | CLK_IS_CRITICAL,
1003*41b08610SInochi Amaoto 0x000, 3, 0);
1004*41b08610SInochi Amaoto
1005*41b08610SInochi Amaoto static const struct clk_hw *clk_gate_noc_sys_parent[] = {
1006*41b08610SInochi Amaoto &clk_mux_noc_sys.common.hw,
1007*41b08610SInochi Amaoto };
1008*41b08610SInochi Amaoto
1009*41b08610SInochi Amaoto static DEFINE_SG2044_GATE(CLK_GATE_NOC_SYS, clk_gate_noc_sys,
1010*41b08610SInochi Amaoto clk_gate_noc_sys_parent,
1011*41b08610SInochi Amaoto CLK_SET_RATE_PARENT | CLK_IS_CRITICAL,
1012*41b08610SInochi Amaoto 0x000, 8, 0);
1013*41b08610SInochi Amaoto
1014*41b08610SInochi Amaoto static const struct clk_hw *clk_gate_vc_src0_parent[] = {
1015*41b08610SInochi Amaoto &clk_mux_vc_src0.common.hw,
1016*41b08610SInochi Amaoto };
1017*41b08610SInochi Amaoto
1018*41b08610SInochi Amaoto static DEFINE_SG2044_GATE(CLK_GATE_VC_SRC0, clk_gate_vc_src0,
1019*41b08610SInochi Amaoto clk_gate_vc_src0_parent,
1020*41b08610SInochi Amaoto CLK_SET_RATE_PARENT | CLK_IS_CRITICAL,
1021*41b08610SInochi Amaoto 0x000, 9, 0);
1022*41b08610SInochi Amaoto
1023*41b08610SInochi Amaoto static const struct clk_hw *clk_gate_vc_src1_parent[] = {
1024*41b08610SInochi Amaoto &clk_mux_vc_src1.common.hw,
1025*41b08610SInochi Amaoto };
1026*41b08610SInochi Amaoto
1027*41b08610SInochi Amaoto static DEFINE_SG2044_GATE(CLK_GATE_VC_SRC1, clk_gate_vc_src1,
1028*41b08610SInochi Amaoto clk_gate_vc_src1_parent,
1029*41b08610SInochi Amaoto CLK_SET_RATE_PARENT | CLK_IS_CRITICAL,
1030*41b08610SInochi Amaoto 0x000, 10, 0);
1031*41b08610SInochi Amaoto
1032*41b08610SInochi Amaoto static const struct clk_hw *clk_gate_ddr0_parent[] = {
1033*41b08610SInochi Amaoto &clk_mux_ddr0.common.hw,
1034*41b08610SInochi Amaoto };
1035*41b08610SInochi Amaoto
1036*41b08610SInochi Amaoto static DEFINE_SG2044_GATE(CLK_GATE_DDR0, clk_gate_ddr0,
1037*41b08610SInochi Amaoto clk_gate_ddr0_parent,
1038*41b08610SInochi Amaoto CLK_SET_RATE_PARENT | CLK_IS_CRITICAL,
1039*41b08610SInochi Amaoto 0x008, 7, 0);
1040*41b08610SInochi Amaoto
1041*41b08610SInochi Amaoto static const struct clk_hw *clk_gate_ddr1_parent[] = {
1042*41b08610SInochi Amaoto &clk_mux_ddr1.common.hw,
1043*41b08610SInochi Amaoto };
1044*41b08610SInochi Amaoto
1045*41b08610SInochi Amaoto static DEFINE_SG2044_GATE(CLK_GATE_DDR1, clk_gate_ddr1,
1046*41b08610SInochi Amaoto clk_gate_ddr1_parent,
1047*41b08610SInochi Amaoto CLK_SET_RATE_PARENT | CLK_IS_CRITICAL,
1048*41b08610SInochi Amaoto 0x008, 8, 0);
1049*41b08610SInochi Amaoto
1050*41b08610SInochi Amaoto static const struct clk_hw *clk_gate_ddr2_parent[] = {
1051*41b08610SInochi Amaoto &clk_mux_ddr2.common.hw,
1052*41b08610SInochi Amaoto };
1053*41b08610SInochi Amaoto
1054*41b08610SInochi Amaoto static DEFINE_SG2044_GATE(CLK_GATE_DDR2, clk_gate_ddr2,
1055*41b08610SInochi Amaoto clk_gate_ddr2_parent,
1056*41b08610SInochi Amaoto CLK_SET_RATE_PARENT | CLK_IS_CRITICAL,
1057*41b08610SInochi Amaoto 0x008, 9, 0);
1058*41b08610SInochi Amaoto
1059*41b08610SInochi Amaoto static const struct clk_hw *clk_gate_ddr3_parent[] = {
1060*41b08610SInochi Amaoto &clk_mux_ddr3.common.hw,
1061*41b08610SInochi Amaoto };
1062*41b08610SInochi Amaoto
1063*41b08610SInochi Amaoto static DEFINE_SG2044_GATE(CLK_GATE_DDR3, clk_gate_ddr3,
1064*41b08610SInochi Amaoto clk_gate_ddr3_parent,
1065*41b08610SInochi Amaoto CLK_SET_RATE_PARENT | CLK_IS_CRITICAL,
1066*41b08610SInochi Amaoto 0x008, 10, 0);
1067*41b08610SInochi Amaoto
1068*41b08610SInochi Amaoto static const struct clk_hw *clk_gate_ddr4_parent[] = {
1069*41b08610SInochi Amaoto &clk_mux_ddr4.common.hw,
1070*41b08610SInochi Amaoto };
1071*41b08610SInochi Amaoto
1072*41b08610SInochi Amaoto static DEFINE_SG2044_GATE(CLK_GATE_DDR4, clk_gate_ddr4,
1073*41b08610SInochi Amaoto clk_gate_ddr4_parent,
1074*41b08610SInochi Amaoto CLK_SET_RATE_PARENT | CLK_IS_CRITICAL,
1075*41b08610SInochi Amaoto 0x008, 11, 0);
1076*41b08610SInochi Amaoto
1077*41b08610SInochi Amaoto static const struct clk_hw *clk_gate_ddr5_parent[] = {
1078*41b08610SInochi Amaoto &clk_mux_ddr5.common.hw,
1079*41b08610SInochi Amaoto };
1080*41b08610SInochi Amaoto
1081*41b08610SInochi Amaoto static DEFINE_SG2044_GATE(CLK_GATE_DDR5, clk_gate_ddr5,
1082*41b08610SInochi Amaoto clk_gate_ddr5_parent,
1083*41b08610SInochi Amaoto CLK_SET_RATE_PARENT | CLK_IS_CRITICAL,
1084*41b08610SInochi Amaoto 0x008, 12, 0);
1085*41b08610SInochi Amaoto
1086*41b08610SInochi Amaoto static const struct clk_hw *clk_gate_ddr6_parent[] = {
1087*41b08610SInochi Amaoto &clk_mux_ddr6.common.hw,
1088*41b08610SInochi Amaoto };
1089*41b08610SInochi Amaoto
1090*41b08610SInochi Amaoto static DEFINE_SG2044_GATE(CLK_GATE_DDR6, clk_gate_ddr6,
1091*41b08610SInochi Amaoto clk_gate_ddr6_parent,
1092*41b08610SInochi Amaoto CLK_SET_RATE_PARENT | CLK_IS_CRITICAL,
1093*41b08610SInochi Amaoto 0x008, 13, 0);
1094*41b08610SInochi Amaoto
1095*41b08610SInochi Amaoto static const struct clk_hw *clk_gate_ddr7_parent[] = {
1096*41b08610SInochi Amaoto &clk_mux_ddr7.common.hw,
1097*41b08610SInochi Amaoto };
1098*41b08610SInochi Amaoto
1099*41b08610SInochi Amaoto static DEFINE_SG2044_GATE(CLK_GATE_DDR7, clk_gate_ddr7,
1100*41b08610SInochi Amaoto clk_gate_ddr7_parent,
1101*41b08610SInochi Amaoto CLK_SET_RATE_PARENT | CLK_IS_CRITICAL,
1102*41b08610SInochi Amaoto 0x008, 14, 0);
1103*41b08610SInochi Amaoto
1104*41b08610SInochi Amaoto static const struct clk_hw *clk_gate_top_50m_parent[] = {
1105*41b08610SInochi Amaoto &clk_div_top_50m.common.hw,
1106*41b08610SInochi Amaoto };
1107*41b08610SInochi Amaoto
1108*41b08610SInochi Amaoto static DEFINE_SG2044_GATE(CLK_GATE_TOP_50M, clk_gate_top_50m,
1109*41b08610SInochi Amaoto clk_gate_top_50m_parent,
1110*41b08610SInochi Amaoto CLK_SET_RATE_PARENT | CLK_IS_CRITICAL,
1111*41b08610SInochi Amaoto 0x000, 1, 0);
1112*41b08610SInochi Amaoto
1113*41b08610SInochi Amaoto static const struct clk_hw *clk_gate_sc_rx_parent[] = {
1114*41b08610SInochi Amaoto &clk_div_top_50m.common.hw,
1115*41b08610SInochi Amaoto };
1116*41b08610SInochi Amaoto
1117*41b08610SInochi Amaoto static DEFINE_SG2044_GATE(CLK_GATE_SC_RX, clk_gate_sc_rx,
1118*41b08610SInochi Amaoto clk_gate_sc_rx_parent,
1119*41b08610SInochi Amaoto CLK_SET_RATE_PARENT | CLK_IS_CRITICAL,
1120*41b08610SInochi Amaoto 0x000, 12, 0);
1121*41b08610SInochi Amaoto
1122*41b08610SInochi Amaoto static const struct clk_hw *clk_gate_sc_rx_x0y1_parent[] = {
1123*41b08610SInochi Amaoto &clk_div_top_50m.common.hw,
1124*41b08610SInochi Amaoto };
1125*41b08610SInochi Amaoto
1126*41b08610SInochi Amaoto static DEFINE_SG2044_GATE(CLK_GATE_SC_RX_X0Y1, clk_gate_sc_rx_x0y1,
1127*41b08610SInochi Amaoto clk_gate_sc_rx_x0y1_parent,
1128*41b08610SInochi Amaoto CLK_SET_RATE_PARENT | CLK_IS_CRITICAL,
1129*41b08610SInochi Amaoto 0x000, 13, 0);
1130*41b08610SInochi Amaoto
1131*41b08610SInochi Amaoto static DEFINE_SG2044_GATE(CLK_GATE_TOP_AXI0, clk_gate_top_axi0,
1132*41b08610SInochi Amaoto clk_div_top_axi0_parent,
1133*41b08610SInochi Amaoto CLK_SET_RATE_PARENT | CLK_IS_CRITICAL,
1134*41b08610SInochi Amaoto 0x008, 5, 0);
1135*41b08610SInochi Amaoto
1136*41b08610SInochi Amaoto static const struct clk_hw *clk_gate_mailbox_intc_parent[] = {
1137*41b08610SInochi Amaoto &clk_gate_top_axi0.common.hw,
1138*41b08610SInochi Amaoto };
1139*41b08610SInochi Amaoto
1140*41b08610SInochi Amaoto static DEFINE_SG2044_GATE(CLK_GATE_INTC0, clk_gate_intc0,
1141*41b08610SInochi Amaoto clk_gate_mailbox_intc_parent,
1142*41b08610SInochi Amaoto CLK_SET_RATE_PARENT | CLK_IS_CRITICAL,
1143*41b08610SInochi Amaoto 0x020, 20, 0);
1144*41b08610SInochi Amaoto
1145*41b08610SInochi Amaoto static DEFINE_SG2044_GATE(CLK_GATE_INTC1, clk_gate_intc1,
1146*41b08610SInochi Amaoto clk_gate_mailbox_intc_parent,
1147*41b08610SInochi Amaoto CLK_SET_RATE_PARENT | CLK_IS_CRITICAL,
1148*41b08610SInochi Amaoto 0x020, 21, 0);
1149*41b08610SInochi Amaoto
1150*41b08610SInochi Amaoto static DEFINE_SG2044_GATE(CLK_GATE_INTC2, clk_gate_intc2,
1151*41b08610SInochi Amaoto clk_gate_mailbox_intc_parent,
1152*41b08610SInochi Amaoto CLK_SET_RATE_PARENT | CLK_IS_CRITICAL,
1153*41b08610SInochi Amaoto 0x020, 22, 0);
1154*41b08610SInochi Amaoto
1155*41b08610SInochi Amaoto static DEFINE_SG2044_GATE(CLK_GATE_INTC3, clk_gate_intc3,
1156*41b08610SInochi Amaoto clk_gate_mailbox_intc_parent,
1157*41b08610SInochi Amaoto CLK_SET_RATE_PARENT | CLK_IS_CRITICAL,
1158*41b08610SInochi Amaoto 0x020, 23, 0);
1159*41b08610SInochi Amaoto
1160*41b08610SInochi Amaoto static DEFINE_SG2044_GATE(CLK_GATE_MAILBOX0, clk_gate_mailbox0,
1161*41b08610SInochi Amaoto clk_gate_mailbox_intc_parent,
1162*41b08610SInochi Amaoto CLK_SET_RATE_PARENT | CLK_IS_CRITICAL,
1163*41b08610SInochi Amaoto 0x020, 16, 0);
1164*41b08610SInochi Amaoto
1165*41b08610SInochi Amaoto static DEFINE_SG2044_GATE(CLK_GATE_MAILBOX1, clk_gate_mailbox1,
1166*41b08610SInochi Amaoto clk_gate_mailbox_intc_parent,
1167*41b08610SInochi Amaoto CLK_SET_RATE_PARENT | CLK_IS_CRITICAL,
1168*41b08610SInochi Amaoto 0x020, 17, 0);
1169*41b08610SInochi Amaoto
1170*41b08610SInochi Amaoto static DEFINE_SG2044_GATE(CLK_GATE_MAILBOX2, clk_gate_mailbox2,
1171*41b08610SInochi Amaoto clk_gate_mailbox_intc_parent,
1172*41b08610SInochi Amaoto CLK_SET_RATE_PARENT | CLK_IS_CRITICAL,
1173*41b08610SInochi Amaoto 0x020, 18, 0);
1174*41b08610SInochi Amaoto
1175*41b08610SInochi Amaoto static DEFINE_SG2044_GATE(CLK_GATE_MAILBOX3, clk_gate_mailbox3,
1176*41b08610SInochi Amaoto clk_gate_mailbox_intc_parent,
1177*41b08610SInochi Amaoto CLK_SET_RATE_PARENT | CLK_IS_CRITICAL,
1178*41b08610SInochi Amaoto 0x020, 19, 0);
1179*41b08610SInochi Amaoto
1180*41b08610SInochi Amaoto static DEFINE_SG2044_GATE(CLK_GATE_TOP_AXI_HSPERI, clk_gate_top_axi_hsperi,
1181*41b08610SInochi Amaoto clk_div_top_axi_hsperi_parent,
1182*41b08610SInochi Amaoto CLK_SET_RATE_PARENT | CLK_IS_CRITICAL,
1183*41b08610SInochi Amaoto 0x008, 6, 0);
1184*41b08610SInochi Amaoto
1185*41b08610SInochi Amaoto static DEFINE_SG2044_GATE(CLK_GATE_APB_TIMER, clk_gate_apb_timer,
1186*41b08610SInochi Amaoto clk_div_top_axi0_parent,
1187*41b08610SInochi Amaoto CLK_SET_RATE_PARENT,
1188*41b08610SInochi Amaoto 0x004, 7, 0);
1189*41b08610SInochi Amaoto
1190*41b08610SInochi Amaoto static const struct clk_hw *clk_gate_timer0_parent[] = {
1191*41b08610SInochi Amaoto &clk_div_timer0.common.hw,
1192*41b08610SInochi Amaoto };
1193*41b08610SInochi Amaoto
1194*41b08610SInochi Amaoto static DEFINE_SG2044_GATE(CLK_GATE_TIMER0, clk_gate_timer0,
1195*41b08610SInochi Amaoto clk_gate_timer0_parent,
1196*41b08610SInochi Amaoto CLK_SET_RATE_PARENT,
1197*41b08610SInochi Amaoto 0x004, 8, 0);
1198*41b08610SInochi Amaoto
1199*41b08610SInochi Amaoto static const struct clk_hw *clk_gate_timer1_parent[] = {
1200*41b08610SInochi Amaoto &clk_div_timer1.common.hw,
1201*41b08610SInochi Amaoto };
1202*41b08610SInochi Amaoto
1203*41b08610SInochi Amaoto static DEFINE_SG2044_GATE(CLK_GATE_TIMER1, clk_gate_timer1,
1204*41b08610SInochi Amaoto clk_gate_timer1_parent,
1205*41b08610SInochi Amaoto CLK_SET_RATE_PARENT,
1206*41b08610SInochi Amaoto 0x004, 9, 0);
1207*41b08610SInochi Amaoto
1208*41b08610SInochi Amaoto static const struct clk_hw *clk_gate_timer2_parent[] = {
1209*41b08610SInochi Amaoto &clk_div_timer2.common.hw,
1210*41b08610SInochi Amaoto };
1211*41b08610SInochi Amaoto
1212*41b08610SInochi Amaoto static DEFINE_SG2044_GATE(CLK_GATE_TIMER2, clk_gate_timer2,
1213*41b08610SInochi Amaoto clk_gate_timer2_parent,
1214*41b08610SInochi Amaoto CLK_SET_RATE_PARENT,
1215*41b08610SInochi Amaoto 0x004, 10, 0);
1216*41b08610SInochi Amaoto
1217*41b08610SInochi Amaoto static const struct clk_hw *clk_gate_timer3_parent[] = {
1218*41b08610SInochi Amaoto &clk_div_timer3.common.hw,
1219*41b08610SInochi Amaoto };
1220*41b08610SInochi Amaoto
1221*41b08610SInochi Amaoto static DEFINE_SG2044_GATE(CLK_GATE_TIMER3, clk_gate_timer3,
1222*41b08610SInochi Amaoto clk_gate_timer3_parent,
1223*41b08610SInochi Amaoto CLK_SET_RATE_PARENT,
1224*41b08610SInochi Amaoto 0x004, 11, 0);
1225*41b08610SInochi Amaoto
1226*41b08610SInochi Amaoto static const struct clk_hw *clk_gate_timer4_parent[] = {
1227*41b08610SInochi Amaoto &clk_div_timer4.common.hw,
1228*41b08610SInochi Amaoto };
1229*41b08610SInochi Amaoto
1230*41b08610SInochi Amaoto static DEFINE_SG2044_GATE(CLK_GATE_TIMER4, clk_gate_timer4,
1231*41b08610SInochi Amaoto clk_gate_timer4_parent,
1232*41b08610SInochi Amaoto CLK_SET_RATE_PARENT,
1233*41b08610SInochi Amaoto 0x004, 12, 0);
1234*41b08610SInochi Amaoto
1235*41b08610SInochi Amaoto static const struct clk_hw *clk_gate_timer5_parent[] = {
1236*41b08610SInochi Amaoto &clk_div_timer5.common.hw,
1237*41b08610SInochi Amaoto };
1238*41b08610SInochi Amaoto
1239*41b08610SInochi Amaoto static DEFINE_SG2044_GATE(CLK_GATE_TIMER5, clk_gate_timer5,
1240*41b08610SInochi Amaoto clk_gate_timer5_parent,
1241*41b08610SInochi Amaoto CLK_SET_RATE_PARENT,
1242*41b08610SInochi Amaoto 0x004, 13, 0);
1243*41b08610SInochi Amaoto
1244*41b08610SInochi Amaoto static const struct clk_hw *clk_gate_timer6_parent[] = {
1245*41b08610SInochi Amaoto &clk_div_timer6.common.hw,
1246*41b08610SInochi Amaoto };
1247*41b08610SInochi Amaoto
1248*41b08610SInochi Amaoto static DEFINE_SG2044_GATE(CLK_GATE_TIMER6, clk_gate_timer6,
1249*41b08610SInochi Amaoto clk_gate_timer6_parent,
1250*41b08610SInochi Amaoto CLK_SET_RATE_PARENT,
1251*41b08610SInochi Amaoto 0x004, 14, 0);
1252*41b08610SInochi Amaoto
1253*41b08610SInochi Amaoto static const struct clk_hw *clk_gate_timer7_parent[] = {
1254*41b08610SInochi Amaoto &clk_div_timer7.common.hw,
1255*41b08610SInochi Amaoto };
1256*41b08610SInochi Amaoto
1257*41b08610SInochi Amaoto static DEFINE_SG2044_GATE(CLK_GATE_TIMER7, clk_gate_timer7,
1258*41b08610SInochi Amaoto clk_gate_timer7_parent,
1259*41b08610SInochi Amaoto CLK_SET_RATE_PARENT,
1260*41b08610SInochi Amaoto 0x004, 15, 0);
1261*41b08610SInochi Amaoto
1262*41b08610SInochi Amaoto static DEFINE_SG2044_GATE(CLK_GATE_CXP_CFG, clk_gate_cxp_cfg,
1263*41b08610SInochi Amaoto clk_div_top_axi0_parent,
1264*41b08610SInochi Amaoto CLK_SET_RATE_PARENT | CLK_IS_CRITICAL,
1265*41b08610SInochi Amaoto 0x000, 15, 0);
1266*41b08610SInochi Amaoto
1267*41b08610SInochi Amaoto static const struct clk_hw *clk_gate_cxp_mac_parent[] = {
1268*41b08610SInochi Amaoto &clk_mux_cxp_mac.common.hw,
1269*41b08610SInochi Amaoto };
1270*41b08610SInochi Amaoto
1271*41b08610SInochi Amaoto static DEFINE_SG2044_GATE(CLK_GATE_CXP_MAC, clk_gate_cxp_mac,
1272*41b08610SInochi Amaoto clk_gate_cxp_mac_parent,
1273*41b08610SInochi Amaoto CLK_SET_RATE_PARENT | CLK_IS_CRITICAL,
1274*41b08610SInochi Amaoto 0x000, 14, 0);
1275*41b08610SInochi Amaoto
1276*41b08610SInochi Amaoto static const struct clk_hw *clk_gate_cxp_test_phy_parent[] = {
1277*41b08610SInochi Amaoto &clk_div_cxp_test_phy.common.hw,
1278*41b08610SInochi Amaoto };
1279*41b08610SInochi Amaoto
1280*41b08610SInochi Amaoto static DEFINE_SG2044_GATE(CLK_GATE_CXP_TEST_PHY, clk_gate_cxp_test_phy,
1281*41b08610SInochi Amaoto clk_gate_cxp_test_phy_parent,
1282*41b08610SInochi Amaoto CLK_SET_RATE_PARENT,
1283*41b08610SInochi Amaoto 0x000, 6, 0);
1284*41b08610SInochi Amaoto
1285*41b08610SInochi Amaoto static const struct clk_hw *clk_gate_cxp_test_eth_phy_parent[] = {
1286*41b08610SInochi Amaoto &clk_div_cxp_test_eth_phy.common.hw,
1287*41b08610SInochi Amaoto };
1288*41b08610SInochi Amaoto
1289*41b08610SInochi Amaoto static DEFINE_SG2044_GATE(CLK_GATE_CXP_TEST_ETH_PHY, clk_gate_cxp_test_eth_phy,
1290*41b08610SInochi Amaoto clk_gate_cxp_test_eth_phy_parent,
1291*41b08610SInochi Amaoto CLK_SET_RATE_PARENT,
1292*41b08610SInochi Amaoto 0x000, 7, 0);
1293*41b08610SInochi Amaoto
1294*41b08610SInochi Amaoto static const struct clk_hw *clk_gate_pcie_1g_parent[] = {
1295*41b08610SInochi Amaoto &clk_div_pcie_1g.common.hw,
1296*41b08610SInochi Amaoto };
1297*41b08610SInochi Amaoto
1298*41b08610SInochi Amaoto static DEFINE_SG2044_GATE(CLK_GATE_PCIE_1G, clk_gate_pcie_1g,
1299*41b08610SInochi Amaoto clk_gate_pcie_1g_parent,
1300*41b08610SInochi Amaoto CLK_SET_RATE_PARENT,
1301*41b08610SInochi Amaoto 0x008, 15, 0);
1302*41b08610SInochi Amaoto
1303*41b08610SInochi Amaoto static const struct clk_hw *clk_gate_c2c0_test_phy_parent[] = {
1304*41b08610SInochi Amaoto &clk_div_c2c0_test_phy.common.hw,
1305*41b08610SInochi Amaoto };
1306*41b08610SInochi Amaoto
1307*41b08610SInochi Amaoto static DEFINE_SG2044_GATE(CLK_GATE_C2C0_TEST_PHY, clk_gate_c2c0_test_phy,
1308*41b08610SInochi Amaoto clk_gate_c2c0_test_phy_parent,
1309*41b08610SInochi Amaoto CLK_SET_RATE_PARENT,
1310*41b08610SInochi Amaoto 0x000, 4, 0);
1311*41b08610SInochi Amaoto
1312*41b08610SInochi Amaoto static const struct clk_hw *clk_gate_c2c1_test_phy_parent[] = {
1313*41b08610SInochi Amaoto &clk_div_c2c1_test_phy.common.hw,
1314*41b08610SInochi Amaoto };
1315*41b08610SInochi Amaoto
1316*41b08610SInochi Amaoto static DEFINE_SG2044_GATE(CLK_GATE_C2C1_TEST_PHY, clk_gate_c2c1_test_phy,
1317*41b08610SInochi Amaoto clk_gate_c2c1_test_phy_parent,
1318*41b08610SInochi Amaoto CLK_SET_RATE_PARENT,
1319*41b08610SInochi Amaoto 0x000, 5, 0);
1320*41b08610SInochi Amaoto
1321*41b08610SInochi Amaoto static const struct clk_hw *clk_gate_uart_500m_parent[] = {
1322*41b08610SInochi Amaoto &clk_div_uart_500m.common.hw,
1323*41b08610SInochi Amaoto };
1324*41b08610SInochi Amaoto
1325*41b08610SInochi Amaoto static DEFINE_SG2044_GATE(CLK_GATE_UART_500M, clk_gate_uart_500m,
1326*41b08610SInochi Amaoto clk_gate_uart_500m_parent,
1327*41b08610SInochi Amaoto CLK_SET_RATE_PARENT,
1328*41b08610SInochi Amaoto 0x004, 1, 0);
1329*41b08610SInochi Amaoto
1330*41b08610SInochi Amaoto static DEFINE_SG2044_GATE(CLK_GATE_APB_UART, clk_gate_apb_uart,
1331*41b08610SInochi Amaoto clk_div_top_axi_hsperi_parent,
1332*41b08610SInochi Amaoto CLK_SET_RATE_PARENT,
1333*41b08610SInochi Amaoto 0x004, 2, 0);
1334*41b08610SInochi Amaoto
1335*41b08610SInochi Amaoto static DEFINE_SG2044_GATE(CLK_GATE_APB_SPI, clk_gate_apb_spi,
1336*41b08610SInochi Amaoto clk_div_top_axi_hsperi_parent,
1337*41b08610SInochi Amaoto CLK_SET_RATE_PARENT,
1338*41b08610SInochi Amaoto 0x004, 22, 0);
1339*41b08610SInochi Amaoto
1340*41b08610SInochi Amaoto static DEFINE_SG2044_GATE(CLK_GATE_AHB_SPIFMC, clk_gate_ahb_spifmc,
1341*41b08610SInochi Amaoto clk_div_top_axi0_parent,
1342*41b08610SInochi Amaoto CLK_SET_RATE_PARENT,
1343*41b08610SInochi Amaoto 0x004, 5, 0);
1344*41b08610SInochi Amaoto
1345*41b08610SInochi Amaoto static DEFINE_SG2044_GATE(CLK_GATE_APB_I2C, clk_gate_apb_i2c,
1346*41b08610SInochi Amaoto clk_div_top_axi0_parent,
1347*41b08610SInochi Amaoto CLK_SET_RATE_PARENT | CLK_IS_CRITICAL,
1348*41b08610SInochi Amaoto 0x004, 23, 0);
1349*41b08610SInochi Amaoto
1350*41b08610SInochi Amaoto static DEFINE_SG2044_GATE(CLK_GATE_AXI_DBG_I2C, clk_gate_axi_dbg_i2c,
1351*41b08610SInochi Amaoto clk_div_top_axi_hsperi_parent,
1352*41b08610SInochi Amaoto CLK_SET_RATE_PARENT,
1353*41b08610SInochi Amaoto 0x004, 3, 0);
1354*41b08610SInochi Amaoto
1355*41b08610SInochi Amaoto static const struct clk_hw *clk_gate_gpio_db_parent[] = {
1356*41b08610SInochi Amaoto &clk_div_gpio_db.common.hw,
1357*41b08610SInochi Amaoto };
1358*41b08610SInochi Amaoto
1359*41b08610SInochi Amaoto static DEFINE_SG2044_GATE(CLK_GATE_GPIO_DB, clk_gate_gpio_db,
1360*41b08610SInochi Amaoto clk_gate_gpio_db_parent,
1361*41b08610SInochi Amaoto CLK_SET_RATE_PARENT | CLK_IS_CRITICAL,
1362*41b08610SInochi Amaoto 0x004, 21, 0);
1363*41b08610SInochi Amaoto
1364*41b08610SInochi Amaoto static DEFINE_SG2044_GATE(CLK_GATE_APB_GPIO_INTR, clk_gate_apb_gpio_intr,
1365*41b08610SInochi Amaoto clk_div_top_axi0_parent,
1366*41b08610SInochi Amaoto CLK_SET_RATE_PARENT | CLK_IS_CRITICAL,
1367*41b08610SInochi Amaoto 0x004, 20, 0);
1368*41b08610SInochi Amaoto
1369*41b08610SInochi Amaoto static DEFINE_SG2044_GATE(CLK_GATE_APB_GPIO, clk_gate_apb_gpio,
1370*41b08610SInochi Amaoto clk_div_top_axi0_parent,
1371*41b08610SInochi Amaoto CLK_SET_RATE_PARENT | CLK_IS_CRITICAL,
1372*41b08610SInochi Amaoto 0x004, 19, 0);
1373*41b08610SInochi Amaoto
1374*41b08610SInochi Amaoto static const struct clk_hw *clk_gate_sd_parent[] = {
1375*41b08610SInochi Amaoto &clk_div_sd.common.hw,
1376*41b08610SInochi Amaoto };
1377*41b08610SInochi Amaoto
1378*41b08610SInochi Amaoto static DEFINE_SG2044_GATE(CLK_GATE_SD, clk_gate_sd,
1379*41b08610SInochi Amaoto clk_gate_sd_parent,
1380*41b08610SInochi Amaoto CLK_SET_RATE_PARENT,
1381*41b08610SInochi Amaoto 0x008, 3, 0);
1382*41b08610SInochi Amaoto
1383*41b08610SInochi Amaoto static DEFINE_SG2044_GATE(CLK_GATE_AXI_SD, clk_gate_axi_sd,
1384*41b08610SInochi Amaoto clk_div_top_axi_hsperi_parent,
1385*41b08610SInochi Amaoto CLK_SET_RATE_PARENT,
1386*41b08610SInochi Amaoto 0x008, 2, 0);
1387*41b08610SInochi Amaoto
1388*41b08610SInochi Amaoto static const struct clk_hw *clk_gate_sd_100k_parent[] = {
1389*41b08610SInochi Amaoto &clk_div_sd_100k.common.hw,
1390*41b08610SInochi Amaoto };
1391*41b08610SInochi Amaoto
1392*41b08610SInochi Amaoto static DEFINE_SG2044_GATE(CLK_GATE_SD_100K, clk_gate_sd_100k,
1393*41b08610SInochi Amaoto clk_gate_sd_100k_parent,
1394*41b08610SInochi Amaoto CLK_SET_RATE_PARENT,
1395*41b08610SInochi Amaoto 0x008, 4, 0);
1396*41b08610SInochi Amaoto
1397*41b08610SInochi Amaoto static const struct clk_hw *clk_gate_emmc_parent[] = {
1398*41b08610SInochi Amaoto &clk_div_emmc.common.hw,
1399*41b08610SInochi Amaoto };
1400*41b08610SInochi Amaoto
1401*41b08610SInochi Amaoto static DEFINE_SG2044_GATE(CLK_GATE_EMMC, clk_gate_emmc,
1402*41b08610SInochi Amaoto clk_gate_emmc_parent,
1403*41b08610SInochi Amaoto CLK_SET_RATE_PARENT,
1404*41b08610SInochi Amaoto 0x008, 0, 0);
1405*41b08610SInochi Amaoto
1406*41b08610SInochi Amaoto static DEFINE_SG2044_GATE(CLK_GATE_AXI_EMMC, clk_gate_axi_emmc,
1407*41b08610SInochi Amaoto clk_div_top_axi_hsperi_parent,
1408*41b08610SInochi Amaoto CLK_SET_RATE_PARENT,
1409*41b08610SInochi Amaoto 0x004, 31, 0);
1410*41b08610SInochi Amaoto
1411*41b08610SInochi Amaoto static const struct clk_hw *clk_gate_emmc_100k_parent[] = {
1412*41b08610SInochi Amaoto &clk_div_emmc_100k.common.hw,
1413*41b08610SInochi Amaoto };
1414*41b08610SInochi Amaoto
1415*41b08610SInochi Amaoto static DEFINE_SG2044_GATE(CLK_GATE_EMMC_100K, clk_gate_emmc_100k,
1416*41b08610SInochi Amaoto clk_gate_emmc_100k_parent,
1417*41b08610SInochi Amaoto CLK_SET_RATE_PARENT,
1418*41b08610SInochi Amaoto 0x008, 1, 0);
1419*41b08610SInochi Amaoto
1420*41b08610SInochi Amaoto static const struct clk_hw *clk_gate_efuse_parent[] = {
1421*41b08610SInochi Amaoto &clk_div_efuse.common.hw,
1422*41b08610SInochi Amaoto };
1423*41b08610SInochi Amaoto
1424*41b08610SInochi Amaoto static DEFINE_SG2044_GATE(CLK_GATE_EFUSE, clk_gate_efuse,
1425*41b08610SInochi Amaoto clk_gate_efuse_parent,
1426*41b08610SInochi Amaoto CLK_SET_RATE_PARENT,
1427*41b08610SInochi Amaoto 0x004, 17, 0);
1428*41b08610SInochi Amaoto
1429*41b08610SInochi Amaoto static DEFINE_SG2044_GATE(CLK_GATE_APB_EFUSE, clk_gate_apb_efuse,
1430*41b08610SInochi Amaoto clk_div_top_axi0_parent,
1431*41b08610SInochi Amaoto CLK_SET_RATE_PARENT,
1432*41b08610SInochi Amaoto 0x004, 18, 0);
1433*41b08610SInochi Amaoto
1434*41b08610SInochi Amaoto static DEFINE_SG2044_GATE(CLK_GATE_SYSDMA_AXI, clk_gate_sysdma_axi,
1435*41b08610SInochi Amaoto clk_div_top_axi_hsperi_parent,
1436*41b08610SInochi Amaoto CLK_SET_RATE_PARENT,
1437*41b08610SInochi Amaoto 0x004, 0, 0);
1438*41b08610SInochi Amaoto
1439*41b08610SInochi Amaoto static const struct clk_hw *clk_gate_tx_eth0_parent[] = {
1440*41b08610SInochi Amaoto &clk_div_tx_eth0.common.hw,
1441*41b08610SInochi Amaoto };
1442*41b08610SInochi Amaoto
1443*41b08610SInochi Amaoto static DEFINE_SG2044_GATE(CLK_GATE_TX_ETH0, clk_gate_tx_eth0,
1444*41b08610SInochi Amaoto clk_gate_tx_eth0_parent,
1445*41b08610SInochi Amaoto CLK_SET_RATE_PARENT,
1446*41b08610SInochi Amaoto 0x004, 27, 0);
1447*41b08610SInochi Amaoto
1448*41b08610SInochi Amaoto static DEFINE_SG2044_GATE(CLK_GATE_AXI_ETH0, clk_gate_axi_eth0,
1449*41b08610SInochi Amaoto clk_div_top_axi_hsperi_parent,
1450*41b08610SInochi Amaoto CLK_SET_RATE_PARENT,
1451*41b08610SInochi Amaoto 0x004, 28, 0);
1452*41b08610SInochi Amaoto
1453*41b08610SInochi Amaoto static const struct clk_hw *clk_gate_ptp_ref_i_eth0_parent[] = {
1454*41b08610SInochi Amaoto &clk_div_ptp_ref_i_eth0.common.hw,
1455*41b08610SInochi Amaoto };
1456*41b08610SInochi Amaoto
1457*41b08610SInochi Amaoto static DEFINE_SG2044_GATE(CLK_GATE_PTP_REF_I_ETH0, clk_gate_ptp_ref_i_eth0,
1458*41b08610SInochi Amaoto clk_gate_ptp_ref_i_eth0_parent,
1459*41b08610SInochi Amaoto CLK_SET_RATE_PARENT,
1460*41b08610SInochi Amaoto 0x004, 29, 0);
1461*41b08610SInochi Amaoto
1462*41b08610SInochi Amaoto static const struct clk_hw *clk_gate_ref_eth0_parent[] = {
1463*41b08610SInochi Amaoto &clk_div_ref_eth0.common.hw,
1464*41b08610SInochi Amaoto };
1465*41b08610SInochi Amaoto
1466*41b08610SInochi Amaoto static DEFINE_SG2044_GATE(CLK_GATE_REF_ETH0, clk_gate_ref_eth0,
1467*41b08610SInochi Amaoto clk_gate_ref_eth0_parent,
1468*41b08610SInochi Amaoto CLK_SET_RATE_PARENT,
1469*41b08610SInochi Amaoto 0x004, 30, 0);
1470*41b08610SInochi Amaoto
1471*41b08610SInochi Amaoto static DEFINE_SG2044_GATE(CLK_GATE_APB_RTC, clk_gate_apb_rtc,
1472*41b08610SInochi Amaoto clk_div_top_axi0_parent,
1473*41b08610SInochi Amaoto CLK_SET_RATE_PARENT | CLK_IS_CRITICAL,
1474*41b08610SInochi Amaoto 0x004, 26, 0);
1475*41b08610SInochi Amaoto
1476*41b08610SInochi Amaoto static DEFINE_SG2044_GATE(CLK_GATE_APB_PWM, clk_gate_apb_pwm,
1477*41b08610SInochi Amaoto clk_div_top_axi0_parent,
1478*41b08610SInochi Amaoto CLK_SET_RATE_PARENT,
1479*41b08610SInochi Amaoto 0x004, 25, 0);
1480*41b08610SInochi Amaoto
1481*41b08610SInochi Amaoto static DEFINE_SG2044_GATE(CLK_GATE_APB_WDT, clk_gate_apb_wdt,
1482*41b08610SInochi Amaoto clk_div_top_axi0_parent,
1483*41b08610SInochi Amaoto CLK_SET_RATE_PARENT,
1484*41b08610SInochi Amaoto 0x004, 24, 0);
1485*41b08610SInochi Amaoto
1486*41b08610SInochi Amaoto static DEFINE_SG2044_GATE(CLK_GATE_AXI_SRAM, clk_gate_axi_sram,
1487*41b08610SInochi Amaoto clk_div_top_axi0_parent,
1488*41b08610SInochi Amaoto CLK_SET_RATE_PARENT | CLK_IS_CRITICAL,
1489*41b08610SInochi Amaoto 0x004, 6, 0);
1490*41b08610SInochi Amaoto
1491*41b08610SInochi Amaoto static DEFINE_SG2044_GATE(CLK_GATE_AHB_ROM, clk_gate_ahb_rom,
1492*41b08610SInochi Amaoto clk_div_top_axi0_parent,
1493*41b08610SInochi Amaoto CLK_SET_RATE_PARENT | CLK_IS_CRITICAL,
1494*41b08610SInochi Amaoto 0x004, 4, 0);
1495*41b08610SInochi Amaoto
1496*41b08610SInochi Amaoto static const struct clk_hw *clk_gate_pka_parent[] = {
1497*41b08610SInochi Amaoto &clk_div_pka.common.hw,
1498*41b08610SInochi Amaoto };
1499*41b08610SInochi Amaoto
1500*41b08610SInochi Amaoto static DEFINE_SG2044_GATE(CLK_GATE_PKA, clk_gate_pka,
1501*41b08610SInochi Amaoto clk_gate_pka_parent,
1502*41b08610SInochi Amaoto CLK_SET_RATE_PARENT,
1503*41b08610SInochi Amaoto 0x004, 16, 0);
1504*41b08610SInochi Amaoto
1505*41b08610SInochi Amaoto static struct sg2044_clk_common * const sg2044_div_commons[] = {
1506*41b08610SInochi Amaoto &clk_div_ap_sys_fixed.common,
1507*41b08610SInochi Amaoto &clk_div_ap_sys_main.common,
1508*41b08610SInochi Amaoto &clk_div_rp_sys_fixed.common,
1509*41b08610SInochi Amaoto &clk_div_rp_sys_main.common,
1510*41b08610SInochi Amaoto &clk_div_tpu_sys_fixed.common,
1511*41b08610SInochi Amaoto &clk_div_tpu_sys_main.common,
1512*41b08610SInochi Amaoto &clk_div_noc_sys_fixed.common,
1513*41b08610SInochi Amaoto &clk_div_noc_sys_main.common,
1514*41b08610SInochi Amaoto &clk_div_vc_src0_fixed.common,
1515*41b08610SInochi Amaoto &clk_div_vc_src0_main.common,
1516*41b08610SInochi Amaoto &clk_div_vc_src1_fixed.common,
1517*41b08610SInochi Amaoto &clk_div_vc_src1_main.common,
1518*41b08610SInochi Amaoto &clk_div_cxp_mac_fixed.common,
1519*41b08610SInochi Amaoto &clk_div_cxp_mac_main.common,
1520*41b08610SInochi Amaoto &clk_div_ddr0_fixed.common,
1521*41b08610SInochi Amaoto &clk_div_ddr0_main.common,
1522*41b08610SInochi Amaoto &clk_div_ddr1_fixed.common,
1523*41b08610SInochi Amaoto &clk_div_ddr1_main.common,
1524*41b08610SInochi Amaoto &clk_div_ddr2_fixed.common,
1525*41b08610SInochi Amaoto &clk_div_ddr2_main.common,
1526*41b08610SInochi Amaoto &clk_div_ddr3_fixed.common,
1527*41b08610SInochi Amaoto &clk_div_ddr3_main.common,
1528*41b08610SInochi Amaoto &clk_div_ddr4_fixed.common,
1529*41b08610SInochi Amaoto &clk_div_ddr4_main.common,
1530*41b08610SInochi Amaoto &clk_div_ddr5_fixed.common,
1531*41b08610SInochi Amaoto &clk_div_ddr5_main.common,
1532*41b08610SInochi Amaoto &clk_div_ddr6_fixed.common,
1533*41b08610SInochi Amaoto &clk_div_ddr6_main.common,
1534*41b08610SInochi Amaoto &clk_div_ddr7_fixed.common,
1535*41b08610SInochi Amaoto &clk_div_ddr7_main.common,
1536*41b08610SInochi Amaoto &clk_div_top_50m.common,
1537*41b08610SInochi Amaoto &clk_div_top_axi0.common,
1538*41b08610SInochi Amaoto &clk_div_top_axi_hsperi.common,
1539*41b08610SInochi Amaoto &clk_div_timer0.common,
1540*41b08610SInochi Amaoto &clk_div_timer1.common,
1541*41b08610SInochi Amaoto &clk_div_timer2.common,
1542*41b08610SInochi Amaoto &clk_div_timer3.common,
1543*41b08610SInochi Amaoto &clk_div_timer4.common,
1544*41b08610SInochi Amaoto &clk_div_timer5.common,
1545*41b08610SInochi Amaoto &clk_div_timer6.common,
1546*41b08610SInochi Amaoto &clk_div_timer7.common,
1547*41b08610SInochi Amaoto &clk_div_cxp_test_phy.common,
1548*41b08610SInochi Amaoto &clk_div_cxp_test_eth_phy.common,
1549*41b08610SInochi Amaoto &clk_div_c2c0_test_phy.common,
1550*41b08610SInochi Amaoto &clk_div_c2c1_test_phy.common,
1551*41b08610SInochi Amaoto &clk_div_pcie_1g.common,
1552*41b08610SInochi Amaoto &clk_div_uart_500m.common,
1553*41b08610SInochi Amaoto &clk_div_gpio_db.common,
1554*41b08610SInochi Amaoto &clk_div_sd.common,
1555*41b08610SInochi Amaoto &clk_div_sd_100k.common,
1556*41b08610SInochi Amaoto &clk_div_emmc.common,
1557*41b08610SInochi Amaoto &clk_div_emmc_100k.common,
1558*41b08610SInochi Amaoto &clk_div_efuse.common,
1559*41b08610SInochi Amaoto &clk_div_tx_eth0.common,
1560*41b08610SInochi Amaoto &clk_div_ptp_ref_i_eth0.common,
1561*41b08610SInochi Amaoto &clk_div_ref_eth0.common,
1562*41b08610SInochi Amaoto &clk_div_pka.common,
1563*41b08610SInochi Amaoto };
1564*41b08610SInochi Amaoto
1565*41b08610SInochi Amaoto static struct sg2044_clk_common * const sg2044_mux_commons[] = {
1566*41b08610SInochi Amaoto &clk_mux_ddr0.common,
1567*41b08610SInochi Amaoto &clk_mux_ddr1.common,
1568*41b08610SInochi Amaoto &clk_mux_ddr2.common,
1569*41b08610SInochi Amaoto &clk_mux_ddr3.common,
1570*41b08610SInochi Amaoto &clk_mux_ddr4.common,
1571*41b08610SInochi Amaoto &clk_mux_ddr5.common,
1572*41b08610SInochi Amaoto &clk_mux_ddr6.common,
1573*41b08610SInochi Amaoto &clk_mux_ddr7.common,
1574*41b08610SInochi Amaoto &clk_mux_noc_sys.common,
1575*41b08610SInochi Amaoto &clk_mux_tpu_sys.common,
1576*41b08610SInochi Amaoto &clk_mux_rp_sys.common,
1577*41b08610SInochi Amaoto &clk_mux_ap_sys.common,
1578*41b08610SInochi Amaoto &clk_mux_vc_src0.common,
1579*41b08610SInochi Amaoto &clk_mux_vc_src1.common,
1580*41b08610SInochi Amaoto &clk_mux_cxp_mac.common,
1581*41b08610SInochi Amaoto };
1582*41b08610SInochi Amaoto
1583*41b08610SInochi Amaoto static struct sg2044_clk_common * const sg2044_gate_commons[] = {
1584*41b08610SInochi Amaoto &clk_gate_ap_sys.common,
1585*41b08610SInochi Amaoto &clk_gate_rp_sys.common,
1586*41b08610SInochi Amaoto &clk_gate_tpu_sys.common,
1587*41b08610SInochi Amaoto &clk_gate_noc_sys.common,
1588*41b08610SInochi Amaoto &clk_gate_vc_src0.common,
1589*41b08610SInochi Amaoto &clk_gate_vc_src1.common,
1590*41b08610SInochi Amaoto &clk_gate_ddr0.common,
1591*41b08610SInochi Amaoto &clk_gate_ddr1.common,
1592*41b08610SInochi Amaoto &clk_gate_ddr2.common,
1593*41b08610SInochi Amaoto &clk_gate_ddr3.common,
1594*41b08610SInochi Amaoto &clk_gate_ddr4.common,
1595*41b08610SInochi Amaoto &clk_gate_ddr5.common,
1596*41b08610SInochi Amaoto &clk_gate_ddr6.common,
1597*41b08610SInochi Amaoto &clk_gate_ddr7.common,
1598*41b08610SInochi Amaoto &clk_gate_top_50m.common,
1599*41b08610SInochi Amaoto &clk_gate_sc_rx.common,
1600*41b08610SInochi Amaoto &clk_gate_sc_rx_x0y1.common,
1601*41b08610SInochi Amaoto &clk_gate_top_axi0.common,
1602*41b08610SInochi Amaoto &clk_gate_intc0.common,
1603*41b08610SInochi Amaoto &clk_gate_intc1.common,
1604*41b08610SInochi Amaoto &clk_gate_intc2.common,
1605*41b08610SInochi Amaoto &clk_gate_intc3.common,
1606*41b08610SInochi Amaoto &clk_gate_mailbox0.common,
1607*41b08610SInochi Amaoto &clk_gate_mailbox1.common,
1608*41b08610SInochi Amaoto &clk_gate_mailbox2.common,
1609*41b08610SInochi Amaoto &clk_gate_mailbox3.common,
1610*41b08610SInochi Amaoto &clk_gate_top_axi_hsperi.common,
1611*41b08610SInochi Amaoto &clk_gate_apb_timer.common,
1612*41b08610SInochi Amaoto &clk_gate_timer0.common,
1613*41b08610SInochi Amaoto &clk_gate_timer1.common,
1614*41b08610SInochi Amaoto &clk_gate_timer2.common,
1615*41b08610SInochi Amaoto &clk_gate_timer3.common,
1616*41b08610SInochi Amaoto &clk_gate_timer4.common,
1617*41b08610SInochi Amaoto &clk_gate_timer5.common,
1618*41b08610SInochi Amaoto &clk_gate_timer6.common,
1619*41b08610SInochi Amaoto &clk_gate_timer7.common,
1620*41b08610SInochi Amaoto &clk_gate_cxp_cfg.common,
1621*41b08610SInochi Amaoto &clk_gate_cxp_mac.common,
1622*41b08610SInochi Amaoto &clk_gate_cxp_test_phy.common,
1623*41b08610SInochi Amaoto &clk_gate_cxp_test_eth_phy.common,
1624*41b08610SInochi Amaoto &clk_gate_pcie_1g.common,
1625*41b08610SInochi Amaoto &clk_gate_c2c0_test_phy.common,
1626*41b08610SInochi Amaoto &clk_gate_c2c1_test_phy.common,
1627*41b08610SInochi Amaoto &clk_gate_uart_500m.common,
1628*41b08610SInochi Amaoto &clk_gate_apb_uart.common,
1629*41b08610SInochi Amaoto &clk_gate_apb_spi.common,
1630*41b08610SInochi Amaoto &clk_gate_ahb_spifmc.common,
1631*41b08610SInochi Amaoto &clk_gate_apb_i2c.common,
1632*41b08610SInochi Amaoto &clk_gate_axi_dbg_i2c.common,
1633*41b08610SInochi Amaoto &clk_gate_gpio_db.common,
1634*41b08610SInochi Amaoto &clk_gate_apb_gpio_intr.common,
1635*41b08610SInochi Amaoto &clk_gate_apb_gpio.common,
1636*41b08610SInochi Amaoto &clk_gate_sd.common,
1637*41b08610SInochi Amaoto &clk_gate_axi_sd.common,
1638*41b08610SInochi Amaoto &clk_gate_sd_100k.common,
1639*41b08610SInochi Amaoto &clk_gate_emmc.common,
1640*41b08610SInochi Amaoto &clk_gate_axi_emmc.common,
1641*41b08610SInochi Amaoto &clk_gate_emmc_100k.common,
1642*41b08610SInochi Amaoto &clk_gate_efuse.common,
1643*41b08610SInochi Amaoto &clk_gate_apb_efuse.common,
1644*41b08610SInochi Amaoto &clk_gate_sysdma_axi.common,
1645*41b08610SInochi Amaoto &clk_gate_tx_eth0.common,
1646*41b08610SInochi Amaoto &clk_gate_axi_eth0.common,
1647*41b08610SInochi Amaoto &clk_gate_ptp_ref_i_eth0.common,
1648*41b08610SInochi Amaoto &clk_gate_ref_eth0.common,
1649*41b08610SInochi Amaoto &clk_gate_apb_rtc.common,
1650*41b08610SInochi Amaoto &clk_gate_apb_pwm.common,
1651*41b08610SInochi Amaoto &clk_gate_apb_wdt.common,
1652*41b08610SInochi Amaoto &clk_gate_axi_sram.common,
1653*41b08610SInochi Amaoto &clk_gate_ahb_rom.common,
1654*41b08610SInochi Amaoto &clk_gate_pka.common,
1655*41b08610SInochi Amaoto };
1656*41b08610SInochi Amaoto
sg2044_clk_fix_init_parent(struct clk_hw ** pdata,const struct clk_init_data * init,struct clk_hw_onecell_data * data)1657*41b08610SInochi Amaoto static void sg2044_clk_fix_init_parent(struct clk_hw **pdata,
1658*41b08610SInochi Amaoto const struct clk_init_data *init,
1659*41b08610SInochi Amaoto struct clk_hw_onecell_data *data)
1660*41b08610SInochi Amaoto {
1661*41b08610SInochi Amaoto u8 i;
1662*41b08610SInochi Amaoto const struct clk_hw *hw;
1663*41b08610SInochi Amaoto const struct sg2044_clk_common *common;
1664*41b08610SInochi Amaoto
1665*41b08610SInochi Amaoto for (i = 0; i < init->num_parents; i++) {
1666*41b08610SInochi Amaoto hw = init->parent_hws[i];
1667*41b08610SInochi Amaoto common = hw_to_sg2044_clk_common(hw);
1668*41b08610SInochi Amaoto
1669*41b08610SInochi Amaoto WARN(!data->hws[common->id], "clk %u is not register\n",
1670*41b08610SInochi Amaoto common->id);
1671*41b08610SInochi Amaoto pdata[i] = data->hws[common->id];
1672*41b08610SInochi Amaoto }
1673*41b08610SInochi Amaoto }
1674*41b08610SInochi Amaoto
sg2044_clk_init_ctrl(struct device * dev,void __iomem * reg,struct sg2044_clk_ctrl * ctrl,const struct sg2044_clk_desc_data * desc)1675*41b08610SInochi Amaoto static int sg2044_clk_init_ctrl(struct device *dev, void __iomem *reg,
1676*41b08610SInochi Amaoto struct sg2044_clk_ctrl *ctrl,
1677*41b08610SInochi Amaoto const struct sg2044_clk_desc_data *desc)
1678*41b08610SInochi Amaoto {
1679*41b08610SInochi Amaoto int ret, i;
1680*41b08610SInochi Amaoto struct clk_hw *hw;
1681*41b08610SInochi Amaoto
1682*41b08610SInochi Amaoto spin_lock_init(&ctrl->lock);
1683*41b08610SInochi Amaoto
1684*41b08610SInochi Amaoto for (i = 0; i < desc->num_div; i++) {
1685*41b08610SInochi Amaoto struct sg2044_clk_common *common = desc->div[i];
1686*41b08610SInochi Amaoto
1687*41b08610SInochi Amaoto common->lock = &ctrl->lock;
1688*41b08610SInochi Amaoto common->base = reg;
1689*41b08610SInochi Amaoto
1690*41b08610SInochi Amaoto ret = devm_clk_hw_register(dev, &common->hw);
1691*41b08610SInochi Amaoto if (ret)
1692*41b08610SInochi Amaoto return ret;
1693*41b08610SInochi Amaoto
1694*41b08610SInochi Amaoto ctrl->data.hws[common->id] = &common->hw;
1695*41b08610SInochi Amaoto }
1696*41b08610SInochi Amaoto
1697*41b08610SInochi Amaoto for (i = 0; i < desc->num_mux; i++) {
1698*41b08610SInochi Amaoto struct sg2044_clk_common *common = desc->mux[i];
1699*41b08610SInochi Amaoto struct sg2044_mux *mux = hw_to_sg2044_mux(&common->hw);
1700*41b08610SInochi Amaoto const struct clk_init_data *init = common->hw.init;
1701*41b08610SInochi Amaoto
1702*41b08610SInochi Amaoto common->lock = &ctrl->lock;
1703*41b08610SInochi Amaoto common->base = reg;
1704*41b08610SInochi Amaoto
1705*41b08610SInochi Amaoto hw = devm_clk_hw_register_mux_parent_data_table(dev,
1706*41b08610SInochi Amaoto init->name,
1707*41b08610SInochi Amaoto init->parent_data,
1708*41b08610SInochi Amaoto init->num_parents,
1709*41b08610SInochi Amaoto init->flags,
1710*41b08610SInochi Amaoto reg + mux->mux.offset,
1711*41b08610SInochi Amaoto mux->mux.shift,
1712*41b08610SInochi Amaoto 1,
1713*41b08610SInochi Amaoto mux->mux.flags,
1714*41b08610SInochi Amaoto mux->mux.table,
1715*41b08610SInochi Amaoto &ctrl->lock);
1716*41b08610SInochi Amaoto if (IS_ERR(hw))
1717*41b08610SInochi Amaoto return PTR_ERR(hw);
1718*41b08610SInochi Amaoto
1719*41b08610SInochi Amaoto if (!(mux->mux.flags & CLK_MUX_READ_ONLY)) {
1720*41b08610SInochi Amaoto mux->nb.notifier_call = sg2044_mux_notifier_cb;
1721*41b08610SInochi Amaoto ret = devm_clk_notifier_register(dev, hw->clk,
1722*41b08610SInochi Amaoto &mux->nb);
1723*41b08610SInochi Amaoto if (ret < 0)
1724*41b08610SInochi Amaoto return dev_err_probe(dev, ret,
1725*41b08610SInochi Amaoto "%s: failed to register notifier\n",
1726*41b08610SInochi Amaoto clk_hw_get_name(hw));
1727*41b08610SInochi Amaoto }
1728*41b08610SInochi Amaoto
1729*41b08610SInochi Amaoto ctrl->data.hws[common->id] = hw;
1730*41b08610SInochi Amaoto }
1731*41b08610SInochi Amaoto
1732*41b08610SInochi Amaoto for (i = 0; i < desc->num_gate; i++) {
1733*41b08610SInochi Amaoto struct sg2044_clk_common *common = desc->gate[i];
1734*41b08610SInochi Amaoto struct sg2044_gate *gate = hw_to_sg2044_gate(&common->hw);
1735*41b08610SInochi Amaoto const struct clk_init_data *init = common->hw.init;
1736*41b08610SInochi Amaoto struct clk_hw *parent_hws[1] = { };
1737*41b08610SInochi Amaoto
1738*41b08610SInochi Amaoto sg2044_clk_fix_init_parent(parent_hws, init, &ctrl->data);
1739*41b08610SInochi Amaoto common->lock = &ctrl->lock;
1740*41b08610SInochi Amaoto common->base = reg;
1741*41b08610SInochi Amaoto
1742*41b08610SInochi Amaoto hw = devm_clk_hw_register_gate_parent_hw(dev, init->name,
1743*41b08610SInochi Amaoto parent_hws[0],
1744*41b08610SInochi Amaoto init->flags,
1745*41b08610SInochi Amaoto reg + gate->gate.offset,
1746*41b08610SInochi Amaoto gate->gate.shift,
1747*41b08610SInochi Amaoto gate->gate.flags,
1748*41b08610SInochi Amaoto &ctrl->lock);
1749*41b08610SInochi Amaoto if (IS_ERR(hw))
1750*41b08610SInochi Amaoto return PTR_ERR(hw);
1751*41b08610SInochi Amaoto
1752*41b08610SInochi Amaoto ctrl->data.hws[common->id] = hw;
1753*41b08610SInochi Amaoto }
1754*41b08610SInochi Amaoto
1755*41b08610SInochi Amaoto return devm_of_clk_add_hw_provider(dev, of_clk_hw_onecell_get,
1756*41b08610SInochi Amaoto &ctrl->data);
1757*41b08610SInochi Amaoto }
1758*41b08610SInochi Amaoto
sg2044_clk_probe(struct platform_device * pdev)1759*41b08610SInochi Amaoto static int sg2044_clk_probe(struct platform_device *pdev)
1760*41b08610SInochi Amaoto {
1761*41b08610SInochi Amaoto struct device *dev = &pdev->dev;
1762*41b08610SInochi Amaoto struct sg2044_clk_ctrl *ctrl;
1763*41b08610SInochi Amaoto const struct sg2044_clk_desc_data *desc;
1764*41b08610SInochi Amaoto void __iomem *reg;
1765*41b08610SInochi Amaoto u32 num_clks;
1766*41b08610SInochi Amaoto
1767*41b08610SInochi Amaoto reg = devm_platform_ioremap_resource(pdev, 0);
1768*41b08610SInochi Amaoto if (IS_ERR(reg))
1769*41b08610SInochi Amaoto return PTR_ERR(reg);
1770*41b08610SInochi Amaoto
1771*41b08610SInochi Amaoto desc = device_get_match_data(dev);
1772*41b08610SInochi Amaoto if (!desc)
1773*41b08610SInochi Amaoto return dev_err_probe(dev, -EINVAL, "no match data for platform\n");
1774*41b08610SInochi Amaoto
1775*41b08610SInochi Amaoto num_clks = desc->num_div + desc->num_gate + desc->num_mux;
1776*41b08610SInochi Amaoto
1777*41b08610SInochi Amaoto ctrl = devm_kzalloc(dev, struct_size(ctrl, data.hws, num_clks), GFP_KERNEL);
1778*41b08610SInochi Amaoto if (!ctrl)
1779*41b08610SInochi Amaoto return -ENOMEM;
1780*41b08610SInochi Amaoto
1781*41b08610SInochi Amaoto ctrl->data.num = num_clks;
1782*41b08610SInochi Amaoto
1783*41b08610SInochi Amaoto return sg2044_clk_init_ctrl(dev, reg, ctrl, desc);
1784*41b08610SInochi Amaoto }
1785*41b08610SInochi Amaoto
1786*41b08610SInochi Amaoto static const struct sg2044_clk_desc_data sg2044_clk_desc_data = {
1787*41b08610SInochi Amaoto .div = sg2044_div_commons,
1788*41b08610SInochi Amaoto .mux = sg2044_mux_commons,
1789*41b08610SInochi Amaoto .gate = sg2044_gate_commons,
1790*41b08610SInochi Amaoto .num_div = ARRAY_SIZE(sg2044_div_commons),
1791*41b08610SInochi Amaoto .num_mux = ARRAY_SIZE(sg2044_mux_commons),
1792*41b08610SInochi Amaoto .num_gate = ARRAY_SIZE(sg2044_gate_commons),
1793*41b08610SInochi Amaoto };
1794*41b08610SInochi Amaoto
1795*41b08610SInochi Amaoto static const struct of_device_id sg2044_clk_match[] = {
1796*41b08610SInochi Amaoto { .compatible = "sophgo,sg2044-clk", .data = &sg2044_clk_desc_data },
1797*41b08610SInochi Amaoto { /* sentinel */ }
1798*41b08610SInochi Amaoto };
1799*41b08610SInochi Amaoto MODULE_DEVICE_TABLE(of, sg2044_clk_match);
1800*41b08610SInochi Amaoto
1801*41b08610SInochi Amaoto static struct platform_driver sg2044_clk_driver = {
1802*41b08610SInochi Amaoto .probe = sg2044_clk_probe,
1803*41b08610SInochi Amaoto .driver = {
1804*41b08610SInochi Amaoto .name = "sg2044-clk",
1805*41b08610SInochi Amaoto .of_match_table = sg2044_clk_match,
1806*41b08610SInochi Amaoto },
1807*41b08610SInochi Amaoto };
1808*41b08610SInochi Amaoto module_platform_driver(sg2044_clk_driver);
1809*41b08610SInochi Amaoto
1810*41b08610SInochi Amaoto MODULE_AUTHOR("Inochi Amaoto <inochiama@gmail.com>");
1811*41b08610SInochi Amaoto MODULE_DESCRIPTION("Sophgo SG2044 clock driver");
1812*41b08610SInochi Amaoto MODULE_LICENSE("GPL");
1813