blob: 048c5ad8a80b67ed54b7d2dfa7f2d746a1356f30 [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
Liu Yingdfd87142013-07-04 17:57:17 +08009extern void imx_cscmr1_fixup(u32 *val);
10
Sascha Hauer2af9e6d2012-03-09 09:11:55 +010011struct clk *imx_clk_pllv1(const char *name, const char *parent,
Sascha Hauer6c7b068502012-03-07 21:01:28 +010012 void __iomem *base);
13
Sascha Hauera547b812012-03-19 12:36:10 +010014struct clk *imx_clk_pllv2(const char *name, const char *parent,
15 void __iomem *base);
16
Shawn Guoa3f6b9d2012-04-04 16:02:28 +080017enum imx_pllv3_type {
18 IMX_PLLV3_GENERIC,
19 IMX_PLLV3_SYS,
20 IMX_PLLV3_USB,
21 IMX_PLLV3_AV,
22 IMX_PLLV3_ENET,
Shawn Guoa3f6b9d2012-04-04 16:02:28 +080023};
24
25struct clk *imx_clk_pllv3(enum imx_pllv3_type type, const char *name,
Sascha Hauer2b254692012-11-22 10:18:41 +010026 const char *parent_name, void __iomem *base, u32 div_mask);
Shawn Guoa3f6b9d2012-04-04 16:02:28 +080027
Sascha Hauerb75c0152011-04-19 08:33:45 +020028struct clk *clk_register_gate2(struct device *dev, const char *name,
29 const char *parent_name, unsigned long flags,
30 void __iomem *reg, u8 bit_idx,
31 u8 clk_gate_flags, spinlock_t *lock);
32
Martin Fuzzey75f83d02013-04-23 20:16:59 +080033struct clk * imx_obtain_fixed_clock(
34 const char *name, unsigned long rate);
35
Sascha Hauerb75c0152011-04-19 08:33:45 +020036static inline struct clk *imx_clk_gate2(const char *name, const char *parent,
37 void __iomem *reg, u8 shift)
38{
39 return clk_register_gate2(NULL, name, parent, CLK_SET_RATE_PARENT, reg,
40 shift, 0, &imx_ccm_lock);
41}
42
Shawn Guoa10bd672012-04-04 16:07:53 +080043struct clk *imx_clk_pfd(const char *name, const char *parent_name,
44 void __iomem *reg, u8 idx);
45
Shawn Guo32af7a82012-04-04 16:20:56 +080046struct clk *imx_clk_busy_divider(const char *name, const char *parent_name,
47 void __iomem *reg, u8 shift, u8 width,
48 void __iomem *busy_reg, u8 busy_shift);
49
50struct clk *imx_clk_busy_mux(const char *name, void __iomem *reg, u8 shift,
51 u8 width, void __iomem *busy_reg, u8 busy_shift,
52 const char **parent_names, int num_parents);
53
Liu Yingcbe7fc82013-07-04 17:22:26 +080054struct clk *imx_clk_fixup_divider(const char *name, const char *parent,
55 void __iomem *reg, u8 shift, u8 width,
56 void (*fixup)(u32 *val));
57
Liu Yinga49e6c42013-07-04 17:35:46 +080058struct clk *imx_clk_fixup_mux(const char *name, void __iomem *reg,
59 u8 shift, u8 width, const char **parents,
60 int num_parents, void (*fixup)(u32 *val));
61
Sascha Hauer6c7b068502012-03-07 21:01:28 +010062static inline struct clk *imx_clk_fixed(const char *name, int rate)
63{
64 return clk_register_fixed_rate(NULL, name, NULL, CLK_IS_ROOT, rate);
65}
66
67static inline struct clk *imx_clk_divider(const char *name, const char *parent,
68 void __iomem *reg, u8 shift, u8 width)
69{
70 return clk_register_divider(NULL, name, parent, CLK_SET_RATE_PARENT,
71 reg, shift, width, 0, &imx_ccm_lock);
72}
73
Philipp Zabel3ce92172013-03-27 18:30:40 +010074static inline struct clk *imx_clk_divider_flags(const char *name,
75 const char *parent, void __iomem *reg, u8 shift, u8 width,
76 unsigned long flags)
77{
78 return clk_register_divider(NULL, name, parent, flags,
79 reg, shift, width, 0, &imx_ccm_lock);
80}
81
Sascha Hauer6c7b068502012-03-07 21:01:28 +010082static inline struct clk *imx_clk_gate(const char *name, const char *parent,
83 void __iomem *reg, u8 shift)
84{
85 return clk_register_gate(NULL, name, parent, CLK_SET_RATE_PARENT, reg,
86 shift, 0, &imx_ccm_lock);
87}
88
89static inline struct clk *imx_clk_mux(const char *name, void __iomem *reg,
90 u8 shift, u8 width, const char **parents, int num_parents)
91{
James Hogan819c1de2013-07-29 12:25:01 +010092 return clk_register_mux(NULL, name, parents, num_parents,
93 CLK_SET_RATE_NO_REPARENT, reg, shift,
Sascha Hauer6c7b068502012-03-07 21:01:28 +010094 width, 0, &imx_ccm_lock);
95}
96
Philipp Zabel3ce92172013-03-27 18:30:40 +010097static inline struct clk *imx_clk_mux_flags(const char *name,
98 void __iomem *reg, u8 shift, u8 width, const char **parents,
99 int num_parents, unsigned long flags)
100{
101 return clk_register_mux(NULL, name, parents, num_parents,
James Hogan819c1de2013-07-29 12:25:01 +0100102 flags | CLK_SET_RATE_NO_REPARENT, reg, shift, width, 0,
Philipp Zabel3ce92172013-03-27 18:30:40 +0100103 &imx_ccm_lock);
104}
105
Sascha Hauer6c7b068502012-03-07 21:01:28 +0100106static inline struct clk *imx_clk_fixed_factor(const char *name,
107 const char *parent, unsigned int mult, unsigned int div)
108{
109 return clk_register_fixed_factor(NULL, name, parent,
110 CLK_SET_RATE_PARENT, mult, div);
111}
112
113#endif