Skip to content

Commit 0e8e6b5

Browse files
AngeloGioacchino Del RegnoUlf Hansson
authored andcommitted
pmdomain: mediatek: Move ctl sequences out of power_on/off functions
In preparation to support power domains of new SoCs and the modem power domains for both new and already supported chips, move the generic control power sequences out of the scpsys_power_on() and scpsys_power_off() and put them in new scpsys_ctl_pwrseq_on(), scpsys_ctl_pewseq_off() functions. Reviewed-by: Nícolas F. R. A. Prado <nfraprado@collabora.com> Signed-off-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> Link: https://lore.kernel.org/r/20250805074746.29457-7-angelogioacchino.delregno@collabora.com Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
1 parent ad4bbdc commit 0e8e6b5

1 file changed

Lines changed: 38 additions & 19 deletions

File tree

drivers/pmdomain/mediatek/mtk-pm-domains.c

Lines changed: 38 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -244,11 +244,45 @@ static int scpsys_regulator_disable(struct regulator *supply)
244244
return supply ? regulator_disable(supply) : 0;
245245
}
246246

247+
static int scpsys_ctl_pwrseq_on(struct scpsys_domain *pd)
248+
{
249+
struct scpsys *scpsys = pd->scpsys;
250+
bool tmp;
251+
int ret;
252+
253+
/* subsys power on */
254+
regmap_set_bits(scpsys->base, pd->data->ctl_offs, PWR_ON_BIT);
255+
regmap_set_bits(scpsys->base, pd->data->ctl_offs, PWR_ON_2ND_BIT);
256+
257+
/* wait until PWR_ACK = 1 */
258+
ret = readx_poll_timeout(scpsys_domain_is_on, pd, tmp, tmp, MTK_POLL_DELAY_US,
259+
MTK_POLL_TIMEOUT);
260+
if (ret < 0)
261+
return ret;
262+
263+
regmap_clear_bits(scpsys->base, pd->data->ctl_offs, PWR_CLK_DIS_BIT);
264+
regmap_clear_bits(scpsys->base, pd->data->ctl_offs, PWR_ISO_BIT);
265+
regmap_set_bits(scpsys->base, pd->data->ctl_offs, PWR_RST_B_BIT);
266+
267+
return 0;
268+
}
269+
270+
static void scpsys_ctl_pwrseq_off(struct scpsys_domain *pd)
271+
{
272+
struct scpsys *scpsys = pd->scpsys;
273+
274+
/* subsys power off */
275+
regmap_set_bits(scpsys->base, pd->data->ctl_offs, PWR_ISO_BIT);
276+
regmap_set_bits(scpsys->base, pd->data->ctl_offs, PWR_CLK_DIS_BIT);
277+
regmap_clear_bits(scpsys->base, pd->data->ctl_offs, PWR_RST_B_BIT);
278+
regmap_clear_bits(scpsys->base, pd->data->ctl_offs, PWR_ON_2ND_BIT);
279+
regmap_clear_bits(scpsys->base, pd->data->ctl_offs, PWR_ON_BIT);
280+
}
281+
247282
static int scpsys_power_on(struct generic_pm_domain *genpd)
248283
{
249284
struct scpsys_domain *pd = container_of(genpd, struct scpsys_domain, genpd);
250285
struct scpsys *scpsys = pd->scpsys;
251-
bool tmp;
252286
int ret;
253287

254288
ret = scpsys_regulator_enable(pd->supply);
@@ -263,20 +297,10 @@ static int scpsys_power_on(struct generic_pm_domain *genpd)
263297
regmap_clear_bits(scpsys->base, pd->data->ext_buck_iso_offs,
264298
pd->data->ext_buck_iso_mask);
265299

266-
/* subsys power on */
267-
regmap_set_bits(scpsys->base, pd->data->ctl_offs, PWR_ON_BIT);
268-
regmap_set_bits(scpsys->base, pd->data->ctl_offs, PWR_ON_2ND_BIT);
269-
270-
/* wait until PWR_ACK = 1 */
271-
ret = readx_poll_timeout(scpsys_domain_is_on, pd, tmp, tmp, MTK_POLL_DELAY_US,
272-
MTK_POLL_TIMEOUT);
273-
if (ret < 0)
300+
ret = scpsys_ctl_pwrseq_on(pd);
301+
if (ret)
274302
goto err_pwr_ack;
275303

276-
regmap_clear_bits(scpsys->base, pd->data->ctl_offs, PWR_CLK_DIS_BIT);
277-
regmap_clear_bits(scpsys->base, pd->data->ctl_offs, PWR_ISO_BIT);
278-
regmap_set_bits(scpsys->base, pd->data->ctl_offs, PWR_RST_B_BIT);
279-
280304
/*
281305
* In few Mediatek platforms(e.g. MT6779), the bus protect policy is
282306
* stricter, which leads to bus protect release must be prior to bus
@@ -342,12 +366,7 @@ static int scpsys_power_off(struct generic_pm_domain *genpd)
342366

343367
clk_bulk_disable_unprepare(pd->num_subsys_clks, pd->subsys_clks);
344368

345-
/* subsys power off */
346-
regmap_set_bits(scpsys->base, pd->data->ctl_offs, PWR_ISO_BIT);
347-
regmap_set_bits(scpsys->base, pd->data->ctl_offs, PWR_CLK_DIS_BIT);
348-
regmap_clear_bits(scpsys->base, pd->data->ctl_offs, PWR_RST_B_BIT);
349-
regmap_clear_bits(scpsys->base, pd->data->ctl_offs, PWR_ON_2ND_BIT);
350-
regmap_clear_bits(scpsys->base, pd->data->ctl_offs, PWR_ON_BIT);
369+
scpsys_ctl_pwrseq_off(pd);
351370

352371
/* wait until PWR_ACK = 0 */
353372
ret = readx_poll_timeout(scpsys_domain_is_on, pd, tmp, !tmp, MTK_POLL_DELAY_US,

0 commit comments

Comments
 (0)