Skip to content

Commit 3849716

Browse files
committed
clk: renesas: sh73a0: Remove sh73a0_cpg.reg
The register block base pointer as stored in the reg member of the sh73a0_cpg structure is only used during initialization. Hence move it to a local variable, and pass it as a parameter to sh73a0_cpg_register_clock(). Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Reviewed-by: Wolfram Sang <wsa+renesas@sang-engineering.com> Link: https://lore.kernel.org/r/5423e43d0cf518691965412fb510097d23ac5955.1654694831.git.geert+renesas@glider.be
1 parent a00d077 commit 3849716

1 file changed

Lines changed: 13 additions & 13 deletions

File tree

drivers/clk/renesas/clk-sh73a0.c

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
struct sh73a0_cpg {
1919
struct clk_onecell_data data;
2020
spinlock_t lock;
21-
void __iomem *reg;
2221
};
2322

2423
#define CPG_FRQCRA 0x00
@@ -73,7 +72,7 @@ static const struct clk_div_table z_div_table[] = {
7372

7473
static struct clk * __init
7574
sh73a0_cpg_register_clock(struct device_node *np, struct sh73a0_cpg *cpg,
76-
const char *name)
75+
void __iomem *base, const char *name)
7776
{
7877
const struct clk_div_table *table = NULL;
7978
unsigned int shift, reg, width;
@@ -83,12 +82,12 @@ sh73a0_cpg_register_clock(struct device_node *np, struct sh73a0_cpg *cpg,
8382

8483
if (!strcmp(name, "main")) {
8584
/* extal1, extal1_div2, extal2, extal2_div2 */
86-
u32 parent_idx = (readl(cpg->reg + CPG_CKSCR) >> 28) & 3;
85+
u32 parent_idx = (readl(base + CPG_CKSCR) >> 28) & 3;
8786

8887
parent_name = of_clk_get_parent_name(np, parent_idx >> 1);
8988
div = (parent_idx & 1) + 1;
9089
} else if (!strncmp(name, "pll", 3)) {
91-
void __iomem *enable_reg = cpg->reg;
90+
void __iomem *enable_reg = base;
9291
u32 enable_bit = name[3] - '0';
9392

9493
parent_name = "main";
@@ -108,7 +107,7 @@ sh73a0_cpg_register_clock(struct device_node *np, struct sh73a0_cpg *cpg,
108107
default:
109108
return ERR_PTR(-EINVAL);
110109
}
111-
if (readl(cpg->reg + CPG_PLLECR) & BIT(enable_bit)) {
110+
if (readl(base + CPG_PLLECR) & BIT(enable_bit)) {
112111
mult = ((readl(enable_reg) >> 24) & 0x3f) + 1;
113112
/* handle CFG bit for PLL1 and PLL2 */
114113
if (enable_bit == 1 || enable_bit == 2)
@@ -117,7 +116,7 @@ sh73a0_cpg_register_clock(struct device_node *np, struct sh73a0_cpg *cpg,
117116
}
118117
} else if (!strcmp(name, "dsi0phy") || !strcmp(name, "dsi1phy")) {
119118
u32 phy_no = name[3] - '0';
120-
void __iomem *dsi_reg = cpg->reg +
119+
void __iomem *dsi_reg = base +
121120
(phy_no ? CPG_DSI1PHYCR : CPG_DSI0PHYCR);
122121

123122
parent_name = phy_no ? "dsi1pck" : "dsi0pck";
@@ -154,14 +153,15 @@ sh73a0_cpg_register_clock(struct device_node *np, struct sh73a0_cpg *cpg,
154153
mult, div);
155154
} else {
156155
return clk_register_divider_table(NULL, name, parent_name, 0,
157-
cpg->reg + reg, shift, width, 0,
156+
base + reg, shift, width, 0,
158157
table, &cpg->lock);
159158
}
160159
}
161160

162161
static void __init sh73a0_cpg_clocks_init(struct device_node *np)
163162
{
164163
struct sh73a0_cpg *cpg;
164+
void __iomem *base;
165165
struct clk **clks;
166166
unsigned int i;
167167
int num_clks;
@@ -186,14 +186,14 @@ static void __init sh73a0_cpg_clocks_init(struct device_node *np)
186186
cpg->data.clks = clks;
187187
cpg->data.clk_num = num_clks;
188188

189-
cpg->reg = of_iomap(np, 0);
190-
if (WARN_ON(cpg->reg == NULL))
189+
base = of_iomap(np, 0);
190+
if (WARN_ON(base == NULL))
191191
return;
192192

193193
/* Set SDHI clocks to a known state */
194-
writel(0x108, cpg->reg + CPG_SD0CKCR);
195-
writel(0x108, cpg->reg + CPG_SD1CKCR);
196-
writel(0x108, cpg->reg + CPG_SD2CKCR);
194+
writel(0x108, base + CPG_SD0CKCR);
195+
writel(0x108, base + CPG_SD1CKCR);
196+
writel(0x108, base + CPG_SD2CKCR);
197197

198198
for (i = 0; i < num_clks; ++i) {
199199
const char *name;
@@ -202,7 +202,7 @@ static void __init sh73a0_cpg_clocks_init(struct device_node *np)
202202
of_property_read_string_index(np, "clock-output-names", i,
203203
&name);
204204

205-
clk = sh73a0_cpg_register_clock(np, cpg, name);
205+
clk = sh73a0_cpg_register_clock(np, cpg, base, name);
206206
if (IS_ERR(clk))
207207
pr_err("%s: failed to register %pOFn %s clock (%ld)\n",
208208
__func__, np, name, PTR_ERR(clk));

0 commit comments

Comments
 (0)