What I want to do:
Create a rotary encoder device in Linux with Yocto Project and device tree (/dev/rotary-encoder). The device should be visible after boot, so that it can be used in user space.
My Hardware:
i.MX8M Mini Evaluation Board (imx8mm evk)
Rotary encoder using two GPIOs
What I tried:
I changed the dts file and added code for the rotary encoder (tmp/work-shared/imx8mmevk/kernel-source/arch/arm64/boot/dts/freescale/fsl-imx8mm-evk.dts):
/ {
...
rotary-encoder {
compatible = "rotary-encoder";
status = "okay";
gpios = <&pca6416 14 GPIO_ACTIVE_HIGH>, <&pca6416 13 GPIO_ACTIVE_HIGH>;
linux,axis = <0>;
rotary-encoder,encoding = "gray";
rotary-encoder,relative-axis;
};
};
What is the right way and do I maybe need some device driver in addition to the device tree file? I thought Linux would have one for rotary encoders. The problem is that my knowledge about device trees is limited. I tried to find a solution via google, but couldn't. Maybe someone can help how to integrate this with the evaluation board.