aboutsummaryrefslogtreecommitdiffstats
path: root/arch/sh/include/asm/gpio.h
diff options
context:
space:
mode:
authorMagnus Damm <damm@igel.co.jp>2008-12-25 04:17:34 -0500
committerPaul Mundt <lethal@linux-sh.org>2009-01-27 00:49:10 -0500
commit69edbba0021a48fe034849501513930f6175cb5d (patch)
tree51499128883b2e84bce5dcaa78e6e943c37eeb40 /arch/sh/include/asm/gpio.h
parent3292094e88ce6b76714dad8ec4b43d7c5c12ada2 (diff)
sh: use gpiolib
This patch updates the SuperH gpio code to make use of gpiolib. The gpiolib callbacks get() and set() are lockless, but we use our own spinlock for the other operations to make sure hardware register bitfield accesses stay atomic. Signed-off-by: Magnus Damm <damm@igel.co.jp> Signed-off-by: Paul Mundt <lethal@linux-sh.org>
Diffstat (limited to 'arch/sh/include/asm/gpio.h')
-rw-r--r--arch/sh/include/asm/gpio.h61
1 files changed, 35 insertions, 26 deletions
diff --git a/arch/sh/include/asm/gpio.h b/arch/sh/include/asm/gpio.h
index 46a6d7914df7..61f93da2c62e 100644
--- a/arch/sh/include/asm/gpio.h
+++ b/arch/sh/include/asm/gpio.h
@@ -19,6 +19,40 @@
19#include <cpu/gpio.h> 19#include <cpu/gpio.h>
20#endif 20#endif
21 21
22#define ARCH_NR_GPIOS 512
23#include <asm-generic/gpio.h>
24
25#ifdef CONFIG_GPIOLIB
26
27static inline int gpio_get_value(unsigned gpio)
28{
29 return __gpio_get_value(gpio);
30}
31
32static inline void gpio_set_value(unsigned gpio, int value)
33{
34 __gpio_set_value(gpio, value);
35}
36
37static inline int gpio_cansleep(unsigned gpio)
38{
39 return __gpio_cansleep(gpio);
40}
41
42static inline int gpio_to_irq(unsigned gpio)
43{
44 WARN_ON(1);
45 return -ENOSYS;
46}
47
48static inline int irq_to_gpio(unsigned int irq)
49{
50 WARN_ON(1);
51 return -EINVAL;
52}
53
54#endif /* CONFIG_GPIOLIB */
55
22typedef unsigned short pinmux_enum_t; 56typedef unsigned short pinmux_enum_t;
23typedef unsigned short pinmux_flag_t; 57typedef unsigned short pinmux_flag_t;
24 58
@@ -94,34 +128,9 @@ struct pinmux_info {
94 unsigned int gpio_data_size; 128 unsigned int gpio_data_size;
95 129
96 unsigned long *gpio_in_use; 130 unsigned long *gpio_in_use;
131 struct gpio_chip chip;
97}; 132};
98 133
99int register_pinmux(struct pinmux_info *pip); 134int register_pinmux(struct pinmux_info *pip);
100 135
101int __gpio_request(unsigned gpio);
102static inline int gpio_request(unsigned gpio, const char *label)
103{
104 return __gpio_request(gpio);
105}
106void gpio_free(unsigned gpio);
107int gpio_direction_input(unsigned gpio);
108int gpio_direction_output(unsigned gpio, int value);
109int gpio_get_value(unsigned gpio);
110void gpio_set_value(unsigned gpio, int value);
111
112/* IRQ modes are unspported */
113static inline int gpio_to_irq(unsigned gpio)
114{
115 WARN_ON(1);
116 return -EINVAL;
117}
118
119static inline int irq_to_gpio(unsigned irq)
120{
121 WARN_ON(1);
122 return -EINVAL;
123}
124
125#include <asm-generic/gpio.h>
126
127#endif /* __ASM_SH_GPIO_H */ 136#endif /* __ASM_SH_GPIO_H */