<?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: iMX27 GPIO access in Other NXP Products</title>
    <link>https://community.nxp.com/t5/Other-NXP-Products/iMX27-GPIO-access/m-p/210834#M2347</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It should be the physical address as GPIO_BASE, i.e. 0x10015000&lt;/P&gt;&lt;P&gt;The problem seems to be that since the pointer *memregs32 is of type long every address from GPIO_BASE will actually be 4 bytes.&lt;/P&gt;&lt;P&gt;Therefore every address accessed using memregs32 should be divided by 4, something like:&lt;/P&gt;&lt;P&gt;...memregs32[0x400/4]...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I think... &lt;IMG alt=":smileyhappy:" class="emoticon emoticon-smileyhappy" id="smileyhappy" src="http://freescale.i.lithium.com/i/smilies/16x16_smiley-happy.gif" title="Smiley Happy" /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 18 Sep 2009 21:10:23 GMT</pubDate>
    <dc:creator>andreas_b</dc:creator>
    <dc:date>2009-09-18T21:10:23Z</dc:date>
    <item>
      <title>iMX27 GPIO access</title>
      <link>https://community.nxp.com/t5/Other-NXP-Products/iMX27-GPIO-access/m-p/210831#M2344</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like to access some gpio (some in input, other in output) in a program to use with Led and button.&lt;/P&gt;&lt;P&gt;The code below seems to work but as no effect on the led itself (even if the DR is effectively change)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;May be I m not using the good offset in mmap (GPIO_BASE ?) at first I use 0x10015000 but after some search in the kernel source I tried with the virtual address 0xf4015000.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;PS: I checked the different value of DDIR (out), GIUS (inuse) and GPR and all seems fine.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would really appreciate some help here &lt;IMG alt=":smileyhappy:" class="emoticon emoticon-smileyhappy" id="smileyhappy" src="http://freescale.i.lithium.com/i/smilies/16x16_smiley-happy.gif" title="Smiley Happy" /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;
