[MinnowBoard] GPIO mapping

John 'Warthog9' Hawley warthog9 at eaglescrag.net
Fri Sep 11 22:20:28 UTC 2015


On 09/11/2015 07:00 AM, Markus Maier wrote:
> Hay Nguonly <HNguonly at ...> writes:
> 
>>
>> Bill, thanks for that quick reply.
>>
>> Yes, that¹s where I got my example from, but I would like to know how that
>> GPIO number is derived?
>> Is it just arbitrary picked by someone, or there is a formula for it.
>>
>> Thanks
>> Hay
>>
> 
> 
> Hay,
> 
> see here how the numbers can be retrieved:
> https://github.com/MinnowBoard/minnow-max-extras/blob/master/lse/what_gpio_num.sh
> 
> But I cannot tell you how they have originally been set.


The GPIO mapping, under the OS (Linux in this case), is defined very
similarly to how hard drives or network interfaces are.  The process is
dependent on a couple of things:

- Dynamic GPIOs under Linux start at the highest number and count down
the available GPIOs (the GPIOs on the MAX / Turbot are dynamic)

- The order in which the drivers get loaded on the board determine which
bank of GPIOs starts the numbering.

So the "formula" per-se is

GPIO High # = 512

for x in $( GPIO Drivers ) {
	for y in $( Number of GPIO Chips ){
		for z in $( Number of GPIOs on the chip ){
			GPIO in driver defined order = GPIO High # - 1;
		}
	}
}

This is why you may see a difference on some kernels (Ubuntu comes to
mind as the I2C buses are backwards on that platform for sure, but I
need to check this to be sure) where the ordering *COUlD* be different
slightly.  This is fundamentally the same issue that SCSI disk drives,
ethernet ports, etc have had in the past and used other mechanisms to
make more explicit mappings.

Does this answer your question?

- John


More information about the elinux-MinnowBoard mailing list