Commit 65d012e4 authored by Geert Uytterhoeven's avatar Geert Uytterhoeven

clk: renesas: r8a73a4: Remove r8a73a4_cpg.reg

The register block base pointer as stored in the reg member of the
r8a73a4_cpg structure is only used during initialization.  Hence move
it to a local variable, and pass it as a parameter to
r8a73a4_cpg_register_clock().
Signed-off-by: default avatarGeert Uytterhoeven <geert+renesas@glider.be>
Reviewed-by: default avatarWolfram Sang <wsa+renesas@sang-engineering.com>
Link: https://lore.kernel.org/r/f835f3dfcf3bf754065e5002663952cc6341caac.1654694831.git.geert+renesas@glider.be
parent 75fe45a0
...@@ -18,7 +18,6 @@ ...@@ -18,7 +18,6 @@
struct r8a73a4_cpg { struct r8a73a4_cpg {
struct clk_onecell_data data; struct clk_onecell_data data;
spinlock_t lock; spinlock_t lock;
void __iomem *reg;
}; };
#define CPG_CKSCR 0xc0 #define CPG_CKSCR 0xc0
...@@ -59,7 +58,7 @@ static const struct clk_div_table div4_div_table[] = { ...@@ -59,7 +58,7 @@ static const struct clk_div_table div4_div_table[] = {
static struct clk * __init static struct clk * __init
r8a73a4_cpg_register_clock(struct device_node *np, struct r8a73a4_cpg *cpg, r8a73a4_cpg_register_clock(struct device_node *np, struct r8a73a4_cpg *cpg,
const char *name) void __iomem *base, const char *name)
{ {
const struct clk_div_table *table = NULL; const struct clk_div_table *table = NULL;
const char *parent_name; const char *parent_name;
...@@ -69,7 +68,7 @@ r8a73a4_cpg_register_clock(struct device_node *np, struct r8a73a4_cpg *cpg, ...@@ -69,7 +68,7 @@ r8a73a4_cpg_register_clock(struct device_node *np, struct r8a73a4_cpg *cpg,
if (!strcmp(name, "main")) { if (!strcmp(name, "main")) {
u32 ckscr = readl(cpg->reg + CPG_CKSCR); u32 ckscr = readl(base + CPG_CKSCR);
switch ((ckscr >> 28) & 3) { switch ((ckscr >> 28) & 3) {
case 0: /* extal1 */ case 0: /* extal1 */
...@@ -93,14 +92,14 @@ r8a73a4_cpg_register_clock(struct device_node *np, struct r8a73a4_cpg *cpg, ...@@ -93,14 +92,14 @@ r8a73a4_cpg_register_clock(struct device_node *np, struct r8a73a4_cpg *cpg,
* clock implementation and we currently have no need to change * clock implementation and we currently have no need to change
* the multiplier value. * the multiplier value.
*/ */
u32 value = readl(cpg->reg + CPG_PLL0CR); u32 value = readl(base + CPG_PLL0CR);
parent_name = "main"; parent_name = "main";
mult = ((value >> 24) & 0x7f) + 1; mult = ((value >> 24) & 0x7f) + 1;
if (value & BIT(20)) if (value & BIT(20))
div = 2; div = 2;
} else if (!strcmp(name, "pll1")) { } else if (!strcmp(name, "pll1")) {
u32 value = readl(cpg->reg + CPG_PLL1CR); u32 value = readl(base + CPG_PLL1CR);
parent_name = "main"; parent_name = "main";
/* XXX: enable bit? */ /* XXX: enable bit? */
...@@ -123,7 +122,7 @@ r8a73a4_cpg_register_clock(struct device_node *np, struct r8a73a4_cpg *cpg, ...@@ -123,7 +122,7 @@ r8a73a4_cpg_register_clock(struct device_node *np, struct r8a73a4_cpg *cpg,
default: default:
return ERR_PTR(-EINVAL); return ERR_PTR(-EINVAL);
} }
value = readl(cpg->reg + cr); value = readl(base + cr);
switch ((value >> 5) & 7) { switch ((value >> 5) & 7) {
case 0: case 0:
parent_name = "main"; parent_name = "main";
...@@ -159,7 +158,7 @@ r8a73a4_cpg_register_clock(struct device_node *np, struct r8a73a4_cpg *cpg, ...@@ -159,7 +158,7 @@ r8a73a4_cpg_register_clock(struct device_node *np, struct r8a73a4_cpg *cpg,
shift = 0; shift = 0;
} }
div *= 32; div *= 32;
mult = 0x20 - ((readl(cpg->reg + CPG_FRQCRC) >> shift) & 0x1f); mult = 0x20 - ((readl(base + CPG_FRQCRC) >> shift) & 0x1f);
} else { } else {
struct div4_clk *c; struct div4_clk *c;
...@@ -181,7 +180,7 @@ r8a73a4_cpg_register_clock(struct device_node *np, struct r8a73a4_cpg *cpg, ...@@ -181,7 +180,7 @@ r8a73a4_cpg_register_clock(struct device_node *np, struct r8a73a4_cpg *cpg,
mult, div); mult, div);
} else { } else {
return clk_register_divider_table(NULL, name, parent_name, 0, return clk_register_divider_table(NULL, name, parent_name, 0,
cpg->reg + reg, shift, 4, 0, base + reg, shift, 4, 0,
table, &cpg->lock); table, &cpg->lock);
} }
} }
...@@ -189,6 +188,7 @@ r8a73a4_cpg_register_clock(struct device_node *np, struct r8a73a4_cpg *cpg, ...@@ -189,6 +188,7 @@ r8a73a4_cpg_register_clock(struct device_node *np, struct r8a73a4_cpg *cpg,
static void __init r8a73a4_cpg_clocks_init(struct device_node *np) static void __init r8a73a4_cpg_clocks_init(struct device_node *np)
{ {
struct r8a73a4_cpg *cpg; struct r8a73a4_cpg *cpg;
void __iomem *base;
struct clk **clks; struct clk **clks;
unsigned int i; unsigned int i;
int num_clks; int num_clks;
...@@ -213,8 +213,8 @@ static void __init r8a73a4_cpg_clocks_init(struct device_node *np) ...@@ -213,8 +213,8 @@ static void __init r8a73a4_cpg_clocks_init(struct device_node *np)
cpg->data.clks = clks; cpg->data.clks = clks;
cpg->data.clk_num = num_clks; cpg->data.clk_num = num_clks;
cpg->reg = of_iomap(np, 0); base = of_iomap(np, 0);
if (WARN_ON(cpg->reg == NULL)) if (WARN_ON(base == NULL))
return; return;
for (i = 0; i < num_clks; ++i) { for (i = 0; i < num_clks; ++i) {
...@@ -224,7 +224,7 @@ static void __init r8a73a4_cpg_clocks_init(struct device_node *np) ...@@ -224,7 +224,7 @@ static void __init r8a73a4_cpg_clocks_init(struct device_node *np)
of_property_read_string_index(np, "clock-output-names", i, of_property_read_string_index(np, "clock-output-names", i,
&name); &name);
clk = r8a73a4_cpg_register_clock(np, cpg, name); clk = r8a73a4_cpg_register_clock(np, cpg, base, name);
if (IS_ERR(clk)) if (IS_ERR(clk))
pr_err("%s: failed to register %pOFn %s clock (%ld)\n", pr_err("%s: failed to register %pOFn %s clock (%ld)\n",
__func__, np, name, PTR_ERR(clk)); __func__, np, name, PTR_ERR(clk));
......
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