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