soc: mediatek: pm-domains: solve power domain glitch issue
Subsystems (2)
PATCH 1/2 soc: mediatek: pm-domains: add smi_larb_reset function when power on
In reply to yu-chang.leeThis patch avoid mtcmos power glitch from happening by set and clear smi larb reset.
--- drivers/pmdomain/mediatek/mt8188-pm-domains.h | 28 +++++++++ drivers/pmdomain/mediatek/mtk-pm-domains.c | 59 +++++++++++++++++++ drivers/pmdomain/mediatek/mtk-pm-domains.h | 12 ++++ 3 files changed, 99 insertions(+)
drivers/pmdomain/mediatek/mt8188-pm-domains.h +28 -0
@@ -573,6 +573,18 @@ static const struct scpsys_domain_data scpsys_domain_data_mt8188[] = { .pwr_sta2nd_offs = 0x170, .sram_pdn_bits = BIT(8), .sram_pdn_ack_bits = BIT(12), + .reset_smi = { +SMI_RESET_WR (MT8188_SMI_LARB10_RESET , +MT8188_SMI_LARB10_RESET_ADDR ), +SMI_RESET_WR (MT8188_SMI_LARB11A_RESET , +MT8188_SMI_LARB11A_RESET_ADDR ), +SMI_RESET_WR (MT8188_SMI_LARB11C_RESET , +MT8188_SMI_LARB11C_RESET_ADDR ), +SMI_RESET_WR (MT8188_SMI_LARB11B_RESET , +MT8188_SMI_LARB11B_RESET_ADDR ), +SMI_RESET_WR (MT8188_SMI_LARB15_RESET , + MT8188_SMI_LARB15_RESET_ADDR), + }, .caps = MTK_SCPD_KEEP_DEFAULT_OFF, }, [MT8188_POWER_DOMAIN_IPE] = {
@@ -583,6 +595,10 @@ static const struct scpsys_domain_data scpsys_domain_data_mt8188[] = { .pwr_sta2nd_offs = 0x170, .sram_pdn_bits = BIT(8), .sram_pdn_ack_bits = BIT(12), + .reset_smi = { +SMI_RESET_WR (MT8188_SMI_LARB12_RESET , + MT8188_SMI_LARB12_RESET_ADDR), + }, .caps = MTK_SCPD_KEEP_DEFAULT_OFF, }, [MT8188_POWER_DOMAIN_CAM_VCORE] = {
@@ -660,6 +676,12 @@ static const struct scpsys_domain_data scpsys_domain_data_mt8188[] = { .pwr_sta2nd_offs = 0x170, .sram_pdn_bits = BIT(8), .sram_pdn_ack_bits = BIT(12), + .reset_smi = { +SMI_RESET_WR (MT8188_SMI_LARB16A_RESET , +MT8188_SMI_LARB16A_RESET_ADDR ), +SMI_RESET_WR (MT8188_SMI_LARB17A_RESET , + MT8188_SMI_LARB17A_RESET_ADDR), + }, .caps = MTK_SCPD_KEEP_DEFAULT_OFF, }, [MT8188_POWER_DOMAIN_CAM_SUBB] = {
@@ -670,6 +692,12 @@ static const struct scpsys_domain_data scpsys_domain_data_mt8188[] = { .pwr_sta2nd_offs = 0x170, .sram_pdn_bits = BIT(8), .sram_pdn_ack_bits = BIT(12), + .reset_smi = { +SMI_RESET_WR (MT8188_SMI_LARB16B_RESET , +MT8188_SMI_LARB16B_RESET_ADDR ), +SMI_RESET_WR (MT8188_SMI_LARB17B_RESET , + MT8188_SMI_LARB17B_RESET_ADDR), + }, .caps = MTK_SCPD_KEEP_DEFAULT_OFF, }, };
drivers/pmdomain/mediatek/mtk-pm-domains.c +59 -0
89 lines not on this page · raw message
drivers/pmdomain/mediatek/mtk-pm-domains.h +12 -0
@@ -43,6 +43,7 @@#define PWR_STATUS_USB BIT(25)#define SPM_MAX_BUS_PROT_DATA 6 +#define SPM_MAX_SMI_RESET_DATA 6enum scpsys_bus_prot_flags {BUS_PROT_REG_UPDATE =BIT (1 ),
@@ -79,6 +80,16 @@ enum scpsys_bus_prot_flags { INFRA_TOPAXI_PROTECTEN, \ INFRA_TOPAXI_PROTECTSTA1) +#define SMI_RESET_WR (_mask, _addr) { \ + .smi_reset_mask = (_mask), \ + .smi_reset_addr = _addr, \ + } + +struct smi_reset_data { +u32 smi_reset_mask; +u32 smi_reset_addr; +}; +struct scpsys_bus_prot_data {u32 bus_prot_set_clr_mask;u32 bus_prot_set;
@@ -110,6 +121,7 @@ struct scpsys_domain_data {u32 ext_buck_iso_mask;u16 caps;const struct scpsys_bus_prot_data bp_cfg[SPM_MAX_BUS_PROT_DATA ]; +const struct smi_reset_data reset_smi[SPM_MAX_SMI_RESET_DATA ];int pwr_sta_offs;int pwr_sta2nd_offs; };
Signature · 1 line
2.18.0
cover soc: mediatek: pm-domains: solve power domain glitch issue
Hi,
This series aims to solve power-off failures and occasional SMI hang issues that occur during camera stress tests. The issue arises because, when MTCMOS powers on or off, signal glitches are sometimes produced. This is fairly normal, but the software must address it to avoid mistaking the glitch for a transaction signal.
The solutions in these patches can be summarized as follows:
1. Disable the sub-common port after turning off the Larb CG and before turning off the Larb MTCMOS.
2. Use CLAMP to disable/enable the SMI common port.
3. Implement an AXI reset.
For previous discussion on the direction of the code modifications, please refer
to: https://lore.kernel.org/linux-arm-kernel/[email protected]/
yu-chang.lee (2):
soc: mediatek: pm-domains: add smi_larb_reset function when power on
soc: mediatek: pm-domains: support smi clamp protection
drivers/pmdomain/mediatek/mt8188-pm-domains.h | 69 +++++- drivers/pmdomain/mediatek/mtk-pm-domains.c | 206 +++++++++++++++--- drivers/pmdomain/mediatek/mtk-pm-domains.h | 13 ++ 3 files changed, 255 insertions(+), 33 deletions(-)
Signature · 1 line
2.18.0
PATCH 2/2 soc: mediatek: pm-domains: support smi clamp protection
In order to avoid power glitch, this patch use smi clamp to disable/enable smi common port.
--- drivers/pmdomain/mediatek/mt8188-pm-domains.h | 41 ++++- drivers/pmdomain/mediatek/mtk-pm-domains.c | 147 ++++++++++++++---- drivers/pmdomain/mediatek/mtk-pm-domains.h | 1 + 3 files changed, 156 insertions(+), 33 deletions(-)
drivers/pmdomain/mediatek/mt8188-pm-domains.h +37 -4
@@ -573,6 +573,18 @@ static const struct scpsys_domain_data scpsys_domain_data_mt8188[] = { .pwr_sta2nd_offs = 0x170, .sram_pdn_bits = BIT(8), .sram_pdn_ack_bits = BIT(12), + .bp_cfg = { +BUS_PROT_WR (SMI , +MT8188_SMI_COMMON_SMI_CLAMP_DIP_TO_VDO0 , +MT8188_SMI_COMMON_CLAMP_EN_SET , +MT8188_SMI_COMMON_CLAMP_EN_CLR , +MT8188_SMI_COMMON_CLAMP_EN_STA ), +BUS_PROT_WR (SMI , +MT8188_SMI_COMMON_SMI_CLAMP_DIP_TO_VPP1 , +MT8188_SMI_COMMON_CLAMP_EN_SET , +MT8188_SMI_COMMON_CLAMP_EN_CLR , + MT8188_SMI_COMMON_CLAMP_EN_STA), + }, .reset_smi = {SMI_RESET_WR (MT8188_SMI_LARB10_RESET , MT8188_SMI_LARB10_RESET_ADDR),
@@ -585,7 +597,7 @@ static const struct scpsys_domain_data scpsys_domain_data_mt8188[] = {SMI_RESET_WR (MT8188_SMI_LARB15_RESET , MT8188_SMI_LARB15_RESET_ADDR), }, - .caps = MTK_SCPD_KEEP_DEFAULT_OFF, + .caps = MTK_SCPD_KEEP_DEFAULT_OFF | MTK_SCPD_CLAMP_PROTECTION, }, [MT8188_POWER_DOMAIN_IPE] = { .name = "ipe",
@@ -595,11 +607,18 @@ static const struct scpsys_domain_data scpsys_domain_data_mt8188[] = { .pwr_sta2nd_offs = 0x170, .sram_pdn_bits = BIT(8), .sram_pdn_ack_bits = BIT(12), + .bp_cfg = { +BUS_PROT_WR (SMI , +MT8188_SMI_COMMON_SMI_CLAMP_IPE_TO_VPP1 , +MT8188_SMI_COMMON_CLAMP_EN_SET , +MT8188_SMI_COMMON_CLAMP_EN_CLR , + MT8188_SMI_COMMON_CLAMP_EN_STA), + }, .reset_smi = {SMI_RESET_WR (MT8188_SMI_LARB12_RESET , MT8188_SMI_LARB12_RESET_ADDR), }, - .caps = MTK_SCPD_KEEP_DEFAULT_OFF, + .caps = MTK_SCPD_KEEP_DEFAULT_OFF | MTK_SCPD_CLAMP_PROTECTION, }, [MT8188_POWER_DOMAIN_CAM_VCORE] = { .name = "cam_vcore",
@@ -676,13 +695,20 @@ static const struct scpsys_domain_data scpsys_domain_data_mt8188[] = { .pwr_sta2nd_offs = 0x170, .sram_pdn_bits = BIT(8), .sram_pdn_ack_bits = BIT(12), + .bp_cfg = { +BUS_PROT_WR (SMI , +MT8188_SMI_COMMON_SMI_CLAMP_IPE_TO_VPP1 , +MT8188_SMI_COMMON_CLAMP_EN_SET , +MT8188_SMI_COMMON_CLAMP_EN_CLR , + MT8188_SMI_COMMON_CLAMP_EN_STA), + }, .reset_smi = {SMI_RESET_WR (MT8188_SMI_LARB16A_RESET ,MT8188_SMI_LARB16A_RESET_ADDR ),SMI_RESET_WR (MT8188_SMI_LARB17A_RESET , MT8188_SMI_LARB17A_RESET_ADDR), }, - .caps = MTK_SCPD_KEEP_DEFAULT_OFF, + .caps = MTK_SCPD_KEEP_DEFAULT_OFF | MTK_SCPD_CLAMP_PROTECTION, }, [MT8188_POWER_DOMAIN_CAM_SUBB] = { .name = "cam_subb",
@@ -692,13 +718,20 @@ static const struct scpsys_domain_data scpsys_domain_data_mt8188[] = { .pwr_sta2nd_offs = 0x170, .sram_pdn_bits = BIT(8), .sram_pdn_ack_bits = BIT(12), + .bp_cfg = { +BUS_PROT_WR (SMI , +MT8188_SMI_COMMON_SMI_CLAMP_CAM_SUBB_TO_VDO0 , +MT8188_SMI_COMMON_CLAMP_EN_SET , +MT8188_SMI_COMMON_CLAMP_EN_CLR , + MT8188_SMI_COMMON_CLAMP_EN_STA), + }, .reset_smi = {SMI_RESET_WR (MT8188_SMI_LARB16B_RESET ,MT8188_SMI_LARB16B_RESET_ADDR ),SMI_RESET_WR (MT8188_SMI_LARB17B_RESET , MT8188_SMI_LARB17B_RESET_ADDR), }, - .caps = MTK_SCPD_KEEP_DEFAULT_OFF, + .caps = MTK_SCPD_KEEP_DEFAULT_OFF | MTK_SCPD_CLAMP_PROTECTION, }, };
drivers/pmdomain/mediatek/mtk-pm-domains.c +118 -29
240 lines not on this page · raw message
drivers/pmdomain/mediatek/mtk-pm-domains.h +1 -0
@@ -13,6 +13,7 @@#define MTK_SCPD_EXT_BUCK_ISO BIT(6)#define MTK_SCPD_HAS_INFRA_NAO BIT(7)#define MTK_SCPD_STRICT_BUS_PROTECTION BIT(8) +#define MTK_SCPD_CLAMP_PROTECTION BIT(9)#define MTK_SCPD_CAPS (_scpd, _x) ((_scpd)->data->caps & (_x))#define SPM_VDE_PWR_CON 0x0210
Signature · 1 line
2.18.0
AngeloGioacchino Del Regno
maintainerRe: [PATCH 1/2] soc: mediatek: pm-domains: add smi_larb_reset function when power on
In reply to yu-chang.leeIl 25/03/24 13:19, yu-chang.lee ha scritto:
Quoted 143 lines
This patch avoid mtcmos power glitch from happening by set and clear smi larb reset.
Signed-off-by yu-chang.lee <[email protected]>--- drivers/pmdomain/mediatek/mt8188-pm-domains.h | 28 +++++++++ drivers/pmdomain/mediatek/mtk-pm-domains.c | 59 +++++++++++++++++++ drivers/pmdomain/mediatek/mtk-pm-domains.h | 12 ++++ 3 files changed, 99 insertions(+)drivers/pmdomain/mediatek/mt8188-pm-domains.h +28
-0@@ -573,6 +573,18 @@ static const struct scpsys_domain_data scpsys_domain_data_mt8188[] = { .pwr_sta2nd_offs = 0x170, .sram_pdn_bits = BIT(8), .sram_pdn_ack_bits = BIT(12), + .reset_smi = { +SMI_RESET_WR (MT8188_SMI_LARB10_RESET , +MT8188_SMI_LARB10_RESET_ADDR ), +SMI_RESET_WR (MT8188_SMI_LARB11A_RESET , +MT8188_SMI_LARB11A_RESET_ADDR ), +SMI_RESET_WR (MT8188_SMI_LARB11C_RESET , +MT8188_SMI_LARB11C_RESET_ADDR ), +SMI_RESET_WR (MT8188_SMI_LARB11B_RESET , +MT8188_SMI_LARB11B_RESET_ADDR ), +SMI_RESET_WR (MT8188_SMI_LARB15_RESET , + MT8188_SMI_LARB15_RESET_ADDR), + }, .caps = MTK_SCPD_KEEP_DEFAULT_OFF, }, [MT8188_POWER_DOMAIN_IPE] = {@@ -583,6 +595,10 @@ static const struct scpsys_domain_data scpsys_domain_data_mt8188[] = { .pwr_sta2nd_offs = 0x170, .sram_pdn_bits = BIT(8), .sram_pdn_ack_bits = BIT(12), + .reset_smi = { +SMI_RESET_WR (MT8188_SMI_LARB12_RESET , + MT8188_SMI_LARB12_RESET_ADDR), + }, .caps = MTK_SCPD_KEEP_DEFAULT_OFF, }, [MT8188_POWER_DOMAIN_CAM_VCORE] = {@@ -660,6 +676,12 @@ static const struct scpsys_domain_data scpsys_domain_data_mt8188[] = { .pwr_sta2nd_offs = 0x170, .sram_pdn_bits = BIT(8), .sram_pdn_ack_bits = BIT(12), + .reset_smi = { +SMI_RESET_WR (MT8188_SMI_LARB16A_RESET , +MT8188_SMI_LARB16A_RESET_ADDR ), +SMI_RESET_WR (MT8188_SMI_LARB17A_RESET , + MT8188_SMI_LARB17A_RESET_ADDR), + }, .caps = MTK_SCPD_KEEP_DEFAULT_OFF, }, [MT8188_POWER_DOMAIN_CAM_SUBB] = {@@ -670,6 +692,12 @@ static const struct scpsys_domain_data scpsys_domain_data_mt8188[] = { .pwr_sta2nd_offs = 0x170, .sram_pdn_bits = BIT(8), .sram_pdn_ack_bits = BIT(12), + .reset_smi = { +SMI_RESET_WR (MT8188_SMI_LARB16B_RESET , +MT8188_SMI_LARB16B_RESET_ADDR ), +SMI_RESET_WR (MT8188_SMI_LARB17B_RESET , + MT8188_SMI_LARB17B_RESET_ADDR), + }, .caps = MTK_SCPD_KEEP_DEFAULT_OFF, }, };drivers/pmdomain/mediatek/mtk-pm-domains.c +40
-0@@ -48,6 +48,8 @@ struct scpsys_domain {struct regmap *infracfg_nao;struct regmap *infracfg;struct regmap *smi; +struct regmap **larb; +int num_larb;struct regulator *supply; };@@ -230,6 +232,39 @@ static int scpsys_regulator_disable(struct regulator *supply)return supply ?regulator_disable (supply) :0 ; } +static int _scpsys_smi_larb_reset (const struct smi_reset_data bpd, +struct regmap *regmap) +{ +int ret; +u32 mask = bpd.smi_reset_mask; + +if (!mask) +return 0 ; + + ret =regmap_set_bits (regmap, bpd.smi_reset_addr, mask); +if (ret) +return ret; + + ret =regmap_clear_bits (regmap, bpd.smi_reset_addr, mask); +if (ret) +return ret; + +return 0 ; +} + +static int scpsys_smi_larb_reset (struct scpsys_domain *pd) +{ +int ret, i; + +for (i =0 ; i < pd->num_larb; i++) { + ret =_scpsys_smi_larb_reset (pd->data->reset_smi[i], pd->larb[i]); +if (ret) +return ret; + } + +return 0 ; +} +static int scpsys_power_on (struct generic_pm_domain *genpd) { struct scpsys_domain *pd = container_of(genpd, struct scpsys_domain, genpd);@@ -279,6 +314,10 @@ static int scpsys_power_on(struct generic_pm_domain *genpd)if (ret <0 ) goto err_disable_subsys_clks; + ret =scpsys_smi_larb_reset (pd); +if (ret <0 ) + goto err_disable_subsys_clks; + ret =scpsys_bus_protect_disable (pd);if (ret <0 ) goto err_disable_sram;@@ -355,6 +394,7 @@ generic_pm_domain *scpsys_add_one_domain(struct scpsys *scpsys, struct device_nostruct scpsys_domain *pd;struct device_node *root_node = scpsys->dev->of_node;struct device_node *smi_node; +struct device_node *larb_node;struct property *prop;const char *clk_name;int i, ret, num_clks;
drivers/pmdomain/mediatek/mtk-pm-domains.c generic_pm_domain *scpsys_add_one_domain(struct scpsys *scpsys, struct device_no · line 461
Quoted 4 lines
drivers/pmdomain/mediatek/mtk-pm-domains.c +1
-0@@ -418,6 +458,25 @@ generic_pm_domain *scpsys_add_one_domain(struct scpsys *scpsys, struct device_noreturn ERR_CAST (pd->smi); } + pd->num_larb =of_count_phandle_with_args (node,"mediatek,larb" ,NULL );
You must update bindings/power/mediatek,power-controller.yaml to allow the mediatek,larb property in the power controller binding, otherwise this will be unusable. Please do so.
Cheers,
Angelo
AngeloGioacchino Del Regno
maintainerRe: [PATCH 2/2] soc: mediatek: pm-domains: support smi clamp protection
In reply to yu-chang.leeIl 25/03/24 13:19, yu-chang.lee ha scritto:
Quoted 241 lines
In order to avoid power glitch, this patch use smi clamp to disable/enable smi common port.
Signed-off-by yu-chang.lee <[email protected]>--- drivers/pmdomain/mediatek/mt8188-pm-domains.h | 41 ++++- drivers/pmdomain/mediatek/mtk-pm-domains.c | 147 ++++++++++++++---- drivers/pmdomain/mediatek/mtk-pm-domains.h | 1 + 3 files changed, 156 insertions(+), 33 deletions(-)drivers/pmdomain/mediatek/mt8188-pm-domains.h +37
-4@@ -573,6 +573,18 @@ static const struct scpsys_domain_data scpsys_domain_data_mt8188[] = { .pwr_sta2nd_offs = 0x170, .sram_pdn_bits = BIT(8), .sram_pdn_ack_bits = BIT(12), + .bp_cfg = { +BUS_PROT_WR (SMI , +MT8188_SMI_COMMON_SMI_CLAMP_DIP_TO_VDO0 , +MT8188_SMI_COMMON_CLAMP_EN_SET , +MT8188_SMI_COMMON_CLAMP_EN_CLR , +MT8188_SMI_COMMON_CLAMP_EN_STA ), +BUS_PROT_WR (SMI , +MT8188_SMI_COMMON_SMI_CLAMP_DIP_TO_VPP1 , +MT8188_SMI_COMMON_CLAMP_EN_SET , +MT8188_SMI_COMMON_CLAMP_EN_CLR , + MT8188_SMI_COMMON_CLAMP_EN_STA), + }, .reset_smi = {SMI_RESET_WR (MT8188_SMI_LARB10_RESET , MT8188_SMI_LARB10_RESET_ADDR),@@ -585,7 +597,7 @@ static const struct scpsys_domain_data scpsys_domain_data_mt8188[] = {SMI_RESET_WR (MT8188_SMI_LARB15_RESET ,MT8188_SMI_LARB15_RESET_ADDR ), }, - .caps = MTK_SCPD_KEEP_DEFAULT_OFF, + .caps = MTK_SCPD_KEEP_DEFAULT_OFF | MTK_SCPD_CLAMP_PROTECTION, }, [MT8188_POWER_DOMAIN_IPE] = { .name = "ipe",@@ -595,11 +607,18 @@ static const struct scpsys_domain_data scpsys_domain_data_mt8188[] = { .pwr_sta2nd_offs = 0x170, .sram_pdn_bits = BIT(8), .sram_pdn_ack_bits = BIT(12), + .bp_cfg = { +BUS_PROT_WR (SMI , +MT8188_SMI_COMMON_SMI_CLAMP_IPE_TO_VPP1 , +MT8188_SMI_COMMON_CLAMP_EN_SET , +MT8188_SMI_COMMON_CLAMP_EN_CLR , + MT8188_SMI_COMMON_CLAMP_EN_STA), + }, .reset_smi = {SMI_RESET_WR (MT8188_SMI_LARB12_RESET ,MT8188_SMI_LARB12_RESET_ADDR ), }, - .caps = MTK_SCPD_KEEP_DEFAULT_OFF, + .caps = MTK_SCPD_KEEP_DEFAULT_OFF | MTK_SCPD_CLAMP_PROTECTION, }, [MT8188_POWER_DOMAIN_CAM_VCORE] = { .name = "cam_vcore",@@ -676,13 +695,20 @@ static const struct scpsys_domain_data scpsys_domain_data_mt8188[] = { .pwr_sta2nd_offs = 0x170, .sram_pdn_bits = BIT(8), .sram_pdn_ack_bits = BIT(12), + .bp_cfg = { +BUS_PROT_WR (SMI , +MT8188_SMI_COMMON_SMI_CLAMP_IPE_TO_VPP1 , +MT8188_SMI_COMMON_CLAMP_EN_SET , +MT8188_SMI_COMMON_CLAMP_EN_CLR , + MT8188_SMI_COMMON_CLAMP_EN_STA), + }, .reset_smi = {SMI_RESET_WR (MT8188_SMI_LARB16A_RESET ,MT8188_SMI_LARB16A_RESET_ADDR ),SMI_RESET_WR (MT8188_SMI_LARB17A_RESET ,MT8188_SMI_LARB17A_RESET_ADDR ), }, - .caps = MTK_SCPD_KEEP_DEFAULT_OFF, + .caps = MTK_SCPD_KEEP_DEFAULT_OFF | MTK_SCPD_CLAMP_PROTECTION, }, [MT8188_POWER_DOMAIN_CAM_SUBB] = { .name = "cam_subb",@@ -692,13 +718,20 @@ static const struct scpsys_domain_data scpsys_domain_data_mt8188[] = { .pwr_sta2nd_offs = 0x170, .sram_pdn_bits = BIT(8), .sram_pdn_ack_bits = BIT(12), + .bp_cfg = { +BUS_PROT_WR (SMI , +MT8188_SMI_COMMON_SMI_CLAMP_CAM_SUBB_TO_VDO0 , +MT8188_SMI_COMMON_CLAMP_EN_SET , +MT8188_SMI_COMMON_CLAMP_EN_CLR , + MT8188_SMI_COMMON_CLAMP_EN_STA), + }, .reset_smi = {SMI_RESET_WR (MT8188_SMI_LARB16B_RESET ,MT8188_SMI_LARB16B_RESET_ADDR ),SMI_RESET_WR (MT8188_SMI_LARB17B_RESET ,MT8188_SMI_LARB17B_RESET_ADDR ), }, - .caps = MTK_SCPD_KEEP_DEFAULT_OFF, + .caps = MTK_SCPD_KEEP_DEFAULT_OFF | MTK_SCPD_CLAMP_PROTECTION, }, };drivers/pmdomain/mediatek/mtk-pm-domains.c +39
-23@@ -47,9 +47,10 @@ struct scpsys_domain {struct clk_bulk_data *subsys_clks;struct regmap *infracfg_nao;struct regmap *infracfg; -struct regmap *smi; +struct regmap **smi;struct regmap **larb;int num_larb; +int num_smi;struct regulator *supply; };@@ -122,29 +123,19 @@ static int scpsys_sram_disable(struct scpsys_domain *pd) MTK_POLL_TIMEOUT); } -static struct regmap *scpsys_bus_protect_get_regmap (struct scpsys_domain *pd, -const struct scpsys_bus_prot_data *bpd) -{ -if (bpd->flags &BUS_PROT_COMPONENT_SMI ) -return pd->smi; -else -return pd->infracfg; -} -static struct regmap *scpsys_bus_protect_get_sta_regmap (struct scpsys_domain *pd,const struct scpsys_bus_prot_data *bpd) {if (bpd->flags &BUS_PROT_STA_COMPONENT_INFRA_NAO )return pd->infracfg_nao;else -return scpsys_bus_protect_get_regmap (pd, bpd); +return pd->infracfg; }static int scpsys_bus_protect_clear (struct scpsys_domain *pd, -const struct scpsys_bus_prot_data *bpd) +const struct scpsys_bus_prot_data *bpd, +struct regmap *sta_regmap,struct regmap *regmap) { -struct regmap *sta_regmap =scpsys_bus_protect_get_sta_regmap (pd, bpd); -struct regmap *regmap =scpsys_bus_protect_get_regmap (pd, bpd);u32 sta_mask = bpd->bus_prot_sta_mask;u32 expected_ack;u32 val;@@ -165,10 +156,9 @@ static int scpsys_bus_protect_clear(struct scpsys_domain *pd, }static int scpsys_bus_protect_set (struct scpsys_domain *pd, -const struct scpsys_bus_prot_data *bpd) +const struct scpsys_bus_prot_data *bpd, +struct regmap *sta_regmap,struct regmap *regmap) { -struct regmap *sta_regmap =scpsys_bus_protect_get_sta_regmap (pd, bpd); -struct regmap *regmap =scpsys_bus_protect_get_regmap (pd, bpd);u32 sta_mask = bpd->bus_prot_sta_mask;u32 val;@@ -182,19 +172,32 @@ static int scpsys_bus_protect_set(struct scpsys_domain *pd, MTK_POLL_DELAY_US, MTK_POLL_TIMEOUT); } -static int scpsys_bus_protect_enable (struct scpsys_domain *pd) +static int _scpsys_clamp_bus_protection_enable (struct scpsys_domain *pd,bool is_smi) { +int smi_count =0 ; +for (int i =0 ; i <SPM_MAX_BUS_PROT_DATA ; i++) {const struct scpsys_bus_prot_data *bpd = &pd->data->bp_cfg[i]; +struct regmap *sta_regmap, *regmap; +bool is_smi = bpd->flags &BUS_PROT_COMPONENT_SMI ;int ret;if (!bpd->bus_prot_set_clr_mask)break ; +if (is_smi) { + sta_regmap = pd->smi[smi_count]; + regmap = pd->smi[smi_count]; + smi_count++; + }else { + sta_regmap =scpsys_bus_protect_get_sta_regmap (pd, bpd); + regmap = pd->infracfg; + } +if (bpd->flags &BUS_PROT_INVERTED ) - ret =scpsys_bus_protect_clear (pd, bpd); + ret =scpsys_bus_protect_clear (pd, bpd, sta_regmap, regmap);else - ret =scpsys_bus_protect_set (pd, bpd); + ret =scpsys_bus_protect_set (pd, bpd, sta_regmap, regmap);if (ret)return ret; }@@ -202,19 +205,32 @@ static int scpsys_bus_protect_enable(struct scpsys_domain *pd)return 0 ; } -static int scpsys_bus_protect_disable (struct scpsys_domain *pd) +static int _scpsys_clamp_bus_protection_disable (struct scpsys_domain *pd,bool is_smi) { +int smi_count = pd->num_smi -1 ; +for (int i =SPM_MAX_BUS_PROT_DATA -1 ; i >=0 ; i--) {const struct scpsys_bus_prot_data *bpd = &pd->data->bp_cfg[i]; +struct regmap *sta_regmap, *regmap; +bool is_smi = bpd->flags &BUS_PROT_COMPONENT_SMI ;int ret;if (!bpd->bus_prot_set_clr_mask)continue ; +if (is_smi) { + sta_regmap = pd->smi[smi_count]; + regmap = pd->smi[smi_count]; + smi_count--; + }else { + sta_regmap =scpsys_bus_protect_get_sta_regmap (pd, bpd); + regmap = pd->infracfg; + } +if (bpd->flags &BUS_PROT_INVERTED ) - ret =scpsys_bus_protect_set (pd, bpd); + ret =scpsys_bus_protect_set (pd, bpd, sta_regmap, regmap);else - ret =scpsys_bus_protect_clear (pd, bpd); + ret =scpsys_bus_protect_clear (pd, bpd, sta_regmap, regmap);if (ret)return ret; }
drivers/pmdomain/mediatek/mtk-pm-domains.c static int scpsys_bus_protect_disable(struct scpsys_domain *pd) · line 244
Quoted 7 lines
drivers/pmdomain/mediatek/mtk-pm-domains.c +4
-0@@ -222,6 +238,50 @@ static int scpsys_bus_protect_disable(struct scpsys_domain *pd)return 0 ; } +static int scpsys_clamp_protection (struct scpsys_domain *pd) +{ +int ret; +
You can directly call _scpsys_clamp_bus_protection_enable(), no need for a helper.
Quoted 9 lines
drivers/pmdomain/mediatek/mtk-pm-domains.c +9
-0+ ret =_scpsys_clamp_bus_protection_enable (pd, true); +if (ret) +return ret; + +return 0 ; +} + +static int scpsys_clamp_protection_disable (struct scpsys_domain *pd) +{
drivers/pmdomain/mediatek/mtk-pm-domains.c static int scpsys_bus_protect_disable(struct scpsys_domain *pd) · line 263
Quoted 10 lines
drivers/pmdomain/mediatek/mtk-pm-domains.c +10
-0+int ret; + + ret =_scpsys_clamp_bus_protection_disable (pd, true); +if (ret) +return ret; + +return 0 ; +} + +static int scpsys_bus_protect_enable (struct scpsys_domain *pd)
Unused function, please remove.
drivers/pmdomain/mediatek/mtk-pm-domains.c static int scpsys_bus_protect_disable(struct scpsys_domain *pd) · line 275
Quoted 12 lines
drivers/pmdomain/mediatek/mtk-pm-domains.c +12
-0+{ +int ret; + + ret =_scpsys_clamp_bus_protection_enable (pd, false); +if (ret) +return ret; + +return 0 ; +} + +static int scpsys_bus_protect_disable (struct scpsys_domain *pd) +{
Unused function, please remove.
Quoted 13 lines
drivers/pmdomain/mediatek/mtk-pm-domains.c +9
-0+int ret; + + ret =_scpsys_clamp_bus_protection_disable (pd, false); +if (ret) +return ret; + +return 0 ; +} +static int scpsys_regulator_enable (struct regulator *supply) {return supply ?regulator_enable (supply) :0 ;
drivers/pmdomain/mediatek/mtk-pm-domains.c static int scpsys_power_on(struct generic_pm_domain *genpd) · line 336
Quoted 5 lines
drivers/pmdomain/mediatek/mtk-pm-domains.c +2
-0@@ -272,6 +332,12 @@ static int scpsys_power_on(struct generic_pm_domain *genpd)bool tmp;int ret; +if (MTK_SCPD_CAPS (pd,MTK_SCPD_CLAMP_PROTECTION )) { + ret =scpsys_clamp_protection (pd);
ret = scpsys_clamp_bus_protection_enable(pd, true);
drivers/pmdomain/mediatek/mtk-pm-domains.c static int scpsys_power_on(struct generic_pm_domain *genpd) · line 388
Quoted 13 lines
drivers/pmdomain/mediatek/mtk-pm-domains.c +6
-0+if (ret) +return ret; + } + ret =scpsys_regulator_enable (pd->supply);if (ret)return ret;@@ -318,6 +384,12 @@ static int scpsys_power_on(struct generic_pm_domain *genpd)if (ret <0 ) goto err_disable_subsys_clks; +if (MTK_SCPD_CAPS (pd,MTK_SCPD_CLAMP_PROTECTION )) { + ret =scpsys_clamp_protection_disable (pd);
ret = scpsys_clamp_bus_protection_disable(pd, true);
drivers/pmdomain/mediatek/mtk-pm-domains.c static int scpsys_power_off(struct generic_pm_domain *genpd) · line 429
Quoted 13 lines
drivers/pmdomain/mediatek/mtk-pm-domains.c +6
-0+if (ret) +return ret; + } + ret =scpsys_bus_protect_disable (pd);if (ret <0 ) goto err_disable_sram;@@ -353,6 +425,12 @@ static int scpsys_power_off(struct generic_pm_domain *genpd)bool tmp;int ret; +if (MTK_SCPD_CAPS (pd,MTK_SCPD_CLAMP_PROTECTION )) { + ret =scpsys_clamp_protection (pd);
ret = scpsys_clamp_bus_protection_enable(pd, true);
drivers/pmdomain/mediatek/mtk-pm-domains.c static int scpsys_power_off(struct generic_pm_domain *genpd) · line 436
Quoted 7 lines
drivers/pmdomain/mediatek/mtk-pm-domains.c +4
-0+if (ret) +return ret; + } + ret =scpsys_bus_protect_enable (pd);if (ret <0 )return ret;
Regards,
Angelo
AngeloGioacchino Del Regno
maintainerIl 25/03/24 13:19, yu-chang.lee ha scritto:
Quoted 17 lines
Hi,
This series aims to solve power-off failures and occasional SMI hang issues that occur during camera stress tests. The issue arises because, when MTCMOS powers on or off, signal glitches are sometimes produced. This is fairly normal, but the software must address it to avoid mistaking the glitch for a transaction signal.
The solutions in these patches can be summarized as follows:
1. Disable the sub-common port after turning off the Larb CG and before turning off the Larb MTCMOS.
2. Use CLAMP to disable/enable the SMI common port.
3. Implement an AXI reset.
For previous discussion on the direction of the code modifications, please refer
to: https://lore.kernel.org/linux-arm-kernel/[email protected]/
Quoted 3 lines
yu-chang.lee (2):
soc: mediatek: pm-domains: addsmi_larb_resetfunction when power on
soc: mediatek: pm-domains: support smi clamp protection
Can you please change both commit titles to use "pmdomain: mediatek:" instead of "soc: mediatek:"?
Thanks
Angelo
Quoted 6 lines
drivers/pmdomain/mediatek/mt8188-pm-domains.h | 69 +++++- drivers/pmdomain/mediatek/mtk-pm-domains.c | 206 +++++++++++++++--- drivers/pmdomain/mediatek/mtk-pm-domains.h | 13 ++ 3 files changed, 255 insertions(+), 33 deletions(-)
Re: [PATCH 2/2] soc: mediatek: pm-domains: support smi clamp protection
In reply to AngeloGioacchino Del RegnoQuoted 312 lines · AngeloGioacchino Del Regno
Il 25/03/24 13:19, yu-chang.lee ha scritto:
Quoted 285 lines
In order to avoid power glitch, this patch use smi clamp to disable/enable smi common port.
Signed-off-by yu-chang.lee <[email protected]>--- drivers/pmdomain/mediatek/mt8188-pm-domains.h | 41 ++++- drivers/pmdomain/mediatek/mtk-pm-domains.c | 147 ++++++++++++++---- drivers/pmdomain/mediatek/mtk-pm-domains.h | 1 + 3 files changed, 156 insertions(+), 33 deletions(-)drivers/pmdomain/mediatek/mt8188-pm-domains.h +12
-0@@ -573,6 +573,18 @@ static const struct scpsys_domain_data scpsys_domain_data_mt8188[] = { .pwr_sta2nd_offs = 0x170, .sram_pdn_bits = BIT(8), .sram_pdn_ack_bits = BIT(12), + .bp_cfg = { +BUS_PROT_WR (SMI , +MT8188_SMI_COMMON_SMI_CLAMP_DIP_TO_ VDO0, +MT8188_SMI_COMMON_CLAMP_EN_SET , +MT8188_SMI_COMMON_CLAMP_EN_CLR , + MT8188_SMI_COMMON_CLAMP_EN_STA), + BUS_PROT_WR(SMI, + MT8188_SMI_COMMON_SMI_CLAMP_DIP_TO_ VPP1, + MT8188_SMI_COMMON_CLAMP_EN_SET, + MT8188_SMI_COMMON_CLAMP_EN_CLR, + MT8188_SMI_COMMON_CLAMP_EN_STA), + },.reset_smi = { SMI_RESET_WR(MT8188_SMI_LARB10_RESET, MT8188_SMI_LARB10_RESET_ADDR),drivers/pmdomain/mediatek/mt8188-pm-domains.h +1
-1@@ -585,7 +597,7 @@ static const struct scpsys_domain_data scpsys_domain_data_mt8188[] = {SMI_RESET_WR (MT8188_SMI_LARB15_RESET ,MT8188_SMI_LARB15_RESET_ADDR ), }, - .caps = MTK_SCPD_KEEP_DEFAULT_OFF, + .caps = MTK_SCPD_KEEP_DEFAULT_OFF | MTK_SCPD_CLAMP_PROTECTION, },[MT8188_POWER_DOMAIN_IPE] = { .name = "ipe",drivers/pmdomain/mediatek/mt8188-pm-domains.h +8
-1@@ -595,11 +607,18 @@ static const struct scpsys_domain_data scpsys_domain_data_mt8188[] = { .pwr_sta2nd_offs = 0x170, .sram_pdn_bits = BIT(8), .sram_pdn_ack_bits = BIT(12), + .bp_cfg = { +BUS_PROT_WR (SMI , +MT8188_SMI_COMMON_SMI_CLAMP_IPE_TO_ VPP1, +MT8188_SMI_COMMON_CLAMP_EN_SET , +MT8188_SMI_COMMON_CLAMP_EN_CLR , + MT8188_SMI_COMMON_CLAMP_EN_STA), + }, .reset_smi = {SMI_RESET_WR (MT8188_SMI_LARB12_RESET , MT8188_SMI_LARB12_RESET_ADDR), }, - .caps = MTK_SCPD_KEEP_DEFAULT_OFF, + .caps =MTK_SCPD_KEEP_DEFAULT_OFF | MTK_SCPD_CLAMP_PROTECTION,}, [MT8188_POWER_DOMAIN_CAM_VCORE] = { .name = "cam_vcore",drivers/pmdomain/mediatek/mt8188-pm-domains.h +8
-1@@ -676,13 +695,20 @@ static const struct scpsys_domain_data scpsys_domain_data_mt8188[] = { .pwr_sta2nd_offs = 0x170, .sram_pdn_bits = BIT(8), .sram_pdn_ack_bits = BIT(12), + .bp_cfg = { +BUS_PROT_WR (SMI , +MT8188_SMI_COMMON_SMI_CLAMP_IPE_TO_ VPP1, +MT8188_SMI_COMMON_CLAMP_EN_SET , +MT8188_SMI_COMMON_CLAMP_EN_CLR , + MT8188_SMI_COMMON_CLAMP_EN_STA), + }, .reset_smi = {SMI_RESET_WR (MT8188_SMI_LARB16A_RESET , MT8188_SMI_LARB16A_RESET_ADDR), SMI_RESET_WR(MT8188_SMI_LARB17A_RESET, MT8188_SMI_LARB17A_RESET_ADDR), }, - .caps = MTK_SCPD_KEEP_DEFAULT_OFF, + .caps =MTK_SCPD_KEEP_DEFAULT_OFF | MTK_SCPD_CLAMP_PROTECTION,}, [MT8188_POWER_DOMAIN_CAM_SUBB] = { .name = "cam_subb",drivers/pmdomain/mediatek/mt8188-pm-domains.h +8
-1@@ -692,13 +718,20 @@ static const struct scpsys_domain_data scpsys_domain_data_mt8188[] = { .pwr_sta2nd_offs = 0x170, .sram_pdn_bits = BIT(8), .sram_pdn_ack_bits = BIT(12), + .bp_cfg = { +BUS_PROT_WR (SMI , +MT8188_SMI_COMMON_SMI_CLAMP_CAM_SUB B_TO_VDO0, +MT8188_SMI_COMMON_CLAMP_EN_SET , +MT8188_SMI_COMMON_CLAMP_EN_CLR , + MT8188_SMI_COMMON_CLAMP_EN_STA), + }, .reset_smi = {SMI_RESET_WR (MT8188_SMI_LARB16B_RESET , MT8188_SMI_LARB16B_RESET_ADDR), SMI_RESET_WR(MT8188_SMI_LARB17B_RESET, MT8188_SMI_LARB17B_RESET_ADDR), }, - .caps = MTK_SCPD_KEEP_DEFAULT_OFF, + .caps =MTK_SCPD_KEEP_DEFAULT_OFF | MTK_SCPD_CLAMP_PROTECTION,}, };drivers/pmdomain/mediatek/mtk-pm-domains.c +4
-12@@ -47,9 +47,10 @@ struct scpsys_domain {struct clk_bulk_data *subsys_clks;struct regmap *infracfg_nao;struct regmap *infracfg; -struct regmap *smi; +struct regmap **smi;struct regmap **larb;int num_larb; +int num_smi;struct regulator *supply; };@@ -122,29 +123,19 @@ static int scpsys_sram_disable(struct scpsys_domain *pd) MTK_POLL_TIMEOUT); } -static struct regmap *scpsys_bus_protect_get_regmap (struct scpsys_domain *pd, -const struct scpsys_bus_prot_data *bpd) -{ -if (bpd->flags &BUS_PROT_COMPONENT_SMI ) -return pd->smi; -else -return pd->infracfg; -} -static struct regmap *scpsys_bus_protect_get_sta_regmap (struct scpsys_domain *pd,const struct scpsys_bus_prot_data *bpd) {if (bpd->flags &BUS_PROT_STA_COMPONENT_INFRA_NAO )return pd->infracfg_nao;else -return scpsys_bus_protect_get_regmap (pd, bpd); +return pd->infracfg; } static int scpsys_bus_protect_clear(struct scpsys_domain *pd, -const struct scpsys_bus_prot_data *bpd) + const struct scpsys_bus_prot_data*bpd,
drivers/pmdomain/mediatek/mtk-pm-domains.c +1
-0+ struct regmap *sta_regmap,struct regmap *regmap)
{drivers/pmdomain/mediatek/mtk-pm-domains.c +0
-1- struct regmap *sta_regmap =
scpsys_bus_protect_get_sta_regmap(pd, bpd);drivers/pmdomain/mediatek/mtk-pm-domains.c +2
-3-struct regmap *regmap =scpsys_bus_protect_get_regmap (pd, bpd);u32 sta_mask = bpd->bus_prot_sta_mask;u32 expected_ack;u32 val;@@ -165,10 +156,9 @@ static int scpsys_bus_protect_clear(struct scpsys_domain *pd, } static int scpsys_bus_protect_set(struct scpsys_domain *pd, -const struct scpsys_bus_prot_data *bpd) + const struct scpsys_bus_prot_data *bpd, + struct regmap *sta_regmap, struct regmap *regmap) { - struct regmap *sta_regmap =
scpsys_bus_protect_get_sta_regmap(pd, bpd);drivers/pmdomain/mediatek/mtk-pm-domains.c +15
-3-struct regmap *regmap =scpsys_bus_protect_get_regmap (pd, bpd);u32 sta_mask = bpd->bus_prot_sta_mask;u32 val;@@ -182,19 +172,32 @@ static int scpsys_bus_protect_set(structscpsys_domain *pd,MTK_POLL_DELAY_US , MTK_POLL_TIMEOUT); } -static int scpsys_bus_protect_enable(struct scpsys_domain *pd) +static int _scpsys_clamp_bus_protection_enable (struct scpsys_domain *pd,bool is_smi) { +int smi_count =0 ; +for (int i =0 ; i <SPM_MAX_BUS_PROT_DATA ; i++) {const struct scpsys_bus_prot_data *bpd = &pd->data- >bp_cfg[i]; +struct regmap *sta_regmap, *regmap; +bool is_smi = bpd->flags &BUS_PROT_COMPONENT_SMI ;int ret;if (!bpd->bus_prot_set_clr_mask)break ; +if (is_smi) { + sta_regmap = pd->smi[smi_count]; + regmap = pd->smi[smi_count]; + smi_count++; + }else { + sta_regmap =scpsys_bus_protect_get_sta_regmap (pd, bpd); + regmap = pd->infracfg; + } +if (bpd->flags &BUS_PROT_INVERTED ) - ret =scpsys_bus_protect_clear (pd, bpd); + ret = scpsys_bus_protect_clear(pd, bpd,
sta_regmap, regmap);
elsedrivers/pmdomain/mediatek/mtk-pm-domains.c +1
-1- ret =scpsys_bus_protect_set (pd, bpd); + ret = scpsys_bus_protect_set(pd, bpd,
sta_regmap, regmap);
if (ret)
return ret;
}drivers/pmdomain/mediatek/mtk-pm-domains.c +15
-2@@ -202,19 +205,32 @@ static int scpsys_bus_protect_enable(struct scpsys_domain *pd)return 0 ; } -static int scpsys_bus_protect_disable(struct scpsys_domain *pd) +static int _scpsys_clamp_bus_protection_disable (struct scpsys_domain *pd,bool is_smi) { +int smi_count = pd->num_smi -1 ; +for (int i =SPM_MAX_BUS_PROT_DATA -1 ; i >=0 ; i--) {const struct scpsys_bus_prot_data *bpd = &pd->data- >bp_cfg[i]; +struct regmap *sta_regmap, *regmap; +bool is_smi = bpd->flags &BUS_PROT_COMPONENT_SMI ;int ret;if (!bpd->bus_prot_set_clr_mask)continue ; +if (is_smi) { + sta_regmap = pd->smi[smi_count]; + regmap = pd->smi[smi_count]; + smi_count--; + }else { + sta_regmap =scpsys_bus_protect_get_sta_regmap (pd, bpd); + regmap = pd->infracfg; + } +if (bpd->flags &BUS_PROT_INVERTED ) - ret =scpsys_bus_protect_set (pd, bpd); + ret =scpsys_bus_protect_set (pd, bpd, sta_regmap, regmap);else
drivers/pmdomain/mediatek/mtk-pm-domains.c +1
-1- ret =scpsys_bus_protect_clear (pd, bpd); + ret = scpsys_bus_protect_clear(pd, bpd,
sta_regmap, regmap);
if (ret)
return ret;
}drivers/pmdomain/mediatek/mtk-pm-domains.c static int scpsys_bus_protect_disable(struct · line 245
Quoted 8 lines
drivers/pmdomain/mediatek/mtk-pm-domains.c +4
-0@@ -222,6 +238,50 @@ static int scpsys_bus_protect_disable(struct scpsys_domain *pd)return 0 ; } +static int scpsys_clamp_protection (struct scpsys_domain *pd) +{ +int ret; +You can directly call
_scpsys_clamp_bus_protection_enable(), no need for a helper.Quoted 14 lines
drivers/pmdomain/mediatek/mtk-pm-domains.c +13
-0+ ret =_scpsys_clamp_bus_protection_enable (pd, true); +if (ret) +return ret; + +return 0 ; +} + +static int scpsys_clamp_protection_disable (struct scpsys_domain *pd) +{ +int ret; + + ret =_scpsys_clamp_bus_protection_disable (pd, true); +if (ret)
Quoted 8 lines
drivers/pmdomain/mediatek/mtk-pm-domains.c static int scpsys_bus_protect_disable(struct scpsys_domain *pd) · line 263
Quoted 6 lines
drivers/pmdomain/mediatek/mtk-pm-domains.c +6
-0+return ret; + +return 0 ; +} + +static int scpsys_bus_protect_enable (struct scpsys_domain *pd)Unused function, please remove.
I think this is used in scpsys_power_off function. Do you mean I should directly call _scpsys_clamp_bus_protection_disable?
Quoted 15 lines
drivers/pmdomain/mediatek/mtk-pm-domains.c static int scpsys_bus_protect_disable(struct scpsys_domain *pd) · line 275
Quoted 13 lines
drivers/pmdomain/mediatek/mtk-pm-domains.c +12
-0+{ +int ret; + + ret =_scpsys_clamp_bus_protection_enable (pd, false); +if (ret) +return ret; + +return 0 ; +} + +static int scpsys_bus_protect_disable (struct scpsys_domain *pd) +{Unused function, please remove.
Same here, I think this is used in scpsys_power_on function.
Quoted 57 lines
Quoted 14 lines
drivers/pmdomain/mediatek/mtk-pm-domains.c +9
-0+int ret; + + ret =_scpsys_clamp_bus_protection_disable (pd, false); +if (ret) +return ret; + +return 0 ; +} +static int scpsys_regulator_enable (struct regulator *supply){ return supply ? regulator_enable(supply) : 0;drivers/pmdomain/mediatek/mtk-pm-domains.c static int scpsys_power_on(struct · line 337
Quoted 6 lines
drivers/pmdomain/mediatek/mtk-pm-domains.c +2
-0@@ -272,6 +332,12 @@ static int scpsys_power_on(struct generic_pm_domain *genpd)bool tmp;int ret; +if (MTK_SCPD_CAPS (pd,MTK_SCPD_CLAMP_PROTECTION )) { + ret =scpsys_clamp_protection (pd);ret = scpsys_clamp_bus_protection_enable(pd, true);Quoted 8 lines
drivers/pmdomain/mediatek/mtk-pm-domains.c +4
-0+if (ret) +return ret; + } + ret =scpsys_regulator_enable (pd->supply);if (ret)return ret;
drivers/pmdomain/mediatek/mtk-pm-domains.c static int scpsys_power_on(struct · line 389
Quoted 6 lines
drivers/pmdomain/mediatek/mtk-pm-domains.c +2
-0@@ -318,6 +384,12 @@ static int scpsys_power_on(struct generic_pm_domain *genpd)if (ret <0 ) goto err_disable_subsys_clks; +if (MTK_SCPD_CAPS (pd,MTK_SCPD_CLAMP_PROTECTION )) { + ret =scpsys_clamp_protection_disable (pd);ret = scpsys_clamp_bus_protection_disable(pd, true);Quoted 8 lines
drivers/pmdomain/mediatek/mtk-pm-domains.c +4
-0+if (ret) +return ret; + } + ret =scpsys_bus_protect_disable (pd);if (ret <0 )goto
err_disable_sram;drivers/pmdomain/mediatek/mtk-pm-domains.c static int scpsys_power_off(struct · line 430
Quoted 6 lines
drivers/pmdomain/mediatek/mtk-pm-domains.c +2
-0@@ -353,6 +425,12 @@ static int scpsys_power_off(struct generic_pm_domain *genpd)bool tmp;int ret; +if (MTK_SCPD_CAPS (pd,MTK_SCPD_CLAMP_PROTECTION )) { + ret =scpsys_clamp_protection (pd);ret =
scpsys_clamp_bus_protection_enable(pd, true);
Quoted 11 lines
Quoted 7 lines
drivers/pmdomain/mediatek/mtk-pm-domains.c +4
-0+if (ret) +return ret; + } + ret =scpsys_bus_protect_enable (pd);if (ret <0 )return ret;
Regards,
Angelo
Best Regards,
yu-chang.lee
AngeloGioacchino Del Regno
maintainerRe: [PATCH 2/2] soc: mediatek: pm-domains: support smi clamp protection
Il 26/03/24 03:00, Yu-chang Lee (李禹璋) ha scritto:
Quoted 322 lines · AngeloGioacchino Del Regno
Quoted 312 lines
Il 25/03/24 13:19, yu-chang.lee ha scritto:
Quoted 285 lines
In order to avoid power glitch, this patch use smi clamp to disable/enable smi common port.
Signed-off-by yu-chang.lee <[email protected]>--- drivers/pmdomain/mediatek/mt8188-pm-domains.h | 41 ++++- drivers/pmdomain/mediatek/mtk-pm-domains.c | 147 ++++++++++++++---- drivers/pmdomain/mediatek/mtk-pm-domains.h | 1 + 3 files changed, 156 insertions(+), 33 deletions(-)drivers/pmdomain/mediatek/mt8188-pm-domains.h +12
-0@@ -573,6 +573,18 @@ static const struct scpsys_domain_data scpsys_domain_data_mt8188[] = { .pwr_sta2nd_offs = 0x170, .sram_pdn_bits = BIT(8), .sram_pdn_ack_bits = BIT(12), + .bp_cfg = { +BUS_PROT_WR (SMI , +MT8188_SMI_COMMON_SMI_CLAMP_DIP_TO_ VDO0, +MT8188_SMI_COMMON_CLAMP_EN_SET , +MT8188_SMI_COMMON_CLAMP_EN_CLR , + MT8188_SMI_COMMON_CLAMP_EN_STA), + BUS_PROT_WR(SMI, + MT8188_SMI_COMMON_SMI_CLAMP_DIP_TO_ VPP1, + MT8188_SMI_COMMON_CLAMP_EN_SET, + MT8188_SMI_COMMON_CLAMP_EN_CLR, + MT8188_SMI_COMMON_CLAMP_EN_STA), + },.reset_smi = { SMI_RESET_WR(MT8188_SMI_LARB10_RESET, MT8188_SMI_LARB10_RESET_ADDR),drivers/pmdomain/mediatek/mt8188-pm-domains.h +1
-1@@ -585,7 +597,7 @@ static const struct scpsys_domain_data scpsys_domain_data_mt8188[] = {SMI_RESET_WR (MT8188_SMI_LARB15_RESET ,MT8188_SMI_LARB15_RESET_ADDR ), }, - .caps = MTK_SCPD_KEEP_DEFAULT_OFF, + .caps = MTK_SCPD_KEEP_DEFAULT_OFF | MTK_SCPD_CLAMP_PROTECTION, },[MT8188_POWER_DOMAIN_IPE] = { .name = "ipe",drivers/pmdomain/mediatek/mt8188-pm-domains.h +8
-1@@ -595,11 +607,18 @@ static const struct scpsys_domain_data scpsys_domain_data_mt8188[] = { .pwr_sta2nd_offs = 0x170, .sram_pdn_bits = BIT(8), .sram_pdn_ack_bits = BIT(12), + .bp_cfg = { +BUS_PROT_WR (SMI , +MT8188_SMI_COMMON_SMI_CLAMP_IPE_TO_ VPP1, +MT8188_SMI_COMMON_CLAMP_EN_SET , +MT8188_SMI_COMMON_CLAMP_EN_CLR , + MT8188_SMI_COMMON_CLAMP_EN_STA), + }, .reset_smi = {SMI_RESET_WR (MT8188_SMI_LARB12_RESET , MT8188_SMI_LARB12_RESET_ADDR), }, - .caps = MTK_SCPD_KEEP_DEFAULT_OFF, + .caps =MTK_SCPD_KEEP_DEFAULT_OFF | MTK_SCPD_CLAMP_PROTECTION,}, [MT8188_POWER_DOMAIN_CAM_VCORE] = { .name = "cam_vcore",drivers/pmdomain/mediatek/mt8188-pm-domains.h +8
-1@@ -676,13 +695,20 @@ static const struct scpsys_domain_data scpsys_domain_data_mt8188[] = { .pwr_sta2nd_offs = 0x170, .sram_pdn_bits = BIT(8), .sram_pdn_ack_bits = BIT(12), + .bp_cfg = { +BUS_PROT_WR (SMI , +MT8188_SMI_COMMON_SMI_CLAMP_IPE_TO_ VPP1, +MT8188_SMI_COMMON_CLAMP_EN_SET , +MT8188_SMI_COMMON_CLAMP_EN_CLR , + MT8188_SMI_COMMON_CLAMP_EN_STA), + }, .reset_smi = {SMI_RESET_WR (MT8188_SMI_LARB16A_RESET , MT8188_SMI_LARB16A_RESET_ADDR), SMI_RESET_WR(MT8188_SMI_LARB17A_RESET, MT8188_SMI_LARB17A_RESET_ADDR), }, - .caps = MTK_SCPD_KEEP_DEFAULT_OFF, + .caps =MTK_SCPD_KEEP_DEFAULT_OFF | MTK_SCPD_CLAMP_PROTECTION,}, [MT8188_POWER_DOMAIN_CAM_SUBB] = { .name = "cam_subb",drivers/pmdomain/mediatek/mt8188-pm-domains.h +8
-1@@ -692,13 +718,20 @@ static const struct scpsys_domain_data scpsys_domain_data_mt8188[] = { .pwr_sta2nd_offs = 0x170, .sram_pdn_bits = BIT(8), .sram_pdn_ack_bits = BIT(12), + .bp_cfg = { +BUS_PROT_WR (SMI , +MT8188_SMI_COMMON_SMI_CLAMP_CAM_SUB B_TO_VDO0, +MT8188_SMI_COMMON_CLAMP_EN_SET , +MT8188_SMI_COMMON_CLAMP_EN_CLR , + MT8188_SMI_COMMON_CLAMP_EN_STA), + }, .reset_smi = {SMI_RESET_WR (MT8188_SMI_LARB16B_RESET , MT8188_SMI_LARB16B_RESET_ADDR), SMI_RESET_WR(MT8188_SMI_LARB17B_RESET, MT8188_SMI_LARB17B_RESET_ADDR), }, - .caps = MTK_SCPD_KEEP_DEFAULT_OFF, + .caps =MTK_SCPD_KEEP_DEFAULT_OFF | MTK_SCPD_CLAMP_PROTECTION,}, };drivers/pmdomain/mediatek/mtk-pm-domains.c +4
-12@@ -47,9 +47,10 @@ struct scpsys_domain {struct clk_bulk_data *subsys_clks;struct regmap *infracfg_nao;struct regmap *infracfg; -struct regmap *smi; +struct regmap **smi;struct regmap **larb;int num_larb; +int num_smi;struct regulator *supply; };@@ -122,29 +123,19 @@ static int scpsys_sram_disable(struct scpsys_domain *pd) MTK_POLL_TIMEOUT); } -static struct regmap *scpsys_bus_protect_get_regmap (struct scpsys_domain *pd, -const struct scpsys_bus_prot_data *bpd) -{ -if (bpd->flags &BUS_PROT_COMPONENT_SMI ) -return pd->smi; -else -return pd->infracfg; -} -static struct regmap *scpsys_bus_protect_get_sta_regmap (struct scpsys_domain *pd,const struct scpsys_bus_prot_data *bpd) {if (bpd->flags &BUS_PROT_STA_COMPONENT_INFRA_NAO )return pd->infracfg_nao;else -return scpsys_bus_protect_get_regmap (pd, bpd); +return pd->infracfg; } static int scpsys_bus_protect_clear(struct scpsys_domain *pd, -const struct scpsys_bus_prot_data *bpd) + const struct scpsys_bus_prot_data*bpd,
drivers/pmdomain/mediatek/mtk-pm-domains.c +1
-0+ struct regmap *sta_regmap,struct regmap *regmap)
{drivers/pmdomain/mediatek/mtk-pm-domains.c +0
-1- struct regmap *sta_regmap =
scpsys_bus_protect_get_sta_regmap(pd, bpd);drivers/pmdomain/mediatek/mtk-pm-domains.c +2
-3-struct regmap *regmap =scpsys_bus_protect_get_regmap (pd, bpd);u32 sta_mask = bpd->bus_prot_sta_mask;u32 expected_ack;u32 val;@@ -165,10 +156,9 @@ static int scpsys_bus_protect_clear(struct scpsys_domain *pd, } static int scpsys_bus_protect_set(struct scpsys_domain *pd, -const struct scpsys_bus_prot_data *bpd) + const struct scpsys_bus_prot_data *bpd, + struct regmap *sta_regmap, struct regmap *regmap) { - struct regmap *sta_regmap =
scpsys_bus_protect_get_sta_regmap(pd, bpd);drivers/pmdomain/mediatek/mtk-pm-domains.c +15
-3-struct regmap *regmap =scpsys_bus_protect_get_regmap (pd, bpd);u32 sta_mask = bpd->bus_prot_sta_mask;u32 val;@@ -182,19 +172,32 @@ static int scpsys_bus_protect_set(structscpsys_domain *pd,MTK_POLL_DELAY_US , MTK_POLL_TIMEOUT); } -static int scpsys_bus_protect_enable(struct scpsys_domain *pd) +static int _scpsys_clamp_bus_protection_enable (struct scpsys_domain *pd,bool is_smi) { +int smi_count =0 ; +for (int i =0 ; i <SPM_MAX_BUS_PROT_DATA ; i++) {const struct scpsys_bus_prot_data *bpd = &pd->data- > bp_cfg[i]; +struct regmap *sta_regmap, *regmap; +bool is_smi = bpd->flags &BUS_PROT_COMPONENT_SMI ;int ret;if (!bpd->bus_prot_set_clr_mask)break ; +if (is_smi) { + sta_regmap = pd->smi[smi_count]; + regmap = pd->smi[smi_count]; + smi_count++; + }else { + sta_regmap =scpsys_bus_protect_get_sta_regmap (pd, bpd); + regmap = pd->infracfg; + } +if (bpd->flags &BUS_PROT_INVERTED ) - ret =scpsys_bus_protect_clear (pd, bpd); + ret = scpsys_bus_protect_clear(pd, bpd,
sta_regmap, regmap);
elsedrivers/pmdomain/mediatek/mtk-pm-domains.c +1
-1- ret =scpsys_bus_protect_set (pd, bpd); + ret = scpsys_bus_protect_set(pd, bpd,sta_regmap, regmap); if (ret) return ret; }drivers/pmdomain/mediatek/mtk-pm-domains.c +15
-2@@ -202,19 +205,32 @@ static int scpsys_bus_protect_enable(struct scpsys_domain *pd)return 0 ; } -static int scpsys_bus_protect_disable(struct scpsys_domain *pd) +static int _scpsys_clamp_bus_protection_disable (struct scpsys_domain *pd,bool is_smi) { +int smi_count = pd->num_smi -1 ; +for (int i =SPM_MAX_BUS_PROT_DATA -1 ; i >=0 ; i--) {const struct scpsys_bus_prot_data *bpd = &pd->data- > bp_cfg[i]; +struct regmap *sta_regmap, *regmap; +bool is_smi = bpd->flags &BUS_PROT_COMPONENT_SMI ;int ret;if (!bpd->bus_prot_set_clr_mask)continue ; +if (is_smi) { + sta_regmap = pd->smi[smi_count]; + regmap = pd->smi[smi_count]; + smi_count--; + }else { + sta_regmap =scpsys_bus_protect_get_sta_regmap (pd, bpd); + regmap = pd->infracfg; + } +if (bpd->flags &BUS_PROT_INVERTED ) - ret =scpsys_bus_protect_set (pd, bpd); + ret =scpsys_bus_protect_set (pd, bpd, sta_regmap, regmap);else
drivers/pmdomain/mediatek/mtk-pm-domains.c +1
-1- ret =scpsys_bus_protect_clear (pd, bpd); + ret = scpsys_bus_protect_clear(pd, bpd,sta_regmap, regmap); if (ret) return ret; }drivers/pmdomain/mediatek/mtk-pm-domains.c static int scpsys_bus_protect_disable(struct · line 245
Quoted 8 lines
drivers/pmdomain/mediatek/mtk-pm-domains.c +4
-0@@ -222,6 +238,50 @@ static int scpsys_bus_protect_disable(struct scpsys_domain *pd)return 0 ; } +static int scpsys_clamp_protection (struct scpsys_domain *pd) +{ +int ret; +You can directly call
_scpsys_clamp_bus_protection_enable(), no need for a helper.Quoted 14 lines
drivers/pmdomain/mediatek/mtk-pm-domains.c +13
-0+ ret =_scpsys_clamp_bus_protection_enable (pd, true); +if (ret) +return ret; + +return 0 ; +} + +static int scpsys_clamp_protection_disable (struct scpsys_domain *pd) +{ +int ret; + + ret =_scpsys_clamp_bus_protection_disable (pd, true); +if (ret)Quoted 8 lines
drivers/pmdomain/mediatek/mtk-pm-domains.c static int scpsys_bus_protect_disable(struct scpsys_domain *pd) · line 263
Quoted 6 lines
drivers/pmdomain/mediatek/mtk-pm-domains.c +6
-0+return ret; + +return 0 ; +} + +static int scpsys_bus_protect_enable (struct scpsys_domain *pd)Unused function, please remove.
Quoted 3 lines
I think this is used in
scpsys_power_offfunction. Do you mean I should directly call_scpsys_clamp_bus_protection_disable?
Yes, please.
Cheers,
Angelo