From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.41 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796265965; b=lXXGE77Fd/lPd7HsonDuqbGOgh6INsyUbtS0Fb4nST3hf0dA/NeFCnYmHowJjD/i2sRi 9DFIz1iRI/qvdtIkreUdL6KhJhIuTiRBWQWKNLzOq2TJMLCBRMo1blQzqGsHAzB794UIY QG//wWlRwb8yIZlqAXmmBMbR0DeCMOEsEKxNKomf7AOjzX0RM8z925O5E0+WXWHhedd2Q SWsNhSWWKHSlfdD6BA80dYXw8hgwD/q+OpRDDFEzoXkljaz9FlzoJft0bEY4PUaREIInx qxxf/4+Ac63e7VeRtcUKDhDkYbsrUWwRhMakXn83wk2wZNaXufEmTlFM5V3DxcRt7aw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796265965; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: From:To:Cc:Subject:Date:Message-ID:X-Mailer:In-Reply-To:References: MIME-Version:Content-Transfer-Encoding; bh=qL1i4/VKoGVTNAQBPOS1eFnaiHZ5on+P8ArADRSDVfQ=; b=pESQUQ4LsH8Rsbkqu3UYbDSLM7KFeJZ58Fi6mg5ZQVxrfKY5G6G36fzeVEmSbi19h0Bt RBM4vr0Np/PRvQ3BX86t4t1h/Q8jFh+vkAZyrfZIf//mJBhg9yHqIwpNs4sWCR6dy0skK VD1EyQ5FhTL++sMJyEOhfp3Qjoo3oxc7PQ9Arm217f4qkD4b4+lTpWF69jcElbb0GAmxB miUFdc/H4yWjK3M/MFPkva9T76bgSUQfrm+i+hAKbv+qRE+ar/zmrzVmBKa/2mNubmQNJ VIVvLD6k++vBYqfXyvrE8CMqHYsP7CmCn3oYv8UdZRQZHNO4LDYwKCB2AT2j1jnd4yg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=vGJiZK0W; arc=none smtp.remote-ip=74.125.82.41 Received: from mail-dl1-f41.google.com (mail-dl1-f41.google.com [74.125.82.41]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A708B606A333 for ; Thu, 3 Dec 2026 02:46:04 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org A708B606A333 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=vGJiZK0W Received: by mail-dl1-f41.google.com with SMTP id a92af1059eb24-1b563e32936so9495786c88.1 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.linux.dev; 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=vGJiZK0WvyNB2QIPf8moUSnw+1jXOej1kR9FZN60AQq2/0BHeIzcBLHfuWWunSVspn 3onGJUppVZ5V6cBQ+eJiNuRHafRrOiKszgp7yu6j1vLiUg9TblxUn17h1UXlk3zC7R4H eOr9MrHK9YqCFTOHUmvbq5Q7NdsplCXdseZjSkOr4DB1r+Kfkgvcva3dPOhbGJzy1BXq r2Xd5jMvkFn9Oijxw0fgihHciD7JjWp0xrB2BLmCTIKMR1jasUHii6uGed68WLucveo4 FLkwhDi2hwR9JrunE6keKFyzuN0Dx4yvwP4naAciHlWfqgGQ5DSR/UvtXCQ/dkchpxV6 gTSg== 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+P8ArADRSDVfQ=; b=Uf5jZ/yfRdr1ZujG9iQv8xxo/DgE5LayX0Ybvi/9/HIY1Q4ee0FW30meziAgwMBF2g XxI0efyXNaPDLN5Jb1yhzF4E5Y+icoZy+sqD9O0X14dVXNRUj8WJD11i4r+nMuXHLZvu cvebTuBogTp6ptxY5teMQIwOiJrosGIr/ors5idxqcl1eLBKGfBE4Brtu6OnpdNKWP2r aji+cdfP7AoeKZ+igxq8r/m3BAQwnNYY4J642gSGaONEEKZoq3xGbHNOaTKnE+2mmPJJ BUXUsTsj9Zl2AocMTkDot73FdV/tGSyHayxOHzODJf06rs6Rsc05BqvPCbsm3nBxQ7QO j6lQ== X-Forwarded-Encrypted: i=1; AL+hErFM/TbmgtbzjR3Uomr2IKaSCVvAWNUYy1FEvXMkxrwhZxe327F7zsPlhVxVAHhG8KRxfouCvBi05qVKow==@lists.linux.dev X-Gm-Message-State: APuU4Z+sTVatAEm2msWV/KH02h6V/JYJqmhhDBwIpDRrFV2YGMj3Hgnm 1ue05udyjl5dLCHPpEfaCOEH5Lz1AJDUKjE/MKINQVYWtoG8W2JoY12g X-Gm-Gg: AZFdTZcUoVk05lLlrjUPhYilYA920TSpjkUYfJfD5lRsYFmwgfMssTTBnI2J1/zLbrj 9i9i2tN+7Yt2u6wE92croD/eRrtsMJ27xx2vywzDysI+EBLLpodo2fBUOcCM4Pw2g8Zrl32jXyO YWMySNAiyu+LfVVD9YcLOoPSPd90ACKTJr9A2L8zxZwTvQQ/sbTwg9AdDFrITC2ZfTkwiXLSIEu EQ5w7WF4hXfSvJhw8sK60M7zt5GyYt8Acr4nvurXRgnxJw/H7Xjs3+J9gwpCi7sraKIyfjUjqp9 preGED1phIl040WRVrU0GAerEfBfXohx1OmkyCPsSFHxqaOijkm6dt/qRwwAyiuBET6AglYyO3k HMcuWyRb/rWfEArjpp1GhcoWFwCyzEJp2o4aMXSLWBp5mVo7Ebek2mzyQ4Dv+10t0Bfs8oHfKnA Fsc9zqmQy55DWEqrNeef3WUd1nBPl5hiAinJCUvsbBtsiVgnFeuhjxMxsG7y1NNvGaQWBedZigU TLsNzuazMbutdIdKx+hlvRqdbDmQtwWs5LSqQ2kOuVww9wInPGvIhqg+1bfY6c6JnlL4CYJpCzB /CQHEdpHVefyE6U+uylA+t3ufWX50r41iXQycN20AmQCrPaH9M3BURRrh9WLZFFXIFOWMzD0e1W g 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-Mailing-List: linux-sunxi@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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