Skip to content

Commit d7a919c

Browse files
marcanjannau
authored andcommitted
soc: apple: pmgr: Add externally-clocked property
MCA power states require an external clock to be provided. If they are powered on while this clock is not active, the power state will only go into the "clock gated" state. This is effectively working as intended, so add a property that instructs the pwrstate driver to consider the PS to be successfully powered on when it reaches the clock gated state. Signed-off-by: Hector Martin <marcan@marcan.st>
1 parent 02c4e18 commit d7a919c

1 file changed

Lines changed: 25 additions & 10 deletions

File tree

drivers/pmdomain/apple/pmgr-pwrstate.c

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ struct apple_pmgr_ps {
4747
u32 min_state;
4848
bool force_disable;
4949
bool force_reset;
50+
bool externally_clocked;
5051
};
5152

5253
#define genpd_to_apple_pmgr_ps(_genpd) container_of(_genpd, struct apple_pmgr_ps, genpd)
@@ -96,10 +97,21 @@ static int apple_pmgr_ps_set(struct generic_pm_domain *genpd, u32 pstate, bool a
9697

9798
regmap_write(ps->regmap, ps->offset, reg);
9899

99-
ret = regmap_read_poll_timeout_atomic(
100-
ps->regmap, ps->offset, cur,
101-
FIELD_GET(APPLE_PMGR_PS_ACTUAL, cur) == pstate, 1,
102-
APPLE_PMGR_PS_SET_TIMEOUT);
100+
if (ps->externally_clocked && pstate == APPLE_PMGR_PS_ACTIVE) {
101+
/*
102+
* If this clock domain requires an external clock, then
103+
* consider the "clock gated" state to be good enough.
104+
*/
105+
ret = regmap_read_poll_timeout_atomic(
106+
ps->regmap, ps->offset, cur,
107+
FIELD_GET(APPLE_PMGR_PS_ACTUAL, cur) >= APPLE_PMGR_PS_CLKGATE, 1,
108+
APPLE_PMGR_PS_SET_TIMEOUT);
109+
} else {
110+
ret = regmap_read_poll_timeout_atomic(
111+
ps->regmap, ps->offset, cur,
112+
FIELD_GET(APPLE_PMGR_PS_ACTUAL, cur) == pstate, 1,
113+
APPLE_PMGR_PS_SET_TIMEOUT);
114+
}
103115

104116
if (ret < 0)
105117
dev_err(ps->dev, "PS %s: Failed to reach power state 0x%x (now: 0x%x)\n",
@@ -259,6 +271,15 @@ static int apple_pmgr_ps_probe(struct platform_device *pdev)
259271
regmap_update_bits(regmap, ps->offset, APPLE_PMGR_FLAGS | APPLE_PMGR_PS_MIN,
260272
FIELD_PREP(APPLE_PMGR_PS_MIN, ps->min_state));
261273

274+
if (of_property_read_bool(node, "apple,force-disable"))
275+
ps->force_disable = true;
276+
277+
if (of_property_read_bool(node, "apple,force-reset"))
278+
ps->force_reset = true;
279+
280+
if (of_property_read_bool(node, "apple,externally-clocked"))
281+
ps->externally_clocked = true;
282+
262283
active = apple_pmgr_ps_is_active(ps);
263284
if (of_property_read_bool(node, "apple,always-on")) {
264285
ps->genpd.flags |= GENPD_FLAG_ALWAYS_ON;
@@ -269,12 +290,6 @@ static int apple_pmgr_ps_probe(struct platform_device *pdev)
269290
}
270291
}
271292

272-
if (of_property_read_bool(node, "apple,force-disable"))
273-
ps->force_disable = true;
274-
275-
if (of_property_read_bool(node, "apple,force-reset"))
276-
ps->force_reset = true;
277-
278293
/* Turn on auto-PM if the domain is already on */
279294
if (active)
280295
regmap_update_bits(regmap, ps->offset, APPLE_PMGR_FLAGS | APPLE_PMGR_AUTO_ENABLE,

0 commit comments

Comments
 (0)