* [PATCH 1/2] dt-bindings: interrupt-controller: Add MT8196 SMMU wrapper
2026-11-17 17:31 [PATCH 0/2] Add MediaTek MT8196 SMMU wrapper interrupt controller Alexandre Mergnat
@ 2026-11-17 17:31 ` Alexandre Mergnat
2026-12-01 2:50 ` Rob Herring (Arm)
2026-11-17 17:31 ` [PATCH 2/2] irqchip: Add MediaTek SMMU wrapper driver Alexandre Mergnat
1 sibling, 1 reply; 4+ messages in thread
From: Alexandre Mergnat @ 2026-11-17 17:31 UTC (permalink / raw)
To: Rob Herring, Krzysztof Kozlowski, Conor Dooley, Matthias Brugger,
AngeloGioacchino Del Regno, Thomas Gleixner, Radu Rendec
Cc: linux-arm-kernel, devicetree, linux-kernel, linux-mediatek,
Alexandre Mergnat
On MT8196, a MediaTek wrapper holds the integration settings of the
multimedia SMMUv3 and merges its interrupts into one GIC line.
Describe it as an interrupt controller, in its own node next to
the SMMU.
Signed-off-by: Alexandre Mergnat <amergnat@baylibre.com>
---
.../mediatek,mt8196-smmu-wp.yaml | 70 ++++++++++++++++++++++
MAINTAINERS | 6 ++
2 files changed, 76 insertions(+)
diff --git a/Documentation/devicetree/bindings/interrupt-controller/mediatek,mt8196-smmu-wp.yaml b/Documentation/devicetree/bindings/interrupt-controller/mediatek,mt8196-smmu-wp.yaml
new file mode 100644
index 000000000000..b841d9d0e3fc
--- /dev/null
+++ b/Documentation/devicetree/bindings/interrupt-controller/mediatek,mt8196-smmu-wp.yaml
@@ -0,0 +1,70 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/interrupt-controller/mediatek,mt8196-smmu-wp.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: MediaTek MT8196 SMMU Wrapper Interrupt Controller
+
+maintainers:
+ - Alexandre Mergnat <amergnat@baylibre.com>
+
+description:
+ The multimedia SMMUv3 of MT8196 is integrated with a wrapper block that
+ collects the interrupt outputs of the SMMU into a single interrupt line.
+ The wrapper latches each SMMU interrupt and keeps that line asserted
+ until the latched interrupts are acknowledged in the wrapper. The
+ wrapper also holds integration settings of the SMMU, such as clock
+ gating and system level cache attributes.
+
+properties:
+ compatible:
+ const: mediatek,mt8196-mm-smmu-wp
+
+ reg:
+ maxItems: 1
+
+ interrupts:
+ maxItems: 1
+
+ interrupt-controller: true
+
+ '#interrupt-cells':
+ const: 1
+ description: |
+ The SMMU interrupt source:
+ 0 - Global error
+ 1 - CMD_SYNC complete
+ 2 - Event queue not empty
+ 3 - PRI queue not empty
+ 4 - Performance monitor
+ 5 - RAS critical error
+ 6 - RAS error recovery
+ 7 - RAS fault handling
+
+ power-domains:
+ maxItems: 1
+
+required:
+ - compatible
+ - reg
+ - interrupts
+ - interrupt-controller
+ - '#interrupt-cells'
+ - power-domains
+
+additionalProperties: false
+
+examples:
+ - |
+ #include <dt-bindings/interrupt-controller/arm-gic.h>
+ #include <dt-bindings/power/mediatek,mt8196-power.h>
+
+ interrupt-controller@309e0000 {
+ compatible = "mediatek,mt8196-mm-smmu-wp";
+ reg = <0x309e0000 0x1000>;
+ interrupts = <GIC_SPI 477 IRQ_TYPE_LEVEL_HIGH>;
+ interrupt-controller;
+ #interrupt-cells = <1>;
+ power-domains = <&hfrpsys_hwv MT8196_POWER_DOMAIN_MM_INFRA1>;
+ };
diff --git a/MAINTAINERS b/MAINTAINERS
index fe23913b1e43..5cc65a753ad2 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -17223,6 +17223,12 @@ F: Documentation/devicetree/bindings/memory-controllers/mediatek,smi*
F: drivers/memory/mtk-smi.c
F: include/soc/mediatek/smi.h
+MEDIATEK SMMU WRAPPER INTERRUPT CONTROLLER DRIVER
+M: Alexandre Mergnat <amergnat@baylibre.com>
+L: linux-mediatek@lists.infradead.org (moderated for non-subscribers)
+S: Maintained
+F: Documentation/devicetree/bindings/interrupt-controller/mediatek,mt8196-smmu-wp.yaml
+
MEDIATEK SWITCH DRIVER
M: Chester A. Unal <chester.a.unal@arinc9.com>
M: Daniel Golle <daniel@makrotopia.org>
--
2.43.0
^ permalink raw reply [flat|nested] 4+ messages in thread* [PATCH 2/2] irqchip: Add MediaTek SMMU wrapper driver
2026-11-17 17:31 [PATCH 0/2] Add MediaTek MT8196 SMMU wrapper interrupt controller Alexandre Mergnat
2026-11-17 17:31 ` [PATCH 1/2] dt-bindings: interrupt-controller: Add MT8196 SMMU wrapper Alexandre Mergnat
@ 2026-11-17 17:31 ` Alexandre Mergnat
1 sibling, 0 replies; 4+ messages in thread
From: Alexandre Mergnat @ 2026-11-17 17:31 UTC (permalink / raw)
To: Rob Herring, Krzysztof Kozlowski, Conor Dooley, Matthias Brugger,
AngeloGioacchino Del Regno, Thomas Gleixner, Radu Rendec
Cc: linux-arm-kernel, devicetree, linux-kernel, linux-mediatek,
Alexandre Mergnat
On MT8196, each interrupt of the multimedia SMMUv3 must be acknowledged
in a MediaTek wrapper, which otherwise keeps its GIC line asserted.
Add a driver for the wrapper as a chained interrupt controller.
Signed-off-by: Alexandre Mergnat <amergnat@baylibre.com>
---
MAINTAINERS | 1 +
drivers/irqchip/Kconfig | 11 +++
drivers/irqchip/Makefile | 1 +
drivers/irqchip/irq-mtk-smmu-wp.c | 145 ++++++++++++++++++++++++++++++++++++++
4 files changed, 158 insertions(+)
diff --git a/MAINTAINERS b/MAINTAINERS
index 5cc65a753ad2..36866ba47912 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -17228,6 +17228,7 @@ M: Alexandre Mergnat <amergnat@baylibre.com>
L: linux-mediatek@lists.infradead.org (moderated for non-subscribers)
S: Maintained
F: Documentation/devicetree/bindings/interrupt-controller/mediatek,mt8196-smmu-wp.yaml
+F: drivers/irqchip/irq-mtk-smmu-wp.c
MEDIATEK SWITCH DRIVER
M: Chester A. Unal <chester.a.unal@arinc9.com>
diff --git a/drivers/irqchip/Kconfig b/drivers/irqchip/Kconfig
index 2edf121c7841..2773515f1dd4 100644
--- a/drivers/irqchip/Kconfig
+++ b/drivers/irqchip/Kconfig
@@ -866,4 +866,15 @@ config IRQCHIP_XILINX_SMMU_CSR
ZynqMP-class platforms where a vendor CSR block mediates SMMU
interrupts.
+config MTK_SMMU_WP
+ bool "MediaTek SMMU wrapper interrupt controller"
+ depends on (ARCH_MEDIATEK && ARM64) || COMPILE_TEST
+ default ARCH_MEDIATEK && ARM64
+ select IRQ_DOMAIN
+ help
+ Support for the wrapper block that MediaTek integrates
+ with the multimedia SMMUv3 of MT8196.
+ The interrupts of that SMMU do not work without this
+ driver.
+
endmenu
diff --git a/drivers/irqchip/Makefile b/drivers/irqchip/Makefile
index eb539d41251e..573b6c06fe06 100644
--- a/drivers/irqchip/Makefile
+++ b/drivers/irqchip/Makefile
@@ -73,6 +73,7 @@ obj-$(CONFIG_BRCMSTB_L2_IRQ) += irq-brcmstb-l2.o
obj-$(CONFIG_KEYSTONE_IRQ) += irq-keystone.o
obj-$(CONFIG_MIPS_GIC) += irq-mips-gic.o
obj-$(CONFIG_MTK_IRQ) += irq-mtk-sysirq.o irq-mtk-cirq.o
+obj-$(CONFIG_MTK_SMMU_WP) += irq-mtk-smmu-wp.o
obj-$(CONFIG_ARCH_DIGICOLOR) += irq-digicolor.o
obj-$(CONFIG_ARCH_SA1100) += irq-sa11x0.o
obj-$(CONFIG_INGENIC_IRQ) += irq-ingenic.o
diff --git a/drivers/irqchip/irq-mtk-smmu-wp.c b/drivers/irqchip/irq-mtk-smmu-wp.c
new file mode 100644
index 000000000000..6e5172d18b14
--- /dev/null
+++ b/drivers/irqchip/irq-mtk-smmu-wp.c
@@ -0,0 +1,145 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * MediaTek SMMU wrapper interrupt controller
+ *
+ * Copyright (C) 2026 BayLibre, SAS
+ *
+ * The wrapper latches each SMMUv3 interrupt source in IRQ_STA and keeps its
+ * single output line asserted while a latched source is not acknowledged.
+ * An acknowledgment clears every pending occurrence of the source, so each
+ * source is handled as an edge, acknowledged before its handler reads the
+ * SMMU state. No mask register is known.
+ */
+
+#include <linux/bitops.h>
+#include <linux/device.h>
+#include <linux/err.h>
+#include <linux/io.h>
+#include <linux/irq.h>
+#include <linux/irqchip.h>
+#include <linux/irqchip/chained_irq.h>
+#include <linux/irqdomain.h>
+#include <linux/platform_device.h>
+#include <linux/property.h>
+
+#define MTK_SMMU_WP_IRQ_STA 0x80
+#define MTK_SMMU_WP_IRQ_ACK 0x84
+#define MTK_SMMU_WP_IRQ_ACK_CNT 0x88
+#define MTK_SMMU_WP_IRQ_ACK_CNT_MASK GENMASK(7, 0)
+
+#define MTK_SMMU_WP_NR_IRQS 8
+
+struct mtk_smmu_wp {
+ struct device *dev;
+ void __iomem *base;
+ struct irq_domain *domain;
+};
+
+static void mtk_smmu_wp_ack_source(struct mtk_smmu_wp *wp, unsigned int src)
+{
+ writel_relaxed(BIT(src), wp->base + MTK_SMMU_WP_IRQ_ACK);
+ /* Flush the posted ACK before the SMMU is read */
+ readl(wp->base + MTK_SMMU_WP_IRQ_STA);
+}
+
+static void mtk_smmu_wp_irq_ack(struct irq_data *d)
+{
+ mtk_smmu_wp_ack_source(irq_data_get_irq_chip_data(d), d->hwirq);
+}
+
+static const struct irq_chip mtk_smmu_wp_chip = {
+ .name = "mtk-smmu-wp",
+ .irq_ack = mtk_smmu_wp_irq_ack,
+};
+
+static void mtk_smmu_wp_handler(struct irq_desc *desc)
+{
+ struct mtk_smmu_wp *wp = irq_desc_get_handler_data(desc);
+ struct irq_chip *chip = irq_desc_get_chip(desc);
+ unsigned long pending;
+ unsigned int src;
+
+ chained_irq_enter(chip, desc);
+
+ pending = readl_relaxed(wp->base + MTK_SMMU_WP_IRQ_STA);
+ for_each_set_bit(src, &pending, MTK_SMMU_WP_NR_IRQS) {
+ if (generic_handle_domain_irq(wp->domain, src)) {
+ /* Release an unused source, which would hold the line */
+ mtk_smmu_wp_ack_source(wp, src);
+ dev_warn_ratelimited(wp->dev, "unexpected source %u\n", src);
+ }
+ }
+
+ chained_irq_exit(chip, desc);
+}
+
+static int mtk_smmu_wp_map(struct irq_domain *d, unsigned int virq, irq_hw_number_t hwirq)
+{
+ irq_set_chip_and_handler(virq, &mtk_smmu_wp_chip, handle_edge_irq);
+ irq_set_chip_data(virq, d->host_data);
+ return 0;
+}
+
+static const struct irq_domain_ops mtk_smmu_wp_domain_ops = {
+ .map = mtk_smmu_wp_map,
+ .xlate = irq_domain_xlate_onecell,
+};
+
+static void mtk_smmu_wp_setup(struct mtk_smmu_wp *wp)
+{
+ u32 val;
+
+ /* Make each IRQ_ACK write clear every pending occurrence */
+ val = readl_relaxed(wp->base + MTK_SMMU_WP_IRQ_ACK_CNT);
+ val |= MTK_SMMU_WP_IRQ_ACK_CNT_MASK;
+ writel_relaxed(val, wp->base + MTK_SMMU_WP_IRQ_ACK_CNT);
+}
+
+static int mtk_smmu_wp_probe(struct platform_device *pdev, struct device_node *parent)
+{
+ struct irq_domain_info info = {
+ .fwnode = dev_fwnode(&pdev->dev),
+ .size = MTK_SMMU_WP_NR_IRQS,
+ .hwirq_max = MTK_SMMU_WP_NR_IRQS,
+ .ops = &mtk_smmu_wp_domain_ops,
+ };
+ struct device *dev = &pdev->dev;
+ struct mtk_smmu_wp *wp;
+ unsigned long pending;
+ unsigned int src;
+ int parent_irq;
+
+ wp = devm_kzalloc_obj(dev, *wp);
+ if (!wp)
+ return -ENOMEM;
+
+ wp->dev = dev;
+
+ wp->base = devm_platform_ioremap_resource(pdev, 0);
+ if (IS_ERR(wp->base))
+ return PTR_ERR(wp->base);
+
+ parent_irq = platform_get_irq(pdev, 0);
+ if (parent_irq < 0)
+ return parent_irq;
+
+ mtk_smmu_wp_setup(wp);
+
+ /* Release the sources that an earlier boot stage left latched */
+ pending = readl_relaxed(wp->base + MTK_SMMU_WP_IRQ_STA);
+ for_each_set_bit(src, &pending, MTK_SMMU_WP_NR_IRQS)
+ mtk_smmu_wp_ack_source(wp, src);
+
+ info.host_data = wp;
+ wp->domain = devm_irq_domain_instantiate(dev, &info);
+ if (IS_ERR(wp->domain))
+ return PTR_ERR(wp->domain);
+
+ irq_set_chained_handler_and_data(parent_irq, mtk_smmu_wp_handler, wp);
+
+ return 0;
+}
+
+IRQCHIP_PLATFORM_DRIVER_BEGIN(mtk_smmu_wp)
+IRQCHIP_MATCH("mediatek,mt8196-mm-smmu-wp", mtk_smmu_wp_probe)
+IRQCHIP_PLATFORM_DRIVER_END(mtk_smmu_wp)
--
2.43.0
^ permalink raw reply [flat|nested] 4+ messages in thread