Skip to content

Commit 06b49ea

Browse files
committed
Merge tag 'gpio-v3.17-1' of git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-gpio
Pull GPIO update from Linus Walleij: "This is the bulk of GPIO changes for the v3.17 development cycle, and this time we got a lot of action going on and it will continue: - The core GPIO library implementation has been split up in three different files: - gpiolib.c for the latest and greatest and shiny GPIO library code using GPIO descriptors only - gpiolib-legacy.c for the old integer number space API that we are phasing out gradually - gpiolib-sysfs.c for the sysfs interface that we are not entirely happy with, but has to live on for ABI compatibility - Add a flags argument to *gpiod_get* functions, with some backward-compatibility macros to ease transitions. We should have had the flags there from the beginning it seems, now we need to clean up the mess. There is a plan on how to move forward here devised by Alexandre Courbot and Mark Brown - Split off a special <linux/gpio/machine.h> header for the board gpio table registration, as per example from the regulator subsystem - Start to kill off the return value from gpiochip_remove() by removing the __must_check attribute and removing all checks inside the drivers/gpio directory. The rationale is: well what were we supposed to do if there is an error code? Not much: print an error message. And gpiolib already does that. So make this function return void eventually - Some cleanups of hairy gpiolib code, make some functions not to be used outside the library private and make sure they are not exported, remove gpiod_lock/unlock_as_irq() as the existing function is for driver-internal use and fine as it is, delete gpio_ensure_requested() as it is not meaningful anymore - Support the GPIOF_ACTIVE_LOW flag from gpio_request_one() function calls, which is logical since this is already supported when referencing GPIOs from e.g. device trees - Switch STMPE, intel-mid, lynxpoint and ACPI (!) to use the gpiolib irqchip helpers cutting down on GPIO irqchip boilerplate a bit more - New driver for the Zynq GPIO block - The usual incremental improvements around a bunch of drivers - Janitorial syntactic and semantic cleanups by Jingoo Han, and Rickard Strandqvist especially" * tag 'gpio-v3.17-1' of git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-gpio: (37 commits) MAINTAINERS: update GPIO include files gpio: add missing includes in machine.h gpio: add flags argument to gpiod_get*() functions MAINTAINERS: Update Samsung pin control entry gpio / ACPI: Move event handling registration to gpiolib irqchip helpers gpio: lynxpoint: Convert to use gpiolib irqchip gpio: split gpiod board registration into machine header gpio: remove gpio_ensure_requested() gpio: remove useless check in gpiolib_sysfs_init() gpiolib: Export gpiochip_request_own_desc and gpiochip_free_own_desc gpio: move gpio_ensure_requested() into legacy C file gpio: remove gpiod_lock/unlock_as_irq() gpio: make gpiochip_get_desc() gpiolib-private gpio: simplify gpiochip_export() gpio: remove export of private of_get_named_gpio_flags() gpio: Add support for GPIOF_ACTIVE_LOW to gpio_request_one functions gpio: zynq: Clear pending interrupt when enabling a IRQ gpio: drop retval check enforcing from gpiochip_remove() gpio: remove all usage of gpio_remove retval in driver/gpio devicetree: Add Zynq GPIO devicetree bindings documentation ...
2 parents 664fb23 + bdc6e95 commit 06b49ea

84 files changed

Lines changed: 2485 additions & 2003 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
Xilinx Zynq GPIO controller Device Tree Bindings
2+
-------------------------------------------
3+
4+
Required properties:
5+
- #gpio-cells : Should be two
6+
- First cell is the GPIO line number
7+
- Second cell is used to specify optional
8+
parameters (unused)
9+
- compatible : Should be "xlnx,zynq-gpio-1.0"
10+
- clocks : Clock specifier (see clock bindings for details)
11+
- gpio-controller : Marks the device node as a GPIO controller.
12+
- interrupts : Interrupt specifier (see interrupt bindings for
13+
details)
14+
- interrupt-parent : Must be core interrupt controller
15+
- reg : Address and length of the register set for the device
16+
17+
Example:
18+
gpio@e000a000 {
19+
#gpio-cells = <2>;
20+
compatible = "xlnx,zynq-gpio-1.0";
21+
clocks = <&clkc 42>;
22+
gpio-controller;
23+
interrupt-parent = <&intc>;
24+
interrupts = <0 20 4>;
25+
reg = <0xe000a000 0x1000>;
26+
};

‎Documentation/gpio/board.txt‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ Platform Data
6060
Finally, GPIOs can be bound to devices and functions using platform data. Board
6161
files that desire to do so need to include the following header:
6262

63-
#include <linux/gpio/driver.h>
63+
#include <linux/gpio/machine.h>
6464

