forked from Minki/linux
gpio: add DT bindings for existing consumer flags
It is customary for GPIO controllers to support open drain/collector and open source/emitter configurations. Add standard GPIO line flags to account for this and augment the documentation to say that these are the most generic bindings. Several people approached me to add new flags to the lines, and this makes sense, but let's first bind up the most common cases before we start to add exotic stuff. Thanks to H. Nikolaus Schaller for ideas on how to encode single-ended wiring such as open drain/source and open collector/emitter. Cc: Tony Lindgren <tony@atomide.com> Cc: Grygorii Strashko <grygorii.strashko@ti.com> Cc: H. Nikolaus Schaller <hns@goldelico.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
This commit is contained in:
parent
b8664924e8
commit
69d301fdd1
@ -52,9 +52,13 @@ only uses one.
|
||||
|
||||
gpio-specifier may encode: bank, pin position inside the bank,
|
||||
whether pin is open-drain and whether pin is logically inverted.
|
||||
|
||||
Exact meaning of each specifier cell is controller specific, and must
|
||||
be documented in the device tree binding for the device. Use the macros
|
||||
defined in include/dt-bindings/gpio/gpio.h whenever possible:
|
||||
be documented in the device tree binding for the device.
|
||||
|
||||
Most controllers are however specifying a generic flag bitfield
|
||||
in the last cell, so for these, use the macros defined in
|
||||
include/dt-bindings/gpio/gpio.h whenever possible:
|
||||
|
||||
Example of a node using GPIOs:
|
||||
|
||||
@ -65,6 +69,15 @@ Example of a node using GPIOs:
|
||||
GPIO_ACTIVE_HIGH is 0, so in this example gpio-specifier is "18 0" and encodes
|
||||
GPIO pin number, and GPIO flags as accepted by the "qe_pio_e" gpio-controller.
|
||||
|
||||
Optional standard bitfield specifiers for the last cell:
|
||||
|
||||
- Bit 0: 0 means active high, 1 means active low
|
||||
- Bit 1: 1 means single-ended wiring, see:
|
||||
https://en.wikipedia.org/wiki/Single-ended_triode
|
||||
When used with active-low, this means open drain/collector, see:
|
||||
https://en.wikipedia.org/wiki/Open_collector
|
||||
When used with active-high, this means open source/emitter
|
||||
|
||||
1.1) GPIO specifier best practices
|
||||
----------------------------------
|
||||
|
||||
|
@ -9,7 +9,19 @@
|
||||
#ifndef _DT_BINDINGS_GPIO_GPIO_H
|
||||
#define _DT_BINDINGS_GPIO_GPIO_H
|
||||
|
||||
/* Bit 0 express polarity */
|
||||
#define GPIO_ACTIVE_HIGH 0
|
||||
#define GPIO_ACTIVE_LOW 1
|
||||
|
||||
/* Bit 1 express single-endedness */
|
||||
#define GPIO_PUSH_PULL 0
|
||||
#define GPIO_SINGLE_ENDED 2
|
||||
|
||||
/*
|
||||
* Open Drain/Collector is the combination of single-ended active low,
|
||||
* Open Source/Emitter is the combination of single-ended active high.
|
||||
*/
|
||||
#define GPIO_OPEN_DRAIN (GPIO_SINGLE_ENDED | GPIO_ACTIVE_LOW)
|
||||
#define GPIO_OPEN_SOURCE (GPIO_SINGLE_ENDED | GPIO_ACTIVE_HIGH)
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user