aboutsummaryrefslogtreecommitdiffstats
path: root/arch/mips/include/asm
diff options
context:
space:
mode:
authorFlorian Fainelli <florian@openwrt.org>2010-01-03 15:16:51 -0500
committerRalf Baechle <ralf@linux-mips.org>2010-02-27 06:53:16 -0500
commit5f3c909881d5deebb9a3ddc836a15937e76daefc (patch)
tree5306ae518c1da71bdba1814e49e75ad7cd6c2736 /arch/mips/include/asm
parent69b427cd23b6f637763bf49e3e166c1236313f69 (diff)
MIPS: AR7: Implement gpiolib
This patch implements gpiolib for the AR7 SoC. Signed-off-by: Florian Fainelli <florian@openwrt.org> To: linux-mips@linux-mips.org Patchwork: http://patchwork.linux-mips.org/patch/816/ Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Diffstat (limited to 'arch/mips/include/asm')
-rw-r--r--arch/mips/include/asm/mach-ar7/gpio.h86
1 files changed, 8 insertions, 78 deletions
diff --git a/arch/mips/include/asm/mach-ar7/gpio.h b/arch/mips/include/asm/mach-ar7/gpio.h
index cbe9c4f126df..73f9b162c970 100644
--- a/arch/mips/include/asm/mach-ar7/gpio.h
+++ b/arch/mips/include/asm/mach-ar7/gpio.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (C) 2007 Florian Fainelli <florian@openwrt.org> 2 * Copyright (C) 2007-2009 Florian Fainelli <florian@openwrt.org>
3 * 3 *
4 * This program is free software; you can redistribute it and/or modify 4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by 5 * it under the terms of the GNU General Public License as published by
@@ -22,88 +22,18 @@
22#include <asm/mach-ar7/ar7.h> 22#include <asm/mach-ar7/ar7.h>
23 23
24#define AR7_GPIO_MAX 32 24#define AR7_GPIO_MAX 32
25#define NR_BUILTIN_GPIO AR7_GPIO_MAX
25 26
26extern int gpio_request(unsigned gpio, const char *label); 27#define gpio_to_irq(gpio) NULL
27extern void gpio_free(unsigned gpio);
28 28
29/* Common GPIO layer */ 29#define gpio_get_value __gpio_get_value
30static inline int gpio_get_value(unsigned gpio) 30#define gpio_set_value __gpio_set_value
31{
32 void __iomem *gpio_in =
33 (void __iomem *)KSEG1ADDR(AR7_REGS_GPIO + AR7_GPIO_INPUT);
34 31
35 return readl(gpio_in) & (1 << gpio); 32#define gpio_cansleep __gpio_cansleep
36}
37
38static inline void gpio_set_value(unsigned gpio, int value)
39{
40 void __iomem *gpio_out =
41 (void __iomem *)KSEG1ADDR(AR7_REGS_GPIO + AR7_GPIO_OUTPUT);
42 unsigned tmp;
43
44 tmp = readl(gpio_out) & ~(1 << gpio);
45 if (value)
46 tmp |= 1 << gpio;
47 writel(tmp, gpio_out);
48}
49
50static inline int gpio_direction_input(unsigned gpio)
51{
52 void __iomem *gpio_dir =
53 (void __iomem *)KSEG1ADDR(AR7_REGS_GPIO + AR7_GPIO_DIR);
54
55 if (gpio >= AR7_GPIO_MAX)
56 return -EINVAL;
57
58 writel(readl(gpio_dir) | (1 << gpio), gpio_dir);
59
60 return 0;
61}
62
63static inline int gpio_direction_output(unsigned gpio, int value)
64{
65 void __iomem *gpio_dir =
66 (void __iomem *)KSEG1ADDR(AR7_REGS_GPIO + AR7_GPIO_DIR);
67
68 if (gpio >= AR7_GPIO_MAX)
69 return -EINVAL;
70
71 gpio_set_value(gpio, value);
72 writel(readl(gpio_dir) & ~(1 << gpio), gpio_dir);
73
74 return 0;
75}
76
77static inline int gpio_to_irq(unsigned gpio)
78{
79 return -EINVAL;
80}
81
82static inline int irq_to_gpio(unsigned irq)
83{
84 return -EINVAL;
85}
86 33
87/* Board specific GPIO functions */ 34/* Board specific GPIO functions */
88static inline int ar7_gpio_enable(unsigned gpio) 35int ar7_gpio_enable(unsigned gpio);
89{ 36int ar7_gpio_disable(unsigned gpio);
90 void __iomem *gpio_en =
91 (void __iomem *)KSEG1ADDR(AR7_REGS_GPIO + AR7_GPIO_ENABLE);
92
93 writel(readl(gpio_en) | (1 << gpio), gpio_en);
94
95 return 0;
96}
97
98static inline int ar7_gpio_disable(unsigned gpio)
99{
100 void __iomem *gpio_en =
101 (void __iomem *)KSEG1ADDR(AR7_REGS_GPIO + AR7_GPIO_ENABLE);
102
103 writel(readl(gpio_en) & ~(1 << gpio), gpio_en);
104
105 return 0;
106}
107 37
108#include <asm-generic/gpio.h> 38#include <asm-generic/gpio.h>
109 39