]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
memory: tegra: Add support for multiple IRQs
authorKetan Patil <ketanp@nvidia.com>
Thu, 26 Feb 2026 16:31:12 +0000 (16:31 +0000)
committerKrzysztof Kozlowski <krzk@kernel.org>
Sat, 7 Mar 2026 16:59:37 +0000 (17:59 +0100)
Add support to handle multiple MC interrupts lines, as supported by
Tegra264. Turn the single IRQ handler callback into a counted array to
allow specifying a separate handler for each interrupt. Move IRQ
handlers into tegra_mc_soc struct, so as to specify SoC specific
values.

Signed-off-by: Ketan Patil <ketanp@nvidia.com>
Reviewed-by: Jon Hunter <jonathanh@nvidia.com>
Tested-by: Jon Hunter <jonathanh@nvidia.com>
Link: https://patch.msgid.link/20260226163115.1152181-4-ketanp@nvidia.com
Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
drivers/memory/tegra/mc.c
drivers/memory/tegra/mc.h
drivers/memory/tegra/tegra114.c
drivers/memory/tegra/tegra124.c
drivers/memory/tegra/tegra186.c
drivers/memory/tegra/tegra194.c
drivers/memory/tegra/tegra20.c
drivers/memory/tegra/tegra210.c
drivers/memory/tegra/tegra234.c
drivers/memory/tegra/tegra30.c
include/soc/tegra/mc.h

index 63f402aa1976e55a814d61dd41b05c33b1f304c9..8114574374d5c7c36d74ab2084faf725eebc22ae 100644 (file)
@@ -398,6 +398,10 @@ unsigned int tegra_mc_get_emem_device_count(struct tegra_mc *mc)
 }
 EXPORT_SYMBOL_GPL(tegra_mc_get_emem_device_count);
 
+const irq_handler_t tegra30_mc_irq_handlers[] = {
+       tegra30_mc_handle_irq
+};
+
 #if defined(CONFIG_ARCH_TEGRA_3x_SOC) || \
     defined(CONFIG_ARCH_TEGRA_114_SOC) || \
     defined(CONFIG_ARCH_TEGRA_124_SOC) || \
@@ -542,7 +546,6 @@ int tegra30_mc_probe(struct tegra_mc *mc)
 
 const struct tegra_mc_ops tegra30_mc_ops = {
        .probe = tegra30_mc_probe,
-       .handle_irq = tegra30_mc_handle_irq,
 };
 #endif
 
@@ -943,26 +946,31 @@ static int tegra_mc_probe(struct platform_device *pdev)
 
        tegra_mc_num_channel_enabled(mc);
 
