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