Emilio López | e874a66 | 2013-02-25 11:44:26 -0300 | [diff] [blame] | 1 | #ifndef __MACH_SUNXI_CLK_FACTORS_H |
| 2 | #define __MACH_SUNXI_CLK_FACTORS_H |
| 3 | |
| 4 | #include <linux/clk-provider.h> |
| 5 | #include <linux/clkdev.h> |
Maxime Ripard | 601da9d | 2014-07-04 22:24:52 +0200 | [diff] [blame] | 6 | #include <linux/spinlock.h> |
Emilio López | e874a66 | 2013-02-25 11:44:26 -0300 | [diff] [blame] | 7 | |
| 8 | #define SUNXI_FACTORS_NOT_APPLICABLE (0) |
| 9 | |
| 10 | struct clk_factors_config { |
| 11 | u8 nshift; |
| 12 | u8 nwidth; |
| 13 | u8 kshift; |
| 14 | u8 kwidth; |
| 15 | u8 mshift; |
| 16 | u8 mwidth; |
| 17 | u8 pshift; |
| 18 | u8 pwidth; |
Chen-Yu Tsai | 9a5e6c7 | 2014-06-26 23:55:41 +0800 | [diff] [blame] | 19 | u8 n_start; |
Emilio López | e874a66 | 2013-02-25 11:44:26 -0300 | [diff] [blame] | 20 | }; |
| 21 | |
Maxime Ripard | 601da9d | 2014-07-04 22:24:52 +0200 | [diff] [blame] | 22 | struct factors_data { |
| 23 | int enable; |
| 24 | int mux; |
Chen-Yu Tsai | e94f8cb3 | 2014-10-20 22:10:26 +0800 | [diff] [blame] | 25 | int muxmask; |
Maxime Ripard | 601da9d | 2014-07-04 22:24:52 +0200 | [diff] [blame] | 26 | struct clk_factors_config *table; |
| 27 | void (*getter) (u32 *rate, u32 parent_rate, u8 *n, u8 *k, u8 *m, u8 *p); |
| 28 | const char *name; |
| 29 | }; |
| 30 | |
Emilio López | 40a5dcb | 2013-12-23 00:32:32 -0300 | [diff] [blame] | 31 | struct clk_factors { |
| 32 | struct clk_hw hw; |
| 33 | void __iomem *reg; |
| 34 | struct clk_factors_config *config; |
| 35 | void (*get_factors) (u32 *rate, u32 parent, u8 *n, u8 *k, u8 *m, u8 *p); |
| 36 | spinlock_t *lock; |
| 37 | }; |
| 38 | |
Hans de Goede | 7c74c22 | 2014-11-23 14:38:07 +0100 | [diff] [blame] | 39 | struct clk *sunxi_factors_register(struct device_node *node, |
| 40 | const struct factors_data *data, |
| 41 | spinlock_t *lock, |
| 42 | void __iomem *reg); |
Maxime Ripard | 601da9d | 2014-07-04 22:24:52 +0200 | [diff] [blame] | 43 | |
Emilio López | e874a66 | 2013-02-25 11:44:26 -0300 | [diff] [blame] | 44 | #endif |