Skip to content

Commit a1aae0a

Browse files
rfs613geertu
authored andcommitted
clk: renesas: r9a06g032: Improve readability
Several small readability improvements: - Move enum gate_type definition up and add comments to each field. - Use this enum instead of generic uint32_t type in clock desc struct. - Tidy up bitfield syntax and comments in clock desc structure - Reformat macros for building clock desc to have one assignment per line There is no functional change. Signed-off-by: Ralph Siemsen <[email protected]> Reviewed-by: Geert Uytterhoeven <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Geert Uytterhoeven <[email protected]>
1 parent 85af88b commit a1aae0a

File tree

1 file changed

+80
-41
lines changed

1 file changed

+80
-41
lines changed

drivers/clk/renesas/r9a06g032-clocks.c

Lines changed: 80 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -34,64 +34,103 @@ struct r9a06g032_gate {
3434
scon, mirack, mistat;
3535
};
3636

37+
enum gate_type {
38+
K_GATE = 0, /* gate which enable/disable */
39+
K_FFC, /* fixed factor clock */
40+
K_DIV, /* divisor */
41+
K_BITSEL, /* special for UARTs */
42+
K_DUALGATE /* special for UARTs */
43+
};
44+
3745
/* This is used to describe a clock for instantiation */
3846
struct r9a06g032_clkdesc {
3947
const char *name;
40-
uint32_t managed: 1;
41-
uint32_t type: 3;
42-
uint32_t index: 8;
43-
uint32_t source : 8; /* source index + 1 (0 == none) */
44-
/* these are used to populate the bitsel struct */
48+
uint32_t managed:1;
49+
enum gate_type type:3;
50+
uint32_t index:8;
51+
uint32_t source:8; /* source index + 1 (0 == none) */
4552
union {
53+
/* type = K_GATE */
4654
struct r9a06g032_gate gate;
47-
/* for dividers */
55+
/* type = K_DIV */
4856
struct {
49-
unsigned int div_min : 10, div_max : 10, reg: 10;
57+
unsigned int div_min:10, div_max:10, reg:10;
5058
u16 div_table[4];
5159
};
52-
/* For fixed-factor ones */
60+
/* type = K_FFC */
5361
struct {
5462
u16 div, mul;
5563
};
56-
/* for dual gate */
64+
/* type = K_DUALGATE */
5765
struct {
58-
uint16_t group : 1;
66+
uint16_t group:1;
5967
u16 sel, g1, r1, g2, r2;
6068
} dual;
6169
};
6270
};
6371

64-
#define I_GATE(_clk, _rst, _rdy, _midle, _scon, _mirack, _mistat) \
65-
{ .gate = _clk, .reset = _rst, \
66-
.ready = _rdy, .midle = _midle, \
67-
.scon = _scon, .mirack = _mirack, .mistat = _mistat }
68-
#define D_GATE(_idx, _n, _src, ...) \
69-
{ .type = K_GATE, .index = R9A06G032_##_idx, \
70-
.source = 1 + R9A06G032_##_src, .name = _n, \
71-
.gate = I_GATE(__VA_ARGS__) }
72-
#define D_MODULE(_idx, _n, _src, ...) \
73-
{ .type = K_GATE, .index = R9A06G032_##_idx, \
74-
.source = 1 + R9A06G032_##_src, .name = _n, \
75-
.managed = 1, .gate = I_GATE(__VA_ARGS__) }
76-
#define D_ROOT(_idx, _n, _mul, _div) \
77-
{ .type = K_FFC, .index = R9A06G032_##_idx, .name = _n, \
78-
.div = _div, .mul = _mul }
79-
#define D_FFC(_idx, _n, _src, _div) \
80-
{ .type = K_FFC, .index = R9A06G032_##_idx, \
81-
.source = 1 + R9A06G032_##_src, .name = _n, \
82-
.div = _div, .mul = 1}
83-
#define D_DIV(_idx, _n, _src, _reg, _min, _max, ...) \
84-
{ .type = K_DIV, .index = R9A06G032_##_idx, \
85-
.source = 1 + R9A06G032_##_src, .name = _n, \
86-
.reg = _reg, .div_min = _min, .div_max = _max, \
87-
.div_table = { __VA_ARGS__ } }
88-
#define D_UGATE(_idx, _n, _src, _g, _g1, _r1, _g2, _r2) \
89-
{ .type = K_DUALGATE, .index = R9A06G032_##_idx, \
90-
.source = 1 + R9A06G032_##_src, .name = _n, \
91-
.dual = { .group = _g, \
92-
.g1 = _g1, .r1 = _r1, .g2 = _g2, .r2 = _r2 }, }
93-
94-
enum { K_GATE = 0, K_FFC, K_DIV, K_BITSEL, K_DUALGATE };
72+
#define I_GATE(_clk, _rst, _rdy, _midle, _scon, _mirack, _mistat) { \
73+
.gate = _clk, \
74+
.reset = _rst, \
75+
.ready = _rdy, \
76+
.midle = _midle, \
77+
.scon = _scon, \
78+
.mirack = _mirack, \
79+
.mistat = _mistat \
80+
}
81+
#define D_GATE(_idx, _n, _src, ...) { \
82+
.type = K_GATE, \
83+
.index = R9A06G032_##_idx, \
84+
.source = 1 + R9A06G032_##_src, \
85+
.name = _n, \
86+
.gate = I_GATE(__VA_ARGS__) \
87+
}
88+
#define D_MODULE(_idx, _n, _src, ...) { \
89+
.type = K_GATE, \
90+
.index = R9A06G032_##_idx, \
91+
.source = 1 + R9A06G032_##_src, \
92+
.name = _n, \
93+
.managed = 1, \
94+
.gate = I_GATE(__VA_ARGS__) \
95+
}
96+
#define D_ROOT(_idx, _n, _mul, _div) { \
97+
.type = K_FFC, \
98+
.index = R9A06G032_##_idx, \
99+
.name = _n, \
100+
.div = _div, \
101+
.mul = _mul \
102+
}
103+
#define D_FFC(_idx, _n, _src, _div) { \
104+
.type = K_FFC, \
105+
.index = R9A06G032_##_idx, \
106+
.source = 1 + R9A06G032_##_src, \
107+
.name = _n, \
108+
.div = _div, \
109+
.mul = 1 \
110+
}
111+
#define D_DIV(_idx, _n, _src, _reg, _min, _max, ...) { \
112+
.type = K_DIV, \
113+
.index = R9A06G032_##_idx, \
114+
.source = 1 + R9A06G032_##_src, \
115+
.name = _n, \
116+
.reg = _reg, \
117+
.div_min = _min, \
118+
.div_max = _max, \
119+
.div_table = { __VA_ARGS__ } \
120+
}
121+
#define D_UGATE(_idx, _n, _src, _g, _g1, _r1, _g2, _r2) { \
122+
.type = K_DUALGATE, \
123+
.index = R9A06G032_##_idx, \
124+
.source = 1 + R9A06G032_##_src, \
125+
.name = _n, \
126+
.dual = { \
127+
.group = _g, \
128+
.g1 = _g1, \
129+
.r1 = _r1, \
130+
.g2 = _g2, \
131+
.r2 = _r2 \
132+
}, \
133+
}
95134

96135
/* Internal clock IDs */
97136
#define R9A06G032_CLKOUT 0

0 commit comments

Comments
 (0)