<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>i.MX ProcessorsのトピックHandling Interrupt from ONOFF Pin</title>
    <link>https://community.nxp.com/t5/i-MX-Processors/Handling-Interrupt-from-ONOFF-Pin/m-p/810542#M125017</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;What I am trying to achieve is: If ONOFF button is pressed shorter than 5 secs, I will handle interrupt and put the system in sleep mode. For now, I am trying to see a kernel message that says I triggered the interrupt successfully when the button is pressed. I am proceeding from another vendor's basic kernel module example for handling gpio interrupts. I have edited it a little bit:&lt;/P&gt;&lt;PRE&gt;#include &amp;lt;linux/module.h&amp;gt;
#include &amp;lt;linux/irq.h&amp;gt;
#include &amp;lt;linux/interrupt.h&amp;gt;
#include &amp;lt;linux/kernel.h&amp;gt;
#include &amp;lt;linux/gpio.h&amp;gt;

static int irq_number = -1;

irqreturn_t gpio_isr(int this_irq, void *dev_id)
{
&amp;nbsp;&amp;nbsp; &amp;nbsp;printk("Interrupt happened at gpio:%d\n", irq_number);
&amp;nbsp;&amp;nbsp; &amp;nbsp;return IRQ_HANDLED;
}

static void __exit gpio_interrupt_exit (void)
{
&amp;nbsp;&amp;nbsp; &amp;nbsp;free_irq(irq_number,0);
&amp;nbsp;&amp;nbsp; &amp;nbsp;return;
}

static int __init gpio_interrupt_init (void)
{
&amp;nbsp;&amp;nbsp; &amp;nbsp;int r;
&amp;nbsp;&amp;nbsp; &amp;nbsp;
&amp;nbsp;&amp;nbsp; &amp;nbsp;if (irq_number &amp;lt; 0) {
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;printk("Please specify a valid gpio_number\n");
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;return -1;
&amp;nbsp;&amp;nbsp; &amp;nbsp;}&amp;nbsp; &amp;nbsp;
&amp;nbsp;&amp;nbsp; &amp;nbsp;r = request_irq(irq_number, gpio_isr, 0, 0, 0);
&amp;nbsp;&amp;nbsp; &amp;nbsp;if (r) {
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;printk("failure requesting irq %i\n", irq_number);
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;return r;
&amp;nbsp;&amp;nbsp; &amp;nbsp;}
&amp;nbsp;&amp;nbsp; &amp;nbsp;return 0;
}

MODULE_LICENSE("GPL");

module_param(irq_number, int, 0);

module_init(gpio_interrupt_init);
module_exit(gpio_interrupt_exit);&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;From what I've read from the Reference Manual, ONOFF pin has IRQ 36, so I enter 36 as my irq_number parameter. After installing module, Linux hangs. I guess I am choosing wrong number that points to a busy pin, so that causes the hang.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is it possible to handle ONOFF pin's interrupt? If so, how can I do it? Thanks in advance.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 22 Jun 2018 13:20:54 GMT</pubDate>
    <dc:creator>denizdayan</dc:creator>
    <dc:date>2018-06-22T13:20:54Z</dc:date>
    <item>
      <title>Handling Interrupt from ONOFF Pin</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/Handling-Interrupt-from-ONOFF-Pin/m-p/810542#M125017</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;What I am trying to achieve is: If ONOFF button is pressed shorter than 5 secs, I will handle interrupt and put the system in sleep mode. For now, I am trying to see a kernel message that says I triggered the interrupt successfully when the button is pressed. I am proceeding from another vendor's basic kernel module example for handling gpio interrupts. I have edited it a little bit:&lt;/P&gt;&lt;PRE&gt;#include &amp;lt;linux/module.h&amp;gt;
#include &amp;lt;linux/irq.h&amp;gt;
#include &amp;lt;linux/interrupt.h&amp;gt;
#include &amp;lt;linux/kernel.h&amp;gt;
#include &amp;lt;linux/gpio.h&amp;gt;

static int irq_number = -1;

irqreturn_t gpio_isr(int this_irq, void *dev_id)
{
&amp;nbsp;&amp;nbsp; &amp;nbsp;printk("Interrupt happened at gpio:%d\n", irq_number);
&amp;nbsp;&amp;nbsp; &amp;nbsp;return IRQ_HANDLED;
}

static void __exit gpio_interrupt_exit (void)
{
&amp;nbsp;&amp;nbsp; &amp;nbsp;free_irq(irq_number,0);
&amp;nbsp;&amp;nbsp; &amp;nbsp;return;
}

static int __init gpio_interrupt_init (void)
{
&amp;nbsp;&amp;nbsp; &amp;nbsp;int r;
&amp;nbsp;&amp;nbsp; &amp;nbsp;
&amp;nbsp;&amp;nbsp; &amp;nbsp;if (irq_number &amp;lt; 0) {
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;printk("Please specify a valid gpio_number\n");
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;return -1;
&amp;nbsp;&amp;nbsp; &amp;nbsp;}&amp;nbsp; &amp;nbsp;
&amp;nbsp;&amp;nbsp; &amp;nbsp;r = request_irq(irq_number, gpio_isr, 0, 0, 0);
&amp;nbsp;&amp;nbsp; &amp;nbsp;if (r) {
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;printk("failure requesting irq %i\n", irq_number);
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;return r;
&amp;nbsp;&amp;nbsp; &amp;nbsp;}
&amp;nbsp;&amp;nbsp; &amp;nbsp;return 0;
}

MODULE_LICENSE("GPL");

module_param(irq_number, int, 0);

module_init(gpio_interrupt_init);
module_exit(gpio_interrupt_exit);&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;From what I've read from the Reference Manual, ONOFF pin has IRQ 36, so I enter 36 as my irq_number parameter. After installing module, Linux hangs. I guess I am choosing wrong number that points to a busy pin, so that causes the hang.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is it possible to handle ONOFF pin's interrupt? If so, how can I do it? Thanks in advance.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 22 Jun 2018 13:20:54 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/Handling-Interrupt-from-ONOFF-Pin/m-p/810542#M125017</guid>
      <dc:creator>denizdayan</dc:creator>
      <dc:date>2018-06-22T13:20:54Z</dc:date>
    </item>
    <item>
      <title>Re: Handling Interrupt from ONOFF Pin</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/Handling-Interrupt-from-ONOFF-Pin/m-p/810543#M125018</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi denizdayan&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;one can look on patch on&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.nxp.com/thread/308257"&gt;ONOFF button doesn't interrupt&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best regards&lt;BR /&gt;igor&lt;BR /&gt;-----------------------------------------------------------------------------------------------------------------------&lt;BR /&gt;Note: If this post answers your question, please click the Correct Answer button. Thank you!&lt;BR /&gt;-----------------------------------------------------------------------------------------------------------------------&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 22 Jun 2018 23:26:42 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/Handling-Interrupt-from-ONOFF-Pin/m-p/810543#M125018</guid>
      <dc:creator>igorpadykov</dc:creator>
      <dc:date>2018-06-22T23:26:42Z</dc:date>
    </item>
  </channel>
</rss>

