Acces GPIO in a different way


At the moment I’m trying to get the fasted blinking led as possible.
I have already used to example provided by you (link) to acces the GPIO. This resulted in a roughly 200 kHz refresh cycle. But if possible I want an even faster GPIO because I want to address multiple GPIO’s within a certain amount of time.

On the internet I read that some using a iMX6D in Linux achieved different speeds with different kind of routines. This where his measurements:

  1. Using sysfs (bash/c) [userspace]: ~3500Hz (own measurement ~200kHz)
  2. calling /dev/mem using mmap [userspace]: ~800kHz
  3. using gpio.h in a simple kernel module [kernelspace]: ~280kHz
  4. ioremap() with writel [kernelspace] : ~1.6MHz
  5. ioremap() with pointers [kernelspace]: ~5.5MHz

So I have already test the first statement and got ~200 kHz for 1 GPIO. At the moment I’m trying statement 2. I get some values in return (how to do this I got from other forums, but most of the time they are doing the same) but not yet the ones I’m looking for as stated in the datasheet of the iMX6 (yes I have gone through the ~4000 of part 1).

So my question is, is it even possible to address the GPIO in any of the other statements except statement 1 (becuase this already works)?

I will be premature in saying this but I know how to use registers on the processor level and that a bit shift left or right can be disastrous.

ps. I’m using an Apalis iMX6Q with 2GB with Linux running on it.

Any information will be very welcome.

Kind regards,


Update, I get the good values when using statement 2 in my previous post. With this I get an toggle speed of around 1.25 MHz for 1 GPIO.
When I measure with an oscilloscope I get very ugly signal but that is totally logical, because of the speed.

Is is possible to set the clock speeds for the GPIO (IPG) faster?


I assume all of them work.

Version 2., 4., 5. are somewhat problematic since you bypass of whatever handling of the gpio controller the kernel is doing. AFAIK it currently works, however future kernel version could decide to keep a local copies of the gpio controller’s registers and work with them instead of reading back the registers.

The maximum IPG clock according to the reference manual is 66.5 MHz. (Table 18-4. System Clock Frequency Values). It is currently set to 66MHz some were in the kernel. I don’t think that an increase of less than 1% is worth messing with this central clock.