Unable to activate rotary encoder on gpio

Hi, I’m the Toradex AI Assistant. The Toradex Support team will follow up with you shortly!

Did you like my answer?

:+1: :-1:


Based on the information provided, it seems like you’ve taken the correct steps to enable the rotary encoder driver and apply the device tree overlay. However, the driver is not being loaded, and the device is not appearing in /dev. Here are a few steps to troubleshoot and resolve the issue:

  1. Verify Device Tree Overlay:
    Ensure that your device tree overlay is correctly written and applied. Here is an example of what a typical rotary encoder device tree overlay might look like:

    /dts-v1/;
    /plugin/;
    
    / {
        compatible = "toradex,colibri-imx7-emmc";
    };
    
    &ecspi1 {
        status = "okay";
    };
    
    &gpio1 {
        rotary_encoder {
            compatible = "rotary-encoder";
            gpios = <&gpio1 2 GPIO_ACTIVE_HIGH>, <&gpio1 3 GPIO_ACTIVE_HIGH>;
            linux,axis = <0>;
        };
    };
    

    Make sure the GPIO pins (SODIMM_100 and SODIMM_102) are correctly mapped in the device tree.

  2. Check Kernel Logs:
    Check the kernel logs for any errors or messages related to the rotary encoder driver. You can use the dmesg command to view the kernel logs:

    dmesg | grep rotary
    

    This might give you some clues if there are any issues with loading the driver.

  3. Verify GPIO Configuration:
    Ensure that the GPIO pins you are using for the rotary encoder are not being used by any other peripheral or function. You can check the pin configuration using the pinmux settings in the device tree.

  4. Manually Load the Driver:
    Try manually loading the rotary encoder driver using the modprobe command:

    modprobe rotary_encoder
    

    After running this command, check if the driver is loaded using lsmod and if the device appears in /dev.

  5. Check for Missing Dependencies:
    Ensure that all necessary dependencies for the rotary encoder driver are included in your kernel configuration. Sometimes, additional modules or configurations might be required.

  6. Rebuild and Reapply the Overlay:
    If you made any changes to the device tree overlay, make sure to recompile and reapply it:

    dtc -I dts -O dtb -o colibri-imx7_rotary_encoder_overlay.dtbo colibri-imx7_rotary_encoder_overlay.dts
    cp colibri-imx7_rotary_encoder_overlay.dtbo /boot/overlays/
    

    Then reboot the system to apply the changes.

If you have followed all these steps and the issue persists, there might be a deeper issue with the driver or the device tree configuration. In such cases, it might be helpful to consult the Toradex community or support for further assistance.

Please, also check if these links can help you solve your problem:

Rotary encoder for imx7?.