aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/clk/mvebu
diff options
context:
space:
mode:
authorStephen Boyd <sboyd@codeaurora.org>2017-06-19 20:05:01 -0400
committerStephen Boyd <sboyd@codeaurora.org>2017-06-19 20:06:46 -0400
commit4d4f9a6a192d4e580d27208e7c49dfda12cabb59 (patch)
treec4800ee68ae2298e7fad95b82ab6576e7f79bbbc /drivers/clk/mvebu
parentb7f8101d6e75fefd22c39624a30c9ed3d7a72463 (diff)
parenta45af6d3a98b4d8a2746de13a8db52fb4123bb56 (diff)
Merge branch 'clk-cp110' of git://git.infradead.org/linux-mvebu into clk-next
Pull improved Marvel Armada 7K/8K cp110 clk support from Gregory CLEMENT: We got more information about the clock controllers and the clock tree of the CP110 part that we find in the Marvell Armada 7K/8K SoCs. The clk driver is modified accordingly from this new information. * 'clk-cp110' of git://git.infradead.org/linux-mvebu: clk: mvebu: cp110: add sdio clock to cp-110 system controller clk: mvebu: cp110: introduce a new binding clk: mvebu: cp110: do not depend anymore of the *-clock-output-names clk: mvebu: cp110: make failure labels more meaningful
Diffstat (limited to 'drivers/clk/mvebu')
-rw-r--r--drivers/clk/mvebu/cp110-system-controller.c200
1 files changed, 138 insertions, 62 deletions
diff --git a/drivers/clk/mvebu/cp110-system-controller.c b/drivers/clk/mvebu/cp110-system-controller.c
index 6b11d7b3e0e0..b034b79345ec 100644
--- a/drivers/clk/mvebu/cp110-system-controller.c
+++ b/drivers/clk/mvebu/cp110-system-controller.c
@@ -11,15 +11,16 @@
11 */ 11 */
12 12
13/* 13/*
14 * CP110 has 5 core clocks: 14 * CP110 has 6 core clocks:
15 * 15 *
16 * - APLL (1 Ghz) 16 * - APLL (1 Ghz)
17 * - PPv2 core (1/3 APLL) 17 * - PPv2 core (1/3 APLL)
18 * - EIP (1/2 APLL) 18 * - EIP (1/2 APLL)
19 * - Core (1/2 EIP) 19 * - Core (1/2 EIP)
20 * - SDIO (2/5 APLL)
20 * 21 *
21 * - NAND clock, which is either: 22 * - NAND clock, which is either:
22 * - Equal to the core clock 23 * - Equal to SDIO clock
23 * - 2/5 APLL 24 * - 2/5 APLL
24 * 25 *
25 * CP110 has 32 gatable clocks, for the various peripherals in the 26 * CP110 has 32 gatable clocks, for the various peripherals in the
@@ -46,7 +47,7 @@ enum {
46 CP110_CLK_TYPE_GATABLE, 47 CP110_CLK_TYPE_GATABLE,
47}; 48};
48 49
49#define CP110_MAX_CORE_CLOCKS 5 50#define CP110_MAX_CORE_CLOCKS 6
50#define CP110_MAX_GATABLE_CLOCKS 32 51#define CP110_MAX_GATABLE_CLOCKS 32
51 52
52#define CP110_CLK_NUM \ 53#define CP110_CLK_NUM \
@@ -57,6 +58,7 @@ enum {
57#define CP110_CORE_EIP 2 58#define CP110_CORE_EIP 2
58#define CP110_CORE_CORE 3 59#define CP110_CORE_CORE 3
59#define CP110_CORE_NAND 4 60#define CP110_CORE_NAND 4
61#define CP110_CORE_SDIO 5
60 62
61/* A number of gatable clocks need special handling */ 63/* A number of gatable clocks need special handling */
62#define CP110_GATE_AUDIO 0 64#define CP110_GATE_AUDIO 0
@@ -84,6 +86,33 @@ enum {
84#define CP110_GATE_EIP150 25 86#define CP110_GATE_EIP150 25
85#define CP110_GATE_EIP197 26 87#define CP110_GATE_EIP197 26
86 88
89const char *gate_base_names[] = {
90 [CP110_GATE_AUDIO] = "audio",
91 [CP110_GATE_COMM_UNIT] = "communit",
92 [CP110_GATE_NAND] = "nand",
93 [CP110_GATE_PPV2] = "ppv2",
94 [CP110_GATE_SDIO] = "sdio",
95 [CP110_GATE_MG] = "mg-domain",
96 [CP110_GATE_MG_CORE] = "mg-core",
97 [CP110_GATE_XOR1] = "xor1",
98 [CP110_GATE_XOR0] = "xor0",
99 [CP110_GATE_GOP_DP] = "gop-dp",
100 [CP110_GATE_PCIE_X1_0] = "pcie_x10",
101 [CP110_GATE_PCIE_X1_1] = "pcie_x11",
102 [CP110_GATE_PCIE_X4] = "pcie_x4",
103 [CP110_GATE_PCIE_XOR] = "pcie-xor",
104 [CP110_GATE_SATA] = "sata",
105 [CP110_GATE_SATA_USB] = "sata-usb",
106 [CP110_GATE_MAIN] = "main",
107 [CP110_GATE_SDMMC_GOP] = "sd-mmc-gop",
108 [CP110_GATE_SLOW_IO] = "slow-io",
109 [CP110_GATE_USB3H0] = "usb3h0",
110 [CP110_GATE_USB3H1] = "usb3h1",
111 [CP110_GATE_USB3DEV] = "usb3dev",
112 [CP110_GATE_EIP150] = "eip150",
113 [CP110_GATE_EIP197] = "eip197"
114};
115
87struct cp110_gate_clk { 116struct cp110_gate_clk {
88 struct clk_hw hw; 117 struct clk_hw hw;
89 struct regmap *regmap; 118 struct regmap *regmap;
@@ -186,17 +215,37 @@ static struct clk_hw *cp110_of_clk_get(struct of_phandle_args *clkspec,
186 return ERR_PTR(-EINVAL); 215 return ERR_PTR(-EINVAL);
187} 216}
188 217
189static int cp110_syscon_clk_probe(struct platform_device *pdev) 218static char *cp110_unique_name(struct device *dev, struct device_node *np,
219 const char *name)
220{
221 const __be32 *reg;
222 u64 addr;
223
224 /* Do not create a name if there is no clock */
225 if (!name)
226 return NULL;
227
228 reg = of_get_property(np, "reg", NULL);
229 addr = of_translate_address(np, reg);
230 return devm_kasprintf(dev, GFP_KERNEL, "%llx-%s",
231 (unsigned long long)addr, name);
232}
233
234static int cp110_syscon_common_probe(struct platform_device *pdev,
235 struct device_node *syscon_node)
190{ 236{
191 struct regmap *regmap; 237 struct regmap *regmap;
192 struct device_node *np = pdev->dev.of_node; 238 struct device *dev = &pdev->dev;
193 const char *ppv2_name, *apll_name, *core_name, *eip_name, *nand_name; 239 struct device_node *np = dev->of_node;
240 const char *ppv2_name, *apll_name, *core_name, *eip_name, *nand_name,
241 *sdio_name;
194 struct clk_hw_onecell_data *cp110_clk_data; 242 struct clk_hw_onecell_data *cp110_clk_data;
195 struct clk_hw *hw, **cp110_clks; 243 struct clk_hw *hw, **cp110_clks;
196 u32 nand_clk_ctrl; 244 u32 nand_clk_ctrl;
197 int i, ret; 245 int i, ret;
246 char *gate_name[ARRAY_SIZE(gate_base_names)];
198 247
199 regmap = syscon_node_to_regmap(np); 248 regmap = syscon_node_to_regmap(syscon_node);
200 if (IS_ERR(regmap)) 249 if (IS_ERR(regmap))
201 return PTR_ERR(regmap); 250 return PTR_ERR(regmap);
202 251
@@ -205,7 +254,7 @@ static int cp110_syscon_clk_probe(struct platform_device *pdev)
205 if (ret) 254 if (ret)
206 return ret; 255 return ret;
207 256
208 cp110_clk_data = devm_kzalloc(&pdev->dev, sizeof(*cp110_clk_data) + 257 cp110_clk_data = devm_kzalloc(dev, sizeof(*cp110_clk_data) +
209 sizeof(struct clk_hw *) * CP110_CLK_NUM, 258 sizeof(struct clk_hw *) * CP110_CLK_NUM,
210 GFP_KERNEL); 259 GFP_KERNEL);
211 if (!cp110_clk_data) 260 if (!cp110_clk_data)
@@ -215,53 +264,47 @@ static int cp110_syscon_clk_probe(struct platform_device *pdev)
215 cp110_clk_data->num = CP110_CLK_NUM; 264 cp110_clk_data->num = CP110_CLK_NUM;
216 265
217 /* Register the APLL which is the root of the hw tree */ 266 /* Register the APLL which is the root of the hw tree */
218 of_property_read_string_index(np, "core-clock-output-names", 267 apll_name = cp110_unique_name(dev, syscon_node, "apll");
219 CP110_CORE_APLL, &apll_name);
220 hw = clk_hw_register_fixed_rate(NULL, apll_name, NULL, 0, 268 hw = clk_hw_register_fixed_rate(NULL, apll_name, NULL, 0,
221 1000 * 1000 * 1000); 269 1000 * 1000 * 1000);
222 if (IS_ERR(hw)) { 270 if (IS_ERR(hw)) {
223 ret = PTR_ERR(hw); 271 ret = PTR_ERR(hw);
224 goto fail0; 272 goto fail_apll;
225 } 273 }
226 274
227 cp110_clks[CP110_CORE_APLL] = hw; 275 cp110_clks[CP110_CORE_APLL] = hw;
228 276
229 /* PPv2 is APLL/3 */ 277 /* PPv2 is APLL/3 */
230 of_property_read_string_index(np, "core-clock-output-names", 278 ppv2_name = cp110_unique_name(dev, syscon_node, "ppv2-core");
231 CP110_CORE_PPV2, &ppv2_name);
232 hw = clk_hw_register_fixed_factor(NULL, ppv2_name, apll_name, 0, 1, 3); 279 hw = clk_hw_register_fixed_factor(NULL, ppv2_name, apll_name, 0, 1, 3);
233 if (IS_ERR(hw)) { 280 if (IS_ERR(hw)) {
234 ret = PTR_ERR(hw); 281 ret = PTR_ERR(hw);
235 goto fail1; 282 goto fail_ppv2;
236 } 283 }
237 284
238 cp110_clks[CP110_CORE_PPV2] = hw; 285 cp110_clks[CP110_CORE_PPV2] = hw;
239 286
240 /* EIP clock is APLL/2 */ 287 /* EIP clock is APLL/2 */
241 of_property_read_string_index(np, "core-clock-output-names", 288 eip_name = cp110_unique_name(dev, syscon_node, "eip");
242 CP110_CORE_EIP, &eip_name);
243 hw = clk_hw_register_fixed_factor(NULL, eip_name, apll_name, 0, 1, 2); 289 hw = clk_hw_register_fixed_factor(NULL, eip_name, apll_name, 0, 1, 2);
244 if (IS_ERR(hw)) { 290 if (IS_ERR(hw)) {
245 ret = PTR_ERR(hw); 291 ret = PTR_ERR(hw);
246 goto fail2; 292 goto fail_eip;
247 } 293 }
248 294
249 cp110_clks[CP110_CORE_EIP] = hw; 295 cp110_clks[CP110_CORE_EIP] = hw;
250 296
251 /* Core clock is EIP/2 */ 297 /* Core clock is EIP/2 */
252 of_property_read_string_index(np, "core-clock-output-names", 298 core_name = cp110_unique_name(dev, syscon_node, "core");
253 CP110_CORE_CORE, &core_name);
254 hw = clk_hw_register_fixed_factor(NULL, core_name, eip_name, 0, 1, 2); 299 hw = clk_hw_register_fixed_factor(NULL, core_name, eip_name, 0, 1, 2);
255 if (IS_ERR(hw)) { 300 if (IS_ERR(hw)) {
256 ret = PTR_ERR(hw); 301 ret = PTR_ERR(hw);
257 goto fail3; 302 goto fail_core;
258 } 303 }
259 304
260 cp110_clks[CP110_CORE_CORE] = hw; 305 cp110_clks[CP110_CORE_CORE] = hw;
261
262 /* NAND can be either APLL/2.5 or core clock */ 306 /* NAND can be either APLL/2.5 or core clock */
263 of_property_read_string_index(np, "core-clock-output-names", 307 nand_name = cp110_unique_name(dev, syscon_node, "nand-core");
264 CP110_CORE_NAND, &nand_name);
265 if (nand_clk_ctrl & NF_CLOCK_SEL_400_MASK) 308 if (nand_clk_ctrl & NF_CLOCK_SEL_400_MASK)
266 hw = clk_hw_register_fixed_factor(NULL, nand_name, 309 hw = clk_hw_register_fixed_factor(NULL, nand_name,
267 apll_name, 0, 2, 5); 310 apll_name, 0, 2, 5);
@@ -270,23 +313,31 @@ static int cp110_syscon_clk_probe(struct platform_device *pdev)
270 core_name, 0, 1, 1); 313 core_name, 0, 1, 1);
271 if (IS_ERR(hw)) { 314 if (IS_ERR(hw)) {
272 ret = PTR_ERR(hw); 315 ret = PTR_ERR(hw);
273 goto fail4; 316 goto fail_nand;
274 } 317 }
275 318
276 cp110_clks[CP110_CORE_NAND] = hw; 319 cp110_clks[CP110_CORE_NAND] = hw;
277 320
278 for (i = 0; i < CP110_MAX_GATABLE_CLOCKS; i++) { 321 /* SDIO clock is APLL/2.5 */
279 const char *parent, *name; 322 sdio_name = cp110_unique_name(dev, syscon_node, "sdio-core");
280 int ret; 323 hw = clk_hw_register_fixed_factor(NULL, sdio_name,
281 324 apll_name, 0, 2, 5);
282 ret = of_property_read_string_index(np, 325 if (IS_ERR(hw)) {
283 "gate-clock-output-names", 326 ret = PTR_ERR(hw);
284 i, &name); 327 goto fail_sdio;
285 /* Reached the end of the list? */ 328 }
286 if (ret < 0)
287 break;
288 329
289 if (!strcmp(name, "none")) 330 cp110_clks[CP110_CORE_SDIO] = hw;
331
332 /* create the unique name for all the gate clocks */
333 for (i = 0; i < ARRAY_SIZE(gate_base_names); i++)
334 gate_name[i] = cp110_unique_name(dev, syscon_node,
335 gate_base_names[i]);
336
337 for (i = 0; i < ARRAY_SIZE(gate_base_names); i++) {
338 const char *parent;
339
340 if (gate_name[i] == NULL)
290 continue; 341 continue;
291 342
292 switch (i) { 343 switch (i) {
@@ -295,14 +346,10 @@ static int cp110_syscon_clk_probe(struct platform_device *pdev)
295 case CP110_GATE_EIP150: 346 case CP110_GATE_EIP150:
296 case CP110_GATE_EIP197: 347 case CP110_GATE_EIP197:
297 case CP110_GATE_SLOW_IO: 348 case CP110_GATE_SLOW_IO:
298 of_property_read_string_index(np, 349 parent = gate_name[CP110_GATE_MAIN];
299 "gate-clock-output-names",
300 CP110_GATE_MAIN, &parent);
301 break; 350 break;
302 case CP110_GATE_MG: 351 case CP110_GATE_MG:
303 of_property_read_string_index(np, 352 parent = gate_name[CP110_GATE_MG_CORE];
304 "gate-clock-output-names",
305 CP110_GATE_MG_CORE, &parent);
306 break; 353 break;
307 case CP110_GATE_NAND: 354 case CP110_GATE_NAND:
308 parent = nand_name; 355 parent = nand_name;
@@ -311,34 +358,30 @@ static int cp110_syscon_clk_probe(struct platform_device *pdev)
311 parent = ppv2_name; 358 parent = ppv2_name;
312 break; 359 break;
313 case CP110_GATE_SDIO: 360 case CP110_GATE_SDIO:
361 parent = sdio_name;
362 break;
314 case CP110_GATE_GOP_DP: 363 case CP110_GATE_GOP_DP:
315 of_property_read_string_index(np, 364 parent = gate_name[CP110_GATE_SDMMC_GOP];
316 "gate-clock-output-names",
317 CP110_GATE_SDMMC_GOP, &parent);
318 break; 365 break;
319 case CP110_GATE_XOR1: 366 case CP110_GATE_XOR1:
320 case CP110_GATE_XOR0: 367 case CP110_GATE_XOR0:
321 case CP110_GATE_PCIE_X1_0: 368 case CP110_GATE_PCIE_X1_0:
322 case CP110_GATE_PCIE_X1_1: 369 case CP110_GATE_PCIE_X1_1:
323 case CP110_GATE_PCIE_X4: 370 case CP110_GATE_PCIE_X4:
324 of_property_read_string_index(np, 371 parent = gate_name[CP110_GATE_PCIE_XOR];
325 "gate-clock-output-names",
326 CP110_GATE_PCIE_XOR, &parent);
327 break; 372 break;
328 case CP110_GATE_SATA: 373 case CP110_GATE_SATA:
329 case CP110_GATE_USB3H0: 374 case CP110_GATE_USB3H0:
330 case CP110_GATE_USB3H1: 375 case CP110_GATE_USB3H1:
331 case CP110_GATE_USB3DEV: 376 case CP110_GATE_USB3DEV:
332 of_property_read_string_index(np, 377 parent = gate_name[CP110_GATE_SATA_USB];
333 "gate-clock-output-names",
334 CP110_GATE_SATA_USB, &parent);
335 break; 378 break;
336 default: 379 default:
337 parent = core_name; 380 parent = core_name;
338 break; 381 break;
339 } 382 }
383 hw = cp110_register_gate(gate_name[i], parent, regmap, i);
340 384
341 hw = cp110_register_gate(name, parent, regmap, i);
342 if (IS_ERR(hw)) { 385 if (IS_ERR(hw)) {
343 ret = PTR_ERR(hw); 386 ret = PTR_ERR(hw);
344 goto fail_gate; 387 goto fail_gate;
@@ -364,30 +407,63 @@ fail_gate:
364 cp110_unregister_gate(hw); 407 cp110_unregister_gate(hw);
365 } 408 }
366 409
410 clk_hw_unregister_fixed_factor(cp110_clks[CP110_CORE_SDIO]);
411fail_sdio:
367 clk_hw_unregister_fixed_factor(cp110_clks[CP110_CORE_NAND]); 412 clk_hw_unregister_fixed_factor(cp110_clks[CP110_CORE_NAND]);
368fail4: 413fail_nand:
369 clk_hw_unregister_fixed_factor(cp110_clks[CP110_CORE_CORE]); 414 clk_hw_unregister_fixed_factor(cp110_clks[CP110_CORE_CORE]);
370fail3: 415fail_core:
371 clk_hw_unregister_fixed_factor(cp110_clks[CP110_CORE_EIP]); 416 clk_hw_unregister_fixed_factor(cp110_clks[CP110_CORE_EIP]);
372fail2: 417fail_eip:
373 clk_hw_unregister_fixed_factor(cp110_clks[CP110_CORE_PPV2]); 418 clk_hw_unregister_fixed_factor(cp110_clks[CP110_CORE_PPV2]);
374fail1: 419fail_ppv2:
375 clk_hw_unregister_fixed_rate(cp110_clks[CP110_CORE_APLL]); 420 clk_hw_unregister_fixed_rate(cp110_clks[CP110_CORE_APLL]);
376fail0: 421fail_apll:
377 return ret; 422 return ret;
378} 423}
379 424
380static const struct of_device_id cp110_syscon_of_match[] = { 425static int cp110_syscon_legacy_clk_probe(struct platform_device *pdev)
426{
427 dev_warn(&pdev->dev, FW_WARN "Using legacy device tree binding\n");
428 dev_warn(&pdev->dev, FW_WARN "Update your device tree:\n");
429 dev_warn(&pdev->dev, FW_WARN
430 "This binding won't be supported in future kernels\n");
431
432 return cp110_syscon_common_probe(pdev, pdev->dev.of_node);
433}
434
435static int cp110_clk_probe(struct platform_device *pdev)
436{
437 return cp110_syscon_common_probe(pdev, pdev->dev.of_node->parent);
438}
439
440
441static const struct of_device_id cp110_syscon_legacy_of_match[] = {
381 { .compatible = "marvell,cp110-system-controller0", }, 442 { .compatible = "marvell,cp110-system-controller0", },
382 { } 443 { }
383}; 444};
384 445
385static struct platform_driver cp110_syscon_driver = { 446static struct platform_driver cp110_syscon_legacy_driver = {
386 .probe = cp110_syscon_clk_probe, 447 .probe = *cp110_syscon_legacy_clk_probe,
387 .driver = { 448 .driver = {
388 .name = "marvell-cp110-system-controller0", 449 .name = "marvell-cp110-system-controller0",
389 .of_match_table = cp110_syscon_of_match, 450 .of_match_table = cp110_syscon_legacy_of_match,
451 .suppress_bind_attrs = true,
452 },
453};
454builtin_platform_driver(cp110_syscon_legacy_driver);
455
456static const struct of_device_id cp110_clock_of_match[] = {
457 { .compatible = "marvell,cp110-clock", },
458 { }
459};
460
461static struct platform_driver cp110_clock_driver = {
462 .probe = cp110_clk_probe,
463 .driver = {
464 .name = "marvell-cp110-clock",
465 .of_match_table = cp110_clock_of_match,
390 .suppress_bind_attrs = true, 466 .suppress_bind_attrs = true,
391 }, 467 },
392}; 468};
393builtin_platform_driver(cp110_syscon_driver); 469builtin_platform_driver(cp110_clock_driver);