diff options
author | Russell King <rmk+kernel@arm.linux.org.uk> | 2009-10-06 14:35:16 +0100 |
---|---|---|
committer | Russell King <rmk+kernel@arm.linux.org.uk> | 2009-12-06 16:52:24 +0000 |
commit | 0831e3e4cf8abcbb772c0cb1eb4406ffcdb974df (patch) | |
tree | e2857742ac48d122c4a858578b4d46597dfb7e87 /arch/arm/mach-sa1100 | |
parent | a5d176a19138eef45e4c7c80a8d3a7c14c8aec53 (diff) | |
download | kernel_samsung_tuna-0831e3e4cf8abcbb772c0cb1eb4406ffcdb974df.zip kernel_samsung_tuna-0831e3e4cf8abcbb772c0cb1eb4406ffcdb974df.tar.gz kernel_samsung_tuna-0831e3e4cf8abcbb772c0cb1eb4406ffcdb974df.tar.bz2 |
ARM: iPAQ: provide a way to setup platform-controlled GPIOs
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Diffstat (limited to 'arch/arm/mach-sa1100')
-rw-r--r-- | arch/arm/mach-sa1100/h3600.c | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/arch/arm/mach-sa1100/h3600.c b/arch/arm/mach-sa1100/h3600.c index c51432b..2b545a4 100644 --- a/arch/arm/mach-sa1100/h3600.c +++ b/arch/arm/mach-sa1100/h3600.c @@ -28,6 +28,7 @@ #include <linux/mtd/mtd.h> #include <linux/mtd/partitions.h> #include <linux/serial_core.h> +#include <linux/gpio.h> #include <asm/irq.h> #include <mach/hardware.h> @@ -49,6 +50,47 @@ void (*assign_h3600_egpio)(enum ipaq_egpio_type x, int level); EXPORT_SYMBOL(assign_h3600_egpio); +struct gpio_default_state { + int gpio; + int mode; + const char *name; +}; + +#define GPIO_MODE_IN -1 +#define GPIO_MODE_OUT0 0 +#define GPIO_MODE_OUT1 1 + +static void h3xxx_init_gpio(struct gpio_default_state *s, size_t n) +{ + while (n--) { + const char *name = s->name; + int err; + + if (!name) + name = "[init]"; + err = gpio_request(s->gpio, name); + if (err) { + printk(KERN_ERR "gpio%u: unable to request: %d\n", + s->gpio, err); + continue; + } + if (s->mode >= 0) { + err = gpio_direction_output(s->gpio, s->mode); + } else { + err = gpio_direction_input(s->gpio); + } + if (err) { + printk(KERN_ERR "gpio%u: unable to set direction: %d\n", + s->gpio, err); + continue; + } + if (!s->name) + gpio_free(s->gpio); + s++; + } +} + + static struct mtd_partition h3xxx_partitions[] = { { .name = "H3XXX boot firmware", |