[PATCH v3 2/4] soc: mediatek: mtk-pmic-pwrap: Skip WDT source and init on arbiter SoCs
From: Ilia Snezhkov via B4 Relay
Date: Wed Nov 25 2026 - 22:10:31 EST
From: Ilia Snezhkov <iasnezhkov@xxxxxxxxx>
Commit 9d498d0b4043 ("soc: mediatek: pwrap: add arbiter capability")
added PWRAP_CAP_ARB for PMIF-SPI arbiter SoCs (MT6873, MT8195, and the
upcoming MT6789), where the bootloader already initializes the wrapper
and the watchdog registers (PWRAP_WDT_UNIT, PWRAP_WDT_SRC_EN, and
PWRAP_WDT_SRC_EN_1) are absent from the per-SoC register tables.
However, pwrap_probe() only guarded PWRAP_WDT_UNIT with
!HAS_CAP(wrp->master->caps, PWRAP_CAP_ARB), leaving the writes to
PWRAP_WDT_SRC_EN and PWRAP_WDT_SRC_EN_1 unconditional. Because omitted
entries in static const int regs[] default to 0, those writes land at
offset 0x0 (PWRAP_INIT_DONE2) and overwrite it with wdt_src
(0xffffffff) on every probe. Similarly, falling into pwrap_init() on
PWRAP_CAP_ARB SoCs would write legacy non-arbiter registers whose
offsets also default to 0x0.
Extend the !HAS_CAP(wrp->master->caps, PWRAP_CAP_ARB) guard in
pwrap_probe() to cover PWRAP_WDT_SRC_EN, PWRAP_WDT_SRC_EN_1, and the
cold pwrap_init() fallback.
Fixes: 9d498d0b4043 ("soc: mediatek: pwrap: add arbiter capability")
Signed-off-by: Ilia Snezhkov <iasnezhkov@xxxxxxxxx>
---
New in v3 (caught during v2 review). Drafted with an AI coding assistant.
drivers/soc/mediatek/mtk-pmic-wrap.c | 21 ++++++++++++---------
1 file changed, 12 insertions(+), 9 deletions(-)
diff --git a/drivers/soc/mediatek/mtk-pmic-wrap.c b/drivers/soc/mediatek/mtk-pmic-wrap.c
index 9067718..6b0d462 100644
--- a/drivers/soc/mediatek/mtk-pmic-wrap.c
+++ b/drivers/soc/mediatek/mtk-pmic-wrap.c
@@ -2533,7 +2533,8 @@ static int pwrap_probe(struct platform_device *pdev)
* The PMIC could already be initialized by the bootloader.
* Skip initialization here in this case.
*/
- if (!pwrap_readl(wrp, PWRAP_INIT_DONE2)) {
+ if (!HAS_CAP(wrp->master->caps, PWRAP_CAP_ARB) &&
+ !pwrap_readl(wrp, PWRAP_INIT_DONE2)) {
ret = pwrap_init(wrp);
if (ret) {
dev_dbg(wrp->dev, "init failed with %d\n", ret);
@@ -2554,16 +2555,18 @@ static int pwrap_probe(struct platform_device *pdev)
}
/* Initialize watchdog, may not be done by the bootloader */
- if (!HAS_CAP(wrp->master->caps, PWRAP_CAP_ARB))
+ if (!HAS_CAP(wrp->master->caps, PWRAP_CAP_ARB)) {
pwrap_writel(wrp, 0xf, PWRAP_WDT_UNIT);
- /*
- * Since STAUPD was not used on mt8173 platform,
- * so STAUPD of WDT_SRC which should be turned off
- */
- pwrap_writel(wrp, wrp->master->wdt_src, PWRAP_WDT_SRC_EN);
- if (HAS_CAP(wrp->master->caps, PWRAP_CAP_WDT_SRC1))
- pwrap_writel(wrp, wrp->master->wdt_src, PWRAP_WDT_SRC_EN_1);
+ /*
+ * Since STAUPD was not used on mt8173 platform,
+ * so STAUPD of WDT_SRC which should be turned off
+ */
+ pwrap_writel(wrp, wrp->master->wdt_src, PWRAP_WDT_SRC_EN);
+ if (HAS_CAP(wrp->master->caps, PWRAP_CAP_WDT_SRC1))
+ pwrap_writel(wrp, wrp->master->wdt_src,
+ PWRAP_WDT_SRC_EN_1);
+ }
if (HAS_CAP(wrp->master->caps, PWRAP_CAP_ARB))
pwrap_writel(wrp, 0x3, PWRAP_TIMER_EN);
--
2.54.0 (Apple Git-157)