diff options
Diffstat (limited to 'Documentation/devicetree/bindings/gpio/gpio.txt')
-rw-r--r-- | Documentation/devicetree/bindings/gpio/gpio.txt | 40 |
1 files changed, 26 insertions, 14 deletions
diff --git a/Documentation/devicetree/bindings/gpio/gpio.txt b/Documentation/devicetree/bindings/gpio/gpio.txt index 3fb8f53071b8..b9bd1d64cfa6 100644 --- a/Documentation/devicetree/bindings/gpio/gpio.txt +++ b/Documentation/devicetree/bindings/gpio/gpio.txt | |||
@@ -13,13 +13,22 @@ properties, each containing a 'gpio-list': | |||
13 | gpio-specifier : Array of #gpio-cells specifying specific gpio | 13 | gpio-specifier : Array of #gpio-cells specifying specific gpio |
14 | (controller specific) | 14 | (controller specific) |
15 | 15 | ||
16 | GPIO properties should be named "[<name>-]gpios". The exact | 16 | GPIO properties should be named "[<name>-]gpios", with <name> being the purpose |
17 | meaning of each gpios property must be documented in the device tree | 17 | of this GPIO for the device. While a non-existent <name> is considered valid |
18 | binding for each device. | 18 | for compatibility reasons (resolving to the "gpios" property), it is not allowed |
19 | for new bindings. | ||
19 | 20 | ||
20 | For example, the following could be used to describe GPIO pins used | 21 | GPIO properties can contain one or more GPIO phandles, but only in exceptional |
21 | as chip select lines; with chip selects 0, 1 and 3 populated, and chip | 22 | cases should they contain more than one. If your device uses several GPIOs with |
22 | select 2 left empty: | 23 | distinct functions, reference each of them under its own property, giving it a |
24 | meaningful name. The only case where an array of GPIOs is accepted is when | ||
25 | several GPIOs serve the same function (e.g. a parallel data line). | ||
26 | |||
27 | The exact purpose of each gpios property must be documented in the device tree | ||
28 | binding of the device. | ||
29 | |||
30 | The following example could be used to describe GPIO pins used as device enable | ||
31 | and bit-banged data signals: | ||
23 | 32 | ||
24 | gpio1: gpio1 { | 33 | gpio1: gpio1 { |
25 | gpio-controller | 34 | gpio-controller |
@@ -30,10 +39,12 @@ select 2 left empty: | |||
30 | #gpio-cells = <1>; | 39 | #gpio-cells = <1>; |
31 | }; | 40 | }; |
32 | [...] | 41 | [...] |
33 | chipsel-gpios = <&gpio1 12 0>, | 42 | |
34 | <&gpio1 13 0>, | 43 | enable-gpios = <&gpio2 2>; |
35 | <0>, /* holes are permitted, means no GPIO 2 */ | 44 | data-gpios = <&gpio1 12 0>, |
36 | <&gpio2 2>; | 45 | <&gpio1 13 0>, |
46 | <&gpio1 14 0>, | ||
47 | <&gpio1 15 0>; | ||
37 | 48 | ||
38 | Note that gpio-specifier length is controller dependent. In the | 49 | Note that gpio-specifier length is controller dependent. In the |
39 | above example, &gpio1 uses 2 cells to specify a gpio, while &gpio2 | 50 | above example, &gpio1 uses 2 cells to specify a gpio, while &gpio2 |
@@ -42,16 +53,17 @@ only uses one. | |||
42 | gpio-specifier may encode: bank, pin position inside the bank, | 53 | gpio-specifier may encode: bank, pin position inside the bank, |
43 | whether pin is open-drain and whether pin is logically inverted. | 54 | whether pin is open-drain and whether pin is logically inverted. |
44 | Exact meaning of each specifier cell is controller specific, and must | 55 | Exact meaning of each specifier cell is controller specific, and must |
45 | be documented in the device tree binding for the device. | 56 | be documented in the device tree binding for the device. Use the macros |
57 | defined in include/dt-bindings/gpio/gpio.h whenever possible: | ||
46 | 58 | ||
47 | Example of a node using GPIOs: | 59 | Example of a node using GPIOs: |
48 | 60 | ||
49 | node { | 61 | node { |
50 | gpios = <&qe_pio_e 18 0>; | 62 | enable-gpios = <&qe_pio_e 18 GPIO_ACTIVE_HIGH>; |
51 | }; | 63 | }; |
52 | 64 | ||
53 | In this example gpio-specifier is "18 0" and encodes GPIO pin number, | 65 | GPIO_ACTIVE_HIGH is 0, so in this example gpio-specifier is "18 0" and encodes |
54 | and GPIO flags as accepted by the "qe_pio_e" gpio-controller. | 66 | GPIO pin number, and GPIO flags as accepted by the "qe_pio_e" gpio-controller. |
55 | 67 | ||
56 | 1.1) GPIO specifier best practices | 68 | 1.1) GPIO specifier best practices |
57 | ---------------------------------- | 69 | ---------------------------------- |