From: Linus Walleij <linus.walleij@linaro.org>
To: linux-gpio@vger.kernel.org,
Lennert Buytenhek <kernel@wantstofly.org>,
Dan Williams <dan.j.williams@intel.com>,
Mikael Pettersson <mikpe@it.uu.se>
Cc: Alexandre Courbot <acourbot@nvidia.com>,
linux-arm-kernel@lists.infradead.org,
Linus Walleij <linus.walleij@linaro.org>
Subject: [PATCH 7/8] gpio: iop: use readl/writel accessors
Date: Mon, 9 Sep 2013 17:41:11 +0200 [thread overview]
Message-ID: <1378741271-13106-1-git-send-email-linus.walleij@linaro.org> (raw)
Use the standard 32bit I/O accessors instead of just assigning
addresses.
Cc: Lennert Buytenhek <kernel@wantstofly.org>
Cc: Dan Williams <dan.j.williams@intel.com>
Cc: Mikael Pettersson <mikpe@it.uu.se>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
drivers/gpio/gpio-iop.c | 24 ++++++++++++++++--------
1 file changed, 16 insertions(+), 8 deletions(-)
diff --git a/drivers/gpio/gpio-iop.c b/drivers/gpio/gpio-iop.c
index 24a86b0..0d991d7 100644
--- a/drivers/gpio/gpio-iop.c
+++ b/drivers/gpio/gpio-iop.c
@@ -17,6 +17,8 @@
#include <linux/gpio.h>
#include <linux/export.h>
#include <linux/platform_device.h>
+#include <linux/bitops.h>
+#include <linux/io.h>
#define IOP3XX_N_GPIOS 8
@@ -29,38 +31,44 @@
static void __iomem *base;
#define IOP3XX_GPIO_REG(reg) (base + (reg))
-#define IOP3XX_GPOE (volatile u32 *)IOP3XX_GPIO_REG(0x0000)
-#define IOP3XX_GPID (volatile u32 *)IOP3XX_GPIO_REG(0x0004)
-#define IOP3XX_GPOD (volatile u32 *)IOP3XX_GPIO_REG(0x0008)
+#define IOP3XX_GPOE IOP3XX_GPIO_REG(0x0000)
+#define IOP3XX_GPID IOP3XX_GPIO_REG(0x0004)
+#define IOP3XX_GPOD IOP3XX_GPIO_REG(0x0008)
static void gpio_line_config(int line, int direction)
{
unsigned long flags;
+ u32 val;
local_irq_save(flags);
+ val = readl(IOP3XX_GPOE);
if (direction == GPIO_IN) {
- *IOP3XX_GPOE |= 1 << line;
+ val |= BIT(line);
} else if (direction == GPIO_OUT) {
- *IOP3XX_GPOE &= ~(1 << line);
+ val &= ~BIT(line);
}
+ writel(val, IOP3XX_GPOE);
local_irq_restore(flags);
}
static int gpio_line_get(int line)
{
- return !!(*IOP3XX_GPID & (1 << line));
+ return !!(readl(IOP3XX_GPID) & BIT(line));
}
static void gpio_line_set(int line, int value)
{
unsigned long flags;
+ u32 val;
local_irq_save(flags);
+ val = readl(IOP3XX_GPOD);
if (value == GPIO_LOW) {
- *IOP3XX_GPOD &= ~(1 << line);
+ val &= ~BIT(line);
} else if (value == GPIO_HIGH) {
- *IOP3XX_GPOD |= 1 << line;
+ val |= BIT(line);
}
+ writel(val, IOP3XX_GPOD);
local_irq_restore(flags);
}
--
1.8.3.1
next reply other threads:[~2013-09-09 15:41 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-09-09 15:41 Linus Walleij [this message]
-- strict thread matches above, loose matches on Subject: below --
2013-09-20 20:18 [PATCH 7/8] gpio: iop: use readl/writel accessors Linus Walleij
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=1378741271-13106-1-git-send-email-linus.walleij@linaro.org \
--to=linus.walleij@linaro.org \
--cc=acourbot@nvidia.com \
--cc=dan.j.williams@intel.com \
--cc=kernel@wantstofly.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-gpio@vger.kernel.org \
--cc=mikpe@it.uu.se \
/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).