From: Andre Przywara <andre.przywara@arm.com>
To: Linus Walleij <linusw@kernel.org>, Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
Chen-Yu Tsai <wens@kernel.org>,
Jernej Skrabec <jernej.skrabec@gmail.com>,
Samuel Holland <samuel@sholland.org>
Cc: Jerome Brunet <jbrunet@baylibre.com>, Yixun Lan <dlan@gentoo.org>,
Enzo Adriano <enzo.adriano.code@gmail.com>,
Vinicius Pedrosa <vinicius.eduardo.pedrosa@gmail.com>,
linux-gpio@vger.kernel.org, devicetree@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-sunxi@lists.linux.dev
Subject: [PATCH 4/7] pinctrl: sunxi: support A733 generation MMIO register layout
Date: Thu, 10 Sep 2026 15:35:15 +0200 [thread overview]
Message-ID: <20260910133519.459011-5-andre.przywara@arm.com> (raw)
In-Reply-To: <20260910133519.459011-1-andre.przywara@arm.com>
After Allwinner changed the layout of the pinctrl/GPIO IP MMIO register
frame only a few years back, the new SoC generation (starting with the
A733) changes the layout again: each port now uses 128 instead of 36 or 48
bytes, and the drive level registers move to make space for the new
set/clear data registers. Also the PortA registers start at offset 0x80
instead of 0x0 as before, to make room for non-bank specific registers,
like the pow_mod_sel registers, at the beginning of the MMIO frame. Finally
the IRQ registers move into each bank's region.
Add yet another quirk bit to mark this case, and set the existing register
offset values to match the new layout. This also requires to add new
members to struct sunxi_pinctrl, to accommodate the extra changes. The
actual runtime code changes are fortunately minor.
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
---
drivers/pinctrl/sunxi/pinctrl-sunxi.c | 14 ++++++++++++--
drivers/pinctrl/sunxi/pinctrl-sunxi.h | 14 ++++++++++++++
2 files changed, 26 insertions(+), 2 deletions(-)
diff --git a/drivers/pinctrl/sunxi/pinctrl-sunxi.c b/drivers/pinctrl/sunxi/pinctrl-sunxi.c
index 5f08c75549b4d..35aa3a8ea1814 100644
--- a/drivers/pinctrl/sunxi/pinctrl-sunxi.c
+++ b/drivers/pinctrl/sunxi/pinctrl-sunxi.c
@@ -65,7 +65,7 @@ static struct irq_chip sunxi_pinctrl_level_irq_chip;
*/
static u32 sunxi_bank_offset(const struct sunxi_pinctrl *pctl, u32 pin)
{
- u32 offset = 0;
+ u32 offset = pctl->bank_offset;
if (pin >= PK_BASE && (pctl->flags & SUNXI_PINCTRL_ELEVEN_BANKS)) {
pin -= PK_BASE;
@@ -102,7 +102,7 @@ static void sunxi_dlevel_reg(const struct sunxi_pinctrl *pctl,
{
u32 offset = pin % PINS_PER_BANK * pctl->dlevel_field_width;
- *reg = sunxi_bank_offset(pctl, pin) + DLEVEL_REGS_OFFSET +
+ *reg = sunxi_bank_offset(pctl, pin) + pctl->drv_regs_offset +
offset / BITS_PER_TYPE(u32) * sizeof(u32);
*shift = offset % BITS_PER_TYPE(u32);
*mask = (BIT(pctl->dlevel_field_width) - 1) << *shift;
@@ -1592,15 +1592,25 @@ int sunxi_pinctrl_init_with_flags(struct platform_device *pdev,
pctl->flags = flags;
if (flags & SUNXI_PINCTRL_NCAT2_REG_LAYOUT) {
pctl->bank_mem_size = D1_BANK_MEM_SIZE;
+ pctl->drv_regs_offset = DLEVEL_REGS_OFFSET;
pctl->pull_regs_offset = D1_PULL_REGS_OFFSET;
pctl->dlevel_field_width = D1_DLEVEL_FIELD_WIDTH;
+ } else if (flags & SUNXI_PINCTRL_NCAT3_REG_LAYOUT) {
+ pctl->bank_mem_size = A733_BANK_MEM_SIZE;
+ pctl->bank_offset = A733_BANK_OFFSET;
+ pctl->drv_regs_offset = A733_DLEVEL_REGS_OFFSET;
+ pctl->pull_regs_offset = A733_PULL_REGS_OFFSET;
+ pctl->dlevel_field_width = D1_DLEVEL_FIELD_WIDTH;
} else {
pctl->bank_mem_size = BANK_MEM_SIZE;
+ pctl->drv_regs_offset = DLEVEL_REGS_OFFSET;
pctl->pull_regs_offset = PULL_REGS_OFFSET;
pctl->dlevel_field_width = DLEVEL_FIELD_WIDTH;
}
if (flags & SUNXI_PINCTRL_ELEVEN_BANKS)
pctl->pow_mod_sel_offset = PIO_11B_POW_MOD_SEL_REG;
+ else if (flags & SUNXI_PINCTRL_NCAT3_REG_LAYOUT)
+ pctl->pow_mod_sel_offset = PIO_NCAT3_POW_MOD_SEL_REG;
else
pctl->pow_mod_sel_offset = PIO_POW_MOD_SEL_REG;
diff --git a/drivers/pinctrl/sunxi/pinctrl-sunxi.h b/drivers/pinctrl/sunxi/pinctrl-sunxi.h
index 15aa6fe62dbbc..d09467ed437a3 100644
--- a/drivers/pinctrl/sunxi/pinctrl-sunxi.h
+++ b/drivers/pinctrl/sunxi/pinctrl-sunxi.h
@@ -53,6 +53,12 @@
#define D1_DLEVEL_FIELD_WIDTH 4
#define D1_PULL_REGS_OFFSET 0x24
+#define A733_BANK_MEM_SIZE 0x80
+#define A733_BANK_OFFSET 0x80
+#define A733_DLEVEL_REGS_OFFSET 0x20
+#define A733_PULL_REGS_OFFSET 0x30
+#define A733_IRQ_REGS_OFFSET 0x40
+
#define PINS_PER_BANK 32
#define IRQ_PER_BANK 32
@@ -94,7 +100,9 @@
#define SUNXI_PINCTRL_NCAT2_REG_LAYOUT BIT(8)
#define SUNXI_PINCTRL_PORTF_SWITCH BIT(9)
#define SUNXI_PINCTRL_ELEVEN_BANKS BIT(10)
+#define SUNXI_PINCTRL_NCAT3_REG_LAYOUT BIT(11)
+#define PIO_NCAT3_POW_MOD_SEL_REG 0x040
#define PIO_POW_MOD_SEL_REG 0x340
#define PIO_11B_POW_MOD_SEL_REG 0x380
#define PIO_POW_MOD_CTL_OFS 0x004
@@ -179,6 +187,8 @@ struct sunxi_pinctrl {
struct pinctrl_dev *pctl_dev;
unsigned long flags;
u32 bank_mem_size;
+ u32 bank_offset;
+ u32 drv_regs_offset;
u32 pull_regs_offset;
u32 dlevel_field_width;
u32 pow_mod_sel_offset;
@@ -238,6 +248,10 @@ 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)
{
+ if (pctl->flags & SUNXI_PINCTRL_NCAT3_REG_LAYOUT)
+ return pctl->bank_offset + bank * pctl->bank_mem_size +
+ A733_IRQ_REGS_OFFSET;
+
return IRQ_REGS_OFFSET +
sunxi_irq_hw_bank_num(pctl->desc, bank) * IRQ_MEM_SIZE;
}
--
2.47.3
next prev parent reply other threads:[~2026-09-10 13:35 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-10 13:35 [PATCH 0/7] pinctrl: sunxi: Add Allwinner A733 support Andre Przywara
2026-09-10 13:35 ` [PATCH 1/7] pinctrl: sunxi: rename SUNXI_PINCTRL_NEW_REG_LAYOUT Andre Przywara
2026-09-10 13:35 ` [PATCH 2/7] pinctrl: sunxi: only use PortK special handling on A523 Andre Przywara
2026-09-10 14:56 ` Chen-Yu Tsai
2026-09-10 13:35 ` [PATCH 3/7] pinctrl: sunxi: refactor IRQ register accessors Andre Przywara
2026-09-10 13:35 ` Andre Przywara [this message]
2026-09-10 14:05 ` [PATCH 4/7] pinctrl: sunxi: support A733 generation MMIO register layout sashiko-bot
2026-09-10 13:35 ` [PATCH 5/7] dt-bindings: pinctrl: add compatible for Allwinner A733 Andre Przywara
2026-09-10 13:35 ` [PATCH 6/7] pinctrl: sunxi: a523-r: add a733-r compatible string Andre Przywara
2026-09-10 14:15 ` sashiko-bot
2026-09-10 13:35 ` [PATCH 7/7] pinctrl: sunxi: add support for the Allwinner A733 Andre Przywara
2026-09-10 14:30 ` sashiko-bot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260910133519.459011-5-andre.przywara@arm.com \
--to=andre.przywara@arm.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=dlan@gentoo.org \
--cc=enzo.adriano.code@gmail.com \
--cc=jbrunet@baylibre.com \
--cc=jernej.skrabec@gmail.com \
--cc=krzk+dt@kernel.org \
--cc=linusw@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-sunxi@lists.linux.dev \
--cc=robh@kernel.org \
--cc=samuel@sholland.org \
--cc=vinicius.eduardo.pedrosa@gmail.com \
--cc=wens@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox