Skip to content

Commit 16d861d

Browse files
AngeloGioacchino Del RegnoUlf Hansson
authored andcommitted
pmdomain: mediatek: Add support for modem power sequences
Add support for the modem power domains by adding its specific power sequence in functions scpsys_modem_pwrseq_{on,off}() and call them if the flag MTK_SCPD_MODEM_PWRSEQ is present. While at it, since some SoC models need to skip setting/clearing the PWR_RST_B_BIT, also add a MTK_SCPD_SKIP_RESET_B flag for that. 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-8-angelogioacchino.delregno@collabora.com Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
1 parent 0e8e6b5 commit 16d861d

2 files changed

Lines changed: 41 additions & 2 deletions

File tree

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

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,36 @@ static void scpsys_ctl_pwrseq_off(struct scpsys_domain *pd)
279279
regmap_clear_bits(scpsys->base, pd->data->ctl_offs, PWR_ON_BIT);
280280
}
281281

282+
static int scpsys_modem_pwrseq_on(struct scpsys_domain *pd)
283+
{
284+
struct scpsys *scpsys = pd->scpsys;
285+
bool tmp;
286+
int ret;
287+
288+
if (!MTK_SCPD_CAPS(pd, MTK_SCPD_SKIP_RESET_B))
289+
regmap_set_bits(scpsys->base, pd->data->ctl_offs, PWR_RST_B_BIT);
290+
291+
regmap_set_bits(scpsys->base, pd->data->ctl_offs, PWR_ON_BIT);
292+
293+
/* wait until PWR_ACK = 1 */
294+
ret = readx_poll_timeout(scpsys_domain_is_on, pd, tmp, tmp, MTK_POLL_DELAY_US,
295+
MTK_POLL_TIMEOUT);
296+
if (ret < 0)
297+
return ret;
298+
299+
return 0;
300+
}
301+
302+
static void scpsys_modem_pwrseq_off(struct scpsys_domain *pd)
303+
{
304+
struct scpsys *scpsys = pd->scpsys;
305+
306+
regmap_clear_bits(scpsys->base, pd->data->ctl_offs, PWR_ON_BIT);
307+
308+
if (!MTK_SCPD_CAPS(pd, MTK_SCPD_SKIP_RESET_B))
309+
regmap_clear_bits(scpsys->base, pd->data->ctl_offs, PWR_RST_B_BIT);
310+
}
311+
282312
static int scpsys_power_on(struct generic_pm_domain *genpd)
283313
{
284314
struct scpsys_domain *pd = container_of(genpd, struct scpsys_domain, genpd);
@@ -297,7 +327,11 @@ static int scpsys_power_on(struct generic_pm_domain *genpd)
297327
regmap_clear_bits(scpsys->base, pd->data->ext_buck_iso_offs,
298328
pd->data->ext_buck_iso_mask);
299329

300-
ret = scpsys_ctl_pwrseq_on(pd);
330+
if (MTK_SCPD_CAPS(pd, MTK_SCPD_MODEM_PWRSEQ))
331+
ret = scpsys_modem_pwrseq_on(pd);
332+
else
333+
ret = scpsys_ctl_pwrseq_on(pd);
334+
301335
if (ret)
302336
goto err_pwr_ack;
303337

@@ -366,7 +400,10 @@ static int scpsys_power_off(struct generic_pm_domain *genpd)
366400

367401
clk_bulk_disable_unprepare(pd->num_subsys_clks, pd->subsys_clks);
368402

369-
scpsys_ctl_pwrseq_off(pd);
403+
if (MTK_SCPD_CAPS(pd, MTK_SCPD_MODEM_PWRSEQ))
404+
scpsys_modem_pwrseq_off(pd);
405+
else
406+
scpsys_ctl_pwrseq_off(pd);
370407

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

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
#define MTK_SCPD_HAS_INFRA_NAO BIT(7)
1515
#define MTK_SCPD_STRICT_BUS_PROTECTION BIT(8)
1616
#define MTK_SCPD_SRAM_PDN_INVERTED BIT(9)
17+
#define MTK_SCPD_MODEM_PWRSEQ BIT(10)
18+
#define MTK_SCPD_SKIP_RESET_B BIT(11)
1719
#define MTK_SCPD_CAPS(_scpd, _x) ((_scpd)->data->caps & (_x))
1820

1921
#define SPM_VDE_PWR_CON 0x0210

0 commit comments

Comments
 (0)