I have an Orange Pi Zero 2 board and I'm trying to add some joystick through GPIO.
I have found an example Device Tree overlay and modified it to my needs (see below attached version). It is also loaded and applied at startup, but yielts an error and no node is found under /dev/input/. Instead it results in the following error message posted to DMESG:
[ 1.533942] sun50i-h616-pinctrl 300b000.pinctrl: pin PC8 already requested by gpio-keys-user; cannot claim for 300b000.pinctrl:72
[ 1.533967] gpio-keys gpio-keys-user: failed to get gpio: -22
[ 1.533975] gpio-keys: probe of gpio-keys-user failed with error -22
It seems as if pinctrl and gpio-keys block each other.
If I remove the pinctrl section, adding the input device works fine, but it doesn' detect useful events, because it seems as if the GPIO pin has not been setup (i.e. pull-up is not configured).
Does anybody have an idea what I'm doing wrong?
Here's my dts file:
/dts-v1/;
/plugin/;
/ {
compatible = "allwinner,sun50i-h616";
fragment@0 {
target = <&pio>;
__overlay__ {
custom-buttons: custom-buttons {
pins = "PC5","PC6","PC8";
function = "gpio_in";
bias-pull-up;
};
};
};
fragment@1 {
target-path = "/";
__overlay__ {
gpio-keys-user {
compatible = "gpio-keys";
pinctrl-names = "default";
pinctrl-0 = <&custom-buttons>;
play_button {
label = "GPIO Key 1";
linux,code = <25>;
gpios = <&pio 0 69 1>;
};
vol_up_button {
label = "GPIO Key 2";
linux,code = <22>;
gpios = <&pio 0 70 1>;
};
vol_down_button {
label = "GPIO Key 3";
linux,code = <32>;
gpios = <&pio 0 72 1>;
};
};
};
};
};