From: Nicolas Frattaroli <nicolas.frattaroli@collabora.com>
To: linux-mediatek@lists.infradead.org,
angelogioacchino.delregno@collabora.com
Cc: lee@kernel.org, robh@kernel.org, krzk+dt@kernel.org,
conor+dt@kernel.org, matthias.bgg@gmail.com, lgirdwood@gmail.com,
broonie@kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org, kernel@collabora.com,
wenst@chromium.org, igor.belwon@mentallysanemainliners.org,
"Nícolas F. R. A. Prado" <nfraprado@collabora.com>,
"AngeloGioacchino Del Regno"
<angelogioacchino.delregno@collabora.com>
Subject: Re: [PATCH v8 9/9] drivers: mfd: Add support for MediaTek SPMI PMICs and MT6363/73
Date: Thu, 09 Oct 2025 22:15:01 +0200 [thread overview]
Message-ID: <14451186.uLZWGnKmhe@workhorse> (raw)
In-Reply-To: <20251003091158.26748-10-angelogioacchino.delregno@collabora.com>
On Friday, 3 October 2025 11:11:58 Central European Summer Time AngeloGioacchino Del Regno wrote:
> This driver adds support for the MediaTek SPMI PMICs and their
> interrupt controller (which is present in 95% of the cases).
>
> Other than probing all of the sub-devices of a SPMI PMIC, this
> sets up a regmap from the relevant SPMI bus and initializes an
> interrupt controller with its irq domain and irqchip to handle
> chained interrupts, with the SPMI bus itself being its parent
> irq controller, and the PMIC being the outmost device.
>
> This driver hence holds all of the information about a specific
> PMIC's interrupts and will properly handle them, calling the
> ISR for any subdevice that requested an interrupt.
>
> As for the interrupt spec, this driver wants 3 interrupt cells,
> but ignores the first one: this is because of how this first
> revision of the MediaTek SPMI 2.0 Controller works, which does
> not hold irq number information in its register, but delegates
> that to the SPMI device - it's possible that this will change
> in the future with a newer revision of the controller IP, and
> this is the main reason for that.
>
> To make use of this implementation, this driver also adds the
> required bits to support MediaTek MT6363 and MT6373 SPMI PMICs.
>
> Reviewed-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>
> Signed-off-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
> ---
> drivers/mfd/Kconfig | 17 ++
> drivers/mfd/Makefile | 1 +
> drivers/mfd/mtk-spmi-pmic.c | 410 ++++++++++++++++++++++++++++++++++++
> include/linux/mfd/mt6363.h | 26 +++
> include/linux/mfd/mt6373.h | 21 ++
> 5 files changed, 475 insertions(+)
> create mode 100644 drivers/mfd/mtk-spmi-pmic.c
> create mode 100644 include/linux/mfd/mt6363.h
> create mode 100644 include/linux/mfd/mt6373.h
Hi Angelo, came across something suspicious here while debugging why
I ran into IRQ parsing from DT issues here.
>
> [...]
> diff --git a/drivers/mfd/mtk-spmi-pmic.c b/drivers/mfd/mtk-spmi-pmic.c
> new file mode 100644
> index 000000000000..512b53bdb0d1
> --- /dev/null
> +++ b/drivers/mfd/mtk-spmi-pmic.c
> [...]
> +
> +static int mtk_spmi_pmic_irq_xlate(struct irq_domain *d, struct device_node *ctrlr,
> + const u32 *intspec, unsigned int intsize,
> + unsigned long *out_hwirq, unsigned int *out_type)
> +{
> + struct mtk_spmi_pmic *pmic = d->host_data;
> + struct device *dev = pmic->dev;
> + struct irq_fwspec fwspec;
> +
> + of_phandle_args_to_fwspec(ctrlr, intspec, intsize, &fwspec);
> + if (WARN_ON(fwspec.param_count < 3))
> + return -EINVAL;
What's the point of fwspec here? The caller in
irqdomain.c::irq_domain_translate has an fwspec, converts it to an
of_node with the intsize/intspec args, then passes it to this function,
which builds it back into an fwspec just to check fwspec.param_count,
which is equal intsize.
fwspec is then never used again.
Just check intsize instead, it's precisely that value.
spmi-mtk-pmif.c::mtk_spmi_rcs_irq_xlate does the same thing, which also
seems pointless.
> +
> + /*
> + * The IRQ number in intspec[0] is ignored on purpose here!
> + *
> + * This is because of how at least the first revision of the SPMI 2.0
> + * controller works in MediaTek SoCs: the controller will raise an
> + * interrupt for each SID (but doesn't know the details!), and the
> + * specific IRQ number that got raised must be read from the PMIC or
> + * its sub-device driver.
> + * It's possible that this will change in the future with a newer
> + * revision of the SPMI controller, and this is why the devicetree
> + * holds the full intspec.
> + */
> + *out_hwirq = intspec[1];
> + *out_type = intspec[2] & IRQ_TYPE_SENSE_MASK;
> +
> + dev_dbg(dev, "Found device IRQ %u chained from SPMI IRQ %x (map: 0x%lx)\n",
> + intspec[1], intspec[0], *out_hwirq);
> +
> + return 0;
> +}
> +
> +static const struct irq_domain_ops mtk_spmi_pmic_irq_domain_ops = {
> + .map = mtk_spmi_pmic_irq_domain_map,
> + .xlate = mtk_spmi_pmic_irq_xlate,
> +};
> +
> [...]
Kind regards,
Nicolas Frattaroli
next prev parent reply other threads:[~2025-10-09 20:15 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-03 9:11 [PATCH v8 0/9] Add support MT6316/6363/MT6373 PMICs regulators and MFD AngeloGioacchino Del Regno
2025-10-03 9:11 ` [PATCH v8 1/9] dt-bindings: regulator: Document MediaTek MT6316 PMIC Regulators AngeloGioacchino Del Regno
2025-10-09 19:18 ` Rob Herring
2025-10-03 9:11 ` [PATCH v8 2/9] regulator: Add support for MediaTek MT6316 SPMI " AngeloGioacchino Del Regno
2025-10-10 21:17 ` kernel test robot
2025-10-03 9:11 ` [PATCH v8 3/9] dt-bindings: regulator: Document MediaTek MT6363 " AngeloGioacchino Del Regno
2025-10-03 9:11 ` [PATCH v8 4/9] regulator: Add support for MediaTek MT6363 SPMI " AngeloGioacchino Del Regno
2025-10-09 14:41 ` Nicolas Frattaroli
2025-10-14 11:35 ` AngeloGioacchino Del Regno
2025-10-14 12:35 ` Mark Brown
2025-10-03 9:11 ` [PATCH v8 5/9] dt-bindings: regulator: Document MediaTek MT6373 " AngeloGioacchino Del Regno
2025-10-09 19:21 ` Rob Herring (Arm)
2025-10-03 9:11 ` [PATCH v8 6/9] regulator: Add support for MediaTek MT6373 SPMI " AngeloGioacchino Del Regno
2025-10-11 5:32 ` kernel test robot
2025-10-03 9:11 ` [PATCH v8 7/9] dt-bindings: iio: adc: mt6359: Allow reg for SPMI PMICs AuxADC AngeloGioacchino Del Regno
2025-10-03 9:11 ` [PATCH v8 8/9] dt-bindings: mfd: Add binding for MediaTek MT6363 series SPMI PMIC AngeloGioacchino Del Regno
2025-10-09 19:24 ` Rob Herring
2025-10-03 9:11 ` [PATCH v8 9/9] drivers: mfd: Add support for MediaTek SPMI PMICs and MT6363/73 AngeloGioacchino Del Regno
2025-10-09 20:15 ` Nicolas Frattaroli [this message]
2025-10-23 13:53 ` Lee Jones
2025-10-24 6:03 ` AngeloGioacchino Del Regno
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=14451186.uLZWGnKmhe@workhorse \
--to=nicolas.frattaroli@collabora.com \
--cc=angelogioacchino.delregno@collabora.com \
--cc=broonie@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=igor.belwon@mentallysanemainliners.org \
--cc=kernel@collabora.com \
--cc=krzk+dt@kernel.org \
--cc=lee@kernel.org \
--cc=lgirdwood@gmail.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=matthias.bgg@gmail.com \
--cc=nfraprado@collabora.com \
--cc=robh@kernel.org \
--cc=wenst@chromium.org \
/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;
as well as URLs for NNTP newsgroup(s).