Sascha Hauer | 6c7b06850 | 2012-03-07 21:01:28 +0100 | [diff] [blame] | 1 | #ifndef __MACH_IMX_CLK_H |
| 2 | #define __MACH_IMX_CLK_H |
| 3 | |
| 4 | #include <linux/spinlock.h> |
| 5 | #include <linux/clk-provider.h> |
Sascha Hauer | 3a84d17 | 2012-09-11 08:50:00 +0200 | [diff] [blame] | 6 | |
| 7 | extern spinlock_t imx_ccm_lock; |
Sascha Hauer | 6c7b06850 | 2012-03-07 21:01:28 +0100 | [diff] [blame] | 8 | |
Liu Ying | dfd8714 | 2013-07-04 17:57:17 +0800 | [diff] [blame] | 9 | extern void imx_cscmr1_fixup(u32 *val); |
| 10 | |
Sascha Hauer | 2af9e6d | 2012-03-09 09:11:55 +0100 | [diff] [blame] | 11 | struct clk *imx_clk_pllv1(const char *name, const char *parent, |
Sascha Hauer | 6c7b06850 | 2012-03-07 21:01:28 +0100 | [diff] [blame] | 12 | void __iomem *base); |
| 13 | |
Sascha Hauer | a547b81 | 2012-03-19 12:36:10 +0100 | [diff] [blame] | 14 | struct clk *imx_clk_pllv2(const char *name, const char *parent, |
| 15 | void __iomem *base); |
| 16 | |
Shawn Guo | a3f6b9d | 2012-04-04 16:02:28 +0800 | [diff] [blame] | 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, |
Shawn Guo | a3f6b9d | 2012-04-04 16:02:28 +0800 | [diff] [blame] | 23 | }; |
| 24 | |
| 25 | struct clk *imx_clk_pllv3(enum imx_pllv3_type type, const char *name, |
Sascha Hauer | 2b25469 | 2012-11-22 10:18:41 +0100 | [diff] [blame] | 26 | const char *parent_name, void __iomem *base, u32 div_mask); |
Shawn Guo | a3f6b9d | 2012-04-04 16:02:28 +0800 | [diff] [blame] | 27 | |
Sascha Hauer | b75c015 | 2011-04-19 08:33:45 +0200 | [diff] [blame] | 28 | struct 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 Fuzzey | 75f83d0 | 2013-04-23 20:16:59 +0800 | [diff] [blame] | 33 | struct clk * imx_obtain_fixed_clock( |
| 34 | const char *name, unsigned long rate); |
| 35 | |
Sascha Hauer | b75c015 | 2011-04-19 08:33:45 +0200 | [diff] [blame] | 36 | static 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 Guo | a10bd67 | 2012-04-04 16:07:53 +0800 | [diff] [blame] | 43 | struct clk *imx_clk_pfd(const char *name, const char *parent_name, |
| 44 | void __iomem *reg, u8 idx); |
| 45 | |
Shawn Guo | 32af7a8 | 2012-04-04 16:20:56 +0800 | [diff] [blame] | 46 | struct 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 | |
| 50 | struct 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 Ying | cbe7fc8 | 2013-07-04 17:22:26 +0800 | [diff] [blame] | 54 | struct 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 Ying | a49e6c4 | 2013-07-04 17:35:46 +0800 | [diff] [blame] | 58 | struct 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 Hauer | 6c7b06850 | 2012-03-07 21:01:28 +0100 | [diff] [blame] | 62 | static 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 | |
| 67 | static 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 Zabel | 3ce9217 | 2013-03-27 18:30:40 +0100 | [diff] [blame] | 74 | static 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 Hauer | 6c7b06850 | 2012-03-07 21:01:28 +0100 | [diff] [blame] | 82 | static 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 | |
| 89 | static 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 Hogan | 819c1de | 2013-07-29 12:25:01 +0100 | [diff] [blame] | 92 | return clk_register_mux(NULL, name, parents, num_parents, |
| 93 | CLK_SET_RATE_NO_REPARENT, reg, shift, |
Sascha Hauer | 6c7b06850 | 2012-03-07 21:01:28 +0100 | [diff] [blame] | 94 | width, 0, &imx_ccm_lock); |
| 95 | } |
| 96 | |
Philipp Zabel | 3ce9217 | 2013-03-27 18:30:40 +0100 | [diff] [blame] | 97 | static 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 Hogan | 819c1de | 2013-07-29 12:25:01 +0100 | [diff] [blame] | 102 | flags | CLK_SET_RATE_NO_REPARENT, reg, shift, width, 0, |
Philipp Zabel | 3ce9217 | 2013-03-27 18:30:40 +0100 | [diff] [blame] | 103 | &imx_ccm_lock); |
| 104 | } |
| 105 | |
Sascha Hauer | 6c7b06850 | 2012-03-07 21:01:28 +0100 | [diff] [blame] | 106 | static 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 |