Skip to content

Commit 4d865a2

Browse files
Ketan Patilkrzk
authored andcommitted
memory: tegra: Add support for multiple IRQs
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>
1 parent 95b714b commit 4d865a2

11 files changed

Lines changed: 49 additions & 18 deletions

File tree

drivers/memory/tegra/mc.c

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,10 @@ unsigned int tegra_mc_get_emem_device_count(struct tegra_mc *mc)
398398
}
399399
EXPORT_SYMBOL_GPL(tegra_mc_get_emem_device_count);
400400

401+
const irq_handler_t tegra30_mc_irq_handlers[] = {
402+
tegra30_mc_handle_irq
403+
};
404+
401405
#if defined(CONFIG_ARCH_TEGRA_3x_SOC) || \
402406
defined(CONFIG_ARCH_TEGRA_114_SOC) || \
403407
defined(CONFIG_ARCH_TEGRA_124_SOC) || \
@@ -542,7 +546,6 @@ int tegra30_mc_probe(struct tegra_mc *mc)
542546

543547
const struct tegra_mc_ops tegra30_mc_ops = {
544548
.probe = tegra30_mc_probe,
545-
.handle_irq = tegra30_mc_handle_irq,
546549
};
547550
#endif
548551

@@ -943,26 +946,31 @@ static int tegra_mc_probe(struct platform_device *pdev)
943946

944947
tegra_mc_num_channel_enabled(mc);
945948

