From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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.subspace.kernel.org (Postfix) with ESMTPS id B6055606A322 for ; Tue, 1 Dec 2026 16:32:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=smexhTL7; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=mZ3eZbFm DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:Reply-To:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id: Content-Transfer-Encoding:Cc:To:In-Reply-To:References:Message-Id: Content-Type:MIME-Version:Subject:Date:From:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Unsubscribe-Post:List-Owner; bh=Y3dDJi0mhxTM9YncifB+qJ95bcErfSSkTlJZj5dPmeA=; b=smexhTL7vmKCod/RKbESINj3jP IgZRVTFqueNI7aBT1p7uNgP57/FQe3rLOjgD0g6D1LH9u+TDxp7nlavFCfFnTPLcXOUgvnhqjQ/LC +jAbRDLbVRPo1+uBX3YZ9p9FqLs5wBoHhZx/xPEYJhHVM7WiBwxa/vPnaFNoz5B/A7d43JubFxcIl LxIoxQEgATlzlcSYd8MfTBTUb/Wn4vO/mlPNIlE2a4kuB7lNBql7ru+hpswIOtkHF7Tpn0U3iNouu S8uCAdxSFu14he2YdiKJqBK5csz6nnHi3I94A23VL/jC8iGecbvhCKvrzGfC/kTGbxwzULhi0XCBC tFKVnHIQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.100.1 #2 (Red Hat Linux)) id 1xYQmO-00000008jaj-20Uo; Tue, 01 Dec 2026 16:32:32 +0000 Received: from sea.source.kernel.org ([172.234.252.31]) by bombadil.infradead.org with esmtps (Exim 4.100.1 #2 (Red Hat Linux)) id 1xYQmM-00000008ja1-3Bz6 for linux-arm-kernel@lists.infradead.org; Tue, 01 Dec 2026 16:32:30 +0000 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by sea.source.kernel.org (Postfix) with ESMTP id 2C8C1449B3; Tue, 1 Dec 2026 16:32:30 +0000 (UTC) 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=1796142749; b=RfD2GzEm1OmIf73SUOIRRp+ADKOI7i1c13Q3SYi0qc7qZE7M9THkTY3HaPhz5KTOZtnI Drmu/yvmRx74P9APKXEseCcVquR/71z7cNC22EBdqn+f02IfaQrgB5IwQX2kNKD1tp8Ih ztb2T0tyQmof+TJX5fOy/oBmuZdi4Tsl2C8ScelUh3AMXLAsRuYDWuPeN/OIkcm+9CAVt uDuo4lLpvH7z9omt3tZx0/FpIh8Z2u4FOnTt6cE4YpYnc/A/G6t0usBWVl9ATjYpy6kcC 7w++XbyO/PMokmSSO3ypS4wTqHMxdeLPHYAEZgHinQWPKzUZjYkeg/Up/29pMOAQGPg== ARC-Message-Signature: i=1; d=kernel.org; s=arc20260519; a=rsa-sha256; c=relaxed/relaxed; t=1796142749; 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=Y3dDJi0mhxTM9YncifB+qJ95bcErfSSkTlJZj5dPmeA=; b=12RXJByNmEaF+JnGuJK6bHLx/H4HTf0J8mt8jVtEN2wdJyPwBQmAjNlzg4l5G0sC4MGo ynLSjOGhPoehXNbZaSm/7MA6le6ScKsPKV66KSpyRgoSSGjFpZ4ljtiSORVLWYwbcKoft evY6zE+ZJ7UUvO/EmX0sSBfOYuDxVmwrQXCyBvGFoQS1ANCPvY7Px3uVrT5I/7JBIQ8gH sUUVpwyVCSYBKkvEA+vRx0AqeIvbBJUGy6VhZuzS7I99KUKIVqwBi8HVcZ0C2udYvPQpd mvk0U7v4sYCBAfTCA1QE/vDNIF42jA40Hb8wnxuZm+gFmLEJtlioLl//YbVZ2KFXt0A== 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 BD77E1F00899; Tue, 1 Dec 2026 16:32:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796142749; bh=Y3dDJi0mhxTM9YncifB+qJ95bcErfSSkTlJZj5dPmeA=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To; b=mZ3eZbFmAVEJRL9t6Upqm9HTumkyBiVExl9wAYPTnI7hiUL7GUt+tRiQeHIHRUW6y 1YwINg1rYTM1G29MDnV0LBfSrRbAQ5Xe3IhmzGeATLWyl7VTZcfjXe2yTiuzrOI0NF 0ESJpU9JGKbZj6z3FumTQi+xrsChuUXLOwwta6C5BH7RHT7G9SJgWZD4K8m+Zs/Zfk PQ0ggyFCW2UwjGLXIVkENTN/MQH2pbNM4ldUL5Yn5u9pGj2qyCRpX+9/52zHJeDZz4 Aan+geY+0Cv+HS/TFAP8NlGM6ekDxCwJ0o2nHSNvOdgyet5in/szW8dvVHwmW9jO9q b+MhSSTsEhVww== Received: from nexus.subspace.kernel.org (localhost [IPv6:::1]) by lkml.kernel.org (Postfix) with ESMTP id 4531A4EEB1; Tue, 1 Dec 2026 16:32:27 +0000 (UTC) From: Fil Dunsky via B4 Relay Date: Tue, 01 Dec 2026 19:32:27 +0300 Subject: [PATCH v6 2/2] irqchip: Add Cortina Systems CS75xx peripheral interrupt controller X-Archived-By: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Message-Id: <20261201-cs75xx-intc-v6-2-bcd0a80afd62@gmail.com> References: <20261201-cs75xx-intc-v6-0-bcd0a80afd62@gmail.com> In-Reply-To: <20261201-cs75xx-intc-v6-0-bcd0a80afd62@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 X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1796142745; l=6359; i=filipp.dunsky@gmail.com; s=20260930; h=from:subject:message-id; bh=kC63pygCBRRsZRngFigEtRzccoF/P+1+zldAEOMUvPA=; b=7hvzuTXTfMpOPUGcDLE7BU8kJmHbLZuLkLQOxTwgdgMZ28uojD47ChJpTCA55V5T6AmEfotre b9vGqROmyIuBz63+sHvdUY18txKgP2gGizDV/G7FJY9raWRji3rObKK 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 Content-Transfer-Encoding: 7bit X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: filipp.dunsky@gmail.com Sender: "linux-arm-kernel" X-Spam-Status: No, score=-18.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 From: Fil Dunsky 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 --- 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 +#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); + + 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