summaryrefslogtreecommitdiffstats
path: root/drivers/gpio
diff options
context:
space:
mode:
authorSebastian Hesselbarth <sebastian.hesselbarth@gmail.com>2013-11-09 14:24:08 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2013-11-11 09:05:35 +0100
commitfcc25285a2b98afd4e6c2324093b4f52f59a26d3 (patch)
tree7d105d64d89ce08fd51c7f17ce39ae6794d242ad /drivers/gpio
parented4348e8b249b56c493519aefeb72c3a8e92737e (diff)
downloadbarebox-fcc25285a2b98afd4e6c2324093b4f52f59a26d3.tar.gz
barebox-fcc25285a2b98afd4e6c2324093b4f52f59a26d3.tar.xz
gpiolib: make gpiolib command more verbose
This adds some more printf information to gpiolib command, like the gpiochip handling a specific gpio. Also, current direction and value of the gpio are printed, if the gpiochip provides the corresponding callbacks. Signed-off-by: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'drivers/gpio')
-rw-r--r--drivers/gpio/gpiolib.c24
1 files changed, 21 insertions, 3 deletions
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index ca6e8adab4..b7db596519 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -228,16 +228,34 @@ static int do_gpiolib(int argc, char *argv[])
int i;
printf("gpiolib: gpio lists\n");
- printf("%*crequested label\n", 11, ' ');
for (i = 0; i < ARCH_NR_GPIOS; i++) {
struct gpio_info *gi = &gpio_desc[i];
+ int val = -1, dir = -1;
if (!gi->chip)
continue;
- printf("gpio %*d: %*s %s\n", 4,
- i, 9, gi->requested ? "true" : "false",
+ /* print chip information and header on first gpio */
+ if (gi->chip->base == i) {
+ printf("\ngpios %u-%u, chip %s:\n",
+ gi->chip->base,
+ gi->chip->base + gi->chip->ngpio - 1,
+ gi->chip->dev->name);
+ printf("%*cdir val requested label\n", 13, ' ');
+ }
+
+ if (gi->chip->ops->get_direction)
+ dir = gi->chip->ops->get_direction(gi->chip,
+ i - gi->chip->base);
+ if (gi->chip->ops->get)
+ val = gi->chip->ops->get(gi->chip,
+ i - gi->chip->base);
+
+ printf(" gpio %*d: %*s %*s %*s %s\n", 4, i,
+ 3, (dir < 0) ? "unk" : ((dir == GPIO_DIR_IN) ? "in" : "out"),
+ 3, (val < 0) ? "unk" : ((val == 0) ? "lo" : "hi"),
+ 9, gi->requested ? "true" : "false",
gi->label ? gi->label : "");
}