<?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>LayerscapeのトピックRe: How To Access GPIO Pins From Linux User Space On LS1021A</title>
    <link>https://community.nxp.com/t5/Layerscape/How-To-Access-GPIO-Pins-From-Linux-User-Space-On-LS1021A/m-p/425967#M339</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for pointing out all that documentation, Pavel.&amp;nbsp; That seems to have lead us down the correct path.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;We were able to determine which port each gpiochip was associated with by reading the "label" of each &lt;SPAN style="font-size: 13.3333330154419px;"&gt; (for our purposes, gpio3 translates to gpiochip160)&lt;/SPAN&gt;.&amp;nbsp; From there we were able to index the corresponding base and export the pin we want to manipulate (for us it was 163).&amp;nbsp; With gpio163 created we were able to write 1's and 0's to the "value" and see the levels change on an oscilloscope.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Patrick&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 21 Apr 2015 17:35:55 GMT</pubDate>
    <dc:creator>patrickmorrow</dc:creator>
    <dc:date>2015-04-21T17:35:55Z</dc:date>
    <item>
      <title>How To Access GPIO Pins From Linux User Space On LS1021A</title>
      <link>https://community.nxp.com/t5/Layerscape/How-To-Access-GPIO-Pins-From-Linux-User-Space-On-LS1021A/m-p/425965#M337</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;We've managed to get a yocto Linux build up and running on a custom board populated with a LS1021A utilizing the 1.7 sdk.&amp;nbsp; We've also managed to run some simple programs on our board that we've built using Codewarrior, mostly baby steps like hello world type stuff that will print out to the terminal, just to make sure that we can.&amp;nbsp; Now we're ready to try something a little more in depth, namely wiggling GPIO pins, but we can't seem to find any information that would tell us the absolute addresses of the pins we wish to drive.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;We've found documentation, both within these forums and elsewhere on the internet, telling us that in order to drive a GPIO pin from Linux user space we need to navigate to /sys/class/gpio, which we do, and then: echo XX &amp;gt; export, where XX would be the address of the pin that we want to establish a connection to (we're aware that what was just written is terminal based, but for the sake of removing all possible things that can cause an issue, we've decided to attempt a terminal solution before translating it into something that can be run from a C program).&amp;nbsp; Our goal is to drive pins GPIO3[3], GPIO3[4] and GPIO3[5], but we get stuck trying to find some kind of conversion that will give us absolute values for those 3 pins. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When we list the contents of the /sys/class/gpio directory we notice that there are sub directories labeled gpiochip128, gpiochip160, gpiochip192, and gpiochip224.&amp;nbsp; Do those correspond to the different GPIO ports and associated pins?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Patrick&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 20 Apr 2015 17:28:05 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Layerscape/How-To-Access-GPIO-Pins-From-Linux-User-Space-On-LS1021A/m-p/425965#M337</guid>
      <dc:creator>patrickmorrow</dc:creator>
      <dc:date>2015-04-20T17:28:05Z</dc:date>
    </item>
    <item>
      <title>Re: How To Access GPIO Pins From Linux User Space On LS1021A</title>
      <link>https://community.nxp.com/t5/Layerscape/How-To-Access-GPIO-Pins-From-Linux-User-Space-On-LS1021A/m-p/425966#M338</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN lang="EN-US" style="font-size: 10.0pt;"&gt;Check please that the following kernel configuration options are set. These options are necessary &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-US" style="font-size: 10.0pt;"&gt;for sysfs GPIO support:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-US" style="font-size: 10.0pt;"&gt;CONFIG_MPC8XXX_GPIO (Platform Support / MPC8xxx GPIO support)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-US" style="font-size: 10.0pt;"&gt;CONFIG_OF_GPIO&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-US" style="font-size: 10.0pt;"&gt;CONFIG_GPIOLIB (-*- GPIO Support ---&amp;gt;&amp;nbsp; )&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-US" style="font-size: 10.0pt;"&gt;CONFIG_GPIO_SYSFS (/sys/class/gpio/... (sysfs interface))&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-US" style="font-size: 10.0pt;"&gt;This option can be checked using the .config file in the kernel source folder.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-US" style="font-size: 10.0pt;"&gt;GPIO controllers should be declared in the Device Tree file. &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-US" style="font-size: 10.0pt;"&gt;More information on the device tree GPIO declaration can be found in the kernel source. &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-US" style="font-size: 10.0pt;"&gt;See please the following files: &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-US" style="font-size: 10.0pt;"&gt;/Documentation/powerpc/dts-bindings/gpio.txt and /Documentation/powerpc/dts-bindings/fsl/8xxx_gpio.txt&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-US" style="font-size: 10.0pt;"&gt;This possibility is available using sysfs from user space.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-US" style="font-size: 10.0pt;"&gt;See the following pages &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-US" style="font-size: 10.0pt;"&gt;(&lt;A href="http://elinux.org/GPIO"&gt;http://elinux.org/GPIO&lt;/A&gt;) &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-US" style="font-size: 10.0pt;"&gt;and &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-US" style="font-size: 10.0pt;"&gt;(&lt;A href="https://www.kernel.org/doc/Documentation/gpio/sysfs.txt"&gt;https://www.kernel.org/doc/Documentation/gpio/sysfs.txt&lt;/A&gt;).&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-US" style="font-size: 10.0pt;"&gt;and&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-US" style="font-size: 10.0pt;"&gt; (&lt;A href="http://www.lindusembedded.com/blog/2011/12/29/gpio-general-purpose-inputoutput-interfaces-in-linux-2/"&gt;http://www.lindusembedded.com/blog/2011/12/29/gpio-general-purpose-inputoutput-interfaces-in-linux-2/&lt;/A&gt;)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-US" style="font-size: 10.0pt;"&gt;and&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-US" style="font-size: 10.0pt;"&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="https://www.kernel.org/doc/Documentation/gpio/sysfs.txt" target="_blank"&gt;https://www.kernel.org/doc/Documentation/gpio/sysfs.txt&lt;/A&gt;&lt;SPAN&gt;).&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-US" style="font-size: 10.0pt;"&gt;The second method consist of using mmap command.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-US" style="font-size: 10.0pt;"&gt;It is a POSIX-compliant Linux/Unix system call that maps files or devices into memory. &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-US" style="font-size: 10.0pt;"&gt;It is a method of memory-mapped file I/O.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-US" style="font-size: 10.0pt;"&gt;&lt;SPAN&gt;For example, look at the following links (&lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="http://en.wikipedia.org/wiki/Mmap" target="_blank"&gt;http://en.wikipedia.org/wiki/Mmap&lt;/A&gt;&lt;SPAN&gt;) and &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-US" style="font-size: 10.0pt;"&gt;(&lt;A href="http://beej.us/guide/bgipc/output/html/multipage/mmap.html"&gt;http://beej.us/guide/bgipc/output/html/multipage/mmap.html&lt;/A&gt;).&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 21 Apr 2015 04:12:28 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Layerscape/How-To-Access-GPIO-Pins-From-Linux-User-Space-On-LS1021A/m-p/425966#M338</guid>
      <dc:creator>Pavel</dc:creator>
      <dc:date>2015-04-21T04:12:28Z</dc:date>
    </item>
    <item>
      <title>Re: How To Access GPIO Pins From Linux User Space On LS1021A</title>
      <link>https://community.nxp.com/t5/Layerscape/How-To-Access-GPIO-Pins-From-Linux-User-Space-On-LS1021A/m-p/425967#M339</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for pointing out all that documentation, Pavel.&amp;nbsp; That seems to have lead us down the correct path.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;We were able to determine which port each gpiochip was associated with by reading the "label" of each &lt;SPAN style="font-size: 13.3333330154419px;"&gt; (for our purposes, gpio3 translates to gpiochip160)&lt;/SPAN&gt;.&amp;nbsp; From there we were able to index the corresponding base and export the pin we want to manipulate (for us it was 163).&amp;nbsp; With gpio163 created we were able to write 1's and 0's to the "value" and see the levels change on an oscilloscope.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Patrick&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 21 Apr 2015 17:35:55 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Layerscape/How-To-Access-GPIO-Pins-From-Linux-User-Space-On-LS1021A/m-p/425967#M339</guid>
      <dc:creator>patrickmorrow</dc:creator>
      <dc:date>2015-04-21T17:35:55Z</dc:date>
    </item>
  </channel>
</rss>

