From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 99BB7EC01CC for ; Mon, 23 Mar 2026 11:02:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=JnjJuu4oNVc2NLDPBlwPIQPjfyeJaWEgq1bwsChfpyE=; b=S1AkML3/n+OmcS3W0+WN6BB207 0ArRNpfhLgvKjMHao4FzusWIgkNkFEKQ4lU0hHlTw9CYLT+n521Q6TCecgRfOqglTsDembXs8O2+7 ef/8rgxLf5lFZA4Bul98tyy+GWqtlL/d5/3am5I5NlYjXB3y3oObm5Kcm0ULETHcSFP7S1Rp0r3vx sGdqPWrtdlb9roptBGa3kNd6+m7uD0sHfZ1q20OLPZ3Bd/sfXM5fr+LqVd1Q8WWHFtE3GMt+NKsTb uD9KMQkFEY6iM7qD2Q1Vj4eMBby3q72IyCbyhoCphXN9khKd37N9jMmEZ5/NiNAPni9gvTok+lOad WTIBZAKQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98.2 #2 (Red Hat Linux)) id 1w4d36-0000000GYjv-2oR2; Mon, 23 Mar 2026 11:02:20 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.98.2 #2 (Red Hat Linux)) id 1w4d31-0000000GYhE-0L8r for linux-arm-kernel@lists.infradead.org; Mon, 23 Mar 2026 11:02:16 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id A37F6169E; Mon, 23 Mar 2026 04:02:08 -0700 (PDT) Received: from e142021.fritz.box (usa-sjc-mx-foss1.foss.arm.com [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id C4FD23F73B; Mon, 23 Mar 2026 04:02:11 -0700 (PDT) From: Andre Przywara To: Linus Walleij , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland Cc: Michal Piekos , linux-gpio@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org Subject: [PATCH 5/5] pinctrl: sunxi: a523: add missing IRQ bank (plus old DT workaround) Date: Mon, 23 Mar 2026 12:01:51 +0100 Message-ID: <20260323110151.2352832-6-andre.przywara@arm.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260323110151.2352832-1-andre.przywara@arm.com> References: <20260323110151.2352832-1-andre.przywara@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20260323_040215_228511_49E9E271 X-CRM114-Status: GOOD ( 21.75 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The Allwinner A532 SoC implements 10 GPIO banks, each of which is interrupt capable. However the first bank (PortA) is skipped, so the indicies of those banks range from 1 to 10, not 0 to 9. We described the skipped bank correctly, but missed that for the IRQ banks, where we rely on the IRQ bank index to be aligned with the MMIO register offset, starting at 0x200. Correct that by increasing the number of IRQ banks to 11, to cover both the first skipped one, but also the last one (PortK). This fixes a bug where the interrupt numbers would be off-by-one, due to that mis-enumeration. The big caveat is that now old DTs break the kernel, since they only provide 10 interrupts, and the driver bails out entirely due to the last missing one. So add a workaround for this particular case, where we detect the requirement for 11 banks, but only 10 interrupts provided, and continue with 10 IRQs, albeit emitting a warning about a DT update. This would still be broken in terms of interrupt assignment, but it was broken the whole time before, so it's not a regression. Signed-off-by: Andre Przywara --- drivers/pinctrl/sunxi/pinctrl-sun55i-a523.c | 2 +- drivers/pinctrl/sunxi/pinctrl-sunxi.c | 22 +++++++++++++-------- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/drivers/pinctrl/sunxi/pinctrl-sun55i-a523.c b/drivers/pinctrl/sunxi/pinctrl-sun55i-a523.c index b6f78f1f30ac..a1d157de53d2 100644 --- a/drivers/pinctrl/sunxi/pinctrl-sun55i-a523.c +++ b/drivers/pinctrl/sunxi/pinctrl-sun55i-a523.c @@ -17,7 +17,7 @@ static const u8 a523_nr_bank_pins[SUNXI_PINCTRL_MAX_BANKS] = /* PA PB PC PD PE PF PG PH PI PJ PK */ { 0, 15, 17, 24, 16, 7, 15, 20, 17, 28, 24 }; -static const unsigned int a523_irq_bank_map[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; +static const unsigned int a523_irq_bank_map[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; static const u8 a523_irq_bank_muxes[SUNXI_PINCTRL_MAX_BANKS] = /* PA PB PC PD PE PF PG PH PI PJ PK */ diff --git a/drivers/pinctrl/sunxi/pinctrl-sunxi.c b/drivers/pinctrl/sunxi/pinctrl-sunxi.c index 6a86b7989b25..ffee79397590 100644 --- a/drivers/pinctrl/sunxi/pinctrl-sunxi.c +++ b/drivers/pinctrl/sunxi/pinctrl-sunxi.c @@ -19,6 +19,7 @@ #include #include #include +#include #include #include #include @@ -1582,6 +1583,7 @@ int sunxi_pinctrl_init_with_flags(struct platform_device *pdev, struct sunxi_pinctrl *pctl; struct pinmux_ops *pmxops; int i, ret, last_pin, pin_idx; + int num_irq_banks; struct clk *clk; pctl = devm_kzalloc(&pdev->dev, sizeof(*pctl), GFP_KERNEL); @@ -1715,16 +1717,20 @@ int sunxi_pinctrl_init_with_flags(struct platform_device *pdev, goto gpiochip_error; } - pctl->irq = devm_kcalloc(&pdev->dev, - pctl->desc->irq_banks, - sizeof(*pctl->irq), - GFP_KERNEL); + num_irq_banks = pctl->desc->irq_banks; + /* Workaround for old A523 DT, exposing one less interrupt. */ + if (num_irq_banks == 11 && of_irq_count(node) < 11) { + num_irq_banks = 10; + pr_warn("Not enough PIO interrupts, please update your DT!\n"); + } + pctl->irq = devm_kcalloc(&pdev->dev, num_irq_banks, + sizeof(*pctl->irq), GFP_KERNEL); if (!pctl->irq) { ret = -ENOMEM; goto gpiochip_error; } - for (i = 0; i < pctl->desc->irq_banks; i++) { + for (i = 0; i < num_irq_banks; i++) { pctl->irq[i] = platform_get_irq(pdev, i); if (pctl->irq[i] < 0) { ret = pctl->irq[i]; @@ -1733,7 +1739,7 @@ int sunxi_pinctrl_init_with_flags(struct platform_device *pdev, } pctl->domain = irq_domain_create_linear(dev_fwnode(&pdev->dev), - pctl->desc->irq_banks * IRQ_PER_BANK, + num_irq_banks * IRQ_PER_BANK, &sunxi_pinctrl_irq_domain_ops, pctl); if (!pctl->domain) { dev_err(&pdev->dev, "Couldn't register IRQ domain\n"); @@ -1741,7 +1747,7 @@ int sunxi_pinctrl_init_with_flags(struct platform_device *pdev, goto gpiochip_error; } - for (i = 0; i < (pctl->desc->irq_banks * IRQ_PER_BANK); i++) { + for (i = 0; i < (num_irq_banks * IRQ_PER_BANK); i++) { int irqno = irq_create_mapping(pctl->domain, i); irq_set_lockdep_class(irqno, &sunxi_pinctrl_irq_lock_class, @@ -1751,7 +1757,7 @@ int sunxi_pinctrl_init_with_flags(struct platform_device *pdev, irq_set_chip_data(irqno, pctl); } - for (i = 0; i < pctl->desc->irq_banks; i++) { + for (i = 0; i < num_irq_banks; i++) { /* Mask and clear all IRQs before registering a handler */ writel(0, pctl->membase + sunxi_irq_ctrl_reg_from_bank(pctl->desc, i)); -- 2.43.0