Greg Kroah-Hartman | b244131 | 2017-11-01 15:07:57 +0100 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
Sascha Hauer | 6c7b06850 | 2012-03-07 21:01:28 +0100 | [diff] [blame] | 2 | #ifndef __MACH_IMX_CLK_H |
| 3 | #define __MACH_IMX_CLK_H |
| 4 | |
| 5 | #include <linux/spinlock.h> |
| 6 | #include <linux/clk-provider.h> |
Sascha Hauer | 3a84d17 | 2012-09-11 08:50:00 +0200 | [diff] [blame] | 7 | |
| 8 | extern spinlock_t imx_ccm_lock; |
Sascha Hauer | 6c7b06850 | 2012-03-07 21:01:28 +0100 | [diff] [blame] | 9 | |
Alexander Shiyan | 229be9c | 2014-06-10 19:40:26 +0400 | [diff] [blame] | 10 | void imx_check_clocks(struct clk *clks[], unsigned int count); |
A.s. Dong | 3b31521 | 2018-11-14 13:02:04 +0000 | [diff] [blame] | 11 | void imx_check_clk_hws(struct clk_hw *clks[], unsigned int count); |
Lucas Stach | 55adc61 | 2015-09-21 18:53:57 +0200 | [diff] [blame] | 12 | void imx_register_uart_clocks(struct clk ** const clks[]); |
Anson Huang | efdb279 | 2019-05-12 10:24:12 +0000 | [diff] [blame] | 13 | void imx_mmdc_mask_handshake(void __iomem *ccm_base, unsigned int chn); |
Anson Huang | fd6ef28 | 2019-06-19 13:52:45 +0800 | [diff] [blame] | 14 | void imx_unregister_clocks(struct clk *clks[], unsigned int count); |
Alexander Shiyan | 229be9c | 2014-06-10 19:40:26 +0400 | [diff] [blame] | 15 | |
Liu Ying | dfd8714 | 2013-07-04 17:57:17 +0800 | [diff] [blame] | 16 | extern void imx_cscmr1_fixup(u32 *val); |
| 17 | |
Shawn Guo | 3bec5f8 | 2015-04-26 13:33:39 +0800 | [diff] [blame] | 18 | enum 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 Stach | ff70fbd | 2018-12-01 10:52:13 +0000 | [diff] [blame] | 27 | enum imx_sccg_pll_type { |
| 28 | SCCG_PLL1, |
| 29 | SCCG_PLL2, |
| 30 | }; |
| 31 | |
Bai Ping | 8646d4d | 2019-01-22 09:31:41 +0000 | [diff] [blame] | 32 | enum imx_pll14xx_type { |
| 33 | PLL_1416X, |
| 34 | PLL_1443X, |
| 35 | }; |
| 36 | |
| 37 | /* NOTE: Rate table should be kept sorted in descending order. */ |
| 38 | struct 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 | |
| 46 | struct 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 Huang | 43cdaa1 | 2019-09-06 09:34:05 -0400 | [diff] [blame] | 53 | extern struct imx_pll14xx_clk imx_1416x_pll; |
| 54 | extern struct imx_pll14xx_clk imx_1443x_pll; |
| 55 | |
Abel Vesa | 2bc7e9d | 2019-05-29 12:26:42 +0000 | [diff] [blame] | 56 | #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 Vesa | 1f9aec9 | 2019-05-29 12:26:42 +0000 | [diff] [blame] | 59 | #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 Vesa | e5674a4 | 2019-05-29 12:26:43 +0000 | [diff] [blame] | 64 | #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 Vesa | 995087c | 2019-05-29 12:26:43 +0000 | [diff] [blame] | 67 | #define imx_clk_pfd(name, parent_name, reg, idx) \ |
| 68 | imx_clk_hw_pfd(name, parent_name, reg, idx)->clk |
| 69 | |
Abel Vesa | dfc148b | 2019-05-29 12:26:43 +0000 | [diff] [blame] | 70 | #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 Vesa | eccf8df | 2019-05-29 12:26:45 +0000 | [diff] [blame] | 73 | #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 Vesa | eccf8df | 2019-05-29 12:26:45 +0000 | [diff] [blame] | 82 | #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 Vesa | eccf8df | 2019-05-29 12:26:45 +0000 | [diff] [blame] | 88 | #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 Ping | 8646d4d | 2019-01-22 09:31:41 +0000 | [diff] [blame] | 100 | struct clk *imx_clk_pll14xx(const char *name, const char *parent_name, |
| 101 | void __iomem *base, const struct imx_pll14xx_clk *pll_clk); |
| 102 | |
Shawn Guo | 3bec5f8 | 2015-04-26 13:33:39 +0800 | [diff] [blame] | 103 | struct clk *imx_clk_pllv1(enum imx_pllv1_type type, const char *name, |
| 104 | const char *parent, void __iomem *base); |
Sascha Hauer | 6c7b06850 | 2012-03-07 21:01:28 +0100 | [diff] [blame] | 105 | |
Sascha Hauer | a547b81 | 2012-03-19 12:36:10 +0100 | [diff] [blame] | 106 | struct clk *imx_clk_pllv2(const char *name, const char *parent, |
| 107 | void __iomem *base); |
| 108 | |
Lucas Stach | 6209624 | 2018-12-01 10:52:11 +0000 | [diff] [blame] | 109 | struct clk *imx_clk_frac_pll(const char *name, const char *parent_name, |
| 110 | void __iomem *base); |
| 111 | |
Abel Vesa | e9dda4a | 2019-02-22 17:07:32 +0000 | [diff] [blame] | 112 | struct 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 Stach | ff70fbd | 2018-12-01 10:52:13 +0000 | [diff] [blame] | 118 | |
Shawn Guo | a3f6b9d | 2012-04-04 16:02:28 +0800 | [diff] [blame] | 119 | enum imx_pllv3_type { |
| 120 | IMX_PLLV3_GENERIC, |
| 121 | IMX_PLLV3_SYS, |
| 122 | IMX_PLLV3_USB, |
Stefan Agner | 60ad846 | 2014-12-02 17:59:42 +0100 | [diff] [blame] | 123 | IMX_PLLV3_USB_VF610, |
Shawn Guo | a3f6b9d | 2012-04-04 16:02:28 +0800 | [diff] [blame] | 124 | IMX_PLLV3_AV, |
| 125 | IMX_PLLV3_ENET, |
Frank Li | f539474 | 2015-05-19 02:45:02 +0800 | [diff] [blame] | 126 | IMX_PLLV3_ENET_IMX7, |
Nikita Yushchenko | c77cbdd1 | 2016-12-19 11:12:09 +0300 | [diff] [blame] | 127 | IMX_PLLV3_SYS_VF610, |
Fabio Estevam | ad14972 | 2017-05-15 08:55:05 -0300 | [diff] [blame] | 128 | IMX_PLLV3_DDR_IMX7, |
Anson Huang | b4a4cb5 | 2019-04-22 08:32:45 +0000 | [diff] [blame] | 129 | IMX_PLLV3_AV_IMX7, |
Shawn Guo | a3f6b9d | 2012-04-04 16:02:28 +0800 | [diff] [blame] | 130 | }; |
| 131 | |
Abel Vesa | e5674a4 | 2019-05-29 12:26:43 +0000 | [diff] [blame] | 132 | struct clk_hw *imx_clk_hw_pllv3(enum imx_pllv3_type type, const char *name, |
Sascha Hauer | 2b25469 | 2012-11-22 10:18:41 +0100 | [diff] [blame] | 133 | const char *parent_name, void __iomem *base, u32 div_mask); |
Shawn Guo | a3f6b9d | 2012-04-04 16:02:28 +0800 | [diff] [blame] | 134 | |
Anson Huang | 34af517 | 2019-06-19 13:52:44 +0800 | [diff] [blame] | 135 | #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. Dong | d9a8f95 | 2018-11-14 13:01:43 +0000 | [diff] [blame] | 152 | struct clk_hw *imx_clk_pllv4(const char *name, const char *parent_name, |
| 153 | void __iomem *base); |
| 154 | |
Abel Vesa | 1f9aec9 | 2019-05-29 12:26:42 +0000 | [diff] [blame] | 155 | struct clk_hw *clk_hw_register_gate2(struct device *dev, const char *name, |
Sascha Hauer | b75c015 | 2011-04-19 08:33:45 +0200 | [diff] [blame] | 156 | const char *parent_name, unsigned long flags, |
Stefan Agner | 4568292 | 2016-03-09 18:16:47 -0800 | [diff] [blame] | 157 | void __iomem *reg, u8 bit_idx, u8 cgr_val, |
Shawn Guo | f9f28cd | 2014-04-19 10:58:22 +0800 | [diff] [blame] | 158 | u8 clk_gate_flags, spinlock_t *lock, |
| 159 | unsigned int *share_count); |
Sascha Hauer | b75c015 | 2011-04-19 08:33:45 +0200 | [diff] [blame] | 160 | |
Martin Fuzzey | 75f83d0 | 2013-04-23 20:16:59 +0800 | [diff] [blame] | 161 | struct clk * imx_obtain_fixed_clock( |
| 162 | const char *name, unsigned long rate); |
| 163 | |
Abel Vesa | a4a4069 | 2019-05-29 12:26:39 +0000 | [diff] [blame] | 164 | struct clk_hw *imx_obtain_fixed_clock_hw( |
| 165 | const char *name, unsigned long rate); |
| 166 | |
A.s. Dong | 3b31521 | 2018-11-14 13:02:04 +0000 | [diff] [blame] | 167 | struct clk_hw *imx_obtain_fixed_clk_hw(struct device_node *np, |
| 168 | const char *name); |
| 169 | |
Abel Vesa | dfc148b | 2019-05-29 12:26:43 +0000 | [diff] [blame] | 170 | struct clk_hw *imx_clk_hw_gate_exclusive(const char *name, const char *parent, |
Shawn Guo | 19d8634 | 2014-08-26 15:06:33 +0800 | [diff] [blame] | 171 | void __iomem *reg, u8 shift, u32 exclusive_mask); |
| 172 | |
Abel Vesa | 995087c | 2019-05-29 12:26:43 +0000 | [diff] [blame] | 173 | struct clk_hw *imx_clk_hw_pfd(const char *name, const char *parent_name, |
Shawn Guo | a10bd67 | 2012-04-04 16:07:53 +0800 | [diff] [blame] | 174 | void __iomem *reg, u8 idx); |
| 175 | |
A.s. Dong | 9fcb6be | 2018-11-14 13:01:47 +0000 | [diff] [blame] | 176 | struct clk_hw *imx_clk_pfdv2(const char *name, const char *parent_name, |
| 177 | void __iomem *reg, u8 idx); |
| 178 | |
Abel Vesa | dd1a6c0 | 2019-05-29 12:26:42 +0000 | [diff] [blame] | 179 | struct clk_hw *imx_clk_hw_busy_divider(const char *name, const char *parent_name, |
Shawn Guo | 32af7a8 | 2012-04-04 16:20:56 +0800 | [diff] [blame] | 180 | void __iomem *reg, u8 shift, u8 width, |
| 181 | void __iomem *busy_reg, u8 busy_shift); |
| 182 | |
Abel Vesa | dd1a6c0 | 2019-05-29 12:26:42 +0000 | [diff] [blame] | 183 | struct clk_hw *imx_clk_hw_busy_mux(const char *name, void __iomem *reg, u8 shift, |
Shawn Guo | 32af7a8 | 2012-04-04 16:20:56 +0800 | [diff] [blame] | 184 | u8 width, void __iomem *busy_reg, u8 busy_shift, |
A.s. Dong | 9e5ef7a | 2018-11-14 13:02:00 +0000 | [diff] [blame] | 185 | const char * const *parent_names, int num_parents); |
Shawn Guo | 32af7a8 | 2012-04-04 16:20:56 +0800 | [diff] [blame] | 186 | |
A.s. Dong | 76a323c | 2018-11-14 13:01:51 +0000 | [diff] [blame] | 187 | struct 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 Hauer | 6c7b06850 | 2012-03-07 21:01:28 +0100 | [diff] [blame] | 192 | |
Abel Vesa | 2597b39 | 2019-05-29 12:26:44 +0000 | [diff] [blame] | 193 | struct clk_hw *imx_clk_hw_fixup_divider(const char *name, const char *parent, |
Liu Ying | cbe7fc8 | 2013-07-04 17:22:26 +0800 | [diff] [blame] | 194 | void __iomem *reg, u8 shift, u8 width, |
| 195 | void (*fixup)(u32 *val)); |
| 196 | |
Abel Vesa | 2597b39 | 2019-05-29 12:26:44 +0000 | [diff] [blame] | 197 | struct clk_hw *imx_clk_hw_fixup_mux(const char *name, void __iomem *reg, |
A.s. Dong | 9e5ef7a | 2018-11-14 13:02:00 +0000 | [diff] [blame] | 198 | u8 shift, u8 width, const char * const *parents, |
Liu Ying | a49e6c4 | 2013-07-04 17:35:46 +0800 | [diff] [blame] | 199 | int num_parents, void (*fixup)(u32 *val)); |
| 200 | |
Sascha Hauer | 6c7b06850 | 2012-03-07 21:01:28 +0100 | [diff] [blame] | 201 | static inline struct clk *imx_clk_fixed(const char *name, int rate) |
| 202 | { |
Stephen Boyd | 38c7035 | 2016-03-01 10:59:49 -0800 | [diff] [blame] | 203 | return clk_register_fixed_rate(NULL, name, NULL, 0, rate); |
Sascha Hauer | 6c7b06850 | 2012-03-07 21:01:28 +0100 | [diff] [blame] | 204 | } |
| 205 | |
A.s. Dong | 3b31521 | 2018-11-14 13:02:04 +0000 | [diff] [blame] | 206 | static 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 Vesa | eccf8df | 2019-05-29 12:26:45 +0000 | [diff] [blame] | 211 | static inline struct clk_hw *imx_clk_hw_mux_ldb(const char *name, void __iomem *reg, |
A.s. Dong | 9e5ef7a | 2018-11-14 13:02:00 +0000 | [diff] [blame] | 212 | u8 shift, u8 width, const char * const *parents, |
| 213 | int num_parents) |
Philipp Zabel | 03d576f | 2016-10-17 22:29:13 -0200 | [diff] [blame] | 214 | { |
Abel Vesa | eccf8df | 2019-05-29 12:26:45 +0000 | [diff] [blame] | 215 | return clk_hw_register_mux(NULL, name, parents, num_parents, |
Philipp Zabel | 03d576f | 2016-10-17 22:29:13 -0200 | [diff] [blame] | 216 | CLK_SET_RATE_NO_REPARENT | CLK_SET_RATE_PARENT, reg, |
| 217 | shift, width, CLK_MUX_READ_ONLY, &imx_ccm_lock); |
| 218 | } |
| 219 | |
Abel Vesa | eccf8df | 2019-05-29 12:26:45 +0000 | [diff] [blame] | 220 | static inline struct clk_hw *imx_clk_hw_fixed_factor(const char *name, |
Dong Aisheng | 5afc994 | 2016-06-30 17:31:15 +0800 | [diff] [blame] | 221 | const char *parent, unsigned int mult, unsigned int div) |
| 222 | { |
Abel Vesa | eccf8df | 2019-05-29 12:26:45 +0000 | [diff] [blame] | 223 | return clk_hw_register_fixed_factor(NULL, name, parent, |
Dong Aisheng | 5afc994 | 2016-06-30 17:31:15 +0800 | [diff] [blame] | 224 | CLK_SET_RATE_PARENT, mult, div); |
| 225 | } |
| 226 | |
Sascha Hauer | 6c7b06850 | 2012-03-07 21:01:28 +0100 | [diff] [blame] | 227 | static 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. Dong | 3b31521 | 2018-11-14 13:02:04 +0000 | [diff] [blame] | 234 | static 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 Zabel | 3ce9217 | 2013-03-27 18:30:40 +0100 | [diff] [blame] | 243 | static 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. Dong | 3b31521 | 2018-11-14 13:02:04 +0000 | [diff] [blame] | 251 | static 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 Vesa | eccf8df | 2019-05-29 12:26:45 +0000 | [diff] [blame] | 260 | static inline struct clk_hw *imx_clk_hw_divider2(const char *name, const char *parent, |
Dong Aisheng | 39c2949 | 2016-06-30 17:31:16 +0800 | [diff] [blame] | 261 | void __iomem *reg, u8 shift, u8 width) |
| 262 | { |
Abel Vesa | eccf8df | 2019-05-29 12:26:45 +0000 | [diff] [blame] | 263 | return clk_hw_register_divider(NULL, name, parent, |
Dong Aisheng | 39c2949 | 2016-06-30 17:31:16 +0800 | [diff] [blame] | 264 | CLK_SET_RATE_PARENT | CLK_OPS_PARENT_ENABLE, |
| 265 | reg, shift, width, 0, &imx_ccm_lock); |
| 266 | } |
| 267 | |
Abel Vesa | b805220 | 2018-12-01 10:52:15 +0000 | [diff] [blame] | 268 | static 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 Hauer | 6c7b06850 | 2012-03-07 21:01:28 +0100 | [diff] [blame] | 277 | static 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 Vesa | eccf8df | 2019-05-29 12:26:45 +0000 | [diff] [blame] | 284 | static inline struct clk_hw *imx_clk_hw_gate_flags(const char *name, const char *parent, |
Bai Ping | 2b18cc1 | 2018-03-20 10:24:02 +0800 | [diff] [blame] | 285 | void __iomem *reg, u8 shift, unsigned long flags) |
| 286 | { |
Abel Vesa | eccf8df | 2019-05-29 12:26:45 +0000 | [diff] [blame] | 287 | return clk_hw_register_gate(NULL, name, parent, flags | CLK_SET_RATE_PARENT, reg, |
Bai Ping | 2b18cc1 | 2018-03-20 10:24:02 +0800 | [diff] [blame] | 288 | shift, 0, &imx_ccm_lock); |
| 289 | } |
| 290 | |
A.s. Dong | 3b31521 | 2018-11-14 13:02:04 +0000 | [diff] [blame] | 291 | static 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 Vesa | eccf8df | 2019-05-29 12:26:45 +0000 | [diff] [blame] | 298 | static inline struct clk_hw *imx_clk_hw_gate_dis(const char *name, const char *parent, |
Alexander Shiyan | 6525169 | 2014-06-22 17:17:06 +0400 | [diff] [blame] | 299 | void __iomem *reg, u8 shift) |
| 300 | { |
Abel Vesa | eccf8df | 2019-05-29 12:26:45 +0000 | [diff] [blame] | 301 | return clk_hw_register_gate(NULL, name, parent, CLK_SET_RATE_PARENT, reg, |
Alexander Shiyan | 6525169 | 2014-06-22 17:17:06 +0400 | [diff] [blame] | 302 | shift, CLK_GATE_SET_TO_DISABLE, &imx_ccm_lock); |
| 303 | } |
| 304 | |
Abel Vesa | eccf8df | 2019-05-29 12:26:45 +0000 | [diff] [blame] | 305 | static inline struct clk_hw *imx_clk_hw_gate_dis_flags(const char *name, const char *parent, |
Anson Huang | febb654 | 2018-08-08 12:39:27 +0800 | [diff] [blame] | 306 | void __iomem *reg, u8 shift, unsigned long flags) |
| 307 | { |
Abel Vesa | eccf8df | 2019-05-29 12:26:45 +0000 | [diff] [blame] | 308 | return clk_hw_register_gate(NULL, name, parent, flags | CLK_SET_RATE_PARENT, reg, |
Anson Huang | febb654 | 2018-08-08 12:39:27 +0800 | [diff] [blame] | 309 | shift, CLK_GATE_SET_TO_DISABLE, &imx_ccm_lock); |
| 310 | } |
| 311 | |
Abel Vesa | eccf8df | 2019-05-29 12:26:45 +0000 | [diff] [blame] | 312 | static inline struct clk_hw *imx_clk_hw_gate2(const char *name, const char *parent, |
Dong Aisheng | 5afc994 | 2016-06-30 17:31:15 +0800 | [diff] [blame] | 313 | void __iomem *reg, u8 shift) |
| 314 | { |
Abel Vesa | eccf8df | 2019-05-29 12:26:45 +0000 | [diff] [blame] | 315 | return clk_hw_register_gate2(NULL, name, parent, CLK_SET_RATE_PARENT, reg, |
Dong Aisheng | 5afc994 | 2016-06-30 17:31:15 +0800 | [diff] [blame] | 316 | shift, 0x3, 0, &imx_ccm_lock, NULL); |
| 317 | } |
| 318 | |
Abel Vesa | eccf8df | 2019-05-29 12:26:45 +0000 | [diff] [blame] | 319 | static inline struct clk_hw *imx_clk_hw_gate2_flags(const char *name, const char *parent, |
Bai Ping | 2b18cc1 | 2018-03-20 10:24:02 +0800 | [diff] [blame] | 320 | void __iomem *reg, u8 shift, unsigned long flags) |
| 321 | { |
Abel Vesa | eccf8df | 2019-05-29 12:26:45 +0000 | [diff] [blame] | 322 | return clk_hw_register_gate2(NULL, name, parent, flags | CLK_SET_RATE_PARENT, reg, |
Bai Ping | 2b18cc1 | 2018-03-20 10:24:02 +0800 | [diff] [blame] | 323 | shift, 0x3, 0, &imx_ccm_lock, NULL); |
| 324 | } |
| 325 | |
Abel Vesa | eccf8df | 2019-05-29 12:26:45 +0000 | [diff] [blame] | 326 | static inline struct clk_hw *imx_clk_hw_gate2_shared(const char *name, |
Dong Aisheng | 5afc994 | 2016-06-30 17:31:15 +0800 | [diff] [blame] | 327 | const char *parent, void __iomem *reg, u8 shift, |
| 328 | unsigned int *share_count) |
| 329 | { |
Abel Vesa | eccf8df | 2019-05-29 12:26:45 +0000 | [diff] [blame] | 330 | return clk_hw_register_gate2(NULL, name, parent, CLK_SET_RATE_PARENT, reg, |
Dong Aisheng | 5afc994 | 2016-06-30 17:31:15 +0800 | [diff] [blame] | 331 | shift, 0x3, 0, &imx_ccm_lock, share_count); |
| 332 | } |
| 333 | |
Abel Vesa | eccf8df | 2019-05-29 12:26:45 +0000 | [diff] [blame] | 334 | static inline struct clk_hw *imx_clk_hw_gate2_shared2(const char *name, |
Fabio Estevam | d5ebf5f | 2016-08-12 15:26:55 -0300 | [diff] [blame] | 335 | const char *parent, void __iomem *reg, u8 shift, |
| 336 | unsigned int *share_count) |
| 337 | { |
Abel Vesa | eccf8df | 2019-05-29 12:26:45 +0000 | [diff] [blame] | 338 | return clk_hw_register_gate2(NULL, name, parent, CLK_SET_RATE_PARENT | |
Fabio Estevam | d5ebf5f | 2016-08-12 15:26:55 -0300 | [diff] [blame] | 339 | CLK_OPS_PARENT_ENABLE, reg, shift, 0x3, 0, |
| 340 | &imx_ccm_lock, share_count); |
| 341 | } |
| 342 | |
Dong Aisheng | 5afc994 | 2016-06-30 17:31:15 +0800 | [diff] [blame] | 343 | static 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 Vesa | eccf8df | 2019-05-29 12:26:45 +0000 | [diff] [blame] | 350 | static inline struct clk_hw *imx_clk_hw_gate3(const char *name, const char *parent, |
Dong Aisheng | 39c2949 | 2016-06-30 17:31:16 +0800 | [diff] [blame] | 351 | void __iomem *reg, u8 shift) |
| 352 | { |
Abel Vesa | eccf8df | 2019-05-29 12:26:45 +0000 | [diff] [blame] | 353 | return clk_hw_register_gate(NULL, name, parent, |
Dong Aisheng | 39c2949 | 2016-06-30 17:31:16 +0800 | [diff] [blame] | 354 | CLK_SET_RATE_PARENT | CLK_OPS_PARENT_ENABLE, |
| 355 | reg, shift, 0, &imx_ccm_lock); |
| 356 | } |
| 357 | |
Abel Vesa | b805220 | 2018-12-01 10:52:15 +0000 | [diff] [blame] | 358 | static 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 Vesa | eccf8df | 2019-05-29 12:26:45 +0000 | [diff] [blame] | 367 | static inline struct clk_hw *imx_clk_hw_gate4(const char *name, const char *parent, |
Dong Aisheng | 39c2949 | 2016-06-30 17:31:16 +0800 | [diff] [blame] | 368 | void __iomem *reg, u8 shift) |
| 369 | { |
Abel Vesa | eccf8df | 2019-05-29 12:26:45 +0000 | [diff] [blame] | 370 | return clk_hw_register_gate2(NULL, name, parent, |
Dong Aisheng | 39c2949 | 2016-06-30 17:31:16 +0800 | [diff] [blame] | 371 | CLK_SET_RATE_PARENT | CLK_OPS_PARENT_ENABLE, |
| 372 | reg, shift, 0x3, 0, &imx_ccm_lock, NULL); |
| 373 | } |
| 374 | |
Abel Vesa | b805220 | 2018-12-01 10:52:15 +0000 | [diff] [blame] | 375 | static 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 Vesa | eccf8df | 2019-05-29 12:26:45 +0000 | [diff] [blame] | 384 | static inline struct clk_hw *imx_clk_hw_mux(const char *name, void __iomem *reg, |
A.s. Dong | 9e5ef7a | 2018-11-14 13:02:00 +0000 | [diff] [blame] | 385 | u8 shift, u8 width, const char * const *parents, |
| 386 | int num_parents) |
Sascha Hauer | 6c7b06850 | 2012-03-07 21:01:28 +0100 | [diff] [blame] | 387 | { |
Abel Vesa | eccf8df | 2019-05-29 12:26:45 +0000 | [diff] [blame] | 388 | return clk_hw_register_mux(NULL, name, parents, num_parents, |
James Hogan | 819c1de | 2013-07-29 12:25:01 +0100 | [diff] [blame] | 389 | CLK_SET_RATE_NO_REPARENT, reg, shift, |
Sascha Hauer | 6c7b06850 | 2012-03-07 21:01:28 +0100 | [diff] [blame] | 390 | width, 0, &imx_ccm_lock); |
| 391 | } |
| 392 | |
Dong Aisheng | 39c2949 | 2016-06-30 17:31:16 +0800 | [diff] [blame] | 393 | static inline struct clk *imx_clk_mux2(const char *name, void __iomem *reg, |
A.s. Dong | 9e5ef7a | 2018-11-14 13:02:00 +0000 | [diff] [blame] | 394 | u8 shift, u8 width, const char * const *parents, |
| 395 | int num_parents) |
Dong Aisheng | 39c2949 | 2016-06-30 17:31:16 +0800 | [diff] [blame] | 396 | { |
| 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. Dong | 3b31521 | 2018-11-14 13:02:04 +0000 | [diff] [blame] | 402 | static 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 Zabel | 3ce9217 | 2013-03-27 18:30:40 +0100 | [diff] [blame] | 413 | static inline struct clk *imx_clk_mux_flags(const char *name, |
A.s. Dong | 9e5ef7a | 2018-11-14 13:02:00 +0000 | [diff] [blame] | 414 | void __iomem *reg, u8 shift, u8 width, |
| 415 | const char * const *parents, int num_parents, |
| 416 | unsigned long flags) |
Philipp Zabel | 3ce9217 | 2013-03-27 18:30:40 +0100 | [diff] [blame] | 417 | { |
| 418 | return clk_register_mux(NULL, name, parents, num_parents, |
James Hogan | 819c1de | 2013-07-29 12:25:01 +0100 | [diff] [blame] | 419 | flags | CLK_SET_RATE_NO_REPARENT, reg, shift, width, 0, |
Philipp Zabel | 3ce9217 | 2013-03-27 18:30:40 +0100 | [diff] [blame] | 420 | &imx_ccm_lock); |
| 421 | } |
| 422 | |
Abel Vesa | b805220 | 2018-12-01 10:52:15 +0000 | [diff] [blame] | 423 | static inline struct clk *imx_clk_mux2_flags(const char *name, |
Abel Vesa | 470663e | 2018-12-14 15:30:10 +0000 | [diff] [blame] | 424 | void __iomem *reg, u8 shift, u8 width, |
| 425 | const char * const *parents, |
Abel Vesa | b805220 | 2018-12-01 10:52:15 +0000 | [diff] [blame] | 426 | 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. Dong | 3b31521 | 2018-11-14 13:02:04 +0000 | [diff] [blame] | 433 | static 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 Vesa | 2bc7e9d | 2019-05-29 12:26:42 +0000 | [diff] [blame] | 445 | struct clk_hw *imx_clk_hw_cpu(const char *name, const char *parent_name, |
Lucas Stach | e0fed51 | 2014-09-26 15:41:01 +0200 | [diff] [blame] | 446 | struct clk *div, struct clk *mux, struct clk *pll, |
| 447 | struct clk *step); |
| 448 | |
Abel Vesa | d3ff972 | 2018-12-01 10:52:14 +0000 | [diff] [blame] | 449 | struct clk *imx8m_clk_composite_flags(const char *name, |
Abel Vesa | 65a6b7c | 2018-12-14 15:30:09 +0000 | [diff] [blame] | 450 | const char * const *parent_names, |
Abel Vesa | d3ff972 | 2018-12-01 10:52:14 +0000 | [diff] [blame] | 451 | 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. Dong | 4046807 | 2018-11-14 13:01:35 +0000 | [diff] [blame] | 465 | struct 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 Hauer | 6c7b06850 | 2012-03-07 21:01:28 +0100 | [diff] [blame] | 469 | #endif |