[U-Boot] Blackfin: cmd_gpio port/pin naming

Andreas Pretzsch apr at cn-eng.de
Mon Jan 10 16:59:25 CET 2011


Am Freitag, den 07.01.2011, 17:38 -0500 schrieb Mike Frysinger: 
> On Friday, January 07, 2011 15:50:30 Andreas Pretzsch wrote:
> > the Blackfin U-Boot GPIO command (see "arch/blackfin/cpu/cmd_gpio.c")
> > specifies the port/pin naming in the form "[p][port]<#>", e.g. PF11.
> > The pin portion of the specified GPIO is limited to 0..15.
> > While this is correct for Blackfins with different bank names (e.g.
> > BF537 with PF, PG, PH), it's not sufficient for Blackfins with linear
> > naming like the BF561 (PF0..PF47).
> 
> if we cut out the friendly port naming, the rest of the code is no longer 
> Blackfin specific.  so what i had been thinking of doing at some point was 
> dropping that as a requirement and making it a "nice" feature so it could be 
> moved into common/cmd_gpio.c for everyone to use.

Sounds like a good idea to me.
As your code already uses the Linux GPIO conventions and naming (without
the gpio_chip stuff, which is not necessary for a bootloader IMHO), it'd
be a solid base for that.

Mr. Denk, are there any plans for a generic GPIO layer in U-Boot ?


> so if we rip out that part and just make it something like:
> ...
> #ifndef name_to_gpio
> #define name_to_gpio(name) simple_strtoul(name, NULL, 10)
> #endif

Personally, I'd go with arch specific functions, following the Linux
codebase, something like:
#ifdef CONFIG_GENERIC_GPIO
#include <asm/gpio.h>
#else
static inline int name_to_gpio(char *name)
{
	return simple_strtoul(name, NULL, 10);
}
...
#endif


> ...
> ulong pin = name_to_gpio(argv[2]);
> if (!gpio_is_valid(pin))
> 	goto usage;
> ...
> 
> although perhaps in your case, we can just change "if (pin > 15)" to "if 
> (!gpio_is_valid(pin))" and forget about the people who do PF34 on parts that 
> only have PF0..PF15 (they'll instead get like PH4 or whatever).

Would ACK that. Won't break any (correct) scripts out in the field and
solves the BF561 gpio issue with minimal effort.
I'll send a patch the next couple of minutes.


-- 

carpe noctem engineering
Ingenieurbuero fuer Hard- & Software-Entwicklung Andreas Pretzsch
Dipl.-Ing. (FH) Andreas Pretzsch          Tel. +49-(0)731-5521572
Hahnengasse 3                             Fax: +49-(0)731-5521573
89073 Ulm, Germany                        email: apr at cn-eng.de




More information about the U-Boot mailing list