diff options
Diffstat (limited to 'drivers/clk/shmobile/clk-rcar-gen2.c')
-rw-r--r-- | drivers/clk/shmobile/clk-rcar-gen2.c | 88 |
1 files changed, 88 insertions, 0 deletions
diff --git a/drivers/clk/shmobile/clk-rcar-gen2.c b/drivers/clk/shmobile/clk-rcar-gen2.c index e996425d06a9..acfb6d7dbd6b 100644 --- a/drivers/clk/shmobile/clk-rcar-gen2.c +++ b/drivers/clk/shmobile/clk-rcar-gen2.c | |||
@@ -33,6 +33,8 @@ struct rcar_gen2_cpg { | |||
33 | #define CPG_FRQCRC 0x000000e0 | 33 | #define CPG_FRQCRC 0x000000e0 |
34 | #define CPG_FRQCRC_ZFC_MASK (0x1f << 8) | 34 | #define CPG_FRQCRC_ZFC_MASK (0x1f << 8) |
35 | #define CPG_FRQCRC_ZFC_SHIFT 8 | 35 | #define CPG_FRQCRC_ZFC_SHIFT 8 |
36 | #define CPG_ADSPCKCR 0x0000025c | ||
37 | #define CPG_RCANCKCR 0x00000270 | ||
36 | 38 | ||
37 | /* ----------------------------------------------------------------------------- | 39 | /* ----------------------------------------------------------------------------- |
38 | * Z Clock | 40 | * Z Clock |
@@ -161,6 +163,88 @@ static struct clk * __init cpg_z_clk_register(struct rcar_gen2_cpg *cpg) | |||
161 | return clk; | 163 | return clk; |
162 | } | 164 | } |
163 | 165 | ||
166 | static struct clk * __init cpg_rcan_clk_register(struct rcar_gen2_cpg *cpg, | ||
167 | struct device_node *np) | ||
168 | { | ||
169 | const char *parent_name = of_clk_get_parent_name(np, 1); | ||
170 | struct clk_fixed_factor *fixed; | ||
171 | struct clk_gate *gate; | ||
172 | struct clk *clk; | ||
173 | |||
174 | fixed = kzalloc(sizeof(*fixed), GFP_KERNEL); | ||
175 | if (!fixed) | ||
176 | return ERR_PTR(-ENOMEM); | ||
177 | |||
178 | fixed->mult = 1; | ||
179 | fixed->div = 6; | ||
180 | |||
181 | gate = kzalloc(sizeof(*gate), GFP_KERNEL); | ||
182 | if (!gate) { | ||
183 | kfree(fixed); | ||
184 | return ERR_PTR(-ENOMEM); | ||
185 | } | ||
186 | |||
187 | gate->reg = cpg->reg + CPG_RCANCKCR; | ||
188 | gate->bit_idx = 8; | ||
189 | gate->flags = CLK_GATE_SET_TO_DISABLE; | ||
190 | gate->lock = &cpg->lock; | ||
191 | |||
192 | clk = clk_register_composite(NULL, "rcan", &parent_name, 1, NULL, NULL, | ||
193 | &fixed->hw, &clk_fixed_factor_ops, | ||
194 | &gate->hw, &clk_gate_ops, 0); | ||
195 | if (IS_ERR(clk)) { | ||
196 | kfree(gate); | ||
197 | kfree(fixed); | ||
198 | } | ||
199 | |||
200 | return clk; | ||
201 | } | ||
202 | |||
203 | /* ADSP divisors */ | ||
204 | static const struct clk_div_table cpg_adsp_div_table[] = { | ||
205 | { 1, 3 }, { 2, 4 }, { 3, 6 }, { 4, 8 }, | ||
206 | { 5, 12 }, { 6, 16 }, { 7, 18 }, { 8, 24 }, | ||
207 | { 10, 36 }, { 11, 48 }, { 0, 0 }, | ||
208 | }; | ||
209 | |||
210 | static struct clk * __init cpg_adsp_clk_register(struct rcar_gen2_cpg *cpg) | ||
211 | { | ||
212 | const char *parent_name = "pll1"; | ||
213 | struct clk_divider *div; | ||
214 | struct clk_gate *gate; | ||
215 | struct clk *clk; | ||
216 | |||
217 | div = kzalloc(sizeof(*div), GFP_KERNEL); | ||
218 | if (!div) | ||
219 | return ERR_PTR(-ENOMEM); | ||
220 | |||
221 | div->reg = cpg->reg + CPG_ADSPCKCR; | ||
222 | div->width = 4; | ||
223 | div->table = cpg_adsp_div_table; | ||
224 | div->lock = &cpg->lock; | ||
225 | |||
226 | gate = kzalloc(sizeof(*gate), GFP_KERNEL); | ||
227 | if (!gate) { | ||
228 | kfree(div); | ||
229 | return ERR_PTR(-ENOMEM); | ||
230 | } | ||
231 | |||
232 | gate->reg = cpg->reg + CPG_ADSPCKCR; | ||
233 | gate->bit_idx = 8; | ||
234 | gate->flags = CLK_GATE_SET_TO_DISABLE; | ||
235 | gate->lock = &cpg->lock; | ||
236 | |||
237 | clk = clk_register_composite(NULL, "adsp", &parent_name, 1, NULL, NULL, | ||
238 | &div->hw, &clk_divider_ops, | ||
239 | &gate->hw, &clk_gate_ops, 0); | ||
240 | if (IS_ERR(clk)) { | ||
241 | kfree(gate); | ||
242 | kfree(div); | ||
243 | } | ||
244 | |||
245 | return clk; | ||
246 | } | ||
247 | |||
164 | /* ----------------------------------------------------------------------------- | 248 | /* ----------------------------------------------------------------------------- |
165 | * CPG Clock Data | 249 | * CPG Clock Data |
166 | */ | 250 | */ |
@@ -263,6 +347,10 @@ rcar_gen2_cpg_register_clock(struct device_node *np, struct rcar_gen2_cpg *cpg, | |||
263 | shift = 0; | 347 | shift = 0; |
264 | } else if (!strcmp(name, "z")) { | 348 | } else if (!strcmp(name, "z")) { |
265 | return cpg_z_clk_register(cpg); | 349 | return cpg_z_clk_register(cpg); |
350 | } else if (!strcmp(name, "rcan")) { | ||
351 | return cpg_rcan_clk_register(cpg, np); | ||
352 | } else if (!strcmp(name, "adsp")) { | ||
353 | return cpg_adsp_clk_register(cpg); | ||
266 | } else { | 354 | } else { |
267 | return ERR_PTR(-EINVAL); | 355 | return ERR_PTR(-EINVAL); |
268 | } | 356 | } |