Skip to content

Commit c7e92de

Browse files
gclementbebarino
authored andcommitted
clk: mvebu: cp110: Fix clock tree representation
Thanks to new documentation, we have a better view of the clock tree. There were few mistakes in the first version of this driver, the main one being the parental link between the clocks. Actually the tree is more flat that we though. Most of the IP blocks require two clocks: one for the IP itself and one for accessing the registers, and unlike what we wrote there is no link between these two clocks. The other mistakes were about the name of the clocks: the root clock is not the Audio PLL but the PLL0, and what we called the EIP clock is named the x2 Core clock and is used by other IP block than the EIP ones. Signed-off-by: Gregory CLEMENT <[email protected]> Signed-off-by: Stephen Boyd <[email protected]>
1 parent 7928b2c commit c7e92de

File tree

1 file changed

+39
-55
lines changed

1 file changed

+39
-55
lines changed

drivers/clk/mvebu/cp110-system-controller.c

Lines changed: 39 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,17 @@
1313
/*
1414
* CP110 has 6 core clocks:
1515
*
16-
* - APLL (1 Ghz)
17-
* - PPv2 core (1/3 APLL)
18-
* - EIP (1/2 APLL)
19-
* - Core (1/2 EIP)
20-
* - SDIO (2/5 APLL)
16+
* - PLL0 (1 Ghz)
17+
* - PPv2 core (1/3 PLL0)
18+
* - x2 Core (1/2 PLL0)
19+
* - Core (1/2 x2 Core)
20+
* - SDIO (2/5 PLL0)
2121
*
2222
* - NAND clock, which is either:
2323
* - Equal to SDIO clock
24-
* - 2/5 APLL
24+
* - 2/5 PLL0
2525
*
26-
* CP110 has 32 gatable clocks, for the various peripherals in the
27-
* IP. They have fairly complicated parent/child relationships.
26+
* CP110 has 32 gatable clocks, for the various peripherals in the IP.
2827
*/
2928

