Skip to content
Snippets Groups Projects
Commit 88f91d13 authored by Måns Rullgård's avatar Måns Rullgård Committed by Stefano Babic
Browse files

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: default avatarMans Rullgard <mans@mansr.com>
Reviewed-by: default avatarStefano Babic <sbabic@denx.de>
parent fcbe8c56
No related branches found
No related tags found
No related merge requests found
...@@ -114,3 +114,18 @@ int gpio_free(unsigned gpio) ...@@ -114,3 +114,18 @@ int gpio_free(unsigned gpio)
{ {
return 0; 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);
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment