From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=217.140.110.172 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796311403; b=GZC6g2yv+UbexF9T+Hkll/Ac5QGrSka6Dxq8TOnElcqTtGbZoDmZvHmaa58MsWdgNZdS pgGz3D6lRQxGj6rICmaw76B1IFmLAHwdJH+Xb/sSFebdWT0KVXsWuhLRLdO0DVx3mQ+hv xlAqLk8v4aKp/ZliLBErTCIEauydJ3UKFlPLzAtOqf4t+2bMsfERNAGWLA+cHqXgAOAQO 84u/CUOq52/hfMndxBg4lZ9DLPjAJGV8cYPUWv6AnkYYTdZ3gJXD0s3dbg8xgx6zu6vVo WQ2wWLHJzz07nj+U5VrEXY2VtRrxG+td6ucsJkRcdAsApMtwFdztMEWz6A9WAXO1DZw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796311403; h=DMARC-Filter:Received:Received:DKIM-Signature:Message-ID:Date: MIME-Version:User-Agent:Subject:To:Cc:References:Content-Language: From:In-Reply-To:Content-Type:Content-Transfer-Encoding; bh=fDtAm3KwspXqDZxNixjWrjExgyhyn3ibuXxMtkhZXWw=; b=16+eE9DGAauhb/AFxzuBhzAxqWUQ2AC5EXTjl7rMYNdVeGsynTGtwM/gaffZzAQunFbT hSDMm4P1Cu2abvtKcYxBLY1jCnmQK3kTd2reY5+Bh8ZMs/Y8g0802BEtkCgDFFpkgt1mE 6fzInMR9p0MloHMrlxA0G4PJ28c6O/XhoVHH4tDZWJ5SXQEULOeFtgxAtUSowE8zCld9F i3HN+VVixzS/r8M81b0UEef5tpo/CWmWvijuDdo/9t84s1UUTWeMDw0Tidi2qASng/dTD XI+BRohhobV+ptW3WOGoR4sHyI3DRgtlnnG3bghjKccvbAR7ly1d9iHLDFPqaHdAzRQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=arm.com; spf=pass smtp.mailfrom=arm.com; dkim=pass header.d=arm.com header.i=@arm.com header.a=rsa-sha256 header.s=foss header.b=cvkseITT; arc=none smtp.remote-ip=217.140.110.172 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 43418606A32F; Thu, 3 Dec 2026 15:23:22 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 43418606A32F Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.a=rsa-sha256 header.s=foss header.b=cvkseITT 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 AC8A7497; Thu, 3 Dec 2026 07:23:18 -0800 (PST) Received: from [192.168.178.24] (usa-sjc-mx-foss1.foss.arm.com [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 83AE53F7D8; Thu, 3 Dec 2026 07:23:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=arm.com; s=foss; t=1796311401; bh=7i9BKG93kvHksGFb2y0+lxQDF1oqojt3wzx/8rhC3qU=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=cvkseITTbZFz3J0SEHrEM9nrILygJwXvraIkns/De2ivW8ACEQWcTSiweQ8dF3X/N Ein5KSGw1WQLRnLnU0UNW7B9bwcFTZnnj9OdcxNGsK7AM8pGbGg9kNROtOrhw+UZif F+3jLICH4zDm76WRf0kOrpBMTilRXNnqlVuCo4ig= Message-ID: <95d61030-bf40-4508-9836-946333f08211@arm.com> Date: Thu, 3 Dec 2026 16:23:18 +0100 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 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v4 1/3] pinctrl: sunxi: dt: number the IRQ banks from the first one that has IRQs To: Pablo Mazzini , Linus Walleij , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland Cc: Norman Herms , Alastair D'Silva , linux-arm-kernel@lists.infradead.org, linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-sunxi@lists.linux.dev References: <20261203024338.13729-1-pmazzini@gmail.com> <20261203024338.13729-2-pmazzini@gmail.com> Content-Language: en-GB From: Andre Przywara In-Reply-To: <20261203024338.13729-2-pmazzini@gmail.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Hi Pablo, many thanks for the quick turnaround! On 12/3/26 03:43, Pablo Mazzini wrote: > 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 So this looks good to me now, thanks for the changes! I tested this on A523 and A733, where the GPIO IRQs are wrong without this patch (assuming the original/new A523 DT), and are working with this change: verified in /proc/interrupts while pushing the buttons. I also tested on H616, without regressions - as expected the H616 and others are unaffected by this change. Reviewed-by: Andre Przywara Tested-by: Andre Przywara LinusW: this is good to go into v7.4 fixes as well, though it conflicts with the other fixes. The resolution is simple, but please just let us know how you want to handle this. Cheers, Andre > --- > 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,