From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=68.232.154.123 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796141232; b=uMdEpmvwAybajpmKlynri8AXWX68+KCJHzoBTRLU2PHPGIRM69KR9HgyeBaz+WjelvzK wxQFbOTlExgJRoNDa4pOUgM4PCOrfcC0+KBEeYFOsDzavX5Q6GJg+brU2KdC6t3wvpfaA BrHC80rqNHczFI6ShJ9HTdRhsqnVv+yS1w8bWk5NiNys66jIfd8COH6Rc3k/bj7fVaskT 6wQyPtPrHdwBaJeMg3KrRSZPeDLEzxbTGsuYKGwmmVZUWuOZWhhblRoAWAyvainEXzKDM O9g3NSd9y3pZWfe9kgO15mS620NeWGIRF60176pal/v6ePAeUy5iDRkKNB7Z04u/dKQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796141232; h=DMARC-Filter:DKIM-Signature:X-CSE-ConnectionGUID:X-CSE-MsgGUID: X-IronPort-AV:X-Amp-Result:Received:Received:Received:From:Date: Subject:MIME-Version:Content-Type:Content-Transfer-Encoding: Message-ID:References:In-Reply-To:To:CC:X-Mailer; bh=hE6D01AsI6fCehaIgkK1uW4yBxJy4WtD1v78lH2LRVA=; b=I8X52rdX45VPdjwcIENcr2Z0+QdRSng56eutYTcS+8MLZen0m8nDNUtFHn68Wj1oSE+v RXJCvcxTOomqEhDgvFcbyv7j+P67E0HUqw7oKUU64djQTZ74eQrLCsbrmqQd1UeF1Btit 6Lc6XiivQXK+eqq31ER66d30fTJuIa/2xTRHnzK/EB7FZvBsra0092/9tep+iwtuhcSIs f5Jj/AX1X1akROeXx4oHiUNo10jzujaELtYUIUt6RzDvPjBxxXSQLQT8FLG0n5I76Gm/D XAJEzmvhqdMZwtIYNkBm1o7SE2rmvzAKS4shqniwi5QNifh24YMpjwMBjoFAs5XrbRA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=microchip.com; spf=pass smtp.mailfrom=microchip.com; dkim=pass header.d=microchip.com header.i=@microchip.com header.a=rsa-sha256 header.s=mchp header.b=x3TDtXuj; arc=none smtp.remote-ip=68.232.154.123 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.154.123]) (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 BC7EA606A695; Tue, 1 Dec 2026 16:07:11 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org BC7EA606A695 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=microchip.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=microchip.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=microchip.com header.i=@microchip.com header.a=rsa-sha256 header.s=mchp header.b=x3TDtXuj DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1796141240; x=1827677240; h=from:date:subject:mime-version:content-transfer-encoding: message-id:references:in-reply-to:to:cc; bh=SVTvfaf0Kt7i/kwIeAKB+24VBKPYkBaejKFY/TlgJys=; b=x3TDtXujVckzOOv2Uhv9JvSJG0Hm0/Lck9TzNpbkSG3oKtJ9qpvZWQOt 30YOLbP4WpE5O85bg/QeJ7jjpMJRhD9JFuLloIIPGawEYLNug5Yjkd/JO obrk+6Kg2TlrstSabGsamOFsBqbPlt/TvFjOk6mwUcPAFjgAxBch3+XcA ic8OYfUivtoraHJrV3k98dTFqTxtWITQbHjsjEgJHoJdx/jE83ArYptgZ SqfClRmDg9SgZ22f3PRHTIJT+eM67cWPKVs2X5Oum+OndLopP+Zi4/A/S 99jrT8orW803wox5s+WAYY25r0tFt3HJ3mW06ohY+zcTvuj3iocLiYbcl Q==; X-CSE-ConnectionGUID: Y72wRj2pTv64CsmB+kvpJA== X-CSE-MsgGUID: 4CNDlaNyTI2tj1FBIRFhfA== X-IronPort-AV: E=Sophos;i="6.27,245,1787036400"; d="scan'208";a="66310792" X-Amp-Result: SKIPPED(no attachment in message) Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa4.microchip.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Dec 2026 09:07:19 -0700 Received: from chn-vm-ex04.mchp-main.com (10.10.87.151) by chn-vm-ex2.mchp-main.com (10.10.87.31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.2.2562.57; Tue, 1 Dec 2026 09:07:10 -0700 Received: from MON-LT-C78453.mchp-main.com (10.10.85.11) by chn-vm-ex04.mchp-main.com (10.10.85.152) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.58 via Frontend Transport; Tue, 1 Dec 2026 09:07:09 -0700 From: Charles Perry Date: Tue, 1 Dec 2026 11:06:27 -0500 Subject: [PATCH 2/2] irqchip: Add Microchip PIC64-HPSC/HX NVM 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" Content-Transfer-Encoding: 7bit Message-ID: <20261201-linux-7-4-rc4-pic64hpsc-nvm-intc-v1-2-e87ed786dc1b@microchip.com> References: <20261201-linux-7-4-rc4-pic64hpsc-nvm-intc-v1-0-e87ed786dc1b@microchip.com> In-Reply-To: <20261201-linux-7-4-rc4-pic64hpsc-nvm-intc-v1-0-e87ed786dc1b@microchip.com> To: Thomas Gleixner , Radu Rendec , "Rob Herring" , Krzysztof Kozlowski , "Conor Dooley" CC: Romain Caritey , , , Charles Perry X-Mailer: b4 0.16.0 From: Romain Caritey Microchip PIC64-HPSC features 4 NVM subsystems, each composed of a NAND, xSPI and pflash controller. PIC64-HX features 2 NVM subsystems, each composed of the same controllers as for PIC64-HPSC, with the addition of an eMMC/SD controller. For each of these SoCs, the interrupts of each of the NAND, xSPI and eMMC/SD controllers go through a local NVM interrupt controller which then connects to the APLIC. All source interrupts in a subsystem share a single APLIC line, so their affinity cannot be set individually. The driver therefore registers a regular IRQ handler rather than a chained handler. This lets userspace set the affinity of the parent NVM interrupt, which then applies to all the sources behind it. Signed-off-by: Romain Caritey Signed-off-by: Charles Perry --- MAINTAINERS | 2 + drivers/irqchip/Kconfig | 8 + drivers/irqchip/Makefile | 1 + drivers/irqchip/irq-mchp-pic64hpsc-nvm-intc.c | 226 ++++++++++++++++++++++++++ 4 files changed, 237 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index 44540a1eb2b8..ecd8ba4f83c2 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -18432,7 +18432,9 @@ F: drivers/tty/serial/8250/8250_pci1xxxx.c MICROCHIP PIC64-HPSC/HX DRIVERS M: Charles Perry S: Supported +F: Documentation/devicetree/bindings/interrupt-controller/microchip,pic64hpsc-nvm-intc.yaml F: Documentation/devicetree/bindings/net/microchip,pic64hpsc-mdio.yaml +F: drivers/irqchip/irq-mchp-pic64hpsc-nvm-intc.c F: drivers/net/mdio/mdio-pic64hpsc.c MICROCHIP POLARFIRE FPGA DRIVERS diff --git a/drivers/irqchip/Kconfig b/drivers/irqchip/Kconfig index 136bab41f801..f72a3648f585 100644 --- a/drivers/irqchip/Kconfig +++ b/drivers/irqchip/Kconfig @@ -821,6 +821,14 @@ config MCHP_EIC help Support for Microchip External Interrupt Controller. +config PIC64HPSC_NVM_INTC + bool "Microchip PIC64-HPSC/HX NVM interrupt controller" + depends on OF + depends on ARCH_MICROCHIP || COMPILE_TEST + select IRQ_DOMAIN + help + Support for Microchip PIC64-HPSC/HX NVM interrupt controller. + config SOPHGO_SG2042_MSI bool "Sophgo SG2042 MSI Controller" depends on ARCH_SOPHGO || COMPILE_TEST diff --git a/drivers/irqchip/Makefile b/drivers/irqchip/Makefile index 16a5fd126c9a..26b13b1075e3 100644 --- a/drivers/irqchip/Makefile +++ b/drivers/irqchip/Makefile @@ -133,6 +133,7 @@ obj-$(CONFIG_WPCM450_AIC) += irq-wpcm450-aic.o obj-$(CONFIG_IRQ_IDT3243X) += irq-idt3243x.o obj-$(CONFIG_APPLE_AIC) += irq-apple-aic.o obj-$(CONFIG_MCHP_EIC) += irq-mchp-eic.o +obj-$(CONFIG_PIC64HPSC_NVM_INTC) += irq-mchp-pic64hpsc-nvm-intc.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 diff --git a/drivers/irqchip/irq-mchp-pic64hpsc-nvm-intc.c b/drivers/irqchip/irq-mchp-pic64hpsc-nvm-intc.c new file mode 100644 index 000000000000..84e4cfdbc5e7 --- /dev/null +++ b/drivers/irqchip/irq-mchp-pic64hpsc-nvm-intc.c @@ -0,0 +1,226 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Microchip PIC64-HPSC/HX NVM interrupt controller. + * + * Copyright (C) 2026 Microchip Technology Inc. All rights reserved. + * Author: Romain Caritey + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define P64H_NVM_INTC_STATUS 0x500 +#define P64H_NVM_INTC_ENABLE 0x504 +#define P64H_NVM_INTC_VALUE 0x508 + +#define P64H_NVM_INTC_NUM_IRQS 7 +#define P64H_NVM_INTC_VALID_MASK GENMASK(P64H_NVM_INTC_NUM_IRQS - 1, 0) + +struct p64h_nvm_intc { + struct device *dev; + void __iomem *base; + struct irq_domain *domain; + raw_spinlock_t lock; +}; + +static inline bool p64h_nvm_intc_hwirq_is_valid(irq_hw_number_t hwirq) +{ + return hwirq < P64H_NVM_INTC_NUM_IRQS; +} + +static void p64h_nvm_intc_update_enable(struct p64h_nvm_intc *intc, u32 clear, + u32 set) +{ + unsigned long flags; + u32 enable; + + raw_spin_lock_irqsave(&intc->lock, flags); + enable = readl(intc->base + P64H_NVM_INTC_ENABLE); + enable &= ~clear; + enable |= set; + writel(enable, intc->base + P64H_NVM_INTC_ENABLE); + + raw_spin_unlock_irqrestore(&intc->lock, flags); +} + +static void p64h_nvm_intc_irq_ack(struct irq_data *d) +{ + struct p64h_nvm_intc *intc = irq_data_get_irq_chip_data(d); + + writel(BIT(d->hwirq), intc->base + P64H_NVM_INTC_STATUS); +} + +static void p64h_nvm_intc_irq_mask(struct irq_data *d) +{ + struct p64h_nvm_intc *intc = irq_data_get_irq_chip_data(d); + + p64h_nvm_intc_update_enable(intc, BIT(d->hwirq), 0); +} + +static void p64h_nvm_intc_irq_unmask(struct irq_data *d) +{ + struct p64h_nvm_intc *intc = irq_data_get_irq_chip_data(d); + + p64h_nvm_intc_update_enable(intc, 0, BIT(d->hwirq)); +} + +static int p64h_nvm_intc_irq_set_type(struct irq_data *d, unsigned int type) +{ + if ((type & IRQ_TYPE_SENSE_MASK) != IRQ_TYPE_LEVEL_HIGH) + return -EINVAL; + + return 0; +} + +static void p64h_nvm_intc_irq_print_chip(struct irq_data *d, struct seq_file *p) +{ + struct p64h_nvm_intc *intc = irq_data_get_irq_chip_data(d); + + seq_printf(p, "nvm-intc-%s", dev_name(intc->dev)); +} + +static const struct irq_chip p64h_nvm_intc_irq_chip = { + .irq_print_chip = p64h_nvm_intc_irq_print_chip, + .irq_ack = p64h_nvm_intc_irq_ack, + .irq_disable = p64h_nvm_intc_irq_mask, + .irq_mask = p64h_nvm_intc_irq_mask, + .irq_unmask = p64h_nvm_intc_irq_unmask, + .irq_set_type = p64h_nvm_intc_irq_set_type, +}; + +static int p64h_nvm_intc_domain_map(struct irq_domain *domain, + unsigned int virq, irq_hw_number_t hwirq) +{ + if (!p64h_nvm_intc_hwirq_is_valid(hwirq)) + return -EINVAL; + + irq_set_chip_data(virq, domain->host_data); + irq_set_chip_and_handler(virq, &p64h_nvm_intc_irq_chip, + handle_level_irq); + irq_set_noprobe(virq); + + return 0; +} + +static void p64h_nvm_intc_domain_unmap(struct irq_domain *domain, + unsigned int virq) +{ + irq_set_chip_and_handler(virq, NULL, NULL); + irq_set_chip_data(virq, NULL); +} + +static int p64h_nvm_intc_domain_xlate(struct irq_domain *domain, + struct device_node *controller, + const u32 *intspec, unsigned int intsize, + unsigned long *out_hwirq, + unsigned int *out_type) +{ + if (intsize != 1 || !p64h_nvm_intc_hwirq_is_valid(intspec[0])) + return -EINVAL; + + *out_hwirq = intspec[0]; + *out_type = IRQ_TYPE_LEVEL_HIGH; + + return 0; +} + +static const struct irq_domain_ops p64h_nvm_intc_domain_ops = { + .map = p64h_nvm_intc_domain_map, + .unmap = p64h_nvm_intc_domain_unmap, + .xlate = p64h_nvm_intc_domain_xlate, +}; + +static irqreturn_t p64h_nvm_intc_handler(int irq, void *data) +{ + struct p64h_nvm_intc *intc = data; + unsigned long pending; + unsigned int hwirq; + + pending = readl(intc->base + P64H_NVM_INTC_STATUS) & + readl(intc->base + P64H_NVM_INTC_ENABLE) & + P64H_NVM_INTC_VALID_MASK; + + if (!pending) + return IRQ_NONE; + + /* + * STATUS may hold a stale edge, already handled while masked. + * Clear it, then dispatch only the sources whose line is still high. + */ + writel(pending, intc->base + P64H_NVM_INTC_STATUS); + + pending &= readl(intc->base + P64H_NVM_INTC_VALUE); + + for_each_set_bit(hwirq, &pending, P64H_NVM_INTC_NUM_IRQS) + generic_handle_domain_irq(intc->domain, hwirq); + + return IRQ_HANDLED; +} + +static int p64h_nvm_intc_probe(struct platform_device *pdev) +{ + struct device *dev = &pdev->dev; + struct p64h_nvm_intc *intc; + int parent_irq; + int ret; + + intc = devm_kzalloc(dev, sizeof(*intc), GFP_KERNEL); + if (!intc) + return -ENOMEM; + + intc->dev = dev; + raw_spin_lock_init(&intc->lock); + + intc->base = devm_platform_ioremap_resource(pdev, 0); + if (IS_ERR(intc->base)) + return PTR_ERR(intc->base); + + parent_irq = platform_get_irq(pdev, 0); + if (parent_irq < 0) + return parent_irq; + + writel(0, intc->base + P64H_NVM_INTC_ENABLE); + writel(P64H_NVM_INTC_VALID_MASK, intc->base + P64H_NVM_INTC_STATUS); + + intc->domain = irq_domain_create_linear(dev_fwnode(dev), + P64H_NVM_INTC_NUM_IRQS, + &p64h_nvm_intc_domain_ops, + intc); + if (!intc->domain) + return dev_err_probe(dev, -ENOMEM, + "failed to create IRQ domain\n"); + + ret = devm_request_irq(dev, parent_irq, p64h_nvm_intc_handler, + IRQF_NO_THREAD, dev_name(dev), intc); + if (ret) { + irq_domain_remove(intc->domain); + return dev_err_probe(dev, ret, "failed to request IRQ %d\n", + parent_irq); + } + + return 0; +} + +static const struct of_device_id p64h_nvm_intc_of_match[] = { + { .compatible = "microchip,pic64hpsc-nvm-intc" }, + {} +}; + +static struct platform_driver p64h_nvm_intc_driver = { + .probe = p64h_nvm_intc_probe, + .driver = { + .name = "pic64hpsc-nvm-intc", + .of_match_table = p64h_nvm_intc_of_match, + .suppress_bind_attrs = true, + }, +}; +builtin_platform_driver(p64h_nvm_intc_driver); -- 2.53.0