aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Walleij <linus.walleij@linaro.org>2014-07-24 14:08:55 -0400
committerLinus Walleij <linus.walleij@linaro.org>2014-07-28 06:23:35 -0400
commit0a6d315827eedc733d404ecff3cd4cc0e6437865 (patch)
treede3b6538e200030ad2a3f7553e7e78f2112f652d
parentc7caf86823c71fae652cc50c7d8dd0d2b5c41229 (diff)
gpio: split gpiod board registration into machine header
As per example from the regulator subsystem: put all defines and functions related to registering board info for GPIO descriptors into a separate <linux/gpio/machine.h> header. Cc: Andrew Victor <linux@maxim.org.za> Cc: Nicolas Ferre <nicolas.ferre@atmel.com> Cc: Jean-Christophe Plagniol-Villard <plagnioj@jcrosoft.com> Cc: Ralf Baechle <ralf@linux-mips.org> Cc: Thierry Reding <thierry.reding@gmail.com> Acked-by: Stephen Warren <swarren@wwwdotorg.org> Reviewed-by: Alexandre Courbot <gnurou@gmail.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
-rw-r--r--Documentation/gpio/board.txt2
-rw-r--r--arch/arm/mach-at91/at91rm9200_devices.c2
-rw-r--r--arch/arm/mach-tegra/board-paz00.c2
-rw-r--r--arch/mips/jz4740/board-qi_lb60.c1
-rw-r--r--drivers/gpio/gpiolib.c1
-rw-r--r--include/linux/gpio/driver.h54
-rw-r--r--include/linux/gpio/machine.h58
7 files changed, 63 insertions, 57 deletions
diff --git a/Documentation/gpio/board.txt b/Documentation/gpio/board.txt
index ba169faad5c6..4452786225b8 100644
--- a/Documentation/gpio/board.txt
+++ b/Documentation/gpio/board.txt
@@ -60,7 +60,7 @@ Platform Data
60Finally, GPIOs can be bound to devices and functions using platform data. Board 60Finally, GPIOs can be bound to devices and functions using platform data. Board
61files that desire to do so need to include the following header: 61files that desire to do so need to include the following header:
62 62
63 #include <linux/gpio/driver.h> 63 #include <linux/gpio/machine.h>
64 64
65GPIOs are mapped by the means of tables of lookups, containing instances of the 65GPIOs are mapped by the means of tables of lookups, containing instances of the
66gpiod_lookup structure. Two macros are defined to help declaring such mappings: 66gpiod_lookup structure. Two macros are defined to help declaring such mappings:
diff --git a/arch/arm/mach-at91/at91rm9200_devices.c b/arch/arm/mach-at91/at91rm9200_devices.c
index 3f4bb58aea54..74f1eaf97801 100644
--- a/arch/arm/mach-at91/at91rm9200_devices.c
+++ b/arch/arm/mach-at91/at91rm9200_devices.c
@@ -15,7 +15,7 @@
15 15
16#include <linux/dma-mapping.h> 16#include <linux/dma-mapping.h>
17#include <linux/gpio.h> 17#include <linux/gpio.h>
18#include <linux/gpio/driver.h> 18#include <linux/gpio/machine.h>
19#include <linux/platform_device.h> 19#include <linux/platform_device.h>
20#include <linux/i2c-gpio.h> 20#include <linux/i2c-gpio.h>
21 21
diff --git a/arch/arm/mach-tegra/board-paz00.c b/arch/arm/mach-tegra/board-paz00.c
index 9c6029ba526f..91fd858ced0d 100644
--- a/arch/arm/mach-tegra/board-paz00.c
+++ b/arch/arm/mach-tegra/board-paz00.c
@@ -18,7 +18,7 @@
18 */ 18 */
19 19
20#include <linux/platform_device.h> 20#include <linux/platform_device.h>
21#include <linux/gpio/driver.h> 21#include <linux/gpio/machine.h>
22#include <linux/rfkill-gpio.h> 22#include <linux/rfkill-gpio.h>
23#include "board.h" 23#include "board.h"
24 24
diff --git a/arch/mips/jz4740/board-qi_lb60.c b/arch/mips/jz4740/board-qi_lb60.c
index 088e92a79ae6..c454525e7695 100644
--- a/arch/mips/jz4740/board-qi_lb60.c
+++ b/arch/mips/jz4740/board-qi_lb60.c
@@ -15,6 +15,7 @@
15#include <linux/kernel.h> 15#include <linux/kernel.h>
16#include <linux/init.h> 16#include <linux/init.h>
17#include <linux/gpio.h> 17#include <linux/gpio.h>
18#include <linux/gpio/machine.h>
18 19
19#include <linux/input.h> 20#include <linux/input.h>
20#include <linux/gpio_keys.h> 21#include <linux/gpio_keys.h>
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index 768f0831db18..18b069e6ba03 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -14,6 +14,7 @@
14#include <linux/slab.h> 14#include <linux/slab.h>
15#include <linux/acpi.h> 15#include <linux/acpi.h>
16#include <linux/gpio/driver.h> 16#include <linux/gpio/driver.h>
17#include <linux/gpio/machine.h>
17 18
18#include "gpiolib.h" 19#include "gpiolib.h"
19 20
diff --git a/include/linux/gpio/driver.h b/include/linux/gpio/driver.h
index 4c463fb0155e..e78a2373e374 100644
--- a/include/linux/gpio/driver.h
+++ b/include/linux/gpio/driver.h
@@ -151,60 +151,6 @@ void gpio_unlock_as_irq(struct gpio_chip *chip, unsigned int offset);
151 151
152struct gpio_chip *gpiod_to_chip(const struct gpio_desc *desc); 152struct gpio_chip *gpiod_to_chip(const struct gpio_desc *desc);
153 153
154enum gpio_lookup_flags {
155 GPIO_ACTIVE_HIGH = (0 << 0),
156 GPIO_ACTIVE_LOW = (1 << 0),
157 GPIO_OPEN_DRAIN = (1 << 1),
158 GPIO_OPEN_SOURCE = (1 << 2),
159};
160
161/**
162 * struct gpiod_lookup - lookup table
163 * @chip_label: name of the chip the GPIO belongs to
164 * @chip_hwnum: hardware number (i.e. relative to the chip) of the GPIO
165 * @con_id: name of the GPIO from the device's point of view
166 * @idx: index of the GPIO in case several GPIOs share the same name
167 * @flags: mask of GPIO_* values
168 *
169 * gpiod_lookup is a lookup table for associating GPIOs to specific devices and
170 * functions using platform data.
171 */
172struct gpiod_lookup {
173 const char *chip_label;
174 u16 chip_hwnum;
175 const char *con_id;
176 unsigned int idx;
177 enum gpio_lookup_flags flags;
178};
179
180struct gpiod_lookup_table {
181 struct list_head list;
182 const char *dev_id;
183 struct gpiod_lookup table[];
184};
185
186/*
187 * Simple definition of a single GPIO under a con_id
188 */
189#define GPIO_LOOKUP(_chip_label, _chip_hwnum, _con_id, _flags) \
190 GPIO_LOOKUP_IDX(_chip_label, _chip_hwnum, _con_id, 0, _flags)
191
192/*
193 * Use this macro if you need to have several GPIOs under the same con_id.
194 * Each GPIO needs to use a different index and can be accessed using
195 * gpiod_get_index()
196 */
197#define GPIO_LOOKUP_IDX(_chip_label, _chip_hwnum, _con_id, _idx, _flags) \
198{ \
199 .chip_label = _chip_label, \
200 .chip_hwnum = _chip_hwnum, \
201 .con_id = _con_id, \
202 .idx = _idx, \
203 .flags = _flags, \
204}
205
206void gpiod_add_lookup_table(struct gpiod_lookup_table *table);
207
208#ifdef CONFIG_GPIOLIB_IRQCHIP 154#ifdef CONFIG_GPIOLIB_IRQCHIP
209 155
210void gpiochip_set_chained_irqchip(struct gpio_chip *gpiochip, 156void gpiochip_set_chained_irqchip(struct gpio_chip *gpiochip,
diff --git a/include/linux/gpio/machine.h b/include/linux/gpio/machine.h
new file mode 100644
index 000000000000..b8ad87fab4ce
--- /dev/null
+++ b/include/linux/gpio/machine.h
@@ -0,0 +1,58 @@
1#ifndef __LINUX_GPIO_MACHINE_H
2#define __LINUX_GPIO_MACHINE_H
3
4enum gpio_lookup_flags {
5 GPIO_ACTIVE_HIGH = (0 << 0),
6 GPIO_ACTIVE_LOW = (1 << 0),
7 GPIO_OPEN_DRAIN = (1 << 1),
8 GPIO_OPEN_SOURCE = (1 << 2),
9};
10
11/**
12 * struct gpiod_lookup - lookup table
13 * @chip_label: name of the chip the GPIO belongs to
14 * @chip_hwnum: hardware number (i.e. relative to the chip) of the GPIO
15 * @con_id: name of the GPIO from the device's point of view
16 * @idx: index of the GPIO in case several GPIOs share the same name
17 * @flags: mask of GPIO_* values
18 *
19 * gpiod_lookup is a lookup table for associating GPIOs to specific devices and
20 * functions using platform data.
21 */
22struct gpiod_lookup {
23 const char *chip_label;
24 u16 chip_hwnum;
25 const char *con_id;
26 unsigned int idx;
27 enum gpio_lookup_flags flags;
28};
29
30struct gpiod_lookup_table {
31 struct list_head list;
32 const char *dev_id;
33 struct gpiod_lookup table[];
34};
35
36/*
37 * Simple definition of a single GPIO under a con_id
38 */
39#define GPIO_LOOKUP(_chip_label, _chip_hwnum, _con_id, _flags) \
40 GPIO_LOOKUP_IDX(_chip_label, _chip_hwnum, _con_id, 0, _flags)
41
42/*
43 * Use this macro if you need to have several GPIOs under the same con_id.
44 * Each GPIO needs to use a different index and can be accessed using
45 * gpiod_get_index()
46 */
47#define GPIO_LOOKUP_IDX(_chip_label, _chip_hwnum, _con_id, _idx, _flags) \
48{ \
49 .chip_label = _chip_label, \
50 .chip_hwnum = _chip_hwnum, \
51 .con_id = _con_id, \
52 .idx = _idx, \
53 .flags = _flags, \
54}
55
56void gpiod_add_lookup_table(struct gpiod_lookup_table *table);
57
58#endif /* __LINUX_GPIO_MACHINE_H */