]>
Commit | Line | Data |
---|---|---|
2a65ed42 MR |
1 | #ifndef _CCU_MUX_H_ |
2 | #define _CCU_MUX_H_ | |
3 | ||
4 | #include <linux/clk-provider.h> | |
5 | ||
6 | #include "ccu_common.h" | |
7 | ||
8 | struct ccu_mux_internal { | |
2b9c875c CYT |
9 | u8 shift; |
10 | u8 width; | |
11 | const u8 *table; | |
2a65ed42 MR |
12 | |
13 | struct { | |
14 | u8 index; | |
178ca531 | 15 | u16 div; |
2a65ed42 MR |
16 | } fixed_prediv; |
17 | ||
18 | struct { | |
19 | u8 index; | |
20 | u8 shift; | |
21 | u8 width; | |
22 | } variable_prediv; | |
23 | }; | |
24 | ||
2b9c875c CYT |
25 | #define _SUNXI_CCU_MUX_TABLE(_shift, _width, _table) \ |
26 | { \ | |
27 | .shift = _shift, \ | |
28 | .width = _width, \ | |
29 | .table = _table, \ | |
2a65ed42 MR |
30 | } |
31 | ||
2b9c875c CYT |
32 | #define _SUNXI_CCU_MUX(_shift, _width) \ |
33 | _SUNXI_CCU_MUX_TABLE(_shift, _width, NULL) | |
34 | ||
2a65ed42 MR |
35 | struct ccu_mux { |
36 | u16 reg; | |
37 | u32 enable; | |
38 | ||
39 | struct ccu_mux_internal mux; | |
40 | struct ccu_common common; | |
41 | }; | |
42 | ||
43 | #define SUNXI_CCU_MUX(_struct, _name, _parents, _reg, _shift, _width, _flags) \ | |
44 | struct ccu_mux _struct = { \ | |
89af8525 | 45 | .mux = _SUNXI_CCU_MUX(_shift, _width), \ |
2a65ed42 MR |
46 | .common = { \ |
47 | .reg = _reg, \ | |
48 | .hw.init = CLK_HW_INIT_PARENTS(_name, \ | |
49 | _parents, \ | |
50 | &ccu_mux_ops, \ | |
51 | _flags), \ | |
52 | } \ | |
53 | } | |
54 | ||
55 | #define SUNXI_CCU_MUX_WITH_GATE(_struct, _name, _parents, _reg, \ | |
56 | _shift, _width, _gate, _flags) \ | |
57 | struct ccu_mux _struct = { \ | |
58 | .enable = _gate, \ | |
89af8525 | 59 | .mux = _SUNXI_CCU_MUX(_shift, _width), \ |
2a65ed42 MR |
60 | .common = { \ |
61 | .reg = _reg, \ | |
62 | .hw.init = CLK_HW_INIT_PARENTS(_name, \ | |
63 | _parents, \ | |
64 | &ccu_mux_ops, \ | |
65 | _flags), \ | |
66 | } \ | |
67 | } | |
68 | ||
69 | static inline struct ccu_mux *hw_to_ccu_mux(struct clk_hw *hw) | |
70 | { | |
71 | struct ccu_common *common = hw_to_ccu_common(hw); | |
72 | ||
73 | return container_of(common, struct ccu_mux, common); | |
74 | } | |
75 | ||
76 | extern const struct clk_ops ccu_mux_ops; | |
77 | ||
78 | void ccu_mux_helper_adjust_parent_for_prediv(struct ccu_common *common, | |
79 | struct ccu_mux_internal *cm, | |
80 | int parent_index, | |
81 | unsigned long *parent_rate); | |
82 | int ccu_mux_helper_determine_rate(struct ccu_common *common, | |
83 | struct ccu_mux_internal *cm, | |
84 | struct clk_rate_request *req, | |
85 | unsigned long (*round)(struct ccu_mux_internal *, | |
86 | unsigned long, | |
87 | unsigned long, | |
88 | void *), | |
89 | void *data); | |
90 | u8 ccu_mux_helper_get_parent(struct ccu_common *common, | |
91 | struct ccu_mux_internal *cm); | |
92 | int ccu_mux_helper_set_parent(struct ccu_common *common, | |
93 | struct ccu_mux_internal *cm, | |
94 | u8 index); | |
95 | ||
96 | #endif /* _CCU_MUX_H_ */ |