mirror of
https://github.com/Fishwaldo/u-boot.git
synced 2025-07-23 23:33:01 +00:00
gpio: mxs: add name_to_gpio() function
Override the default name_to_gpio() function with one that accepts strings of the form bank:pin. If a colon is present in the provided name, it behaves like the default version. This lets the "gpio" command work with sane names rather than requiring the user to enter the bank/pin composite in decimal. Signed-off-by: Mans Rullgard <mans@mansr.com> Reviewed-by: Stefano Babic <sbabic@denx.de>
This commit is contained in:
parent
fcbe8c5674
commit
88f91d1375
1 changed files with 15 additions and 0 deletions
|
@ -114,3 +114,18 @@ int gpio_free(unsigned gpio)
|
|||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int name_to_gpio(const char *name)
|
||||
{
|
||||
unsigned bank, pin;
|
||||
char *end;
|
||||
|
||||
bank = simple_strtoul(name, &end, 10);
|
||||
|
||||
if (!*end || *end != ':')
|
||||
return bank;
|
||||
|
||||
pin = simple_strtoul(end + 1, NULL, 10);
|
||||
|
||||
return (bank << MXS_PAD_BANK_SHIFT) | (pin << MXS_PAD_PIN_SHIFT);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue