SHOW:
|
|
- or go back to the newest paste.
| 1 | /dts-v1/; | |
| 2 | /plugin/; | |
| 3 | ||
| 4 | #include <dt-bindings/board/am335x-bbw-bbb-base.h> | |
| 5 | #include <dt-bindings/pinctrl/am33xx.h> | |
| 6 | #include <dt-bindings/gpio/gpio.h> | |
| 7 | ||
| 8 | - | // file identification |
| 8 | + | / {
|
| 9 | - | &{/chosen} {
|
| 9 | + | // file identification |
| 10 | - | overlays {
|
| 10 | + | fragment@0 {
|
| 11 | - | // XXX change property name to the name of this overlay (excluding .dts file suffix) |
| 11 | + | target-path = "/chosen"; |
| 12 | - | gpio-demo = __TIMESTAMP__; |
| 12 | + | __overlay__ {
|
| 13 | overlays {
| |
| 14 | - | }; |
| 14 | + | // XXX change property name to the name of this overlay (excluding .dts file suffix) |
| 15 | gpio-demo = __TIMESTAMP__; | |
| 16 | - | // XXX caution: not compatible with cape-universal! |
| 16 | + | }; |
| 17 | }; | |
| 18 | - | // A udev rule along these lines is recommended to create symlinks in /dev/gpio/ |
| 18 | + | |
| 19 | - | // |
| 19 | + | |
| 20 | - | // SUBSYSTEM=="subsystem", KERNEL=="gpio", ACTION=="add", \ |
| 20 | + | // XXX caution: not compatible with cape-universal! |
| 21 | - | // RUN+="/bin/mkdir -p /dev/gpio" |
| 21 | + | |
| 22 | - | // |
| 22 | + | // A udev rule along these lines is recommended to create symlinks in /dev/gpio/ |
| 23 | - | // SUBSYSTEM=="gpio", ACTION=="add", TEST=="value", ATTR{label}!="sysfs", \
|
| 23 | + | // |
| 24 | - | // RUN+="/bin/ln -sT '/sys/class/gpio/%k' /dev/gpio/%s{label}"
|
| 24 | + | // SUBSYSTEM=="subsystem", KERNEL=="gpio", ACTION=="add", \ |
| 25 | // RUN+="/bin/mkdir -p /dev/gpio" | |
| 26 | - | &{/} {
|
| 26 | + | // |
| 27 | - | // If you want to use multiple overlays that do gpio configuration, be |
| 27 | + | // SUBSYSTEM=="gpio", ACTION=="add", TEST=="value", ATTR{label}!="sysfs", \
|
| 28 | - | // sure that each uses a different device tree node! |
| 28 | + | // RUN+="/bin/ln -sT '/sys/class/gpio/%k' /dev/gpio/%s{label}"
|
| 29 | - | gpio-demo {
|
| 29 | + | |
| 30 | - | compatible = "gpio-of-helper"; |
| 30 | + | fragment@1 {
|
| 31 | target-path = "/"; | |
| 32 | - | // It is usually not *strictly* required to perform pinmux for |
| 32 | + | __overlay__ {
|
| 33 | - | // GPIOs since this is typically their default, but it's good |
| 33 | + | // If you want to use multiple overlays that do gpio configuration, be |
| 34 | - | // practice to do it anyway since: |
| 34 | + | // sure that each uses a different device tree node! |
| 35 | - | // 1. it makes *sure* the pinmux is right |
| 35 | + | gpio-demo {
|
| 36 | - | // 2. you can configure internal pull-up/down |
| 36 | + | compatible = "gpio-of-helper"; |
| 37 | - | // 3. it lets the kernel know the pins are in use |
| 37 | + | |
| 38 | - | pinctrl-names = "default"; |
| 38 | + | // It is usually not *strictly* required to perform pinmux for |
| 39 | - | pinctrl-0 = <&gpio_demo_pins>; |
| 39 | + | // GPIOs since this is typically their default, but it's good |
| 40 | // practice to do it anyway since: | |
| 41 | - | // Note that gpio numbers for each pin can be found in the |
| 41 | + | // 1. it makes *sure* the pinmux is right |
| 42 | - | // comments in include/bone/black.h |
| 42 | + | // 2. you can configure internal pull-up/down |
| 43 | // 3. it lets the kernel know the pins are in use | |
| 44 | - | // input only, active-low; connect button between pin and gnd. |
| 44 | + | pinctrl-names = "default"; |
| 45 | - | // declaring the gpio as ACTIVE_LOW means the value reads as 1 |
| 45 | + | pinctrl-0 = <&gpio_demo_pins>; |
| 46 | - | // when the button is pressed. |
| 46 | + | |
| 47 | - | button {
|
| 47 | + | // Note that gpio numbers for each pin can be found in the |
| 48 | - | gpio = <&gpio2 2 GPIO_ACTIVE_LOW>; // P8.07 |
| 48 | + | // comments in include/bone/black.h |
| 49 | - | input; |
| 49 | + | |
| 50 | // input only, active-low; connect button between pin and gnd. | |
| 51 | // declaring the gpio as ACTIVE_LOW means the value reads as 1 | |
| 52 | - | // output only, active-low, initially high (inactive) |
| 52 | + | // when the button is pressed. |
| 53 | - | reset-thing {
|
| 53 | + | button {
|
| 54 | - | gpio = <&gpio2 3 GPIO_ACTIVE_LOW>; // P8.08 |
| 54 | + | gpio = <&gpio2 2 GPIO_ACTIVE_LOW>; // P8.07 |
| 55 | - | init-high; |
| 55 | + | input; |
| 56 | }; | |
| 57 | ||
| 58 | - | // note: GPIO_ACTIVE_LOW inverts the meaning of the value, but it |
| 58 | + | // output only, active-low, initially high (inactive) |
| 59 | - | // does not invert the meaning of "init-low" / "init-high" ! |
| 59 | + | reset-thing {
|
| 60 | gpio = <&gpio2 3 GPIO_ACTIVE_LOW>; // P8.08 | |
| 61 | init-high; | |
| 62 | - | // bidirectional, initially input |
| 62 | + | }; |
| 63 | - | input-bidi {
|
| 63 | + | |
| 64 | - | gpio = <&gpio2 5 GPIO_ACTIVE_HIGH>; // P8.09 |
| 64 | + | // note: GPIO_ACTIVE_LOW inverts the meaning of the value, but it |
| 65 | - | input; |
| 65 | + | // does not invert the meaning of "init-low" / "init-high" ! |
| 66 | - | dir-changeable; |
| 66 | + | |
| 67 | ||
| 68 | // bidirectional, initially input | |
| 69 | - | // bidirectional, initially output, initially low (inactive) |
| 69 | + | input-bidi {
|
| 70 | - | output-bidi {
|
| 70 | + | gpio = <&gpio2 5 GPIO_ACTIVE_HIGH>; // P8.09 |
| 71 | - | gpio = <&gpio2 4 GPIO_ACTIVE_HIGH>; // P8.10 |
| 71 | + | input; |
| 72 | - | init-low; |
| 72 | + | dir-changeable; |
| 73 | - | dir-changeable; |
| 73 | + | }; |
| 74 | ||
| 75 | // bidirectional, initially output, initially low (inactive) | |
| 76 | - | }; |
| 76 | + | output-bidi {
|
| 77 | gpio = <&gpio2 4 GPIO_ACTIVE_HIGH>; // P8.10 | |
| 78 | - | &am33xx_pinmux {
|
| 78 | + | init-low; |
| 79 | - | gpio_demo_pins: gpio-demo {
|
| 79 | + | dir-changeable; |
| 80 | - | pinctrl-single,pins = < |
| 80 | + | }; |
| 81 | - | BONE_P8_07 (PIN_INPUT_PULLUP | MUX_MODE7 ) // gpio 2.02 / button |
| 81 | + | }; |
| 82 | - | BONE_P8_08 (PIN_INPUT_PULLUP | MUX_MODE7 ) // gpio 2.03 / reset-thing |
| 82 | + | |
| 83 | - | BONE_P8_09 (PIN_INPUT_PULLUP | MUX_MODE7 ) // gpio 2.05 / input-bidi |
| 83 | + | |
| 84 | - | BONE_P8_10 (PIN_INPUT_PULLUP | MUX_MODE7 ) // gpio 2.04 / output-bidi |
| 84 | + | |
| 85 | - | >; |
| 85 | + | fragment@2 {
|
| 86 | target = <&am33xx_pinmux>; | |
| 87 | __overlay__ {
| |
| 88 | gpio_demo_pins: gpio-demo {
| |
| 89 | pinctrl-single,pins = < | |
| 90 | BONE_P8_07 (PIN_INPUT_PULLUP | MUX_MODE7 ) // gpio 2.02 / button | |
| 91 | BONE_P8_08 (PIN_INPUT_PULLUP | MUX_MODE7 ) // gpio 2.03 / reset-thing | |
| 92 | BONE_P8_09 (PIN_INPUT_PULLUP | MUX_MODE7 ) // gpio 2.05 / input-bidi | |
| 93 | BONE_P8_10 (PIN_INPUT_PULLUP | MUX_MODE7 ) // gpio 2.04 / output-bidi | |
| 94 | >; | |
| 95 | }; | |
| 96 | }; | |
| 97 | }; | |
| 98 | }; |