Commit 268aebaa authored by Xing Zheng's avatar Xing Zheng Committed by Heiko Stuebner

clk: rockchip: allow varying mux parameters for cpuclk pll-sources

Thers are only two parent PLLs that APLL and GPLL for core on the
previous SoCs (RK3066/RK3188/RK3288/RK3368). Hence, we set fixed
GPLL as alternate parent when core is switching freq.

Since RK3399 big.LITTLE architecture, we need to select and adapt
more PLLs (ALPLL/ABPLL/DPLL/GPLL) sources.
Signed-off-by: default avatarXing Zheng <zhengxing@rock-chips.com>
Signed-off-by: default avatarHeiko Stuebner <heiko@sntech.de>
parent 9387bfd1
...@@ -158,12 +158,16 @@ static int rockchip_cpuclk_pre_rate_change(struct rockchip_cpuclk *cpuclk, ...@@ -158,12 +158,16 @@ static int rockchip_cpuclk_pre_rate_change(struct rockchip_cpuclk *cpuclk,
writel(HIWORD_UPDATE(alt_div, reg_data->div_core_mask, writel(HIWORD_UPDATE(alt_div, reg_data->div_core_mask,
reg_data->div_core_shift) | reg_data->div_core_shift) |
HIWORD_UPDATE(1, 1, reg_data->mux_core_shift), HIWORD_UPDATE(reg_data->mux_core_alt,
reg_data->mux_core_mask,
reg_data->mux_core_shift),
cpuclk->reg_base + reg_data->core_reg); cpuclk->reg_base + reg_data->core_reg);
} else { } else {
/* select alternate parent */ /* select alternate parent */
writel(HIWORD_UPDATE(1, 1, reg_data->mux_core_shift), writel(HIWORD_UPDATE(reg_data->mux_core_alt,
cpuclk->reg_base + reg_data->core_reg); reg_data->mux_core_mask,
reg_data->mux_core_shift),
cpuclk->reg_base + reg_data->core_reg);
} }
spin_unlock_irqrestore(cpuclk->lock, flags); spin_unlock_irqrestore(cpuclk->lock, flags);
...@@ -198,7 +202,9 @@ static int rockchip_cpuclk_post_rate_change(struct rockchip_cpuclk *cpuclk, ...@@ -198,7 +202,9 @@ static int rockchip_cpuclk_post_rate_change(struct rockchip_cpuclk *cpuclk,
writel(HIWORD_UPDATE(0, reg_data->div_core_mask, writel(HIWORD_UPDATE(0, reg_data->div_core_mask,
reg_data->div_core_shift) | reg_data->div_core_shift) |
HIWORD_UPDATE(0, 1, reg_data->mux_core_shift), HIWORD_UPDATE(reg_data->mux_core_main,
reg_data->mux_core_mask,
reg_data->mux_core_shift),
cpuclk->reg_base + reg_data->core_reg); cpuclk->reg_base + reg_data->core_reg);
if (ndata->old_rate > ndata->new_rate) if (ndata->old_rate > ndata->new_rate)
...@@ -252,7 +258,7 @@ struct clk *rockchip_clk_register_cpuclk(const char *name, ...@@ -252,7 +258,7 @@ struct clk *rockchip_clk_register_cpuclk(const char *name,
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
init.name = name; init.name = name;
init.parent_names = &parent_names[0]; init.parent_names = &parent_names[reg_data->mux_core_main];
init.num_parents = 1; init.num_parents = 1;
init.ops = &rockchip_cpuclk_ops; init.ops = &rockchip_cpuclk_ops;
...@@ -270,10 +276,10 @@ struct clk *rockchip_clk_register_cpuclk(const char *name, ...@@ -270,10 +276,10 @@ struct clk *rockchip_clk_register_cpuclk(const char *name,
cpuclk->clk_nb.notifier_call = rockchip_cpuclk_notifier_cb; cpuclk->clk_nb.notifier_call = rockchip_cpuclk_notifier_cb;
cpuclk->hw.init = &init; cpuclk->hw.init = &init;
cpuclk->alt_parent = __clk_lookup(parent_names[1]); cpuclk->alt_parent = __clk_lookup(parent_names[reg_data->mux_core_alt]);
if (!cpuclk->alt_parent) { if (!cpuclk->alt_parent) {
pr_err("%s: could not lookup alternate parent\n", pr_err("%s: could not lookup alternate parent: (%d)\n",
__func__); __func__, reg_data->mux_core_alt);
ret = -EINVAL; ret = -EINVAL;
goto free_cpuclk; goto free_cpuclk;
} }
...@@ -285,10 +291,11 @@ struct clk *rockchip_clk_register_cpuclk(const char *name, ...@@ -285,10 +291,11 @@ struct clk *rockchip_clk_register_cpuclk(const char *name,
goto free_cpuclk; goto free_cpuclk;
} }
clk = __clk_lookup(parent_names[0]); clk = __clk_lookup(parent_names[reg_data->mux_core_main]);
if (!clk) { if (!clk) {
pr_err("%s: could not lookup parent clock %s\n", pr_err("%s: could not lookup parent clock: (%d) %s\n",
__func__, parent_names[0]); __func__, reg_data->mux_core_main,
parent_names[reg_data->mux_core_main]);
ret = -EINVAL; ret = -EINVAL;
goto free_alt_parent; goto free_alt_parent;
} }
......
...@@ -113,7 +113,10 @@ static const struct rockchip_cpuclk_reg_data rk3036_cpuclk_data = { ...@@ -113,7 +113,10 @@ static const struct rockchip_cpuclk_reg_data rk3036_cpuclk_data = {
.core_reg = RK2928_CLKSEL_CON(0), .core_reg = RK2928_CLKSEL_CON(0),
.div_core_shift = 0, .div_core_shift = 0,
.div_core_mask = 0x1f, .div_core_mask = 0x1f,
.mux_core_alt = 1,
.mux_core_main = 0,
.mux_core_shift = 7, .mux_core_shift = 7,
.mux_core_mask = 0x1,
}; };
PNAME(mux_pll_p) = { "xin24m", "xin24m" }; PNAME(mux_pll_p) = { "xin24m", "xin24m" };
......
...@@ -155,7 +155,10 @@ static const struct rockchip_cpuclk_reg_data rk3066_cpuclk_data = { ...@@ -155,7 +155,10 @@ static const struct rockchip_cpuclk_reg_data rk3066_cpuclk_data = {
.core_reg = RK2928_CLKSEL_CON(0), .core_reg = RK2928_CLKSEL_CON(0),
.div_core_shift = 0, .div_core_shift = 0,
.div_core_mask = 0x1f, .div_core_mask = 0x1f,
.mux_core_alt = 1,
.mux_core_main = 0,
.mux_core_shift = 8, .mux_core_shift = 8,
.mux_core_mask = 0x1,
}; };
#define RK3188_DIV_ACLK_CORE_MASK 0x7 #define RK3188_DIV_ACLK_CORE_MASK 0x7
...@@ -191,7 +194,10 @@ static const struct rockchip_cpuclk_reg_data rk3188_cpuclk_data = { ...@@ -191,7 +194,10 @@ static const struct rockchip_cpuclk_reg_data rk3188_cpuclk_data = {
.core_reg = RK2928_CLKSEL_CON(0), .core_reg = RK2928_CLKSEL_CON(0),
.div_core_shift = 9, .div_core_shift = 9,
.div_core_mask = 0x1f, .div_core_mask = 0x1f,
.mux_core_alt = 1,
.mux_core_main = 0,
.mux_core_shift = 8, .mux_core_shift = 8,
.mux_core_mask = 0x1,
}; };
PNAME(mux_pll_p) = { "xin24m", "xin32k" }; PNAME(mux_pll_p) = { "xin24m", "xin32k" };
......
...@@ -111,7 +111,10 @@ static const struct rockchip_cpuclk_reg_data rk3228_cpuclk_data = { ...@@ -111,7 +111,10 @@ static const struct rockchip_cpuclk_reg_data rk3228_cpuclk_data = {
.core_reg = RK2928_CLKSEL_CON(0), .core_reg = RK2928_CLKSEL_CON(0),
.div_core_shift = 0, .div_core_shift = 0,
.div_core_mask = 0x1f, .div_core_mask = 0x1f,
.mux_core_alt = 1,
.mux_core_main = 0,
.mux_core_shift = 6, .mux_core_shift = 6,
.mux_core_mask = 0x1,
}; };
PNAME(mux_pll_p) = { "clk_24m", "xin24m" }; PNAME(mux_pll_p) = { "clk_24m", "xin24m" };
......
...@@ -165,7 +165,10 @@ static const struct rockchip_cpuclk_reg_data rk3288_cpuclk_data = { ...@@ -165,7 +165,10 @@ static const struct rockchip_cpuclk_reg_data rk3288_cpuclk_data = {
.core_reg = RK3288_CLKSEL_CON(0), .core_reg = RK3288_CLKSEL_CON(0),
.div_core_shift = 8, .div_core_shift = 8,
.div_core_mask = 0x1f, .div_core_mask = 0x1f,
.mux_core_alt = 1,
.mux_core_main = 0,
.mux_core_shift = 15, .mux_core_shift = 15,
.mux_core_mask = 0x1,
}; };
PNAME(mux_pll_p) = { "xin24m", "xin32k" }; PNAME(mux_pll_p) = { "xin24m", "xin32k" };
......
...@@ -165,14 +165,20 @@ static const struct rockchip_cpuclk_reg_data rk3368_cpuclkb_data = { ...@@ -165,14 +165,20 @@ static const struct rockchip_cpuclk_reg_data rk3368_cpuclkb_data = {
.core_reg = RK3368_CLKSEL_CON(0), .core_reg = RK3368_CLKSEL_CON(0),
.div_core_shift = 0, .div_core_shift = 0,
.div_core_mask = 0x1f, .div_core_mask = 0x1f,
.mux_core_alt = 1,
.mux_core_main = 0,
.mux_core_shift = 7, .mux_core_shift = 7,
.mux_core_mask = 0x1,
}; };
static const struct rockchip_cpuclk_reg_data rk3368_cpuclkl_data = { static const struct rockchip_cpuclk_reg_data rk3368_cpuclkl_data = {
.core_reg = RK3368_CLKSEL_CON(2), .core_reg = RK3368_CLKSEL_CON(2),
.div_core_shift = 0, .div_core_shift = 0,
.mux_core_alt = 1,
.mux_core_main = 0,
.div_core_mask = 0x1f, .div_core_mask = 0x1f,
.mux_core_shift = 7, .mux_core_shift = 7,
.mux_core_mask = 0x1,
}; };
#define RK3368_DIV_ACLKM_MASK 0x1f #define RK3368_DIV_ACLKM_MASK 0x1f
......
...@@ -217,14 +217,20 @@ struct rockchip_cpuclk_rate_table { ...@@ -217,14 +217,20 @@ struct rockchip_cpuclk_rate_table {
* @core_reg: register offset of the core settings register * @core_reg: register offset of the core settings register
* @div_core_shift: core divider offset used to divide the pll value * @div_core_shift: core divider offset used to divide the pll value
* @div_core_mask: core divider mask * @div_core_mask: core divider mask
* @mux_core_alt: mux value to select alternate parent
* @mux_core_main: mux value to select main parent of core
* @mux_core_shift: offset of the core multiplexer * @mux_core_shift: offset of the core multiplexer
* @mux_core_mask: core multiplexer mask
*/ */
struct rockchip_cpuclk_reg_data { struct rockchip_cpuclk_reg_data {
int core_reg; int core_reg;
u8 div_core_shift; u8 div_core_shift;
u32 div_core_mask; u32 div_core_mask;
int mux_core_reg; int mux_core_reg;
u8 mux_core_alt;
u8 mux_core_main;
u8 mux_core_shift; u8 mux_core_shift;
u32 mux_core_mask;
}; };
struct clk *rockchip_clk_register_cpuclk(const char *name, struct clk *rockchip_clk_register_cpuclk(const char *name,
......
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