-       if (mc->soc->ops && mc->soc->ops->handle_irq) {
-               mc->irq = platform_get_irq(pdev, 0);
-               if (mc->irq < 0)
-                       return mc->irq;
+       if (mc->soc->handle_irq) {
+               unsigned int i;
 
                WARN(!mc->soc->client_id_mask, "missing client ID mask for this SoC\n");
 
+               for (i = 0; i < mc->soc->num_interrupts; i++) {
+                       int irq;
+
+                       irq = platform_get_irq(pdev, i);
+                       if (irq < 0)
+                               return irq;
+
+                       err = devm_request_irq(&pdev->dev, irq, mc->soc->handle_irq[i], 0,
+                                              dev_name(&pdev->dev), mc);
+                       if (err < 0) {
+                               dev_err(&pdev->dev, "failed to request IRQ#%u: %d\n", irq, err);
+                               return err;
+                       }
+               }
+
                if (mc->soc->num_channels)
                        mc_ch_writel(mc, MC_BROADCAST_CHANNEL, mc->soc->intmask,
                                     MC_INTMASK);
                else
                        mc_writel(mc, mc->soc->intmask, MC_INTMASK);
-
-               err = devm_request_irq(&pdev->dev, mc->irq, mc->soc->ops->handle_irq, 0,
-                                      dev_name(&pdev->dev), mc);
-               if (err < 0) {
-                       dev_err(&pdev->dev, "failed to request IRQ#%u: %d\n", mc->irq,
-                               err);
-                       return err;
-               }
        }
 
        if (mc->soc->reset_ops) {
index 5f816d703d81559d06fbcf9e63d671254ffd5c34..34ce03ebc51caea5b8742a253e8e2c11861f33da 100644 (file)
@@ -193,6 +193,7 @@ extern const struct tegra_mc_ops tegra186_mc_ops;
 #endif
 
 irqreturn_t tegra30_mc_handle_irq(int irq, void *data);
+extern const irq_handler_t tegra30_mc_irq_handlers[1];
 extern const char * const tegra_mc_status_names[32];
 extern const char * const tegra_mc_error_names[8];
 
index ea7e4c7bb5f837b3da0b46c06be2cdb5633928d7..fffb28eea57f041b6f9764542743b05eee47daa7 100644 (file)
@@ -1115,4 +1115,6 @@ const struct tegra_mc_soc tegra114_mc_soc = {
        .num_resets = ARRAY_SIZE(tegra114_mc_resets),
        .ops = &tegra30_mc_ops,
        .regs = &tegra20_mc_regs,
+       .handle_irq = tegra30_mc_irq_handlers,
+       .num_interrupts = ARRAY_SIZE(tegra30_mc_irq_handlers),
 };
index f0cfe14bb47581617d2d5cbaa395bc6deb964fbb..2cf733198782c20db8c885bffc71b9e7159f83e0 100644 (file)
@@ -1276,6 +1276,8 @@ const struct tegra_mc_soc tegra124_mc_soc = {
        .icc_ops = &tegra124_mc_icc_ops,
        .ops = &tegra30_mc_ops,
        .regs = &tegra20_mc_regs,
+       .handle_irq = tegra30_mc_irq_handlers,
+       .num_interrupts = ARRAY_SIZE(tegra30_mc_irq_handlers),
 };
 #endif /* CONFIG_ARCH_TEGRA_124_SOC */
 
@@ -1309,5 +1311,7 @@ const struct tegra_mc_soc tegra132_mc_soc = {
        .icc_ops = &tegra124_mc_icc_ops,
        .ops = &tegra30_mc_ops,
        .regs = &tegra20_mc_regs,
+       .handle_irq = tegra30_mc_irq_handlers,
+       .num_interrupts = ARRAY_SIZE(tegra30_mc_irq_handlers),
 };
 #endif /* CONFIG_ARCH_TEGRA_132_SOC */
index 51e2dd628fb47eafafe6819135a0d711dcc47bef..eb1eaaffc79a82bf340023afb358c25d80be7bf1 100644 (file)
@@ -174,7 +174,6 @@ const struct tegra_mc_ops tegra186_mc_ops = {
        .remove = tegra186_mc_remove,
        .resume = tegra186_mc_resume,
        .probe_device = tegra186_mc_probe_device,
-       .handle_irq = tegra30_mc_handle_irq,
 };
 
 #if defined(CONFIG_ARCH_TEGRA_186_SOC)
@@ -915,5 +914,7 @@ const struct tegra_mc_soc tegra186_mc_soc = {
        .ch_intmask = 0x0000000f,
        .global_intstatus_channel_shift = 0,
        .regs = &tegra20_mc_regs,
+       .handle_irq = tegra30_mc_irq_handlers,
+       .num_interrupts = ARRAY_SIZE(tegra30_mc_irq_handlers),
 };
 #endif
index 5b7ff2dd68122ad08ea7bac259d8f0bbf27cfbe8..cb0e7886857d909bbbeffe9e87445649c55f47ab 100644 (file)
@@ -1359,4 +1359,6 @@ const struct tegra_mc_soc tegra194_mc_soc = {
        .ch_intmask = 0x00000f00,
        .global_intstatus_channel_shift = 8,
        .regs = &tegra20_mc_regs,
+       .handle_irq = tegra30_mc_irq_handlers,
+       .num_interrupts = ARRAY_SIZE(tegra30_mc_irq_handlers),
 };
index 1b2b598ab5645cbbae2d76795ae324d1f94d81f3..6750b08d875fe9f931959a6e92ae8aa8a84a17fd 100644 (file)
@@ -761,9 +761,12 @@ static irqreturn_t tegra20_mc_handle_irq(int irq, void *data)
        return IRQ_HANDLED;
 }
 
+static const irq_handler_t tegra20_mc_irq_handlers[] = {
+       tegra20_mc_handle_irq
+};
+
 static const struct tegra_mc_ops tegra20_mc_ops = {
        .probe = tegra20_mc_probe,
-       .handle_irq = tegra20_mc_handle_irq,
 };
 
 const struct tegra_mc_soc tegra20_mc_soc = {
@@ -779,4 +782,6 @@ const struct tegra_mc_soc tegra20_mc_soc = {
        .icc_ops = &tegra20_mc_icc_ops,
        .ops = &tegra20_mc_ops,
        .regs = &tegra20_mc_regs,
+       .handle_irq = tegra20_mc_irq_handlers,
+       .num_interrupts = ARRAY_SIZE(tegra20_mc_irq_handlers),
 };
index e166b33848e95563660e52e9ff418ebd1e40ed94..8283601ab52cdac52658c706c101424671d9f4ab 100644 (file)
@@ -1288,4 +1288,6 @@ const struct tegra_mc_soc tegra210_mc_soc = {
        .num_resets = ARRAY_SIZE(tegra210_mc_resets),
        .ops = &tegra30_mc_ops,
        .regs = &tegra20_mc_regs,
+       .handle_irq = tegra30_mc_irq_handlers,
+       .num_interrupts = ARRAY_SIZE(tegra30_mc_irq_handlers),
 };
index 512d054d7592465135cf09dfdb927a0936f45ff3..9586d7528fb702e83055cc114e478547c2dbe0e8 100644 (file)
@@ -1153,4 +1153,6 @@ const struct tegra_mc_soc tegra234_mc_soc = {
         */
        .num_carveouts = 32,
        .regs = &tegra20_mc_regs,
+       .handle_irq = tegra30_mc_irq_handlers,
+       .num_interrupts = ARRAY_SIZE(tegra30_mc_irq_handlers),
 };
index 337501a30a73f85d37bb8f358fb7fea73b353e70..ff89b907877216c0c69d30e31cf32a84fa3148af 100644 (file)
@@ -1401,4 +1401,6 @@ const struct tegra_mc_soc tegra30_mc_soc = {
        .icc_ops = &tegra30_mc_icc_ops,
        .ops = &tegra30_mc_ops,
        .regs = &tegra20_mc_regs,
+       .handle_irq = tegra30_mc_irq_handlers,
+       .num_interrupts = ARRAY_SIZE(tegra30_mc_irq_handlers),
 };
index 372f47e824d5371764677aeede3ab2f431b05fd0..d07de04c0f337bcb65aeeade9eab67dd8029769a 100644 (file)
 #include <linux/debugfs.h>
 #include <linux/err.h>
 #include <linux/interconnect-provider.h>
+#include <linux/interrupt.h>
 #include <linux/irq.h>
 #include <linux/reset-controller.h>
-#include <linux/types.h>
 #include <linux/tegra-icc.h>
+#include <linux/types.h>
 
 struct clk;
 struct device;
@@ -164,7 +165,6 @@ struct tegra_mc_ops {
        int (*probe)(struct tegra_mc *mc);
        void (*remove)(struct tegra_mc *mc);
        int (*resume)(struct tegra_mc *mc);
-       irqreturn_t (*handle_irq)(int irq, void *data);
        int (*probe_device)(struct tegra_mc *mc, struct device *dev);
 };
 
@@ -214,6 +214,9 @@ struct tegra_mc_soc {
        const struct tegra_mc_icc_ops *icc_ops;
        const struct tegra_mc_ops *ops;
        const struct tegra_mc_regs *regs;
+
+       const irq_handler_t *handle_irq;
+       unsigned int num_interrupts;
 };
 
 struct tegra_mc {
@@ -224,7 +227,6 @@ struct tegra_mc {
        void __iomem *bcast_ch_regs;
        void __iomem **ch_regs;
        struct clk *clk;
-       int irq;
 
        const struct tegra_mc_soc *soc;
        unsigned long tick;