4 #include <linux/clk-provider.h>
6 #include "ccu_common.h"
8 struct ccu_mux_fixed_prediv
{
13 struct ccu_mux_internal
{
18 const struct ccu_mux_fixed_prediv
*fixed_predivs
;
28 #define _SUNXI_CCU_MUX_TABLE(_shift, _width, _table) \
35 #define _SUNXI_CCU_MUX(_shift, _width) \
36 _SUNXI_CCU_MUX_TABLE(_shift, _width, NULL)
42 struct ccu_mux_internal mux
;
43 struct ccu_common common
;
46 #define SUNXI_CCU_MUX_TABLE_WITH_GATE(_struct, _name, _parents, _table, \
47 _reg, _shift, _width, _gate, \
49 struct ccu_mux _struct = { \
51 .mux = _SUNXI_CCU_MUX_TABLE(_shift, _width, _table), \
54 .hw.init = CLK_HW_INIT_PARENTS(_name, \
61 #define SUNXI_CCU_MUX_WITH_GATE(_struct, _name, _parents, _reg, \
62 _shift, _width, _gate, _flags) \
63 SUNXI_CCU_MUX_TABLE_WITH_GATE(_struct, _name, _parents, NULL, \
64 _reg, _shift, _width, _gate, \
67 #define SUNXI_CCU_MUX(_struct, _name, _parents, _reg, _shift, _width, \
69 SUNXI_CCU_MUX_TABLE_WITH_GATE(_struct, _name, _parents, NULL, \
70 _reg, _shift, _width, 0, _flags)
72 static inline struct ccu_mux
*hw_to_ccu_mux(struct clk_hw
*hw
)
74 struct ccu_common
*common
= hw_to_ccu_common(hw
);
76 return container_of(common
, struct ccu_mux
, common
);
79 extern const struct clk_ops ccu_mux_ops
;
81 void ccu_mux_helper_adjust_parent_for_prediv(struct ccu_common
*common
,
82 struct ccu_mux_internal
*cm
,
84 unsigned long *parent_rate
);
85 int ccu_mux_helper_determine_rate(struct ccu_common
*common
,
86 struct ccu_mux_internal
*cm
,
87 struct clk_rate_request
*req
,
88 unsigned long (*round
)(struct ccu_mux_internal
*,
93 u8
ccu_mux_helper_get_parent(struct ccu_common
*common
,
94 struct ccu_mux_internal
*cm
);
95 int ccu_mux_helper_set_parent(struct ccu_common
*common
,
96 struct ccu_mux_internal
*cm
,
100 struct notifier_block clk_nb
;
101 struct ccu_common
*common
;
102 struct ccu_mux_internal
*cm
;
104 u32 delay_us
; /* How many us to wait after reparenting */
105 u8 bypass_index
; /* Which parent to temporarily use */
106 u8 original_index
; /* This is set by the notifier callback */
109 #define to_ccu_mux_nb(_nb) container_of(_nb, struct ccu_mux_nb, clk_nb)
111 int ccu_mux_notifier_register(struct clk
*clk
, struct ccu_mux_nb
*mux_nb
);
113 #endif /* _CCU_MUX_H_ */