Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

pmdomain: mediatek: Handle SoCs with inverted SRAM power-down bits

Some SoCs, and even some subsystems in the same SoC, may have the
logic for SRAM power-down inverted, as in, setting the bit means
"power down" and unsetting means "power up": this is because some
hardware subsystems use this as a power-lock indication and some
use this as a power down one (for example, usually, the modem ss
has it inverted!).

In preparation for adding support for power domains with inverted
SRAM_PDN bits, add a new MTK_SCPD_SRAM_PDN_INVERTED flag and check
for it in scpsys_sram_enable() and scpsys_sram_disable().

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-6-angelogioacchino.delregno@collabora.com
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>

authored by

AngeloGioacchino Del Regno and committed by
Ulf Hansson
ad4bbdc5 c29345fa

+21 -7
+20 -7
drivers/pmdomain/mediatek/mtk-pm-domains.c
··· 79 79 80 80 static int scpsys_sram_enable(struct scpsys_domain *pd) 81 81 { 82 - u32 pdn_ack = pd->data->sram_pdn_ack_bits; 82 + u32 expected_ack, pdn_ack = pd->data->sram_pdn_ack_bits; 83 83 struct scpsys *scpsys = pd->scpsys; 84 84 unsigned int tmp; 85 85 int ret; 86 86 87 - regmap_clear_bits(scpsys->base, pd->data->ctl_offs, pd->data->sram_pdn_bits); 87 + if (MTK_SCPD_CAPS(pd, MTK_SCPD_SRAM_PDN_INVERTED)) { 88 + regmap_set_bits(scpsys->base, pd->data->ctl_offs, pd->data->sram_pdn_bits); 89 + expected_ack = pdn_ack; 90 + } else { 91 + regmap_clear_bits(scpsys->base, pd->data->ctl_offs, pd->data->sram_pdn_bits); 92 + expected_ack = 0; 93 + } 88 94 89 95 /* Either wait until SRAM_PDN_ACK all 1 or 0 */ 90 96 ret = regmap_read_poll_timeout(scpsys->base, pd->data->ctl_offs, tmp, 91 - (tmp & pdn_ack) == 0, MTK_POLL_DELAY_US, MTK_POLL_TIMEOUT); 97 + (tmp & pdn_ack) == expected_ack, 98 + MTK_POLL_DELAY_US, MTK_POLL_TIMEOUT); 92 99 if (ret < 0) 93 100 return ret; 94 101 ··· 110 103 111 104 static int scpsys_sram_disable(struct scpsys_domain *pd) 112 105 { 113 - u32 pdn_ack = pd->data->sram_pdn_ack_bits; 106 + u32 expected_ack, pdn_ack = pd->data->sram_pdn_ack_bits; 114 107 struct scpsys *scpsys = pd->scpsys; 115 108 unsigned int tmp; 116 109 ··· 120 113 regmap_clear_bits(scpsys->base, pd->data->ctl_offs, PWR_SRAM_ISOINT_B_BIT); 121 114 } 122 115 123 - regmap_set_bits(scpsys->base, pd->data->ctl_offs, pd->data->sram_pdn_bits); 116 + if (MTK_SCPD_CAPS(pd, MTK_SCPD_SRAM_PDN_INVERTED)) { 117 + regmap_clear_bits(scpsys->base, pd->data->ctl_offs, pd->data->sram_pdn_bits); 118 + expected_ack = 0; 119 + } else { 120 + regmap_set_bits(scpsys->base, pd->data->ctl_offs, pd->data->sram_pdn_bits); 121 + expected_ack = pdn_ack; 122 + } 124 123 125 124 /* Either wait until SRAM_PDN_ACK all 1 or 0 */ 126 125 return regmap_read_poll_timeout(scpsys->base, pd->data->ctl_offs, tmp, 127 - (tmp & pdn_ack) == pdn_ack, MTK_POLL_DELAY_US, 128 - MTK_POLL_TIMEOUT); 126 + (tmp & pdn_ack) == expected_ack, 127 + MTK_POLL_DELAY_US, MTK_POLL_TIMEOUT); 129 128 } 130 129 131 130 static struct regmap *scpsys_bus_protect_get_regmap(struct scpsys_domain *pd,
+1
drivers/pmdomain/mediatek/mtk-pm-domains.h
··· 13 13 #define MTK_SCPD_EXT_BUCK_ISO BIT(6) 14 14 #define MTK_SCPD_HAS_INFRA_NAO BIT(7) 15 15 #define MTK_SCPD_STRICT_BUS_PROTECTION BIT(8) 16 + #define MTK_SCPD_SRAM_PDN_INVERTED BIT(9) 16 17 #define MTK_SCPD_CAPS(_scpd, _x) ((_scpd)->data->caps & (_x)) 17 18 18 19 #define SPM_VDE_PWR_CON 0x0210