gpio-keys and gpio-leds not working in linux 4 kernels?

I have been trying to upgrade a number of beaglebone blacks to Debian 9.5. I have been working off the 10-28-2018 IoT image.

I have a custom-built cape that my lab uses to track animal behavior experiments. The BBBs are currently running Debian 7 with the Linux 3.8 kernel. The cape makes heavy use of the gpio-keys and gpio-leds drivers, and I wrote a custom device tree overlay to map various pins accordingly. The gpio-keys driver is particularly important as it allows our node-based software to respond to behavioral events. The gpio-leds driver is less important, but I do find the oneshot trigger convenient for some things.

So far, I have been unable to get either of these drivers to work in the new kernel. If I leave the pins configured as GPIOs I can flip the output and read inputs just fine. Here is a DTS that recreates the problem:

/dts-v1/;
/plugin/;

#include <dt-bindings/gpio/gpio.h>
#include <dt-bindings/pinctrl/am33xx.h>
#include <dt-bindings/interrupt-controller/irq.h>

/ {
compatible = “ti,beaglebone-black”;

/* identification */
part-number = “BBB-GpioLed”;
version = “00A0”;

exclusive-use =
“P8.18”, “gpio2_1”,
“P8.16”, “gpio1_14”;

fragment@0 {
target = <&ocp>;
overlay {
P8_18_pinmux { status = “disabled”; }; /* gpio2_6 */
P8_16_pinmux { status = “disabled”; };
};
};

/*

  • Free up the gpios used by the cape-universal gpio helpers.
    */
    fragment@1 {
    target = <&ocp>;
    overlay {
    cape-universal { status = “disabled”; };
    };
    };

/* sets pin mux /
fragment@2 {
target = <&am33xx_pinmux>;
overlay {
led_gpio: pinmux_led_gpio_pins {
pinctrl-single,pins = <
0x08c 0x07 /
P8.18 - left red / >;
};
hopdet_gpio: pinmux_hopdet_gpio_pins {
pinctrl-single,pins = <
0x038 0x37 /
P8.16 - hopper up */

;
};
};
};
fragment@3 {
target-path = “/”;
overlay {
sbd-cues {
compatible = “gpio-leds”;
pinctrl-names = “default”;
pinctrl-0 = <&led_gpio>;
sbd-cue-lrd {
label = “gpioled:red”;
gpios = <&gpio3 1 0>; /* P8.18 /
//gpios = <&gpio3 6 GPIO_ACTIVE_HIGH>; /
P8.45 /
default-state = “on”;
};
};
sbd-hopdet {
compatible = “gpio-keys”;
pinctrl-names = “default”;
pinctrl-0 = <&hopdet_gpio>;
hopper-up {
label = “starboard::hopper-up”;
debounce_interval = <100>;
linux,code = <1>;
gpios = <&gpio2 14 GPIO_ACTIVE_LOW>; /
P8.16 */
gpio-key,wakeup;
};
};
};
};
};

I compile this by dropping it in the bb.org-overlays project and running make. As you can see from the uEnv.txt below, the HDMI, eMMC, and PRU capes are not being loaded.

#Docs: http://elinux.org/Beagleboard:U-boot_partitioning_layout_2.0

uname_r=4.14.79-ti-r84
#uuid=
#dtb=

###U-Boot Overlays###
###Documentation: http://elinux.org/Beagleboard:BeagleBoneBlack_Debian#U-Boot_Overlays
###Master Enable
enable_uboot_overlays=1

I have been trying to upgrade a number of beaglebone blacks to Debian 9.5. I have been working off the 10-28-2018 IoT image.

I have a custom-built cape that my lab uses to track animal behavior experiments. The BBBs are currently running Debian 7 with the Linux 3.8 kernel. The cape makes heavy use of the gpio-keys and gpio-leds drivers, and I wrote a custom device tree overlay to map various pins accordingly. The gpio-keys driver is particularly important as it allows our node-based software to respond to behavioral events. The gpio-leds driver is less important, but I do find the oneshot trigger convenient for some things.

So far, I have been unable to get either of these drivers to work in the new kernel. If I leave the pins configured as GPIOs I can flip the output and read inputs just fine. Here is a DTS that recreates the problem:

Well the gpio# changed after 3.8.13 (around 3.13.x)... use this
values.. (3.8.13_gpio(x) = 3.11+_gpio(x-1))

        exclusive-use =
                "P8.18", "gpio2_1",
                "P8.16", "gpio1_14";

                           sbd-cue-lrd {
                                   label = "gpioled:red";
                                   //gpios = <&gpio3 1 0>; /* P8.18 */

                                    gpios = <&gpio2 1 0>; /* P8.18 */

                                   //gpios = <&gpio3 6 GPIO_ACTIVE_HIGH>; /* P8.45 */
                                   default-state = "on";

                           hopper-up {
                                   label = "starboard::hopper-up";
                                   debounce_interval = <100>;
                                   linux,code = <1>;
                                   //gpios = <&gpio2 14 GPIO_ACTIVE_LOW>; /* P8.16 */

                                    gpios = <&gpio1 14
GPIO_ACTIVE_LOW>; /* P8.16 */

                                   gpio-key,wakeup;

Regards,

Thank you, this fixes the problem. Both drivers work perfectly when connected to the right gpios!