diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2011-03-17 22:13:18 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2011-03-17 22:13:18 -0400 |
commit | 6899608533410557e6698cb9d4ff6df553916e98 (patch) | |
tree | b392548a6757d08ec7b1395925499e032c174411 /arch/arm/mach-msm/clock-debug.c | |
parent | 411f5c7a502769ccc0377c5ba36cb0b283847ba8 (diff) | |
parent | 92c260f755c42337c550d8ac1f8ccd1b32bffb20 (diff) |
Merge branch 'for-linus' of git://codeaurora.org/quic/kernel/davidb/linux-msm
* 'for-linus' of git://codeaurora.org/quic/kernel/davidb/linux-msm: (46 commits)
msm: scm: Check for interruption immediately
msm: scm: Fix improper register assignment
msm: scm: Mark inline asm as volatile
msm: iommu: Enable HTW L2 redirection on MSM8960
msm: iommu: Don't read from write-only registers
msm: iommu: Remove dependency on IDR
msm: iommu: Use ASID tagging instead of VMID tagging
msm: iommu: Rework clock logic and add IOMMU bus clock control
msm: iommu: Clock control for the IOMMU driver
msm: mdp: Set the correct pack pattern for XRGB/ARGB
msm_fb: Fix framebuffer console
msm: mdp: Add support for RGBX 8888 image format.
video: msmfb: Put the partial update magic value into the fix_screen struct.
msm: clock: Migrate to clkdev
msm: clock: Remove references to clk_ops_pcom
msm: headsmp.S: Fix section mismatch
msm: Use explicit GPLv2 licenses
msm: iommu: Enable IOMMU support for MSM8960
msm: iommu: Generalize platform data for multiple targets
msm: iommu: Create a Kconfig item for the IOMMU driver
...
Diffstat (limited to 'arch/arm/mach-msm/clock-debug.c')
-rw-r--r-- | arch/arm/mach-msm/clock-debug.c | 130 |
1 files changed, 130 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..4886404d42f5 --- /dev/null +++ b/arch/arm/mach-msm/clock-debug.c | |||
@@ -0,0 +1,130 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2007 Google, Inc. | ||
3 | * Copyright (c) 2007-2010, Code Aurora Forum. All rights reserved. | ||
4 | * | ||
5 | * This software is licensed under the terms of the GNU General Public | ||
6 | * License version 2, as published by the Free Software Foundation, and | ||
7 | * may be copied, distributed, and modified under those terms. | ||
8 | * | ||
9 | * This program is distributed in the hope that it will be useful, | ||
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | * GNU General Public License for more details. | ||
13 | * | ||
14 | */ | ||
15 | |||
16 | #include <linux/kernel.h> | ||
17 | #include <linux/module.h> | ||
18 | #include <linux/ctype.h> | ||
19 | #include <linux/debugfs.h> | ||
20 | #include <linux/clk.h> | ||
21 | #include "clock.h" | ||
22 | |||
23 | static int clock_debug_rate_set(void *data, u64 val) | ||
24 | { | ||
25 | struct clk *clock = data; | ||
26 | int ret; | ||
27 | |||
28 | /* Only increases to max rate will succeed, but that's actually good | ||
29 | * for debugging purposes so we don't check for error. */ | ||
30 | if (clock->flags & CLK_MAX) | ||
31 | clk_set_max_rate(clock, val); | ||
32 | if (clock->flags & CLK_MIN) | ||
33 | ret = clk_set_min_rate(clock, val); | ||
34 | else | ||
35 | ret = clk_set_rate(clock, val); | ||
36 | if (ret != 0) | ||
37 | printk(KERN_ERR "clk_set%s_rate failed (%d)\n", | ||
38 | (clock->flags & CLK_MIN) ? "_min" : "", ret); | ||
39 | return ret; | ||
40 | } | ||
41 | |||
42 | static int clock_debug_rate_get(void *data, u64 *val) | ||
43 | { | ||
44 | struct clk *clock = data; | ||
45 | *val = clk_get_rate(clock); | ||
46 | return 0; | ||
47 | } | ||
48 | |||
49 | DEFINE_SIMPLE_ATTRIBUTE(clock_rate_fops, clock_debug_rate_get, | ||
50 | clock_debug_rate_set, "%llu\n"); | ||
51 | |||
52 | static int clock_debug_enable_set(void *data, u64 val) | ||
53 | { | ||
54 | struct clk *clock = data; | ||
55 | int rc = 0; | ||
56 | |||
57 | if (val) | ||
58 | rc = clock->ops->enable(clock->id); | ||
59 | else | ||
60 | clock->ops->disable(clock->id); | ||
61 | |||
62 | return rc; | ||
63 | } | ||
64 | |||
65 | static int clock_debug_enable_get(void *data, u64 *val) | ||
66 | { | ||
67 | struct clk *clock = data; | ||
68 | |||
69 | *val = clock->ops->is_enabled(clock->id); | ||
70 | |||
71 | return 0; | ||
72 | } | ||
73 | |||
74 | DEFINE_SIMPLE_ATTRIBUTE(clock_enable_fops, clock_debug_enable_get, | ||
75 | clock_debug_enable_set, "%llu\n"); | ||
76 | |||
77 | static int clock_debug_local_get(void *data, u64 *val) | ||
78 | { | ||
79 | struct clk *clock = data; | ||
80 | |||
81 | *val = clock->ops->is_local(clock->id); | ||
82 | |||
83 | return 0; | ||
84 | } | ||
85 | |||
86 | DEFINE_SIMPLE_ATTRIBUTE(clock_local_fops, clock_debug_local_get, | ||
87 | NULL, "%llu\n"); | ||
88 | |||
89 | static struct dentry *debugfs_base; | ||
90 | |||
91 | int __init clock_debug_init(void) | ||
92 | { | ||
93 | debugfs_base = debugfs_create_dir("clk", NULL); | ||
94 | if (!debugfs_base) | ||
95 | return -ENOMEM; | ||
96 | return 0; | ||
97 | } | ||
98 | |||
99 | int __init clock_debug_add(struct clk *clock) | ||
100 | { | ||
101 | char temp[50], *ptr; | ||
102 | struct dentry *clk_dir; | ||
103 | |||
104 | if (!debugfs_base) | ||
105 | return -ENOMEM; | ||
106 | |||
107 | strncpy(temp, clock->dbg_name, ARRAY_SIZE(temp)-1); | ||
108 | for (ptr = temp; *ptr; ptr++) | ||
109 | *ptr = tolower(*ptr); | ||
110 | |||
111 | clk_dir = debugfs_create_dir(temp, debugfs_base); | ||
112 | if (!clk_dir) | ||
113 | return -ENOMEM; | ||
114 | |||
115 | if (!debugfs_create_file("rate", S_IRUGO | S_IWUSR, clk_dir, | ||
116 | clock, &clock_rate_fops)) | ||
117 | goto error; | ||
118 | |||
119 | if (!debugfs_create_file("enable", S_IRUGO | S_IWUSR, clk_dir, | ||
120 | clock, &clock_enable_fops)) | ||
121 | goto error; | ||
122 | |||
123 | if (!debugfs_create_file("is_local", S_IRUGO, clk_dir, clock, | ||
124 | &clock_local_fops)) | ||
125 | goto error; | ||
126 | return 0; | ||
127 | error: | ||
128 | debugfs_remove_recursive(clk_dir); | ||
129 | return -ENOMEM; | ||
130 | } | ||