1
2
3
4
5
6
7
8#ifndef __CLK_RENESAS_CPG_MSSR_H__
9#define __CLK_RENESAS_CPG_MSSR_H__
10
11
12
13
14
15
16
17
18
19
20struct cpg_core_clk {
21
22 const char *name;
23 unsigned int id;
24 unsigned int type;
25
26 unsigned int parent;
27 unsigned int div;
28 unsigned int mult;
29 unsigned int offset;
30};
31
32enum clk_types {
33
34 CLK_TYPE_IN,
35 CLK_TYPE_FF,
36 CLK_TYPE_DIV6P1,
37 CLK_TYPE_DIV6_RO,
38 CLK_TYPE_FR,
39
40
41 CLK_TYPE_CUSTOM,
42};
43
44#define DEF_TYPE(_name, _id, _type...) \
45 { .name = _name, .id = _id, .type = _type }
46#define DEF_BASE(_name, _id, _type, _parent...) \
47 DEF_TYPE(_name, _id, _type, .parent = _parent)
48
49#define DEF_INPUT(_name, _id) \
50 DEF_TYPE(_name, _id, CLK_TYPE_IN)
51#define DEF_FIXED(_name, _id, _parent, _div, _mult) \
52 DEF_BASE(_name, _id, CLK_TYPE_FF, _parent, .div = _div, .mult = _mult)
53#define DEF_DIV6P1(_name, _id, _parent, _offset) \
54 DEF_BASE(_name, _id, CLK_TYPE_DIV6P1, _parent, .offset = _offset)
55#define DEF_DIV6_RO(_name, _id, _parent, _offset, _div) \
56 DEF_BASE(_name, _id, CLK_TYPE_DIV6_RO, _parent, .offset = _offset, .div = _div, .mult = 1)
57#define DEF_RATE(_name, _id, _rate) \
58 DEF_TYPE(_name, _id, CLK_TYPE_FR, .mult = _rate)
59
60
61
62
63
64struct mssr_mod_clk {
65 const char *name;
66 unsigned int id;
67 unsigned int parent;
68};
69
70
71#define MOD_CLK_PACK(x) ((x) - ((x) / 100) * (100 - 32))
72
73#define MOD_CLK_ID(x) (MOD_CLK_BASE + MOD_CLK_PACK(x))
74
75#define DEF_MOD(_name, _mod, _parent...) \
76 { .name = _name, .id = MOD_CLK_ID(_mod), .parent = _parent }
77
78
79#define MOD_CLK_PACK_10(x) ((x / 10) * 32 + (x % 10))
80
81#define MOD_CLK_ID_10(x) (MOD_CLK_BASE + MOD_CLK_PACK_10(x))
82
83#define DEF_MOD_STB(_name, _mod, _parent...) \
84 { .name = _name, .id = MOD_CLK_ID_10(_mod), .parent = _parent }
85
86struct device_node;
87
88enum clk_reg_layout {
89 CLK_REG_LAYOUT_RCAR_GEN2_AND_GEN3 = 0,
90 CLK_REG_LAYOUT_RZ_A,
91 CLK_REG_LAYOUT_RCAR_V3U,
92};
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124struct cpg_mssr_info {
125
126 const struct cpg_core_clk *early_core_clks;
127 unsigned int num_early_core_clks;
128 const struct mssr_mod_clk *early_mod_clks;
129 unsigned int num_early_mod_clks;
130
131
132 const struct cpg_core_clk *core_clks;
133 unsigned int num_core_clks;
134 unsigned int last_dt_core_clk;
135 unsigned int num_total_core_clks;
136 enum clk_reg_layout reg_layout;
137
138
139 const struct mssr_mod_clk *mod_clks;
140 unsigned int num_mod_clks;
141 unsigned int num_hw_mod_clks;
142
143
144 const unsigned int *crit_mod_clks;
145 unsigned int num_crit_mod_clks;
146
147
148 const unsigned int *core_pm_clks;
149 unsigned int num_core_pm_clks;
150
151
152 int (*init)(struct device *dev);
153 struct clk *(*cpg_clk_register)(struct device *dev,
154 const struct cpg_core_clk *core,
155 const struct cpg_mssr_info *info,
156 struct clk **clks, void __iomem *base,
157 struct raw_notifier_head *notifiers);
158};
159
160extern const struct cpg_mssr_info r7s9210_cpg_mssr_info;
161extern const struct cpg_mssr_info r8a7742_cpg_mssr_info;
162extern const struct cpg_mssr_info r8a7743_cpg_mssr_info;
163extern const struct cpg_mssr_info r8a7745_cpg_mssr_info;
164extern const struct cpg_mssr_info r8a77470_cpg_mssr_info;
165extern const struct cpg_mssr_info r8a774a1_cpg_mssr_info;
166extern const struct cpg_mssr_info r8a774b1_cpg_mssr_info;
167extern const struct cpg_mssr_info r8a774c0_cpg_mssr_info;
168extern const struct cpg_mssr_info r8a774e1_cpg_mssr_info;
169extern const struct cpg_mssr_info r8a7790_cpg_mssr_info;
170extern const struct cpg_mssr_info r8a7791_cpg_mssr_info;
171extern const struct cpg_mssr_info r8a7792_cpg_mssr_info;
172extern const struct cpg_mssr_info r8a7794_cpg_mssr_info;
173extern const struct cpg_mssr_info r8a7795_cpg_mssr_info;
174extern const struct cpg_mssr_info r8a7796_cpg_mssr_info;
175extern const struct cpg_mssr_info r8a77965_cpg_mssr_info;
176extern const struct cpg_mssr_info r8a77970_cpg_mssr_info;
177extern const struct cpg_mssr_info r8a77980_cpg_mssr_info;
178extern const struct cpg_mssr_info r8a77990_cpg_mssr_info;
179extern const struct cpg_mssr_info r8a77995_cpg_mssr_info;
180extern const struct cpg_mssr_info r8a779a0_cpg_mssr_info;
181
182void __init cpg_mssr_early_init(struct device_node *np,
183 const struct cpg_mssr_info *info);
184
185
186
187
188
189struct mssr_mod_reparent {
190 unsigned int clk, parent;
191};
192
193
194extern void cpg_core_nullify_range(struct cpg_core_clk *core_clks,
195 unsigned int num_core_clks,
196 unsigned int first_clk,
197 unsigned int last_clk);
198extern void mssr_mod_nullify(struct mssr_mod_clk *mod_clks,
199 unsigned int num_mod_clks,
200 const unsigned int *clks, unsigned int n);
201extern void mssr_mod_reparent(struct mssr_mod_clk *mod_clks,
202 unsigned int num_mod_clks,
203 const struct mssr_mod_reparent *clks,
204 unsigned int n);
205#endif
206