Daniel Lezcano | 7c15fad | 2016-02-18 15:57:43 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Power debug tool (powerdebug) |
Amit Arora | 39f2954 | 2010-09-14 12:03:22 +0530 | [diff] [blame] | 3 | * |
Daniel Lezcano | 7c15fad | 2016-02-18 15:57:43 +0000 | [diff] [blame] | 4 | * Copyright (C) 2016, Linaro Limited. |
Amit Arora | 39f2954 | 2010-09-14 12:03:22 +0530 | [diff] [blame] | 5 | * |
Daniel Lezcano | 7c15fad | 2016-02-18 15:57:43 +0000 | [diff] [blame] | 6 | * This program is free software; you can redistribute it and/or |
| 7 | * modify it under the terms of the GNU General Public License |
| 8 | * as published by the Free Software Foundation; either version 2 |
| 9 | * of the License, or (at your option) any later version. |
Amit Arora | 39f2954 | 2010-09-14 12:03:22 +0530 | [diff] [blame] | 10 | * |
Daniel Lezcano | 7c15fad | 2016-02-18 15:57:43 +0000 | [diff] [blame] | 11 | * This program is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | * GNU General Public License for more details. |
| 15 | * |
| 16 | * You should have received a copy of the GNU General Public License |
| 17 | * along with this program; if not, write to the Free Software |
| 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
| 19 | * |
| 20 | */ |
Amit Arora | 39f2954 | 2010-09-14 12:03:22 +0530 | [diff] [blame] | 21 | |
Amit Arora | e9e16b0 | 2010-08-03 10:15:20 +0530 | [diff] [blame] | 22 | #include <getopt.h> |
Daniel Lezcano | c5afe83 | 2011-03-23 14:37:36 +0100 | [diff] [blame] | 23 | #include <stdbool.h> |
Daniel Lezcano | 1562748 | 2011-06-15 15:45:12 +0200 | [diff] [blame] | 24 | #include <string.h> |
| 25 | #include <stdlib.h> |
| 26 | #include <stdio.h> |
| 27 | #include <errno.h> |
| 28 | #include <ncurses.h> |
Sanjay Singh Rawat | 83b37c3 | 2013-04-17 14:57:07 +0530 | [diff] [blame] | 29 | #include <signal.h> |
Daniel Lezcano | 192c1d2 | 2011-03-26 22:06:14 +0100 | [diff] [blame] | 30 | #include "display.h" |
Daniel Lezcano | db14580 | 2011-06-21 00:57:08 +0200 | [diff] [blame] | 31 | #include "mainloop.h" |
Amit Arora | e9e16b0 | 2010-08-03 10:15:20 +0530 | [diff] [blame] | 32 | #include "powerdebug.h" |
| 33 | |
Sanjay Singh Rawat | 83b37c3 | 2013-04-17 14:57:07 +0530 | [diff] [blame] | 34 | extern void sigwinch_handler(int); |
| 35 | |
Daniel Lezcano | 9db095c | 2016-02-18 13:05:01 +0000 | [diff] [blame] | 36 | #define REGULATOR_OPTION 0x01 |
| 37 | #define SENSOR_OPTION 0x02 |
| 38 | #define CLOCK_OPTION 0x04 |
| 39 | #define GPIO_OPTION 0x08 |
| 40 | |
| 41 | #define VERBOSE_OPTION 0x10 |
| 42 | #define DUMP_OPTION 0x20 |
| 43 | |
| 44 | #define DEFAULT_OPTION (REGULATOR_OPTION | SENSOR_OPTION | \ |
| 45 | CLOCK_OPTION | GPIO_OPTION) |
| 46 | |
Amit Arora | 422c52f | 2010-12-02 16:22:29 +0530 | [diff] [blame] | 47 | void usage(void) |
Amit Arora | e9e16b0 | 2010-08-03 10:15:20 +0530 | [diff] [blame] | 48 | { |
Amit Arora | 422c52f | 2010-12-02 16:22:29 +0530 | [diff] [blame] | 49 | printf("Usage: powerdebug [OPTIONS]\n"); |
| 50 | printf("\n"); |
| 51 | printf("powerdebug -d [ -r ] [ -s ] [ -c [ -p <clock-name> ] ] " |
| 52 | "[ -v ]\n"); |
| 53 | printf("powerdebug [ -r | -s | -c ]\n"); |
Amit Arora | 1755278 | 2010-12-02 12:23:14 +0530 | [diff] [blame] | 54 | printf(" -r, --regulator Show regulator information\n"); |
| 55 | printf(" -s, --sensor Show sensor information\n"); |
| 56 | printf(" -c, --clock Show clock information\n"); |
Amit Arora | 422c52f | 2010-12-02 16:22:29 +0530 | [diff] [blame] | 57 | printf(" -p, --findparents Show all parents for a particular" |
Amit Kucheria | a0adae4 | 2011-01-12 10:54:23 -0600 | [diff] [blame] | 58 | " clock\n"); |
Amit Arora | 1755278 | 2010-12-02 12:23:14 +0530 | [diff] [blame] | 59 | printf(" -t, --time Set ticktime in seconds (eg. 10.0)\n"); |
| 60 | printf(" -d, --dump Dump information once (no refresh)\n"); |
Amit Arora | 422c52f | 2010-12-02 16:22:29 +0530 | [diff] [blame] | 61 | printf(" -v, --verbose Verbose mode (use with -r and/or" |
Amit Kucheria | a0adae4 | 2011-01-12 10:54:23 -0600 | [diff] [blame] | 62 | " -s)\n"); |
Amit Arora | 1755278 | 2010-12-02 12:23:14 +0530 | [diff] [blame] | 63 | printf(" -V, --version Show Version\n"); |
| 64 | printf(" -h, --help Help\n"); |
Amit Arora | e9e16b0 | 2010-08-03 10:15:20 +0530 | [diff] [blame] | 65 | } |
| 66 | |
Amit Arora | 1755278 | 2010-12-02 12:23:14 +0530 | [diff] [blame] | 67 | void version() |
Amit Arora | e9e16b0 | 2010-08-03 10:15:20 +0530 | [diff] [blame] | 68 | { |
Amit Arora | 1755278 | 2010-12-02 12:23:14 +0530 | [diff] [blame] | 69 | printf("powerdebug version %s\n", VERSION); |
Amit Arora | e9e16b0 | 2010-08-03 10:15:20 +0530 | [diff] [blame] | 70 | } |
| 71 | |
Daniel Lezcano | 316bcae | 2011-03-23 14:37:30 +0100 | [diff] [blame] | 72 | /* |
| 73 | * Options: |
Daniel Lezcano | 716b23e | 2011-08-25 15:46:13 +0200 | [diff] [blame] | 74 | * -r, --regulator : regulators |
Daniel Lezcano | 316bcae | 2011-03-23 14:37:30 +0100 | [diff] [blame] | 75 | * -s, --sensor : sensors |
| 76 | * -c, --clock : clocks |
Daniel Lezcano | 716b23e | 2011-08-25 15:46:13 +0200 | [diff] [blame] | 77 | * -g, --gpio : gpios |
Daniel Lezcano | 316bcae | 2011-03-23 14:37:30 +0100 | [diff] [blame] | 78 | * -p, --findparents : clockname whose parents have to be found |
| 79 | * -t, --time : ticktime |
| 80 | * -d, --dump : dump |
| 81 | * -v, --verbose : verbose |
| 82 | * -V, --version : version |
| 83 | * -h, --help : help |
| 84 | * no option / default : show usage! |
| 85 | */ |
| 86 | |
| 87 | static struct option long_options[] = { |
| 88 | { "regulator", 0, 0, 'r' }, |
| 89 | { "sensor", 0, 0, 's' }, |
| 90 | { "clock", 0, 0, 'c' }, |
Daniel Lezcano | 716b23e | 2011-08-25 15:46:13 +0200 | [diff] [blame] | 91 | { "gpio", 0, 0, 'g' }, |
Daniel Lezcano | 316bcae | 2011-03-23 14:37:30 +0100 | [diff] [blame] | 92 | { "findparents", 1, 0, 'p' }, |
| 93 | { "time", 1, 0, 't' }, |
| 94 | { "dump", 0, 0, 'd' }, |
| 95 | { "verbose", 0, 0, 'v' }, |
| 96 | { "version", 0, 0, 'V' }, |
| 97 | { "help", 0, 0, 'h' }, |
| 98 | { 0, 0, 0, 0 } |
| 99 | }; |
| 100 | |
Daniel Lezcano | 316bcae | 2011-03-23 14:37:30 +0100 | [diff] [blame] | 101 | int getoptions(int argc, char *argv[], struct powerdebug_options *options) |
Amit Arora | e9e16b0 | 2010-08-03 10:15:20 +0530 | [diff] [blame] | 102 | { |
Daniel Lezcano | 316bcae | 2011-03-23 14:37:30 +0100 | [diff] [blame] | 103 | int c; |
Amit Arora | e9e16b0 | 2010-08-03 10:15:20 +0530 | [diff] [blame] | 104 | |
Daniel Lezcano | 316bcae | 2011-03-23 14:37:30 +0100 | [diff] [blame] | 105 | memset(options, 0, sizeof(*options)); |
| 106 | options->ticktime = 10; |
Daniel Lezcano | 558a6d5 | 2011-03-23 14:37:41 +0100 | [diff] [blame] | 107 | options->selectedwindow = -1; |
Amit Arora | e9e16b0 | 2010-08-03 10:15:20 +0530 | [diff] [blame] | 108 | |
Amit Arora | fefe8bf | 2010-08-05 13:31:20 +0530 | [diff] [blame] | 109 | while (1) { |
| 110 | int optindex = 0; |
Amit Arora | fefe8bf | 2010-08-05 13:31:20 +0530 | [diff] [blame] | 111 | |
Daniel Lezcano | 716b23e | 2011-08-25 15:46:13 +0200 | [diff] [blame] | 112 | c = getopt_long(argc, argv, "rscgp:t:dvVh", |
Daniel Lezcano | 316bcae | 2011-03-23 14:37:30 +0100 | [diff] [blame] | 113 | long_options, &optindex); |
Amit Arora | fefe8bf | 2010-08-05 13:31:20 +0530 | [diff] [blame] | 114 | if (c == -1) |
| 115 | break; |
| 116 | |
| 117 | switch (c) { |
Amit Arora | 6e774cd | 2010-10-28 11:31:24 +0530 | [diff] [blame] | 118 | case 'r': |
Daniel Lezcano | 9db095c | 2016-02-18 13:05:01 +0000 | [diff] [blame] | 119 | options->flags |= REGULATOR_OPTION; |
Daniel Lezcano | 558a6d5 | 2011-03-23 14:37:41 +0100 | [diff] [blame] | 120 | options->selectedwindow = REGULATOR; |
Amit Arora | 6e774cd | 2010-10-28 11:31:24 +0530 | [diff] [blame] | 121 | break; |
| 122 | case 's': |
Daniel Lezcano | 9db095c | 2016-02-18 13:05:01 +0000 | [diff] [blame] | 123 | options->flags |= SENSOR_OPTION; |
Daniel Lezcano | 558a6d5 | 2011-03-23 14:37:41 +0100 | [diff] [blame] | 124 | options->selectedwindow = SENSOR; |
Amit Arora | 6e774cd | 2010-10-28 11:31:24 +0530 | [diff] [blame] | 125 | break; |
| 126 | case 'c': |
Daniel Lezcano | 9db095c | 2016-02-18 13:05:01 +0000 | [diff] [blame] | 127 | options->flags |= CLOCK_OPTION; |
Daniel Lezcano | 558a6d5 | 2011-03-23 14:37:41 +0100 | [diff] [blame] | 128 | options->selectedwindow = CLOCK; |
Amit Arora | 6e774cd | 2010-10-28 11:31:24 +0530 | [diff] [blame] | 129 | break; |
Daniel Lezcano | 716b23e | 2011-08-25 15:46:13 +0200 | [diff] [blame] | 130 | case 'g': |
Daniel Lezcano | 9db095c | 2016-02-18 13:05:01 +0000 | [diff] [blame] | 131 | options->flags |= GPIO_OPTION; |
Daniel Lezcano | 716b23e | 2011-08-25 15:46:13 +0200 | [diff] [blame] | 132 | options->selectedwindow = GPIO; |
| 133 | break; |
Daniel Lezcano | 9db095c | 2016-02-18 13:05:01 +0000 | [diff] [blame] | 134 | case 'd': |
| 135 | options->flags |= DUMP_OPTION; |
| 136 | break; |
| 137 | case 'v': |
| 138 | options->flags |= VERBOSE_OPTION; |
| 139 | break; |
Amit Arora | f4fb810 | 2010-11-30 13:55:50 +0530 | [diff] [blame] | 140 | case 'p': |
Daniel Lezcano | 6e0c9c8 | 2011-03-26 22:06:07 +0100 | [diff] [blame] | 141 | options->clkname = strdup(optarg); |
| 142 | if (!options->clkname) { |
Daniel Lezcano | 9420fde | 2011-03-23 14:37:31 +0100 | [diff] [blame] | 143 | fprintf(stderr, "failed to allocate memory"); |
| 144 | return -1; |
| 145 | } |
Daniel Lezcano | 9db095c | 2016-02-18 13:05:01 +0000 | [diff] [blame] | 146 | options->flags |= (DUMP_OPTION | CLOCK_OPTION); |
Amit Arora | f4fb810 | 2010-11-30 13:55:50 +0530 | [diff] [blame] | 147 | break; |
Amit Arora | 6e774cd | 2010-10-28 11:31:24 +0530 | [diff] [blame] | 148 | case 't': |
Daniel Lezcano | 7f112da | 2011-03-23 14:37:32 +0100 | [diff] [blame] | 149 | options->ticktime = atoi(optarg); |
Amit Arora | 6e774cd | 2010-10-28 11:31:24 +0530 | [diff] [blame] | 150 | break; |
Amit Arora | 6e774cd | 2010-10-28 11:31:24 +0530 | [diff] [blame] | 151 | case 'V': |
| 152 | version(); |
| 153 | break; |
Amit Arora | 6e774cd | 2010-10-28 11:31:24 +0530 | [diff] [blame] | 154 | case '?': |
Daniel Lezcano | 316bcae | 2011-03-23 14:37:30 +0100 | [diff] [blame] | 155 | fprintf(stderr, "%s: Unknown option %c'.\n", |
Amit Kucheria | a0adae4 | 2011-01-12 10:54:23 -0600 | [diff] [blame] | 156 | argv[0], optopt); |
Amit Arora | 6e774cd | 2010-10-28 11:31:24 +0530 | [diff] [blame] | 157 | default: |
Daniel Lezcano | 316bcae | 2011-03-23 14:37:30 +0100 | [diff] [blame] | 158 | return -1; |
Amit Arora | fefe8bf | 2010-08-05 13:31:20 +0530 | [diff] [blame] | 159 | } |
Amit Arora | e9e16b0 | 2010-08-03 10:15:20 +0530 | [diff] [blame] | 160 | } |
Amit Arora | a06a730 | 2010-12-02 15:59:37 +0530 | [diff] [blame] | 161 | |
Daniel Lezcano | 934fc09 | 2011-03-26 22:06:18 +0100 | [diff] [blame] | 162 | /* No system specified to be dump, let's default to all */ |
Daniel Lezcano | 9db095c | 2016-02-18 13:05:01 +0000 | [diff] [blame] | 163 | if (!(options->flags & DEFAULT_OPTION)) |
| 164 | options->flags |= DEFAULT_OPTION; |
Amit Arora | fefe8bf | 2010-08-05 13:31:20 +0530 | [diff] [blame] | 165 | |
Daniel Lezcano | c9c1462 | 2011-03-26 22:06:10 +0100 | [diff] [blame] | 166 | if (options->selectedwindow == -1) |
Daniel Lezcano | 558a6d5 | 2011-03-23 14:37:41 +0100 | [diff] [blame] | 167 | options->selectedwindow = CLOCK; |
Amit Arora | e9e16b0 | 2010-08-03 10:15:20 +0530 | [diff] [blame] | 168 | |
Daniel Lezcano | 316bcae | 2011-03-23 14:37:30 +0100 | [diff] [blame] | 169 | return 0; |
| 170 | } |
| 171 | |
Daniel Lezcano | b25be4a | 2011-06-15 15:45:12 +0200 | [diff] [blame] | 172 | static int powerdebug_dump(struct powerdebug_options *options) |
Daniel Lezcano | 21c04d4 | 2011-03-26 22:06:04 +0100 | [diff] [blame] | 173 | { |
Daniel Lezcano | 9db095c | 2016-02-18 13:05:01 +0000 | [diff] [blame] | 174 | if (options->flags & REGULATOR_OPTION) |
Daniel Lezcano | b25be4a | 2011-06-15 15:45:12 +0200 | [diff] [blame] | 175 | regulator_dump(); |
Daniel Lezcano | b574671 | 2011-03-26 22:06:05 +0100 | [diff] [blame] | 176 | |
Daniel Lezcano | 9db095c | 2016-02-18 13:05:01 +0000 | [diff] [blame] | 177 | if (options->flags & CLOCK_OPTION) |
Daniel Lezcano | 597892a | 2011-06-15 15:45:12 +0200 | [diff] [blame] | 178 | clock_dump(options->clkname); |
Daniel Lezcano | b574671 | 2011-03-26 22:06:05 +0100 | [diff] [blame] | 179 | |
Daniel Lezcano | 9db095c | 2016-02-18 13:05:01 +0000 | [diff] [blame] | 180 | if (options->flags & SENSOR_OPTION) |
Daniel Lezcano | 3d0aef4 | 2011-06-15 15:45:12 +0200 | [diff] [blame] | 181 | sensor_dump(); |
Daniel Lezcano | b574671 | 2011-03-26 22:06:05 +0100 | [diff] [blame] | 182 | |
Daniel Lezcano | 9db095c | 2016-02-18 13:05:01 +0000 | [diff] [blame] | 183 | if (options->flags & GPIO_OPTION) |
Daniel Lezcano | 716b23e | 2011-08-25 15:46:13 +0200 | [diff] [blame] | 184 | gpio_dump(); |
| 185 | |
Daniel Lezcano | 21c04d4 | 2011-03-26 22:06:04 +0100 | [diff] [blame] | 186 | return 0; |
| 187 | } |
| 188 | |
Daniel Lezcano | b25be4a | 2011-06-15 15:45:12 +0200 | [diff] [blame] | 189 | static int powerdebug_display(struct powerdebug_options *options) |
Daniel Lezcano | c08f1f2 | 2011-03-26 22:06:21 +0100 | [diff] [blame] | 190 | { |
Daniel Lezcano | 7b3da50 | 2011-06-15 15:45:12 +0200 | [diff] [blame] | 191 | if (display_init(options->selectedwindow)) { |
Daniel Lezcano | c08f1f2 | 2011-03-26 22:06:21 +0100 | [diff] [blame] | 192 | printf("failed to initialize display\n"); |
| 193 | return -1; |
| 194 | } |
| 195 | |
Daniel Lezcano | db14580 | 2011-06-21 00:57:08 +0200 | [diff] [blame] | 196 | if (mainloop(options->ticktime * 1000)) |
Daniel Lezcano | c08f1f2 | 2011-03-26 22:06:21 +0100 | [diff] [blame] | 197 | return -1; |
| 198 | |
| 199 | return 0; |
| 200 | } |
| 201 | |
Daniel Lezcano | 6e0c9c8 | 2011-03-26 22:06:07 +0100 | [diff] [blame] | 202 | static struct powerdebug_options *powerdebug_init(void) |
| 203 | { |
| 204 | struct powerdebug_options *options; |
| 205 | |
Daniel Lezcano | 188ff0f | 2016-02-18 15:40:12 +0000 | [diff] [blame] | 206 | signal(SIGWINCH, sigwinch_handler); |
| 207 | |
Daniel Lezcano | 6e0c9c8 | 2011-03-26 22:06:07 +0100 | [diff] [blame] | 208 | options = malloc(sizeof(*options)); |
| 209 | if (!options) |
| 210 | return NULL; |
| 211 | |
Daniel Lezcano | 6e0c9c8 | 2011-03-26 22:06:07 +0100 | [diff] [blame] | 212 | return options; |
| 213 | } |
| 214 | |
Daniel Lezcano | 0051f4f | 2011-03-23 14:37:34 +0100 | [diff] [blame] | 215 | int main(int argc, char **argv) |
| 216 | { |
| 217 | struct powerdebug_options *options; |
Daniel Lezcano | b25be4a | 2011-06-15 15:45:12 +0200 | [diff] [blame] | 218 | int ret; |
Daniel Lezcano | 0051f4f | 2011-03-23 14:37:34 +0100 | [diff] [blame] | 219 | |
Sanjay Singh Rawat | 9fe0c05 | 2013-02-22 17:57:18 +0530 | [diff] [blame] | 220 | #ifdef __ANDROID__ |
| 221 | if (setenv("TERM", "xterm", 1) < 0) { |
| 222 | fprintf(stderr, "setenv failure"); |
| 223 | return 1; |
| 224 | } |
| 225 | if (setenv("TERMINFO", "/system/etc/terminfo", 1) < 0) { |
| 226 | fprintf(stderr, "setenv failure"); |
| 227 | return 1; |
| 228 | } |
| 229 | #endif |
Daniel Lezcano | 6e0c9c8 | 2011-03-26 22:06:07 +0100 | [diff] [blame] | 230 | options = powerdebug_init(); |
Daniel Lezcano | 0051f4f | 2011-03-23 14:37:34 +0100 | [diff] [blame] | 231 | if (!options) { |
Daniel Lezcano | 6e0c9c8 | 2011-03-26 22:06:07 +0100 | [diff] [blame] | 232 | fprintf(stderr, "not enough memory to allocate options\n"); |
Daniel Lezcano | 0051f4f | 2011-03-23 14:37:34 +0100 | [diff] [blame] | 233 | return 1; |
| 234 | } |
| 235 | |
Daniel Lezcano | c08f1f2 | 2011-03-26 22:06:21 +0100 | [diff] [blame] | 236 | if (getoptions(argc, argv, options)) { |
| 237 | usage(); |
| 238 | return 1; |
| 239 | } |
| 240 | |
Daniel Lezcano | db14580 | 2011-06-21 00:57:08 +0200 | [diff] [blame] | 241 | if (mainloop_init()) { |
| 242 | fprintf(stderr, "failed to initialize the mainloop\n"); |
| 243 | return 1; |
| 244 | } |
| 245 | |
Daniel Lezcano | 188ff0f | 2016-02-18 15:40:12 +0000 | [diff] [blame] | 246 | if ((options->flags & REGULATOR_OPTION) && regulator_init()) { |
Sanjay Singh Rawat | 5fef005 | 2013-04-17 15:02:01 +0530 | [diff] [blame] | 247 | printf("failed to initialize regulator\n"); |
Daniel Lezcano | 9db095c | 2016-02-18 13:05:01 +0000 | [diff] [blame] | 248 | options->flags &= ~REGULATOR_OPTION; |
Daniel Lezcano | 4aab2fe | 2011-03-26 22:05:53 +0100 | [diff] [blame] | 249 | } |
Daniel Lezcano | 0051f4f | 2011-03-23 14:37:34 +0100 | [diff] [blame] | 250 | |
Daniel Lezcano | 188ff0f | 2016-02-18 15:40:12 +0000 | [diff] [blame] | 251 | if ((options->flags & CLOCK_OPTION) && clock_init()) { |
Daniel Lezcano | f0e0665 | 2011-03-26 22:06:19 +0100 | [diff] [blame] | 252 | printf("failed to initialize clock details (check debugfs)\n"); |
Daniel Lezcano | 9db095c | 2016-02-18 13:05:01 +0000 | [diff] [blame] | 253 | options->flags &= ~CLOCK_OPTION; |
Daniel Lezcano | f0e0665 | 2011-03-26 22:06:19 +0100 | [diff] [blame] | 254 | } |
| 255 | |
Daniel Lezcano | 188ff0f | 2016-02-18 15:40:12 +0000 | [diff] [blame] | 256 | if ((options->flags & SENSOR_OPTION) && sensor_init()) { |
Daniel Lezcano | 3d0aef4 | 2011-06-15 15:45:12 +0200 | [diff] [blame] | 257 | printf("failed to initialize sensors\n"); |
Daniel Lezcano | 9db095c | 2016-02-18 13:05:01 +0000 | [diff] [blame] | 258 | options->flags &= SENSOR_OPTION; |
Daniel Lezcano | 3d0aef4 | 2011-06-15 15:45:12 +0200 | [diff] [blame] | 259 | } |
| 260 | |
Daniel Lezcano | 188ff0f | 2016-02-18 15:40:12 +0000 | [diff] [blame] | 261 | if ((options->flags & GPIO_OPTION) && gpio_init()) { |
Daniel Lezcano | 716b23e | 2011-08-25 15:46:13 +0200 | [diff] [blame] | 262 | printf("failed to initialize gpios\n"); |
Daniel Lezcano | 9db095c | 2016-02-18 13:05:01 +0000 | [diff] [blame] | 263 | options->flags &= GPIO_OPTION; |
Daniel Lezcano | 716b23e | 2011-08-25 15:46:13 +0200 | [diff] [blame] | 264 | } |
| 265 | |
Daniel Lezcano | 9db095c | 2016-02-18 13:05:01 +0000 | [diff] [blame] | 266 | ret = options->flags & DUMP_OPTION ? powerdebug_dump(options) : |
Daniel Lezcano | b25be4a | 2011-06-15 15:45:12 +0200 | [diff] [blame] | 267 | powerdebug_display(options); |
Daniel Lezcano | 21c04d4 | 2011-03-26 22:06:04 +0100 | [diff] [blame] | 268 | |
Daniel Lezcano | c08f1f2 | 2011-03-26 22:06:21 +0100 | [diff] [blame] | 269 | return ret < 0; |
Amit Arora | e9e16b0 | 2010-08-03 10:15:20 +0530 | [diff] [blame] | 270 | } |