6565
GPIOs are mapped by the means of tables of lookups, containing instances of the
6666
gpiod_lookup structure. Two macros are defined to help declaring such mappings:

‎Documentation/gpio/consumer.txt‎

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,24 @@ gpiod_get() functions. Like many other kernel subsystems, gpiod_get() takes the
2929
device that will use the GPIO and the function the requested GPIO is supposed to
3030
fulfill:
3131

32-
struct gpio_desc *gpiod_get(struct device *dev, const char *con_id)
32+
struct gpio_desc *gpiod_get(struct device *dev, const char *con_id,
33+
enum gpiod_flags flags)
3334

3435
If a function is implemented by using several GPIOs together (e.g. a simple LED
3536
device that displays digits), an additional index argument can be specified:
3637

3738
struct gpio_desc *gpiod_get_index(struct device *dev,
38-
const char *con_id, unsigned int idx)
39+
const char *con_id, unsigned int idx,
40+
enum gpiod_flags flags)
41+
42+
The flags parameter is used to optionally specify a direction and initial value
43+
for the GPIO. Values can be:
44+
45+
* GPIOD_ASIS or 0 to not initialize the GPIO at all. The direction must be set
46+
later with one of the dedicated functions.
47+
* GPIOD_IN to initialize the GPIO as input.
48+
* GPIOD_OUT_LOW to initialize the GPIO as output with a value of 0.
49+
* GPIOD_OUT_HIGH to initialize the GPIO as output with a value of 1.
3950

4051
Both functions return either a valid GPIO descriptor, or an error code checkable
4152
with IS_ERR() (they will never return a NULL pointer). -ENOENT will be returned
@@ -46,11 +57,13 @@ errors and an absence of GPIO for optional GPIO parameters.
4657

4758
Device-managed variants of these functions are also defined:
4859

49-
struct gpio_desc *devm_gpiod_get(struct device *dev, const char *con_id)
60+
struct gpio_desc *devm_gpiod_get(struct device *dev, const char *con_id,
61+
enum gpiod_flags flags)
5062

5163
struct gpio_desc *devm_gpiod_get_index(struct device *dev,
5264
const char *con_id,
53-
unsigned int idx)
65+
unsigned int idx,
66+
enum gpiod_flags flags)
5467

5568
A GPIO descriptor can be disposed of using the gpiod_put() function:
5669

@@ -67,8 +80,9 @@ Using GPIOs
6780

6881
Setting Direction
6982
-----------------
70-
The first thing a driver must do with a GPIO is setting its direction. This is
71-
done by invoking one of the gpiod_direction_*() functions:
83+
The first thing a driver must do with a GPIO is setting its direction. If no
84+
direction-setting flags have been given to gpiod_get*(), this is done by
85+
invoking one of the gpiod_direction_*() functions:
7286

7387
int gpiod_direction_input(struct gpio_desc *desc)
7488
int gpiod_direction_output(struct gpio_desc *desc, int value)

‎Documentation/gpio/driver.txt‎

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,13 +157,34 @@ Locking IRQ usage
157157
Input GPIOs can be used as IRQ signals. When this happens, a driver is requested
158158
to mark the GPIO as being used as an IRQ:
159159

160-
int gpiod_lock_as_irq(struct gpio_desc *desc)
160+
int gpio_lock_as_irq(struct gpio_chip *chip, unsigned int offset)
161161

162162
This will prevent the use of non-irq related GPIO APIs until the GPIO IRQ lock
163163
is released:
164164

165-
void gpiod_unlock_as_irq(struct gpio_desc *desc)
165+
void gpio_unlock_as_irq(struct gpio_chip *chip, unsigned int offset)
166166

167167
When implementing an irqchip inside a GPIO driver, these two functions should
168168
typically be called in the .startup() and .shutdown() callbacks from the
169169
irqchip.
170+
171+
172+
Requesting self-owned GPIO pins
173+
-------------------------------
174+
175+
Sometimes it is useful to allow a GPIO chip driver to request its own GPIO
176+
descriptors through the gpiolib API. Using gpio_request() for this purpose
177+
does not help since it pins the module to the kernel forever (it calls
178+
try_module_get()). A GPIO driver can use the following functions instead
179+
to request and free descriptors without being pinned to the kernel forever.
180+
181+
int gpiochip_request_own_desc(struct gpio_desc *desc, const char *label)
182+
183+
void gpiochip_free_own_desc(struct gpio_desc *desc)
184+
185+
Descriptors requested with gpiochip_request_own_desc() must be released with
186+
gpiochip_free_own_desc().
187+
188+
These functions must be used with care since they do not affect module use
189+
count. Do not use the functions to request gpio descriptors not owned by the
190+
calling driver.

‎MAINTAINERS‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4031,7 +4031,8 @@ T: git git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-gpio.git
40314031
S: Maintained
40324032
F: Documentation/gpio/
40334033
F: drivers/gpio/
4034-
F: include/linux/gpio*
4034+
F: include/linux/gpio/
4035+
F: include/linux/gpio.h
40354036
F: include/asm-generic/gpio.h
40364037

40374038
GRE DEMULTIPLEXER DRIVER
@@ -7002,9 +7003,7 @@ M: Thomas Abraham <thomas.abraham@linaro.org>
70027003
L: linux-arm-kernel@lists.infradead.org (moderated for non-subscribers)
70037004
L: linux-samsung-soc@vger.kernel.org (moderated for non-subscribers)
70047005
S: Maintained
7005-
F: drivers/pinctrl/pinctrl-exynos.*
7006-
F: drivers/pinctrl/pinctrl-s3c*
7007-
F: drivers/pinctrl/pinctrl-samsung.*
7006+
F: drivers/pinctrl/samsung/
70087007

70097008
PIN CONTROLLER - ST SPEAR
70107009
M: Viresh Kumar <viresh.linux@gmail.com>

‎arch/arm/mach-at91/at91rm9200_devices.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
#include <linux/dma-mapping.h>
1717
#include <linux/gpio.h>
18-
#include <linux/gpio/driver.h>
18+
#include <linux/gpio/machine.h>
1919
#include <linux/platform_device.h>
2020
#include <linux/i2c-gpio.h>
2121

‎arch/arm/mach-tegra/board-paz00.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
*
1818
*/
1919

20-
#include <linux/gpio/driver.h>
20+
#include <linux/gpio/machine.h>
2121
#include <linux/platform_device.h>
2222
#include <linux/rfkill-gpio.h>
2323

‎arch/mips/jz4740/board-qi_lb60.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include <linux/kernel.h>
1616
#include <linux/init.h>
1717
#include <linux/gpio.h>
18+
#include <linux/gpio/machine.h>
1819

1920
#include <linux/input.h>
2021
#include <linux/gpio_keys.h>

‎drivers/gpio/Kconfig‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,13 @@ config GPIO_XILINX
340340
help
341341
Say yes here to support the Xilinx FPGA GPIO device
342342

343+
config GPIO_ZYNQ
344+
tristate "Xilinx Zynq GPIO support"
345+
depends on ARCH_ZYNQ
346+
select GPIOLIB_IRQCHIP
347+
help
348+
Say yes here to support Xilinx Zynq GPIO controller.
349+
343350
config GPIO_XTENSA
344351
bool "Xtensa GPIO32 support"
345352
depends on XTENSA
@@ -423,7 +430,7 @@ config GPIO_GE_FPGA
423430
config GPIO_LYNXPOINT
424431
tristate "Intel Lynxpoint GPIO support"
425432
depends on ACPI && X86
426-
select IRQ_DOMAIN
433+
select GPIOLIB_IRQCHIP
427434
help
428435
driver for GPIO functionality on Intel Lynxpoint PCH chipset
429436
Requires ACPI device enumeration code to set up a platform device.
@@ -586,6 +593,7 @@ config GPIO_SX150X
586593
config GPIO_STMPE
587594
bool "STMPE GPIOs"
588595
depends on MFD_STMPE
596+
select GPIOLIB_IRQCHIP
589597
help
590598
This enables support for the GPIOs found on the STMPE I/O
591599
Expanders.

‎drivers/gpio/Makefile‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ ccflags-$(CONFIG_DEBUG_GPIO) += -DDEBUG
44

55
obj-$(CONFIG_GPIO_DEVRES) += devres.o
66
obj-$(CONFIG_GPIOLIB) += gpiolib.o
7+
obj-$(CONFIG_GPIOLIB) += gpiolib-legacy.o
78
obj-$(CONFIG_OF_GPIO) += gpiolib-of.o
9+
obj-$(CONFIG_GPIO_SYSFS) += gpiolib-sysfs.o
810
obj-$(CONFIG_GPIO_ACPI) += gpiolib-acpi.o
911

1012
# Device drivers. Generally keep list sorted alphabetically
@@ -102,3 +104,4 @@ obj-$(CONFIG_GPIO_WM8994) += gpio-wm8994.o
102104
obj-$(CONFIG_GPIO_XILINX) += gpio-xilinx.o
103105
obj-$(CONFIG_GPIO_XTENSA) += gpio-xtensa.o
104106
obj-$(CONFIG_GPIO_ZEVIO) += gpio-zevio.o
107+
obj-$(CONFIG_GPIO_ZYNQ) += gpio-zynq.o

0 commit comments

Comments
 (0)