* [PATCH v6 0/2] irqchip: Add Cortina Systems CS75xx peripheral interrupt controller
@ 2026-12-01 16:32 Fil Dunsky via B4 Relay
2026-12-01 16:32 ` [PATCH v6 1/2] dt-bindings: interrupt-controller: Add Cortina Systems CS7542 " Fil Dunsky via B4 Relay
2026-12-01 16:32 ` [PATCH v6 2/2] irqchip: Add Cortina Systems CS75xx " Fil Dunsky via B4 Relay
0 siblings, 2 replies; 4+ messages in thread
From: Fil Dunsky via B4 Relay @ 2026-12-01 16:32 UTC (permalink / raw)
To: Thomas Gleixner, Radu Rendec, Rob Herring, Krzysztof Kozlowski,
Conor Dooley
Cc: linux-kernel, devicetree, linux-arm-kernel
The timers, GPIO banks, I2C, MDIO, SPI and a few other low speed
peripherals of the Cortina Systems CS75xx ("Goldengate G2") SoCs share
one GIC interrupt. This series adds the binding and a chained driver for
the small controller in the peripheral register block that reports the
level of these 15 sources and masks them; each source is acknowledged in
its peripheral.
There is a second status/enable pair right behind it whose purpose I do
not know; it is not described.
The driver used to be part of a series with the GPIO, I2C and watchdog
drivers and the device tree changes. That series is now split per
subsystem. The driver depends on OF and HAS_IOMEM, with no dependency on
the platform series [1], which is under review separately. The device
tree nodes will follow with the other CS75xx dts changes once the
platform is merged.
There is no public documentation; the register layout comes from the GPL
vendor kernels and was checked on a Securifi Almond+ (CS7542), where the
GPIO and I2C interrupts of the board are delivered through this
controller. The v5 IRQ flags and normal initialization path were checked
in RAM with PROVE_LOCKING; MMIO cleanup on initialization failure was
reviewed but not fault-injected on the board.
[1] https://lore.kernel.org/all/20261122-b4-cs75xx-v9-0-1fc1b90bd097@gmail.com/
---
Changes in v6:
- Instantiate the IRQ domain with its generic chip and parent handler
initialized before the domain becomes visible (Thomas Gleixner).
- Use guard_chained_irq() and combine the two int declarations.
- Base the series on tip irq/drivers, which provides the chained IRQ guard.
- Cross-compile the corrected driver for ARM. Check the publication order,
cleanup and dispatch with a host test using the driver source.
- Link to v5: https://patch.msgid.link/20261120-cs75xx-intc-v5-0-f2be75c5e97c@gmail.com
Changes in v5:
- replace the ARCH_CORTINA_ACCESS || COMPILE_TEST dependency and
architecture default with OF, retaining HAS_IOMEM, so the driver can
be merged without the platform series
- build built-in on ARM and x86-64 with COMPILE_TEST=n and without the
platform series; check that OF and MMIO dependencies gate the option
- require HAS_IOMEM for COMPILE_TEST builds
- mark child interrupts as level-triggered and keep them non-probeable
- release the reserved MMIO region on initialization failure
- Link to v4: https://patch.msgid.link/20261117-cs75xx-intc-v4-0-0a678f35e5f3@gmail.com
Changes in v4:
- rebase on v7.4-rc1; update the platform reference to v7
- split out of "Cortina Systems CS75xx: interrupt controller, GPIO, I2C
and TWD watchdog" so that each driver can go through its own tree; no
longer based on the platform series
- declare the variables of the chained handler from the longest to the
shortest line
- do not wrap lines that fit in 100 columns (Thomas)
- collect Reviewed-by tags
- Link to v3: https://patch.msgid.link/20261013-b4-cs75xx-s2-v3-0-181bb0d23f4c@gmail.com
Changes in v3:
- rebase on v6 of the platform series
- Link to v2: https://patch.msgid.link/20261013-b4-cs75xx-s2-v2-0-94f8c0a90cda@gmail.com
Changes in v2:
- rebase on v5 of the platform series
- Link to v1: https://patch.msgid.link/20261012-b4-cs75xx-s2-v1-0-8a7641b7b79c@gmail.com
Cc: linux-arm-kernel@lists.infradead.org
---
Fil Dunsky (2):
dt-bindings: interrupt-controller: Add Cortina Systems CS7542 peripheral interrupt controller
irqchip: Add Cortina Systems CS75xx peripheral interrupt controller
.../interrupt-controller/cortina,cs7542-intc.yaml | 57 +++++++++
drivers/irqchip/Kconfig | 12 ++
drivers/irqchip/Makefile | 1 +
drivers/irqchip/irq-cs75xx.c | 129 +++++++++++++++++++++
4 files changed, 199 insertions(+)
---
base-commit: d4673c92ff7f50ef7de22c887f0909b837c2a34a
change-id: 20261015-cs75xx-intc-b422801c7a5d
Best regards,
--
Fil Dunsky <filipp.dunsky@gmail.com>
^ permalink raw reply [flat|nested] 4+ messages in thread* [PATCH v6 1/2] dt-bindings: interrupt-controller: Add Cortina Systems CS7542 peripheral interrupt controller 2026-12-01 16:32 [PATCH v6 0/2] irqchip: Add Cortina Systems CS75xx peripheral interrupt controller Fil Dunsky via B4 Relay @ 2026-12-01 16:32 ` Fil Dunsky via B4 Relay 2026-12-01 16:32 ` [PATCH v6 2/2] irqchip: Add Cortina Systems CS75xx " Fil Dunsky via B4 Relay 1 sibling, 0 replies; 4+ messages in thread From: Fil Dunsky via B4 Relay @ 2026-12-01 16:32 UTC (permalink / raw) To: Thomas Gleixner, Radu Rendec, Rob Herring, Krzysztof Kozlowski, Conor Dooley Cc: linux-kernel, devicetree, linux-arm-kernel From: Fil Dunsky <filipp.dunsky@gmail.com> The low speed peripherals of the Cortina Systems CS75xx SoCs share one GIC interrupt. A small controller in the peripheral register block reports which of its 15 sources are asserted and allows masking them. Reviewed-by: Rob Herring (Arm) <robh@kernel.org> Signed-off-by: Fil Dunsky <filipp.dunsky@gmail.com> --- .../interrupt-controller/cortina,cs7542-intc.yaml | 57 ++++++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/Documentation/devicetree/bindings/interrupt-controller/cortina,cs7542-intc.yaml b/Documentation/devicetree/bindings/interrupt-controller/cortina,cs7542-intc.yaml new file mode 100644 index 0000000000..2963acaf7d --- /dev/null +++ b/Documentation/devicetree/bindings/interrupt-controller/cortina,cs7542-intc.yaml @@ -0,0 +1,57 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/interrupt-controller/cortina,cs7542-intc.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Cortina Systems CS7542 peripheral interrupt controller + +maintainers: + - Fil Dunsky <filipp.dunsky@gmail.com> + +description: + The low speed peripherals of the Cortina Systems CS75xx (Goldengate G2) + SoCs (two software interrupts, two timers, the AXI bridge, SPI, the five + GPIO banks, I2C, MDIO, SSP and the random number generator) share one GIC + interrupt. This controller has a status register showing the level of the + 15 sources and an enable register to mask them. The sources are cleared in + the peripherals themselves. + +properties: + compatible: + const: cortina,cs7542-intc + + reg: + maxItems: 1 + + interrupts: + maxItems: 1 + + interrupt-controller: true + + "#interrupt-cells": + const: 1 + description: + The number of the source, 0 to 14. All sources are active high level + interrupts. + +required: + - compatible + - reg + - interrupts + - interrupt-controller + - "#interrupt-cells" + +additionalProperties: false + +examples: + - | + #include <dt-bindings/interrupt-controller/arm-gic.h> + + interrupt-controller@f0070004 { + compatible = "cortina,cs7542-intc"; + reg = <0xf0070004 0x8>; + interrupts = <GIC_SPI 3 IRQ_TYPE_LEVEL_HIGH>; + interrupt-controller; + #interrupt-cells = <1>; + }; -- 2.53.0 ^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH v6 2/2] irqchip: Add Cortina Systems CS75xx peripheral interrupt controller 2026-12-01 16:32 [PATCH v6 0/2] irqchip: Add Cortina Systems CS75xx peripheral interrupt controller Fil Dunsky via B4 Relay 2026-12-01 16:32 ` [PATCH v6 1/2] dt-bindings: interrupt-controller: Add Cortina Systems CS7542 " Fil Dunsky via B4 Relay @ 2026-12-01 16:32 ` Fil Dunsky via B4 Relay 2026-12-01 21:00 ` Thomas Gleixner 1 sibling, 1 reply; 4+ messages in thread From: Fil Dunsky via B4 Relay @ 2026-12-01 16:32 UTC (permalink / raw) To: Thomas Gleixner, Radu Rendec, Rob Herring, Krzysztof Kozlowski, Conor Dooley Cc: linux-kernel, devicetree, linux-arm-kernel From: Fil Dunsky <filipp.dunsky@gmail.com> The timers, GPIO banks, I2C, MDIO, SPI and a few other low speed peripherals of the Cortina Systems CS75xx SoCs share a single GIC interrupt. A status register shows the level of the 15 sources and an enable register masks them; there is nothing to acknowledge, each source is cleared in its peripheral. Add a chained driver using a generic chip on a linear domain. The driver depends on OF and HAS_IOMEM and can be enabled independently of the CS75xx platform support. Use irq_domain_instantiate() to allocate and initialize the generic chip and install the parent handler before the IRQ domain is published. A consumer can then only map an IRQ once the chip and handler are ready. Use guard_chained_irq() to pair chained entry and exit. Link: https://lore.kernel.org/all/87mrqpov7z.ffs@fw13/ Signed-off-by: Fil Dunsky <filipp.dunsky@gmail.com> --- drivers/irqchip/Kconfig | 12 ++++ drivers/irqchip/Makefile | 1 + drivers/irqchip/irq-cs75xx.c | 129 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 142 insertions(+) diff --git a/drivers/irqchip/Kconfig b/drivers/irqchip/Kconfig index aafd2e625f..afe426e628 100644 --- a/drivers/irqchip/Kconfig +++ b/drivers/irqchip/Kconfig @@ -187,6 +187,18 @@ config BRCMSTB_L2_IRQ select GENERIC_IRQ_CHIP select IRQ_DOMAIN +config CS75XX_INTC + bool "Cortina Systems CS75xx peripheral interrupt controller" + depends on OF + depends on HAS_IOMEM + select GENERIC_IRQ_CHIP + select IRQ_DOMAIN + help + Support for the interrupt controller of the Cortina Systems + CS75xx SoCs that combines the interrupts of the low speed + peripherals (timers, GPIO banks, I2C, MDIO, SPI) into a single + GIC interrupt. Say Y if you have a board with such an SoC. + config DAVINCI_CP_INTC bool select GENERIC_IRQ_CHIP diff --git a/drivers/irqchip/Makefile b/drivers/irqchip/Makefile index eb539d4125..b37a55d7f7 100644 --- a/drivers/irqchip/Makefile +++ b/drivers/irqchip/Makefile @@ -136,3 +136,4 @@ obj-$(CONFIG_MCHP_EIC) += irq-mchp-eic.o obj-$(CONFIG_SOPHGO_SG2042_MSI) += irq-sg2042-msi.o obj-$(CONFIG_SUNPLUS_SP7021_INTC) += irq-sp7021-intc.o obj-$(CONFIG_IRQCHIP_XILINX_SMMU_CSR) += irq-xilinx-smmu-csr.o +obj-$(CONFIG_CS75XX_INTC) += irq-cs75xx.o diff --git a/drivers/irqchip/irq-cs75xx.c b/drivers/irqchip/irq-cs75xx.c new file mode 100644 index 0000000000..5c60290d79 --- /dev/null +++ b/drivers/irqchip/irq-cs75xx.c @@ -0,0 +1,129 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Cortina Systems CS75xx peripheral interrupt controller + * + * The low speed peripherals on the register bus (timers, GPIO banks, I2C, + * MDIO, SPI, ...) share a single GIC interrupt. A status register shows + * the level of the 15 sources and an enable register masks them; there is + * nothing to acknowledge, the sources are cleared in the peripherals. + */ + +#include <linux/bitops.h> +#include <linux/io.h> +#include <linux/ioport.h> +#include <linux/irq.h> +#include <linux/irqchip.h> +#include <linux/irqchip/chained_irq.h> +#include <linux/irqdomain.h> +#include <linux/of.h> +#include <linux/of_address.h> +#include <linux/of_irq.h> + +#define CS75XX_INTC_STATUS 0x00 +#define CS75XX_INTC_ENABLE 0x04 + +#define CS75XX_INTC_NR_IRQS 15 + +static void cs75xx_intc_handler(struct irq_desc *desc) +{ + struct irq_domain *domain = irq_desc_get_handler_data(desc); + struct irq_chip *chip = irq_desc_get_chip(desc); + struct irq_chip_generic *gc; + unsigned long pending; + unsigned int hwirq; + + gc = irq_get_domain_generic_chip(domain, 0); + guard_chained_irq(chip, desc); + + pending = readl(gc->reg_base + CS75XX_INTC_STATUS) & gc->mask_cache; + for_each_set_bit(hwirq, &pending, CS75XX_INTC_NR_IRQS) + generic_handle_domain_irq(domain, hwirq); +} + +struct cs75xx_intc_setup { + void __iomem *base; + unsigned int parent_irq; +}; + +static int __init cs75xx_intc_domain_init(struct irq_domain *domain) +{ + const struct cs75xx_intc_setup *setup = domain->host_data; + struct irq_chip_generic *gc; + + gc = irq_get_domain_generic_chip(domain, 0); + gc->reg_base = setup->base; + gc->chip_types[0].regs.mask = CS75XX_INTC_ENABLE; + gc->chip_types[0].chip.irq_mask = irq_gc_mask_clr_bit; + gc->chip_types[0].chip.irq_unmask = irq_gc_mask_set_bit; + + /* The setup data lives on the stack and is only needed before publication. */ + domain->host_data = NULL; + irq_set_chained_handler_and_data(setup->parent_irq, cs75xx_intc_handler, domain); + return 0; +} + +static int __init cs75xx_intc_init(struct device_node *np, struct device_node *parent) +{ + struct cs75xx_intc_setup setup; + struct irq_domain_chip_generic_info gc_info = { + .name = "cs75xx-intc", + .handler = handle_level_irq, + .irqs_per_chip = CS75XX_INTC_NR_IRQS, + .num_ct = 1, + .irq_flags_to_clear = IRQ_NOREQUEST, + .irq_flags_to_set = IRQ_LEVEL | IRQ_NOPROBE, + .gc_flags = IRQ_GC_INIT_MASK_CACHE, + }; + struct irq_domain_info info = { + .fwnode = of_fwnode_handle(np), + .size = CS75XX_INTC_NR_IRQS, + .hwirq_max = CS75XX_INTC_NR_IRQS, + .ops = &irq_generic_chip_ops, + .dgc_info = &gc_info, + .init = cs75xx_intc_domain_init, + .host_data = &setup, + }; + struct irq_domain *domain; + struct resource res; + void __iomem *base; + int ret, parent_irq; + + ret = of_address_to_resource(np, 0, &res); + if (ret) + return ret; + + base = of_io_request_and_map(np, 0, of_node_full_name(np)); + if (IS_ERR(base)) { + pr_err("%pOF: unable to map registers\n", np); + return PTR_ERR(base); + } + + /* Mask everything before the chained handler is installed */ + writel(0, base + CS75XX_INTC_ENABLE); + + parent_irq = irq_of_parse_and_map(np, 0); + if (!parent_irq) { + pr_err("%pOF: unable to map parent interrupt\n", np); + ret = -EINVAL; + goto err_unmap; + } + + setup.base = base; + setup.parent_irq = parent_irq; + domain = irq_domain_instantiate(&info); + if (IS_ERR(domain)) { + ret = PTR_ERR(domain); + goto err_dispose; + } + + return 0; + +err_dispose: + irq_dispose_mapping(parent_irq); +err_unmap: + iounmap(base); + release_mem_region(res.start, resource_size(&res)); + return ret; +} + +IRQCHIP_DECLARE(cs7542_intc, "cortina,cs7542-intc", cs75xx_intc_init); -- 2.53.0 ^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v6 2/2] irqchip: Add Cortina Systems CS75xx peripheral interrupt controller 2026-12-01 16:32 ` [PATCH v6 2/2] irqchip: Add Cortina Systems CS75xx " Fil Dunsky via B4 Relay @ 2026-12-01 21:00 ` Thomas Gleixner 0 siblings, 0 replies; 4+ messages in thread From: Thomas Gleixner @ 2026-12-01 21:00 UTC (permalink / raw) To: filipp.dunsky, Radu Rendec, Rob Herring, Krzysztof Kozlowski, Conor Dooley Cc: linux-kernel, devicetree, linux-arm-kernel On Tue, Dec 01 2026 at 19:32, Fil Dunsky via wrote: > + > +static int __init cs75xx_intc_domain_init(struct irq_domain *domain) > +{ > + const struct cs75xx_intc_setup *setup = domain->host_data; > + struct irq_chip_generic *gc; > + > + gc = irq_get_domain_generic_chip(domain, 0); > + gc->reg_base = setup->base; > + gc->chip_types[0].regs.mask = CS75XX_INTC_ENABLE; > + gc->chip_types[0].chip.irq_mask = irq_gc_mask_clr_bit; > + gc->chip_types[0].chip.irq_unmask = irq_gc_mask_set_bit; > + > + /* The setup data lives on the stack and is only needed before publication. */ > + domain->host_data = NULL; > + irq_set_chained_handler_and_data(setup->parent_irq, cs75xx_intc_handler, domain); > + return 0; > +} irq_domain_chip_generic_info has its own init() callback for a reason. The point is that the chip has to be ready and complete after irq_domain_alloc_generic_chips() returns. Your admittedly clever abuse of the domain_info::init() callback relies on the behavior of the current core code. That's not really clever as it is prone to hard to diagnose failures down the road if the core code changes. I pointed you to an example which got it right, no? > +static int __init cs75xx_intc_init(struct device_node *np, struct device_node *parent) > +{ > + struct cs75xx_intc_setup setup; Handing host data in with a pointer to stack memory and then clearing it in the domain somewhere else is the other "clever" thing which makes me cringe. I can see the "charm" of your approach, but then it want's to be done right. Something like the uncompiled below should work. You get the idea. Feel free to turn it into a proper patch. Thanks, tglx --- --- a/include/linux/irqdomain.h +++ b/include/linux/irqdomain.h @@ -149,6 +149,12 @@ struct irq_domain_chip_generic; * @gc: Pointer to a list of generic chips. There is a helper function for * setting up one or more generic chips for interrupt controllers * drivers using the generic chip library which uses this pointer. + * @init_data: Controller private data pointer for the init callbacks of the domain + * and the generic chips. Can safely point to stack memory. It is NULL'ed + * after the callbacks have completed and before the domain is published. + * The init() callbacks are not allowed to store the pointer. It's only + * there to provide data for domain and chip initialization to avoid carrying + * unused allocated memory around in @host_data forever. * @dev: Pointer to the device which instantiated the irqdomain * With per device irq domains this is not necessarily the same * as @pm_dev. @@ -188,6 +194,7 @@ struct irq_domain { const struct msi_parent_ops *msi_parent_ops; #endif void (*exit)(struct irq_domain *d); + void *init_data; /* reverse map data. The linear map gets appended to the irq_domain */ irq_hw_number_t hwirq_max; @@ -325,6 +332,8 @@ struct irq_domain_chip_generic_info; * domains are added using same fwnode * @ops: Domain operation callbacks * @host_data: Controller private data pointer + * @init_data: Controller private data pointer for the init callbacks + * of the domain and generic chips. Can safely point to stack memory. * @dev: Device which creates the domain * @dgc_info: Geneneric chip information structure pointer used to * create generic chips for the domain if not NULL. @@ -345,6 +354,7 @@ struct irq_domain_info { const char *name_suffix; const struct irq_domain_ops *ops; void *host_data; + void *init_data; struct device *dev; #ifdef CONFIG_IRQ_DOMAIN_HIERARCHY /** --- a/kernel/irq/irqdomain.c +++ b/kernel/irq/irqdomain.c @@ -332,6 +332,7 @@ static struct irq_domain *__irq_domain_i domain->flags |= info->domain_flags; domain->exit = info->exit; domain->dev = info->dev; + domain->init_data = info->init_data; #ifdef CONFIG_IRQ_DOMAIN_HIERARCHY if (info->parent) { @@ -352,6 +353,8 @@ static struct irq_domain *__irq_domain_i if (err) goto err_domain_gc_remove; } + /* info::init_data can point to stack memory. Don't leak the pointer */ + domain->init_data = NULL; __irq_domain_publish(domain); ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-12-01 21:00 UTC | newest] Thread overview: 4+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2026-12-01 16:32 [PATCH v6 0/2] irqchip: Add Cortina Systems CS75xx peripheral interrupt controller Fil Dunsky via B4 Relay 2026-12-01 16:32 ` [PATCH v6 1/2] dt-bindings: interrupt-controller: Add Cortina Systems CS7542 " Fil Dunsky via B4 Relay 2026-12-01 16:32 ` [PATCH v6 2/2] irqchip: Add Cortina Systems CS75xx " Fil Dunsky via B4 Relay 2026-12-01 21:00 ` Thomas Gleixner
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox