<div dir="ltr">I don&#39;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&#39;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). <div><br></div><div>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.</div><div>This call was missing in the gpio controller driver. Invoking that API with appropriate parameters solved the problem.</div><div><br></div><div>Thanks &amp; Regards,</div><div>Rajasekhar </div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Jan 24, 2017 at 10:47 PM, Anish Kumar <span dir="ltr">&lt;<a href="mailto:anish198519851985@gmail.com" target="_blank">anish198519851985@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="auto"><span class=""><div></div><div><br></div><div><br>On Jan 23, 2017, at 10:56 PM, Rajasekhar Pulluru &lt;<a href="mailto:pullururajasekhar@gmail.com" target="_blank">pullururajasekhar@gmail.com</a>&gt; wrote:<br><br></div><blockquote type="cite"><div><div dir="ltr">Hi Anish,<div><br></div><div>My intention is just to detect interrupt in the user space and read the device id without using udev.</div><div><br></div><div>I don&#39;t want to create a new driver in kernel (assume I can&#39;t modify linux kernel sources), which is the first reason to go for uio generic platform driver.</div><div><br></div><div>If I register a gpio interrupt (level triggered) using a kernel module, I can get the interrupt detected </div></div></div></blockquote><div><br></div></span>Which means you are able to do insmod, so you can very well write a kernel module and send some event to user space.<div><div class="h5"><br><blockquote type="cite"><div><div dir="ltr"><div>when device is inserted/removed. But I would like to detect device presence completely from user space without modifying linux kernel.</div><div><br></div><div>Thanks &amp; Regards,</div><div>Rajasekhar</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Jan 24, 2017 at 11:56 AM, anish singh <span dir="ltr">&lt;<a href="mailto:anish198519851985@gmail.com" target="_blank">anish198519851985@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote"><div><div class="m_-2135019904526500474h5">On Mon, Jan 23, 2017 at 7:46 AM, Rajasekhar Pulluru <span dir="ltr">&lt;<a href="mailto:pullururajasekhar@gmail.com" target="_blank">pullururajasekhar@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>Hi,</div><div><br></div><div>I have a query on device tree pertaining to modelling a gpio pin as an interrupt source. </div><div>I have searched mailing list archives and kernel documentation before posting this and couldn&#39;t get any direct solution.</div><div>(My understanding is limited and hence posting the query below:)</div><div><br></div><div>My SOC has a gpio controller and uart both sharing same interrupt line as specified below. </div><div><br></div><div><span class="m_-2135019904526500474m_-656488108402783319m_-7514866219543690092gmail-Apple-tab-span" style="white-space:pre-wrap">        </span>interrupt-parent = &lt;&amp;gic&gt;;</div><div><br></div><div>        mygpio: gpio@0x19008000 {</div><div>                compatible = &quot;mysoc,mygpio-controller,gc&quot;;</div><div>                #address-cells = &lt;1&gt;;</div><div>                #size-cells = &lt;1&gt;;</div><div>                #gpio-cells = &lt;2&gt;;</div><div>                reg = gpio: &lt;0x19008000 0x50&gt;;</div><div>                ngpios = &lt;12&gt;;</div><div>                pin-offset = &lt;4&gt;;</div><div>                pin-base = &lt;4&gt;;</div><div>                irq-base = &lt;256&gt;; /* sw irq base for irq handlers */</div><div>                gpio-controller;</div><div>                interrupt-controller;</div><div>                interrupts = &lt;GIC_SPI 91 IRQ_TYPE_LEVEL_HIGH&gt;;</div><div>        };</div><div><br></div><div>        uart0: serial@0x19000300 {</div><div>                compatible = &quot;snps,dw-apb-uart&quot;;</div><div>                reg = &lt;0x19000300 0x100&gt;;</div><div>                interrupts = &lt;GIC_SPI 91 IRQ_TYPE_LEVEL_HIGH&gt;;</div><div>                clock-frequency = &lt;62500000&gt;;</div><div>        };</div><div><br></div><div>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). </div><div>And I intend to detect the presence of the pluggable device from user space by means of generic uio platform driver using below device</div></div></blockquote><div><br></div></div></div><div>What do you intend to achieve by detecting device in userspace?<br></div><div>You can directly get notification using udev notification.<br><br></div><div>However, you need to send udev notification from a kernel driver.<br> <br></div><span><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>tree configuration. (following <a href="https://yurovsky.github.io/2014/10/10/linux-uio-gpio-interrupt/" target="_blank">https://yurovsky.github.io/201<wbr>4/10/10/linux-uio-gpio-interru<wbr>pt/</a>)</div><div><br></div><div>        user_io@0 {</div><div>            compatible = &quot;mydevice,generic-uio,ui_pdrv&quot;<wbr>;</div><div>            status = &quot;okay&quot;;</div><div>            interrupt-parent = &lt;&amp;mygpio&gt;;</div><div>            interrupts = &lt;0 IRQ_TYPE_LEVEL_HIGH&gt;;</div><div>        };</div><div><br></div><div>Running modprobe uio_pdrv_genirq of_id=&quot;mydevice,generic-uio,ui<wbr>_pdrv&quot; and creating /dev/uio0 using mknod (major number from cat /proc/devices | grep uio),</div><div>I couldn&#39;t see an irq entry bind to uio driver under /proc/interrupts.</div><div>Am I doing anything wrong here?</div><div><br></div><div>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 </div><div>wasn&#39;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</div><div>a device node to register the gpio pin0 as an interrupt source that allows me to poll on its sysfs entry?</div></div></blockquote><div><br></div></span><div>All sysfs nodes can be polled as it is supported in kernel. <br></div><div>You can simply create a dummy driver and register the<br></div><div>irq and in your irq handler send udev notifications using<br></div><div>kobj.<br></div><div><br>Or<br></div><div>just update a sysfs node which can be polled from userspace.<br><br></div><div>If this answer is not sufficient then please explain in detail<br></div><div>what you are planning to achieve rather than what you are<br></div><div>doing to achieve that. <br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><br></div><div>Thanks,</div><div>Rajasekhar</div></div>
<br>______________________________<wbr>_________________<br>
Kernelnewbies mailing list<br>
<a href="mailto:Kernelnewbies@kernelnewbies.org" target="_blank">Kernelnewbies@kernelnewbies.or<wbr>g</a><br>
<a href="https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies" rel="noreferrer" target="_blank">https://lists.kernelnewbies.or<wbr>g/mailman/listinfo/kernelnewbi<wbr>es</a><br>
<br></blockquote></div><br></div></div>
</blockquote></div><br></div>
</div></blockquote></div></div></div></blockquote></div><br></div>