Skip to content

Commit ce5e839

Browse files
geertustorulf
authored andcommitted
pmdomain: renesas: rcar-sysc: Absorb rcar_sysc_ch into rcar_sysc_pd
Until commit 7e8a50d ("soc: renesas: rcar-sysc: Drop legacy handling") in v4.19, the rcar_sysc_ch structure was part of the API for legacy board code not yet using DT. Since then, there is no longer a reason to keep it as a separate structure. Moreover, a future quirk handling will need access to the rcar_sysc_pd structure's flags member in rcar_sysc_pwr_on_off(). Hence absorb the rcar_sysc_ch structure into the rcar_sysc_pd structure, and pass around the latter instead of the former. Signed-off-by: Geert Uytterhoeven <[email protected]> Reviewed-by: Kuninori Morimoto <[email protected]> Link: https://lore.kernel.org/r/672805a8c52ce63200e342212bbe6f84a445397b.1713348705.git.geert+renesas@glider.be Signed-off-by: Ulf Hansson <[email protected]>
1 parent dff14af commit ce5e839

File tree

1 file changed

+24
-30
lines changed

1 file changed

+24
-30
lines changed

drivers/pmdomain/renesas/rcar-sysc.c

Lines changed: 24 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -56,17 +56,20 @@
5656

5757
#define RCAR_PD_ALWAYS_ON 32 /* Always-on power area */
5858

59-
struct rcar_sysc_ch {
59+
struct rcar_sysc_pd {
60+
struct generic_pm_domain genpd;
6061
u16 chan_offs;
6162
u8 chan_bit;
6263
u8 isr_bit;
64+
unsigned int flags;
65+
char name[];
6366
};
6467

6568
static void __iomem *rcar_sysc_base;
6669
static DEFINE_SPINLOCK(rcar_sysc_lock); /* SMP CPUs + I/O devices */
6770
static u32 rcar_sysc_extmask_offs, rcar_sysc_extmask_val;
6871

69-
static int rcar_sysc_pwr_on_off(const struct rcar_sysc_ch *sysc_ch, bool on)
72+
static int rcar_sysc_pwr_on_off(const struct rcar_sysc_pd *pd, bool on)
7073
{
7174
unsigned int sr_bit, reg_offs;
7275
u32 val;
@@ -88,16 +91,15 @@ static int rcar_sysc_pwr_on_off(const struct rcar_sysc_ch *sysc_ch, bool on)
8891
return -EAGAIN;
8992

9093
/* Submit power shutoff or power resume request */
91-
iowrite32(BIT(sysc_ch->chan_bit),
92-
rcar_sysc_base + sysc_ch->chan_offs + reg_offs);
94+
iowrite32(BIT(pd->chan_bit), rcar_sysc_base + pd->chan_offs + reg_offs);
9395

9496
return 0;
9597
}
9698

97-
static int rcar_sysc_power(const struct rcar_sysc_ch *sysc_ch, bool on)
99+
static int rcar_sysc_power(const struct rcar_sysc_pd *pd, bool on)
98100
{
99-
unsigned int isr_mask = BIT(sysc_ch->isr_bit);
100-
unsigned int chan_mask = BIT(sysc_ch->chan_bit);
101+
unsigned int isr_mask = BIT(pd->isr_bit);
102+
unsigned int chan_mask = BIT(pd->chan_bit);
101103
unsigned int status, k;
102104
unsigned long flags;
103105
int ret;
@@ -125,12 +127,11 @@ static int rcar_sysc_power(const struct rcar_sysc_ch *sysc_ch, bool on)
125127

126128
/* Submit power shutoff or resume request until it was accepted */
127129
for (k = 0; k < PWRER_RETRIES; k++) {
128-
ret = rcar_sysc_pwr_on_off(sysc_ch, on);
130+
ret = rcar_sysc_pwr_on_off(pd, on);
129131
if (ret)
130132
goto out;
131133

132-
status = ioread32(rcar_sysc_base +
133-
sysc_ch->chan_offs + PWRER_OFFS);
134+
status = ioread32(rcar_sysc_base + pd->chan_offs + PWRER_OFFS);
134135
if (!(status & chan_mask))
135136
break;
136137

@@ -158,28 +159,21 @@ static int rcar_sysc_power(const struct rcar_sysc_ch *sysc_ch, bool on)
158159
spin_unlock_irqrestore(&rcar_sysc_lock, flags);
159160

160161
pr_debug("sysc power %s domain %d: %08x -> %d\n", on ? "on" : "off",
161-
sysc_ch->isr_bit, ioread32(rcar_sysc_base + SYSCISR), ret);
162+
pd->isr_bit, ioread32(rcar_sysc_base + SYSCISR), ret);
162163
return ret;
163164
}
164165

165-
static bool rcar_sysc_power_is_off(const struct rcar_sysc_ch *sysc_ch)
166+
static bool rcar_sysc_power_is_off(const struct rcar_sysc_pd *pd)
166167
{
167168
unsigned int st;
168169

169-
st = ioread32(rcar_sysc_base + sysc_ch->chan_offs + PWRSR_OFFS);
170-
if (st & BIT(sysc_ch->chan_bit))
170+
st = ioread32(rcar_sysc_base + pd->chan_offs + PWRSR_OFFS);
171+
if (st & BIT(pd->chan_bit))
171172
return true;
172173

173174
return false;
174175
}
175176

176-
struct rcar_sysc_pd {
177-
struct generic_pm_domain genpd;
178-
struct rcar_sysc_ch ch;
179-
unsigned int flags;
180-
char name[];
181-
};
182-
183177
static inline struct rcar_sysc_pd *to_rcar_pd(struct generic_pm_domain *d)
184178
{
185179
return container_of(d, struct rcar_sysc_pd, genpd);
@@ -190,15 +184,15 @@ static int rcar_sysc_pd_power_off(struct generic_pm_domain *genpd)
190184
struct rcar_sysc_pd *pd = to_rcar_pd(genpd);
191185

192186
pr_debug("%s: %s\n", __func__, genpd->name);
193-
return rcar_sysc_power(&pd->ch, false);
187+
return rcar_sysc_power(pd, false);
194188
}
195189

196190
static int rcar_sysc_pd_power_on(struct generic_pm_domain *genpd)
197191
{
198192
struct rcar_sysc_pd *pd = to_rcar_pd(genpd);
199193

200194
pr_debug("%s: %s\n", __func__, genpd->name);
201-
return rcar_sysc_power(&pd->ch, true);
195+
return rcar_sysc_power(pd, true);
202196
}
203197

204198
static bool has_cpg_mstp;
@@ -252,12 +246,12 @@ static int __init rcar_sysc_pd_setup(struct rcar_sysc_pd *pd)
252246
goto finalize;
253247
}
254248

255-
if (!rcar_sysc_power_is_off(&pd->ch)) {
249+
if (!rcar_sysc_power_is_off(pd)) {
256250
pr_debug("%s: %s is already powered\n", __func__, genpd->name);
257251
goto finalize;
258252
}
259253

260-
rcar_sysc_power(&pd->ch, true);
254+
rcar_sysc_power(pd, true);
261255

262256
finalize:
263257
error = pm_genpd_init(genpd, &simple_qos_governor, false);
@@ -412,9 +406,9 @@ static int __init rcar_sysc_pd_init(void)
412406

413407
memcpy(pd->name, area->name, n);
414408
pd->genpd.name = pd->name;
415-
pd->ch.chan_offs = area->chan_offs;
416-
pd->ch.chan_bit = area->chan_bit;
417-
pd->ch.isr_bit = area->isr_bit;
409+
pd->chan_offs = area->chan_offs;
410+
pd->chan_bit = area->chan_bit;
411+
pd->isr_bit = area->isr_bit;
418412
pd->flags = area->flags;
419413

420414
error = rcar_sysc_pd_setup(pd);
@@ -473,10 +467,10 @@ static int rcar_sysc_power_cpu(unsigned int idx, bool on)
473467
continue;
474468

475469
pd = to_rcar_pd(genpd);
476-
if (!(pd->flags & PD_CPU) || pd->ch.chan_bit != idx)
470+
if (!(pd->flags & PD_CPU) || pd->chan_bit != idx)
477471
continue;
478472

479-
return rcar_sysc_power(&pd->ch, on);
473+
return rcar_sysc_power(pd, on);
480474
}
481475

482476
return -ENOENT;

0 commit comments

Comments
 (0)