diff options
author | Russell King <rmk+kernel@arm.linux.org.uk> | 2009-10-06 09:35:16 -0400 |
---|---|---|
committer | Russell King <rmk+kernel@arm.linux.org.uk> | 2009-12-06 11:52:24 -0500 |
commit | 0831e3e4cf8abcbb772c0cb1eb4406ffcdb974df (patch) | |
tree | e2857742ac48d122c4a858578b4d46597dfb7e87 /arch/arm/mach-sa1100/h3600.c | |
parent | a5d176a19138eef45e4c7c80a8d3a7c14c8aec53 (diff) |
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/h3600.c')
-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 c51432bad46d..2b545a4baa08 100644 --- a/arch/arm/mach-sa1100/h3600.c +++ b/arch/arm/mach-sa1100/h3600.c | |||
@@ -28,6 +28,7 @@ | |||
28 | #include <linux/mtd/mtd.h> | 28 | #include <linux/mtd/mtd.h> |
29 | #include <linux/mtd/partitions.h> | 29 | #include <linux/mtd/partitions.h> |
30 | #include <linux/serial_core.h> | 30 | #include <linux/serial_core.h> |
31 | #include <linux/gpio.h> | ||
31 | 32 | ||
32 | #include <asm/irq.h> | 33 | #include <asm/irq.h> |
33 | #include <mach/hardware.h> | 34 | #include <mach/hardware.h> |
@@ -49,6 +50,47 @@ | |||
49 | void (*assign_h3600_egpio)(enum ipaq_egpio_type x, int level); | 50 | void (*assign_h3600_egpio)(enum ipaq_egpio_type x, int level); |
50 | EXPORT_SYMBOL(assign_h3600_egpio); | 51 | EXPORT_SYMBOL(assign_h3600_egpio); |
51 | 52 | ||
53 | struct gpio_default_state { | ||
54 | int gpio; | ||
55 | int mode; | ||
56 | const char *name; | ||
57 | }; | ||
58 | |||
59 | #define GPIO_MODE_IN -1 | ||
60 | #define GPIO_MODE_OUT0 0 | ||
61 | #define GPIO_MODE_OUT1 1 | ||
62 | |||
63 | static void h3xxx_init_gpio(struct gpio_default_state *s, size_t n) | ||
64 | { | ||
65 | while (n--) { | ||
66 | const char *name = s->name; | ||
67 | int err; | ||
68 | |||
69 | if (!name) | ||
70 | name = "[init]"; | ||
71 | err = gpio_request(s->gpio, name); | ||
72 | if (err) { | ||
73 | printk(KERN_ERR "gpio%u: unable to request: %d\n", | ||
74 | s->gpio, err); | ||
75 | continue; | ||
76 | } | ||
77 | if (s->mode >= 0) { | ||
78 | err = gpio_direction_output(s->gpio, s->mode); | ||
79 | } else { | ||
80 | err = gpio_direction_input(s->gpio); | ||
81 | } | ||
82 | if (err) { | ||
83 | printk(KERN_ERR "gpio%u: unable to set direction: %d\n", | ||
84 | s->gpio, err); | ||
85 | continue; | ||
86 | } | ||
87 | if (!s->name) | ||
88 | gpio_free(s->gpio); | ||
89 | s++; | ||
90 | } | ||
91 | } | ||
92 | |||
93 | |||
52 | static struct mtd_partition h3xxx_partitions[] = { | 94 | static struct mtd_partition h3xxx_partitions[] = { |
53 | { | 95 | { |
54 | .name = "H3XXX boot firmware", | 96 | .name = "H3XXX boot firmware", |