* Configuring UIO to handle GPIO interrupt #yocto #linux
@ 2020-07-08 14:15 sdw
2020-07-08 14:22 ` [yocto] " Quentin Schulz
0 siblings, 1 reply; 2+ messages in thread
From: sdw @ 2020-07-08 14:15 UTC (permalink / raw)
To: yocto
Dear Yocto community,
I am hoping that you can provide advice on configuring UIO to handle a GPIO 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, with the i.MX8M Mini processor on a System-on-Module. 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.
I have modified my kernel .config file via 'bitbake -c menuconfig virtual/kernel', 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. I then built the SD card image using 'bitbake fsl-image-qt5', and programmed it onto my SD card.
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 above:
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? I can provide my .config file, .dts file, or any other information, but I am not sure how they should be added for access by the group.
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?
Thank you for your help, and kind regards,
Scott
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [yocto] Configuring UIO to handle GPIO interrupt #yocto #linux
2020-07-08 14:15 Configuring UIO to handle GPIO interrupt #yocto #linux sdw
@ 2020-07-08 14:22 ` Quentin Schulz
0 siblings, 0 replies; 2+ messages in thread
From: Quentin Schulz @ 2020-07-08 14:22 UTC (permalink / raw)
To: sdw; +Cc: yocto
Hi Scott,
On Wed, Jul 08, 2020 at 07:15:17AM -0700, sdw@inea.com wrote:
> Dear Yocto community,
>
> I am hoping that you can provide advice on configuring UIO to handle a GPIO 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, with the i.MX8M Mini processor on a System-on-Module. 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.
>
> I have modified my kernel .config file via 'bitbake -c menuconfig virtual/kernel', 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. I then built the SD card image using 'bitbake fsl-image-qt5', and programmed it onto my SD card.
>
Up till there, this discussion would probably fit some kernel
communities more than the Yocto one.
A few things though:
- Bear in mind that using bitbake -c menuconfig virtual/kernel, the
changes aren't permanent. If there's a clean rebuild of the kernel for
some reason, your changes will be overwritten, you need to create a
patch for it (or take a defconfig) and add it to your kernel recipe (or
fork the kernel repo and add your own defconfig),
- Modules aren't shipped by default by Yocto, so you need either to
add kernel-modules to IMAGE_INSTALL or probably smarter to have it in
your machine configuration file in MACHINE_EXTRA_RRECOMMENDS, this will
install **all** kernel modules created by yocto,
or just add kernel-module-uio-pdrv-genirq (probably, don't know the exact
name of it) the same way to only have uio,
Quentin
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-07-08 14:22 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-08 14:15 Configuring UIO to handle GPIO interrupt #yocto #linux sdw
2020-07-08 14:22 ` [yocto] " Quentin Schulz
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.