* [PATCH 0/3] soc: mediatek: pwrap: mt6572 support + log level fixes
@ 2026-07-14 12:42 ` Roman Vivchar
0 siblings, 0 replies; 15+ messages in thread
From: Roman Vivchar via B4 Relay @ 2026-07-14 12:42 UTC (permalink / raw)
To: Rob Herring, Krzysztof Kozlowski, Conor Dooley, Matthias Brugger,
AngeloGioacchino Del Regno, Flora Fu, Alexandre Mergnat
Cc: devicetree, linux-kernel, linux-arm-kernel, linux-mediatek,
Roman Vivchar
This patch series adds support for the mt6572 pwrap.
All known mt6572 devices use mt6323 PMIC, which is already supported
by the upstream drivers. mt6572 also shares SoC-specific init with
mt2701.
Patch 1 adds dt-bindings compatible.
Patch 2 fixes improper log levels in the driver, improving UX when
debugging.
Patch 3 adds mt6572 support.
Tested on various mt6572 devices without any failures.
Signed-off-by: Roman Vivchar <rva333@protonmail.com>
---
Roman Vivchar (3):
dt-bindings: soc: mediatek: pwrap: add mt6572
soc: mediatek: pwrap: use correct log level
soc: mediatek: pwrap: add mt6572 support
.../bindings/soc/mediatek/mediatek,pwrap.yaml | 1 +
drivers/soc/mediatek/mtk-pmic-wrap.c | 156 +++++++++++++++++----
2 files changed, 129 insertions(+), 28 deletions(-)
---
base-commit: 8cd9520d35a6c38db6567e97dd93b1f11f185dc6
change-id: 20260712-6572-pwrap-4c91563cfd23
Best regards,
--
Roman Vivchar <rva333@protonmail.com>
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH 0/3] soc: mediatek: pwrap: mt6572 support + log level fixes
@ 2026-07-14 12:42 ` Roman Vivchar
0 siblings, 0 replies; 15+ messages in thread
From: Roman Vivchar @ 2026-07-14 12:42 UTC (permalink / raw)
To: Rob Herring, Krzysztof Kozlowski, Conor Dooley, Matthias Brugger,
AngeloGioacchino Del Regno, Flora Fu, Alexandre Mergnat
Cc: devicetree, linux-kernel, linux-arm-kernel, linux-mediatek,
Roman Vivchar
This patch series adds support for the mt6572 pwrap.
All known mt6572 devices use mt6323 PMIC, which is already supported
by the upstream drivers. mt6572 also shares SoC-specific init with
mt2701.
Patch 1 adds dt-bindings compatible.
Patch 2 fixes improper log levels in the driver, improving UX when
debugging.
Patch 3 adds mt6572 support.
Tested on various mt6572 devices without any failures.
Signed-off-by: Roman Vivchar <rva333@protonmail.com>
---
Roman Vivchar (3):
dt-bindings: soc: mediatek: pwrap: add mt6572
soc: mediatek: pwrap: use correct log level
soc: mediatek: pwrap: add mt6572 support
.../bindings/soc/mediatek/mediatek,pwrap.yaml | 1 +
drivers/soc/mediatek/mtk-pmic-wrap.c | 156 +++++++++++++++++----
2 files changed, 129 insertions(+), 28 deletions(-)
---
base-commit: 8cd9520d35a6c38db6567e97dd93b1f11f185dc6
change-id: 20260712-6572-pwrap-4c91563cfd23
Best regards,
--
Roman Vivchar <rva333@protonmail.com>
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH 1/3] dt-bindings: soc: mediatek: pwrap: add mt6572
2026-07-14 12:42 ` Roman Vivchar
@ 2026-07-14 12:42 ` Roman Vivchar
-1 siblings, 0 replies; 15+ messages in thread
From: Roman Vivchar via B4 Relay @ 2026-07-14 12:42 UTC (permalink / raw)
To: Rob Herring, Krzysztof Kozlowski, Conor Dooley, Matthias Brugger,
AngeloGioacchino Del Regno, Flora Fu, Alexandre Mergnat
Cc: devicetree, linux-kernel, linux-arm-kernel, linux-mediatek,
Roman Vivchar
From: Roman Vivchar <rva333@protonmail.com>
Add a compatible string for the mt6572 SoC.
Signed-off-by: Roman Vivchar <rva333@protonmail.com>
---
Documentation/devicetree/bindings/soc/mediatek/mediatek,pwrap.yaml | 1 +
1 file changed, 1 insertion(+)
diff --git a/Documentation/devicetree/bindings/soc/mediatek/mediatek,pwrap.yaml b/Documentation/devicetree/bindings/soc/mediatek/mediatek,pwrap.yaml
index e7c4a3984c60..a3cf11153fba 100644
--- a/Documentation/devicetree/bindings/soc/mediatek/mediatek,pwrap.yaml
+++ b/Documentation/devicetree/bindings/soc/mediatek/mediatek,pwrap.yaml
@@ -31,6 +31,7 @@ properties:
- items:
- enum:
- mediatek,mt2701-pwrap
+ - mediatek,mt6572-pwrap
- mediatek,mt6765-pwrap
- mediatek,mt6779-pwrap
- mediatek,mt6795-pwrap
--
2.54.0
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH 1/3] dt-bindings: soc: mediatek: pwrap: add mt6572
@ 2026-07-14 12:42 ` Roman Vivchar
0 siblings, 0 replies; 15+ messages in thread
From: Roman Vivchar @ 2026-07-14 12:42 UTC (permalink / raw)
To: Rob Herring, Krzysztof Kozlowski, Conor Dooley, Matthias Brugger,
AngeloGioacchino Del Regno, Flora Fu, Alexandre Mergnat
Cc: devicetree, linux-kernel, linux-arm-kernel, linux-mediatek,
Roman Vivchar
Add a compatible string for the mt6572 SoC.
Signed-off-by: Roman Vivchar <rva333@protonmail.com>
---
Documentation/devicetree/bindings/soc/mediatek/mediatek,pwrap.yaml | 1 +
1 file changed, 1 insertion(+)
diff --git a/Documentation/devicetree/bindings/soc/mediatek/mediatek,pwrap.yaml b/Documentation/devicetree/bindings/soc/mediatek/mediatek,pwrap.yaml
index e7c4a3984c60..a3cf11153fba 100644
--- a/Documentation/devicetree/bindings/soc/mediatek/mediatek,pwrap.yaml
+++ b/Documentation/devicetree/bindings/soc/mediatek/mediatek,pwrap.yaml
@@ -31,6 +31,7 @@ properties:
- items:
- enum:
- mediatek,mt2701-pwrap
+ - mediatek,mt6572-pwrap
- mediatek,mt6765-pwrap
- mediatek,mt6779-pwrap
- mediatek,mt6795-pwrap
--
2.54.0
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH 2/3] soc: mediatek: pwrap: use correct log level
2026-07-14 12:42 ` Roman Vivchar
@ 2026-07-14 12:42 ` Roman Vivchar
-1 siblings, 0 replies; 15+ messages in thread
From: Roman Vivchar via B4 Relay @ 2026-07-14 12:42 UTC (permalink / raw)
To: Rob Herring, Krzysztof Kozlowski, Conor Dooley, Matthias Brugger,
AngeloGioacchino Del Regno, Flora Fu, Alexandre Mergnat
Cc: devicetree, linux-kernel, linux-arm-kernel, linux-mediatek,
Roman Vivchar
From: Roman Vivchar <rva333@protonmail.com>
Errors paths should be dev_err, not dev_dbg. Replace all dev_dbg in error
branches to have the correct log level. Also simplify dev_err and return
with dev_err_probe.
Signed-off-by: Roman Vivchar <rva333@protonmail.com>
---
drivers/soc/mediatek/mtk-pmic-wrap.c | 45 ++++++++++++++----------------------
1 file changed, 17 insertions(+), 28 deletions(-)
diff --git a/drivers/soc/mediatek/mtk-pmic-wrap.c b/drivers/soc/mediatek/mtk-pmic-wrap.c
index 0bcd85826375..a4b10b0a97cb 100644
--- a/drivers/soc/mediatek/mtk-pmic-wrap.c
+++ b/drivers/soc/mediatek/mtk-pmic-wrap.c
@@ -2475,10 +2475,9 @@ static int pwrap_probe(struct platform_device *pdev)
if (np->child)
of_slave_id = of_match_node(of_slave_match_tbl, np->child);
- if (!of_slave_id) {
- dev_dbg(&pdev->dev, "slave pmic should be defined in dts\n");
- return -EINVAL;
- }
+ if (!of_slave_id)
+ return dev_err_probe(&pdev->dev, -EINVAL,
+ "slave pmic should be defined in dts\n");
wrp = devm_kzalloc(&pdev->dev, sizeof(*wrp), GFP_KERNEL);
if (!wrp)
@@ -2496,11 +2495,9 @@ static int pwrap_probe(struct platform_device *pdev)
if (HAS_CAP(wrp->master->caps, PWRAP_CAP_RESET)) {
wrp->rstc = devm_reset_control_get(wrp->dev, "pwrap");
- if (IS_ERR(wrp->rstc)) {
- ret = PTR_ERR(wrp->rstc);
- dev_dbg(wrp->dev, "cannot get pwrap reset: %d\n", ret);
- return ret;
- }
+ if (IS_ERR(wrp->rstc))
+ return dev_err_probe(wrp->dev, PTR_ERR(wrp->rstc),
+ "cannot get pwrap reset\n");
}
if (HAS_CAP(wrp->master->caps, PWRAP_CAP_BRIDGE)) {
@@ -2510,12 +2507,9 @@ static int pwrap_probe(struct platform_device *pdev)
wrp->rstc_bridge = devm_reset_control_get(wrp->dev,
"pwrap-bridge");
- if (IS_ERR(wrp->rstc_bridge)) {
- ret = PTR_ERR(wrp->rstc_bridge);
- dev_dbg(wrp->dev,
- "cannot get pwrap-bridge reset: %d\n", ret);
- return ret;
- }
+ if (IS_ERR(wrp->rstc_bridge))
+ return dev_err_probe(wrp->dev, PTR_ERR(wrp->rstc_bridge),
+ "cannot get pwrap-bridge reset\n");
}
ret = devm_clk_bulk_get_all_enabled(wrp->dev, &clk);
@@ -2535,10 +2529,8 @@ static int pwrap_probe(struct platform_device *pdev)
*/
if (!pwrap_readl(wrp, PWRAP_INIT_DONE2)) {
ret = pwrap_init(wrp);
- if (ret) {
- dev_dbg(wrp->dev, "init failed with %d\n", ret);
- return ret;
- }
+ if (ret)
+ return dev_err_probe(wrp->dev, ret, "init failed\n");
}
if (HAS_CAP(wrp->master->caps, PWRAP_CAP_ARB))
@@ -2548,10 +2540,9 @@ static int pwrap_probe(struct platform_device *pdev)
else
mask_done = PWRAP_STATE_INIT_DONE0;
- if (!(pwrap_readl(wrp, PWRAP_WACS2_RDATA) & mask_done)) {
- dev_dbg(wrp->dev, "initialization isn't finished\n");
- return -ENODEV;
- }
+ if (!(pwrap_readl(wrp, PWRAP_WACS2_RDATA) & mask_done))
+ return dev_err_probe(wrp->dev, -ENODEV,
+ "initialization isn't finished\n");
/* Initialize watchdog, may not be done by the bootloader */
if (!HAS_CAP(wrp->master->caps, PWRAP_CAP_ARB))
@@ -2593,11 +2584,9 @@ static int pwrap_probe(struct platform_device *pdev)
return PTR_ERR(wrp->regmap);
ret = of_platform_populate(np, NULL, NULL, wrp->dev);
- if (ret) {
- dev_dbg(wrp->dev, "failed to create child devices at %pOF\n",
- np);
- return ret;
- }
+ if (ret)
+ return dev_err_probe(wrp->dev, ret,
+ "failed to create child devices at %pOF\n", np);
return 0;
}
--
2.54.0
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH 2/3] soc: mediatek: pwrap: use correct log level
@ 2026-07-14 12:42 ` Roman Vivchar
0 siblings, 0 replies; 15+ messages in thread
From: Roman Vivchar @ 2026-07-14 12:42 UTC (permalink / raw)
To: Rob Herring, Krzysztof Kozlowski, Conor Dooley, Matthias Brugger,
AngeloGioacchino Del Regno, Flora Fu, Alexandre Mergnat
Cc: devicetree, linux-kernel, linux-arm-kernel, linux-mediatek,
Roman Vivchar
Errors paths should be dev_err, not dev_dbg. Replace all dev_dbg in error
branches to have the correct log level. Also simplify dev_err and return
with dev_err_probe.
Signed-off-by: Roman Vivchar <rva333@protonmail.com>
---
drivers/soc/mediatek/mtk-pmic-wrap.c | 45 ++++++++++++++----------------------
1 file changed, 17 insertions(+), 28 deletions(-)
diff --git a/drivers/soc/mediatek/mtk-pmic-wrap.c b/drivers/soc/mediatek/mtk-pmic-wrap.c
index 0bcd85826375..a4b10b0a97cb 100644
--- a/drivers/soc/mediatek/mtk-pmic-wrap.c
+++ b/drivers/soc/mediatek/mtk-pmic-wrap.c
@@ -2475,10 +2475,9 @@ static int pwrap_probe(struct platform_device *pdev)
if (np->child)
of_slave_id = of_match_node(of_slave_match_tbl, np->child);
- if (!of_slave_id) {
- dev_dbg(&pdev->dev, "slave pmic should be defined in dts\n");
- return -EINVAL;
- }
+ if (!of_slave_id)
+ return dev_err_probe(&pdev->dev, -EINVAL,
+ "slave pmic should be defined in dts\n");
wrp = devm_kzalloc(&pdev->dev, sizeof(*wrp), GFP_KERNEL);
if (!wrp)
@@ -2496,11 +2495,9 @@ static int pwrap_probe(struct platform_device *pdev)
if (HAS_CAP(wrp->master->caps, PWRAP_CAP_RESET)) {
wrp->rstc = devm_reset_control_get(wrp->dev, "pwrap");
- if (IS_ERR(wrp->rstc)) {
- ret = PTR_ERR(wrp->rstc);
- dev_dbg(wrp->dev, "cannot get pwrap reset: %d\n", ret);
- return ret;
- }
+ if (IS_ERR(wrp->rstc))
+ return dev_err_probe(wrp->dev, PTR_ERR(wrp->rstc),
+ "cannot get pwrap reset\n");
}
if (HAS_CAP(wrp->master->caps, PWRAP_CAP_BRIDGE)) {
@@ -2510,12 +2507,9 @@ static int pwrap_probe(struct platform_device *pdev)
wrp->rstc_bridge = devm_reset_control_get(wrp->dev,
"pwrap-bridge");
- if (IS_ERR(wrp->rstc_bridge)) {
- ret = PTR_ERR(wrp->rstc_bridge);
- dev_dbg(wrp->dev,
- "cannot get pwrap-bridge reset: %d\n", ret);
- return ret;
- }
+ if (IS_ERR(wrp->rstc_bridge))
+ return dev_err_probe(wrp->dev, PTR_ERR(wrp->rstc_bridge),
+ "cannot get pwrap-bridge reset\n");
}
ret = devm_clk_bulk_get_all_enabled(wrp->dev, &clk);
@@ -2535,10 +2529,8 @@ static int pwrap_probe(struct platform_device *pdev)
*/
if (!pwrap_readl(wrp, PWRAP_INIT_DONE2)) {
ret = pwrap_init(wrp);
- if (ret) {
- dev_dbg(wrp->dev, "init failed with %d\n", ret);
- return ret;
- }
+ if (ret)
+ return dev_err_probe(wrp->dev, ret, "init failed\n");
}
if (HAS_CAP(wrp->master->caps, PWRAP_CAP_ARB))
@@ -2548,10 +2540,9 @@ static int pwrap_probe(struct platform_device *pdev)
else
mask_done = PWRAP_STATE_INIT_DONE0;
- if (!(pwrap_readl(wrp, PWRAP_WACS2_RDATA) & mask_done)) {
- dev_dbg(wrp->dev, "initialization isn't finished\n");
- return -ENODEV;
- }
+ if (!(pwrap_readl(wrp, PWRAP_WACS2_RDATA) & mask_done))
+ return dev_err_probe(wrp->dev, -ENODEV,
+ "initialization isn't finished\n");
/* Initialize watchdog, may not be done by the bootloader */
if (!HAS_CAP(wrp->master->caps, PWRAP_CAP_ARB))
@@ -2593,11 +2584,9 @@ static int pwrap_probe(struct platform_device *pdev)
return PTR_ERR(wrp->regmap);
ret = of_platform_populate(np, NULL, NULL, wrp->dev);
- if (ret) {
- dev_dbg(wrp->dev, "failed to create child devices at %pOF\n",
- np);
- return ret;
- }
+ if (ret)
+ return dev_err_probe(wrp->dev, ret,
+ "failed to create child devices at %pOF\n", np);
return 0;
}
--
2.54.0
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH 3/3] soc: mediatek: pwrap: add mt6572 support
2026-07-14 12:42 ` Roman Vivchar
@ 2026-07-14 12:42 ` Roman Vivchar
-1 siblings, 0 replies; 15+ messages in thread
From: Roman Vivchar via B4 Relay @ 2026-07-14 12:42 UTC (permalink / raw)
To: Rob Herring, Krzysztof Kozlowski, Conor Dooley, Matthias Brugger,
AngeloGioacchino Del Regno, Flora Fu, Alexandre Mergnat
Cc: devicetree, linux-kernel, linux-arm-kernel, linux-mediatek,
Roman Vivchar
From: Roman Vivchar <rva333@protonmail.com>
Add mt6572 registers and platform data for the pmic wrapper.
The mt2701 SoC-specific initialization function is used because they
share the same GPS_INTF settings.
Signed-off-by: Roman Vivchar <rva333@protonmail.com>
---
drivers/soc/mediatek/mtk-pmic-wrap.c | 111 +++++++++++++++++++++++++++++++++++
1 file changed, 111 insertions(+)
diff --git a/drivers/soc/mediatek/mtk-pmic-wrap.c b/drivers/soc/mediatek/mtk-pmic-wrap.c
index a4b10b0a97cb..4b8a5dc80a36 100644
--- a/drivers/soc/mediatek/mtk-pmic-wrap.c
+++ b/drivers/soc/mediatek/mtk-pmic-wrap.c
@@ -569,6 +569,96 @@ static const int mt2701_regs[] = {
[PWRAP_ADC_RDATA_ADDR2] = 0x154,
};
+static const int mt6572_regs[] = {
+ [PWRAP_MUX_SEL] = 0x0,
+ [PWRAP_WRAP_EN] = 0x4,
+ [PWRAP_DIO_EN] = 0x8,
+ [PWRAP_SIDLY] = 0xc,
+ [PWRAP_OP_TYPE] = 0x10,
+ [PWRAP_MSB_FIRST] = 0x14,
+ [PWRAP_RDDMY] = 0x18,
+ [PWRAP_SI_CK_CON] = 0x1c,
+ [PWRAP_CSHEXT_WRITE] = 0x20,
+ [PWRAP_CSHEXT_READ] = 0x24,
+ [PWRAP_CSLEXT_START] = 0x28,
+ [PWRAP_CSLEXT_END] = 0x2c,
+ [PWRAP_STAUPD_PRD] = 0x30,
+ [PWRAP_STAUPD_GRPEN] = 0x34,
+ [PWRAP_STAUPD_MAN_TRIG] = 0x38,
+ [PWRAP_STAUPD_STA] = 0x3c,
+ [PWRAP_GPS_STA] = 0x40,
+ [PWRAP_WRAP_STA] = 0x44,
+ [PWRAP_HARB_INIT] = 0x48,
+ [PWRAP_HARB_HPRIO] = 0x4c,
+ [PWRAP_HIPRIO_ARB_EN] = 0x50,
+ [PWRAP_HARB_STA0] = 0x54,
+ [PWRAP_HARB_STA1] = 0x58,
+ [PWRAP_MAN_EN] = 0x5c,
+ [PWRAP_MAN_CMD] = 0x60,
+ [PWRAP_MAN_RDATA] = 0x64,
+ [PWRAP_MAN_VLDCLR] = 0x68,
+ [PWRAP_WACS0_EN] = 0x6c,
+ [PWRAP_INIT_DONE0] = 0x70,
+ [PWRAP_WACS0_CMD] = 0x74,
+ [PWRAP_WACS0_RDATA] = 0x78,
+ [PWRAP_WACS0_VLDCLR] = 0x7c,
+ [PWRAP_WACS1_EN] = 0x80,
+ [PWRAP_INIT_DONE1] = 0x84,
+ [PWRAP_WACS1_CMD] = 0x88,
+ [PWRAP_WACS1_RDATA] = 0x8c,
+ [PWRAP_WACS1_VLDCLR] = 0x90,
+ [PWRAP_WACS2_EN] = 0x94,
+ [PWRAP_INIT_DONE2] = 0x98,
+ [PWRAP_WACS2_CMD] = 0x9c,
+ [PWRAP_WACS2_RDATA] = 0xa0,
+ [PWRAP_WACS2_VLDCLR] = 0xa4,
+ [PWRAP_INT_EN] = 0xa8,
+ [PWRAP_INT_FLG_RAW] = 0xac,
+ [PWRAP_INT_FLG] = 0xb0,
+ [PWRAP_INT_CLR] = 0xb4,
+ [PWRAP_SIG_ADR] = 0xb8,
+ [PWRAP_SIG_MODE] = 0xbc,
+ [PWRAP_SIG_VALUE] = 0xc0,
+ [PWRAP_SIG_ERRVAL] = 0xc4,
+ [PWRAP_CRC_EN] = 0xc8,
+ [PWRAP_TIMER_EN] = 0xcc,
+ [PWRAP_TIMER_STA] = 0xd0,
+ [PWRAP_WDT_UNIT] = 0xd4,
+ [PWRAP_WDT_SRC_EN] = 0xd8,
+ [PWRAP_WDT_FLG] = 0xdc,
+ [PWRAP_DEBUG_INT_SEL] = 0xe0,
+ [PWRAP_DVFS_ADR0] = 0xe4,
+ [PWRAP_DVFS_WDATA0] = 0xe8,
+ [PWRAP_DVFS_ADR1] = 0xec,
+ [PWRAP_DVFS_WDATA1] = 0xf0,
+ [PWRAP_DVFS_ADR2] = 0xf4,
+ [PWRAP_DVFS_WDATA2] = 0xf8,
+ [PWRAP_DVFS_ADR3] = 0xfc,
+ [PWRAP_DVFS_WDATA3] = 0x100,
+ [PWRAP_DVFS_ADR4] = 0x104,
+ [PWRAP_DVFS_WDATA4] = 0x108,
+ [PWRAP_DVFS_ADR5] = 0x10c,
+ [PWRAP_DVFS_WDATA5] = 0x110,
+ [PWRAP_DVFS_ADR6] = 0x114,
+ [PWRAP_DVFS_WDATA6] = 0x118,
+ [PWRAP_DVFS_ADR7] = 0x11c,
+ [PWRAP_DVFS_WDATA7] = 0x120,
+ [PWRAP_CIPHER_KEY_SEL] = 0x124,
+ [PWRAP_CIPHER_IV_SEL] = 0x128,
+ [PWRAP_CIPHER_EN] = 0x12c,
+ [PWRAP_CIPHER_RDY] = 0x130,
+ [PWRAP_CIPHER_MODE] = 0x134,
+ [PWRAP_CIPHER_SWRST] = 0x138,
+ [PWRAP_DCM_EN] = 0x13c,
+ [PWRAP_DCM_DBC_PRD] = 0x140,
+ [PWRAP_ADC_CMD_ADDR] = 0x144,
+ [PWRAP_PWRAP_ADC_CMD] = 0x148,
+ [PWRAP_ADC_RDY_ADDR] = 0x14c,
+ [PWRAP_ADC_RDATA_ADDR1] = 0x150,
+ [PWRAP_ADC_RDATA_ADDR2] = 0x154,
+ [PWRAP_SW_RST] = 0x180,
+};
+
static const int mt6765_regs[] = {
[PWRAP_MUX_SEL] = 0x0,
[PWRAP_WRAP_EN] = 0x4,
@@ -1314,6 +1404,7 @@ enum pmic_type {
enum pwrap_type {
PWRAP_MT2701,
+ PWRAP_MT6572,
PWRAP_MT6765,
PWRAP_MT6779,
PWRAP_MT6795,
@@ -1733,6 +1824,11 @@ static void pwrap_init_chip_select_ext(struct pmic_wrapper *wrp, u8 hext_write,
static int pwrap_common_init_reg_clock(struct pmic_wrapper *wrp)
{
switch (wrp->master->type) {
+ case PWRAP_MT6572:
+ pwrap_writel(wrp, 0x8, PWRAP_RDDMY);
+ pwrap_write(wrp, wrp->slave->dew_regs[PWRAP_DEW_RDDMY_NO], 0x8);
+ pwrap_init_chip_select_ext(wrp, 5, 0, 0, 0);
+ break;
case PWRAP_MT6795:
if (wrp->slave->type == PMIC_MT6331) {
const u32 *dew_regs = wrp->slave->dew_regs;
@@ -1839,6 +1935,7 @@ static int pwrap_init_cipher(struct pmic_wrapper *wrp)
pwrap_writel(wrp, 1, PWRAP_CIPHER_START);
break;
case PWRAP_MT2701:
+ case PWRAP_MT6572:
case PWRAP_MT6765:
case PWRAP_MT6779:
case PWRAP_MT6795:
@@ -2277,6 +2374,19 @@ static const struct pmic_wrapper_type pwrap_mt2701 = {
.init_soc_specific = pwrap_mt2701_init_soc_specific,
};
+static const struct pmic_wrapper_type pwrap_mt6572 = {
+ .regs = mt6572_regs,
+ .type = PWRAP_MT6572,
+ .arb_en_all = 0x1ff,
+ .int_en_all = 0x7ffffffd,
+ .int1_en_all = 0,
+ .spi_w = PWRAP_MAN_CMD_SPI_WRITE,
+ .wdt_src = PWRAP_WDT_SRC_MASK_ALL,
+ .caps = PWRAP_CAP_RESET | PWRAP_CAP_DCM,
+ .init_reg_clock = pwrap_common_init_reg_clock,
+ .init_soc_specific = pwrap_mt2701_init_soc_specific,
+};
+
static const struct pmic_wrapper_type pwrap_mt6765 = {
.regs = mt6765_regs,
.type = PWRAP_MT6765,
@@ -2446,6 +2556,7 @@ static const struct pmic_wrapper_type pwrap_mt8186 = {
static const struct of_device_id of_pwrap_match_tbl[] = {
{ .compatible = "mediatek,mt2701-pwrap", .data = &pwrap_mt2701 },
+ { .compatible = "mediatek,mt6572-pwrap", .data = &pwrap_mt6572 },
{ .compatible = "mediatek,mt6765-pwrap", .data = &pwrap_mt6765 },
{ .compatible = "mediatek,mt6779-pwrap", .data = &pwrap_mt6779 },
{ .compatible = "mediatek,mt6795-pwrap", .data = &pwrap_mt6795 },
--
2.54.0
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH 3/3] soc: mediatek: pwrap: add mt6572 support
@ 2026-07-14 12:42 ` Roman Vivchar
0 siblings, 0 replies; 15+ messages in thread
From: Roman Vivchar @ 2026-07-14 12:42 UTC (permalink / raw)
To: Rob Herring, Krzysztof Kozlowski, Conor Dooley, Matthias Brugger,
AngeloGioacchino Del Regno, Flora Fu, Alexandre Mergnat
Cc: devicetree, linux-kernel, linux-arm-kernel, linux-mediatek,
Roman Vivchar
Add mt6572 registers and platform data for the pmic wrapper.
The mt2701 SoC-specific initialization function is used because they
share the same GPS_INTF settings.
Signed-off-by: Roman Vivchar <rva333@protonmail.com>
---
drivers/soc/mediatek/mtk-pmic-wrap.c | 111 +++++++++++++++++++++++++++++++++++
1 file changed, 111 insertions(+)
diff --git a/drivers/soc/mediatek/mtk-pmic-wrap.c b/drivers/soc/mediatek/mtk-pmic-wrap.c
index a4b10b0a97cb..4b8a5dc80a36 100644
--- a/drivers/soc/mediatek/mtk-pmic-wrap.c
+++ b/drivers/soc/mediatek/mtk-pmic-wrap.c
@@ -569,6 +569,96 @@ static const int mt2701_regs[] = {
[PWRAP_ADC_RDATA_ADDR2] = 0x154,
};
+static const int mt6572_regs[] = {
+ [PWRAP_MUX_SEL] = 0x0,
+ [PWRAP_WRAP_EN] = 0x4,
+ [PWRAP_DIO_EN] = 0x8,
+ [PWRAP_SIDLY] = 0xc,
+ [PWRAP_OP_TYPE] = 0x10,
+ [PWRAP_MSB_FIRST] = 0x14,
+ [PWRAP_RDDMY] = 0x18,
+ [PWRAP_SI_CK_CON] = 0x1c,
+ [PWRAP_CSHEXT_WRITE] = 0x20,
+ [PWRAP_CSHEXT_READ] = 0x24,
+ [PWRAP_CSLEXT_START] = 0x28,
+ [PWRAP_CSLEXT_END] = 0x2c,
+ [PWRAP_STAUPD_PRD] = 0x30,
+ [PWRAP_STAUPD_GRPEN] = 0x34,
+ [PWRAP_STAUPD_MAN_TRIG] = 0x38,
+ [PWRAP_STAUPD_STA] = 0x3c,
+ [PWRAP_GPS_STA] = 0x40,
+ [PWRAP_WRAP_STA] = 0x44,
+ [PWRAP_HARB_INIT] = 0x48,
+ [PWRAP_HARB_HPRIO] = 0x4c,
+ [PWRAP_HIPRIO_ARB_EN] = 0x50,
+ [PWRAP_HARB_STA0] = 0x54,
+ [PWRAP_HARB_STA1] = 0x58,
+ [PWRAP_MAN_EN] = 0x5c,
+ [PWRAP_MAN_CMD] = 0x60,
+ [PWRAP_MAN_RDATA] = 0x64,
+ [PWRAP_MAN_VLDCLR] = 0x68,
+ [PWRAP_WACS0_EN] = 0x6c,
+ [PWRAP_INIT_DONE0] = 0x70,
+ [PWRAP_WACS0_CMD] = 0x74,
+ [PWRAP_WACS0_RDATA] = 0x78,
+ [PWRAP_WACS0_VLDCLR] = 0x7c,
+ [PWRAP_WACS1_EN] = 0x80,
+ [PWRAP_INIT_DONE1] = 0x84,
+ [PWRAP_WACS1_CMD] = 0x88,
+ [PWRAP_WACS1_RDATA] = 0x8c,
+ [PWRAP_WACS1_VLDCLR] = 0x90,
+ [PWRAP_WACS2_EN] = 0x94,
+ [PWRAP_INIT_DONE2] = 0x98,
+ [PWRAP_WACS2_CMD] = 0x9c,
+ [PWRAP_WACS2_RDATA] = 0xa0,
+ [PWRAP_WACS2_VLDCLR] = 0xa4,
+ [PWRAP_INT_EN] = 0xa8,
+ [PWRAP_INT_FLG_RAW] = 0xac,
+ [PWRAP_INT_FLG] = 0xb0,
+ [PWRAP_INT_CLR] = 0xb4,
+ [PWRAP_SIG_ADR] = 0xb8,
+ [PWRAP_SIG_MODE] = 0xbc,
+ [PWRAP_SIG_VALUE] = 0xc0,
+ [PWRAP_SIG_ERRVAL] = 0xc4,
+ [PWRAP_CRC_EN] = 0xc8,
+ [PWRAP_TIMER_EN] = 0xcc,
+ [PWRAP_TIMER_STA] = 0xd0,
+ [PWRAP_WDT_UNIT] = 0xd4,
+ [PWRAP_WDT_SRC_EN] = 0xd8,
+ [PWRAP_WDT_FLG] = 0xdc,
+ [PWRAP_DEBUG_INT_SEL] = 0xe0,
+ [PWRAP_DVFS_ADR0] = 0xe4,
+ [PWRAP_DVFS_WDATA0] = 0xe8,
+ [PWRAP_DVFS_ADR1] = 0xec,
+ [PWRAP_DVFS_WDATA1] = 0xf0,
+ [PWRAP_DVFS_ADR2] = 0xf4,
+ [PWRAP_DVFS_WDATA2] = 0xf8,
+ [PWRAP_DVFS_ADR3] = 0xfc,
+ [PWRAP_DVFS_WDATA3] = 0x100,
+ [PWRAP_DVFS_ADR4] = 0x104,
+ [PWRAP_DVFS_WDATA4] = 0x108,
+ [PWRAP_DVFS_ADR5] = 0x10c,
+ [PWRAP_DVFS_WDATA5] = 0x110,
+ [PWRAP_DVFS_ADR6] = 0x114,
+ [PWRAP_DVFS_WDATA6] = 0x118,
+ [PWRAP_DVFS_ADR7] = 0x11c,
+ [PWRAP_DVFS_WDATA7] = 0x120,
+ [PWRAP_CIPHER_KEY_SEL] = 0x124,
+ [PWRAP_CIPHER_IV_SEL] = 0x128,
+ [PWRAP_CIPHER_EN] = 0x12c,
+ [PWRAP_CIPHER_RDY] = 0x130,
+ [PWRAP_CIPHER_MODE] = 0x134,
+ [PWRAP_CIPHER_SWRST] = 0x138,
+ [PWRAP_DCM_EN] = 0x13c,
+ [PWRAP_DCM_DBC_PRD] = 0x140,
+ [PWRAP_ADC_CMD_ADDR] = 0x144,
+ [PWRAP_PWRAP_ADC_CMD] = 0x148,
+ [PWRAP_ADC_RDY_ADDR] = 0x14c,
+ [PWRAP_ADC_RDATA_ADDR1] = 0x150,
+ [PWRAP_ADC_RDATA_ADDR2] = 0x154,
+ [PWRAP_SW_RST] = 0x180,
+};
+
static const int mt6765_regs[] = {
[PWRAP_MUX_SEL] = 0x0,
[PWRAP_WRAP_EN] = 0x4,
@@ -1314,6 +1404,7 @@ enum pmic_type {
enum pwrap_type {
PWRAP_MT2701,
+ PWRAP_MT6572,
PWRAP_MT6765,
PWRAP_MT6779,
PWRAP_MT6795,
@@ -1733,6 +1824,11 @@ static void pwrap_init_chip_select_ext(struct pmic_wrapper *wrp, u8 hext_write,
static int pwrap_common_init_reg_clock(struct pmic_wrapper *wrp)
{
switch (wrp->master->type) {
+ case PWRAP_MT6572:
+ pwrap_writel(wrp, 0x8, PWRAP_RDDMY);
+ pwrap_write(wrp, wrp->slave->dew_regs[PWRAP_DEW_RDDMY_NO], 0x8);
+ pwrap_init_chip_select_ext(wrp, 5, 0, 0, 0);
+ break;
case PWRAP_MT6795:
if (wrp->slave->type == PMIC_MT6331) {
const u32 *dew_regs = wrp->slave->dew_regs;
@@ -1839,6 +1935,7 @@ static int pwrap_init_cipher(struct pmic_wrapper *wrp)
pwrap_writel(wrp, 1, PWRAP_CIPHER_START);
break;
case PWRAP_MT2701:
+ case PWRAP_MT6572:
case PWRAP_MT6765:
case PWRAP_MT6779:
case PWRAP_MT6795:
@@ -2277,6 +2374,19 @@ static const struct pmic_wrapper_type pwrap_mt2701 = {
.init_soc_specific = pwrap_mt2701_init_soc_specific,
};
+static const struct pmic_wrapper_type pwrap_mt6572 = {
+ .regs = mt6572_regs,
+ .type = PWRAP_MT6572,
+ .arb_en_all = 0x1ff,
+ .int_en_all = 0x7ffffffd,
+ .int1_en_all = 0,
+ .spi_w = PWRAP_MAN_CMD_SPI_WRITE,
+ .wdt_src = PWRAP_WDT_SRC_MASK_ALL,
+ .caps = PWRAP_CAP_RESET | PWRAP_CAP_DCM,
+ .init_reg_clock = pwrap_common_init_reg_clock,
+ .init_soc_specific = pwrap_mt2701_init_soc_specific,
+};
+
static const struct pmic_wrapper_type pwrap_mt6765 = {
.regs = mt6765_regs,
.type = PWRAP_MT6765,
@@ -2446,6 +2556,7 @@ static const struct pmic_wrapper_type pwrap_mt8186 = {
static const struct of_device_id of_pwrap_match_tbl[] = {
{ .compatible = "mediatek,mt2701-pwrap", .data = &pwrap_mt2701 },
+ { .compatible = "mediatek,mt6572-pwrap", .data = &pwrap_mt6572 },
{ .compatible = "mediatek,mt6765-pwrap", .data = &pwrap_mt6765 },
{ .compatible = "mediatek,mt6779-pwrap", .data = &pwrap_mt6779 },
{ .compatible = "mediatek,mt6795-pwrap", .data = &pwrap_mt6795 },
--
2.54.0
^ permalink raw reply related [flat|nested] 15+ messages in thread
* Re: [PATCH 2/3] soc: mediatek: pwrap: use correct log level
2026-07-14 12:42 ` Roman Vivchar
(?)
@ 2026-07-14 12:53 ` sashiko-bot
-1 siblings, 0 replies; 15+ messages in thread
From: sashiko-bot @ 2026-07-14 12:53 UTC (permalink / raw)
To: Roman Vivchar; +Cc: robh, conor+dt, devicetree
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] Child devices created by `of_platform_populate()` are leaked upon probe failure or driver unbind, leading to a Use-After-Free.
--
--- Patch [2]: [PATCH 2/3] soc: mediatek: pwrap: use correct log level ---
commit 9e7d63641cf243186ed10eee942d5eeb9f4b6345
Author: Roman Vivchar <rva333@protonmail.com>
soc: mediatek: pwrap: use correct log level
This commit updates error handling in the mediatek pwrap driver to use
dev_err_probe instead of dev_dbg for error branches. It also simplifies
the returns by utilizing dev_err_probe.
> diff --git a/drivers/soc/mediatek/mtk-pmic-wrap.c b/drivers/soc/mediatek/mtk-pmic-wrap.c
> index 0bcd858263755..a4b10b0a97cbb 100644
> --- a/drivers/soc/mediatek/mtk-pmic-wrap.c
> +++ b/drivers/soc/mediatek/mtk-pmic-wrap.c
[ ... ]
> @@ -2593,11 +2584,9 @@ static int pwrap_probe(struct platform_device *pdev)
> return PTR_ERR(wrp->regmap);
>
> ret = of_platform_populate(np, NULL, NULL, wrp->dev);
> - if (ret) {
> - dev_dbg(wrp->dev, "failed to create child devices at %pOF\n",
> - np);
> - return ret;
> - }
> + if (ret)
> + return dev_err_probe(wrp->dev, ret,
> + "failed to create child devices at %pOF\n", np);
[Severity: High]
This is a pre-existing issue, but does this missing cleanup for
of_platform_populate() leave child devices registered if this fails
halfway through, or during driver unbind?
If a user unbinds the driver via sysfs, devres will automatically free
the parent driver's resources, including wrp->regmap. Since there is no
remove callback to call of_platform_depopulate(), the child devices
remain active. When these active child drivers subsequently attempt to
use their parent's freed regmap, could this result in a use-after-free?
Would it be safer to use devm_of_platform_populate() here instead to
ensure proper cleanup?
> return 0;
> }
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260714-6572-pwrap-v1-0-d8e5a39cf7ef@protonmail.com?part=2
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH 3/3] soc: mediatek: pwrap: add mt6572 support
2026-07-14 12:42 ` Roman Vivchar
(?)
@ 2026-07-14 13:24 ` sashiko-bot
-1 siblings, 0 replies; 15+ messages in thread
From: sashiko-bot @ 2026-07-14 13:24 UTC (permalink / raw)
To: Roman Vivchar; +Cc: robh, conor+dt, devicetree
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Unconditional dereference and access of `wrp->slave->dew_regs` in MT6572 clock initialization can cause a NULL pointer dereference or unintended PMIC register overwrite.
--
--- Patch [3]: [PATCH 3/3] soc: mediatek: pwrap: add mt6572 support ---
commit 27b1606815262a3356b161758ca5a4ebb413b4ab
Author: Roman Vivchar <rva333@protonmail.com>
soc: mediatek: pwrap: add mt6572 support
This commit adds mt6572 registers and platform data for the pmic wrapper.
It reuses the mt2701 SoC-specific initialization function since they share
the same GPS_INTF settings.
> diff --git a/drivers/soc/mediatek/mtk-pmic-wrap.c b/drivers/soc/mediatek/mtk-pmic-wrap.c
> index a4b10b0a97cbb..4b8a5dc80a36e 100644
> --- a/drivers/soc/mediatek/mtk-pmic-wrap.c
> +++ b/drivers/soc/mediatek/mtk-pmic-wrap.c
[ ... ]
> @@ -1733,6 +1824,11 @@ static void pwrap_init_chip_select_ext(struct pmic_wrapper *wrp, u8 hext_write,
> static int pwrap_common_init_reg_clock(struct pmic_wrapper *wrp)
> {
> switch (wrp->master->type) {
> + case PWRAP_MT6572:
> + pwrap_writel(wrp, 0x8, PWRAP_RDDMY);
> + pwrap_write(wrp, wrp->slave->dew_regs[PWRAP_DEW_RDDMY_NO], 0x8);
[Severity: High]
Could this unconditionally dereference wrp->slave->dew_regs if the configured
slave PMIC doesn't populate it?
If the mediatek,mt6572-pwrap device node is configured with a PMIC that
doesn't populate dew_regs (like PMIC_MT6380), or leaves PWRAP_DEW_RDDMY_NO
uninitialized (like PMIC_MT6397), this array lookup could either
dereference a NULL pointer or evaluate to 0x0.
This could lead to a kernel panic during driver probe or an unintended
SPI write of 0x8 to PMIC register 0x0.
Would it be safer to validate the slave PMIC type or check that dew_regs is
present before accessing it here, similar to how it is handled for
PWRAP_MT6795 below?
> + pwrap_init_chip_select_ext(wrp, 5, 0, 0, 0);
> + break;
> case PWRAP_MT6795:
> if (wrp->slave->type == PMIC_MT6331) {
[ ... ]
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260714-6572-pwrap-v1-0-d8e5a39cf7ef@protonmail.com?part=3
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH 1/3] dt-bindings: soc: mediatek: pwrap: add mt6572
2026-07-14 12:42 ` Roman Vivchar
(?)
@ 2026-07-15 10:20 ` AngeloGioacchino Del Regno
-1 siblings, 0 replies; 15+ messages in thread
From: AngeloGioacchino Del Regno @ 2026-07-15 10:20 UTC (permalink / raw)
To: rva333, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Matthias Brugger, Flora Fu, Alexandre Mergnat
Cc: devicetree, linux-kernel, linux-arm-kernel, linux-mediatek
On 7/14/26 14:42, Roman Vivchar via B4 Relay wrote:
> From: Roman Vivchar <rva333@protonmail.com>
>
> Add a compatible string for the mt6572 SoC.
>
> Signed-off-by: Roman Vivchar <rva333@protonmail.com>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
> ---
> Documentation/devicetree/bindings/soc/mediatek/mediatek,pwrap.yaml | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/Documentation/devicetree/bindings/soc/mediatek/mediatek,pwrap.yaml b/Documentation/devicetree/bindings/soc/mediatek/mediatek,pwrap.yaml
> index e7c4a3984c60..a3cf11153fba 100644
> --- a/Documentation/devicetree/bindings/soc/mediatek/mediatek,pwrap.yaml
> +++ b/Documentation/devicetree/bindings/soc/mediatek/mediatek,pwrap.yaml
> @@ -31,6 +31,7 @@ properties:
> - items:
> - enum:
> - mediatek,mt2701-pwrap
> + - mediatek,mt6572-pwrap
> - mediatek,mt6765-pwrap
> - mediatek,mt6779-pwrap
> - mediatek,mt6795-pwrap
>
--
AngeloGioacchino Del Regno
Senior Software Engineer
Collabora Ltd.
Platinum Building, St John's Innovation Park, Cambridge CB4 0DS, UK
Registered in England & Wales, no. 5513718
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH 2/3] soc: mediatek: pwrap: use correct log level
2026-07-14 12:42 ` Roman Vivchar
(?)
(?)
@ 2026-07-15 10:20 ` AngeloGioacchino Del Regno
-1 siblings, 0 replies; 15+ messages in thread
From: AngeloGioacchino Del Regno @ 2026-07-15 10:20 UTC (permalink / raw)
To: rva333, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Matthias Brugger, Flora Fu, Alexandre Mergnat
Cc: devicetree, linux-kernel, linux-arm-kernel, linux-mediatek
On 7/14/26 14:42, Roman Vivchar via B4 Relay wrote:
> From: Roman Vivchar <rva333@protonmail.com>
>
> Errors paths should be dev_err, not dev_dbg. Replace all dev_dbg in error
> branches to have the correct log level. Also simplify dev_err and return
> with dev_err_probe.
>
> Signed-off-by: Roman Vivchar <rva333@protonmail.com>
Yeah.... I agree.
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
> ---
> drivers/soc/mediatek/mtk-pmic-wrap.c | 45 ++++++++++++++----------------------
> 1 file changed, 17 insertions(+), 28 deletions(-)
>
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH 3/3] soc: mediatek: pwrap: add mt6572 support
2026-07-14 12:42 ` Roman Vivchar
(?)
(?)
@ 2026-07-15 10:20 ` AngeloGioacchino Del Regno
2026-07-15 11:24 ` Roman Vivchar
-1 siblings, 1 reply; 15+ messages in thread
From: AngeloGioacchino Del Regno @ 2026-07-15 10:20 UTC (permalink / raw)
To: rva333, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Matthias Brugger, Flora Fu, Alexandre Mergnat
Cc: devicetree, linux-kernel, linux-arm-kernel, linux-mediatek
On 7/14/26 14:42, Roman Vivchar via B4 Relay wrote:
> From: Roman Vivchar <rva333@protonmail.com>
>
> Add mt6572 registers and platform data for the pmic wrapper.
> The mt2701 SoC-specific initialization function is used because they
> share the same GPS_INTF settings.
>
> Signed-off-by: Roman Vivchar <rva333@protonmail.com>
> ---
> drivers/soc/mediatek/mtk-pmic-wrap.c | 111 +++++++++++++++++++++++++++++++++++
> 1 file changed, 111 insertions(+)
>
> diff --git a/drivers/soc/mediatek/mtk-pmic-wrap.c b/drivers/soc/mediatek/mtk-pmic-wrap.c
> index a4b10b0a97cb..4b8a5dc80a36 100644
> --- a/drivers/soc/mediatek/mtk-pmic-wrap.c
> +++ b/drivers/soc/mediatek/mtk-pmic-wrap.c
> @@ -569,6 +569,96 @@ static const int mt2701_regs[] = {
> [PWRAP_ADC_RDATA_ADDR2] = 0x154,
> };
>
..snip..
>
> +static const struct pmic_wrapper_type pwrap_mt6572 = {
> + .regs = mt6572_regs,
MT6572 only has PWRAP_OP_TYPE, PWRAP_MSB_FIRST, PWRAP_GPS_STA additional registers
compared to MT2701, and the three are currently unused.
Instead of adding yet one more huge array for 3 more registers, since I'm mostly
sure that those will never be used anyway (happy if you prove me wrong!), you can
at this point just use mt2701_regs for mt6572.
Perhaps, add a comment saying that MT6572 does indeed have those additional regs
but were omitted because currently unused.
So, something like
/*
* MT6572 has additional registers OP_TYPE (0x10), MSB_FIRST (0x14), GPS_STA (0x40)
* which were omitted as they're currently unused in this driver.
* Apart from that, the register map matches the one from MT2701.
*/
static const struct pmic_wrapper_type pwrap_mt6572 = {
.regs = mt2701_regs,
Cheers,
Angelo
> + .type = PWRAP_MT6572,
> + .arb_en_all = 0x1ff,
> + .int_en_all = 0x7ffffffd,
> + .int1_en_all = 0,
> + .spi_w = PWRAP_MAN_CMD_SPI_WRITE,
> + .wdt_src = PWRAP_WDT_SRC_MASK_ALL,
> + .caps = PWRAP_CAP_RESET | PWRAP_CAP_DCM,
> + .init_reg_clock = pwrap_common_init_reg_clock,
> + .init_soc_specific = pwrap_mt2701_init_soc_specific,
> +};
> +
> static const struct pmic_wrapper_type pwrap_mt6765 = {
> .regs = mt6765_regs,
> .type = PWRAP_MT6765,
> @@ -2446,6 +2556,7 @@ static const struct pmic_wrapper_type pwrap_mt8186 = {
>
> static const struct of_device_id of_pwrap_match_tbl[] = {
> { .compatible = "mediatek,mt2701-pwrap", .data = &pwrap_mt2701 },
> + { .compatible = "mediatek,mt6572-pwrap", .data = &pwrap_mt6572 },
> { .compatible = "mediatek,mt6765-pwrap", .data = &pwrap_mt6765 },
> { .compatible = "mediatek,mt6779-pwrap", .data = &pwrap_mt6779 },
> { .compatible = "mediatek,mt6795-pwrap", .data = &pwrap_mt6795 },
>
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH 3/3] soc: mediatek: pwrap: add mt6572 support
2026-07-15 10:20 ` AngeloGioacchino Del Regno
@ 2026-07-15 11:24 ` Roman Vivchar
2026-07-15 12:01 ` AngeloGioacchino Del Regno
0 siblings, 1 reply; 15+ messages in thread
From: Roman Vivchar @ 2026-07-15 11:24 UTC (permalink / raw)
To: AngeloGioacchino Del Regno
Cc: Rob Herring, Krzysztof Kozlowski, Conor Dooley, Matthias Brugger,
Flora Fu, Alexandre Mergnat, devicetree, linux-kernel,
linux-arm-kernel, linux-mediatek
Hi AngeloGioacchino,
On Wednesday, July 15th, 2026 at 1:21 PM, AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> wrote:
> On 7/14/26 14:42, Roman Vivchar via B4 Relay wrote:
...
> >
> > +static const struct pmic_wrapper_type pwrap_mt6572 = {
> > + .regs = mt6572_regs,
>
> MT6572 only has PWRAP_OP_TYPE, PWRAP_MSB_FIRST, PWRAP_GPS_STA additional registers
> compared to MT2701, and the three are currently unused.
GPS_STA is indeed unused. As for others, downstream kernel includes mt6320 path.
//###############################
//Enable 6320 option
//###############################
#ifdef SLV_6320
WRAP_WR32(PMIC_WRAP_OP_TYPE ,OP_TYPE_CSL);
WRAP_WR32(PMIC_WRAP_MSB_FIRST , LSB);
#endif
Though I haven't seen any mt6572 device with the mt6320 so far, as well as
pwrap_init_chip_select_ext is configured for the mt6323.
> Instead of adding yet one more huge array for 3 more registers, since I'm mostly
> sure that those will never be used anyway (happy if you prove me wrong!), you can
> at this point just use mt2701_regs for mt6572.
>
> Perhaps, add a comment saying that MT6572 does indeed have those additional regs
> but were omitted because currently unused.
>
> So, something like
>
> /*
> * MT6572 has additional registers OP_TYPE (0x10), MSB_FIRST (0x14), GPS_STA (0x40)
> * which were omitted as they're currently unused in this driver.
> * Apart from that, the register map matches the one from MT2701.
> */
> static const struct pmic_wrapper_type pwrap_mt6572 = {
> .regs = mt2701_regs,
>
I'm not a big fan of dead code, but at some point the mt6572+mt6320 may exist.
Would you suggest keeping mt6572 array or drop it until some mt6320
device appears?
Best regards,
Roman
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH 3/3] soc: mediatek: pwrap: add mt6572 support
2026-07-15 11:24 ` Roman Vivchar
@ 2026-07-15 12:01 ` AngeloGioacchino Del Regno
0 siblings, 0 replies; 15+ messages in thread
From: AngeloGioacchino Del Regno @ 2026-07-15 12:01 UTC (permalink / raw)
To: Roman Vivchar
Cc: Rob Herring, Krzysztof Kozlowski, Conor Dooley, Matthias Brugger,
Flora Fu, Alexandre Mergnat, devicetree, linux-kernel,
linux-arm-kernel, linux-mediatek
On 7/15/26 13:24, Roman Vivchar wrote:
> Hi AngeloGioacchino,
>
> On Wednesday, July 15th, 2026 at 1:21 PM, AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> wrote:
>
>> On 7/14/26 14:42, Roman Vivchar via B4 Relay wrote:
>
> ...
>
>>>
>>> +static const struct pmic_wrapper_type pwrap_mt6572 = {
>>> + .regs = mt6572_regs,
>>
>> MT6572 only has PWRAP_OP_TYPE, PWRAP_MSB_FIRST, PWRAP_GPS_STA additional registers
>> compared to MT2701, and the three are currently unused.
>
> GPS_STA is indeed unused. As for others, downstream kernel includes mt6320 path.
>
> //###############################
> //Enable 6320 option
> //###############################
> #ifdef SLV_6320
> WRAP_WR32(PMIC_WRAP_OP_TYPE ,OP_TYPE_CSL);
> WRAP_WR32(PMIC_WRAP_MSB_FIRST , LSB);
> #endif
>
> Though I haven't seen any mt6572 device with the mt6320 so far, as well as
> pwrap_init_chip_select_ext is configured for the mt6323.
>
>> Instead of adding yet one more huge array for 3 more registers, since I'm mostly
>> sure that those will never be used anyway (happy if you prove me wrong!), you can
>> at this point just use mt2701_regs for mt6572.
>>
>> Perhaps, add a comment saying that MT6572 does indeed have those additional regs
>> but were omitted because currently unused.
>>
>> So, something like
>>
>> /*
>> * MT6572 has additional registers OP_TYPE (0x10), MSB_FIRST (0x14), GPS_STA (0x40)
>> * which were omitted as they're currently unused in this driver.
>> * Apart from that, the register map matches the one from MT2701.
>> */
>> static const struct pmic_wrapper_type pwrap_mt6572 = {
>> .regs = mt2701_regs,
>>
>
> I'm not a big fan of dead code, but at some point the mt6572+mt6320 may exist.
> Would you suggest keeping mt6572 array or drop it until some mt6320
> device appears?
>
Nah, please, drop it until some MT6320 device appears.
Besides, you also said that you haven't seen any MT6572 w/6320 so far, so it's
even more unlikely that we'll ever see one.
While at it, could you please also add the information about MT6320 cases in
the commit description?
Something like "blahblah additional registers blahblah omitted, those seem to
be used only when the MT6572 is paired with a MT6320 PMIC blahblah" :-)
Cheers,
Angelo
^ permalink raw reply [flat|nested] 15+ messages in thread
end of thread, other threads:[~2026-07-15 12:01 UTC | newest]
Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-14 12:42 [PATCH 0/3] soc: mediatek: pwrap: mt6572 support + log level fixes Roman Vivchar via B4 Relay
2026-07-14 12:42 ` Roman Vivchar
2026-07-14 12:42 ` [PATCH 1/3] dt-bindings: soc: mediatek: pwrap: add mt6572 Roman Vivchar via B4 Relay
2026-07-14 12:42 ` Roman Vivchar
2026-07-15 10:20 ` AngeloGioacchino Del Regno
2026-07-14 12:42 ` [PATCH 2/3] soc: mediatek: pwrap: use correct log level Roman Vivchar via B4 Relay
2026-07-14 12:42 ` Roman Vivchar
2026-07-14 12:53 ` sashiko-bot
2026-07-15 10:20 ` AngeloGioacchino Del Regno
2026-07-14 12:42 ` [PATCH 3/3] soc: mediatek: pwrap: add mt6572 support Roman Vivchar via B4 Relay
2026-07-14 12:42 ` Roman Vivchar
2026-07-14 13:24 ` sashiko-bot
2026-07-15 10:20 ` AngeloGioacchino Del Regno
2026-07-15 11:24 ` Roman Vivchar
2026-07-15 12:01 ` AngeloGioacchino Del Regno
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.