diff options
author | David Brown <davidb@codeaurora.org> | 2011-01-28 22:31:53 +0300 |
---|---|---|
committer | David Brown <davidb@codeaurora.org> | 2011-01-28 22:31:53 +0300 |
commit | ecca8194c16bdf6cde99a2b29c23a77901cd61a6 (patch) | |
tree | 80b533b480b94b1bdc4dad3b0d300868f44cde04 /arch/arm/mach-msm/clock-debug.c | |
parent | d1f4cec78ee3141a78b2b35969f5bebf7ea9b208 (diff) | |
parent | 07a3cc4814f790354d4c7be2c9dc6143a714a07a (diff) | |
download | linux-ecca8194c16bdf6cde99a2b29c23a77901cd61a6.tar.xz |
Merge branch 'msm-core' into for-next
* msm-core:
msm: Clean up useless ifdefs
msm: clock: Add support for more proc_comm clocks
msm: clock: Invert debugfs directory layout
msm: clock: Move debugfs code from clock.c to clock-debug.c
msm: clock: Remove 7x30 and pcom includes from clock.h
msm: clock: Remove unused code and definitions
msm: Warning fix in trout gpio board file
msm: Remove broken register definition from trout
Diffstat (limited to 'arch/arm/mach-msm/clock-debug.c')
-rw-r--r-- | arch/arm/mach-msm/clock-debug.c | 131 |
1 files changed, 131 insertions, 0 deletions
diff --git a/arch/arm/mach-msm/clock-debug.c b/arch/arm/mach-msm/clock-debug.c new file mode 100644 index 000000000000..b67b9e82ece6 --- /dev/null +++ b/arch/arm/mach-msm/clock-debug.c @@ -0,0 +1,131 @@ +/* + * Copyright (C) 2007 Google, Inc. + * Copyright (c) 2007-2010, Code Aurora Forum. All rights reserved. + * + * This software is licensed under the terms of the GNU General Public + * License version 2, as published by the Free Software Foundation, and + * may be copied, distributed, and modified under those terms. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + */ + +#include <linux/kernel.h> +#include <linux/module.h> +#include <linux/ctype.h> +#include <linux/debugfs.h> +#include <linux/clk.h> +#include "clock.h" +#include "clock-pcom.h" + +static int clock_debug_rate_set(void *data, u64 val) +{ + struct clk *clock = data; + int ret; + + /* Only increases to max rate will succeed, but that's actually good + * for debugging purposes so we don't check for error. */ + if (clock->flags & CLK_MAX) + clk_set_max_rate(clock, val); + if (clock->flags & CLK_MIN) + ret = clk_set_min_rate(clock, val); + else + ret = clk_set_rate(clock, val); + if (ret != 0) + printk(KERN_ERR "clk_set%s_rate failed (%d)\n", + (clock->flags & CLK_MIN) ? "_min" : "", ret); + return ret; +} + +static int clock_debug_rate_get(void *data, u64 *val) +{ + struct clk *clock = data; + *val = clk_get_rate(clock); + return 0; +} + +DEFINE_SIMPLE_ATTRIBUTE(clock_rate_fops, clock_debug_rate_get, + clock_debug_rate_set, "%llu\n"); + +static int clock_debug_enable_set(void *data, u64 val) +{ + struct clk *clock = data; + int rc = 0; + + if (val) + rc = clock->ops->enable(clock->id); + else + clock->ops->disable(clock->id); + + return rc; +} + +static int clock_debug_enable_get(void *data, u64 *val) +{ + struct clk *clock = data; + + *val = clock->ops->is_enabled(clock->id); + + return 0; +} + +DEFINE_SIMPLE_ATTRIBUTE(clock_enable_fops, clock_debug_enable_get, + clock_debug_enable_set, "%llu\n"); + +static int clock_debug_local_get(void *data, u64 *val) +{ + struct clk *clock = data; + + *val = clock->ops != &clk_ops_pcom; + + return 0; +} + +DEFINE_SIMPLE_ATTRIBUTE(clock_local_fops, clock_debug_local_get, + NULL, "%llu\n"); + +static struct dentry *debugfs_base; + +int __init clock_debug_init(void) +{ + debugfs_base = debugfs_create_dir("clk", NULL); + if (!debugfs_base) + return -ENOMEM; + return 0; +} + +int __init clock_debug_add(struct clk *clock) +{ + char temp[50], *ptr; + struct dentry *clk_dir; + + if (!debugfs_base) + return -ENOMEM; + + strncpy(temp, clock->dbg_name, ARRAY_SIZE(temp)-1); + for (ptr = temp; *ptr; ptr++) + *ptr = tolower(*ptr); + + clk_dir = debugfs_create_dir(temp, debugfs_base); + if (!clk_dir) + return -ENOMEM; + + if (!debugfs_create_file("rate", S_IRUGO | S_IWUSR, clk_dir, + clock, &clock_rate_fops)) + goto error; + + if (!debugfs_create_file("enable", S_IRUGO | S_IWUSR, clk_dir, + clock, &clock_enable_fops)) + goto error; + + if (!debugfs_create_file("is_local", S_IRUGO, clk_dir, clock, + &clock_local_fops)) + goto error; + return 0; +error: + debugfs_remove_recursive(clk_dir); + return -ENOMEM; +} |