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

34 views
Skip to first unread message

dme...@gmail.com

unread,
Nov 19, 2018, 1:18:51 PM11/19/18
to BeagleBoard
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
###
###Overide capes with eeprom
#uboot_overlay_addr0=/lib/firmware/BBB-StarBoard-00A2.dtbo
#uboot_overlay_addr1=/lib/firmware/<file1>.dtbo
#uboot_overlay_addr2=/lib/firmware/<file2>.dtbo
#uboot_overlay_addr3=/lib/firmware/<file3>.dtbo
###
###Additional custom capes
#uboot_overlay_addr4=/lib/firmware/<file4>.dtbo
#uboot_overlay_addr5=/lib/firmware/<file5>.dtbo
#uboot_overlay_addr6=/lib/firmware/<file6>.dtbo
#uboot_overlay_addr7=/lib/firmware/<file7>.dtbo
###
###Custom Cape
dtb_overlay=/lib/firmware/BBB-GpioLed-00A0.dtbo
###
###Disable auto loading of virtual capes (emmc/video/wireless/adc)
disable_uboot_overlay_emmc=1
disable_uboot_overlay_video=1
#disable_uboot_overlay_audio=1
#disable_uboot_overlay_wireless=1
#disable_uboot_overlay_adc=1
###
###PRUSS OPTIONS
###pru_rproc (4.4.x-ti kernel)
#uboot_overlay_pru=/lib/firmware/AM335X-PRU-RPROC-4-4-TI-00A0.dtbo
###pru_rproc (4.14.x-ti kernel)
#uboot_overlay_pru=/lib/firmware/AM335X-PRU-RPROC-4-14-TI-00A0.dtbo
###pru_uio (4.4.x-ti, 4.14.x-ti & mainline/bone kernel)
#uboot_overlay_pru=/lib/firmware/AM335X-PRU-UIO-00A0.dtbo
###
###Cape Universal Enable
enable_uboot_cape_universal=1
###
###Debug: disable uboot autoload of Cape
#disable_uboot_overlay_addr0=1
#disable_uboot_overlay_addr1=1
#disable_uboot_overlay_addr2=1
#disable_uboot_overlay_addr3=1
###
###U-Boot fdt tweaks... (60000 = 384KB)
#uboot_fdt_buffer=0x60000
###U-Boot Overlays###

cmdline=coherent_pool=1M net.ifnames=0 quiet

#In the event of edid real failures, uncomment this next line:
#cmdline=coherent_pool=1M net.ifnames=0 quiet video=HDMI-A-1:1024x768@60e

#Use an overlayfs on top of a read-only root filesystem:
#cmdline=coherent_pool=1M net.ifnames=0 quiet overlayroot=tmpfs

##enable Generic eMMC Flasher:
##make sure, these tools are installed: dosfstools rsync
#cmdline=init=/opt/scripts/tools/eMMC/init-eMMC-flasher-v3.sh


I have tried a variety of things that did not work:

- switching to any of the following kernels: 4.14.79-ti-r84, 4.19.0-ti-r2, 4.14.71-bone17, 4.9.126-ti-r115
- loading or not loading the universal cape, either through uEnv.txt or the DTS file (fragment2)
- instead of using custom pinmux fragment, use the pre-built pinctrl refs, e.g. &P8_45_gpio_pin

I see many capes that use these drivers, and I've based a lot of my work off this recent post (https://beagleboard.org/blog/2018-01-17-building-a-device-tree-overlay-for-your-new-pocketcape-design), so I would imagine these drivers work, but I'm making some stupid error. Can anyone help me find it?

thanks,
Dan

Robert Nelson

unread,
Nov 19, 2018, 1:24:28 PM11/19/18
to Beagle Board, dme...@gmail.com
On Mon, Nov 19, 2018 at 12:18 PM <dme...@gmail.com> wrote:
>
> 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,

--
Robert Nelson
https://rcn-ee.com/

dme...@gmail.com

unread,
Nov 27, 2018, 12:28:31 PM11/27/18
to BeagleBoard
Thank you, this fixes the problem. Both drivers work perfectly when connected to the right gpios!
Reply all
Reply to author
Forward
0 new messages