Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ARM: OMAP: CLKFW: Initial debugfs support for omap clock framework

debugfs can provide the infrastructure to trace the dependencies of
clock tree hierarchy quite visibly. This patch enables to keep track
of clock tree hierarchy and expose their attributes under each clock
directry as below:

omap:~# tree -d -L 2 /debug/clock/omap_32k_fck/
/debug/clock/omap_32k_fck/
|-- gpt10_fck
|-- gpt11_fck
|-- gpt1_fck
|-- per_32k_alwon_fck
| |-- gpio2_fck
| |-- gpio3_fck
| |-- gpio4_fck
| |-- gpio5_fck
| |-- gpio6_fck
| `-- wdt3_fck
|-- ts_fck
`-- wkup_32k_fck
|-- gpio1_fck
`-- wdt2_fck

14 directories
omap:~# tree /debug/clock/omap_32k_fck/gpt10_fck/
/debug/clock/omap_32k_fck/gpt10_fck/
|-- flags
|-- rate
`-- usecount

0 directories, 3 files

Although, compared with David Brownell's small patch, this may look
bit overkilling, I expect that this debugfs can deal with other PRCM
complexities at the same time. For example, powerdomain dependencies
can be expressed by using symbolic links of these clocks if
powerdomain supports dubgfs as well.

Signed-off-by: Hiroshi DOYU <Hiroshi.DOYU@nokia.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>

authored by

Hiroshi DOYU and committed by
Tony Lindgren
137b3ee2 44f78f43

+95 -36
+92 -36
arch/arm/plat-omap/clock.c
··· 1 1 /* 2 2 * linux/arch/arm/plat-omap/clock.c 3 3 * 4 - * Copyright (C) 2004 - 2005 Nokia corporation 4 + * Copyright (C) 2004 - 2008 Nokia corporation 5 5 * Written by Tuukka Tikkanen <tuukka.tikkanen@elektrobit.com> 6 6 * 7 7 * Modified for omap shared clock framework by Tony Lindgren <tony@atomide.com> ··· 22 22 #include <linux/mutex.h> 23 23 #include <linux/platform_device.h> 24 24 #include <linux/cpufreq.h> 25 + #include <linux/debugfs.h> 25 26 26 27 #include <asm/io.h> 27 28 ··· 33 32 static DEFINE_SPINLOCK(clockfw_lock); 34 33 35 34 static struct clk_functions *arch_clock; 36 - 37 - #ifdef CONFIG_PM_DEBUG 38 - 39 - static void print_parents(struct clk *clk) 40 - { 41 - struct clk *p; 42 - int printed = 0; 43 - 44 - list_for_each_entry(p, &clocks, node) { 45 - if (p->parent == clk && p->usecount) { 46 - if (!clk->usecount && !printed) { 47 - printk("MISMATCH: %s\n", clk->name); 48 - printed = 1; 49 - } 50 - printk("\t%-15s\n", p->name); 51 - } 52 - } 53 - } 54 - 55 - void clk_print_usecounts(void) 56 - { 57 - unsigned long flags; 58 - struct clk *p; 59 - 60 - spin_lock_irqsave(&clockfw_lock, flags); 61 - list_for_each_entry(p, &clocks, node) { 62 - if (p->usecount) 63 - printk("%-15s: %d\n", p->name, p->usecount); 64 - print_parents(p); 65 - 66 - } 67 - spin_unlock_irqrestore(&clockfw_lock, flags); 68 - } 69 - 70 - #endif 71 35 72 36 /*------------------------------------------------------------------------- 73 37 * Standard clock functions defined in include/linux/clk.h ··· 412 446 return 0; 413 447 } 414 448 449 + #if defined(CONFIG_PM_DEBUG) && defined(CONFIG_DEBUG_FS) 450 + /* 451 + * debugfs support to trace clock tree hierarchy and attributes 452 + */ 453 + static struct dentry *clk_debugfs_root; 454 + 455 + static int clk_debugfs_register_one(struct clk *c) 456 + { 457 + int err; 458 + struct dentry *d, *child; 459 + struct clk *pa = c->parent; 460 + char s[255]; 461 + char *p = s; 462 + 463 + p += sprintf(p, "%s", c->name); 464 + if (c->id != 0) 465 + sprintf(p, ":%d", c->id); 466 + d = debugfs_create_dir(s, pa ? pa->dent : clk_debugfs_root); 467 + if (IS_ERR(d)) 468 + return PTR_ERR(d); 469 + c->dent = d; 470 + 471 + d = debugfs_create_u8("usecount", S_IRUGO, c->dent, (u8 *)&c->usecount); 472 + if (IS_ERR(d)) { 473 + err = PTR_ERR(d); 474 + goto err_out; 475 + } 476 + d = debugfs_create_u32("rate", S_IRUGO, c->dent, (u32 *)&c->rate); 477 + if (IS_ERR(d)) { 478 + err = PTR_ERR(d); 479 + goto err_out; 480 + } 481 + d = debugfs_create_x32("flags", S_IRUGO, c->dent, (u32 *)&c->flags); 482 + if (IS_ERR(d)) { 483 + err = PTR_ERR(d); 484 + goto err_out; 485 + } 486 + return 0; 487 + 488 + err_out: 489 + d = c->dent; 490 + list_for_each_entry(child, &d->d_subdirs, d_u.d_child) 491 + debugfs_remove(child); 492 + debugfs_remove(c->dent); 493 + return err; 494 + } 495 + 496 + static int clk_debugfs_register(struct clk *c) 497 + { 498 + int err; 499 + struct clk *pa = c->parent; 500 + 501 + if (pa && !pa->dent) { 502 + err = clk_debugfs_register(pa); 503 + if (err) 504 + return err; 505 + } 506 + 507 + if (!c->dent) { 508 + err = clk_debugfs_register_one(c); 509 + if (err) 510 + return err; 511 + } 512 + return 0; 513 + } 514 + 515 + static int __init clk_debugfs_init(void) 516 + { 517 + struct clk *c; 518 + struct dentry *d; 519 + int err; 520 + 521 + d = debugfs_create_dir("clock", NULL); 522 + if (IS_ERR(d)) 523 + return PTR_ERR(d); 524 + clk_debugfs_root = d; 525 + 526 + list_for_each_entry(c, &clocks, node) { 527 + err = clk_debugfs_register(c); 528 + if (err) 529 + goto err_out; 530 + } 531 + return 0; 532 + err_out: 533 + debugfs_remove(clk_debugfs_root); /* REVISIT: Cleanup correctly */ 534 + return err; 535 + } 536 + late_initcall(clk_debugfs_init); 537 + 538 + #endif /* defined(CONFIG_PM_DEBUG) && defined(CONFIG_DEBUG_FS) */
+3
include/asm-arm/arch-omap/clock.h
··· 71 71 __u8 rate_offset; 72 72 __u8 src_offset; 73 73 #endif 74 + #if defined(CONFIG_PM_DEBUG) && defined(CONFIG_DEBUG_FS) 75 + struct dentry *dent; /* For visible tree hierarchy */ 76 + #endif 74 77 }; 75 78 76 79 struct cpufreq_frequency_table;