@@ -34,64 +34,103 @@ struct r9a06g032_gate {
34
34
scon , mirack , mistat ;
35
35
};
36
36
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
+
37
45
/* This is used to describe a clock for instantiation */
38
46
struct r9a06g032_clkdesc {
39
47
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) */
45
52
union {
53
+ /* type = K_GATE */
46
54
struct r9a06g032_gate gate ;
47
- /* for dividers */
55
+ /* type = K_DIV */
48
56
struct {
49
- unsigned int div_min : 10 , div_max : 10 , reg : 10 ;
57
+ unsigned int div_min : 10 , div_max : 10 , reg :10 ;
50
58
u16 div_table [4 ];
51
59
};
52
- /* For fixed-factor ones */
60
+ /* type = K_FFC */
53
61
struct {
54
62
u16 div , mul ;
55
63
};
56
- /* for dual gate */
64
+ /* type = K_DUALGATE */
57
65
struct {
58
- uint16_t group : 1 ;
66
+ uint16_t group : 1 ;
59
67
u16 sel , g1 , r1 , g2 , r2 ;
60
68
} dual ;
61
69
};
62
70
};
63
71
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
+ }
95
134
96
135
/* Internal clock IDs */
97
136
#define R9A06G032_CLKOUT 0
0 commit comments