summaryrefslogtreecommitdiff
path: root/target/linux/ar7/files/include
diff options
context:
space:
mode:
authorEugene Konev <ejka@imfi.kspu.ru>2007-09-21 12:37:50 +0000
committerEugene Konev <ejka@imfi.kspu.ru>2007-09-21 12:37:50 +0000
commit041a03c5bdb4339f3ed2bc90268747de5b20c951 (patch)
tree9be165a8c4ae82520674a61cefae303e06c03de5 /target/linux/ar7/files/include
parentd725c9b25be261a9cdde4b83ff00ed0744fe9c7d (diff)
downloadmtk-20170518-041a03c5bdb4339f3ed2bc90268747de5b20c951.zip
mtk-20170518-041a03c5bdb4339f3ed2bc90268747de5b20c951.tar.gz
mtk-20170518-041a03c5bdb4339f3ed2bc90268747de5b20c951.tar.bz2
make gpio conformant to generic gpio spec.
SVN-Revision: 8911
Diffstat (limited to 'target/linux/ar7/files/include')
-rw-r--r--target/linux/ar7/files/include/asm-mips/ar7/gpio.h53
1 files changed, 27 insertions, 26 deletions
diff --git a/target/linux/ar7/files/include/asm-mips/ar7/gpio.h b/target/linux/ar7/files/include/asm-mips/ar7/gpio.h
index c82ba78..a7ae1ee 100644
--- a/target/linux/ar7/files/include/asm-mips/ar7/gpio.h
+++ b/target/linux/ar7/files/include/asm-mips/ar7/gpio.h
@@ -22,24 +22,37 @@
#define AR7_GPIO_MAX 32
-extern int gpio_request(unsigned gpio, char *label);
+extern int gpio_request(unsigned gpio, const char *label);
extern void gpio_free(unsigned gpio);
/* Common GPIO layer */
-static inline int gpio_direction_input(unsigned gpio)
+static inline int gpio_get_value(unsigned gpio)
{
- void __iomem *gpio_dir =
- (void __iomem *)KSEG1ADDR(AR7_REGS_GPIO + AR7_GPIO_DIR);
+ void __iomem *gpio_in =
+ (void __iomem *)KSEG1ADDR(AR7_REGS_GPIO + AR7_GPIO_INPUT);
if (gpio >= AR7_GPIO_MAX)
return -EINVAL;
- writel(readl(gpio_dir) | (1 << gpio), gpio_dir);
+ return ((readl(gpio_in) & (1 << gpio)) != 0);
+}
- return 0;
+static inline void gpio_set_value(unsigned gpio, int value)
+{
+ void __iomem *gpio_out =
+ (void __iomem *)KSEG1ADDR(AR7_REGS_GPIO + AR7_GPIO_OUTPUT);
+ volatile unsigned tmp;
+
+ if (gpio >= AR7_GPIO_MAX)
+ return;
+
+ tmp = readl(gpio_out) & ~(1 << gpio);
+ if (value)
+ tmp |= 1 << gpio;
+ writel(tmp, gpio_out);
}
-static inline int gpio_direction_output(unsigned gpio)
+static inline int gpio_direction_input(unsigned gpio)
{
void __iomem *gpio_dir =
(void __iomem *)KSEG1ADDR(AR7_REGS_GPIO + AR7_GPIO_DIR);
@@ -47,35 +60,23 @@ static inline int gpio_direction_output(unsigned gpio)
if (gpio >= AR7_GPIO_MAX)
return -EINVAL;
- writel(readl(gpio_dir) & ~(1 << gpio), gpio_dir);
+ writel(readl(gpio_dir) | (1 << gpio), gpio_dir);
return 0;
}
-static inline int gpio_get_value(unsigned gpio)
+static inline int gpio_direction_output(unsigned gpio, int value)
{
- void __iomem *gpio_in =
- (void __iomem *)KSEG1ADDR(AR7_REGS_GPIO + AR7_GPIO_INPUT);
+ void __iomem *gpio_dir =
+ (void __iomem *)KSEG1ADDR(AR7_REGS_GPIO + AR7_GPIO_DIR);
if (gpio >= AR7_GPIO_MAX)
return -EINVAL;
- return ((readl(gpio_in) & (1 << gpio)) != 0);
-}
-
-static inline void gpio_set_value(unsigned gpio, int value)
-{
- void __iomem *gpio_out =
- (void __iomem *)KSEG1ADDR(AR7_REGS_GPIO + AR7_GPIO_OUTPUT);
- volatile unsigned tmp;
-
- if (gpio >= AR7_GPIO_MAX)
- return;
+ gpio_set_value(gpio, value);
+ writel(readl(gpio_dir) & ~(1 << gpio), gpio_dir);
- tmp = readl(gpio_out) & ~(1 << gpio);
- if (value)
- tmp |= 1 << gpio;
- writel(tmp, gpio_out);
+ return 0;
}
static inline int gpio_to_irq(unsigned gpio)