From 326928845e261b4becb3eba96d92dacfb144324a Mon Sep 17 00:00:00 2001 From: Peter De Schrijver Date: Mon, 2 May 2011 15:43:06 +0300 Subject: ARM: tegra: generate status events for all clocks Change-Id: I55f52ab038764079811c68b3bb3738a9de17d7bf Signed-off-by: Peter De Schrijver Reviewed-on: http://git-master/r/31530 Reviewed-by: Niket Sirsi Tested-by: Niket Sirsi --- arch/arm/mach-tegra/clock.c | 58 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/arch/arm/mach-tegra/clock.c b/arch/arm/mach-tegra/clock.c index f1b45b3f3dc2..da7ca265bf6b 100644 --- a/arch/arm/mach-tegra/clock.c +++ b/arch/arm/mach-tegra/clock.c @@ -1010,6 +1010,61 @@ static const struct file_operations clock_tree_fops = { .release = single_release, }; +static void syncevent_one(struct clk *c) +{ + struct clk *child; + + if (c->state == ON) + trace_clock_enable(c->name, 1, smp_processor_id()); + else + trace_clock_disable(c->name, 0, smp_processor_id()); + + trace_clock_set_rate(c->name, clk_get_rate_all_locked(c), + smp_processor_id()); + + list_for_each_entry(child, &clocks, node) { + if (child->parent != c) + continue; + + syncevent_one(child); + } +} + +static int syncevent_write(struct file *file, const char __user *user_buf, + size_t count, loff_t *ppos) +{ + struct clk *c; + char buffer[40]; + int buf_size; + + memset(buffer, 0, sizeof(buffer)); + buf_size = min(count, (sizeof(buffer)-1)); + + if (copy_from_user(buffer, user_buf, buf_size)) + return -EFAULT; + + if (!strnicmp("all", buffer, 3)) { + mutex_lock(&clock_list_lock); + + clk_lock_all(); + + list_for_each_entry(c, &clocks, node) { + if (c->parent == NULL) + syncevent_one(c); + } + + clk_unlock_all(); + + mutex_unlock(&clock_list_lock); + } + + return count; +} + +static const struct file_operations syncevent_fops = { + .write = syncevent_write, +}; + static int possible_parents_show(struct seq_file *s, void *data) { struct clk *c = s->private; @@ -1246,6 +1301,9 @@ static int __init clk_debugfs_init(void) if (!d) goto err_out; + d = debugfs_create_file("syncevents", S_IWUGO, clk_debugfs_root, NULL, + &syncevent_fops); + if (dvfs_debugfs_init(clk_debugfs_root)) goto err_out; -- cgit v1.2.3