946-
if (mc->soc->ops && mc->soc->ops->handle_irq) {
947-
mc->irq = platform_get_irq(pdev, 0);
948-
if (mc->irq < 0)
949-
return mc->irq;
949+
if (mc->soc->handle_irq) {
950+
unsigned int i;
950951

951952
WARN(!mc->soc->client_id_mask, "missing client ID mask for this SoC\n");
952953

954+
for (i = 0; i < mc->soc->num_interrupts; i++) {
955+
int irq;
956+
957+
irq = platform_get_irq(pdev, i);
958+
if (irq < 0)
959+
return irq;
960+
961+
err = devm_request_irq(&pdev->dev, irq, mc->soc->handle_irq[i], 0,
962+
dev_name(&pdev->dev), mc);
963+
if (err < 0) {
964+
dev_err(&pdev->dev, "failed to request IRQ#%u: %d\n", irq, err);
965+
return err;
966+
}
967+
}
968+
953969
if (mc->soc->num_channels)
954970
mc_ch_writel(mc, MC_BROADCAST_CHANNEL, mc->soc->intmask,
955971
MC_INTMASK);
956972
else
957973
mc_writel(mc, mc->soc->intmask, MC_INTMASK);
958-
959-
err = devm_request_irq(&pdev->dev, mc->irq, mc->soc->ops->handle_irq, 0,
960-
dev_name(&pdev->dev), mc);
961-
if (err < 0) {
962-
dev_err(&pdev->dev, "failed to request IRQ#%u: %d\n", mc->irq,
963-
err);
964-
return err;
965-
}
966974
}
967975

968976
if (mc->soc->reset_ops) {

drivers/memory/tegra/mc.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,7 @@ extern const struct tegra_mc_ops tegra186_mc_ops;
193193
#endif
194194

195195
irqreturn_t tegra30_mc_handle_irq(int irq, void *data);
196+
extern const irq_handler_t tegra30_mc_irq_handlers[1];
196197
extern const char * const tegra_mc_status_names[32];
197198
extern const char * const tegra_mc_error_names[8];
198199

drivers/memory/tegra/tegra114.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1115,4 +1115,6 @@ const struct tegra_mc_soc tegra114_mc_soc = {
11151115
.num_resets = ARRAY_SIZE(tegra114_mc_resets),
11161116
.ops = &tegra30_mc_ops,
11171117
.regs = &tegra20_mc_regs,
1118+
.handle_irq = tegra30_mc_irq_handlers,
1119+
.num_interrupts = ARRAY_SIZE(tegra30_mc_irq_handlers),
11181120
};

drivers/memory/tegra/tegra124.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1276,6 +1276,8 @@ const struct tegra_mc_soc tegra124_mc_soc = {
12761276
.icc_ops = &tegra124_mc_icc_ops,
12771277
.ops = &tegra30_mc_ops,
12781278
.regs = &tegra20_mc_regs,
1279+
.handle_irq = tegra30_mc_irq_handlers,
1280+
.num_interrupts = ARRAY_SIZE(tegra30_mc_irq_handlers),
12791281
};
12801282
#endif /* CONFIG_ARCH_TEGRA_124_SOC */
12811283

@@ -1309,5 +1311,7 @@ const struct tegra_mc_soc tegra132_mc_soc = {
13091311
.icc_ops = &tegra124_mc_icc_ops,
13101312
.ops = &tegra30_mc_ops,
13111313
.regs = &tegra20_mc_regs,
1314+
.handle_irq = tegra30_mc_irq_handlers,
1315+
.num_interrupts = ARRAY_SIZE(tegra30_mc_irq_handlers),
13121316
};
13131317
#endif /* CONFIG_ARCH_TEGRA_132_SOC */

drivers/memory/tegra/tegra186.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,6 @@ const struct tegra_mc_ops tegra186_mc_ops = {
174174
.remove = tegra186_mc_remove,
175175
.resume = tegra186_mc_resume,
176176
.probe_device = tegra186_mc_probe_device,
177-
.handle_irq = tegra30_mc_handle_irq,
178177
};
179178

180179
#if defined(CONFIG_ARCH_TEGRA_186_SOC)
@@ -915,5 +914,7 @@ const struct tegra_mc_soc tegra186_mc_soc = {
915914
.ch_intmask = 0x0000000f,
916915
.global_intstatus_channel_shift = 0,
917916
.regs = &tegra20_mc_regs,
917+
.handle_irq = tegra30_mc_irq_handlers,
918+
.num_interrupts = ARRAY_SIZE(tegra30_mc_irq_handlers),
918919
};
919920
#endif

drivers/memory/tegra/tegra194.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1359,4 +1359,6 @@ const struct tegra_mc_soc tegra194_mc_soc = {
13591359
.ch_intmask = 0x00000f00,
13601360
.global_intstatus_channel_shift = 8,
13611361
.regs = &tegra20_mc_regs,
1362+
.handle_irq = tegra30_mc_irq_handlers,
1363+
.num_interrupts = ARRAY_SIZE(tegra30_mc_irq_handlers),
13621364
};

drivers/memory/tegra/tegra20.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -761,9 +761,12 @@ static irqreturn_t tegra20_mc_handle_irq(int irq, void *data)
761761
return IRQ_HANDLED;
762762
}
763763

764+
static const irq_handler_t tegra20_mc_irq_handlers[] = {
765+
tegra20_mc_handle_irq
766+
};
767+
764768
static const struct tegra_mc_ops tegra20_mc_ops = {
765769
.probe = tegra20_mc_probe,
766-
.handle_irq = tegra20_mc_handle_irq,
767770
};
768771

769772
const struct tegra_mc_soc tegra20_mc_soc = {
@@ -779,4 +782,6 @@ const struct tegra_mc_soc tegra20_mc_soc = {
779782
.icc_ops = &tegra20_mc_icc_ops,
780783
.ops = &tegra20_mc_ops,
781784
.regs = &tegra20_mc_regs,
785+
.handle_irq = tegra20_mc_irq_handlers,
786+
.num_interrupts = ARRAY_SIZE(tegra20_mc_irq_handlers),
782787
};

drivers/memory/tegra/tegra210.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1288,4 +1288,6 @@ const struct tegra_mc_soc tegra210_mc_soc = {
12881288
.num_resets = ARRAY_SIZE(tegra210_mc_resets),
12891289
.ops = &tegra30_mc_ops,
12901290
.regs = &tegra20_mc_regs,
1291+
.handle_irq = tegra30_mc_irq_handlers,
1292+
.num_interrupts = ARRAY_SIZE(tegra30_mc_irq_handlers),
12911293
};

drivers/memory/tegra/tegra234.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1153,4 +1153,6 @@ const struct tegra_mc_soc tegra234_mc_soc = {
11531153
*/
11541154
.num_carveouts = 32,
11551155
.regs = &tegra20_mc_regs,
1156+
.handle_irq = tegra30_mc_irq_handlers,
1157+
.num_interrupts = ARRAY_SIZE(tegra30_mc_irq_handlers),
11561158
};

drivers/memory/tegra/tegra30.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1401,4 +1401,6 @@ const struct tegra_mc_soc tegra30_mc_soc = {
14011401
.icc_ops = &tegra30_mc_icc_ops,
14021402
.ops = &tegra30_mc_ops,
14031403
.regs = &tegra20_mc_regs,
1404+
.handle_irq = tegra30_mc_irq_handlers,
1405+
.num_interrupts = ARRAY_SIZE(tegra30_mc_irq_handlers),
14041406
};

0 commit comments

Comments
 (0)