aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/arm/mach-ixp4xx/common.c23
-rw-r--r--include/asm-arm/arch-ixp4xx/gpio.h73
2 files changed, 96 insertions, 0 deletions
diff --git a/arch/arm/mach-ixp4xx/common.c b/arch/arm/mach-ixp4xx/common.c
index 45068c3d8dcc..39f2eeb219b4 100644
--- a/arch/arm/mach-ixp4xx/common.c
+++ b/arch/arm/mach-ixp4xx/common.c
@@ -102,6 +102,29 @@ static signed char irq2gpio[32] = {
102 7, 8, 9, 10, 11, 12, -1, -1, 102 7, 8, 9, 10, 11, 12, -1, -1,
103}; 103};
104 104
105int gpio_to_irq(int gpio)
106{
107 int irq;
108
109 for (irq = 0; irq < 32; irq++) {
110 if (irq2gpio[irq] == gpio)
111 return irq;
112 }
113 return -EINVAL;
114}
115EXPORT_SYMBOL(gpio_to_irq);
116
117int irq_to_gpio(int irq)
118{
119 int gpio = (irq < 32) ? irq2gpio[irq] : -EINVAL;
120
121 if (gpio == -1)
122 return -EINVAL;
123
124 return gpio;
125}
126EXPORT_SYMBOL(irq_to_gpio);
127
105static int ixp4xx_set_irq_type(unsigned int irq, unsigned int type) 128static int ixp4xx_set_irq_type(unsigned int irq, unsigned int type)
106{ 129{
107 int line = irq2gpio[irq]; 130 int line = irq2gpio[irq];
diff --git a/include/asm-arm/arch-ixp4xx/gpio.h b/include/asm-arm/arch-ixp4xx/gpio.h
new file mode 100644
index 000000000000..3a4c5b8ae9e1
--- /dev/null
+++ b/include/asm-arm/arch-ixp4xx/gpio.h
@@ -0,0 +1,73 @@
1/*
2 * linux/include/asm-arm/arch-ixp4xx/gpio.h
3 *
4 * IXP4XX GPIO wrappers for arch-neutral GPIO calls
5 *
6 * Written by Milan Svoboda <msvoboda@ra.rockwell.com>
7 * Based on PXA implementation by Philipp Zabel <philipp.zabel@gmail.com>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 *
23 */
24
25#ifndef __ASM_ARCH_IXP4XX_GPIO_H
26#define __ASM_ARCH_IXP4XX_GPIO_H
27
28#include <asm/hardware.h>
29
30static inline int gpio_request(unsigned gpio, const char *label)
31{
32 return 0;
33}
34
35static inline void gpio_free(unsigned gpio)
36{
37 return;
38}
39
40static inline int gpio_direction_input(unsigned gpio)
41{
42 gpio_line_config(gpio, IXP4XX_GPIO_IN);
43 return 0;
44}
45
46static inline int gpio_direction_output(unsigned gpio, int level)
47{
48 gpio_line_set(gpio, level);
49 gpio_line_config(gpio, IXP4XX_GPIO_OUT);
50 return 0;
51}
52
53static inline int gpio_get_value(unsigned gpio)
54{
55 int value;
56
57 gpio_line_get(gpio, &value);
58
59 return value;
60}
61
62static inline void gpio_set_value(unsigned gpio, int value)
63{
64 gpio_line_set(gpio, value);
65}
66
67#include <asm-generic/gpio.h> /* cansleep wrappers */
68
69extern int gpio_to_irq(int gpio);
70extern int irq_to_gpio(int gpio);
71
72#endif
73