blob: 6a07903a28bc81e8123985fc179d0ca17de9b6e9 [file] [log] [blame]
Sascha Hauer6c7b068502012-03-07 21:01:28 +01001#ifndef __MACH_IMX_CLK_H
2#define __MACH_IMX_CLK_H
3
4#include <linux/spinlock.h>
5#include <linux/clk-provider.h>
Sascha Hauer3a84d172012-09-11 08:50:00 +02006
7extern spinlock_t imx_ccm_lock;
Sascha Hauer6c7b068502012-03-07 21:01:28 +01008
Alexander Shiyan229be9c2014-06-10 19:40:26 +04009void imx_check_clocks(struct clk *clks[], unsigned int count);
10
Liu Yingdfd87142013-07-04 17:57:17 +080011extern void imx_cscmr1_fixup(u32 *val);
12
Sascha Hauer2af9e6d2012-03-09 09:11:55 +010013struct clk *imx_clk_pllv1(const char *name, const char *parent,
Sascha Hauer6c7b068502012-03-07 21:01:28 +010014 void __iomem *base);
15
Sascha Hauera547b812012-03-19 12:36:10 +010016struct clk *imx_clk_pllv2(const char *name, const char *parent,
17 void __iomem *base);
18
Shawn Guoa3f6b9d2012-04-04 16:02:28 +080019enum imx_pllv3_type {
20 IMX_PLLV3_GENERIC,
21 IMX_PLLV3_SYS,
22 IMX_PLLV3_USB,
Stefan Agner60ad8462014-12-02 17:59:42 +010023 IMX_PLLV3_USB_VF610,
Shawn Guoa3f6b9d2012-04-04 16:02:28 +080024 IMX_PLLV3_AV,
25 IMX_PLLV3_ENET,
Shawn Guoa3f6b9d2012-04-04 16:02:28 +080026};
27
28struct clk *imx_clk_pllv3(enum imx_pllv3_type type, const char *name,
Sascha Hauer2b254692012-11-22 10:18:41 +010029 const char *parent_name, void __iomem *base, u32 div_mask);
Shawn Guoa3f6b9d2012-04-04 16:02:28 +080030
Sascha Hauerb75c0152011-04-19 08:33:45 +020031struct clk *clk_register_gate2(struct device *dev, const char *name,
32 const char *parent_name, unsigned long flags,
33 void __iomem *reg, u8 bit_idx,
Shawn Guof9f28cd2014-04-19 10:58:22 +080034 u8 clk_gate_flags, spinlock_t *lock,
35 unsigned int *share_count);
Sascha Hauerb75c0152011-04-19 08:33:45 +020036
Martin Fuzzey75f83d02013-04-23 20:16:59 +080037struct clk * imx_obtain_fixed_clock(
38 const char *name, unsigned long rate);
39
Shawn Guo19d86342014-08-26 15:06:33 +080040struct clk *imx_clk_gate_exclusive(const char *name, const char *parent,
41 void __iomem *reg, u8 shift, u32 exclusive_mask);
42
Sascha Hauerb75c0152011-04-19 08:33:45 +020043static inline struct clk *imx_clk_gate2(const char *name, const char *parent,
44 void __iomem *reg, u8 shift)
45{
46 return clk_register_gate2(NULL, name, parent, CLK_SET_RATE_PARENT, reg,
Shawn Guof9f28cd2014-04-19 10:58:22 +080047 shift, 0, &imx_ccm_lock, NULL);
48}
49
50static inline struct clk *imx_clk_gate2_shared(const char *name,
51 const char *parent, void __iomem *reg, u8 shift,
52 unsigned int *share_count)
53{
54 return clk_register_gate2(NULL, name, parent, CLK_SET_RATE_PARENT, reg,
55 shift, 0, &imx_ccm_lock, share_count);
Sascha Hauerb75c0152011-04-19 08:33:45 +020056}
57
Shawn Guoa10bd672012-04-04 16:07:53 +080058struct clk *imx_clk_pfd(const char *name, const char *parent_name,
59 void __iomem *reg, u8 idx);
60
Shawn Guo32af7a82012-04-04 16:20:56 +080061struct clk *imx_clk_busy_divider(const char *name, const char *parent_name,
62 void __iomem *reg, u8 shift, u8 width,
63 void __iomem *busy_reg, u8 busy_shift);
64
65struct clk *imx_clk_busy_mux(const char *name, void __iomem *reg, u8 shift,
66 u8 width, void __iomem *busy_reg, u8 busy_shift,
67 const char **parent_names, int num_parents);
68
Liu Yingcbe7fc82013-07-04 17:22:26 +080069struct clk *imx_clk_fixup_divider(const char *name, const char *parent,
70 void __iomem *reg, u8 shift, u8 width,
71 void (*fixup)(u32 *val));
72
Liu Yinga49e6c42013-07-04 17:35:46 +080073struct clk *imx_clk_fixup_mux(const char *name, void __iomem *reg,
74 u8 shift, u8 width, const char **parents,
75 int num_parents, void (*fixup)(u32 *val));
76
Sascha Hauer6c7b068502012-03-07 21:01:28 +010077static inline struct clk *imx_clk_fixed(const char *name, int rate)
78{
79 return clk_register_fixed_rate(NULL, name, NULL, CLK_IS_ROOT, rate);
80}
81
82static inline struct clk *imx_clk_divider(const char *name, const char *parent,
83 void __iomem *reg, u8 shift, u8 width)
84{
85 return clk_register_divider(NULL, name, parent, CLK_SET_RATE_PARENT,
86 reg, shift, width, 0, &imx_ccm_lock);
87}
88
Philipp Zabel3ce92172013-03-27 18:30:40 +010089static inline struct clk *imx_clk_divider_flags(const char *name,
90 const char *parent, void __iomem *reg, u8 shift, u8 width,
91 unsigned long flags)
92{
93 return clk_register_divider(NULL, name, parent, flags,
94 reg, shift, width, 0, &imx_ccm_lock);
95}
96
Sascha Hauer6c7b068502012-03-07 21:01:28 +010097static inline struct clk *imx_clk_gate(const char *name, const char *parent,
98 void __iomem *reg, u8 shift)
99{
100 return clk_register_gate(NULL, name, parent, CLK_SET_RATE_PARENT, reg,
101 shift, 0, &imx_ccm_lock);
102}
103
Alexander Shiyan65251692014-06-22 17:17:06 +0400104static inline struct clk *imx_clk_gate_dis(const char *name, const char *parent,
105 void __iomem *reg, u8 shift)
106{
107 return clk_register_gate(NULL, name, parent, CLK_SET_RATE_PARENT, reg,
108 shift, CLK_GATE_SET_TO_DISABLE, &imx_ccm_lock);
109}
110
Sascha Hauer6c7b068502012-03-07 21:01:28 +0100111static inline struct clk *imx_clk_mux(const char *name, void __iomem *reg,
112 u8 shift, u8 width, const char **parents, int num_parents)
113{
James Hogan819c1de2013-07-29 12:25:01 +0100114 return clk_register_mux(NULL, name, parents, num_parents,
115 CLK_SET_RATE_NO_REPARENT, reg, shift,
Sascha Hauer6c7b068502012-03-07 21:01:28 +0100116 width, 0, &imx_ccm_lock);
117}
118
Philipp Zabel3ce92172013-03-27 18:30:40 +0100119static inline struct clk *imx_clk_mux_flags(const char *name,
120 void __iomem *reg, u8 shift, u8 width, const char **parents,
121 int num_parents, unsigned long flags)
122{
123 return clk_register_mux(NULL, name, parents, num_parents,
James Hogan819c1de2013-07-29 12:25:01 +0100124 flags | CLK_SET_RATE_NO_REPARENT, reg, shift, width, 0,
Philipp Zabel3ce92172013-03-27 18:30:40 +0100125 &imx_ccm_lock);
126}
127
Sascha Hauer6c7b068502012-03-07 21:01:28 +0100128static inline struct clk *imx_clk_fixed_factor(const char *name,
129 const char *parent, unsigned int mult, unsigned int div)
130{
131 return clk_register_fixed_factor(NULL, name, parent,
132 CLK_SET_RATE_PARENT, mult, div);
133}
134
Lucas Stache0fed512014-09-26 15:41:01 +0200135struct clk *imx_clk_cpu(const char *name, const char *parent_name,
136 struct clk *div, struct clk *mux, struct clk *pll,
137 struct clk *step);
138
Sascha Hauer6c7b068502012-03-07 21:01:28 +0100139#endif