]> git.karo-electronics.de Git - karo-tx-linux.git/blob - arch/arm/mach-imx/clk.h
ENGR00277382-1 [MX6SL] Ensure that PLL1 and PLL2 are always enabled.
[karo-tx-linux.git] / arch / arm / mach-imx / clk.h
1 #ifndef __MACH_IMX_CLK_H
2 #define __MACH_IMX_CLK_H
3
4 #include <linux/spinlock.h>
5 #include <linux/clk-provider.h>
6
7 extern spinlock_t imx_ccm_lock;
8
9 extern void imx_cscmr1_fixup(u32 *val);
10
11 struct clk *imx_clk_pllv1(const char *name, const char *parent,
12                 void __iomem *base);
13
14 struct clk *imx_clk_pllv2(const char *name, const char *parent,
15                 void __iomem *base);
16
17 enum imx_pllv3_type {
18         IMX_PLLV3_GENERIC,
19         IMX_PLLV3_SYS,
20         IMX_PLLV3_USB,
21         IMX_PLLV3_AV,
22         IMX_PLLV3_ENET,
23 };
24
25 struct clk *imx_clk_pllv3(enum imx_pllv3_type type, const char *name,
26                 const char *parent_name, void __iomem *base,
27                 u32 div_mask, bool always_on);
28
29 struct clk *clk_register_gate2(struct device *dev, const char *name,
30                 const char *parent_name, unsigned long flags,
31                 void __iomem *reg, u8 bit_idx,
32                 u8 clk_gate_flags, spinlock_t *lock,
33                 unsigned int *share_count);
34
35 struct clk * imx_obtain_fixed_clock(
36                         const char *name, unsigned long rate);
37
38 static inline struct clk *imx_clk_gate2(const char *name, const char *parent,
39                 void __iomem *reg, u8 shift)
40 {
41         return clk_register_gate2(NULL, name, parent, CLK_SET_RATE_PARENT, reg,
42                         shift, 0, &imx_ccm_lock, NULL);
43 }
44
45 static inline struct clk *imx_clk_gate2_shared(const char *name,
46                 const char *parent, void __iomem *reg, u8 shift,
47                 unsigned int *share_count)
48 {
49         return clk_register_gate2(NULL, name, parent, CLK_SET_RATE_PARENT, reg,
50                         shift, 0, &imx_ccm_lock, share_count);
51 }
52
53 struct clk *imx_clk_pfd(const char *name, const char *parent_name,
54                 void __iomem *reg, u8 idx);
55
56 struct clk *imx_clk_busy_divider(const char *name, const char *parent_name,
57                                  void __iomem *reg, u8 shift, u8 width,
58                                  void __iomem *busy_reg, u8 busy_shift);
59
60 struct clk *imx_clk_busy_mux(const char *name, void __iomem *reg, u8 shift,
61                              u8 width, void __iomem *busy_reg, u8 busy_shift,
62                              const char **parent_names, int num_parents);
63
64 struct clk *imx_clk_fixup_divider(const char *name, const char *parent,
65                                   void __iomem *reg, u8 shift, u8 width,
66                                   void (*fixup)(u32 *val));
67
68 struct clk *imx_clk_fixup_mux(const char *name, void __iomem *reg,
69                               u8 shift, u8 width, const char **parents,
70                               int num_parents, void (*fixup)(u32 *val));
71
72 static inline struct clk *imx_clk_fixed(const char *name, int rate)
73 {
74         return clk_register_fixed_rate(NULL, name, NULL, CLK_IS_ROOT, rate);
75 }
76
77 static inline struct clk *imx_clk_divider(const char *name, const char *parent,
78                 void __iomem *reg, u8 shift, u8 width)
79 {
80         return clk_register_divider(NULL, name, parent, CLK_SET_RATE_PARENT,
81                         reg, shift, width, 0, &imx_ccm_lock);
82 }
83
84 static inline struct clk *imx_clk_divider_flags(const char *name,
85                 const char *parent, void __iomem *reg, u8 shift, u8 width,
86                 unsigned long flags)
87 {
88         return clk_register_divider(NULL, name, parent, flags,
89                         reg, shift, width, 0, &imx_ccm_lock);
90 }
91
92 static inline struct clk *imx_clk_gate(const char *name, const char *parent,
93                 void __iomem *reg, u8 shift)
94 {
95         return clk_register_gate(NULL, name, parent, CLK_SET_RATE_PARENT, reg,
96                         shift, 0, &imx_ccm_lock);
97 }
98
99 static inline struct clk *imx_clk_mux(const char *name, void __iomem *reg,
100                 u8 shift, u8 width, const char **parents, int num_parents)
101 {
102         return clk_register_mux(NULL, name, parents, num_parents,
103                         CLK_SET_RATE_NO_REPARENT, reg, shift,
104                         width, 0, &imx_ccm_lock);
105 }
106
107 static inline struct clk *imx_clk_mux_flags(const char *name,
108                 void __iomem *reg, u8 shift, u8 width, const char **parents,
109                 int num_parents, unsigned long flags)
110 {
111         return clk_register_mux(NULL, name, parents, num_parents,
112                         flags | CLK_SET_RATE_NO_REPARENT, reg, shift, width, 0,
113                         &imx_ccm_lock);
114 }
115
116 static inline struct clk *imx_clk_fixed_factor(const char *name,
117                 const char *parent, unsigned int mult, unsigned int div)
118 {
119         return clk_register_fixed_factor(NULL, name, parent,
120                         CLK_SET_RATE_PARENT, mult, div);
121 }
122
123 #endif