Thread (5 messages) 5 messages, 2 authors, 2017-01-24

Help on modelling gpio interrupt source when interrupt is shared

From: Rajasekhar Pulluru <hidden>
Date: 2017-01-24 18:35:45

I don't want to re-invent the wheel by introducing a new kernel driver for
which kernel already provides an infrastructure (UIO). I already mentioned
that I can't modify linux kernel sources (for various reasons, one of them
is migrating the new kernel driver from one version to another and
verifying the functionality is an added task).

I figured out the problem why irq is not binding to uio driver. When the
gpio controller (that is also an interrupt controller) is registered with
gpio framework, the gpio controller driver needs to
invoke gpiochip_irqchip_add in order for the (interrupt) clients(in this
case uio) to request for the interrupt resource successfully.
This call was missing in the gpio controller driver. Invoking that API with
appropriate parameters solved the problem.

Thanks & Regards,
Rajasekhar

On Tue, Jan 24, 2017 at 10:47 PM, Anish Kumar [off-list ref]
wrote:

On Jan 23, 2017, at 10:56 PM, Rajasekhar Pulluru <
pullururajasekhar at gmail.com> wrote:

Hi Anish,

My intention is just to detect interrupt in the user space and read the
device id without using udev.

I don't want to create a new driver in kernel (assume I can't modify linux
kernel sources), which is the first reason to go for uio generic platform
driver.

If I register a gpio interrupt (level triggered) using a kernel module, I
can get the interrupt detected


Which means you are able to do insmod, so you can very well write a kernel
module and send some event to user space.

when device is inserted/removed. But I would like to detect device
presence completely from user space without modifying linux kernel.

Thanks & Regards,
Rajasekhar

On Tue, Jan 24, 2017 at 11:56 AM, anish singh <anish198519851985@gmail.com
quoted
wrote:
quoted

On Mon, Jan 23, 2017 at 7:46 AM, Rajasekhar Pulluru <
pullururajasekhar at gmail.com> wrote:
quoted
Hi,

I have a query on device tree pertaining to modelling a gpio pin as an
interrupt source.
I have searched mailing list archives and kernel documentation before
posting this and couldn't get any direct solution.
(My understanding is limited and hence posting the query below:)

My SOC has a gpio controller and uart both sharing same interrupt line
as specified below.

interrupt-parent = <&gic>;

        mygpio: gpio at 0x19008000 {
                compatible = "mysoc,mygpio-controller,gc";
                #address-cells = <1>;
                #size-cells = <1>;
                #gpio-cells = <2>;
                reg = gpio: <0x19008000 0x50>;
                ngpios = <12>;
                pin-offset = <4>;
                pin-base = <4>;
                irq-base = <256>; /* sw irq base for irq handlers */
                gpio-controller;
                interrupt-controller;
                interrupts = <GIC_SPI 91 IRQ_TYPE_LEVEL_HIGH>;
        };

        uart0: serial at 0x19000300 {
                compatible = "snps,dw-apb-uart";
                reg = <0x19000300 0x100>;
                interrupts = <GIC_SPI 91 IRQ_TYPE_LEVEL_HIGH>;
                clock-frequency = <62500000>;
        };

gpio pin 0 of mygpio is used as an interrupt source for detecting the
presence of external pluggable device (that is not driven by kernel).
And I intend to detect the presence of the pluggable device from user
space by means of generic uio platform driver using below device
What do you intend to achieve by detecting device in userspace?
You can directly get notification using udev notification.

However, you need to send udev notification from a kernel driver.

quoted
tree configuration. (following https://yurovsky.github.io/201
4/10/10/linux-uio-gpio-interrupt/)

        user_io at 0 {
            compatible = "mydevice,generic-uio,ui_pdrv";
            status = "okay";
            interrupt-parent = <&mygpio>;
            interrupts = <0 IRQ_TYPE_LEVEL_HIGH>;
        };

Running modprobe uio_pdrv_genirq of_id="mydevice,generic-uio,ui_pdrv"
and creating /dev/uio0 using mknod (major number from cat /proc/devices |
grep uio),
I couldn't see an irq entry bind to uio driver under /proc/interrupts.
Am I doing anything wrong here?

Other method I have tried to get notified of the gpio pin0 interrupt in
user space is to poll on /sys/class/gpio/gpio0/value. But merely exporting
gpio0
wasn't sufficient as kernel should make a call to request_irq on the
gpio0 interrupt line. Is there a generic driver framework (like pinctrl)
that can export
a device node to register the gpio pin0 as an interrupt source that
allows me to poll on its sysfs entry?
All sysfs nodes can be polled as it is supported in kernel.
You can simply create a dummy driver and register the
irq and in your irq handler send udev notifications using
kobj.

Or
just update a sysfs node which can be polled from userspace.

If this answer is not sufficient then please explain in detail
what you are planning to achieve rather than what you are
doing to achieve that.
quoted
Thanks,
Rajasekhar

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies at kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20170125/b95b0a49/attachment-0001.html 
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help