I'm trying to add a rotary encoder to the IMX7ULP evk platform. But it does not seem to probe well. Is there something i've missed in the devicetree configuration?
[ 1.825046] rotary-encoder rotary@0: gray
[ 1.829150] rotary-encoder rotary@0: unable to get gpios: -22
[ 1.834987] rotary-encoder: probe of rotary@0 failed with error -22
The Rotary is connected by A channel to D8 and B channel to D9
rotary@0 {
compatible = "rotary-encoder";
gpios = <&gpio_ptf 10 GPIO_ACTIVE_LOW>, <&gpio_ptf 11 GPIO_ACTIVE_LOW>; // D8 = PTF10 | D9 = PTF11
linux,axis = <0>; /* REL_X */
rotary-encoder,encoding = "gray";
rotary-encoder,relative-axis;
status = "okay";
};
已解决! 转到解答。
Hi,
I haven't done anything with rotary encoders and Linux but by the looks of it the kernel has matched the device tree configuration with the correct driver and issued a probe. The problem looks like it's failing to get the gpio's probably being part of the driver's probe function. Normally with the imx7 you will have to reserve the pins within the iomuxc { } in the device tree then the driver can pick them up via gpio defs. Have a scroll through the iomux pinctrl code in the device tree, check out other people dts using the encoder and you might crack your problem.
Check out this link and notice the iomuxc bit
http://www.armadeus.org/wiki/index.php?title=Rotary_encoder_with_GPIOs
EDIT: in case the link disappears, it's imx6 but close enough to get the idea.
gpio-keys {
compatible = "gpio-keys";
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_gpio_keys>;
user-button {
label = "User button";
gpios = <&gpio2 11 GPIO_ACTIVE_LOW>;
linux,code = <BTN_MISC>;
wakeup-source;
};
+ rotary1_button {
+ label = "rotary1_button";
+ gpios = <&gpio5 2 GPIO_ACTIVE_LOW>;
+ debounce-interval = <10>;
+ linux,code = <28>;
+ };
}
+ rotary1 {
+ compatible = "rotary-encoder";
+ pinctrl-names = "default";
+ pinctrl-0 = <&pinctrl_rotary1>;
+ gpios = <&gpio5 0 1>, <&gpio5 1 1>;
+ linux,axis = <1>; /* REL_Y */
+ rotary-encoder,relative-axis;
+ };
...
&iomuxc {
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_gpios>;
...
+ pinctrl_rotary1: rotary1grp {
+ fsl,pins = <
+ MX6UL_PAD_SNVS_TAMPER0__GPIO5_IO00 0x0b0b0
+ MX6UL_PAD_SNVS_TAMPER1__GPIO5_IO01 0x0b0b0
+ >;
+ };
Hi,
I haven't done anything with rotary encoders and Linux but by the looks of it the kernel has matched the device tree configuration with the correct driver and issued a probe. The problem looks like it's failing to get the gpio's probably being part of the driver's probe function. Normally with the imx7 you will have to reserve the pins within the iomuxc { } in the device tree then the driver can pick them up via gpio defs. Have a scroll through the iomux pinctrl code in the device tree, check out other people dts using the encoder and you might crack your problem.
Check out this link and notice the iomuxc bit
http://www.armadeus.org/wiki/index.php?title=Rotary_encoder_with_GPIOs
EDIT: in case the link disappears, it's imx6 but close enough to get the idea.
gpio-keys {
compatible = "gpio-keys";
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_gpio_keys>;
user-button {
label = "User button";
gpios = <&gpio2 11 GPIO_ACTIVE_LOW>;
linux,code = <BTN_MISC>;
wakeup-source;
};
+ rotary1_button {
+ label = "rotary1_button";
+ gpios = <&gpio5 2 GPIO_ACTIVE_LOW>;
+ debounce-interval = <10>;
+ linux,code = <28>;
+ };
}
+ rotary1 {
+ compatible = "rotary-encoder";
+ pinctrl-names = "default";
+ pinctrl-0 = <&pinctrl_rotary1>;
+ gpios = <&gpio5 0 1>, <&gpio5 1 1>;
+ linux,axis = <1>; /* REL_Y */
+ rotary-encoder,relative-axis;
+ };
...
&iomuxc {
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_gpios>;
...
+ pinctrl_rotary1: rotary1grp {
+ fsl,pins = <
+ MX6UL_PAD_SNVS_TAMPER0__GPIO5_IO00 0x0b0b0
+ MX6UL_PAD_SNVS_TAMPER1__GPIO5_IO01 0x0b0b0
+ >;
+ };
Here is a good summary.
https://www.variscite.com/blog/i-mx-device-tree-pinmux-settings/
This link refers to the i.MX8QXP Reference Manual Rev. 0, 05/2020, page 957. There's an equivalent reference manual for the imx7.