<?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>topic Re: LS1021A External interrupt in Layerscape</title>
    <link>https://community.nxp.com/t5/Layerscape/LS1021A-External-interrupt/m-p/651787#M2265</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Then if you want to use the irq from the gpio you have to use gpio_to_irq.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;irqNum = gpio_to_irq(57); // IRQ number of gpio 1_25&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You have add to the includes:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;#include &amp;lt;linux/gpio.h&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The gpio number is bank*32 + offset.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I tested this mechanism with a LS1021A and an external device interrupting in a GPIO line (GPIO4_23).&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 31 Jan 2017 10:02:59 GMT</pubDate>
    <dc:creator>erdani80</dc:creator>
    <dc:date>2017-01-31T10:02:59Z</dc:date>
    <item>
      <title>LS1021A External interrupt</title>
      <link>https://community.nxp.com/t5/Layerscape/LS1021A-External-interrupt/m-p/651783#M2261</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am trying&amp;nbsp;to write an interrupt handler for LS1021A external interrupt IRQ5 using the QorIQ SDK 2.0. I have created a kernel module to handle the interrupt but the&amp;nbsp;&lt;EM&gt;reset_irq&lt;/EM&gt; function is always returning -22 (Invalid argument).&lt;/P&gt;&lt;P&gt;This is my code:&lt;/P&gt;&lt;PRE class="language-c line-numbers"&gt;&lt;CODE&gt;&lt;SPAN class="keyword token"&gt;static&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;unsigned&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;int&lt;/SPAN&gt; irqNum&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;

&lt;SPAN class="keyword token"&gt;static&lt;/SPAN&gt; irq_handler_t &lt;SPAN class="token function"&gt;irq5_handler&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="keyword token"&gt;unsigned&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;int&lt;/SPAN&gt; irq&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;void&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;*&lt;/SPAN&gt;dev_id&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;struct&lt;/SPAN&gt; pt_regs &lt;SPAN class="operator token"&gt;*&lt;/SPAN&gt;regs&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;SPAN class="token function"&gt;printk&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;KERN_INFO &lt;SPAN class="string token"&gt;"Interrupt received\n"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;SPAN class="keyword token"&gt;return&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;irq_handler_t&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; IRQ_HANDLED&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="punctuation token"&gt;}&lt;/SPAN&gt;‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

&lt;SPAN class="keyword token"&gt;static&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;int&lt;/SPAN&gt; __init &lt;SPAN class="token function"&gt;irq_init&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="keyword token"&gt;void&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;SPAN class="keyword token"&gt;int&lt;/SPAN&gt; result &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;irqNum &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;201&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;&amp;nbsp; &lt;SPAN class="comment token"&gt;// IRQ number of IRQ5&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;result &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;request_irq&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;irqNum&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;irq_handler_t&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; irq5_handler&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; IRQF_TRIGGER_RISING&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"irq5_handler"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; NULL&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;SPAN class="token function"&gt;printk&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;KERN_INFO &lt;SPAN class="string token"&gt;"request_irq result is %d\n"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; result&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;SPAN class="keyword token"&gt;return&lt;/SPAN&gt; result&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="punctuation token"&gt;}&lt;/SPAN&gt;

