Commit | Line | Data |
---|---|---|
b2441318 | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
e874a669 EL |
2 | #ifndef __MACH_SUNXI_CLK_FACTORS_H |
3 | #define __MACH_SUNXI_CLK_FACTORS_H | |
4 | ||
5 | #include <linux/clk-provider.h> | |
601da9d0 | 6 | #include <linux/spinlock.h> |
e874a669 EL |
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; | |
9a5e6c7e | 19 | u8 n_start; |
e874a669 EL |
20 | }; |
21 | ||
cfa63688 CYT |
22 | struct factors_request { |
23 | unsigned long rate; | |
24 | unsigned long parent_rate; | |
435b7be1 | 25 | u8 parent_index; |
cfa63688 CYT |
26 | u8 n; |
27 | u8 k; | |
28 | u8 m; | |
29 | u8 p; | |
30 | }; | |
31 | ||
601da9d0 MR |
32 | struct factors_data { |
33 | int enable; | |
34 | int mux; | |
e94f8cb3 | 35 | int muxmask; |
b3e919e0 | 36 | const struct clk_factors_config *table; |
cfa63688 | 37 | void (*getter)(struct factors_request *req); |
435b7be1 | 38 | void (*recalc)(struct factors_request *req); |
601da9d0 MR |
39 | const char *name; |
40 | }; | |
41 | ||
40a5dcba EL |
42 | struct clk_factors { |
43 | struct clk_hw hw; | |
44 | void __iomem *reg; | |
b3e919e0 | 45 | const struct clk_factors_config *config; |
cfa63688 | 46 | void (*get_factors)(struct factors_request *req); |
435b7be1 | 47 | void (*recalc)(struct factors_request *req); |
40a5dcba | 48 | spinlock_t *lock; |
4cbeaebb CYT |
49 | /* for cleanup */ |
50 | struct clk_mux *mux; | |
51 | struct clk_gate *gate; | |
40a5dcba EL |
52 | }; |
53 | ||
7c74c220 HG |
54 | struct clk *sunxi_factors_register(struct device_node *node, |
55 | const struct factors_data *data, | |
56 | spinlock_t *lock, | |
57 | void __iomem *reg); | |
601da9d0 | 58 | |
4cbeaebb CYT |
59 | void sunxi_factors_unregister(struct device_node *node, struct clk *clk); |
60 | ||
e874a669 | 61 | #endif |