]>
git.proxmox.com Git - mirror_ubuntu-focal-kernel.git/blob - drivers/clk/sunxi-ng/ccu_mux.h
4 #include <linux/clk-provider.h>
6 #include "ccu_common.h"
8 struct ccu_mux_fixed_prediv
{
13 struct ccu_mux_var_prediv
{
19 struct ccu_mux_internal
{
24 const struct ccu_mux_fixed_prediv
*fixed_predivs
;
27 const struct ccu_mux_var_prediv
*var_predivs
;
31 #define _SUNXI_CCU_MUX_TABLE(_shift, _width, _table) \
38 #define _SUNXI_CCU_MUX(_shift, _width) \
39 _SUNXI_CCU_MUX_TABLE(_shift, _width, NULL)
45 struct ccu_mux_internal mux
;
46 struct ccu_common common
;
49 #define SUNXI_CCU_MUX_TABLE_WITH_GATE(_struct, _name, _parents, _table, \
50 _reg, _shift, _width, _gate, \
52 struct ccu_mux _struct = { \
54 .mux = _SUNXI_CCU_MUX_TABLE(_shift, _width, _table), \
57 .hw.init = CLK_HW_INIT_PARENTS(_name, \
64 #define SUNXI_CCU_MUX_WITH_GATE(_struct, _name, _parents, _reg, \
65 _shift, _width, _gate, _flags) \
66 SUNXI_CCU_MUX_TABLE_WITH_GATE(_struct, _name, _parents, NULL, \
67 _reg, _shift, _width, _gate, \
70 #define SUNXI_CCU_MUX(_struct, _name, _parents, _reg, _shift, _width, \
72 SUNXI_CCU_MUX_TABLE_WITH_GATE(_struct, _name, _parents, NULL, \
73 _reg, _shift, _width, 0, _flags)
75 static inline struct ccu_mux
*hw_to_ccu_mux(struct clk_hw
*hw
)
77 struct ccu_common
*common
= hw_to_ccu_common(hw
);
79 return container_of(common
, struct ccu_mux
, common
);
82 extern const struct clk_ops ccu_mux_ops
;
84 unsigned long ccu_mux_helper_apply_prediv(struct ccu_common
*common
,
85 struct ccu_mux_internal
*cm
,
87 unsigned long parent_rate
);
88 int ccu_mux_helper_determine_rate(struct ccu_common
*common
,
89 struct ccu_mux_internal
*cm
,
90 struct clk_rate_request
*req
,
91 unsigned long (*round
)(struct ccu_mux_internal
*,
97 u8
ccu_mux_helper_get_parent(struct ccu_common
*common
,
98 struct ccu_mux_internal
*cm
);
99 int ccu_mux_helper_set_parent(struct ccu_common
*common
,
100 struct ccu_mux_internal
*cm
,
104 struct notifier_block clk_nb
;
105 struct ccu_common
*common
;
106 struct ccu_mux_internal
*cm
;
108 u32 delay_us
; /* How many us to wait after reparenting */
109 u8 bypass_index
; /* Which parent to temporarily use */
110 u8 original_index
; /* This is set by the notifier callback */
113 #define to_ccu_mux_nb(_nb) container_of(_nb, struct ccu_mux_nb, clk_nb)
115 int ccu_mux_notifier_register(struct clk
*clk
, struct ccu_mux_nb
*mux_nb
);
117 #endif /* _CCU_MUX_H_ */