# Fast GPIO - direct access to registers

**URL:** <https://forum.legato.io/t/fast-gpio-direct-access-to-registers/2593>\
**Category:** Uncategorized\
**Created:** [August 10, 2017, 8:13am UTC](https://forum.legato.io/t/fast-gpio-direct-access-to-registers/2593 "2017-08-10T08:13:10Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![johnofleek](https://avatars.discourse-cdn.com/v4/letter/j/e9bcb4/32.png) [@johnofleek](https://forum.legato.io/u/johnofleek)\
**Post date:** [August 10, 2017, 8:13am UTC](https://forum.legato.io/t/fast-gpio-direct-access-to-registers/2593/1 "2017-08-10T08:13:10Z")

</div>

Hi

It would useful to be able to carry out GPIO fast state changes and simultaneous multiple bit changes.

This is achieved on some other Linux platforms by setting or clearing bits in registers mapped at memory addresses. The following is an example for a different SoC and openWRT. I don’t know if this is a good example. But I do know that similar performance is obtainable with the Raspberry Pi SoC

[http://www.black-swift.com/wiki/index.php?title=Working\_with\_GPIOs\_(C/C%2B%2B)](http://www.black-swift.com/wiki/index.php?title=Working_with_GPIOs_(C/C%2B%2B))

Is this possible on the WP8548 and other Sierra WP devices?

Cheers John

---

<div class="post-metadata">

**Author:** ![achuang](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.legato.io/achuang/32/132_2.png) [@achuang](https://forum.legato.io/u/achuang)\
**Post date:** [August 22, 2017, 11:23pm UTC](https://forum.legato.io/t/fast-gpio-direct-access-to-registers/2593/2 "2017-08-22T23:23:02Z")

</div>

Hi John,

In general, Sierra does not allow unfettered access directly to registers. This could cause challenges with concurrency etc. and security concerns too.

Alan

---

<div class="post-metadata">

**Author:** ![johnofleek](https://avatars.discourse-cdn.com/v4/letter/j/e9bcb4/32.png) [@johnofleek](https://forum.legato.io/u/johnofleek)\
**Post date:** [September 7, 2017, 10:16am UTC](https://forum.legato.io/t/fast-gpio-direct-access-to-registers/2593/3 "2017-09-07T10:16:42Z")

</div>

Hi Alex

Yes that is understandable. But the performance of file based IO is very poor (as pointed out to me again by a customer today). Also I think the current latency through the IPC api also has a significant impact on IO performance.

Maybe the answer is for Sierra to supply a linkable library that hides the hardware implementation but has little impact on IO performance ?

I notice that there is an open issue in the release notes

> GPIO Service  
> Only one service is able to access a GPIO pin at a time

Perhaps when that issue is addressed the speed can be addressed as well?

Cheers

John

---

<div class="post-metadata">

**Author:** ![achuang](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.legato.io/achuang/32/132_2.png) [@achuang](https://forum.legato.io/u/achuang)\
**Post date:** [September 7, 2017, 9:14pm UTC](https://forum.legato.io/t/fast-gpio-direct-access-to-registers/2593/4 "2017-09-07T21:14:38Z")

</div>

Hi John,

May I use what you are trying to do, ‘bitbang’?

---

<div class="post-metadata">

**Author:** ![johnofleek](https://avatars.discourse-cdn.com/v4/letter/j/e9bcb4/32.png) [@johnofleek](https://forum.legato.io/u/johnofleek)\
**Post date:** [September 12, 2017, 1:08pm UTC](https://forum.legato.io/t/fast-gpio-direct-access-to-registers/2593/5 "2017-09-12T13:08:26Z")

</div>

Hi Alan

Originally someone asked me to implement a demo using a 1-wire device (bit bash) - not a good use case as the timing would be too tricky in Linux and so I didn’t post this on the forum.

Since then a couple of customers + @davidc have brought up the issue of long latency / slow IO for various reasons including parallel bus emulation via GPIO. I think in these cases the actual timing is not critical but bandwidth / latency is an issue.

Cheers

John

---

<div class="post-metadata">

**Author:** ![achuang](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.legato.io/achuang/32/132_2.png) [@achuang](https://forum.legato.io/u/achuang)\
**Post date:** [September 25, 2017, 6:42pm UTC](https://forum.legato.io/t/fast-gpio-direct-access-to-registers/2593/6 "2017-09-25T18:42:50Z")

</div>

Hi John,

Based on your use case, the way to go is to implement a kernel driver module that bit-bangs GPIOs and then load it via Legato.

Thanks,  
Alan

---

<div class="post-metadata">

**Author:** ![johnofleek](https://avatars.discourse-cdn.com/v4/letter/j/e9bcb4/32.png) [@johnofleek](https://forum.legato.io/u/johnofleek)\
**Post date:** [September 25, 2017, 7:08pm UTC](https://forum.legato.io/t/fast-gpio-direct-access-to-registers/2593/7 "2017-09-25T19:08:26Z")

</div>

Hi Alan

To implement the driver for good performance wouldn’t I need a the IC programmers guide for the GPIO (registers and addresses)?

Cheers

John

---

<div class="post-metadata">

**Author:** ![achuang](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.legato.io/achuang/32/132_2.png) [@achuang](https://forum.legato.io/u/achuang)\
**Post date:** [September 28, 2017, 10:28pm UTC](https://forum.legato.io/t/fast-gpio-direct-access-to-registers/2593/8 "2017-09-28T22:28:11Z")

</div>

John,

I suggest you give kernel module a try and let us know the result.

Cheers,  
Alan
