aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArnaud Patard <arnaud.patard@rtp-net.org>2008-07-08 18:07:48 -0400
committerRussell King <rmk+kernel@arm.linux.org.uk>2008-07-09 18:31:42 -0400
commit63f385cd1f649b3f4f2d59fc609e051981215fd7 (patch)
treeb0c1d0bf186c701284ba63dda9514cec333037a5
parent543cf4cb3fe6f6cae3651ba918b9c56200b257d0 (diff)
[ARM] 5160/1: IOP3XX: gpio/gpiolib support
This patch brings support for gpio/gpiolib framework to Intel IOP3xx platforms. Signed-off-by: Arnaud Patard <arnaud.patard@rtp-net.org> Acked-by: Dan Williams <dan.j.williams@intel.com> Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
-rw-r--r--arch/arm/Kconfig4
-rw-r--r--arch/arm/plat-iop/gpio.c43
-rw-r--r--include/asm-arm/arch-iop32x/gpio.h6
-rw-r--r--include/asm-arm/arch-iop33x/gpio.h6
-rw-r--r--include/asm-arm/hardware/iop3xx-gpio.h73
5 files changed, 132 insertions, 0 deletions
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index b786e68914d4..63ef7cf852a7 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -299,6 +299,8 @@ config ARCH_IOP32X
299 depends on MMU 299 depends on MMU
300 select PLAT_IOP 300 select PLAT_IOP
301 select PCI 301 select PCI
302 select GENERIC_GPIO
303 select HAVE_GPIO_LIB
302 help 304 help
303 Support for Intel's 80219 and IOP32X (XScale) family of 305 Support for Intel's 80219 and IOP32X (XScale) family of
304 processors. 306 processors.
@@ -308,6 +310,8 @@ config ARCH_IOP33X
308 depends on MMU 310 depends on MMU
309 select PLAT_IOP 311 select PLAT_IOP
310 select PCI 312 select PCI
313 select GENERIC_GPIO
314 select HAVE_GPIO_LIB
311 help 315 help
312 Support for Intel's IOP33X (XScale) family of processors. 316 Support for Intel's IOP33X (XScale) family of processors.
313 317
diff --git a/arch/arm/plat-iop/gpio.c b/arch/arm/plat-iop/gpio.c
index eda436083417..640e498c12ef 100644
--- a/arch/arm/plat-iop/gpio.c
+++ b/arch/arm/plat-iop/gpio.c
@@ -11,6 +11,10 @@
11 */ 11 */
12 12
13#include <linux/device.h> 13#include <linux/device.h>
14#include <linux/init.h>
15#include <linux/types.h>
16#include <linux/errno.h>
17#include <linux/gpio.h>
14#include <asm/hardware/iop3xx.h> 18#include <asm/hardware/iop3xx.h>
15 19
16void gpio_line_config(int line, int direction) 20void gpio_line_config(int line, int direction)
@@ -46,3 +50,42 @@ void gpio_line_set(int line, int value)
46 local_irq_restore(flags); 50 local_irq_restore(flags);
47} 51}
48EXPORT_SYMBOL(gpio_line_set); 52EXPORT_SYMBOL(gpio_line_set);
53
54static int iop3xx_gpio_direction_input(struct gpio_chip *chip, unsigned gpio)
55{
56 gpio_line_config(gpio, GPIO_IN);
57 return 0;
58}
59
60static int iop3xx_gpio_direction_output(struct gpio_chip *chip, unsigned gpio, int level)
61{
62 gpio_line_set(gpio, level);
63 gpio_line_config(gpio, GPIO_OUT);
64 return 0;
65}
66
67static int iop3xx_gpio_get_value(struct gpio_chip *chip, unsigned gpio)
68{
69 return gpio_line_get(gpio);
70}
71
72static void iop3xx_gpio_set_value(struct gpio_chip *chip, unsigned gpio, int value)
73{
74 gpio_line_set(gpio, value);
75}
76
77static struct gpio_chip iop3xx_chip = {
78 .label = "iop3xx",
79 .direction_input = iop3xx_gpio_direction_input,
80 .get = iop3xx_gpio_get_value,
81 .direction_output = iop3xx_gpio_direction_output,
82 .set = iop3xx_gpio_set_value,
83 .base = 0,
84 .ngpio = IOP3XX_N_GPIOS,
85};
86
87static int __init iop3xx_gpio_setup(void)
88{
89 return gpiochip_add(&iop3xx_chip);
90}
91arch_initcall(iop3xx_gpio_setup);
diff --git a/include/asm-arm/arch-iop32x/gpio.h b/include/asm-arm/arch-iop32x/gpio.h
new file mode 100644
index 000000000000..708f4ec9db1d
--- /dev/null
+++ b/include/asm-arm/arch-iop32x/gpio.h
@@ -0,0 +1,6 @@
1#ifndef __ASM_ARCH_IOP32X_GPIO_H
2#define __ASM_ARCH_IOP32X_GPIO_H
3
4#include <asm/hardware/iop3xx-gpio.h>
5
6#endif
diff --git a/include/asm-arm/arch-iop33x/gpio.h b/include/asm-arm/arch-iop33x/gpio.h
new file mode 100644
index 000000000000..ddd55bba9bb9
--- /dev/null
+++ b/include/asm-arm/arch-iop33x/gpio.h
@@ -0,0 +1,6 @@
1#ifndef __ASM_ARCH_IOP33X_GPIO_H
2#define __ASM_ARCH_IOP33X_GPIO_H
3
4#include <asm/hardware/iop3xx-gpio.h>
5
6#endif
diff --git a/include/asm-arm/hardware/iop3xx-gpio.h b/include/asm-arm/hardware/iop3xx-gpio.h
new file mode 100644
index 000000000000..0c9331f9ac24
--- /dev/null
+++ b/include/asm-arm/hardware/iop3xx-gpio.h
@@ -0,0 +1,73 @@
1/*
2 * linux/include/asm-arm/hardware/iop3xx-gpio.h
3 *
4 * IOP3xx GPIO wrappers
5 *
6 * Copyright (c) 2008 Arnaud Patard <arnaud.patard@rtp-net.org>
7 * Based on IXP4XX gpio.h file
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_ARM_HARDWARE_IOP3XX_GPIO_H
26#define __ASM_ARM_HARDWARE_IOP3XX_GPIO_H
27
28#include <asm/hardware.h>
29#include <asm-generic/gpio.h>
30
31#define IOP3XX_N_GPIOS 8
32
33static inline int gpio_get_value(unsigned gpio)
34{
35 if (gpio > IOP3XX_N_GPIOS)
36 return __gpio_get_value(gpio);
37
38 return gpio_line_get(gpio);
39}
40
41static inline void gpio_set_value(unsigned gpio, int value)
42{
43 if (gpio > IOP3XX_N_GPIOS) {
44 __gpio_set_value(gpio, value);
45 return;
46 }
47 gpio_line_set(gpio, value);
48}
49
50static inline int gpio_cansleep(unsigned gpio)
51{
52 if (gpio < IOP3XX_N_GPIOS)
53 return 0;
54 else
55 return __gpio_cansleep(gpio);
56}
57
58/*
59 * The GPIOs are not generating any interrupt
60 * Note : manuals are not clear about this
61 */
62static inline int gpio_to_irq(int gpio)
63{
64 return -EINVAL;
65}
66
67static inline int irq_to_gpio(int gpio)
68{
69 return -EINVAL;
70}
71
72#endif
73