aboutsummaryrefslogtreecommitdiffstats
path: root/include/uapi/linux
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2016-07-26 22:16:01 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2016-07-26 22:16:01 -0400
commit1cd04d293c818687795b83cd8f2626bd4662feeb (patch)
treedcbaadd82c02204114b99c418bfae1ee57b2c4ca /include/uapi/linux
parent9c1958fc326a0a0a533ec8e86ea6fa30977207de (diff)
parent224f9e6d538c4cfb2fa8dc4206fceb9431271388 (diff)
Merge tag 'gpio-v4.8-1' of git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-gpio
Pull GPIO updates from Linus Walleij: "This is the bulk of GPIO changes for the v4.8 kernel cycle. The big news is the completion of the chardev ABI which I'm very happy about and apart from that it's an ordinary, quite busy cycle. The details are below. The patches are tested in linux-next for some time, patches to other subsystem mostly have ACKs. I got overly ambitious with configureing lines as input for IRQ lines but it turns out that some controllers have their interrupt-enable and input-enabling in orthogonal settings so the assumption that all IRQ lines are input lines does not hold. Oh well, revert and back to the drawing board with that. Core changes: - The big item is of course the completion of the character device ABI. It has now replaced and surpassed the former unmaintainable sysfs ABI: we can now hammer (bitbang) individual lines or sets of lines and read individual lines or sets of lines from userspace, and we can also register to listen to GPIO events from userspace. As a tie-in we have two new tools in tools/gpio: gpio-hammer and gpio-event-mon that illustrate the proper use of the new ABI. As someone said: the wild west days of GPIO are now over. - Continued to remove the pointless ARCH_[WANT_OPTIONAL|REQUIRE]_GPIOLIB Kconfig symbols. I'm patching hexagon, openrisc, powerpc, sh, unicore, ia64 and microblaze. These are either ACKed by their maintainers or patched anyways after a grace period and no response from maintainers. Some archs (ARM) come in from their trees, and others (x86) are still not fixed, so I might send a second pull request to root it out later in this merge window, or just defer to v4.9. - The GPIO tools are moved to the tools build system. New drivers: - New driver for the MAX77620/MAX20024. - New driver for the Intel Merrifield. - Enabled PCA953x for the TI PCA9536. - Enabled PCA953x for the Intel Edison. - Enabled R8A7792 in the RCAR driver. Driver improvements: - The STMPE and F7188x now supports the .get_direction() callback. - The Xilinx driver supports setting multiple lines at once. - ACPI support for the Vulcan GPIO controller. - The MMIO GPIO driver supports device tree probing. - The Acer One 10 is supported through the _DEP ACPI attribute. Cleanups: - A major cleanup of the OF/DT support code. It is way easier to read and understand now, probably this improves performance too. - Drop a few redundant .owner assignments. - Remove CLPS711x boardfile support: we are 100% DT" * tag 'gpio-v4.8-1' of git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-gpio: (67 commits) MAINTAINERS: Add INTEL MERRIFIELD GPIO entry gpio: dwapb: add missing fwnode_handle_put() in dwapb_gpio_get_pdata() gpio: merrifield: Protect irq_ack() and gpio_set() by lock gpio: merrifield: Introduce GPIO driver to support Merrifield gpio: intel-mid: Make it depend to X86_INTEL_MID gpio: intel-mid: Sort header block alphabetically gpio: intel-mid: Remove potentially harmful code gpio: rcar: add R8A7792 support gpiolib: remove duplicated include from gpiolib.c Revert "gpio: convince line to become input in irq helper" gpiolib: of_find_gpio(): Don't discard errors gpio: of: Allow overriding the device node gpio: free handles in fringe cases gpio: tps65218: Add platform_device_id table gpio: max77620: get gpio value based on direction gpio: lynxpoint: avoid potential warning on error path tools/gpio: add install section tools/gpio: move to tools buildsystem gpio: intel-mid: switch to devm_gpiochip_add_data() gpio: 74x164: Use spi_write() helper instead of open coding ...
Diffstat (limited to 'include/uapi/linux')
-rw-r--r--include/uapi/linux/gpio.h105
1 files changed, 102 insertions, 3 deletions
diff --git a/include/uapi/linux/gpio.h b/include/uapi/linux/gpio.h
index d0a3cac72250..333d3544c964 100644
--- a/include/uapi/linux/gpio.h
+++ b/include/uapi/linux/gpio.h
@@ -1,7 +1,7 @@
1/* 1/*
2 * <linux/gpio.h> - userspace ABI for the GPIO character devices 2 * <linux/gpio.h> - userspace ABI for the GPIO character devices
3 * 3 *
4 * Copyright (C) 2015 Linus Walleij 4 * Copyright (C) 2016 Linus Walleij
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify it 6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License version 2 as published by 7 * under the terms of the GNU General Public License version 2 as published by
@@ -26,8 +26,8 @@ struct gpiochip_info {
26 __u32 lines; 26 __u32 lines;
27}; 27};
28 28
29/* Line is in use by the kernel */ 29/* Informational flags */
30#define GPIOLINE_FLAG_KERNEL (1UL << 0) 30#define GPIOLINE_FLAG_KERNEL (1UL << 0) /* Line used by the kernel */
31#define GPIOLINE_FLAG_IS_OUT (1UL << 1) 31#define GPIOLINE_FLAG_IS_OUT (1UL << 1)
32#define GPIOLINE_FLAG_ACTIVE_LOW (1UL << 2) 32#define GPIOLINE_FLAG_ACTIVE_LOW (1UL << 2)
33#define GPIOLINE_FLAG_OPEN_DRAIN (1UL << 3) 33#define GPIOLINE_FLAG_OPEN_DRAIN (1UL << 3)
@@ -52,7 +52,106 @@ struct gpioline_info {
52 char consumer[32]; 52 char consumer[32];
53}; 53};
54 54
55/* Maximum number of requested handles */
56#define GPIOHANDLES_MAX 64
57
58/* Linerequest flags */
59#define GPIOHANDLE_REQUEST_INPUT (1UL << 0)
60#define GPIOHANDLE_REQUEST_OUTPUT (1UL << 1)
61#define GPIOHANDLE_REQUEST_ACTIVE_LOW (1UL << 2)
62#define GPIOHANDLE_REQUEST_OPEN_DRAIN (1UL << 3)
63#define GPIOHANDLE_REQUEST_OPEN_SOURCE (1UL << 4)
64
65/**
66 * struct gpiohandle_request - Information about a GPIO handle request
67 * @lineoffsets: an array desired lines, specified by offset index for the
68 * associated GPIO device
69 * @flags: desired flags for the desired GPIO lines, such as
70 * GPIOHANDLE_REQUEST_OUTPUT, GPIOHANDLE_REQUEST_ACTIVE_LOW etc, OR:ed
71 * together. Note that even if multiple lines are requested, the same flags
72 * must be applicable to all of them, if you want lines with individual
73 * flags set, request them one by one. It is possible to select
74 * a batch of input or output lines, but they must all have the same
75 * characteristics, i.e. all inputs or all outputs, all active low etc
76 * @default_values: if the GPIOHANDLE_REQUEST_OUTPUT is set for a requested
77 * line, this specifies the default output value, should be 0 (low) or
78 * 1 (high), anything else than 0 or 1 will be interpreted as 1 (high)
79 * @consumer_label: a desired consumer label for the selected GPIO line(s)
80 * such as "my-bitbanged-relay"
81 * @lines: number of lines requested in this request, i.e. the number of
82 * valid fields in the above arrays, set to 1 to request a single line
83 * @fd: if successful this field will contain a valid anonymous file handle
84 * after a GPIO_GET_LINEHANDLE_IOCTL operation, zero or negative value
85 * means error
86 */
87struct gpiohandle_request {
88 __u32 lineoffsets[GPIOHANDLES_MAX];
89 __u32 flags;
90 __u8 default_values[GPIOHANDLES_MAX];
91 char consumer_label[32];
92 __u32 lines;
93 int fd;
94};
95
96/**
97 * struct gpiohandle_data - Information of values on a GPIO handle
98 * @values: when getting the state of lines this contains the current
99 * state of a line, when setting the state of lines these should contain
100 * the desired target state
101 */
102struct gpiohandle_data {
103 __u8 values[GPIOHANDLES_MAX];
104};
105
106#define GPIOHANDLE_GET_LINE_VALUES_IOCTL _IOWR(0xB4, 0x08, struct gpiohandle_data)
107#define GPIOHANDLE_SET_LINE_VALUES_IOCTL _IOWR(0xB4, 0x09, struct gpiohandle_data)
108
109/* Eventrequest flags */
110#define GPIOEVENT_REQUEST_RISING_EDGE (1UL << 0)
111#define GPIOEVENT_REQUEST_FALLING_EDGE (1UL << 1)
112#define GPIOEVENT_REQUEST_BOTH_EDGES ((1UL << 0) | (1UL << 1))
113
114/**
115 * struct gpioevent_request - Information about a GPIO event request
116 * @lineoffset: the desired line to subscribe to events from, specified by
117 * offset index for the associated GPIO device
118 * @handleflags: desired handle flags for the desired GPIO line, such as
119 * GPIOHANDLE_REQUEST_ACTIVE_LOW or GPIOHANDLE_REQUEST_OPEN_DRAIN
120 * @eventflags: desired flags for the desired GPIO event line, such as
121 * GPIOEVENT_REQUEST_RISING_EDGE or GPIOEVENT_REQUEST_FALLING_EDGE
122 * @consumer_label: a desired consumer label for the selected GPIO line(s)
123 * such as "my-listener"
124 * @fd: if successful this field will contain a valid anonymous file handle
125 * after a GPIO_GET_LINEEVENT_IOCTL operation, zero or negative value
126 * means error
127 */
128struct gpioevent_request {
129 __u32 lineoffset;
130 __u32 handleflags;
131 __u32 eventflags;
132 char consumer_label[32];
133 int fd;
134};
135
136/**
137 * GPIO event types
138 */
139#define GPIOEVENT_EVENT_RISING_EDGE 0x01
140#define GPIOEVENT_EVENT_FALLING_EDGE 0x02
141
142/**
143 * struct gpioevent_data - The actual event being pushed to userspace
144 * @timestamp: best estimate of time of event occurrence, in nanoseconds
145 * @id: event identifier
146 */
147struct gpioevent_data {
148 __u64 timestamp;
149 __u32 id;
150};
151
55#define GPIO_GET_CHIPINFO_IOCTL _IOR(0xB4, 0x01, struct gpiochip_info) 152#define GPIO_GET_CHIPINFO_IOCTL _IOR(0xB4, 0x01, struct gpiochip_info)
56#define GPIO_GET_LINEINFO_IOCTL _IOWR(0xB4, 0x02, struct gpioline_info) 153#define GPIO_GET_LINEINFO_IOCTL _IOWR(0xB4, 0x02, struct gpioline_info)
154#define GPIO_GET_LINEHANDLE_IOCTL _IOWR(0xB4, 0x03, struct gpiohandle_request)
155#define GPIO_GET_LINEEVENT_IOCTL _IOWR(0xB4, 0x04, struct gpioevent_request)
57 156
58#endif /* _UAPI_GPIO_H_ */ 157#endif /* _UAPI_GPIO_H_ */