Devicetree
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Ilia Snezhkov" <iasnezhkov@gmail.com>
Cc: devicetree@vger.kernel.org, robh@kernel.org, conor+dt@kernel.org
Subject: Re: [PATCH v2 2/3] soc: mediatek: mtk-pmic-pwrap: Add MT6789 support
Date: Thu, 26 Nov 2026 00:21:30 +0000	[thread overview]
Message-ID: <sashiko-outbox-234462@kernel.org> (raw)
In-Reply-To: <20261126000711.16163-3-iasnezhkov@gmail.com>

Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [High] soc: mediatek: pwrap: missing INT_FLG and INT_CLR offsets in
  mt6789_regs
- [Medium] soc: mediatek: pwrap: unmapped WDT_SRC_EN and init writes to
  0x0 on MT6789
--

commit f63c0f3d9c9912d15ad03c4814d1837bc4e482d8
Author: Arseniy Velikanov <me@adomerle.pw>

soc: mediatek: mtk-pmic-pwrap: Add MT6789 support

This commit adds PMIC wrapper register definitions, cipher handling, wrapper
parameters, and device tree match table entry for the MediaTek MT6789 SoC.

> diff --git a/drivers/soc/mediatek/mtk-pmic-wrap.c b/drivers/soc/mediatek/mtk-pmic-wrap.c
> index 90677187c3b56..c74e9164f3343 100644
> --- a/drivers/soc/mediatek/mtk-pmic-wrap.c
> +++ b/drivers/soc/mediatek/mtk-pmic-wrap.c
> @@ -640,6 +640,17 @@ static const int mt6779_regs[] = {
>  	[PWRAP_WACS2_VLDCLR] =		0xC28,
>  };
>  
> +static const int mt6789_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,
> +};

[Severity: High]
Should mt6789_regs[] also define PWRAP_INT_FLG and PWRAP_INT_CLR?

Because both are omitted here, their offsets default to 0x0
(PWRAP_INIT_DONE2).  pwrap_probe() enables interrupts in PWRAP_INT_EN with
int_en_all = 0x180000 and registers pwrap_interrupt() with IRQF_TRIGGER_HIGH:

drivers/soc/mediatek/mtk-pmic-wrap.c:pwrap_interrupt() {
	rdata = pwrap_readl(wrp, PWRAP_INT_FLG);
	dev_err(wrp->dev, "unexpected interrupt int=0x%x\n", rdata);
	pwrap_writel(wrp, 0xffffffff, PWRAP_INT_CLR);

	return IRQ_HANDLED;
}

When an enabled interrupt fires, pwrap_interrupt() reads and writes
0xffffffff to offset 0x0 instead of clearing the interrupt status register,
leaving the level-high IRQ asserted and causing an interrupt storm.  (Comparing
with mt8195_regs[], which shares these register offsets and int_en_all =
0x180000, 0x450 is bank 1 INT1_EN with flag and clear at 0x458 and 0x45c,
while bank 0 INT_EN/FLG/CLR are at 0x420/0x428/0x42c.)

[ ... ]

> @@ -1852,6 +1864,7 @@ static int pwrap_init_cipher(struct pmic_wrapper *wrp)
>  	case PWRAP_MT7622:
>  		pwrap_writel(wrp, 0, PWRAP_CIPHER_EN);
>  		break;
> +	case PWRAP_MT6789:
>  	case PWRAP_MT6873:
>  	case PWRAP_MT8183:
>  	case PWRAP_MT8195:
> @@ -2302,6 +2315,19 @@ static const struct pmic_wrapper_type pwrap_mt6779 = {
>  	.init_soc_specific = NULL,
>  };
>  
> +static const struct pmic_wrapper_type pwrap_mt6789 = {
> +	.regs = mt6789_regs,
> +	.type = PWRAP_MT6789,
> +	.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,
> +};

[Severity: Medium]
Does probing pwrap_mt6789 overwrite PWRAP_INIT_DONE2 at offset 0x0 with
wdt_src (0xffffffff)?

In pwrap_probe(), the PWRAP_CAP_ARB check added by 9d498d0b4043 ("soc:
mediatek: pwrap: add arbiter capability") only guards PWRAP_WDT_UNIT, while
PWRAP_WDT_SRC_EN is written unconditionally:

drivers/soc/mediatek/mtk-pmic-wrap.c:pwrap_probe() {
	...
	if (!HAS_CAP(wrp->master->caps, PWRAP_CAP_ARB))
		pwrap_writel(wrp, 0xf, PWRAP_WDT_UNIT);

	pwrap_writel(wrp, wrp->master->wdt_src, PWRAP_WDT_SRC_EN);
	...
}

Since PWRAP_WDT_SRC_EN is not in mt6789_regs[], its offset is 0x0, so every
probe writes 0xffffffff to PWRAP_INIT_DONE2.  In addition, this patch adds
PWRAP_MT6789 to pwrap_init_cipher(), but mt6789_regs[] omits all cipher and
initialization registers used by pwrap_init() and pwrap_init_cipher(), so
if PWRAP_INIT_DONE2 is not already set by the bootloader, those writes will
also hit offset 0x0.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261126000711.16163-1-iasnezhkov@gmail.com?part=2

  reply	other threads:[~2026-11-26  0:21 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-26  0:07 [PATCH v2 0/3] soc/spi: mediatek: Add MT6789 PMIC wrapper and SPI support Ilia Snezhkov via B4 Relay
2026-11-26  0:07 ` [PATCH v2 1/3] dt-bindings: soc: mediatek: pwrap: Add compatible for MT6789 Ilia Snezhkov via B4 Relay
2026-11-26  0:07 ` [PATCH v2 2/3] soc: mediatek: mtk-pmic-pwrap: Add MT6789 support Ilia Snezhkov via B4 Relay
2026-11-26  0:21   ` sashiko-bot [this message]
2026-11-26  0:07 ` [PATCH v2 3/3] dt-bindings: spi: mediatek,spi-mt65xx: Add compatible for MT6789 Ilia Snezhkov via B4 Relay

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=sashiko-outbox-234462@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=iasnezhkov@gmail.com \
    --cc=robh@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox