<?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: i.MX8 PWM interrupt in i.MX Processors</title>
    <link>https://community.nxp.com/t5/i-MX-Processors/i-MX8-PWM-interrupt/m-p/1889706#M225162</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;The&amp;nbsp;PWMx_PWMIR register only supports&amp;nbsp;Compare Interrupt,&amp;nbsp;Roll-over Interrupt and&amp;nbsp;FIFO Empty Interrupt.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For GPIO you need to do a hardware modifications.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best regards,&lt;/P&gt;
&lt;P&gt;Salas.&lt;/P&gt;</description>
    <pubDate>Tue, 18 Jun 2024 17:44:56 GMT</pubDate>
    <dc:creator>Manuel_Salas</dc:creator>
    <dc:date>2024-06-18T17:44:56Z</dc:date>
    <item>
      <title>i.MX8 PWM interrupt</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/i-MX8-PWM-interrupt/m-p/1888638#M225051</link>
      <description>&lt;P&gt;Dear community!&lt;/P&gt;&lt;P&gt;I would like to ask you a question whether is possible to use PWM interrupt on i.MX8mp. I wanted to create a custom driver and be notified when PWM output is going down (FALLING_EDGE). Is it even possible to be achieve it, or not just by design?&lt;/P&gt;&lt;P&gt;In the DTB&lt;/P&gt;&lt;LI-CODE lang="c"&gt;// imx8mp.dtsi
pwm1: pwm@30660000 {
	compatible = "fsl,imx8mp-pwm", "fsl,imx27-pwm";
	reg = &amp;lt;0x30660000 0x10000&amp;gt;;
	interrupts = &amp;lt;GIC_SPI 81 IRQ_TYPE_LEVEL_HIGH&amp;gt;;
	clocks = &amp;lt;&amp;amp;clk IMX8MP_CLK_PWM1_ROOT&amp;gt;,
		 &amp;lt;&amp;amp;clk IMX8MP_CLK_PWM1_ROOT&amp;gt;;
	clock-names = "ipg", "per";
	#pwm-cells = &amp;lt;3&amp;gt;;
	status = "disabled";
};

// imx8mp-my-device.dts
cam_trigger: cam-trigger {
	compatible = "company,cam-trigger";
	pwms = &amp;lt;&amp;amp;pwm1 0 8333333 0&amp;gt;;
	interrupts = &amp;lt;GIC_SPI 81 IRQ_TYPE_LEVEL_HIGH&amp;gt;;
	status = "okay";
};

&amp;amp;iomuxc {
	pinctrl-names = "default";

	pinctrl_pwm1: pwm1grp {
		fsl,pins = &amp;lt;
			MX8MP_IOMUXC_GPIO1_IO01__PWM1_OUT	0x116
		&amp;gt;;
	};
};

&amp;amp;pwm1 {
	pinctrl-names = "default";
	pinctrl-0 = &amp;lt;&amp;amp;pinctrl_pwm1&amp;gt;;
	status = "okay";
};&lt;/LI-CODE&gt;&lt;P&gt;is a &lt;EM&gt;&amp;lt;GIC_SPI 81 IRQ_TYPE_LEVEL_HIGH&amp;gt;&lt;/EM&gt; entry. So I registered to this interrupt via &lt;EM&gt;devm_request_irq&lt;/EM&gt; and verified it in &lt;EM&gt;/proc/interrupt&lt;/EM&gt;, that registration was successful. (Even if I wanted to have a falling edge, I used just something.) But the interrupt didn't happen.&lt;/P&gt;&lt;P&gt;After deeper analysis I realized, that i.MX8 has an &lt;EM&gt;PWMIR&lt;/EM&gt; register, but the handling is missing in &lt;EM&gt;pwm-imx27&lt;/EM&gt; driver. I guess that would be the reason why... .&lt;/P&gt;&lt;P&gt;Now the questions are:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Is my meaning true?&lt;UL&gt;&lt;LI&gt;How hard is to implement such a mechanism into driver.&lt;UL&gt;&lt;LI&gt;According to DS, just a &lt;EM&gt;capture&lt;/EM&gt; should be enough&lt;/LI&gt;&lt;/UL&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/LI&gt;&lt;LI&gt;What the &lt;EM&gt;GIC_SPI 81&lt;/EM&gt; is meaning then? Does it mean that is it there just "for fun" ?&lt;/LI&gt;&lt;LI&gt;Is there an another way how to be notified when interrupt happens?&lt;UL&gt;&lt;LI&gt;HW modifications like routing the output pin to other input GPIO are not possible&lt;/LI&gt;&lt;/UL&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;Many thanks for any inputs.&lt;BR /&gt;Andy&lt;/P&gt;</description>
      <pubDate>Mon, 17 Jun 2024 10:46:44 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/i-MX8-PWM-interrupt/m-p/1888638#M225051</guid>
      <dc:creator>andrej_valek</dc:creator>
      <dc:date>2024-06-17T10:46:44Z</dc:date>
    </item>
    <item>
      <title>Re: i.MX8 PWM interrupt</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/i-MX8-PWM-interrupt/m-p/1888946#M225079</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/170941"&gt;@andrej_valek&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The IRQ 81 is&amp;nbsp;Cumulative interrupt line. OR of Rollover Interrupt line, Compare Interrupt line and FIFO Waterlevel crossing interrupt line for PWM1.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Maybe for your use case you can get the PWM signal to any GPIO and config the Falling Edge to get the interruption.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best reagrds,&lt;/P&gt;
&lt;P&gt;Salas.&lt;/P&gt;</description>
      <pubDate>Mon, 17 Jun 2024 21:48:37 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/i-MX8-PWM-interrupt/m-p/1888946#M225079</guid>
      <dc:creator>Manuel_Salas</dc:creator>
      <dc:date>2024-06-17T21:48:37Z</dc:date>
    </item>
    <item>
      <title>Re: i.MX8 PWM interrupt</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/i-MX8-PWM-interrupt/m-p/1889206#M225117</link>
      <description>&lt;P&gt;Hello &lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/203368"&gt;@Manuel_Salas&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;The IRQ 81 is Cumulative interrupt line. OR of Rollover Interrupt line, Compare Interrupt line and FIFO Waterlevel crossing interrupt line for PWM1.&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Yes, but are you sure, that will it work even if there is no &lt;EM&gt;PWMIR&lt;/EM&gt; register handling? Or is it reading the bits done somehow differently?&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;you can get the PWM signal to any GPIO&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;How can I do that without modifying the HW? Is there a way to register for GPIO interrupt even if the pin is set to &lt;EM&gt;MX8MP_IOMUXC_GPIO1_IO01__PWM1_OUT&lt;/EM&gt; which not a GPIO, but routed as a PWM. So does it mean, it will be handled somehow internally? If yes, could you please write me an example how to do it?&lt;/P&gt;&lt;P&gt;Thank you,&lt;BR /&gt;Andy&lt;/P&gt;</description>
      <pubDate>Tue, 18 Jun 2024 06:54:42 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/i-MX8-PWM-interrupt/m-p/1889206#M225117</guid>
      <dc:creator>andrej_valek</dc:creator>
      <dc:date>2024-06-18T06:54:42Z</dc:date>
    </item>
    <item>
      <title>Re: i.MX8 PWM interrupt</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/i-MX8-PWM-interrupt/m-p/1889706#M225162</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;The&amp;nbsp;PWMx_PWMIR register only supports&amp;nbsp;Compare Interrupt,&amp;nbsp;Roll-over Interrupt and&amp;nbsp;FIFO Empty Interrupt.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For GPIO you need to do a hardware modifications.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best regards,&lt;/P&gt;
&lt;P&gt;Salas.&lt;/P&gt;</description>
      <pubDate>Tue, 18 Jun 2024 17:44:56 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/i-MX8-PWM-interrupt/m-p/1889706#M225162</guid>
      <dc:creator>Manuel_Salas</dc:creator>
      <dc:date>2024-06-18T17:44:56Z</dc:date>
    </item>
    <item>
      <title>Re: i.MX8 PWM interrupt</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/i-MX8-PWM-interrupt/m-p/1889722#M225165</link>
      <description>&lt;P&gt;Hello again,&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;The PWMx_PWMIR register only supports Compare Interrupt, Roll-over Interrupt and FIFO Empty Interrupt.&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;I know that :). But then how to enable the notification for "Compare interrupt"? Does it mean, that I have to just set the CIE bit in PWMx_PWMIR register? Will be the interrupt on line 81 called automatically? How/when will be CMP bit cleared?&lt;/P&gt;&lt;P&gt;Regards,&lt;BR /&gt;Andy&lt;/P&gt;</description>
      <pubDate>Tue, 18 Jun 2024 18:05:43 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/i-MX8-PWM-interrupt/m-p/1889722#M225165</guid>
      <dc:creator>andrej_valek</dc:creator>
      <dc:date>2024-06-18T18:05:43Z</dc:date>
    </item>
    <item>
      <title>Re: i.MX8 PWM interrupt</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/i-MX8-PWM-interrupt/m-p/1892692#M225377</link>
      <description>&lt;P&gt;Ok, I will answer it by myself. Here are the modifications which I had to do to make the interrupts working.&lt;/P&gt;&lt;LI-CODE lang="c"&gt;#define MX3_PWMIR			0x08    /* PWM Interrupt Register */

#define MX3_PWMIR_CIE	BIT(2)
#define MX3_PWMIR_RIE	BIT(1)
#define MX3_PWMIR_FIE	BIT(0)

struct pwm_imx27_chip {
...
	int irq;

if (state-&amp;gt;enabled) {
	cr |= MX3_PWMCR_EN;
	/* enable interrupts */
	writel(MX3_PWMIR_CIE | MX3_PWMIR_RIE, imx-&amp;gt;mmio_base + MX3_PWMIR);
	} else {
	/* disable interrupts */
	writel(0, imx-&amp;gt;mmio_base + MX3_PWMIR);
}


static irqreturn_t imx_pwm_interrupt(int irq, void *data)
{
	struct pwm_imx27_chip *imx = data;
	unsigned long flags;
	u32 pwmsr;

	spin_lock_irqsave(&amp;amp;imx-&amp;gt;lock, flags);

	pwmsr = readl(imx-&amp;gt;mmio_base + MX3_PWMSR);

	/* handle flags separately, while multiple of them could happen */
	if (pwmsr &amp;amp;&amp;amp; (~MX3_PWMSR_CMP)) pwmsr |= MX3_PWMSR_CMP;
	if (pwmsr &amp;amp;&amp;amp; (~MX3_PWMSR_ROV)) pwmsr |= MX3_PWMSR_ROV;

	/* ack interrupt flags */
	writel(pwmsr, imx-&amp;gt;mmio_base + MX3_PWMSR);
	
	spin_unlock_irqrestore(&amp;amp;imx-&amp;gt;lock, flags);

	return IRQ_HANDLED;
}

// probe...
	imx-&amp;gt;irq = platform_get_irq(pdev, 0);
	if (imx-&amp;gt;irq &amp;lt; 0) {
		dev_err(&amp;amp;pdev-&amp;gt;dev, "Failed to get IRQ\n");
		return imx-&amp;gt;irq;
	}

	ret = devm_request_irq(&amp;amp;pdev-&amp;gt;dev, imx-&amp;gt;irq, imx_pwm_interrupt, IRQF_TRIGGER_HIGH,
			       pdev-&amp;gt;name, imx);
	if (ret &amp;lt; 0) {
		dev_err(&amp;amp;pdev-&amp;gt;dev, "Failed to request IRQ\n");
		return ret;
	}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;Maybe it will help to someone else too.&lt;/P&gt;&lt;P&gt;Regards,&lt;BR /&gt;Andy&lt;/P&gt;</description>
      <pubDate>Mon, 24 Jun 2024 07:55:21 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/i-MX8-PWM-interrupt/m-p/1892692#M225377</guid>
      <dc:creator>andrej_valek</dc:creator>
      <dc:date>2024-06-24T07:55:21Z</dc:date>
    </item>
  </channel>
</rss>

