<?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: Is gpio_get_value() working correctly? in i.MX Processors</title>
    <link>https://community.nxp.com/t5/i-MX-Processors/Is-gpio-get-value-working-correctly/m-p/255684#M24366</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Ah yes, that's what I meant! I'll correct my reply. Thanks!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 11 Dec 2013 20:58:52 GMT</pubDate>
    <dc:creator>KursadOney</dc:creator>
    <dc:date>2013-12-11T20:58:52Z</dc:date>
    <item>
      <title>Is gpio_get_value() working correctly?</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/Is-gpio-get-value-working-correctly/m-p/255681#M24363</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm working with u-boot-2013.10 with an iMX6D based board and just noticed something odd about the gpio_get_value() function in drivers/gpio/mxc_gpio.c &lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;(or maybe its just that I don't fully understand the difference between the PSR and DR GPIO control registers)...&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a couple of LEDs on my board connected to GPIO pins.&amp;nbsp; I just wrote a test function to blink those LEDs.&amp;nbsp; I first retrieve the current state using gpio_get_value(), then I change the state for the test using gpio_set_value()&amp;nbsp; and finally I restore the state back to each pin that I originally read.&amp;nbsp; Turns out that didn't work (it doesn't&amp;nbsp; restore the state).&amp;nbsp; Looking closer at the function, I see that it retrieves the bit from the PSR (pad status register); but it appears that this register should only be used on GPIO bits that are programmed as inputs.&amp;nbsp; &lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;When I changed &lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;this function to use the DR &lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;(data register), then it properly returned the status of the GPIO bit I was &lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;interested in.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So, it seems to me that the gpio_get_value() function should actually use DR for requests of bits that are programmed as&lt;/P&gt;&lt;P&gt;GPIO output, and PSR for requests of bits that are programmed as GPIO input.&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Does that make sense?&lt;/P&gt;&lt;P&gt;Ed&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 Dec 2013 20:14:16 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/Is-gpio-get-value-working-correctly/m-p/255681#M24363</guid>
      <dc:creator>EdSutter</dc:creator>
      <dc:date>2013-12-11T20:14:16Z</dc:date>
    </item>
    <item>
      <title>Re: Is gpio_get_value() working correctly?</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/Is-gpio-get-value-working-correctly/m-p/255682#M24364</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Ed,&lt;/P&gt;&lt;P&gt;I believe you're correct. In fact, it sounds like there is no need to use the &lt;SPAN style="text-decoration: line-through;"&gt;DR&lt;/SPAN&gt; PSR registers at all. The reference manual says:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;&lt;EM&gt;While the GPIO direction is set to input (GPIO_GDIR = 0), a&lt;/EM&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;read access to GPIO_DR does not return GPIO_DR data.&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Instead, it returns the GPIO_PSR data, which is the&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;corresponding input signal value.&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I checked the denx u-boot tree and &lt;A href="http://git.denx.de/?p=u-boot.git;a=blob;f=drivers/gpio/mxc_gpio.c;h=6a572d5454b39e4905da9094edd01f47cf451035;hb=4b210ad34282bfd9fc982a8e3c9a9126f4094cdb#l105"&gt;this issue&lt;/A&gt; seems to be there too. The following line:&lt;/P&gt;&lt;P&gt;val = (readl(&amp;amp;regs-&amp;gt;gpio_psr) &amp;gt;&amp;gt; gpio) &amp;amp; 0x01;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;should be:&lt;/P&gt;&lt;P&gt;val = (readl(&amp;amp;regs-&amp;gt;gpio_dr) &amp;gt;&amp;gt; gpio) &amp;amp; 0x01;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;&lt;A class="jx-jive-macro-user" href="https://community.nxp.com/people/FabioEstevam"&gt;FabioEstevam&lt;/A&gt; - can you verify this? Can Ed submit a patch to your tree that can be propogated upstream?&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 Dec 2013 20:52:06 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/Is-gpio-get-value-working-correctly/m-p/255682#M24364</guid>
      <dc:creator>KursadOney</dc:creator>
      <dc:date>2013-12-11T20:52:06Z</dc:date>
    </item>
    <item>
      <title>Re: Is gpio_get_value() working correctly?</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/Is-gpio-get-value-working-correctly/m-p/255683#M24365</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Kursad,&lt;/P&gt;&lt;P&gt;Thanks for the quick reply.&lt;/P&gt;&lt;P&gt;Just to clarify, I assume you meant...&lt;/P&gt;&lt;P&gt;... no need to use the PSR registers at all...&lt;/P&gt;&lt;P&gt;correct?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And, by the way, I'm using the source from the denx uboot tree.&lt;/P&gt;&lt;P&gt;Ed&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 Dec 2013 20:57:08 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/Is-gpio-get-value-working-correctly/m-p/255683#M24365</guid>
      <dc:creator>EdSutter</dc:creator>
      <dc:date>2013-12-11T20:57:08Z</dc:date>
    </item>
    <item>
      <title>Re: Is gpio_get_value() working correctly?</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/Is-gpio-get-value-working-correctly/m-p/255684#M24366</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Ah yes, that's what I meant! I'll correct my reply. Thanks!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 Dec 2013 20:58:52 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/Is-gpio-get-value-working-correctly/m-p/255684#M24366</guid>
      <dc:creator>KursadOney</dc:creator>
      <dc:date>2013-12-11T20:58:52Z</dc:date>
    </item>
    <item>
      <title>Re: Is gpio_get_value() working correctly?</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/Is-gpio-get-value-working-correctly/m-p/255685#M24367</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Ed and Kursad,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;We discussed about this issue recently in the U-boot list and the conclusion was that the proper way to handle it would be passing the SION flag to the GPIO connected to your LED.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please check this patch from Otavio:&lt;/P&gt;&lt;P&gt;&lt;A href="http://patchwork.ozlabs.org/patch/294937/" title="http://patchwork.ozlabs.org/patch/294937/"&gt;[U-Boot,v2,5/9] imx: Easy enabling of SION per-pin using MUX_MODE_SION helper macro - Patchwork&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Fabio Estevam&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 Dec 2013 21:30:27 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/Is-gpio-get-value-working-correctly/m-p/255685#M24367</guid>
      <dc:creator>fabio_estevam</dc:creator>
      <dc:date>2013-12-11T21:30:27Z</dc:date>
    </item>
    <item>
      <title>Re: Is gpio_get_value() working correctly?</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/Is-gpio-get-value-working-correctly/m-p/255686#M24368</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Ok, I see...&lt;/P&gt;&lt;P&gt;Kursad and Fabio, thanks much for the quick help.&lt;/P&gt;&lt;P&gt;Ed&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 Dec 2013 22:32:52 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/Is-gpio-get-value-working-correctly/m-p/255686#M24368</guid>
      <dc:creator>EdSutter</dc:creator>
      <dc:date>2013-12-11T22:32:52Z</dc:date>
    </item>
  </channel>
</rss>

