Subject: [MT8189] Pwrap/SPMI/regulator driver
Add support for MT8188 Pwrap,SPMI driver,add dt-bindings description related. modify mt6315 regulator buck function.
niklaus.liu (3):
dt-bindings: mediatek : add binding for pwrap,spmi soc:mediatek mt8189: Porting driver for spmi/pwrap
regulator: Modify mt6315 regulator mode mask
.../bindings/soc/mediatek/mediatek,pwrap.yaml | 1 + .../bindings/spmi/mtk,spmi-mtk-pmif.yaml | 1 + drivers/regulator/mt6315-regulator.c | 6 +++++ drivers/soc/mediatek/mtk-pmic-wrap.c | 27 +++++++++++++++++++ drivers/spmi/spmi-mtk-pmif.c | 3 +++ 5 files changed, 38 insertions(+)
Signature · 1 line
2.46.0
PATCH 1/3 dt-bindings: mediatek : add binding for pwrap,spmi
Add pwrap,spmi compatible for mt8189 to the binding.
--- .../devicetree/bindings/soc/mediatek/mediatek,pwrap.yaml | 1 + Documentation/devicetree/bindings/spmi/mtk,spmi-mtk-pmif.yaml | 1 + 2 files changed, 2 insertions(+)
Documentation/devicetree/bindings/soc/mediatek/mediatek,pwrap.yaml +1 -0
@@ -52,6 +52,7 @@ properties: - items: - enum: - mediatek,mt8188-pwrap + - mediatek,mt8189-pwrap - const: mediatek,mt8195-pwrap - const: syscon
Documentation/devicetree/bindings/spmi/mtk,spmi-mtk-pmif.yaml +1 -0
@@ -26,6 +26,7 @@ properties: - enum: - mediatek,mt8186-spmi - mediatek,mt8188-spmi + - mediatek,mt8189-spmi - const: mediatek,mt8195-spmi reg:
Signature · 1 line
2.46.0
AngeloGioacchino Del Regno
maintainerRe: [PATCH 1/3] dt-bindings: mediatek : add binding for pwrap,spmi
Il 01/08/25 08:39, niklaus.liu ha scritto:
Quoted 1 line
Add pwrap,spmi compatible for mt8189 to the binding.
The changes look good, but you have to split the commit in two; one for adding the compatible to mediatek,pwrap.yaml and one for adding it to the other.
Besides, please check the git log for both yaml files and:
1. Use the same prefixes that you find in there for your new commit titles;
2. Add a commit description that describes your change, e.g.:
"Add a new compatible string for MT8189; this SoC's {spmi, pwrap} IP is fully
compatible with the one found in the MT8195 SoC."
Regards,
Angelo
Quoted 31 lines
Signed-off-by niklaus.liu <[email protected]>--- .../devicetree/bindings/soc/mediatek/mediatek,pwrap.yaml | 1 + Documentation/devicetree/bindings/spmi/mtk,spmi-mtk-pmif.yaml | 1 + 2 files changed, 2 insertions(+)Documentation/devicetree/bindings/soc/mediatek/mediatek,pwrap.yaml +1
-0@@ -52,6 +52,7 @@ properties: - items: - enum: - mediatek,mt8188-pwrap + - mediatek,mt8189-pwrap - const: mediatek,mt8195-pwrap - const: sysconDocumentation/devicetree/bindings/spmi/mtk,spmi-mtk-pmif.yaml +1
-0@@ -26,6 +26,7 @@ properties: - enum: - mediatek,mt8186-spmi - mediatek,mt8188-spmi + - mediatek,mt8189-spmi - const: mediatek,mt8195-spmi reg:
PATCH 2/3 soc:mediatek mt8189: Porting driver for spmi/pwrap
In reply to niklaus.liuModify spmi/pwrap driver for mt8189
--- drivers/soc/mediatek/mtk-pmic-wrap.c | 27 +++++++++++++++++++++++++++ drivers/spmi/spmi-mtk-pmif.c | 3 +++ 2 files changed, 30 insertions(+)
drivers/soc/mediatek/mtk-pmic-wrap.c +27 -0
@@ -1087,6 +1087,17 @@ static const int mt8183_regs[] = { [PWRAP_WACS2_VLDCLR] = 0xC28, }; +static int mt8189_regs[] = { + [PWRAP_INIT_DONE2 ] =0x0 , + [PWRAP_TIMER_EN ] =0x3e4 , + [PWRAP_INT_EN ] =0x450 , + [PWRAP_WACS2_CMD ] =0x880 , + [PWRAP_SWINF_2_WDATA_31_0 ] =0x884 , + [PWRAP_SWINF_2_RDATA_31_0 ] =0x894 , + [PWRAP_WACS2_VLDCLR ] =0x8a4 , + [PWRAP_WACS2_RDATA ] =0x8a8 , +}; +static const int mt8195_regs[] = { [PWRAP_INIT_DONE2 ] =0x0 , [PWRAP_STAUPD_CTRL ] =0x4C ,
@@ -1324,6 +1335,7 @@ enum pwrap_type {PWRAP_MT8173 ,PWRAP_MT8183 ,PWRAP_MT8186 , +PWRAP_MT8189 ,PWRAP_MT8195 ,PWRAP_MT8365 , PWRAP_MT8516,
@@ -1854,6 +1866,7 @@ static int pwrap_init_cipher(struct pmic_wrapper *wrp)break ;case PWRAP_MT6873 :case PWRAP_MT8183 : +case PWRAP_MT8189 :case PWRAP_MT8195 :break ; }
@@ -2393,6 +2406,19 @@ static const struct pmic_wrapper_type pwrap_mt8183 = { .init_soc_specific = pwrap_mt8183_init_soc_specific, }; +static struct pmic_wrapper_type pwrap_mt8189 = { + .regs = mt8189_regs, + .type =PWRAP_MT8189 , + .arb_en_all =0x777f , + .int_en_all =0x180000 , + .int1_en_all =0 , + .spi_w =PWRAP_MAN_CMD_SPI_WRITE , + .wdt_src =PWRAP_WDT_SRC_MASK_ALL , + .caps =PWRAP_CAP_ARB , + .init_reg_clock = pwrap_common_init_reg_clock, + .init_soc_specific =NULL , +}; +static const struct pmic_wrapper_type pwrap_mt8195 = { .regs = mt8195_regs, .type =PWRAP_MT8195 ,
@@ -2456,6 +2482,7 @@ static const struct of_device_id of_pwrap_match_tbl[] = { { .compatible = "mediatek,mt8173-pwrap", .data = &pwrap_mt8173 }, { .compatible = "mediatek,mt8183-pwrap", .data = &pwrap_mt8183 }, { .compatible = "mediatek,mt8186-pwrap", .data = &pwrap_mt8186 }, + { .compatible = "mediatek,mt8189-pwrap", .data = &pwrap_mt8189 }, { .compatible = "mediatek,mt8195-pwrap", .data = &pwrap_mt8195 }, { .compatible = "mediatek,mt8365-pwrap", .data = &pwrap_mt8365 }, { .compatible = "mediatek,mt8516-pwrap", .data = &pwrap_mt8516 },
drivers/spmi/spmi-mtk-pmif.c +3 -0
@@ -530,6 +530,9 @@ static const struct of_device_id mtk_spmi_match_table[] = { { .compatible = "mediatek,mt6873-spmi", .data = &mt6873_pmif_arb, + }, { + .compatible = "mediatek,mt8189-spmi", + .data = &mt8195_pmif_arb, }, { .compatible = "mediatek,mt8195-spmi", .data = &mt8195_pmif_arb,
Signature · 1 line
2.46.0
AngeloGioacchino Del Regno
maintainerRe: [PATCH 2/3] soc:mediatek mt8189: Porting driver for spmi/pwrap
Il 01/08/25 08:39, niklaus.liu ha scritto:
Quoted 16 lines
Modify spmi/pwrap driver for mt8189
Signed-off-by niklaus.liu <[email protected]>--- drivers/soc/mediatek/mtk-pmic-wrap.c | 27 +++++++++++++++++++++++++++ drivers/spmi/spmi-mtk-pmif.c | 3 +++ 2 files changed, 30 insertions(+)drivers/soc/mediatek/mtk-pmic-wrap.c +0
-0@@ -1087,6 +1087,17 @@ static const int mt8183_regs[] = { [PWRAP_WACS2_VLDCLR] = 0xC28, };
drivers/soc/mediatek/mtk-pmic-wrap.c static const int mt8183_regs[] = { · line 1099
Quoted 10 lines
drivers/soc/mediatek/mtk-pmic-wrap.c +10
-0+static int mt8189_regs[] = { + [PWRAP_INIT_DONE2 ] =0x0 , + [PWRAP_TIMER_EN ] =0x3e4 , + [PWRAP_INT_EN ] =0x450 , + [PWRAP_WACS2_CMD ] =0x880 , + [PWRAP_SWINF_2_WDATA_31_0 ] =0x884 , + [PWRAP_SWINF_2_RDATA_31_0 ] =0x894 , + [PWRAP_WACS2_VLDCLR ] =0x8a4 , + [PWRAP_WACS2_RDATA ] =0x8a8 , +};
You can fully reuse mt8195_regs, as mt8189 has the same layout.
Quoted 23 lines
drivers/soc/mediatek/mtk-pmic-wrap.c +3
-0+static const int mt8195_regs[] = { [PWRAP_INIT_DONE2 ] =0x0 , [PWRAP_STAUPD_CTRL ] =0x4C ,@@ -1324,6 +1335,7 @@ enum pwrap_type {PWRAP_MT8173 ,PWRAP_MT8183 ,PWRAP_MT8186 , +PWRAP_MT8189 ,PWRAP_MT8195 ,PWRAP_MT8365 , PWRAP_MT8516,@@ -1854,6 +1866,7 @@ static int pwrap_init_cipher(struct pmic_wrapper *wrp)break ;case PWRAP_MT6873 :case PWRAP_MT8183 : +case PWRAP_MT8189 :case PWRAP_MT8195 :break ; }@@ -2393,6 +2406,19 @@ static const struct pmic_wrapper_type pwrap_mt8183 = { .init_soc_specific = pwrap_mt8183_init_soc_specific, };
drivers/soc/mediatek/mtk-pmic-wrap.c static const struct pmic_wrapper_type pwrap_mt8183 = { · line 2417
Quoted 10 lines
drivers/soc/mediatek/mtk-pmic-wrap.c +9
-0+static struct pmic_wrapper_type pwrap_mt8189 = { + .regs = mt8189_regs, + .type =PWRAP_MT8189 , + .arb_en_all =0x777f , + .int_en_all =0x180000 , + .int1_en_all =0 , + .spi_w =PWRAP_MAN_CMD_SPI_WRITE , + .wdt_src =PWRAP_WDT_SRC_MASK_ALL , + .caps =PWRAP_CAP_ARB ,
Why are you avoiding to enable the INT1 interrupt on MT8189?
Is this working around a hardware bug, or did you simply forget to enable it? I think you should really enable it, which means....
drivers/soc/mediatek/mtk-pmic-wrap.c static const struct of_device_id of_pwrap_match_tbl[] = { · line 2485
Quoted 12 lines
drivers/soc/mediatek/mtk-pmic-wrap.c +5
-0+ .init_reg_clock = pwrap_common_init_reg_clock, + .init_soc_specific = NULL, +}; +static const struct pmic_wrapper_type pwrap_mt8195 = { .regs = mt8195_regs, .type =PWRAP_MT8195 ,@@ -2456,6 +2482,7 @@ static const struct of_device_id of_pwrap_match_tbl[] = { { .compatible = "mediatek,mt8173-pwrap", .data = &pwrap_mt8173 }, { .compatible = "mediatek,mt8183-pwrap", .data = &pwrap_mt8183 }, { .compatible = "mediatek,mt8186-pwrap", .data = &pwrap_mt8186 }, + { .compatible = "mediatek,mt8189-pwrap", .data = &pwrap_mt8189 },
...means that you don't even need to add a new compatible in this list, because the MT8195 compatible can be reused.
You only have to add the MT8189 compatible to the bindings, so that you are allowed to specify in your devicetree node
compatible = "mediatek,mt8189-pwrap", "mediatek,mt8195-pwrap";
Quoted 8 lines
drivers/soc/mediatek/mtk-pmic-wrap.c +0
-0{ .compatible = "mediatek,mt8195-pwrap", .data = &pwrap_mt8195 }, { .compatible = "mediatek,mt8365-pwrap", .data = &pwrap_mt8365 }, { .compatible = "mediatek,mt8516-pwrap", .data = &pwrap_mt8516 },drivers/spmi/spmi-mtk-pmif.c +0
-0
drivers/spmi/spmi-mtk-pmif.c static const struct of_device_id mtk_spmi_match_table[] = { · line 535
Quoted 6 lines
drivers/spmi/spmi-mtk-pmif.c +3
-0@@ -530,6 +530,9 @@ static const struct of_device_id mtk_spmi_match_table[] = { { .compatible = "mediatek,mt6873-spmi", .data = &mt6873_pmif_arb, + }, { + .compatible = "mediatek,mt8189-spmi", + .data = &mt8195_pmif_arb,
This change is useless. Just add the compatible to the bindings so that you can specify
compatible = "mediatek,mt8189-spmi", "mediatek,mt8195-spmi";
Regards,
Angelo
PATCH 3/3 regulator: Modify mt6315 regulator mode mask
In reply to niklaus.liuModify mt6315 regulator mode mask, compatible with all 6315 models
--- drivers/regulator/mt6315-regulator.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/regulator/mt6315-regulator.c +6 -0
@@ -218,8 +218,10 @@ static int mt6315_regulator_probe(struct spmi_device *pdev)struct regmap *regmap;struct mt6315_chip *chip;struct mt_regulator_init_data *init_data; +struct device_node *node = pdev->dev.of_node;struct regulator_config config = {};struct regulator_dev *rdev; +unsigned int val =0 ;int i; regmap =devm_regmap_init_spmi_ext (pdev, &mt6315_regmap_config);
@@ -247,6 +249,10 @@ static int mt6315_regulator_probe(struct spmi_device *pdev) init_data->modeset_mask[MT6315_VBUCK1 ] =BIT (MT6315_VBUCK1 );break ; } + +if (!of_property_read_u32 (node,"buck1-modeset-mask" , &val)) + init_data->modeset_mask[MT6315_VBUCK1 ] = val; +for (i =MT6315_VBUCK2 ; i <MT6315_VBUCK_MAX ; i++) init_data->modeset_mask[i] =BIT (i);
Signature · 1 line
2.46.0
Re: [PATCH 3/3] regulator: Modify mt6315 regulator mode mask
Quoted 24 lines · niklaus.liu
Modify mt6315 regulator mode mask, compatible with all 6315 models
Signed-off-by niklaus.liu <[email protected]>--- drivers/regulator/mt6315-regulator.c | 6 ++++++ 1 file changed, 6 insertions(+)drivers/regulator/mt6315-regulator.c +2
-0@@ -218,8 +218,10 @@ static int mt6315_regulator_probe(struct spmi_device *pdev)struct regmap *regmap;struct mt6315_chip *chip;struct mt_regulator_init_data *init_data; +struct device_node *node = pdev->dev.of_node;struct regulator_config config = {};struct regulator_dev *rdev; +unsigned int val =0 ;int i; regmap =devm_regmap_init_spmi_ext (pdev, &mt6315_regmap_config);
drivers/regulator/mt6315-regulator.c static int mt6315_regulator_probe(struct spmi_device *pdev) · line 255
Quoted 7 lines
drivers/regulator/mt6315-regulator.c +4
-0@@ -247,6 +249,10 @@ static int mt6315_regulator_probe(struct spmi_device *pdev) init_data->modeset_mask[MT6315_VBUCK1 ] =BIT (MT6315_VBUCK1 );break ; } + +if (!of_property_read_u32 (node,"buck1-modeset-mask" , &val)) + init_data->modeset_mask[MT6315_VBUCK1 ] = val; +
This needs a matching change to the DT bindings.
However, please take a look at Angelo's recent series [1] for MT8196 PMICs that also adds variants of the MT6316 series regulators and how it adds compatible strings for various parts to cover 2-phase, 3-phase, and 4-phase settings.
Now personally I think a better way would be if we could somehow read back
a) the part number, or b) the multi-phase settings from the chip itself, and derive modeset_mask automatically. Is that possible? Can MediaTek share this information?
ChenYu
Quoted 7 lines
drivers/regulator/mt6315-regulator.c +0
-1for (i =MT6315_VBUCK2 ; i <MT6315_VBUCK_MAX ; i++) init_data->modeset_mask[i] =BIT (i); --2.46.0