1 // SPDX-License-Identifier: GPL-2.0
3 // Spreadtrum multiplexer clock driver
5 // Copyright (C) 2017 Spreadtrum, Inc.
6 // Author: Chunyan Zhang <chunyan.zhang@spreadtrum.com>
14 * struct sprd_mux_ssel - Mux clock's source select bits in its register
15 * @shift: Bit offset of the divider in its register
16 * @width: Width of the divider field in its register
17 * @table: For some mux clocks, not all sources are used on some special
18 * chips, this matches the value of mux clock's register and the
19 * sources which are used for this mux clock
21 struct sprd_mux_ssel
{
28 struct sprd_mux_ssel mux
;
29 struct sprd_clk_common common
;
32 #define _SPRD_MUX_CLK(_shift, _width, _table) \
39 #define SPRD_MUX_CLK_TABLE(_struct, _name, _parents, _table, \
40 _reg, _shift, _width, \
42 struct sprd_mux _struct = { \
43 .mux = _SPRD_MUX_CLK(_shift, _width, _table), \
47 .hw.init = CLK_HW_INIT_PARENTS(_name, \
54 #define SPRD_MUX_CLK(_struct, _name, _parents, _reg, \
55 _shift, _width, _flags) \
56 SPRD_MUX_CLK_TABLE(_struct, _name, _parents, NULL, \
57 _reg, _shift, _width, _flags)
59 static inline struct sprd_mux
*hw_to_sprd_mux(const struct clk_hw
*hw
)
61 struct sprd_clk_common
*common
= hw_to_sprd_clk_common(hw
);
63 return container_of(common
, struct sprd_mux
, common
);
66 extern const struct clk_ops sprd_mux_ops
;
68 u8
sprd_mux_helper_get_parent(const struct sprd_clk_common
*common
,
69 const struct sprd_mux_ssel
*mux
);
70 int sprd_mux_helper_set_parent(const struct sprd_clk_common
*common
,
71 const struct sprd_mux_ssel
*mux
,
74 #endif /* _SPRD_MUX_H_ */