blob: 2534359fdedc4341838e085aa1fcd1c271f76932 [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
Sascha Hauer2af9e6d2012-03-09 09:11:55 +01009struct clk *imx_clk_pllv1(const char *name, const char *parent,
Sascha Hauer6c7b068502012-03-07 21:01:28 +010010 void __iomem *base);
11
Sascha Hauera547b812012-03-19 12:36:10 +010012struct clk *imx_clk_pllv2(const char *name, const char *parent,
13 void __iomem *base);
14
Shawn Guoa3f6b9d2012-04-04 16:02:28 +080015enum imx_pllv3_type {
16 IMX_PLLV3_GENERIC,
17 IMX_PLLV3_SYS,
18 IMX_PLLV3_USB,
19 IMX_PLLV3_AV,
20 IMX_PLLV3_ENET,
Shawn Guoa3f6b9d2012-04-04 16:02:28 +080021};
22
23struct clk *imx_clk_pllv3(enum imx_pllv3_type type, const char *name,
Sascha Hauer2b254692012-11-22 10:18:41 +010024 const char *parent_name, void __iomem *base, u32 div_mask);
Shawn Guoa3f6b9d2012-04-04 16:02:28 +080025
Sascha Hauerb75c0152011-04-19 08:33:45 +020026struct clk *clk_register_gate2(struct device *dev, const char *name,
27 const char *parent_name, unsigned long flags,
28 void __iomem *reg, u8 bit_idx,
29 u8 clk_gate_flags, spinlock_t *lock);
30
Martin Fuzzey75f83d02013-04-23 20:16:59 +080031struct clk * imx_obtain_fixed_clock(
32 const char *name, unsigned long rate);
33
Sascha Hauerb75c0152011-04-19 08:33:45 +020034static inline struct clk *imx_clk_gate2(const char *name, const char *parent,
35 void __iomem *reg, u8 shift)
36{
37 return clk_register_gate2(NULL, name, parent, CLK_SET_RATE_PARENT, reg,
38 shift, 0, &imx_ccm_lock);
39}
40
Shawn Guoa10bd672012-04-04 16:07:53 +080041struct clk *imx_clk_pfd(const char *name, const char *parent_name,
42 void __iomem *reg, u8 idx);
43
Shawn Guo32af7a82012-04-04 16:20:56 +080044struct clk *imx_clk_busy_divider(const char *name, const char *parent_name,
45 void __iomem *reg, u8 shift, u8 width,
46 void __iomem *busy_reg, u8 busy_shift);
47
48struct clk *imx_clk_busy_mux(const char *name, void __iomem *reg, u8 shift,
49 u8 width, void __iomem *busy_reg, u8 busy_shift,
50 const char **parent_names, int num_parents);
51
Liu Yingcbe7fc82013-07-04 17:22:26 +080052struct clk *imx_clk_fixup_divider(const char *name, const char *parent,
53 void __iomem *reg, u8 shift, u8 width,
54 void (*fixup)(u32 *val));
55
Liu Yinga49e6c42013-07-04 17:35:46 +080056struct clk *imx_clk_fixup_mux(const char *name, void __iomem *reg,
57 u8 shift, u8 width, const char **parents,
58 int num_parents, void (*fixup)(u32 *val));
59
Sascha Hauer6c7b068502012-03-07 21:01:28 +010060static inline struct clk *imx_clk_fixed(const char *name, int rate)
61{
62 return clk_register_fixed_rate(NULL, name, NULL, CLK_IS_ROOT, rate);
63}
64
65static inline struct clk *imx_clk_divider(const char *name, const char *parent,
66 void __iomem *reg, u8 shift, u8 width)
67{
68 return clk_register_divider(NULL, name, parent, CLK_SET_RATE_PARENT,
69 reg, shift, width, 0, &imx_ccm_lock);
70}
71
Philipp Zabel3ce92172013-03-27 18:30:40 +010072static inline struct clk *imx_clk_divider_flags(const char *name,
73 const char *parent, void __iomem *reg, u8 shift, u8 width,
74 unsigned long flags)
75{
76 return clk_register_divider(NULL, name, parent, flags,
77 reg, shift, width, 0, &imx_ccm_lock);
78}
79
Sascha Hauer6c7b068502012-03-07 21:01:28 +010080static inline struct clk *imx_clk_gate(const char *name, const char *parent,
81 void __iomem *reg, u8 shift)
82{
83 return clk_register_gate(NULL, name, parent, CLK_SET_RATE_PARENT, reg,
84 shift, 0, &imx_ccm_lock);
85}
86
87static inline struct clk *imx_clk_mux(const char *name, void __iomem *reg,
88 u8 shift, u8 width, const char **parents, int num_parents)
89{
90 return clk_register_mux(NULL, name, parents, num_parents, 0, reg, shift,
91 width, 0, &imx_ccm_lock);
92}
93
Philipp Zabel3ce92172013-03-27 18:30:40 +010094static inline struct clk *imx_clk_mux_flags(const char *name,
95 void __iomem *reg, u8 shift, u8 width, const char **parents,
96 int num_parents, unsigned long flags)
97{
98 return clk_register_mux(NULL, name, parents, num_parents,
99 flags, reg, shift, width, 0,
100 &imx_ccm_lock);
101}
102
Sascha Hauer6c7b068502012-03-07 21:01:28 +0100103static inline struct clk *imx_clk_fixed_factor(const char *name,
104 const char *parent, unsigned int mult, unsigned int div)
105{
106 return clk_register_fixed_factor(NULL, name, parent,
107 CLK_SET_RATE_PARENT, mult, div);
108}
109
110#endif