1
2
3
4
5
6
7
8#ifndef _SPRD_MUX_H_
9#define _SPRD_MUX_H_
10
11#include "common.h"
12
13
14
15
16
17
18
19
20
21struct sprd_mux_ssel {
22 u8 shift;
23 u8 width;
24 const u8 *table;
25};
26
27struct sprd_mux {
28 struct sprd_mux_ssel mux;
29 struct sprd_clk_common common;
30};
31
32#define _SPRD_MUX_CLK(_shift, _width, _table) \
33 { \
34 .shift = _shift, \
35 .width = _width, \
36 .table = _table, \
37 }
38
39#define SPRD_MUX_CLK_TABLE(_struct, _name, _parents, _table, \
40 _reg, _shift, _width, \
41 _flags) \
42 struct sprd_mux _struct = { \
43 .mux = _SPRD_MUX_CLK(_shift, _width, _table), \
44 .common = { \
45 .regmap = NULL, \
46 .reg = _reg, \
47 .hw.init = CLK_HW_INIT_PARENTS(_name, \
48 _parents, \
49 &sprd_mux_ops, \
50 _flags), \
51 } \
52 }
53
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)
58
59static inline struct sprd_mux *hw_to_sprd_mux(const struct clk_hw *hw)
60{
61 struct sprd_clk_common *common = hw_to_sprd_clk_common(hw);
62
63 return container_of(common, struct sprd_mux, common);
64}
65
66extern const struct clk_ops sprd_mux_ops;
67
68u8 sprd_mux_helper_get_parent(const struct sprd_clk_common *common,
69 const struct sprd_mux_ssel *mux);
70int sprd_mux_helper_set_parent(const struct sprd_clk_common *common,
71 const struct sprd_mux_ssel *mux,
72 u8 index);
73
74#endif
75