linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: andy.shevchenko@gmail.com
To: Andy Shevchenko <andy.shevchenko@gmail.com>,
	linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: Linus Walleij <linus.walleij@linaro.org>,
	Bartosz Golaszewski <brgl@bgdev.pl>
Subject: [PATCH v1 1/1] gpio: mmio: Support 64-bit BE access
Date: Wed, 21 Feb 2024 01:23:28 +0200	[thread overview]
Message-ID: <20240220232328.1881707-1-andy.shevchenko@gmail.com> (raw)

Use ioread64be()/iowrite64be() for 64-bit BE access.

Signed-off-by: Andy Shevchenko <andy.shevchenko@gmail.com>
---
 drivers/gpio/gpio-mmio.c | 21 ++++++++++++++++-----
 1 file changed, 16 insertions(+), 5 deletions(-)

diff --git a/drivers/gpio/gpio-mmio.c b/drivers/gpio/gpio-mmio.c
index 71e1af7c2184..cd5ef9233152 100644
--- a/drivers/gpio/gpio-mmio.c
+++ b/drivers/gpio/gpio-mmio.c
@@ -92,12 +92,12 @@ static unsigned long bgpio_read32(void __iomem *reg)
 #if BITS_PER_LONG >= 64
 static void bgpio_write64(void __iomem *reg, unsigned long data)
 {
-	writeq(data, reg);
+	iowrite64(data, reg);
 }
 
 static unsigned long bgpio_read64(void __iomem *reg)
 {
-	return readq(reg);
+	return ioread64(reg);
 }
 #endif /* BITS_PER_LONG >= 64 */
 
@@ -121,6 +121,18 @@ static unsigned long bgpio_read32be(void __iomem *reg)
 	return ioread32be(reg);
 }
 
+#if BITS_PER_LONG >= 64
+static void bgpio_write64be(void __iomem *reg, unsigned long data)
+{
+	iowrite64be(data, reg);
+}
+
+static unsigned long bgpio_read64be(void __iomem *reg)
+{
+	return ioread64be(reg);
+}
+#endif /* BITS_PER_LONG >= 64 */
+
 static unsigned long bgpio_line2mask(struct gpio_chip *gc, unsigned int line)
 {
 	if (gc->be_bits)
@@ -445,9 +457,8 @@ static int bgpio_setup_accessors(struct device *dev,
 #if BITS_PER_LONG >= 64
 	case 64:
 		if (byte_be) {
-			dev_err(dev,
-				"64 bit big endian byte order unsupported\n");
-			return -EINVAL;
+			gc->read_reg	= bgpio_read64be;
+			gc->write_reg	= bgpio_write64be;
 		} else {
 			gc->read_reg	= bgpio_read64;
 			gc->write_reg	= bgpio_write64;
-- 
2.43.2


             reply	other threads:[~2024-02-20 23:24 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-20 23:23 andy.shevchenko [this message]
2024-02-21  8:02 ` [PATCH v1 1/1] gpio: mmio: Support 64-bit BE access Linus Walleij
2024-02-22  9:07 ` Bartosz Golaszewski

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=20240220232328.1881707-1-andy.shevchenko@gmail.com \
    --to=andy.shevchenko@gmail.com \
    --cc=brgl@bgdev.pl \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.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;
as well as URLs for NNTP newsgroup(s).