AnsweredAssumed Answered

UIO to handle GPIO interrupts?

Question asked by Scott Whitney on Jul 7, 2020
Latest reply on Jul 8, 2020 by Scott Whitney

I am hoping that you can provide advice on using UIO to handle an interrupt from user space.  I found an excellent summary at https://yurovsky.github.io/2014/10/10/linux-uio-gpio-interrupt.html and have tried to follow it as well as I can, being a newcomer to Yocto and embedded Linux.

 

We are using a Variscite DART-MX8M-MINI development kit.  I have enabled spidev, which I am using to communicate with an ADS1299 EEG analog front end from TI.  It generates a “data ready” interrupt DRDY# (active low).  I’d like to be able to handle this falling-edge interrupt by connecting it to a GPIO (GPIO1_0) and either read() or poll() to wait for an interrupt, and can then read the acquired data using /dev/spidev0.0.

 

In my device tree, I have added the following under my &ecspi1 node.  I am not certain this is the correct place to add this information, or if I can simply add it within the device tree “root” node “/ {“.  I would appreciate your advice on the best place add this information.

       // Added for DRDY# interrupt on GPIO1_0 from user space

       user_io@0 {

              compatible = "mydevice,generic-uio,ui_pdrv";

              status = "okay";

              interrupt-parent = <&gpio1>;

              interrupts = <0 IRQ_TYPE_EDGE_FALLING>;

              pinctrl-names = "default";

              pinctrl-0 = <&pinctrl_user_io>;

       };

 

Under my dts &iomuxc node, the various pinctrl groups are defined.  I added the following for GPIO1_0:

 

              // Added for DRDY# interrupt on GPIO1_0 from user space

              pinctrl_user_io: user_io-0 {

                     fsl,pins = <

                           MX8MM_IOMUXC_GPIO1_IO00_GPIO1_IO0           0x1c0

                     >;

              };

 

This _should_ configure the pin to enable a pull-up.  Can you confirm this?

 

I have modified my kernel .config file via menuconfig, and it contains the following entries:

CONFIG_UIO=y

CONFIG_UIO_PDRV_GENIRQ=m

 

The “y” setting for CONFIG_UIO was evidently due to other dependencies in the provided configuration.

However, when I boot the board up, I cannot see /dev/uio0 or run the modprobe command as specified in the description at the link provided:

 

root@imx8mm-var-dart:~# ls /dev/u*

/dev/ubi_ctrl  /dev/udev_network_queue  /dev/uhid  /dev/uinput  /dev/urandom

root@imx8mm-var-dart:~# modprobe uio_pdrv_genirq of_id="mydevice,generic-uio,ui_pdrv"

modprobe: FATAL: Module uio_pdrv_genirq not found in directory /lib/modules/4.19.35-imx8mm+ge6d3e3fefe4e

 

I used grep to look for “uio” in the /lib/modules directory, and only found the following:

 

root@imx8mm-var-dart:/lib/modules/4.19.35-imx8mm+ge6d3e3fefe4e# grep -RnI uio .

./modules.builtin:270:kernel/drivers/uio/uio.ko

 

I am stumped, and think I must have something wrong in my .dts file, my .config file, or in the packages/libraries added to the Yocto image.  Do you have any suggestions for how to diagnose/fix this problem. My .dts file and .config file is attached.

 

Thanks for your help.  UIO apparently is a "preferred" way to handle writing simple device drivers from user space.  Do I need to add something to Yocto to enable UIO and UIO_PDRV_GENIRQ?

 

Best regards,

 

Scott

Outcomes