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> |
Maxime Ripard | 601da9d | 2014-07-04 22:24:52 +0200 | [diff] [blame] | 5 | #include <linux/spinlock.h> |
Emilio López | e874a66 | 2013-02-25 11:44:26 -0300 | [diff] [blame] | 6 | |
| 7 | #define SUNXI_FACTORS_NOT_APPLICABLE (0) |
| 8 | |
| 9 | struct clk_factors_config { |
| 10 | u8 nshift; |
| 11 | u8 nwidth; |
| 12 | u8 kshift; |
| 13 | u8 kwidth; |
| 14 | u8 mshift; |
| 15 | u8 mwidth; |
| 16 | u8 pshift; |
| 17 | u8 pwidth; |
Chen-Yu Tsai | 9a5e6c7 | 2014-06-26 23:55:41 +0800 | [diff] [blame] | 18 | u8 n_start; |
Emilio López | e874a66 | 2013-02-25 11:44:26 -0300 | [diff] [blame] | 19 | }; |
| 20 | |
Chen-Yu Tsai | cfa63688 | 2016-01-25 21:15:42 +0800 | [diff] [blame] | 21 | struct factors_request { |
| 22 | unsigned long rate; |
| 23 | unsigned long parent_rate; |
Chen-Yu Tsai | 435b7be | 2016-01-25 21:15:43 +0800 | [diff] [blame] | 24 | u8 parent_index; |
Chen-Yu Tsai | cfa63688 | 2016-01-25 21:15:42 +0800 | [diff] [blame] | 25 | u8 n; |
| 26 | u8 k; |
| 27 | u8 m; |
| 28 | u8 p; |
| 29 | }; |
| 30 | |
Maxime Ripard | 601da9d | 2014-07-04 22:24:52 +0200 | [diff] [blame] | 31 | struct factors_data { |
| 32 | int enable; |
| 33 | int mux; |
Chen-Yu Tsai | e94f8cb3 | 2014-10-20 22:10:26 +0800 | [diff] [blame] | 34 | int muxmask; |
Chen-Yu Tsai | b3e919e | 2016-01-25 21:15:38 +0800 | [diff] [blame] | 35 | const struct clk_factors_config *table; |
Chen-Yu Tsai | cfa63688 | 2016-01-25 21:15:42 +0800 | [diff] [blame] | 36 | void (*getter)(struct factors_request *req); |
Chen-Yu Tsai | 435b7be | 2016-01-25 21:15:43 +0800 | [diff] [blame] | 37 | void (*recalc)(struct factors_request *req); |
Maxime Ripard | 601da9d | 2014-07-04 22:24:52 +0200 | [diff] [blame] | 38 | const char *name; |
| 39 | }; |
| 40 | |
Emilio López | 40a5dcb | 2013-12-23 00:32:32 -0300 | [diff] [blame] | 41 | struct clk_factors { |
| 42 | struct clk_hw hw; |
| 43 | void __iomem *reg; |
Chen-Yu Tsai | b3e919e | 2016-01-25 21:15:38 +0800 | [diff] [blame] | 44 | const struct clk_factors_config *config; |
Chen-Yu Tsai | cfa63688 | 2016-01-25 21:15:42 +0800 | [diff] [blame] | 45 | void (*get_factors)(struct factors_request *req); |
Chen-Yu Tsai | 435b7be | 2016-01-25 21:15:43 +0800 | [diff] [blame] | 46 | void (*recalc)(struct factors_request *req); |
Emilio López | 40a5dcb | 2013-12-23 00:32:32 -0300 | [diff] [blame] | 47 | spinlock_t *lock; |
Chen-Yu Tsai | 4cbeaeb | 2016-01-25 21:15:40 +0800 | [diff] [blame] | 48 | /* for cleanup */ |
| 49 | struct clk_mux *mux; |
| 50 | struct clk_gate *gate; |
Emilio López | 40a5dcb | 2013-12-23 00:32:32 -0300 | [diff] [blame] | 51 | }; |
| 52 | |
Hans de Goede | 7c74c22 | 2014-11-23 14:38:07 +0100 | [diff] [blame] | 53 | struct clk *sunxi_factors_register(struct device_node *node, |
| 54 | const struct factors_data *data, |
| 55 | spinlock_t *lock, |
| 56 | void __iomem *reg); |
Maxime Ripard | 601da9d | 2014-07-04 22:24:52 +0200 | [diff] [blame] | 57 | |
Chen-Yu Tsai | 4cbeaeb | 2016-01-25 21:15:40 +0800 | [diff] [blame] | 58 | void sunxi_factors_unregister(struct device_node *node, struct clk *clk); |
| 59 | |
Emilio López | e874a66 | 2013-02-25 11:44:26 -0300 | [diff] [blame] | 60 | #endif |