Amit Arora | 728e0c9 | 2010-09-14 12:06:09 +0530 | [diff] [blame] | 1 | /******************************************************************************* |
Amit Kucheria | c0e17fc | 2011-01-17 09:35:52 +0200 | [diff] [blame] | 2 | * Copyright (C) 2010, Linaro Limited. |
Amit Arora | 728e0c9 | 2010-09-14 12:06:09 +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 |
Daniel Lezcano | 2adc48d | 2011-06-08 23:30:01 +0200 | [diff] [blame] | 14 | * |
| 15 | * Daniel Lezcano <daniel.lezcano@linaro.org> (IBM Corporation) |
| 16 | * - Rewrote code and API |
| 17 | * |
Amit Arora | 728e0c9 | 2010-09-14 12:06:09 +0530 | [diff] [blame] | 18 | *******************************************************************************/ |
| 19 | |
Daniel Lezcano | 141c048 | 2011-06-08 23:30:00 +0200 | [diff] [blame] | 20 | #ifndef _GNU_SOURCE |
| 21 | #define _GNU_SOURCE |
Daniel Lezcano | 9dc3fb3 | 2011-03-26 22:06:08 +0100 | [diff] [blame] | 22 | #include <stdio.h> |
Daniel Lezcano | 141c048 | 2011-06-08 23:30:00 +0200 | [diff] [blame] | 23 | #undef _GNU_SOURCE |
| 24 | #endif |
Daniel Lezcano | 9dc3fb3 | 2011-03-26 22:06:08 +0100 | [diff] [blame] | 25 | #include <mntent.h> |
Daniel Lezcano | ef32319 | 2011-03-26 22:06:20 +0100 | [diff] [blame] | 26 | #include <sys/stat.h> |
Daniel Lezcano | 9dc3fb3 | 2011-03-26 22:06:08 +0100 | [diff] [blame] | 27 | |
Amit Arora | 728e0c9 | 2010-09-14 12:06:09 +0530 | [diff] [blame] | 28 | #include "powerdebug.h" |
Amit Arora | ed3e565 | 2010-10-27 12:02:53 +0530 | [diff] [blame] | 29 | #include "clocks.h" |
Daniel Lezcano | c193b60 | 2011-06-08 23:30:00 +0200 | [diff] [blame] | 30 | #include "tree.h" |
Daniel Lezcano | 88b38e3 | 2011-06-15 15:45:12 +0200 | [diff] [blame] | 31 | #include "utils.h" |
Amit Arora | 24ed7d1 | 2010-09-14 12:12:58 +0530 | [diff] [blame] | 32 | |
Daniel Lezcano | c45662b | 2011-06-08 23:30:00 +0200 | [diff] [blame] | 33 | struct clock_info { |
Daniel Lezcano | c45662b | 2011-06-08 23:30:00 +0200 | [diff] [blame] | 34 | int flags; |
| 35 | int rate; |
| 36 | int usecount; |
Daniel Lezcano | 2adc48d | 2011-06-08 23:30:01 +0200 | [diff] [blame] | 37 | bool expanded; |
Daniel Lezcano | 9d5431c | 2011-06-08 23:30:00 +0200 | [diff] [blame] | 38 | char *prefix; |
Daniel Lezcano | c45662b | 2011-06-08 23:30:00 +0200 | [diff] [blame] | 39 | } *clocks_info; |
| 40 | |
Daniel Lezcano | 9d5431c | 2011-06-08 23:30:00 +0200 | [diff] [blame] | 41 | static struct tree *clock_tree = NULL; |
Daniel Lezcano | c193b60 | 2011-06-08 23:30:00 +0200 | [diff] [blame] | 42 | |
Daniel Lezcano | 9dc3fb3 | 2011-03-26 22:06:08 +0100 | [diff] [blame] | 43 | static int locate_debugfs(char *clk_path) |
| 44 | { |
| 45 | const char *mtab = "/proc/mounts"; |
| 46 | struct mntent *mntent; |
| 47 | int ret = -1; |
| 48 | FILE *file = NULL; |
| 49 | |
| 50 | file = setmntent(mtab, "r"); |
| 51 | if (!file) |
| 52 | return -1; |
| 53 | |
| 54 | while ((mntent = getmntent(file))) { |
| 55 | |
| 56 | if (strcmp(mntent->mnt_type, "debugfs")) |
| 57 | continue; |
| 58 | |
| 59 | strcpy(clk_path, mntent->mnt_dir); |
| 60 | ret = 0; |
| 61 | break; |
| 62 | } |
| 63 | |
| 64 | fclose(file); |
| 65 | return ret; |
| 66 | } |
| 67 | |
Daniel Lezcano | 2adc48d | 2011-06-08 23:30:01 +0200 | [diff] [blame] | 68 | static struct clock_info *clock_alloc(void) |
Amit Arora | 24ed7d1 | 2010-09-14 12:12:58 +0530 | [diff] [blame] | 69 | { |
Daniel Lezcano | 2adc48d | 2011-06-08 23:30:01 +0200 | [diff] [blame] | 70 | struct clock_info *ci; |
Daniel Lezcano | 9dc3fb3 | 2011-03-26 22:06:08 +0100 | [diff] [blame] | 71 | |
Daniel Lezcano | 2adc48d | 2011-06-08 23:30:01 +0200 | [diff] [blame] | 72 | ci = malloc(sizeof(*ci)); |
| 73 | if (ci) |
| 74 | memset(ci, 0, sizeof(*ci)); |
Daniel Lezcano | c5a65bf | 2011-03-26 22:06:11 +0100 | [diff] [blame] | 75 | |
Daniel Lezcano | 2adc48d | 2011-06-08 23:30:01 +0200 | [diff] [blame] | 76 | return ci; |
Amit Arora | 24ed7d1 | 2010-09-14 12:12:58 +0530 | [diff] [blame] | 77 | } |
Amit Arora | 728e0c9 | 2010-09-14 12:06:09 +0530 | [diff] [blame] | 78 | |
Daniel Lezcano | afe6225 | 2011-06-08 23:30:00 +0200 | [diff] [blame] | 79 | static inline const char *clock_rate(int *rate) |
Daniel Lezcano | c671833 | 2011-03-23 14:37:39 +0100 | [diff] [blame] | 80 | { |
Daniel Lezcano | afe6225 | 2011-06-08 23:30:00 +0200 | [diff] [blame] | 81 | int r; |
Daniel Lezcano | c671833 | 2011-03-23 14:37:39 +0100 | [diff] [blame] | 82 | |
Daniel Lezcano | afe6225 | 2011-06-08 23:30:00 +0200 | [diff] [blame] | 83 | /* GHZ */ |
| 84 | r = *rate >> 30; |
| 85 | if (r) { |
| 86 | *rate = r; |
| 87 | return "GHZ"; |
| 88 | } |
Daniel Lezcano | c671833 | 2011-03-23 14:37:39 +0100 | [diff] [blame] | 89 | |
Daniel Lezcano | afe6225 | 2011-06-08 23:30:00 +0200 | [diff] [blame] | 90 | /* MHZ */ |
| 91 | r = *rate >> 20; |
| 92 | if (r) { |
| 93 | *rate = r; |
| 94 | return "MHZ"; |
| 95 | } |
Daniel Lezcano | c671833 | 2011-03-23 14:37:39 +0100 | [diff] [blame] | 96 | |
Daniel Lezcano | afe6225 | 2011-06-08 23:30:00 +0200 | [diff] [blame] | 97 | /* KHZ */ |
| 98 | r = *rate >> 10; |
| 99 | if (r) { |
| 100 | *rate = r; |
| 101 | return "KHZ"; |
| 102 | } |
| 103 | |
| 104 | return ""; |
Daniel Lezcano | c671833 | 2011-03-23 14:37:39 +0100 | [diff] [blame] | 105 | } |
| 106 | |
Daniel Lezcano | afe6225 | 2011-06-08 23:30:00 +0200 | [diff] [blame] | 107 | static int dump_clock_cb(struct tree *t, void *data) |
Daniel Lezcano | ef32319 | 2011-03-26 22:06:20 +0100 | [diff] [blame] | 108 | { |
Daniel Lezcano | afe6225 | 2011-06-08 23:30:00 +0200 | [diff] [blame] | 109 | struct clock_info *clk = t->private; |
| 110 | struct clock_info *pclk; |
| 111 | const char *unit; |
| 112 | int ret = 0; |
| 113 | int rate = clk->rate; |
Daniel Lezcano | ef32319 | 2011-03-26 22:06:20 +0100 | [diff] [blame] | 114 | |
Daniel Lezcano | afe6225 | 2011-06-08 23:30:00 +0200 | [diff] [blame] | 115 | if (!t->parent) { |
| 116 | printf("/\n"); |
| 117 | clk->prefix = ""; |
| 118 | return 0; |
Daniel Lezcano | ef32319 | 2011-03-26 22:06:20 +0100 | [diff] [blame] | 119 | } |
| 120 | |
Daniel Lezcano | afe6225 | 2011-06-08 23:30:00 +0200 | [diff] [blame] | 121 | pclk = t->parent->private; |
| 122 | |
| 123 | if (!clk->prefix) |
| 124 | ret = asprintf(&clk->prefix, "%s%s%s", pclk->prefix, |
| 125 | t->depth > 1 ? " ": "", t->next ? "|" : " "); |
| 126 | if (ret < 0) |
| 127 | return -1; |
| 128 | |
| 129 | unit = clock_rate(&rate); |
| 130 | |
| 131 | printf("%s%s-- %s (flags:0x%x, usecount:%d, rate: %d %s)\n", |
| 132 | clk->prefix, !t->next ? "`" : "", t->name, clk->flags, |
| 133 | clk->usecount, rate, unit); |
| 134 | |
| 135 | return 0; |
Daniel Lezcano | ef32319 | 2011-03-26 22:06:20 +0100 | [diff] [blame] | 136 | } |
| 137 | |
Daniel Lezcano | afe6225 | 2011-06-08 23:30:00 +0200 | [diff] [blame] | 138 | int dump_clock_info(void) |
Daniel Lezcano | c671833 | 2011-03-23 14:37:39 +0100 | [diff] [blame] | 139 | { |
Daniel Lezcano | afe6225 | 2011-06-08 23:30:00 +0200 | [diff] [blame] | 140 | return tree_for_each(clock_tree, dump_clock_cb, NULL); |
| 141 | } |
Daniel Lezcano | c671833 | 2011-03-23 14:37:39 +0100 | [diff] [blame] | 142 | |
Daniel Lezcano | 3e38e0f | 2011-06-08 23:30:00 +0200 | [diff] [blame] | 143 | static int dump_all_parents(char *clkarg) |
Daniel Lezcano | afe6225 | 2011-06-08 23:30:00 +0200 | [diff] [blame] | 144 | { |
| 145 | struct tree *tree; |
Daniel Lezcano | c671833 | 2011-03-23 14:37:39 +0100 | [diff] [blame] | 146 | |
Daniel Lezcano | afe6225 | 2011-06-08 23:30:00 +0200 | [diff] [blame] | 147 | tree = tree_find(clock_tree, clkarg); |
| 148 | if (!tree) { |
Daniel Lezcano | c671833 | 2011-03-23 14:37:39 +0100 | [diff] [blame] | 149 | printf("Clock NOT found!\n"); |
Daniel Lezcano | afe6225 | 2011-06-08 23:30:00 +0200 | [diff] [blame] | 150 | return -1; |
Daniel Lezcano | c671833 | 2011-03-23 14:37:39 +0100 | [diff] [blame] | 151 | } |
Daniel Lezcano | afe6225 | 2011-06-08 23:30:00 +0200 | [diff] [blame] | 152 | |
| 153 | return tree_for_each_parent(tree, dump_clock_cb, NULL); |
Daniel Lezcano | c671833 | 2011-03-23 14:37:39 +0100 | [diff] [blame] | 154 | } |
| 155 | |
Daniel Lezcano | 897f733 | 2011-03-26 22:06:06 +0100 | [diff] [blame] | 156 | void find_parents_for_clock(char *clkname, int complete) |
Amit Arora | 3bd7916 | 2010-12-01 13:51:42 +0530 | [diff] [blame] | 157 | { |
| 158 | char name[256]; |
| 159 | |
| 160 | name[0] = '\0'; |
| 161 | if (!complete) { |
| 162 | char str[256]; |
| 163 | |
| 164 | strcat(name, clkname); |
| 165 | sprintf(str, "Enter Clock Name : %s\n", name); |
Daniel Lezcano | b3e6e81 | 2011-06-15 15:45:12 +0200 | [diff] [blame] | 166 | display_reset_cursor(CLOCK); |
| 167 | display_print_line(CLOCK, 0, str, 1, NULL); |
| 168 | display_refresh_pad(CLOCK); |
Amit Arora | 3bd7916 | 2010-12-01 13:51:42 +0530 | [diff] [blame] | 169 | return; |
| 170 | } |
| 171 | sprintf(name, "Parents for \"%s\" Clock : \n", clkname); |
Daniel Lezcano | b3e6e81 | 2011-06-15 15:45:12 +0200 | [diff] [blame] | 172 | display_reset_cursor(CLOCK); |
| 173 | display_print_line(CLOCK, 0, name, 1, NULL); |
| 174 | display_refresh_pad(CLOCK); |
Daniel Lezcano | 3e38e0f | 2011-06-08 23:30:00 +0200 | [diff] [blame] | 175 | dump_all_parents(clkname); |
Amit Kucheria | a0adae4 | 2011-01-12 10:54:23 -0600 | [diff] [blame] | 176 | } |
Amit Arora | 3bd7916 | 2010-12-01 13:51:42 +0530 | [diff] [blame] | 177 | |
Daniel Lezcano | 2adc48d | 2011-06-08 23:30:01 +0200 | [diff] [blame] | 178 | static inline int read_clock_cb(struct tree *t, void *data) |
Daniel Lezcano | ef32319 | 2011-03-26 22:06:20 +0100 | [diff] [blame] | 179 | { |
Daniel Lezcano | 2adc48d | 2011-06-08 23:30:01 +0200 | [diff] [blame] | 180 | struct clock_info *clk = t->private; |
Daniel Lezcano | ef32319 | 2011-03-26 22:06:20 +0100 | [diff] [blame] | 181 | |
Daniel Lezcano | 2adc48d | 2011-06-08 23:30:01 +0200 | [diff] [blame] | 182 | file_read_value(t->path, "flags", "%x", &clk->flags); |
| 183 | file_read_value(t->path, "rate", "%d", &clk->rate); |
| 184 | file_read_value(t->path, "usecount", "%d", &clk->usecount); |
Amit Arora | 3bc8c92 | 2010-11-16 11:27:38 +0530 | [diff] [blame] | 185 | |
| 186 | return 0; |
| 187 | } |
| 188 | |
Daniel Lezcano | 2adc48d | 2011-06-08 23:30:01 +0200 | [diff] [blame] | 189 | static int read_clock_info(void) |
Amit Arora | ac4e865 | 2010-11-09 11:16:53 +0530 | [diff] [blame] | 190 | { |
Daniel Lezcano | 2adc48d | 2011-06-08 23:30:01 +0200 | [diff] [blame] | 191 | return tree_for_each(clock_tree, read_clock_cb, NULL); |
Daniel Lezcano | b2565a8 | 2011-06-08 23:30:00 +0200 | [diff] [blame] | 192 | } |
| 193 | |
Daniel Lezcano | 9d5431c | 2011-06-08 23:30:00 +0200 | [diff] [blame] | 194 | static int fill_clock_cb(struct tree *t, void *data) |
| 195 | { |
Daniel Lezcano | 2adc48d | 2011-06-08 23:30:01 +0200 | [diff] [blame] | 196 | struct clock_info *clk; |
Daniel Lezcano | 9d5431c | 2011-06-08 23:30:00 +0200 | [diff] [blame] | 197 | |
Daniel Lezcano | 2adc48d | 2011-06-08 23:30:01 +0200 | [diff] [blame] | 198 | clk = clock_alloc(); |
| 199 | if (!clk) |
Daniel Lezcano | 9d5431c | 2011-06-08 23:30:00 +0200 | [diff] [blame] | 200 | return -1; |
Daniel Lezcano | 2adc48d | 2011-06-08 23:30:01 +0200 | [diff] [blame] | 201 | t->private = clk; |
Daniel Lezcano | 9d5431c | 2011-06-08 23:30:00 +0200 | [diff] [blame] | 202 | |
Daniel Lezcano | 2adc48d | 2011-06-08 23:30:01 +0200 | [diff] [blame] | 203 | /* we skip the root node but we set it expanded for its children */ |
| 204 | if (!t->parent) { |
| 205 | clk->expanded = true; |
| 206 | return 0; |
| 207 | } |
Daniel Lezcano | 9d5431c | 2011-06-08 23:30:00 +0200 | [diff] [blame] | 208 | |
Daniel Lezcano | 2adc48d | 2011-06-08 23:30:01 +0200 | [diff] [blame] | 209 | return read_clock_cb(t, data); |
| 210 | } |
| 211 | |
| 212 | static int fill_clock_tree(void) |
| 213 | { |
| 214 | return tree_for_each(clock_tree, fill_clock_cb, NULL); |
| 215 | } |
| 216 | |
| 217 | static int is_collapsed(struct tree *t, void *data) |
| 218 | { |
| 219 | struct clock_info *clk = t->private; |
| 220 | |
| 221 | if (!clk->expanded) |
| 222 | return 1; |
Daniel Lezcano | 9d5431c | 2011-06-08 23:30:00 +0200 | [diff] [blame] | 223 | |
| 224 | return 0; |
| 225 | } |
| 226 | |
Daniel Lezcano | 2adc48d | 2011-06-08 23:30:01 +0200 | [diff] [blame] | 227 | static char *clock_line(struct tree *t) |
Amit Arora | eb6cba9 | 2010-10-25 16:03:21 +0530 | [diff] [blame] | 228 | { |
Daniel Lezcano | 2adc48d | 2011-06-08 23:30:01 +0200 | [diff] [blame] | 229 | struct clock_info *clk; |
| 230 | int rate; |
| 231 | const char *clkunit; |
| 232 | char *clkrate, *clkname, *clkline = NULL; |
Daniel Lezcano | 28b53cd | 2011-06-08 23:30:00 +0200 | [diff] [blame] | 233 | |
Daniel Lezcano | 2adc48d | 2011-06-08 23:30:01 +0200 | [diff] [blame] | 234 | clk = t->private; |
| 235 | rate = clk->rate; |
| 236 | clkunit = clock_rate(&rate); |
| 237 | |
| 238 | if (asprintf(&clkname, "%*s%s", (t->depth - 1) * 2, "", t->name) < 0) |
| 239 | return NULL; |
| 240 | |
| 241 | if (asprintf(&clkrate, "%d%s", rate, clkunit) < 0) |
| 242 | goto free_clkname; |
| 243 | |
| 244 | if (asprintf(&clkline, "%-55s 0x%-16x %-12s %-9d %-8d", clkname, |
| 245 | clk->flags, clkrate, clk->usecount, t->nrchild) < 0) |
| 246 | goto free_clkrate; |
| 247 | |
| 248 | free_clkrate: |
| 249 | free(clkrate); |
| 250 | free_clkname: |
| 251 | free(clkname); |
| 252 | |
| 253 | return clkline; |
| 254 | } |
| 255 | |
| 256 | static int clock_print_info_cb(struct tree *t, void *data) |
| 257 | { |
| 258 | struct clock_info *clock = t->private; |
| 259 | int *line = data; |
| 260 | char *buffer; |
| 261 | |
| 262 | /* we skip the root node of the tree */ |
| 263 | if (!t->parent) |
| 264 | return 0; |
| 265 | |
| 266 | /* show the clock when *all* its parent is expanded */ |
| 267 | if (tree_for_each_parent(t->parent, is_collapsed, NULL)) |
| 268 | return 0; |
| 269 | |
| 270 | buffer = clock_line(t); |
| 271 | if (!buffer) |
Daniel Lezcano | 9d5431c | 2011-06-08 23:30:00 +0200 | [diff] [blame] | 272 | return -1; |
| 273 | |
Daniel Lezcano | b3e6e81 | 2011-06-15 15:45:12 +0200 | [diff] [blame] | 274 | display_print_line(CLOCK, *line, buffer, clock->usecount, t); |
Daniel Lezcano | 28b53cd | 2011-06-08 23:30:00 +0200 | [diff] [blame] | 275 | |
Daniel Lezcano | 2adc48d | 2011-06-08 23:30:01 +0200 | [diff] [blame] | 276 | (*line)++; |
Daniel Lezcano | 28b53cd | 2011-06-08 23:30:00 +0200 | [diff] [blame] | 277 | |
Daniel Lezcano | 2adc48d | 2011-06-08 23:30:01 +0200 | [diff] [blame] | 278 | free(buffer); |
Daniel Lezcano | b2565a8 | 2011-06-08 23:30:00 +0200 | [diff] [blame] | 279 | |
Daniel Lezcano | 2adc48d | 2011-06-08 23:30:01 +0200 | [diff] [blame] | 280 | return 0; |
| 281 | } |
Daniel Lezcano | 28b53cd | 2011-06-08 23:30:00 +0200 | [diff] [blame] | 282 | |
Daniel Lezcano | 2adc48d | 2011-06-08 23:30:01 +0200 | [diff] [blame] | 283 | static int clock_print_info(void) |
| 284 | { |
| 285 | int ret, line = 0; |
Daniel Lezcano | b2565a8 | 2011-06-08 23:30:00 +0200 | [diff] [blame] | 286 | |
Daniel Lezcano | 2adc48d | 2011-06-08 23:30:01 +0200 | [diff] [blame] | 287 | print_clock_header(); |
Daniel Lezcano | b2565a8 | 2011-06-08 23:30:00 +0200 | [diff] [blame] | 288 | |
Daniel Lezcano | b3e6e81 | 2011-06-15 15:45:12 +0200 | [diff] [blame] | 289 | display_reset_cursor(CLOCK); |
Daniel Lezcano | b2565a8 | 2011-06-08 23:30:00 +0200 | [diff] [blame] | 290 | |
Daniel Lezcano | 2adc48d | 2011-06-08 23:30:01 +0200 | [diff] [blame] | 291 | ret = tree_for_each(clock_tree, clock_print_info_cb, &line); |
Daniel Lezcano | b2565a8 | 2011-06-08 23:30:00 +0200 | [diff] [blame] | 292 | |
Daniel Lezcano | b3e6e81 | 2011-06-15 15:45:12 +0200 | [diff] [blame] | 293 | display_refresh_pad(CLOCK); |
Daniel Lezcano | b2565a8 | 2011-06-08 23:30:00 +0200 | [diff] [blame] | 294 | |
| 295 | return ret; |
Daniel Lezcano | 28b53cd | 2011-06-08 23:30:00 +0200 | [diff] [blame] | 296 | } |
| 297 | |
Daniel Lezcano | 2adc48d | 2011-06-08 23:30:01 +0200 | [diff] [blame] | 298 | int clock_toggle_expanded(void) |
Daniel Lezcano | 28b53cd | 2011-06-08 23:30:00 +0200 | [diff] [blame] | 299 | { |
Daniel Lezcano | b3e6e81 | 2011-06-15 15:45:12 +0200 | [diff] [blame] | 300 | struct tree *t = display_get_row_data(CLOCK); |
Daniel Lezcano | 2adc48d | 2011-06-08 23:30:01 +0200 | [diff] [blame] | 301 | struct clock_info *clk = t->private; |
| 302 | |
| 303 | clk->expanded = !clk->expanded; |
| 304 | |
| 305 | return 0; |
| 306 | } |
| 307 | |
| 308 | /* |
| 309 | * Initialize the clock framework |
| 310 | */ |
| 311 | int clock_init(void) |
| 312 | { |
| 313 | char clk_dir_path[PATH_MAX]; |
| 314 | |
| 315 | if (locate_debugfs(clk_dir_path)) |
| 316 | return -1; |
| 317 | |
| 318 | sprintf(clk_dir_path, "%s/clock", clk_dir_path); |
| 319 | |
| 320 | if (access(clk_dir_path, F_OK)) |
| 321 | return -1; |
| 322 | |
| 323 | clock_tree = tree_load(clk_dir_path, NULL); |
| 324 | if (!clock_tree) |
| 325 | return -1; |
| 326 | |
| 327 | return fill_clock_tree(); |
| 328 | } |
| 329 | |
| 330 | /* |
| 331 | * Read the clock information and fill the tree with the information |
| 332 | * found in the files. Then print the result to the text based interface |
| 333 | * Return 0 on success, < 0 otherwise |
| 334 | */ |
Daniel Lezcano | 597892a | 2011-06-15 15:45:12 +0200 | [diff] [blame^] | 335 | int clock_display(void) |
Daniel Lezcano | 2adc48d | 2011-06-08 23:30:01 +0200 | [diff] [blame] | 336 | { |
| 337 | if (read_clock_info()) |
| 338 | return -1; |
| 339 | |
| 340 | return clock_print_info(); |
| 341 | } |
| 342 | |
| 343 | /* |
| 344 | * Read the clock information and fill the tree with the information |
| 345 | * found in the files. Then dump to stdout a formatted result. |
| 346 | * @clk : a name for a specific clock we want to show |
| 347 | * Return 0 on success, < 0 otherwise |
| 348 | */ |
Daniel Lezcano | 597892a | 2011-06-15 15:45:12 +0200 | [diff] [blame^] | 349 | int clock_dump(char *clk) |
Daniel Lezcano | 2adc48d | 2011-06-08 23:30:01 +0200 | [diff] [blame] | 350 | { |
| 351 | int ret; |
| 352 | |
| 353 | if (read_clock_info()) |
| 354 | return -1; |
Amit Arora | eb6cba9 | 2010-10-25 16:03:21 +0530 | [diff] [blame] | 355 | |
Daniel Lezcano | c789194 | 2011-06-08 23:30:00 +0200 | [diff] [blame] | 356 | if (clk) { |
| 357 | printf("\nParents for \"%s\" Clock :\n\n", clk); |
Daniel Lezcano | 2adc48d | 2011-06-08 23:30:01 +0200 | [diff] [blame] | 358 | ret = dump_all_parents(clk); |
Daniel Lezcano | c789194 | 2011-06-08 23:30:00 +0200 | [diff] [blame] | 359 | printf("\n\n"); |
| 360 | } else { |
| 361 | printf("\nClock Tree :\n"); |
| 362 | printf("**********\n"); |
Daniel Lezcano | 2adc48d | 2011-06-08 23:30:01 +0200 | [diff] [blame] | 363 | ret = dump_clock_info(); |
Daniel Lezcano | c789194 | 2011-06-08 23:30:00 +0200 | [diff] [blame] | 364 | printf("\n\n"); |
| 365 | } |
Daniel Lezcano | 2adc48d | 2011-06-08 23:30:01 +0200 | [diff] [blame] | 366 | |
| 367 | return ret; |
Daniel Lezcano | 28b53cd | 2011-06-08 23:30:00 +0200 | [diff] [blame] | 368 | } |