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 1FC9E606A32D for ; Thu, 3 Dec 2026 02:46:28 +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=XWIh29Ef; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=p2p+Xqxw 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-Unsubscribe-Post: List-Owner; bh=qL1i4/VKoGVTNAQBPOS1eFnaiHZ5on+P8ArADRSDVfQ=; b=XWIh29Ef/MyPiO 9WU0eVl/l1TXZR03R5PL0VJxgKEyzhC6pI3iecNZYqv4DQxzebHPQ0ebnjfFUUnC1109zbsollT2n UI6p5cFn883O0n1wp0PWubxQ266V9sXQPOqaZe3JV6KVPFwSQJccxomemt1ryDxSqcUOiCf5T3MUh ZDs7Vhm/e+E15G65tK+dMgqciNwFEGYva+v5igQecl4IhfD6KijyYHJSO69j5KWIT86ZIXHhGpYcV vqnpG7V87LSbNoSymzZ4DctU0mhcUZBoTi/OHi5SrucuVq6uh4QsD/pHYR7+ERQiNIIpnEqIywKH+ Yjal7ki9qKHkFxyn0oOQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.100.1 #2 (Red Hat Linux)) id 1xYwpm-0000000DGy6-2SK8; Thu, 03 Dec 2026 02:46:17 +0000 Received: from mail-dl1-x122a.google.com ([2607:f8b0:4864:20::122a]) by bombadil.infradead.org with esmtps (Exim 4.100.1 #2 (Red Hat Linux)) id 1xYwpg-0000000DGtr-3KxZ for linux-arm-kernel@lists.infradead.org; Thu, 03 Dec 2026 02:46:06 +0000 Received: by mail-dl1-x122a.google.com with SMTP id a92af1059eb24-1b5786e099cso14450724c88.0 for ; Wed, 02 Dec 2026 18:46:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796265964; x=1796870764; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=qL1i4/VKoGVTNAQBPOS1eFnaiHZ5on+P8ArADRSDVfQ=; b=p2p+Xqxw9q0kBJI/Zz8i9mR/eHPh1pFMD56k6WOF6PM3nrhjrIXMiCzJKS/oSZ0Req XjqhJdWG2YdOGNuvqG8b1xOM7OonFDqWBCeoQ+EqBFknuaN1+Zld002u4QuS56+g/t/s SR0NuhDbNUHtLljk1jnHqe9vrQ16hkxYdgydjd4L31iWgxflQo2tTswLSR7PStuy+tbQ P378Zj7PjWUx9WYv4EsHTLjya0FBhX7NR/ooq3EJyHD9MOUESqTwKMFtfEyPvug6S4P4 3MaVpvC05LRygRZFs51wVn8Z2OfdSurIjLqeHFGkSOzGh1ztJ011sCNOF0QnWgyZyAXJ XThw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796265964; x=1796870764; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=qL1i4/VKoGVTNAQBPOS1eFnaiHZ5on+P8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JKOypKo6QO44/D4LX+gDD7VIysAV84UwD14Bpe8z7YfCkWPYaqU+vn/K2Eato 9ElGZRl3ua5Uk/C5dNJVxsSOi3AFWHWl9nEsEop6HdrYtO5bQW3IcsOjyCvn7Cjd5k3UgP3/vTW 9nlthEHuOPFxDMyqIQjRJoaqVLZzfcqhOUQgYl4t1D6n/cYSO2M/opV9f4SZECPj9dp01nKp1+w c X-Received: by 2002:a05:701b:4583:10b0:185:33ab:4d55 with SMTP id a92af1059eb24-1b5569101fdmr38952711c88.29.1796265963724; Wed, 02 Dec 2026 18:46:03 -0800 (PST) Received: from debian.tfbnw.net ([2620:10d:c090:400::5:6099]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-38567ea2cc5sm110161104eec.29.2026.12.02.18.46.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Dec 2026 18:46:03 -0800 (PST) From: Pablo Mazzini To: Linus Walleij , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland Cc: Pablo Mazzini , Norman Herms , Alastair D'Silva , Andre Przywara , linux-arm-kernel@lists.infradead.org, linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-sunxi@lists.linux.dev Subject: [PATCH v4 1/3] pinctrl: sunxi: dt: number the IRQ banks from the first one that has IRQs Date: Thu, 3 Dec 2026 02:43:35 +0000 Message-ID: <20261203024338.13729-2-pmazzini@gmail.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20261203024338.13729-1-pmazzini@gmail.com> References: <20261203024338.13729-1-pmazzini@gmail.com> X-Archived-By: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.9.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20261202_184605_459717_0C34092C X-CRM114-Status: GOOD ( 17.72 ) X-Spam-Score: -2.1 (--) 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: , Sender: "linux-arm-kernel" X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,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 prepare_function_table() starts counting the IRQ banks at bank 0, so on SoCs without PortA the first IRQ bank gets number 1. On the A523 and A733 this numbers PB to PK as 1 to 10, and PK is written past the end of irq_array. Start counting at -1 instead, so that the IRQ banks match the interrupts in the DT. irq_bank_map then maps them to the hardware, and both SoCs need one for different reasons. The A523 does not implement PortA, but has IRQ registers for it, which its map skips. The A733 uses the NCAT3 layout, where the IRQ registers are part of the GPIO bank registers, so its map gives the GPIO bank. Apply the map to that layout too, which so far ignored it. Signed-off-by: Pablo Mazzini Tested-by: Norman Herms # Radxa Cubie A7S (A733) Reviewed-by: Alastair D'Silva Tested-by: Alastair D'Silva # OrangePi 4 Pro --- drivers/pinctrl/sunxi/pinctrl-sun55i-a523.c | 6 +++++- drivers/pinctrl/sunxi/pinctrl-sun60i-a733.c | 6 +++++- drivers/pinctrl/sunxi/pinctrl-sunxi-dt.c | 4 ++-- drivers/pinctrl/sunxi/pinctrl-sunxi.h | 7 ++++--- 4 files changed, 16 insertions(+), 7 deletions(-) diff --git a/drivers/pinctrl/sunxi/pinctrl-sun55i-a523.c b/drivers/pinctrl/sunxi/pinctrl-sun55i-a523.c index 001bd42afa3e..9ebe0136d736 100644 --- a/drivers/pinctrl/sunxi/pinctrl-sun55i-a523.c +++ b/drivers/pinctrl/sunxi/pinctrl-sun55i-a523.c @@ -17,7 +17,11 @@ 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 }; +/* + * The A523 does not implement PortA, but has IRQ registers for it, so + * the map has to skip them. + */ +static const unsigned int a523_irq_bank_map[] = { 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-sun60i-a733.c b/drivers/pinctrl/sunxi/pinctrl-sun60i-a733.c index 456d9170c2a2..1540a8420e13 100644 --- a/drivers/pinctrl/sunxi/pinctrl-sun60i-a733.c +++ b/drivers/pinctrl/sunxi/pinctrl-sun60i-a733.c @@ -21,8 +21,12 @@ static const u8 a733_irq_bank_muxes[SUNXI_PINCTRL_MAX_BANKS] = /* PA PB PC PD PE PF PG PH PI PJ PK */ { 0, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14}; +/* Maps from the interrupts in the DT to the GPIO banks. */ +static const unsigned int a733_irq_bank_map[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; + static struct sunxi_pinctrl_desc a733_pinctrl_data = { - .irq_banks = 10, + .irq_banks = ARRAY_SIZE(a733_irq_bank_map), + .irq_bank_map = a733_irq_bank_map, .io_bias_cfg_variant = BIAS_VOLTAGE_PIO_POW_MODE_SEL, }; diff --git a/drivers/pinctrl/sunxi/pinctrl-sunxi-dt.c b/drivers/pinctrl/sunxi/pinctrl-sunxi-dt.c index aeaf5534cf80..ea90eb28d9e7 100644 --- a/drivers/pinctrl/sunxi/pinctrl-sunxi-dt.c +++ b/drivers/pinctrl/sunxi/pinctrl-sunxi-dt.c @@ -208,8 +208,8 @@ static int prepare_function_table(struct device *dev, struct device_node *pnode, * Assign the function's memory and fill in GPIOs, IRQ and a sentinel. * The extra functions will be filled in later. */ - irq_bank = 0; - last_bank = 0; + irq_bank = -1; + last_bank = -1; for (i = 0; i < npins; i++) { struct sunxi_desc_pin *pin = &pins[i]; int bank = (pin->pin.number - pin_base) / PINS_PER_BANK; diff --git a/drivers/pinctrl/sunxi/pinctrl-sunxi.h b/drivers/pinctrl/sunxi/pinctrl-sunxi.h index 7c2f29e75519..09ebf67767c0 100644 --- a/drivers/pinctrl/sunxi/pinctrl-sunxi.h +++ b/drivers/pinctrl/sunxi/pinctrl-sunxi.h @@ -257,12 +257,13 @@ static inline u32 sunxi_irq_hw_bank_num(const struct sunxi_pinctrl_desc *desc, static inline u32 sunxi_irq_base_reg(const struct sunxi_pinctrl *pctl, u16 bank) { + u32 hw_bank = sunxi_irq_hw_bank_num(pctl->desc, bank); + if (pctl->flags & SUNXI_PINCTRL_NCAT3_REG_LAYOUT) - return pctl->bank_offset + bank * pctl->bank_mem_size + + return pctl->bank_offset + hw_bank * pctl->bank_mem_size + A733_IRQ_REGS_OFFSET; - return IRQ_REGS_OFFSET + - sunxi_irq_hw_bank_num(pctl->desc, bank) * IRQ_MEM_SIZE; + return IRQ_REGS_OFFSET + hw_bank * IRQ_MEM_SIZE; } static inline u32 sunxi_irq_cfg_reg(const struct sunxi_pinctrl *pctl, -- 2.52.1