blob: bc5bb6ac86364b362985a8b85cecc9ce956e0e9d [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001/* SPDX-License-Identifier: GPL-2.0 */
Sascha Hauer6c7b068502012-03-07 21:01:28 +01002#ifndef __MACH_IMX_CLK_H
3#define __MACH_IMX_CLK_H
4
5#include <linux/spinlock.h>
6#include <linux/clk-provider.h>
Sascha Hauer3a84d172012-09-11 08:50:00 +02007
8extern spinlock_t imx_ccm_lock;
Sascha Hauer6c7b068502012-03-07 21:01:28 +01009
Alexander Shiyan229be9c2014-06-10 19:40:26 +040010void imx_check_clocks(struct clk *clks[], unsigned int count);
A.s. Dong3b315212018-11-14 13:02:04 +000011void imx_check_clk_hws(struct clk_hw *clks[], unsigned int count);
Lucas Stach55adc612015-09-21 18:53:57 +020012void imx_register_uart_clocks(struct clk ** const clks[]);
Anson Huangefdb2792019-05-12 10:24:12 +000013void imx_mmdc_mask_handshake(void __iomem *ccm_base, unsigned int chn);
Anson Huangfd6ef282019-06-19 13:52:45 +080014void imx_unregister_clocks(struct clk *clks[], unsigned int count);
Alexander Shiyan229be9c2014-06-10 19:40:26 +040015
Liu Yingdfd87142013-07-04 17:57:17 +080016extern void imx_cscmr1_fixup(u32 *val);
17
Shawn Guo3bec5f82015-04-26 13:33:39 +080018enum imx_pllv1_type {
19 IMX_PLLV1_IMX1,
20 IMX_PLLV1_IMX21,
21 IMX_PLLV1_IMX25,
22 IMX_PLLV1_IMX27,
23 IMX_PLLV1_IMX31,
24 IMX_PLLV1_IMX35,
25};
26
Lucas Stachff70fbd2018-12-01 10:52:13 +000027enum imx_sccg_pll_type {
28 SCCG_PLL1,
29 SCCG_PLL2,
30};
31
Bai Ping8646d4d2019-01-22 09:31:41 +000032enum imx_pll14xx_type {
33 PLL_1416X,
34 PLL_1443X,
35};
36
37/* NOTE: Rate table should be kept sorted in descending order. */
38struct imx_pll14xx_rate_table {
39 unsigned int rate;
40 unsigned int pdiv;
41 unsigned int mdiv;
42 unsigned int sdiv;
43 unsigned int kdiv;
44};
45
46struct imx_pll14xx_clk {
47 enum imx_pll14xx_type type;
48 const struct imx_pll14xx_rate_table *rate_table;
49 int rate_count;
50 int flags;
51};
52
Anson Huang43cdaa12019-09-06 09:34:05 -040053extern struct imx_pll14xx_clk imx_1416x_pll;
54extern struct imx_pll14xx_clk imx_1443x_pll;
55
Abel Vesa2bc7e9d2019-05-29 12:26:42 +000056#define imx_clk_cpu(name, parent_name, div, mux, pll, step) \
57 imx_clk_hw_cpu(name, parent_name, div, mux, pll, step)->clk
58
Abel Vesa1f9aec92019-05-29 12:26:42 +000059#define clk_register_gate2(dev, name, parent_name, flags, reg, bit_idx, \
60 cgr_val, clk_gate_flags, lock, share_count) \
61 clk_hw_register_gate2(dev, name, parent_name, flags, reg, bit_idx, \
62 cgr_val, clk_gate_flags, lock, share_count)->clk
63
Abel Vesae5674a42019-05-29 12:26:43 +000064#define imx_clk_pllv3(type, name, parent_name, base, div_mask) \
65 imx_clk_hw_pllv3(type, name, parent_name, base, div_mask)->clk
66
Abel Vesa995087c2019-05-29 12:26:43 +000067#define imx_clk_pfd(name, parent_name, reg, idx) \
68 imx_clk_hw_pfd(name, parent_name, reg, idx)->clk
69
Abel Vesadfc148b2019-05-29 12:26:43 +000070#define imx_clk_gate_exclusive(name, parent, reg, shift, exclusive_mask) \
71 imx_clk_hw_gate_exclusive(name, parent, reg, shift, exclusive_mask)->clk
72
Abel Vesaeccf8df2019-05-29 12:26:45 +000073#define imx_clk_fixed_factor(name, parent, mult, div) \
74 imx_clk_hw_fixed_factor(name, parent, mult, div)->clk
75
76#define imx_clk_divider2(name, parent, reg, shift, width) \
77 imx_clk_hw_divider2(name, parent, reg, shift, width)->clk
78
79#define imx_clk_gate_dis(name, parent, reg, shift) \
80 imx_clk_hw_gate_dis(name, parent, reg, shift)->clk
81
Abel Vesaeccf8df2019-05-29 12:26:45 +000082#define imx_clk_gate2(name, parent, reg, shift) \
83 imx_clk_hw_gate2(name, parent, reg, shift)->clk
84
85#define imx_clk_gate2_flags(name, parent, reg, shift, flags) \
86 imx_clk_hw_gate2_flags(name, parent, reg, shift, flags)->clk
87
Abel Vesaeccf8df2019-05-29 12:26:45 +000088#define imx_clk_gate2_shared2(name, parent, reg, shift, share_count) \
89 imx_clk_hw_gate2_shared2(name, parent, reg, shift, share_count)->clk
90
91#define imx_clk_gate3(name, parent, reg, shift) \
92 imx_clk_hw_gate3(name, parent, reg, shift)->clk
93
94#define imx_clk_gate4(name, parent, reg, shift) \
95 imx_clk_hw_gate4(name, parent, reg, shift)->clk
96
97#define imx_clk_mux(name, reg, shift, width, parents, num_parents) \
98 imx_clk_hw_mux(name, reg, shift, width, parents, num_parents)->clk
99
Bai Ping8646d4d2019-01-22 09:31:41 +0000100struct clk *imx_clk_pll14xx(const char *name, const char *parent_name,
101 void __iomem *base, const struct imx_pll14xx_clk *pll_clk);
102
Shawn Guo3bec5f82015-04-26 13:33:39 +0800103struct clk *imx_clk_pllv1(enum imx_pllv1_type type, const char *name,
104 const char *parent, void __iomem *base);
Sascha Hauer6c7b068502012-03-07 21:01:28 +0100105
Sascha Hauera547b812012-03-19 12:36:10 +0100106struct clk *imx_clk_pllv2(const char *name, const char *parent,
107 void __iomem *base);
108
Lucas Stach62096242018-12-01 10:52:11 +0000109struct clk *imx_clk_frac_pll(const char *name, const char *parent_name,
110 void __iomem *base);
111
Abel Vesae9dda4a2019-02-22 17:07:32 +0000112struct clk *imx_clk_sccg_pll(const char *name,
113 const char * const *parent_names,
114 u8 num_parents,
115 u8 parent, u8 bypass1, u8 bypass2,
116 void __iomem *base,
117 unsigned long flags);
Lucas Stachff70fbd2018-12-01 10:52:13 +0000118
Shawn Guoa3f6b9d2012-04-04 16:02:28 +0800119enum imx_pllv3_type {
120 IMX_PLLV3_GENERIC,
121 IMX_PLLV3_SYS,
122 IMX_PLLV3_USB,
Stefan Agner60ad8462014-12-02 17:59:42 +0100123 IMX_PLLV3_USB_VF610,
Shawn Guoa3f6b9d2012-04-04 16:02:28 +0800124 IMX_PLLV3_AV,
125 IMX_PLLV3_ENET,
Frank Lif5394742015-05-19 02:45:02 +0800126 IMX_PLLV3_ENET_IMX7,
Nikita Yushchenkoc77cbdd12016-12-19 11:12:09 +0300127 IMX_PLLV3_SYS_VF610,
Fabio Estevamad149722017-05-15 08:55:05 -0300128 IMX_PLLV3_DDR_IMX7,
Anson Huangb4a4cb52019-04-22 08:32:45 +0000129 IMX_PLLV3_AV_IMX7,
Shawn Guoa3f6b9d2012-04-04 16:02:28 +0800130};
131
Abel Vesae5674a42019-05-29 12:26:43 +0000132struct clk_hw *imx_clk_hw_pllv3(enum imx_pllv3_type type, const char *name,
Sascha Hauer2b254692012-11-22 10:18:41 +0100133 const char *parent_name, void __iomem *base, u32 div_mask);
Shawn Guoa3f6b9d2012-04-04 16:02:28 +0800134
Anson Huang34af5172019-06-19 13:52:44 +0800135#define PLL_1416X_RATE(_rate, _m, _p, _s) \
136 { \
137 .rate = (_rate), \
138 .mdiv = (_m), \
139 .pdiv = (_p), \
140 .sdiv = (_s), \
141 }
142
143#define PLL_1443X_RATE(_rate, _m, _p, _s, _k) \
144 { \
145 .rate = (_rate), \
146 .mdiv = (_m), \
147 .pdiv = (_p), \
148 .sdiv = (_s), \
149 .kdiv = (_k), \
150 }
151
A.s. Dongd9a8f952018-11-14 13:01:43 +0000152struct clk_hw *imx_clk_pllv4(const char *name, const char *parent_name,
153 void __iomem *base);
154
Abel Vesa1f9aec92019-05-29 12:26:42 +0000155struct clk_hw *clk_hw_register_gate2(struct device *dev, const char *name,
Sascha Hauerb75c0152011-04-19 08:33:45 +0200156 const char *parent_name, unsigned long flags,
Stefan Agner45682922016-03-09 18:16:47 -0800157 void __iomem *reg, u8 bit_idx, u8 cgr_val,
Shawn Guof9f28cd2014-04-19 10:58:22 +0800158 u8 clk_gate_flags, spinlock_t *lock,
159 unsigned int *share_count);
Sascha Hauerb75c0152011-04-19 08:33:45 +0200160
Martin Fuzzey75f83d02013-04-23 20:16:59 +0800161struct clk * imx_obtain_fixed_clock(
162 const char *name, unsigned long rate);
163
Abel Vesaa4a40692019-05-29 12:26:39 +0000164struct clk_hw *imx_obtain_fixed_clock_hw(
165 const char *name, unsigned long rate);
166
A.s. Dong3b315212018-11-14 13:02:04 +0000167struct clk_hw *imx_obtain_fixed_clk_hw(struct device_node *np,
168 const char *name);
169
Abel Vesadfc148b2019-05-29 12:26:43 +0000170struct clk_hw *imx_clk_hw_gate_exclusive(const char *name, const char *parent,
Shawn Guo19d86342014-08-26 15:06:33 +0800171 void __iomem *reg, u8 shift, u32 exclusive_mask);
172
Abel Vesa995087c2019-05-29 12:26:43 +0000173struct clk_hw *imx_clk_hw_pfd(const char *name, const char *parent_name,
Shawn Guoa10bd672012-04-04 16:07:53 +0800174 void __iomem *reg, u8 idx);
175
A.s. Dong9fcb6be2018-11-14 13:01:47 +0000176struct clk_hw *imx_clk_pfdv2(const char *name, const char *parent_name,
177 void __iomem *reg, u8 idx);
178
Abel Vesadd1a6c02019-05-29 12:26:42 +0000179struct clk_hw *imx_clk_hw_busy_divider(const char *name, const char *parent_name,
Shawn Guo32af7a82012-04-04 16:20:56 +0800180 void __iomem *reg, u8 shift, u8 width,
181 void __iomem *busy_reg, u8 busy_shift);
182
Abel Vesadd1a6c02019-05-29 12:26:42 +0000183struct clk_hw *imx_clk_hw_busy_mux(const char *name, void __iomem *reg, u8 shift,
Shawn Guo32af7a82012-04-04 16:20:56 +0800184 u8 width, void __iomem *busy_reg, u8 busy_shift,
A.s. Dong9e5ef7a2018-11-14 13:02:00 +0000185 const char * const *parent_names, int num_parents);
Shawn Guo32af7a82012-04-04 16:20:56 +0800186
A.s. Dong76a323c2018-11-14 13:01:51 +0000187struct clk_hw *imx7ulp_clk_composite(const char *name,
188 const char * const *parent_names,
189 int num_parents, bool mux_present,
190 bool rate_present, bool gate_present,
191 void __iomem *reg);
Sascha Hauer6c7b068502012-03-07 21:01:28 +0100192
Abel Vesa2597b392019-05-29 12:26:44 +0000193struct clk_hw *imx_clk_hw_fixup_divider(const char *name, const char *parent,
Liu Yingcbe7fc82013-07-04 17:22:26 +0800194 void __iomem *reg, u8 shift, u8 width,
195 void (*fixup)(u32 *val));
196
Abel Vesa2597b392019-05-29 12:26:44 +0000197struct clk_hw *imx_clk_hw_fixup_mux(const char *name, void __iomem *reg,
A.s. Dong9e5ef7a2018-11-14 13:02:00 +0000198 u8 shift, u8 width, const char * const *parents,
Liu Yinga49e6c42013-07-04 17:35:46 +0800199 int num_parents, void (*fixup)(u32 *val));
200
Sascha Hauer6c7b068502012-03-07 21:01:28 +0100201static inline struct clk *imx_clk_fixed(const char *name, int rate)
202{
Stephen Boyd38c70352016-03-01 10:59:49 -0800203 return clk_register_fixed_rate(NULL, name, NULL, 0, rate);
Sascha Hauer6c7b068502012-03-07 21:01:28 +0100204}
205
A.s. Dong3b315212018-11-14 13:02:04 +0000206static inline struct clk_hw *imx_clk_hw_fixed(const char *name, int rate)
207{
208 return clk_hw_register_fixed_rate(NULL, name, NULL, 0, rate);
209}
210
Abel Vesaeccf8df2019-05-29 12:26:45 +0000211static inline struct clk_hw *imx_clk_hw_mux_ldb(const char *name, void __iomem *reg,
A.s. Dong9e5ef7a2018-11-14 13:02:00 +0000212 u8 shift, u8 width, const char * const *parents,
213 int num_parents)
Philipp Zabel03d576f2016-10-17 22:29:13 -0200214{
Abel Vesaeccf8df2019-05-29 12:26:45 +0000215 return clk_hw_register_mux(NULL, name, parents, num_parents,
Philipp Zabel03d576f2016-10-17 22:29:13 -0200216 CLK_SET_RATE_NO_REPARENT | CLK_SET_RATE_PARENT, reg,
217 shift, width, CLK_MUX_READ_ONLY, &imx_ccm_lock);
218}
219
Abel Vesaeccf8df2019-05-29 12:26:45 +0000220static inline struct clk_hw *imx_clk_hw_fixed_factor(const char *name,
Dong Aisheng5afc9942016-06-30 17:31:15 +0800221 const char *parent, unsigned int mult, unsigned int div)
222{
Abel Vesaeccf8df2019-05-29 12:26:45 +0000223 return clk_hw_register_fixed_factor(NULL, name, parent,
Dong Aisheng5afc9942016-06-30 17:31:15 +0800224 CLK_SET_RATE_PARENT, mult, div);
225}
226
Sascha Hauer6c7b068502012-03-07 21:01:28 +0100227static inline struct clk *imx_clk_divider(const char *name, const char *parent,
228 void __iomem *reg, u8 shift, u8 width)
229{
230 return clk_register_divider(NULL, name, parent, CLK_SET_RATE_PARENT,
231 reg, shift, width, 0, &imx_ccm_lock);
232}
233
A.s. Dong3b315212018-11-14 13:02:04 +0000234static inline struct clk_hw *imx_clk_hw_divider(const char *name,
235 const char *parent,
236 void __iomem *reg, u8 shift,
237 u8 width)
238{
239 return clk_hw_register_divider(NULL, name, parent, CLK_SET_RATE_PARENT,
240 reg, shift, width, 0, &imx_ccm_lock);
241}
242
Philipp Zabel3ce92172013-03-27 18:30:40 +0100243static inline struct clk *imx_clk_divider_flags(const char *name,
244 const char *parent, void __iomem *reg, u8 shift, u8 width,
245 unsigned long flags)
246{
247 return clk_register_divider(NULL, name, parent, flags,
248 reg, shift, width, 0, &imx_ccm_lock);
249}
250
A.s. Dong3b315212018-11-14 13:02:04 +0000251static inline struct clk_hw *imx_clk_hw_divider_flags(const char *name,
252 const char *parent,
253 void __iomem *reg, u8 shift,
254 u8 width, unsigned long flags)
255{
256 return clk_hw_register_divider(NULL, name, parent, flags,
257 reg, shift, width, 0, &imx_ccm_lock);
258}
259
Abel Vesaeccf8df2019-05-29 12:26:45 +0000260static inline struct clk_hw *imx_clk_hw_divider2(const char *name, const char *parent,
Dong Aisheng39c29492016-06-30 17:31:16 +0800261 void __iomem *reg, u8 shift, u8 width)
262{
Abel Vesaeccf8df2019-05-29 12:26:45 +0000263 return clk_hw_register_divider(NULL, name, parent,
Dong Aisheng39c29492016-06-30 17:31:16 +0800264 CLK_SET_RATE_PARENT | CLK_OPS_PARENT_ENABLE,
265 reg, shift, width, 0, &imx_ccm_lock);
266}
267
Abel Vesab8052202018-12-01 10:52:15 +0000268static inline struct clk *imx_clk_divider2_flags(const char *name,
269 const char *parent, void __iomem *reg, u8 shift, u8 width,
270 unsigned long flags)
271{
272 return clk_register_divider(NULL, name, parent,
273 flags | CLK_SET_RATE_PARENT | CLK_OPS_PARENT_ENABLE,
274 reg, shift, width, 0, &imx_ccm_lock);
275}
276
Sascha Hauer6c7b068502012-03-07 21:01:28 +0100277static inline struct clk *imx_clk_gate(const char *name, const char *parent,
278 void __iomem *reg, u8 shift)
279{
280 return clk_register_gate(NULL, name, parent, CLK_SET_RATE_PARENT, reg,
281 shift, 0, &imx_ccm_lock);
282}
283
Abel Vesaeccf8df2019-05-29 12:26:45 +0000284static inline struct clk_hw *imx_clk_hw_gate_flags(const char *name, const char *parent,
Bai Ping2b18cc12018-03-20 10:24:02 +0800285 void __iomem *reg, u8 shift, unsigned long flags)
286{
Abel Vesaeccf8df2019-05-29 12:26:45 +0000287 return clk_hw_register_gate(NULL, name, parent, flags | CLK_SET_RATE_PARENT, reg,
Bai Ping2b18cc12018-03-20 10:24:02 +0800288 shift, 0, &imx_ccm_lock);
289}
290
A.s. Dong3b315212018-11-14 13:02:04 +0000291static inline struct clk_hw *imx_clk_hw_gate(const char *name, const char *parent,
292 void __iomem *reg, u8 shift)
293{
294 return clk_hw_register_gate(NULL, name, parent, CLK_SET_RATE_PARENT, reg,
295 shift, 0, &imx_ccm_lock);
296}
297
Abel Vesaeccf8df2019-05-29 12:26:45 +0000298static inline struct clk_hw *imx_clk_hw_gate_dis(const char *name, const char *parent,
Alexander Shiyan65251692014-06-22 17:17:06 +0400299 void __iomem *reg, u8 shift)
300{
Abel Vesaeccf8df2019-05-29 12:26:45 +0000301 return clk_hw_register_gate(NULL, name, parent, CLK_SET_RATE_PARENT, reg,
Alexander Shiyan65251692014-06-22 17:17:06 +0400302 shift, CLK_GATE_SET_TO_DISABLE, &imx_ccm_lock);
303}
304
Abel Vesaeccf8df2019-05-29 12:26:45 +0000305static inline struct clk_hw *imx_clk_hw_gate_dis_flags(const char *name, const char *parent,
Anson Huangfebb6542018-08-08 12:39:27 +0800306 void __iomem *reg, u8 shift, unsigned long flags)
307{
Abel Vesaeccf8df2019-05-29 12:26:45 +0000308 return clk_hw_register_gate(NULL, name, parent, flags | CLK_SET_RATE_PARENT, reg,
Anson Huangfebb6542018-08-08 12:39:27 +0800309 shift, CLK_GATE_SET_TO_DISABLE, &imx_ccm_lock);
310}
311
Abel Vesaeccf8df2019-05-29 12:26:45 +0000312static inline struct clk_hw *imx_clk_hw_gate2(const char *name, const char *parent,
Dong Aisheng5afc9942016-06-30 17:31:15 +0800313 void __iomem *reg, u8 shift)
314{
Abel Vesaeccf8df2019-05-29 12:26:45 +0000315 return clk_hw_register_gate2(NULL, name, parent, CLK_SET_RATE_PARENT, reg,
Dong Aisheng5afc9942016-06-30 17:31:15 +0800316 shift, 0x3, 0, &imx_ccm_lock, NULL);
317}
318
Abel Vesaeccf8df2019-05-29 12:26:45 +0000319static inline struct clk_hw *imx_clk_hw_gate2_flags(const char *name, const char *parent,
Bai Ping2b18cc12018-03-20 10:24:02 +0800320 void __iomem *reg, u8 shift, unsigned long flags)
321{
Abel Vesaeccf8df2019-05-29 12:26:45 +0000322 return clk_hw_register_gate2(NULL, name, parent, flags | CLK_SET_RATE_PARENT, reg,
Bai Ping2b18cc12018-03-20 10:24:02 +0800323 shift, 0x3, 0, &imx_ccm_lock, NULL);
324}
325
Abel Vesaeccf8df2019-05-29 12:26:45 +0000326static inline struct clk_hw *imx_clk_hw_gate2_shared(const char *name,
Dong Aisheng5afc9942016-06-30 17:31:15 +0800327 const char *parent, void __iomem *reg, u8 shift,
328 unsigned int *share_count)
329{
Abel Vesaeccf8df2019-05-29 12:26:45 +0000330 return clk_hw_register_gate2(NULL, name, parent, CLK_SET_RATE_PARENT, reg,
Dong Aisheng5afc9942016-06-30 17:31:15 +0800331 shift, 0x3, 0, &imx_ccm_lock, share_count);
332}
333
Abel Vesaeccf8df2019-05-29 12:26:45 +0000334static inline struct clk_hw *imx_clk_hw_gate2_shared2(const char *name,
Fabio Estevamd5ebf5f2016-08-12 15:26:55 -0300335 const char *parent, void __iomem *reg, u8 shift,
336 unsigned int *share_count)
337{
Abel Vesaeccf8df2019-05-29 12:26:45 +0000338 return clk_hw_register_gate2(NULL, name, parent, CLK_SET_RATE_PARENT |
Fabio Estevamd5ebf5f2016-08-12 15:26:55 -0300339 CLK_OPS_PARENT_ENABLE, reg, shift, 0x3, 0,
340 &imx_ccm_lock, share_count);
341}
342
Dong Aisheng5afc9942016-06-30 17:31:15 +0800343static inline struct clk *imx_clk_gate2_cgr(const char *name,
344 const char *parent, void __iomem *reg, u8 shift, u8 cgr_val)
345{
346 return clk_register_gate2(NULL, name, parent, CLK_SET_RATE_PARENT, reg,
347 shift, cgr_val, 0, &imx_ccm_lock, NULL);
348}
349
Abel Vesaeccf8df2019-05-29 12:26:45 +0000350static inline struct clk_hw *imx_clk_hw_gate3(const char *name, const char *parent,
Dong Aisheng39c29492016-06-30 17:31:16 +0800351 void __iomem *reg, u8 shift)
352{
Abel Vesaeccf8df2019-05-29 12:26:45 +0000353 return clk_hw_register_gate(NULL, name, parent,
Dong Aisheng39c29492016-06-30 17:31:16 +0800354 CLK_SET_RATE_PARENT | CLK_OPS_PARENT_ENABLE,
355 reg, shift, 0, &imx_ccm_lock);
356}
357
Abel Vesab8052202018-12-01 10:52:15 +0000358static inline struct clk *imx_clk_gate3_flags(const char *name,
359 const char *parent, void __iomem *reg, u8 shift,
360 unsigned long flags)
361{
362 return clk_register_gate(NULL, name, parent,
363 flags | CLK_SET_RATE_PARENT | CLK_OPS_PARENT_ENABLE,
364 reg, shift, 0, &imx_ccm_lock);
365}
366
Abel Vesaeccf8df2019-05-29 12:26:45 +0000367static inline struct clk_hw *imx_clk_hw_gate4(const char *name, const char *parent,
Dong Aisheng39c29492016-06-30 17:31:16 +0800368 void __iomem *reg, u8 shift)
369{
Abel Vesaeccf8df2019-05-29 12:26:45 +0000370 return clk_hw_register_gate2(NULL, name, parent,
Dong Aisheng39c29492016-06-30 17:31:16 +0800371 CLK_SET_RATE_PARENT | CLK_OPS_PARENT_ENABLE,
372 reg, shift, 0x3, 0, &imx_ccm_lock, NULL);
373}
374
Abel Vesab8052202018-12-01 10:52:15 +0000375static inline struct clk *imx_clk_gate4_flags(const char *name,
376 const char *parent, void __iomem *reg, u8 shift,
377 unsigned long flags)
378{
379 return clk_register_gate2(NULL, name, parent,
380 flags | CLK_SET_RATE_PARENT | CLK_OPS_PARENT_ENABLE,
381 reg, shift, 0x3, 0, &imx_ccm_lock, NULL);
382}
383
Abel Vesaeccf8df2019-05-29 12:26:45 +0000384static inline struct clk_hw *imx_clk_hw_mux(const char *name, void __iomem *reg,
A.s. Dong9e5ef7a2018-11-14 13:02:00 +0000385 u8 shift, u8 width, const char * const *parents,
386 int num_parents)
Sascha Hauer6c7b068502012-03-07 21:01:28 +0100387{
Abel Vesaeccf8df2019-05-29 12:26:45 +0000388 return clk_hw_register_mux(NULL, name, parents, num_parents,
James Hogan819c1de2013-07-29 12:25:01 +0100389 CLK_SET_RATE_NO_REPARENT, reg, shift,
Sascha Hauer6c7b068502012-03-07 21:01:28 +0100390 width, 0, &imx_ccm_lock);
391}
392
Dong Aisheng39c29492016-06-30 17:31:16 +0800393static inline struct clk *imx_clk_mux2(const char *name, void __iomem *reg,
A.s. Dong9e5ef7a2018-11-14 13:02:00 +0000394 u8 shift, u8 width, const char * const *parents,
395 int num_parents)
Dong Aisheng39c29492016-06-30 17:31:16 +0800396{
397 return clk_register_mux(NULL, name, parents, num_parents,
398 CLK_SET_RATE_NO_REPARENT | CLK_OPS_PARENT_ENABLE,
399 reg, shift, width, 0, &imx_ccm_lock);
400}
401
A.s. Dong3b315212018-11-14 13:02:04 +0000402static inline struct clk_hw *imx_clk_hw_mux2(const char *name, void __iomem *reg,
403 u8 shift, u8 width,
404 const char * const *parents,
405 int num_parents)
406{
407 return clk_hw_register_mux(NULL, name, parents, num_parents,
408 CLK_SET_RATE_NO_REPARENT |
409 CLK_OPS_PARENT_ENABLE,
410 reg, shift, width, 0, &imx_ccm_lock);
411}
412
Philipp Zabel3ce92172013-03-27 18:30:40 +0100413static inline struct clk *imx_clk_mux_flags(const char *name,
A.s. Dong9e5ef7a2018-11-14 13:02:00 +0000414 void __iomem *reg, u8 shift, u8 width,
415 const char * const *parents, int num_parents,
416 unsigned long flags)
Philipp Zabel3ce92172013-03-27 18:30:40 +0100417{
418 return clk_register_mux(NULL, name, parents, num_parents,
James Hogan819c1de2013-07-29 12:25:01 +0100419 flags | CLK_SET_RATE_NO_REPARENT, reg, shift, width, 0,
Philipp Zabel3ce92172013-03-27 18:30:40 +0100420 &imx_ccm_lock);
421}
422
Abel Vesab8052202018-12-01 10:52:15 +0000423static inline struct clk *imx_clk_mux2_flags(const char *name,
Abel Vesa470663e2018-12-14 15:30:10 +0000424 void __iomem *reg, u8 shift, u8 width,
425 const char * const *parents,
Abel Vesab8052202018-12-01 10:52:15 +0000426 int num_parents, unsigned long flags)
427{
428 return clk_register_mux(NULL, name, parents, num_parents,
429 flags | CLK_SET_RATE_NO_REPARENT | CLK_OPS_PARENT_ENABLE,
430 reg, shift, width, 0, &imx_ccm_lock);
431}
432
A.s. Dong3b315212018-11-14 13:02:04 +0000433static inline struct clk_hw *imx_clk_hw_mux_flags(const char *name,
434 void __iomem *reg, u8 shift,
435 u8 width,
436 const char * const *parents,
437 int num_parents,
438 unsigned long flags)
439{
440 return clk_hw_register_mux(NULL, name, parents, num_parents,
441 flags | CLK_SET_RATE_NO_REPARENT,
442 reg, shift, width, 0, &imx_ccm_lock);
443}
444
Abel Vesa2bc7e9d2019-05-29 12:26:42 +0000445struct clk_hw *imx_clk_hw_cpu(const char *name, const char *parent_name,
Lucas Stache0fed512014-09-26 15:41:01 +0200446 struct clk *div, struct clk *mux, struct clk *pll,
447 struct clk *step);
448
Abel Vesad3ff9722018-12-01 10:52:14 +0000449struct clk *imx8m_clk_composite_flags(const char *name,
Abel Vesa65a6b7c2018-12-14 15:30:09 +0000450 const char * const *parent_names,
Abel Vesad3ff9722018-12-01 10:52:14 +0000451 int num_parents, void __iomem *reg,
452 unsigned long flags);
453
454#define __imx8m_clk_composite(name, parent_names, reg, flags) \
455 imx8m_clk_composite_flags(name, parent_names, \
456 ARRAY_SIZE(parent_names), reg, \
457 flags | CLK_SET_RATE_NO_REPARENT | CLK_OPS_PARENT_ENABLE)
458
459#define imx8m_clk_composite(name, parent_names, reg) \
460 __imx8m_clk_composite(name, parent_names, reg, 0)
461
462#define imx8m_clk_composite_critical(name, parent_names, reg) \
463 __imx8m_clk_composite(name, parent_names, reg, CLK_IS_CRITICAL)
464
A.s. Dong40468072018-11-14 13:01:35 +0000465struct clk_hw *imx_clk_divider_gate(const char *name, const char *parent_name,
466 unsigned long flags, void __iomem *reg, u8 shift, u8 width,
467 u8 clk_divider_flags, const struct clk_div_table *table,
468 spinlock_t *lock);
Sascha Hauer6c7b068502012-03-07 21:01:28 +0100469#endif