Skip to content

Commit 65d012e

Browse files
committed
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: Geert Uytterhoeven <geert+renesas@glider.be> Reviewed-by: Wolfram Sang <wsa+renesas@sang-engineering.com> Link: https://lore.kernel.org/r/f835f3dfcf3bf754065e5002663952cc6341caac.1654694831.git.geert+renesas@glider.be
1 parent 75fe45a commit 65d012e

1 file changed

Lines changed: 11 additions & 11 deletions

File tree

drivers/clk/renesas/clk-r8a73a4.c

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

2423
#define CPG_CKSCR 0xc0
@@ -59,7 +58,7 @@ static const struct clk_div_table div4_div_table[] = {
5958

6059
static struct clk * __init
6160
r8a73a4_cpg_register_clock(struct device_node *np, struct r8a73a4_cpg *cpg,
62-
const char *name)
61+
void __iomem *base, const char *name)
6362
{
6463
const struct clk_div_table *table = NULL;
6564
const char *parent_name;
@@ -69,7 +68,7 @@ r8a73a4_cpg_register_clock(struct device_node *np, struct r8a73a4_cpg *cpg,
6968

7069

7170
if (!strcmp(name, "main")) {
72-
u32 ckscr = readl(cpg->reg + CPG_CKSCR);
71+
u32 ckscr = readl(base + CPG_CKSCR);
7372

7473
switch ((ckscr >> 28) & 3) {
7574
case 0: /* extal1 */
@@ -93,14 +92,14 @@ r8a73a4_cpg_register_clock(struct device_node *np, struct r8a73a4_cpg *cpg,
9392
* clock implementation and we currently have no need to change
9493
* the multiplier value.
9594
*/
96-
u32 value = readl(cpg->reg + CPG_PLL0CR);
95+
u32 value = readl(base + CPG_PLL0CR);
9796

9897
parent_name = "main";
9998
mult = ((value >> 24) & 0x7f) + 1;
10099
if (value & BIT(20))
101100
div = 2;
102101
} else if (!strcmp(name, "pll1")) {
103-
u32 value = readl(cpg->reg + CPG_PLL1CR);
102+
u32 value = readl(base + CPG_PLL1CR);
104103

105104
parent_name = "main";
106105
/* XXX: enable bit? */
@@ -123,7 +122,7 @@ r8a73a4_cpg_register_clock(struct device_node *np, struct r8a73a4_cpg *cpg,
123122
default:
124123
return ERR_PTR(-EINVAL);
125124
}
126-
value = readl(cpg->reg + cr);
125+
value = readl(base + cr);
127126
switch ((value >> 5) & 7) {
128127
case 0:
129128
parent_name = "main";
@@ -159,7 +158,7 @@ r8a73a4_cpg_register_clock(struct device_node *np, struct r8a73a4_cpg *cpg,
159158
shift = 0;
160159
}
161160
div *= 32;
162-
mult = 0x20 - ((readl(cpg->reg + CPG_FRQCRC) >> shift) & 0x1f);
161+
mult = 0x20 - ((readl(base + CPG_FRQCRC) >> shift) & 0x1f);
163162
} else {
164163
struct div4_clk *c;
165164

@@ -181,14 +180,15 @@ r8a73a4_cpg_register_clock(struct device_node *np, struct r8a73a4_cpg *cpg,
181180
mult, div);
182181
} else {
183182
return clk_register_divider_table(NULL, name, parent_name, 0,
184-
cpg->reg + reg, shift, 4, 0,
183+
base + reg, shift, 4, 0,
185184
table, &cpg->lock);
186185
}
187186
}
188187

189188
static void __init r8a73a4_cpg_clocks_init(struct device_node *np)
190189
{
191190
struct r8a73a4_cpg *cpg;
191+
void __iomem *base;
192192
struct clk **clks;
193193
unsigned int i;
194194
int num_clks;
@@ -213,8 +213,8 @@ static void __init r8a73a4_cpg_clocks_init(struct device_node *np)
213213
cpg->data.clks = clks;
214214
cpg->data.clk_num = num_clks;
215215

216-
cpg->reg = of_iomap(np, 0);
217-
if (WARN_ON(cpg->reg == NULL))
216+
base = of_iomap(np, 0);
217+
if (WARN_ON(base == NULL))
218218
return;
219219

220220
for (i = 0; i < num_clks; ++i) {
@@ -224,7 +224,7 @@ static void __init r8a73a4_cpg_clocks_init(struct device_node *np)
224224
of_property_read_string_index(np, "clock-output-names", i,
225225
&name);
226226

227-
clk = r8a73a4_cpg_register_clock(np, cpg, name);
227+
clk = r8a73a4_cpg_register_clock(np, cpg, base, name);
228228
if (IS_ERR(clk))
229229
pr_err("%s: failed to register %pOFn %s clock (%ld)\n",
230230
__func__, np, name, PTR_ERR(clk));

0 commit comments

Comments
 (0)