1 #ifndef __MACH_IMX_CLK_H
2 #define __MACH_IMX_CLK_H
4 #include <linux/spinlock.h>
5 #include <linux/clk-provider.h>
7 extern spinlock_t imx_ccm_lock
;
9 void imx_check_clocks(struct clk
*clks
[], unsigned int count
);
10 void imx_register_uart_clocks(struct clk
** const clks
[]);
12 extern void imx_cscmr1_fixup(u32
*val
);
23 struct clk
*imx_clk_pllv1(enum imx_pllv1_type type
, const char *name
,
24 const char *parent
, void __iomem
*base
);
26 struct clk
*imx_clk_pllv2(const char *name
, const char *parent
,
39 struct clk
*imx_clk_pllv3(enum imx_pllv3_type type
, const char *name
,
40 const char *parent_name
, void __iomem
*base
, u32 div_mask
);
42 struct clk
*clk_register_gate2(struct device
*dev
, const char *name
,
43 const char *parent_name
, unsigned long flags
,
44 void __iomem
*reg
, u8 bit_idx
,
45 u8 clk_gate_flags
, spinlock_t
*lock
,
46 unsigned int *share_count
);
48 struct clk
* imx_obtain_fixed_clock(
49 const char *name
, unsigned long rate
);
51 struct clk
*imx_clk_gate_exclusive(const char *name
, const char *parent
,
52 void __iomem
*reg
, u8 shift
, u32 exclusive_mask
);
54 static inline struct clk
*imx_clk_gate2(const char *name
, const char *parent
,
55 void __iomem
*reg
, u8 shift
)
57 return clk_register_gate2(NULL
, name
, parent
, CLK_SET_RATE_PARENT
, reg
,
58 shift
, 0, &imx_ccm_lock
, NULL
);
61 static inline struct clk
*imx_clk_gate2_shared(const char *name
,
62 const char *parent
, void __iomem
*reg
, u8 shift
,
63 unsigned int *share_count
)
65 return clk_register_gate2(NULL
, name
, parent
, CLK_SET_RATE_PARENT
, reg
,
66 shift
, 0, &imx_ccm_lock
, share_count
);
69 struct clk
*imx_clk_pfd(const char *name
, const char *parent_name
,
70 void __iomem
*reg
, u8 idx
);
72 struct clk
*imx_clk_busy_divider(const char *name
, const char *parent_name
,
73 void __iomem
*reg
, u8 shift
, u8 width
,
74 void __iomem
*busy_reg
, u8 busy_shift
);
76 struct clk
*imx_clk_busy_mux(const char *name
, void __iomem
*reg
, u8 shift
,
77 u8 width
, void __iomem
*busy_reg
, u8 busy_shift
,
78 const char **parent_names
, int num_parents
);
80 struct clk
*imx_clk_fixup_divider(const char *name
, const char *parent
,
81 void __iomem
*reg
, u8 shift
, u8 width
,
82 void (*fixup
)(u32
*val
));
84 struct clk
*imx_clk_fixup_mux(const char *name
, void __iomem
*reg
,
85 u8 shift
, u8 width
, const char **parents
,
86 int num_parents
, void (*fixup
)(u32
*val
));
88 static inline struct clk
*imx_clk_fixed(const char *name
, int rate
)
90 return clk_register_fixed_rate(NULL
, name
, NULL
, CLK_IS_ROOT
, rate
);
93 static inline struct clk
*imx_clk_divider(const char *name
, const char *parent
,
94 void __iomem
*reg
, u8 shift
, u8 width
)
96 return clk_register_divider(NULL
, name
, parent
, CLK_SET_RATE_PARENT
,
97 reg
, shift
, width
, 0, &imx_ccm_lock
);
100 static inline struct clk
*imx_clk_divider_flags(const char *name
,
101 const char *parent
, void __iomem
*reg
, u8 shift
, u8 width
,
104 return clk_register_divider(NULL
, name
, parent
, flags
,
105 reg
, shift
, width
, 0, &imx_ccm_lock
);
108 static inline struct clk
*imx_clk_gate(const char *name
, const char *parent
,
109 void __iomem
*reg
, u8 shift
)
111 return clk_register_gate(NULL
, name
, parent
, CLK_SET_RATE_PARENT
, reg
,
112 shift
, 0, &imx_ccm_lock
);
115 static inline struct clk
*imx_clk_gate_dis(const char *name
, const char *parent
,
116 void __iomem
*reg
, u8 shift
)
118 return clk_register_gate(NULL
, name
, parent
, CLK_SET_RATE_PARENT
, reg
,
119 shift
, CLK_GATE_SET_TO_DISABLE
, &imx_ccm_lock
);
122 static inline struct clk
*imx_clk_mux(const char *name
, void __iomem
*reg
,
123 u8 shift
, u8 width
, const char **parents
, int num_parents
)
125 return clk_register_mux(NULL
, name
, parents
, num_parents
,
126 CLK_SET_RATE_NO_REPARENT
, reg
, shift
,
127 width
, 0, &imx_ccm_lock
);
130 static inline struct clk
*imx_clk_mux_flags(const char *name
,
131 void __iomem
*reg
, u8 shift
, u8 width
, const char **parents
,
132 int num_parents
, unsigned long flags
)
134 return clk_register_mux(NULL
, name
, parents
, num_parents
,
135 flags
| CLK_SET_RATE_NO_REPARENT
, reg
, shift
, width
, 0,
139 static inline struct clk
*imx_clk_fixed_factor(const char *name
,
140 const char *parent
, unsigned int mult
, unsigned int div
)
142 return clk_register_fixed_factor(NULL
, name
, parent
,
143 CLK_SET_RATE_PARENT
, mult
, div
);
146 struct clk
*imx_clk_cpu(const char *name
, const char *parent_name
,
147 struct clk
*div
, struct clk
*mux
, struct clk
*pll
,