Commit a013e981 authored by Xingyu Wu's avatar Xingyu Wu Committed by Conor Dooley

clk: starfive: jh7110-sys: Add PLL clocks source from DTS

Modify PLL clocks source to be got from DTS or
the fixed factor clocks.
Signed-off-by: default avatarXingyu Wu <xingyu.wu@starfivetech.com>
Reviewed-by: default avatarEmil Renner Berthing <emil.renner.berthing@canonical.com>
Signed-off-by: default avatarConor Dooley <conor.dooley@microchip.com>
parent 616bc1de
...@@ -35,6 +35,7 @@ config CLK_STARFIVE_JH7110_SYS ...@@ -35,6 +35,7 @@ config CLK_STARFIVE_JH7110_SYS
select AUXILIARY_BUS select AUXILIARY_BUS
select CLK_STARFIVE_JH71X0 select CLK_STARFIVE_JH71X0
select RESET_STARFIVE_JH7110 if RESET_CONTROLLER select RESET_STARFIVE_JH7110 if RESET_CONTROLLER
select CLK_STARFIVE_JH7110_PLL
default ARCH_STARFIVE default ARCH_STARFIVE
help help
Say yes here to support the system clock controller on the Say yes here to support the system clock controller on the
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
*/ */
#include <linux/auxiliary_bus.h> #include <linux/auxiliary_bus.h>
#include <linux/clk.h>
#include <linux/clk-provider.h> #include <linux/clk-provider.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/io.h> #include <linux/io.h>
...@@ -389,6 +390,7 @@ static int __init jh7110_syscrg_probe(struct platform_device *pdev) ...@@ -389,6 +390,7 @@ static int __init jh7110_syscrg_probe(struct platform_device *pdev)
struct jh71x0_clk_priv *priv; struct jh71x0_clk_priv *priv;
unsigned int idx; unsigned int idx;
int ret; int ret;
struct clk *pllclk;
priv = devm_kzalloc(&pdev->dev, priv = devm_kzalloc(&pdev->dev,
struct_size(priv, reg, JH7110_SYSCLK_END), struct_size(priv, reg, JH7110_SYSCLK_END),
...@@ -402,28 +404,42 @@ static int __init jh7110_syscrg_probe(struct platform_device *pdev) ...@@ -402,28 +404,42 @@ static int __init jh7110_syscrg_probe(struct platform_device *pdev)
if (IS_ERR(priv->base)) if (IS_ERR(priv->base))
return PTR_ERR(priv->base); return PTR_ERR(priv->base);
/* /* Use fixed factor clocks if can not get the PLL clocks from DTS */
* These PLL clocks are not actually fixed factor clocks and can be pllclk = clk_get(priv->dev, "pll0_out");
* controlled by the syscon registers of JH7110. They will be dropped if (IS_ERR(pllclk)) {
* and registered in the PLL clock driver instead. /* 24MHz -> 1000.0MHz */
*/ priv->pll[0] = devm_clk_hw_register_fixed_factor(priv->dev, "pll0_out",
/* 24MHz -> 1000.0MHz */ "osc", 0, 125, 3);
priv->pll[0] = devm_clk_hw_register_fixed_factor(priv->dev, "pll0_out", if (IS_ERR(priv->pll[0]))
"osc", 0, 125, 3); return PTR_ERR(priv->pll[0]);
if (IS_ERR(priv->pll[0])) } else {
return PTR_ERR(priv->pll[0]); clk_put(pllclk);
priv->pll[0] = NULL;
/* 24MHz -> 1066.0MHz */ }
priv->pll[1] = devm_clk_hw_register_fixed_factor(priv->dev, "pll1_out",
"osc", 0, 533, 12); pllclk = clk_get(priv->dev, "pll1_out");
if (IS_ERR(priv->pll[1])) if (IS_ERR(pllclk)) {
return PTR_ERR(priv->pll[1]); /* 24MHz -> 1066.0MHz */
priv->pll[1] = devm_clk_hw_register_fixed_factor(priv->dev, "pll1_out",
/* 24MHz -> 1188.0MHz */ "osc", 0, 533, 12);
priv->pll[2] = devm_clk_hw_register_fixed_factor(priv->dev, "pll2_out", if (IS_ERR(priv->pll[1]))
"osc", 0, 99, 2); return PTR_ERR(priv->pll[1]);
if (IS_ERR(priv->pll[2])) } else {
return PTR_ERR(priv->pll[2]); clk_put(pllclk);
priv->pll[1] = NULL;
}
pllclk = clk_get(priv->dev, "pll2_out");
if (IS_ERR(pllclk)) {
/* 24MHz -> 1188.0MHz */
priv->pll[2] = devm_clk_hw_register_fixed_factor(priv->dev, "pll2_out",
"osc", 0, 99, 2);
if (IS_ERR(priv->pll[2]))
return PTR_ERR(priv->pll[2]);
} else {
clk_put(pllclk);
priv->pll[2] = NULL;
}
for (idx = 0; idx < JH7110_SYSCLK_END; idx++) { for (idx = 0; idx < JH7110_SYSCLK_END; idx++) {
u32 max = jh7110_sysclk_data[idx].max; u32 max = jh7110_sysclk_data[idx].max;
...@@ -462,6 +478,12 @@ static int __init jh7110_syscrg_probe(struct platform_device *pdev) ...@@ -462,6 +478,12 @@ static int __init jh7110_syscrg_probe(struct platform_device *pdev)
parents[i].fw_name = "tdm_ext"; parents[i].fw_name = "tdm_ext";
else if (pidx == JH7110_SYSCLK_MCLK_EXT) else if (pidx == JH7110_SYSCLK_MCLK_EXT)
parents[i].fw_name = "mclk_ext"; parents[i].fw_name = "mclk_ext";
else if (pidx == JH7110_SYSCLK_PLL0_OUT && !priv->pll[0])
parents[i].fw_name = "pll0_out";
else if (pidx == JH7110_SYSCLK_PLL1_OUT && !priv->pll[1])
parents[i].fw_name = "pll1_out";
else if (pidx == JH7110_SYSCLK_PLL2_OUT && !priv->pll[2])
parents[i].fw_name = "pll2_out";
else else
parents[i].hw = priv->pll[pidx - JH7110_SYSCLK_PLL0_OUT]; parents[i].hw = priv->pll[pidx - JH7110_SYSCLK_PLL0_OUT];
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment