All of lore.kernel.org
 help / color / mirror / Atom feed
From: Samuel Holland <samuel@sholland.org>
To: u-boot@lists.denx.de, Jagan Teki <jagan@amarulasolutions.com>,
	Andre Przywara <andre.przywara@arm.com>
Cc: Samuel Holland <samuel@sholland.org>,
	Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
	Icenowy Zheng <icenowy@aosc.io>,
	Jaehoon Chung <jh80.chung@samsung.com>,
	Jernej Skrabec <jernej.skrabec@gmail.com>,
	Peng Fan <peng.fan@nxp.com>, Simon Glass <sjg@chromium.org>
Subject: [PATCH 2/4] sunxi: gpio: Add per-bank drive and pull setters
Date: Wed, 20 Oct 2021 23:52:55 -0500	[thread overview]
Message-ID: <20211021045258.30757-3-samuel@sholland.org> (raw)
In-Reply-To: <20211021045258.30757-1-samuel@sholland.org>

The GPIO and pinctrl drivers need these setters for pin configuration.
Since they are DM drivers, they should not be using hardcoded base
addresses. Factor out variants of the setter functions which take a
pointer to the GPIO bank's MMIO registers.

Signed-off-by: Samuel Holland <samuel@sholland.org>
---

 arch/arm/include/asm/arch-sunxi/gpio.h |  2 ++
 arch/arm/mach-sunxi/pinmux.c           | 20 ++++++++++++++++----
 2 files changed, 18 insertions(+), 4 deletions(-)

diff --git a/arch/arm/include/asm/arch-sunxi/gpio.h b/arch/arm/include/asm/arch-sunxi/gpio.h
index 2b72b2263b..106605adf5 100644
--- a/arch/arm/include/asm/arch-sunxi/gpio.h
+++ b/arch/arm/include/asm/arch-sunxi/gpio.h
@@ -227,7 +227,9 @@ void sunxi_gpio_set_cfgpin(u32 pin, u32 val);
 int sunxi_gpio_get_cfgbank(struct sunxi_gpio *pio, int bank_offset);
 int sunxi_gpio_get_cfgpin(u32 pin);
 void sunxi_gpio_set_drv(u32 pin, u32 val);
+void sunxi_gpio_set_drv_bank(struct sunxi_gpio *pio, u32 bank_offset, u32 val);
 void sunxi_gpio_set_pull(u32 pin, u32 val);
+void sunxi_gpio_set_pull_bank(struct sunxi_gpio *pio, int bank_offset, u32 val);
 int sunxi_name_to_gpio(const char *name);
 
 #if !defined CONFIG_SPL_BUILD && defined CONFIG_AXP_GPIO
diff --git a/arch/arm/mach-sunxi/pinmux.c b/arch/arm/mach-sunxi/pinmux.c
index cf9d9daf7c..b2093b623a 100644
--- a/arch/arm/mach-sunxi/pinmux.c
+++ b/arch/arm/mach-sunxi/pinmux.c
@@ -48,19 +48,31 @@ int sunxi_gpio_get_cfgpin(u32 pin)
 void sunxi_gpio_set_drv(u32 pin, u32 val)
 {
 	u32 bank = GPIO_BANK(pin);
-	u32 index = GPIO_DRV_INDEX(pin);
-	u32 offset = GPIO_DRV_OFFSET(pin);
 	struct sunxi_gpio *pio = BANK_TO_GPIO(bank);
 
+	sunxi_gpio_set_drv_bank(pio, pin, val);
+}
+
+void sunxi_gpio_set_drv_bank(struct sunxi_gpio *pio, u32 bank_offset, u32 val)
+{
+	u32 index = GPIO_DRV_INDEX(bank_offset);
+	u32 offset = GPIO_DRV_OFFSET(bank_offset);
+
 	clrsetbits_le32(&pio->drv[0] + index, 0x3 << offset, val << offset);
 }
 
 void sunxi_gpio_set_pull(u32 pin, u32 val)
 {
 	u32 bank = GPIO_BANK(pin);
-	u32 index = GPIO_PULL_INDEX(pin);
-	u32 offset = GPIO_PULL_OFFSET(pin);
 	struct sunxi_gpio *pio = BANK_TO_GPIO(bank);
 
+	sunxi_gpio_set_pull_bank(pio, pin, val);
+}
+
+void sunxi_gpio_set_pull_bank(struct sunxi_gpio *pio, int bank_offset, u32 val)
+{
+	u32 index = GPIO_PULL_INDEX(bank_offset);
+	u32 offset = GPIO_PULL_OFFSET(bank_offset);
+
 	clrsetbits_le32(&pio->pull[0] + index, 0x3 << offset, val << offset);
 }
-- 
2.32.0


  parent reply	other threads:[~2021-10-21  4:53 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-21  4:52 [PATCH 0/4] gpio: sunxi: Handle pin configuration flags Samuel Holland
2021-10-21  4:52 ` [PATCH 1/4] sunxi: gpio: Return void from setter functions Samuel Holland
2021-11-05 13:53   ` Heinrich Schuchardt
2021-10-21  4:52 ` Samuel Holland [this message]
2021-11-05 14:12   ` [PATCH 2/4] sunxi: gpio: Add per-bank drive and pull setters Heinrich Schuchardt
2022-01-30  1:11     ` Andre Przywara
2021-10-21  4:52 ` [PATCH 3/4] gpio: sunxi: Implement .set_flags Samuel Holland
2021-10-24 19:53   ` Simon Glass
2021-11-05 14:43   ` Heinrich Schuchardt
2021-11-05 21:46     ` Samuel Holland
2022-01-30  1:18       ` Andre Przywara
2021-10-21  4:52 ` [PATCH 4/4] mmc: sunxi: Use DM_GPIO flags to set pull-up Samuel Holland
2021-10-21 21:58   ` Jaehoon Chung
2021-10-22  9:00     ` Andre Przywara
2021-10-22 10:10       ` Jaehoon Chung
2021-10-22 10:36         ` Andre Przywara
2021-11-05 15:52   ` Heinrich Schuchardt

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=20211021045258.30757-3-samuel@sholland.org \
    --to=samuel@sholland.org \
    --cc=andre.przywara@arm.com \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=icenowy@aosc.io \
    --cc=jagan@amarulasolutions.com \
    --cc=jernej.skrabec@gmail.com \
    --cc=jh80.chung@samsung.com \
    --cc=peng.fan@nxp.com \
    --cc=sjg@chromium.org \
    --cc=u-boot@lists.denx.de \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.