aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpio/gpio-iop.c
diff options
context:
space:
mode:
authorLinus Walleij <linus.walleij@linaro.org>2013-09-09 10:54:32 -0400
committerLinus Walleij <linus.walleij@linaro.org>2013-09-20 17:05:10 -0400
commite3f94b385748c10b735f392b69f39f33f02ca3a5 (patch)
tree44bf587becb3fa0c228e5c3ccddf1efb3e7a11d4 /drivers/gpio/gpio-iop.c
parent7b85b867b99044da93f83851c806d1e324d49ed5 (diff)
gpio: iop: use readl/writel accessors
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> Tested-by: Aaro Koskinen <aaro.koskinen@iki.fi> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'drivers/gpio/gpio-iop.c')
-rw-r--r--drivers/gpio/gpio-iop.c24
1 files changed, 16 insertions, 8 deletions
diff --git a/drivers/gpio/gpio-iop.c b/drivers/gpio/gpio-iop.c
index 24a86b05dc8c..0d991d732467 100644
--- a/drivers/gpio/gpio-iop.c
+++ b/drivers/gpio/gpio-iop.c
@@ -17,6 +17,8 @@
17#include <linux/gpio.h> 17#include <linux/gpio.h>
18#include <linux/export.h> 18#include <linux/export.h>
19#include <linux/platform_device.h> 19#include <linux/platform_device.h>
20#include <linux/bitops.h>
21#include <linux/io.h>
20 22
21#define IOP3XX_N_GPIOS 8 23#define IOP3XX_N_GPIOS 8
22 24
@@ -29,38 +31,44 @@
29static void __iomem *base; 31static void __iomem *base;
30 32
31#define IOP3XX_GPIO_REG(reg) (base + (reg)) 33#define IOP3XX_GPIO_REG(reg) (base + (reg))
32#define IOP3XX_GPOE (volatile u32 *)IOP3XX_GPIO_REG(0x0000) 34#define IOP3XX_GPOE IOP3XX_GPIO_REG(0x0000)
33#define IOP3XX_GPID (volatile u32 *)IOP3XX_GPIO_REG(0x0004) 35#define IOP3XX_GPID IOP3XX_GPIO_REG(0x0004)
34#define IOP3XX_GPOD (volatile u32 *)IOP3XX_GPIO_REG(0x0008) 36#define IOP3XX_GPOD IOP3XX_GPIO_REG(0x0008)
35 37
36static void gpio_line_config(int line, int direction) 38static void gpio_line_config(int line, int direction)
37{ 39{
38 unsigned long flags; 40 unsigned long flags;
41 u32 val;
39 42
40 local_irq_save(flags); 43 local_irq_save(flags);
44 val = readl(IOP3XX_GPOE);
41 if (direction == GPIO_IN) { 45 if (direction == GPIO_IN) {
42 *IOP3XX_GPOE |= 1 << line; 46 val |= BIT(line);
43 } else if (direction == GPIO_OUT) { 47 } else if (direction == GPIO_OUT) {
44 *IOP3XX_GPOE &= ~(1 << line); 48 val &= ~BIT(line);
45 } 49 }
50 writel(val, IOP3XX_GPOE);
46 local_irq_restore(flags); 51 local_irq_restore(flags);
47} 52}
48 53
49static int gpio_line_get(int line) 54static int gpio_line_get(int line)
50{ 55{
51 return !!(*IOP3XX_GPID & (1 << line)); 56 return !!(readl(IOP3XX_GPID) & BIT(line));
52} 57}
53 58
54static void gpio_line_set(int line, int value) 59static void gpio_line_set(int line, int value)
55{ 60{
56 unsigned long flags; 61 unsigned long flags;
62 u32 val;
57 63
58 local_irq_save(flags); 64 local_irq_save(flags);
65 val = readl(IOP3XX_GPOD);
59 if (value == GPIO_LOW) { 66 if (value == GPIO_LOW) {
60 *IOP3XX_GPOD &= ~(1 << line); 67 val &= ~BIT(line);
61 } else if (value == GPIO_HIGH) { 68 } else if (value == GPIO_HIGH) {
62 *IOP3XX_GPOD |= 1 << line; 69 val |= BIT(line);
63 } 70 }
71 writel(val, IOP3XX_GPOD);
64 local_irq_restore(flags); 72 local_irq_restore(flags);
65} 73}
66 74