&lt;SPAN class="token function"&gt;module_init&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;irq_init&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is creating a kernel module the right approach to handle the interrupt?&lt;/P&gt;&lt;P&gt;Do I need to perform any actions like initializing the pin&amp;nbsp;before requesting the interrupt (&lt;EM&gt;request_irq&lt;/EM&gt;)?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It would be helpful if someone can point me to a document or a sample program that explains the usage of IRQ(0-5)&amp;nbsp;from Linux; specifically for the LS1021A processor.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 28 Jan 2017 03:38:30 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Layerscape/LS1021A-External-interrupt/m-p/651783#M2261</guid>
      <dc:creator>rahulr</dc:creator>
      <dc:date>2017-01-28T03:38:30Z</dc:date>
    </item>
    <item>
      <title>Re: LS1021A External interrupt</title>
      <link>https://community.nxp.com/t5/Layerscape/LS1021A-External-interrupt/m-p/651784#M2262</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The first 32 interrupt channels are for the core and are not exposed into linux.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In order to find the correspondence between the IRQ ID in the tables and the one used in linux you have to calculate the following:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Linux IRQ = Interrupt ID - 32&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;That is your Irq number is 169. You are trying to request the&amp;nbsp;PEX2 link-up IRQ.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 30 Jan 2017 18:03:12 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Layerscape/LS1021A-External-interrupt/m-p/651784#M2262</guid>
      <dc:creator>erdani80</dc:creator>
      <dc:date>2017-01-30T18:03:12Z</dc:date>
    </item>
    <item>
      <title>Re: LS1021A External interrupt</title>
      <link>https://community.nxp.com/t5/Layerscape/LS1021A-External-interrupt/m-p/651785#M2263</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Daniel!&lt;/P&gt;&lt;P&gt;I am getting the same error (-22) after correcting the IRQ number (&lt;EM&gt;irqNumber = 169;&lt;/EM&gt;). Do I need to add something to the device tree before trying to request the IRQ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I see that some of the IRQ pins has alternate functions like GPIO. Is it required to first set the pin to IRQ mode? I assumed this is done automatically by the&amp;nbsp;&lt;EM&gt;request_irq&lt;/EM&gt; function.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;EDIT:&lt;/P&gt;&lt;P&gt;I added some&amp;nbsp;&lt;EM&gt;printk&lt;/EM&gt; statements to the kernel source code and found that the code is failing at&amp;nbsp;the following statement in &lt;EM&gt;kernek/irq/manage.c&lt;/EM&gt;.&lt;/P&gt;&lt;PRE class="language-c"&gt;&lt;CODE&gt;desc &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;irq_to_desc&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;irq&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;if&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;!&lt;/SPAN&gt;desc&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
 &lt;SPAN class="keyword token"&gt;return&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;-&lt;/SPAN&gt;EINVAL&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;‍‍‍‍‍‍&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 30 Jan 2017 18:48:00 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Layerscape/LS1021A-External-interrupt/m-p/651785#M2263</guid>
      <dc:creator>rahulr</dc:creator>
      <dc:date>2017-01-30T18:48:00Z</dc:date>
    </item>
    <item>
      <title>Re: LS1021A External interrupt</title>
      <link>https://community.nxp.com/t5/Layerscape/LS1021A-External-interrupt/m-p/651786#M2264</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt;"&gt;The LS1021a IRQ5 is GPIO1_25. NXP SDK 2.0 supports SYSFS possibility. Usually this possibility is used for interrupt on GPIO pins.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt;"&gt;See attached file.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Have a great day,&lt;BR /&gt;Pavel Chubakov&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&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>Tue, 31 Jan 2017 05:26:05 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Layerscape/LS1021A-External-interrupt/m-p/651786#M2264</guid>
      <dc:creator>Pavel</dc:creator>
      <dc:date>2017-01-31T05:26:05Z</dc:date>
    </item>
    <item>
      <title>Re: LS1021A External interrupt</title>
      <link>https://community.nxp.com/t5/Layerscape/LS1021A-External-interrupt/m-p/651787#M2265</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Then if you want to use the irq from the gpio you have to use gpio_to_irq.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;irqNum = gpio_to_irq(57); // IRQ number of gpio 1_25&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You have add to the includes:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;#include &amp;lt;linux/gpio.h&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The gpio number is bank*32 + offset.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I tested this mechanism with a LS1021A and an external device interrupting in a GPIO line (GPIO4_23).&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 31 Jan 2017 10:02:59 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Layerscape/LS1021A-External-interrupt/m-p/651787#M2265</guid>
      <dc:creator>erdani80</dc:creator>
      <dc:date>2017-01-31T10:02:59Z</dc:date>
    </item>
    <item>
      <title>Re: LS1021A External interrupt</title>
      <link>https://community.nxp.com/t5/Layerscape/LS1021A-External-interrupt/m-p/651788#M2266</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="color: #51626f; background-color: #ffffff;"&gt;I got -22 as the response for&amp;nbsp;gpio_to_irq(); for all the GPIOs I tried.&amp;nbsp;Pavel's document will be very helpful in debugging this issue. Unfortunately I wont be able to use the GPIO interrupt because on the final design, we are using IRQ0 pin for interrupt as far as I know this is a dedicated interrupt pin (no GPIO function). I was using IRQ5 only because it's easier to access using the LS1021A-TWR tower connector.&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 31 Jan 2017 16:12:31 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Layerscape/LS1021A-External-interrupt/m-p/651788#M2266</guid>
      <dc:creator>rahulr</dc:creator>
      <dc:date>2017-01-31T16:12:31Z</dc:date>
    </item>
  </channel>
</rss>

