plug the gpio subsys with the main function

Let's create the command options parameters and plug the gpio code
with the main code.

Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
diff --git a/powerdebug.c b/powerdebug.c
index b4575c4..cc9e871 100644
--- a/powerdebug.c
+++ b/powerdebug.c
@@ -24,6 +24,7 @@
 #include "display.h"
 #include "clocks.h"
 #include "sensor.h"
+#include "gpio.h"
 #include "mainloop.h"
 #include "powerdebug.h"
 
@@ -54,9 +55,10 @@
 
 /*
  * Options:
- * -r, --regulator      : regulator
+ * -r, --regulator      : regulators
  * -s, --sensor	 	: sensors
  * -c, --clock	  	: clocks
+ * -g, --gpio           : gpios
  * -p, --findparents    : clockname whose parents have to be found
  * -t, --time		: ticktime
  * -d, --dump		: dump
@@ -70,6 +72,7 @@
 	{ "regulator", 0, 0, 'r' },
 	{ "sensor", 0, 0, 's' },
 	{ "clock",  0, 0, 'c' },
+	{ "gpio",  0, 0, 'g' },
 	{ "findparents", 1, 0, 'p' },
 	{ "time", 1, 0, 't' },
 	{ "dump", 0, 0, 'd' },
@@ -84,6 +87,7 @@
 	bool regulators;
 	bool sensors;
 	bool clocks;
+	bool gpios;
 	bool dump;
 	unsigned int ticktime;
 	int selectedwindow;
@@ -101,7 +105,7 @@
 	while (1) {
 		int optindex = 0;
 
-		c = getopt_long(argc, argv, "rscp:t:dvVh",
+		c = getopt_long(argc, argv, "rscgp:t:dvVh",
 				long_options, &optindex);
 		if (c == -1)
 			break;
@@ -119,6 +123,10 @@
 			options->clocks = true;
 			options->selectedwindow = CLOCK;
 			break;
+		case 'g':
+			options->gpios = true;
+			options->selectedwindow = GPIO;
+			break;
 		case 'p':
 			options->clkname = strdup(optarg);
 			if (!options->clkname) {
@@ -149,8 +157,10 @@
 	}
 
 	/* No system specified to be dump, let's default to all */
-	if (!options->regulators && !options->clocks && !options->sensors)
-		options->regulators = options->clocks = options->sensors = true;
+	if (!options->regulators && !options->clocks &&
+	    !options->sensors && !options->gpios)
+		options->regulators = options->clocks =
+			options->sensors = options->gpios = true;
 
 	if (options->selectedwindow == -1)
 		options->selectedwindow = CLOCK;
@@ -169,6 +179,9 @@
 	if (options->sensors)
 		sensor_dump();
 
+	if (options->gpios)
+		gpio_dump();
+
 	return 0;
 }
 
@@ -234,6 +247,11 @@
 		options->sensors = false;
 	}
 
+	if (gpio_init()) {
+		printf("failed to initialize gpios\n");
+		options->gpios = false;
+	}
+
 	ret = options->dump ? powerdebug_dump(options) :
 		powerdebug_display(options);