From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=100.103.45.18 ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1796500782; b=JKHBUmDa3Lw30ej7hZh9j3BcgSDj7J+ROcC7H0wN8RXwSAjsDlJvmUxpWNEA1ZlRQWxW UfY4DTpdE5E+iWIy5IyFR8XlqN2JPATstCl9vUaJJzQ5NxX1oscf5RY+FLA4WtnPjnEZD EqolooLv5dlC7J7jblRbGXWGTueB2jPwE0wRH88EH3qVN3G/qmoBwPAg3ERrhFJg1IlbR V1wB4velg2dmXPfWSYFa7ejxrrzuZOjMb3VpeXhw5pQ+FdJVML8PHfP3NJUXkuNCfl2on znkWMmf7UojwCAUF8PAJII7ZxjXUbSsXNnb/QW//1eZzHTPxhBUtuoibNtj+CZyMYng== ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796500782; h=Received:DKIM-Signature:Received:From:Date:Subject:MIME-Version: Content-Type:Message-Id:References:In-Reply-To:To:Cc:X-Mailer: X-Developer-Signature:X-Developer-Key:X-Endpoint-Received: X-Original-From:Reply-To:Content-Transfer-Encoding; bh=q591Wp/NLrEED85h8WX1tOKyf9/7Vp4Qb+2HOcEWqA0=; b=ckyRZSo7kJv24yrSrjN9YCBBlIqwgjbS409Q7k0p12pIxAFEbPd3tTbYQ1nK1g33K4B/ hKJK9+CgwPQxs0/X2w6xMY2K1mFWVWUOs8gHnnUfuTN63rjuVUQfZIQ8q0S9ch4wAQQ0b tdesT6focGlONrKWZHxliUc0CM23A1Yx92GI6DvKiN7crVuPgcHCRPCYVQWv13rCGpgBp YhrEtg4JXuTEF72bUMeddDN3yo7uWQtKyQZjq4pKQDvkXyCfS9/KcY1ZJtnkelDiIvpER jv/V7sDRNpjvwi/Tu5fVekroFtYyy5WxDo/W3NFHwei1XM2ZfkXG0D6qFr3XsGx46EA== ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=CEeR3leR; arc=pass header.oldest-pass=0 smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A0C7F606A33B; Sat, 5 Dec 2026 19:59:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=CEeR3leR Authentication-Results: smtp.kernel.org; arc=none smtp.remote-ip=100.80.115.77 ARC-Seal: i=1; d=kernel.org; s=arc20260519; a=rsa-sha256; cv=none; t=1796500782; b=k1+jAwNqb7yMBT4KXMhsiuT6Kcumd5kiv7h3prjeAuQ3IDo9btZzBqZjZ8JK30yJasK1 xZ4mxyndsbIpDhiV+DoCvE5U1E43hJ5OH03YBstwm70N1V3NSc8QWC6P+2hJtVlZt3Z+j DPMndwBKAlohdWHenz1O2zsRBCvWfaNOmCALJ278GFk9BBcd1jtSYF/ZHyGAHWDvF+2VV /5l7i2VSXDNoJYj2t1om4P96EV8wGgrpSK0xCbohYehGw7K/GOevPTex0VbIoE5V3yrse ROk/nBMZ0KOZXuF57841OOfgReMOKbq6Hbx2eL6oy7JCz+0DDN2Z5XBGFfNWjt7MJLg== ARC-Message-Signature: i=1; d=kernel.org; s=arc20260519; a=rsa-sha256; c=relaxed/relaxed; t=1796500782; h=DKIM-Signature:Received:From:Date:Subject:MIME-Version:Content-Type: Message-Id:References:In-Reply-To:To:Cc:X-Mailer: X-Developer-Signature:X-Developer-Key:X-Endpoint-Received: X-Original-From:Reply-To:Content-Transfer-Encoding; bh=q591Wp/NLrEED85h8WX1tOKyf9/7Vp4Qb+2HOcEWqA0=; b=fWG7OO3r/3dlmnJFB4n/mZ+aUe1AulvJXyrmjCecbGq8U3KtpkYMTri+JBrDe9bYzAQK s4FDNwxtmAuleXH+beyt4t+eL1YZSJA4EXIhqMr0CgEOcP79BE2aV8mvATvRWm1ZZBEcP ifKKVyJWviTz63IEWaSm+iftYSChsGBZhRU9Ay2YFNSHIsrZU2twlmvAb0noBKy0QBRkM Cb4nC43lEX6IYrfXfZWygy+cfrr5XgHtwnHlpYN1SDztd7soAByIFWTx5AYNDWJ/14DLo pYDHtPf/dL8nlkaflrVaYclc6bfkftWyntqgn0uMrjWZaybf3eFF87EINBtoXpjGEtg== ARC-Authentication-Results: i=1; smtp.kernel.org; arc=none smtp.remote-ip=100.80.115.77 Received: from lkml.kernel.org (nexus.subspace.kernel.org [100.80.115.77]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.kernel.org (Postfix) with ESMTPS id 7FD281F00A10; Sat, 5 Dec 2026 19:59:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796500782; bh=q591Wp/NLrEED85h8WX1tOKyf9/7Vp4Qb+2HOcEWqA0=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To; b=CEeR3leR6ro6EVgbtB5QsP/FBanFQ45psyeRISdgVL8U/PLTDbaFwGodM79WDLFUF zhRBgpbzhuWV6S66yWIAu7W/Ks7+wmhoi/Cn5YL0hlieEizC1KcpXG69K9s88lUmX0 zSrBP278owfaDrFRXtxetVHXRzE/rcDH52ARbrOT2sS6fdT5MJtcOdfbBBGjwBdX0F ur5M4krA628J59CF8svJ68PJRBfBlVrVjx+MNuYi9wUWbIue7bmVK1qLu38r4E31NP 4XmT/g6/KukMyPotJWX6oIh8PxejtXzbDJFFJgG6nWEMMepsDEmdP2SsnYzDMn8Kww XBIuALMltv+HQ== Received: from nexus.subspace.kernel.org (localhost [IPv6:::1]) by lkml.kernel.org (Postfix) with ESMTP id 0AEAA50482; Sat, 5 Dec 2026 19:59:41 +0000 (UTC) From: Fil Dunsky via B4 Relay Date: Sat, 05 Dec 2026 22:59:42 +0300 Subject: [PATCH v8 3/3] irqchip: Add Cortina Systems CS75xx peripheral interrupt controller X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Message-Id: <20261205-cs75xx-intc-v8-3-a8159d212d38@gmail.com> References: <20261205-cs75xx-intc-v8-0-a8159d212d38@gmail.com> In-Reply-To: <20261205-cs75xx-intc-v8-0-a8159d212d38@gmail.com> To: Thomas Gleixner , Radu Rendec , Rob Herring , Krzysztof Kozlowski , Conor Dooley Cc: linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Fil Dunsky X-Mailer: b4 0.16.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1796500779; l=6623; i=filipp.dunsky@gmail.com; s=20260930; h=from:subject:message-id; bh=nEt0A9rlOX4bkNV3zqhtzEKBkW4TxO8gRdED/mHqo0Q=; b=QBqzK/UzOl3roa0fK16knAeJO06mPJf3OBJTp5hFrHREFB1+1en+TFwQvSSVIMDaZhC9vnCxq 0KndJcpfhaWCg2iVOHJgwlUWH6Fkk8X6HNaFMWWyadftkskxKdxoyO5 X-Developer-Key: i=filipp.dunsky@gmail.com; a=ed25519; pk=JAYP8e2rJ54DHOmhNtXud8rl1igAaAXoOHxtJmVXI1g= X-Endpoint-Received: by B4 Relay for filipp.dunsky@gmail.com/20260930 with auth_id=1085 X-Original-From: Fil Dunsky Reply-To: filipp.dunsky@gmail.com Content-Transfer-Encoding: 7bit From: Fil Dunsky The low-speed peripherals of the Cortina Systems CS75xx SoCs share one GIC interrupt. A status register reports the level of 15 sources, and an enable register masks them. 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 CS75xx platform support. Use irq_domain_instantiate() to initialize the generic chip and install the parent handler before the domain is published. Pass the transient register base and parent IRQ through init_data. Take the generic chip lock while reading the interrupt status and mask cache so a concurrent mask change cannot mix stale status with a new mask. Release the lock before dispatching child IRQs, which can update the mask themselves. Link: https://lore.kernel.org/all/87mrqpov7z.ffs@fw13/ Link: https://lore.kernel.org/r/87zeuoogwp.ffs@fw13 Link: https://lore.kernel.org/all/sashiko-outbox-250607@kernel.org/ Signed-off-by: Fil Dunsky --- drivers/irqchip/Kconfig | 12 ++++ drivers/irqchip/Makefile | 1 + drivers/irqchip/irq-cs75xx.c | 135 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 148 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..f6bc46f450 --- /dev/null +++ b/drivers/irqchip/irq-cs75xx.c @@ -0,0 +1,135 @@ +// 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 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#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); + + scoped_guard(raw_spinlock, &gc->lock) + 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_chip_init(struct irq_chip_generic *gc) +{ + const struct cs75xx_intc_setup *setup = gc->domain->init_data; + + 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; + + return 0; +} + +static int __init cs75xx_intc_domain_init(struct irq_domain *domain) +{ + const struct cs75xx_intc_setup *setup = domain->init_data; + + 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, + .init = cs75xx_intc_chip_init, + }; + 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, + .init_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