diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2014-08-08 21:00:35 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2014-08-08 21:00:35 -0400 |
commit | 06b49ea43c0cdd22625883e555e45e66ef29e201 (patch) | |
tree | 9c72c88541e2bec5a95354504708a066fd8e50aa /Documentation | |
parent | 664fb23070ae66a023250a83870a5bae7cd0efeb (diff) | |
parent | bdc6e95e1273b5cef01590273c1a240c53ceeea0 (diff) |
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
...
Diffstat (limited to 'Documentation')
-rw-r--r-- | Documentation/devicetree/bindings/gpio/gpio-zynq.txt | 26 | ||||
-rw-r--r-- | Documentation/gpio/board.txt | 2 | ||||
-rw-r--r-- | Documentation/gpio/consumer.txt | 26 | ||||
-rw-r--r-- | Documentation/gpio/driver.txt | 25 |
4 files changed, 70 insertions, 9 deletions
diff --git a/Documentation/devicetree/bindings/gpio/gpio-zynq.txt b/Documentation/devicetree/bindings/gpio/gpio-zynq.txt new file mode 100644 index 000000000000..986371a4be2c --- /dev/null +++ b/Documentation/devicetree/bindings/gpio/gpio-zynq.txt | |||
@@ -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 | }; | ||
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 | |||
60 | Finally, GPIOs can be bound to devices and functions using platform data. Board | 60 | Finally, GPIOs can be bound to devices and functions using platform data. Board |
61 | files that desire to do so need to include the following header: | 61 | files 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 | ||
65 | GPIOs are mapped by the means of tables of lookups, containing instances of the | 65 | GPIOs are mapped by the means of tables of lookups, containing instances of the |
66 | gpiod_lookup structure. Two macros are defined to help declaring such mappings: | 66 | gpiod_lookup structure. Two macros are defined to help declaring such mappings: |
diff --git a/Documentation/gpio/consumer.txt b/Documentation/gpio/consumer.txt index d8abfc31abbe..76546324e968 100644 --- a/Documentation/gpio/consumer.txt +++ b/Documentation/gpio/consumer.txt | |||
@@ -29,13 +29,24 @@ gpiod_get() functions. Like many other kernel subsystems, gpiod_get() takes the | |||
29 | device that will use the GPIO and the function the requested GPIO is supposed to | 29 | device that will use the GPIO and the function the requested GPIO is supposed to |
30 | fulfill: | 30 | fulfill: |
31 | 31 | ||
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) | ||
33 | 34 | ||
34 | If a function is implemented by using several GPIOs together (e.g. a simple LED | 35 | If a function is implemented by using several GPIOs together (e.g. a simple LED |
35 | device that displays digits), an additional index argument can be specified: | 36 | device that displays digits), an additional index argument can be specified: |
36 | 37 | ||
37 | struct gpio_desc *gpiod_get_index(struct device *dev, | 38 | 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. | ||
39 | 50 | ||
40 | Both functions return either a valid GPIO descriptor, or an error code checkable | 51 | Both functions return either a valid GPIO descriptor, or an error code checkable |
41 | with IS_ERR() (they will never return a NULL pointer). -ENOENT will be returned | 52 | 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. | |||
46 | 57 | ||
47 | Device-managed variants of these functions are also defined: | 58 | Device-managed variants of these functions are also defined: |
48 | 59 | ||
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) | ||
50 | 62 | ||
51 | struct gpio_desc *devm_gpiod_get_index(struct device *dev, | 63 | struct gpio_desc *devm_gpiod_get_index(struct device *dev, |
52 | const char *con_id, | 64 | const char *con_id, |
53 | unsigned int idx) | 65 | unsigned int idx, |
66 | enum gpiod_flags flags) | ||
54 | 67 | ||
55 | A GPIO descriptor can be disposed of using the gpiod_put() function: | 68 | A GPIO descriptor can be disposed of using the gpiod_put() function: |
56 | 69 | ||
@@ -67,8 +80,9 @@ Using GPIOs | |||
67 | 80 | ||
68 | Setting Direction | 81 | Setting Direction |
69 | ----------------- | 82 | ----------------- |
70 | The first thing a driver must do with a GPIO is setting its direction. This is | 83 | The first thing a driver must do with a GPIO is setting its direction. If no |
71 | done by invoking one of the gpiod_direction_*() functions: | 84 | direction-setting flags have been given to gpiod_get*(), this is done by |
85 | invoking one of the gpiod_direction_*() functions: | ||
72 | 86 | ||
73 | int gpiod_direction_input(struct gpio_desc *desc) | 87 | int gpiod_direction_input(struct gpio_desc *desc) |
74 | int gpiod_direction_output(struct gpio_desc *desc, int value) | 88 | int gpiod_direction_output(struct gpio_desc *desc, int value) |
diff --git a/Documentation/gpio/driver.txt b/Documentation/gpio/driver.txt index fa9a0a8b3734..18790c237977 100644 --- a/Documentation/gpio/driver.txt +++ b/Documentation/gpio/driver.txt | |||
@@ -157,13 +157,34 @@ Locking IRQ usage | |||
157 | Input GPIOs can be used as IRQ signals. When this happens, a driver is requested | 157 | Input GPIOs can be used as IRQ signals. When this happens, a driver is requested |
158 | to mark the GPIO as being used as an IRQ: | 158 | to mark the GPIO as being used as an IRQ: |
159 | 159 | ||
160 | int gpiod_lock_as_irq(struct gpio_desc *desc) | 160 | int gpio_lock_as_irq(struct gpio_chip *chip, unsigned int offset) |
161 | 161 | ||
162 | This will prevent the use of non-irq related GPIO APIs until the GPIO IRQ lock | 162 | This will prevent the use of non-irq related GPIO APIs until the GPIO IRQ lock |
163 | is released: | 163 | is released: |
164 | 164 | ||
165 | void gpiod_unlock_as_irq(struct gpio_desc *desc) | 165 | void gpio_unlock_as_irq(struct gpio_chip *chip, unsigned int offset) |
166 | 166 | ||
167 | When implementing an irqchip inside a GPIO driver, these two functions should | 167 | When implementing an irqchip inside a GPIO driver, these two functions should |
168 | typically be called in the .startup() and .shutdown() callbacks from the | 168 | typically be called in the .startup() and .shutdown() callbacks from the |
169 | irqchip. | 169 | 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. | ||