#include &amp;lt;stdlib.h&amp;gt;#include &amp;lt;stdio.h&amp;gt;#include &amp;lt;fcntl.h&amp;gt;#include &amp;lt;sys/mman.h&amp;gt;#include &amp;lt;linux/fb.h&amp;gt;#include &amp;lt;unistd.h&amp;gt;#include &amp;lt;stropts.h&amp;gt;#include &amp;lt;errno.h&amp;gt;unsigned long *memregs32;int memfd;#define GPIO_BASE 0xf4015000//#define GPIO_BASE 0x10015000void *trymmap (void *start, size_t length, int prot, int flags, int fd, off_t offset){ char *p; int aa; printf ("mmap(%X, %X, %X, %X, %X, %X) ... ", (unsigned int)start, length, prot, flags, fd, (unsigned int)offset); p = mmap (start, length, prot, flags, fd, offset); if (p == (char *)0xFFFFFFFF) { aa = errno;  printf ("failed. errno = %d\n", aa); }else { printf ("OK! (%X)\n", (unsigned int)p); } return p;}unsigned char initphys (void){ memfd = open("/dev/mem", O_RDWR); if (memfd == -1) { printf ("Open failed\n");  return 0; } printf ("/dev/mem opened successfully - fd = %d\n", memfd); memregs32 = trymmap(0, 0x10000, PROT_READ|PROT_WRITE, MAP_SHARED, memfd, GPIO_BASE); if (memregs32 == (unsigned long *)0xFFFFFFFF) return 0; return 1;}void closephys (void){ close (memfd);}int main(void){ int i; if (!initphys()) return 0; printf ("Reading GPIO pins...\n"); printf ("DDIR = %08X\n", memregs32[0x400]); printf ("OCR1 = %08X\n", memregs32[0x404]); printf ("OCR2 = %08X\n", memregs32[0x408]); memregs32[0x408] |= 0x300; printf ("OCR2 = %08X\n", memregs32[0x408]); printf ("ICONFA1 = %08X\n", memregs32[0x40C]); printf ("ICONFA2 = %08X\n", memregs32[0x410]); printf ("ICONFB1 = %08X\n", memregs32[0x414]); printf ("ICONFB2 = %08X\n", memregs32[0x418]); printf ("DR = %08X\n", memregs32[0x41C]); printf ("GIUS = %08X\n", memregs32[0x420]); printf ("SSR = %08X\n", memregs32[0x424]); printf ("ICR1 = %08X\n", memregs32[0x428]); printf ("ICR2 = %08X\n", memregs32[0x42C]); printf ("IMR = %08X\n", memregs32[0x430]); printf ("ISR = %08X\n", memregs32[0x434]); printf ("GPR = %08X\n", memregs32[0x438]); printf ("SWR = %08X\n", memregs32[0x43C]); printf ("PUEN = %08X\n", memregs32[0x440]);  printf ("Flash battery LED...\n"); for (i = 0; i &amp;lt; 9; i ++) { memregs32[0x41C] ^= 0x00100000;  printf ("%s\n", memregs32[0x41C] &amp;amp; 0x00100000 ? "on" : "off"); } closephys(); printf("test complete\n"); return 0;}&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&amp;nbsp;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 26 Aug 2009 14:53:24 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Other-NXP-Products/iMX27-GPIO-access/m-p/210831#M2344</guid>
      <dc:creator>quentin</dc:creator>
      <dc:date>2009-08-26T14:53:24Z</dc:date>
    </item>
    <item>
      <title>Re: iMX27 GPIO access</title>
      <link>https://community.nxp.com/t5/Other-NXP-Products/iMX27-GPIO-access/m-p/210832#M2345</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I'm facing the same kind of problem. Trying to draw a gpio-signal first low and then high but no matter what I attempt it doesn't work. No action at all while measuring with an oscilloscope so if you have come up with something new I would really appreciate if you could share it &lt;IMG alt=":smileyhappy:" class="emoticon emoticon-smileyhappy" id="smileyhappy" src="http://freescale.i.lithium.com/i/smilies/16x16_smiley-happy.gif" title="Smiley Happy" /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;(Or if someone else has some info?!)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Br,&lt;/P&gt;&lt;P&gt;Andreas&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 15 Sep 2009 23:00:13 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Other-NXP-Products/iMX27-GPIO-access/m-p/210832#M2345</guid>
      <dc:creator>andreas_b</dc:creator>
      <dc:date>2009-09-15T23:00:13Z</dc:date>
    </item>
    <item>
      <title>Re: iMX27 GPIO access</title>
      <link>https://community.nxp.com/t5/Other-NXP-Products/iMX27-GPIO-access/m-p/210833#M2346</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Well for now I use the sysfs interface to read my gpio but when I try to change the value of an output gpio, the change doesn't take effect even if no error is return.So I m stuck there.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;here an example : &lt;A href="http://docs.blackfin.uclinux.org/doku.php?id=linux-kernel:drivers:gpio-sysfs" target="test_blank"&gt;http://docs.blackfin.uclinux.org/doku.php?id=linux-kernel:drivers:gpio-sysfs&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It would be nice to know the gpio base address to use with mmap for the imx27.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 16 Sep 2009 14:55:26 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Other-NXP-Products/iMX27-GPIO-access/m-p/210833#M2346</guid>
      <dc:creator>quentin</dc:creator>
      <dc:date>2009-09-16T14:55:26Z</dc:date>
    </item>
    <item>
      <title>Re: iMX27 GPIO access</title>
      <link>https://community.nxp.com/t5/Other-NXP-Products/iMX27-GPIO-access/m-p/210834#M2347</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It should be the physical address as GPIO_BASE, i.e. 0x10015000&lt;/P&gt;&lt;P&gt;The problem seems to be that since the pointer *memregs32 is of type long every address from GPIO_BASE will actually be 4 bytes.&lt;/P&gt;&lt;P&gt;Therefore every address accessed using memregs32 should be divided by 4, something like:&lt;/P&gt;&lt;P&gt;...memregs32[0x400/4]...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I think... &lt;IMG alt=":smileyhappy:" class="emoticon emoticon-smileyhappy" id="smileyhappy" src="http://freescale.i.lithium.com/i/smilies/16x16_smiley-happy.gif" title="Smiley Happy" /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 18 Sep 2009 21:10:23 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Other-NXP-Products/iMX27-GPIO-access/m-p/210834#M2347</guid>
      <dc:creator>andreas_b</dc:creator>
      <dc:date>2009-09-18T21:10:23Z</dc:date>
    </item>
  </channel>
</rss>

