From: Ryan Chen <ryan_chen@aspeedtech.com>
To: ryan_chen <ryan_chen@aspeedtech.com>,
Thomas Gleixner <tglx@linutronix.de>,
Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>, Joel Stanley <joel@jms.id.au>,
Andrew Jeffery <andrew@codeconstruct.com.au>,
<jk@codeconstruct.com.au>, Kevin Chen <kevin_chen@aspeedtech.com>,
<linux-kernel@vger.kernel.org>, <devicetree@vger.kernel.org>,
<linux-arm-kernel@lists.infradead.org>,
<linux-aspeed@lists.ozlabs.org>
Subject: [PATCH v5 2/3] Irqchip/ast2700-intc: add debugfs support for routing/protection display
Date: Wed, 22 Oct 2025 14:55:06 +0800 [thread overview]
Message-ID: <20251022065507.1152071-3-ryan_chen@aspeedtech.com> (raw)
In-Reply-To: <20251022065507.1152071-1-ryan_chen@aspeedtech.com>
AST2700 INTC0/INTC1 nodes ("aspeed,ast2700-intc0/1") not only
include the interrupt controller child node ("aspeed,ast2700-intc-ic"),
but also provide interrupt routing and register protection features.
Adds debugfs entries for interrupt routing and protection status for
AST2700 INTC0/INTC1.
Signed-off-by: Ryan Chen <ryan_chen@aspeedtech.com>
---
drivers/irqchip/Kconfig | 6 +
drivers/irqchip/Makefile | 1 +
drivers/irqchip/irq-ast2700-intc.c | 174 +++++++++++++++++++++++++++++
3 files changed, 181 insertions(+)
create mode 100644 drivers/irqchip/irq-ast2700-intc.c
diff --git a/drivers/irqchip/Kconfig b/drivers/irqchip/Kconfig
index a61c6dc63c29..75922d5c4da6 100644
--- a/drivers/irqchip/Kconfig
+++ b/drivers/irqchip/Kconfig
@@ -111,6 +111,12 @@ config AL_FIC
help
Support Amazon's Annapurna Labs Fabric Interrupt Controller.
+config AST2700_INTC
+ tristate "AST2700 Interrupt Controller"
+ depends on ARCH_ASPEED
+ help
+ Support AST2700 Interrupt Controller.
+
config ATMEL_AIC_IRQ
bool
select GENERIC_IRQ_CHIP
diff --git a/drivers/irqchip/Makefile b/drivers/irqchip/Makefile
index 3de083f5484c..055724a9e536 100644
--- a/drivers/irqchip/Makefile
+++ b/drivers/irqchip/Makefile
@@ -91,6 +91,7 @@ obj-$(CONFIG_LS_EXTIRQ) += irq-ls-extirq.o
obj-$(CONFIG_LS_SCFG_MSI) += irq-ls-scfg-msi.o
obj-$(CONFIG_ARCH_ASPEED) += irq-aspeed-vic.o irq-aspeed-i2c-ic.o irq-aspeed-scu-ic.o
obj-$(CONFIG_ARCH_ASPEED) += irq-aspeed-intc.o
+obj-$(CONFIG_AST2700_INTC) += irq-ast2700-intc.o
obj-$(CONFIG_STM32MP_EXTI) += irq-stm32mp-exti.o
obj-$(CONFIG_STM32_EXTI) += irq-stm32-exti.o
obj-$(CONFIG_QCOM_IRQ_COMBINER) += qcom-irq-combiner.o
diff --git a/drivers/irqchip/irq-ast2700-intc.c b/drivers/irqchip/irq-ast2700-intc.c
new file mode 100644
index 000000000000..7c7241539fe5
--- /dev/null
+++ b/drivers/irqchip/irq-ast2700-intc.c
@@ -0,0 +1,174 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * AST2700 Interrupt Controller
+ */
+
+#include <linux/debugfs.h>
+#include <linux/io.h>
+#include <linux/module.h>
+#include <linux/of_address.h>
+#include <linux/of_device.h>
+#include <linux/platform_device.h>
+#include <linux/seq_file.h>
+
+/* INTC0 register layout */
+#define INTC0_PROT_OFFS 0x40
+#define INTC0_ROUTING_SEL0_BASE 0x200
+#define INTC0_ROUTING_GAP 0x100
+#define INTC0_GROUPS 4
+
+/* INTC1 register layout */
+#define INTC1_PROT_OFFS 0x00
+#define INTC1_ROUTING_SEL0_BASE 0x80
+#define INTC1_ROUTING_GAP 0x20
+#define INTC1_GROUPS 6
+
+struct aspeed_intc_data {
+ const char *name;
+ u32 prot_offs;
+ u32 rout_sel0_base;
+ u32 rout_gap;
+ unsigned int groups;
+};
+
+static const struct aspeed_intc_data aspeed_intc0_data = {
+ .name = "INTC0",
+ .prot_offs = INTC0_PROT_OFFS,
+ .rout_sel0_base = INTC0_ROUTING_SEL0_BASE,
+ .rout_gap = INTC0_ROUTING_GAP,
+ .groups = INTC0_GROUPS,
+};
+
+static const struct aspeed_intc_data aspeed_intc1_data = {
+ .name = "INTC1",
+ .prot_offs = INTC1_PROT_OFFS,
+ .rout_sel0_base = INTC1_ROUTING_SEL0_BASE,
+ .rout_gap = INTC1_ROUTING_GAP,
+ .groups = INTC1_GROUPS,
+};
+
+struct aspeed_intc {
+ void __iomem *base;
+ const struct aspeed_intc_data *data;
+#ifdef CONFIG_DEBUG_FS
+ struct dentry *dbg_root;
+#endif
+};
+
+#ifdef CONFIG_DEBUG_FS
+static int aspeed_intc_regs_show(struct seq_file *s, void *unused)
+{
+ struct aspeed_intc *intc = s->private;
+ const struct aspeed_intc_data *d = intc->data;
+ void __iomem *base = intc->base;
+ unsigned int i;
+
+ for (i = 0; i < d->groups; i++) {
+ void __iomem *b = base + d->rout_sel0_base + i * 4;
+ u32 r0 = readl(b);
+ u32 r1 = readl(b + d->rout_gap);
+ u32 r2 = readl(b + 2 * d->rout_gap);
+
+ seq_printf(s, "ROUTE[%u]: 0x%08x 0x%08x 0x%08x\n", i, r0, r1, r2);
+ }
+ return 0;
+}
+
+static int aspeed_intc_regs_open(struct inode *inode, struct file *file)
+{
+ return single_open(file, aspeed_intc_regs_show, inode->i_private);
+}
+
+static const struct file_operations aspeed_intc_regs_fops = {
+ .owner = THIS_MODULE,
+ .open = aspeed_intc_regs_open,
+ .read = seq_read,
+ .llseek = seq_lseek,
+ .release = single_release,
+};
+
+static int aspeed_intc_prot_show(struct seq_file *s, void *unused)
+{
+ struct aspeed_intc *intc = s->private;
+ const struct aspeed_intc_data *d = intc->data;
+ u32 prot = readl(intc->base + d->prot_offs);
+
+ seq_printf(s, "%s_PROT: 0x%08x\n", d->name, prot);
+ return 0;
+}
+
+static int aspeed_intc_prot_open(struct inode *inode, struct file *file)
+{
+ return single_open(file, aspeed_intc_prot_show, inode->i_private);
+}
+
+static const struct file_operations aspeed_intc_prot_fops = {
+ .owner = THIS_MODULE,
+ .open = aspeed_intc_prot_open,
+ .read = seq_read,
+ .llseek = seq_lseek,
+ .release = single_release,
+};
+#endif /* CONFIG_DEBUG_FS */
+
+static int aspeed_intc_probe(struct platform_device *pdev)
+{
+ const struct aspeed_intc_data *data;
+ struct aspeed_intc *intc;
+ struct resource *res;
+
+ data = of_device_get_match_data(&pdev->dev);
+ if (!data)
+ return -ENODEV;
+
+ intc = devm_kzalloc(&pdev->dev, sizeof(*intc), GFP_KERNEL);
+ if (!intc)
+ return -ENOMEM;
+
+ res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+ intc->base = devm_ioremap_resource(&pdev->dev, res);
+ if (IS_ERR(intc->base))
+ return PTR_ERR(intc->base);
+
+ intc->data = data;
+
+ platform_set_drvdata(pdev, intc);
+
+#ifdef CONFIG_DEBUG_FS
+ intc->dbg_root = debugfs_create_dir(dev_name(&pdev->dev), NULL);
+ if (intc->dbg_root) {
+ debugfs_create_file("routing", 0400, intc->dbg_root, intc,
+ &aspeed_intc_regs_fops);
+ debugfs_create_file("protection", 0400, intc->dbg_root, intc,
+ &aspeed_intc_prot_fops);
+ }
+#endif
+ return 0;
+}
+
+static void aspeed_intc_remove(struct platform_device *pdev)
+{
+#ifdef CONFIG_DEBUG_FS
+ struct aspeed_intc *intc = platform_get_drvdata(pdev);
+
+ if (intc && intc->dbg_root)
+ debugfs_remove_recursive(intc->dbg_root);
+#endif
+}
+
+static const struct of_device_id aspeed_intc_of_match[] = {
+ { .compatible = "aspeed,ast2700-intc0", .data = &aspeed_intc0_data },
+ { .compatible = "aspeed,ast2700-intc1", .data = &aspeed_intc1_data },
+ { /* sentinel */ }
+};
+MODULE_DEVICE_TABLE(of, aspeed_intc_of_match);
+
+static struct platform_driver aspeed_intc_driver = {
+ .probe = aspeed_intc_probe,
+ .remove = aspeed_intc_remove,
+ .driver = {
+ .name = "aspeed-ast2700-intc",
+ .of_match_table = aspeed_intc_of_match,
+ },
+};
+module_platform_driver(aspeed_intc_driver);
--
2.34.1
next prev parent reply other threads:[~2025-10-22 6:55 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-22 6:55 [PATCH v5 0/3] AST2700 interrupt controller hierarchy support Ryan Chen
2025-10-22 6:55 ` [PATCH v5 1/3] dt-bindings: interrupt-controller: aspeed,ast2700: Add support for INTC hierarchy Ryan Chen
2025-10-22 8:29 ` Rob Herring (Arm)
2025-10-22 13:51 ` Rob Herring
2025-10-23 6:57 ` Ryan Chen
2025-10-24 23:11 ` Rob Herring
2025-10-26 3:57 ` Ryan Chen
2025-10-22 6:55 ` Ryan Chen [this message]
2025-10-22 16:37 ` [PATCH v5 2/3] Irqchip/ast2700-intc: add debugfs support for routing/protection display Thomas Gleixner
2025-10-23 8:20 ` Ryan Chen
2025-10-22 6:55 ` [PATCH v5 3/3] irqchip: aspeed: add compatible strings for ast2700-intc0-ic and ast2700-intc1-ic Ryan Chen
2025-10-22 16:51 ` Thomas Gleixner
2025-10-23 8:29 ` Ryan Chen
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=20251022065507.1152071-3-ryan_chen@aspeedtech.com \
--to=ryan_chen@aspeedtech.com \
--cc=andrew@codeconstruct.com.au \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=jk@codeconstruct.com.au \
--cc=joel@jms.id.au \
--cc=kevin_chen@aspeedtech.com \
--cc=krzk+dt@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-aspeed@lists.ozlabs.org \
--cc=linux-kernel@vger.kernel.org \
--cc=robh@kernel.org \
--cc=tglx@linutronix.de \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.