diff options
author | Paul Mundt <lethal@linux-sh.org> | 2010-10-13 14:04:44 -0400 |
---|---|---|
committer | Paul Mundt <lethal@linux-sh.org> | 2010-10-13 14:04:44 -0400 |
commit | 47da88f36639b8de57f6cdd680f8c27528ccd67c (patch) | |
tree | 2c5cf30f6fb84366277fcbec57a0c8cc04f64282 /arch/sh/boards/mach-sdk7786 | |
parent | 550a1ef18a53cae3d908edceca9daaafbedcf12f (diff) |
sh: mach-sdk7786: Add support for fpga gpios.
The sdk7786 FPGA supports a number of user settable input switches that
are otherwise unused. This wires up a dummy gpio chip for the switch bank
to simply expose them to userspace.
Signed-off-by: Paul Mundt <lethal@linux-sh.org>
Diffstat (limited to 'arch/sh/boards/mach-sdk7786')
-rw-r--r-- | arch/sh/boards/mach-sdk7786/Makefile | 2 | ||||
-rw-r--r-- | arch/sh/boards/mach-sdk7786/gpio.c | 49 |
2 files changed, 51 insertions, 0 deletions
diff --git a/arch/sh/boards/mach-sdk7786/Makefile b/arch/sh/boards/mach-sdk7786/Makefile index a29f19e85b63..d0f801bd8416 100644 --- a/arch/sh/boards/mach-sdk7786/Makefile +++ b/arch/sh/boards/mach-sdk7786/Makefile | |||
@@ -1 +1,3 @@ | |||
1 | obj-y := setup.o fpga.o irq.o | 1 | obj-y := setup.o fpga.o irq.o |
2 | |||
3 | obj-$(CONFIG_GENERIC_GPIO) += gpio.o | ||
diff --git a/arch/sh/boards/mach-sdk7786/gpio.c b/arch/sh/boards/mach-sdk7786/gpio.c new file mode 100644 index 000000000000..f71ce09d4e15 --- /dev/null +++ b/arch/sh/boards/mach-sdk7786/gpio.c | |||
@@ -0,0 +1,49 @@ | |||
1 | /* | ||
2 | * SDK7786 FPGA USRGPIR Support. | ||
3 | * | ||
4 | * Copyright (C) 2010 Paul Mundt | ||
5 | * | ||
6 | * This file is subject to the terms and conditions of the GNU General Public | ||
7 | * License. See the file "COPYING" in the main directory of this archive | ||
8 | * for more details. | ||
9 | */ | ||
10 | #include <linux/init.h> | ||
11 | #include <linux/interrupt.h> | ||
12 | #include <linux/gpio.h> | ||
13 | #include <linux/irq.h> | ||
14 | #include <linux/kernel.h> | ||
15 | #include <linux/spinlock.h> | ||
16 | #include <linux/io.h> | ||
17 | #include <mach/fpga.h> | ||
18 | |||
19 | #define NR_FPGA_GPIOS 8 | ||
20 | |||
21 | static const char *usrgpir_gpio_names[NR_FPGA_GPIOS] = { | ||
22 | "in0", "in1", "in2", "in3", "in4", "in5", "in6", "in7", | ||
23 | }; | ||
24 | |||
25 | static int usrgpir_gpio_direction_input(struct gpio_chip *chip, unsigned gpio) | ||
26 | { | ||
27 | /* always in */ | ||
28 | return 0; | ||
29 | } | ||
30 | |||
31 | static int usrgpir_gpio_get(struct gpio_chip *chip, unsigned gpio) | ||
32 | { | ||
33 | return !!(fpga_read_reg(USRGPIR) & (1 << gpio)); | ||
34 | } | ||
35 | |||
36 | static struct gpio_chip usrgpir_gpio_chip = { | ||
37 | .label = "sdk7786-fpga", | ||
38 | .names = usrgpir_gpio_names, | ||
39 | .direction_input = usrgpir_gpio_direction_input, | ||
40 | .get = usrgpir_gpio_get, | ||
41 | .base = -1, /* don't care */ | ||
42 | .ngpio = NR_FPGA_GPIOS, | ||
43 | }; | ||
44 | |||
45 | static int __init usrgpir_gpio_setup(void) | ||
46 | { | ||
47 | return gpiochip_add(&usrgpir_gpio_chip); | ||
48 | } | ||
49 | device_initcall(usrgpir_gpio_setup); | ||