3029
#define pr_fmt(fmt) "cp110-system-controller: " fmt
@@ -53,9 +52,9 @@ enum {
5352
#define CP110_CLK_NUM \
5453
(CP110_MAX_CORE_CLOCKS + CP110_MAX_GATABLE_CLOCKS)
5554

56-
#define CP110_CORE_APLL 0
55+
#define CP110_CORE_PLL0 0
5756
#define CP110_CORE_PPV2 1
58-
#define CP110_CORE_EIP 2
57+
#define CP110_CORE_X2CORE 2
5958
#define CP110_CORE_CORE 3
6059
#define CP110_CORE_NAND 4
6160
#define CP110_CORE_SDIO 5
@@ -237,7 +236,7 @@ static int cp110_syscon_common_probe(struct platform_device *pdev,
237236
struct regmap *regmap;
238237
struct device *dev = &pdev->dev;
239238
struct device_node *np = dev->of_node;
240-
const char *ppv2_name, *apll_name, *core_name, *eip_name, *nand_name,
239+
const char *ppv2_name, *pll0_name, *core_name, *x2core_name, *nand_name,
241240
*sdio_name;
242241
struct clk_hw_onecell_data *cp110_clk_data;
243242
struct clk_hw *hw, **cp110_clks;
@@ -263,51 +262,53 @@ static int cp110_syscon_common_probe(struct platform_device *pdev,
263262
cp110_clks = cp110_clk_data->hws;
264263
cp110_clk_data->num = CP110_CLK_NUM;
265264

266-
/* Register the APLL which is the root of the hw tree */
267-
apll_name = cp110_unique_name(dev, syscon_node, "apll");
268-
hw = clk_hw_register_fixed_rate(NULL, apll_name, NULL, 0,
265+
/* Register the PLL0 which is the root of the hw tree */
266+
pll0_name = cp110_unique_name(dev, syscon_node, "pll0");
267+
hw = clk_hw_register_fixed_rate(NULL, pll0_name, NULL, 0,
269268
1000 * 1000 * 1000);
270269
if (IS_ERR(hw)) {
271270
ret = PTR_ERR(hw);
272-
goto fail_apll;
271+
goto fail_pll0;
273272
}
274273

275-
cp110_clks[CP110_CORE_APLL] = hw;
274+
cp110_clks[CP110_CORE_PLL0] = hw;
276275

277-
/* PPv2 is APLL/3 */
276+
/* PPv2 is PLL0/3 */
278277
ppv2_name = cp110_unique_name(dev, syscon_node, "ppv2-core");
279-
hw = clk_hw_register_fixed_factor(NULL, ppv2_name, apll_name, 0, 1, 3);
278+
hw = clk_hw_register_fixed_factor(NULL, ppv2_name, pll0_name, 0, 1, 3);
280279
if (IS_ERR(hw)) {
281280
ret = PTR_ERR(hw);
282281
goto fail_ppv2;
283282
}
284283

285284
cp110_clks[CP110_CORE_PPV2] = hw;
286285

287-
/* EIP clock is APLL/2 */
288-
eip_name = cp110_unique_name(dev, syscon_node, "eip");
289-
hw = clk_hw_register_fixed_factor(NULL, eip_name, apll_name, 0, 1, 2);
286+
/* X2CORE clock is PLL0/2 */
287+
x2core_name = cp110_unique_name(dev, syscon_node, "x2core");
288+
hw = clk_hw_register_fixed_factor(NULL, x2core_name, pll0_name,
289+
0, 1, 2);
290290
if (IS_ERR(hw)) {
291291
ret = PTR_ERR(hw);
292292
goto fail_eip;
293293
}
294294

295-
cp110_clks[CP110_CORE_EIP] = hw;
295+
cp110_clks[CP110_CORE_X2CORE] = hw;
296296

297-
/* Core clock is EIP/2 */
297+
/* Core clock is X2CORE/2 */
298298
core_name = cp110_unique_name(dev, syscon_node, "core");
299-
hw = clk_hw_register_fixed_factor(NULL, core_name, eip_name, 0, 1, 2);
299+
hw = clk_hw_register_fixed_factor(NULL, core_name, x2core_name,
300+
0, 1, 2);
300301
if (IS_ERR(hw)) {
301302
ret = PTR_ERR(hw);
302303
goto fail_core;
303304
}
304305

305306
cp110_clks[CP110_CORE_CORE] = hw;
306-
/* NAND can be either APLL/2.5 or core clock */
307+
/* NAND can be either PLL0/2.5 or core clock */
307308
nand_name = cp110_unique_name(dev, syscon_node, "nand-core");
308309
if (nand_clk_ctrl & NF_CLOCK_SEL_400_MASK)
309310
hw = clk_hw_register_fixed_factor(NULL, nand_name,
310-
apll_name, 0, 2, 5);
311+
pll0_name, 0, 2, 5);
311312
else
312313
hw = clk_hw_register_fixed_factor(NULL, nand_name,
313314
core_name, 0, 1, 1);
@@ -318,10 +319,10 @@ static int cp110_syscon_common_probe(struct platform_device *pdev,
318319

319320
cp110_clks[CP110_CORE_NAND] = hw;
320321

321-
/* SDIO clock is APLL/2.5 */
322+
/* SDIO clock is PLL0/2.5 */
322323
sdio_name = cp110_unique_name(dev, syscon_node, "sdio-core");
323324
hw = clk_hw_register_fixed_factor(NULL, sdio_name,
324-
apll_name, 0, 2, 5);
325+
pll0_name, 0, 2, 5);
325326
if (IS_ERR(hw)) {
326327
ret = PTR_ERR(hw);
327328
goto fail_sdio;
@@ -341,40 +342,23 @@ static int cp110_syscon_common_probe(struct platform_device *pdev,
341342
continue;
342343

343344
switch (i) {
344-
case CP110_GATE_AUDIO:
345-
case CP110_GATE_COMM_UNIT:
346-
case CP110_GATE_EIP150:
347-
case CP110_GATE_EIP197:
348-
case CP110_GATE_SLOW_IO:
349-
parent = gate_name[CP110_GATE_MAIN];
350-
break;
351-
case CP110_GATE_MG:
352-
parent = gate_name[CP110_GATE_MG_CORE];
353-
break;
354345
case CP110_GATE_NAND:
355346
parent = nand_name;
356347
break;
348+
case CP110_GATE_MG:
349+
case CP110_GATE_GOP_DP:
357350
case CP110_GATE_PPV2:
358351
parent = ppv2_name;
359352
break;
360353
case CP110_GATE_SDIO:
361354
parent = sdio_name;
362355
break;
363-
case CP110_GATE_GOP_DP:
364-
parent = gate_name[CP110_GATE_SDMMC_GOP];
365-
break;
366-
case CP110_GATE_XOR1:
367-
case CP110_GATE_XOR0:
368-
case CP110_GATE_PCIE_X1_0:
369-
case CP110_GATE_PCIE_X1_1:
356+
case CP110_GATE_MAIN:
357+
case CP110_GATE_PCIE_XOR:
370358
case CP110_GATE_PCIE_X4:
371-
parent = gate_name[CP110_GATE_PCIE_XOR];
372-
break;
373-
case CP110_GATE_SATA:
374-
case CP110_GATE_USB3H0:
375-
case CP110_GATE_USB3H1:
376-
case CP110_GATE_USB3DEV:
377-
parent = gate_name[CP110_GATE_SATA_USB];
359+
case CP110_GATE_EIP150:
360+
case CP110_GATE_EIP197:
361+
parent = x2core_name;
378362
break;
379363
default:
380364
parent = core_name;
@@ -413,12 +397,12 @@ static int cp110_syscon_common_probe(struct platform_device *pdev,
413397
fail_nand:
414398
clk_hw_unregister_fixed_factor(cp110_clks[CP110_CORE_CORE]);
415399
fail_core:
416-
clk_hw_unregister_fixed_factor(cp110_clks[CP110_CORE_EIP]);
400+
clk_hw_unregister_fixed_factor(cp110_clks[CP110_CORE_X2CORE]);
417401
fail_eip:
418402
clk_hw_unregister_fixed_factor(cp110_clks[CP110_CORE_PPV2]);
419403
fail_ppv2:
420-
clk_hw_unregister_fixed_rate(cp110_clks[CP110_CORE_APLL]);
421-
fail_apll:
404+
clk_hw_unregister_fixed_rate(cp110_clks[CP110_CORE_PLL0]);
405+
fail_pll0:
422406
return ret;
423407
}
424408

0 commit comments

Comments
 (0)