Gpio_button_hotplug feature supported on kmod-gpio-pca953x?

Hi All,

I'm working on camera device, kernel version is 4.9.
We use pca953x extender to support more GPIOs, like button.
We enable pca953x and gpio_button_hotplug driver with following part of DTS.

+     gpio-keys {
+         compatible = "gpio-keys";
+         #address-cells = <1>;
+         #size-cells = <0>;
+         button-reset {
+             linux,code = <171>;
+             label = "config";
+             gpios = <&pinctrl 513 GPIO_ACTIVE_LOW>;
+             debounce-interval= <20>;
+         };
+     };

I already checked the /sys/class/gpio/gpio513/value is working.
Set up configs, like

# cat /etc/config/system 

config system
        option timezone 'UTC'
        option ttylogin '0'
        option log_size '64'
        option urandom_seed '0'
        option hostname 'vx3-583c'

config timeserver 'ntp'
        option enabled '1'
        option enable_server '0'
        list server '0.openwrt.pool.ntp.org'
        list server '1.openwrt.pool.ntp.org'
        list server '2.openwrt.pool.ntp.org'
        list server '3.openwrt.pool.ntp.org'

config button
        option button 'config'
        option action 'pressed'
        option handler 'logger config pressed; button.sh button config pressed;'

config button
        option button 'config'
        option action 'released'
        option handler 'logger config released; button.sh button config released;'

# cat /etc/hotplug.d/button/00-button 
#!/bin/sh
. /lib/functions.sh

do_button () {
    local button
    local action
    local handler
    local min
    local max

    config_get button "${1}" button
    config_get action "${1}" action
    config_get handler "${1}" handler
    config_get min "${1}" min
    config_get max "${1}" max

    [ "${ACTION}" = "${action}" -a "${BUTTON}" = "${button}" -a -n "${handler}" ] && {
        [ -z "${min}" -o -z "${max}" ] && eval ${handler}
        [ -n "${min}" -a -n "${max}" ] && {
            [ "${min}" -le "${SEEN}" -a "${max}" -ge "${SEEN}" ] && eval ${handler}
        }
    }
}

config_load system
config_foreach do_button button

Before using pca953x extender, we use normal GPIO from CPU, this feature is working.
Switch GPIO to extender, this feature is not working now.

Any suggestion to me about how to fix this problem? Thanks.

How is anything kernel 4.9 related to OpenWrt?

1 Like

Basically, we select external kernel to build. To support uevent, we have a patch for kobject_uevent.c.
Before using GPIO extender, hotplug looks working well.

You are not getting the point, how is whatever custom kernel you are using an OpenWrt issue?

@robimarko I still don't understand what you mean. Could you please explain more? Thanks.

Issues with kernel v4.9 and any external kernel tree are yours and only yours to fix, OpenWrt is not involved in this.

Shoudn't this be a reference to pca953x node instead of pinctrl node? &pinctrl is a pinmux controller for the pins on SoC, not a GPIO controller and not for external pins.

Understand. Thanks.

@musashino

In our DTS, the pinctrl is GPIO controller.

        pinctrl: pinctrl@xxxxxxx {
            #address-cells = <1>;
            #size-cells = <1>;
            ranges;
            compatible = "realtek,xxxx-pinctrl";
            reg = <xxxxx>;
            interrupts = <BSP_IRQ_OTHERS>;
            interrupt-parent = <&cpuintc>;
            pwm-etnled-mapping = /bits/ 32 <0 1 2 0>;
            gpio-controller;
            #gpio-cells = <2>;
            gpio-numbers = <NUM_GPIOS>;
            status = "enable";