[PATCH 2/2] gpiolib: add command to dump the current gpio status
Jean-Christophe PLAGNIOL-VILLARD
plagnioj at jcrosoft.com
Fri Dec 21 08:26:09 EST 2012
This will allow to known which gpio is requested by what
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
---
drivers/gpio/gpio.c | 37 +++++++++++++++++++++++++++++++++++++
1 file changed, 37 insertions(+)
diff --git a/drivers/gpio/gpio.c b/drivers/gpio/gpio.c
index ed9f923..d37f5a0 100644
--- a/drivers/gpio/gpio.c
+++ b/drivers/gpio/gpio.c
@@ -1,4 +1,6 @@
#include <common.h>
+#include <command.h>
+#include <complete.h>
#include <gpio.h>
#include <errno.h>
#include <malloc.h>
@@ -198,3 +200,38 @@ int gpio_get_num(struct device_d *dev, int gpio)
return -ENODEV;
}
+
+#ifdef CONFIG_CMD_GPIO
+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];
+
+ if (!gi->chip)
+ continue;
+
+ printf("gpio %*d: %*s %s\n", 4,
+ i, 9, gi->requested ? "true" : "false",
+ gi->label ? gi->label : "");
+ }
+
+ return 0;
+}
+
+BAREBOX_CMD_HELP_START(gpiolib)
+BAREBOX_CMD_HELP_USAGE("gpiolib\n")
+BAREBOX_CMD_HELP_SHORT("dump current registered gpio\n");
+BAREBOX_CMD_HELP_END
+
+BAREBOX_CMD_START(gpiolib)
+ .cmd = do_gpiolib,
+ .usage = "dump current registered gpio",
+ BAREBOX_CMD_HELP(cmd_gpiolib_help)
+ BAREBOX_CMD_COMPLETE(empty_complete)
+BAREBOX_CMD_END
+#endif
--
1.7.10.4
More information about the barebox
mailing list