diff options
author | Matt Wagantall <mattw@codeaurora.org> | 2011-01-26 19:20:54 -0500 |
---|---|---|
committer | David Brown <davidb@codeaurora.org> | 2011-01-28 14:20:48 -0500 |
commit | d64560fe3e9bf64b2050ceeb6b6946ba2a4efda0 (patch) | |
tree | d58ae274bf9d3f7c231eb8d8761c8e50a670bd36 /arch/arm/mach-msm | |
parent | ce1c80fbaa3b8e132d4e430cbf7cb4a9cd28b2d5 (diff) |
msm: clock: Move debugfs code from clock.c to clock-debug.c
The clock debugfs code is large enough, and easy enough to separate,
that it deserves its own file which is compiled only when
CONFIG_DEBUG_FS is enabled.
Also, cleanup header file #includes that are no longer required.
Reviewed-by: Saravana Kannan <skannan@codeaurora.org>
Signed-off-by: Matt Wagantall <mattw@codeaurora.org>
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
Signed-off-by: David Brown <davidb@codeaurora.org>
Diffstat (limited to 'arch/arm/mach-msm')
-rw-r--r-- | arch/arm/mach-msm/Makefile | 3 | ||||
-rw-r--r-- | arch/arm/mach-msm/clock-debug.c | 133 | ||||
-rw-r--r-- | arch/arm/mach-msm/clock.c | 127 | ||||
-rw-r--r-- | arch/arm/mach-msm/clock.h | 9 |
4 files changed, 150 insertions, 122 deletions
diff --git a/arch/arm/mach-msm/Makefile b/arch/arm/mach-msm/Makefile index 0e5c9dc23830..c7964417daed 100644 --- a/arch/arm/mach-msm/Makefile +++ b/arch/arm/mach-msm/Makefile | |||
@@ -1,4 +1,7 @@ | |||
1 | obj-y += io.o idle.o timer.o | 1 | obj-y += io.o idle.o timer.o |
2 | ifdef CONFIG_MSM_PROC_COMM | ||
3 | obj-$(CONFIG_DEBUG_FS) += clock-debug.o | ||
4 | endif | ||
2 | 5 | ||
3 | obj-$(CONFIG_MSM_VIC) += irq-vic.o | 6 | obj-$(CONFIG_MSM_VIC) += irq-vic.o |
4 | 7 | ||
diff --git a/arch/arm/mach-msm/clock-debug.c b/arch/arm/mach-msm/clock-debug.c new file mode 100644 index 000000000000..6f603edbb4d0 --- /dev/null +++ b/arch/arm/mach-msm/clock-debug.c | |||
@@ -0,0 +1,133 @@ | |||
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 | #include "clock-pcom.h" | ||
23 | |||
24 | static int clock_debug_rate_set(void *data, u64 val) | ||
25 | { | ||
26 | struct clk *clock = data; | ||
27 | int ret; | ||
28 | |||
29 | /* Only increases to max rate will succeed, but that's actually good | ||
30 | * for debugging purposes so we don't check for error. */ | ||
31 | if (clock->flags & CLK_MAX) | ||
32 | clk_set_max_rate(clock, val); | ||
33 | if (clock->flags & CLK_MIN) | ||
34 | ret = clk_set_min_rate(clock, val); | ||
35 | else | ||
36 | ret = clk_set_rate(clock, val); | ||
37 | if (ret != 0) | ||
38 | printk(KERN_ERR "clk_set%s_rate failed (%d)\n", | ||
39 | (clock->flags & CLK_MIN) ? "_min" : "", ret); | ||
40 | return ret; | ||
41 | } | ||
42 | |||
43 | static int clock_debug_rate_get(void *data, u64 *val) | ||
44 | { | ||
45 | struct clk *clock = data; | ||
46 | *val = clk_get_rate(clock); | ||
47 | return 0; | ||
48 | } | ||
49 | |||
50 | DEFINE_SIMPLE_ATTRIBUTE(clock_rate_fops, clock_debug_rate_get, | ||
51 | clock_debug_rate_set, "%llu\n"); | ||
52 | |||
53 | static int clock_debug_enable_set(void *data, u64 val) | ||
54 | { | ||
55 | struct clk *clock = data; | ||
56 | int rc = 0; | ||
57 | |||
58 | if (val) | ||
59 | rc = clock->ops->enable(clock->id); | ||
60 | else | ||
61 | clock->ops->disable(clock->id); | ||
62 | |||
63 | return rc; | ||
64 | } | ||
65 | |||
66 | static int clock_debug_enable_get(void *data, u64 *val) | ||
67 | { | ||
68 | struct clk *clock = data; | ||
69 | |||
70 | *val = clock->ops->is_enabled(clock->id); | ||
71 | |||
72 | return 0; | ||
73 | } | ||
74 | |||
75 | DEFINE_SIMPLE_ATTRIBUTE(clock_enable_fops, clock_debug_enable_get, | ||
76 | clock_debug_enable_set, "%llu\n"); | ||
77 | |||
78 | static int clock_debug_local_get(void *data, u64 *val) | ||
79 | { | ||
80 | struct clk *clock = data; | ||
81 | |||
82 | *val = clock->ops != &clk_ops_pcom; | ||
83 | |||
84 | return 0; | ||
85 | } | ||
86 | |||
87 | DEFINE_SIMPLE_ATTRIBUTE(clock_local_fops, clock_debug_local_get, | ||
88 | NULL, "%llu\n"); | ||
89 | |||
90 | static struct dentry *dent_rate, *dent_enable, *dent_local; | ||
91 | |||
92 | int __init clock_debug_init(void) | ||
93 | { | ||
94 | dent_rate = debugfs_create_dir("clk_rate", 0); | ||
95 | if (!dent_rate) | ||
96 | goto err; | ||
97 | |||
98 | dent_enable = debugfs_create_dir("clk_enable", 0); | ||
99 | if (!dent_enable) | ||
100 | goto err; | ||
101 | |||
102 | dent_local = debugfs_create_dir("clk_local", NULL); | ||
103 | if (!dent_local) | ||
104 | goto err; | ||
105 | |||
106 | return 0; | ||
107 | err: | ||
108 | debugfs_remove(dent_local); | ||
109 | debugfs_remove(dent_enable); | ||
110 | debugfs_remove(dent_rate); | ||
111 | return -ENOMEM; | ||
112 | } | ||
113 | |||
114 | int __init clock_debug_add(struct clk *clock) | ||
115 | { | ||
116 | char temp[50], *ptr; | ||
117 | |||
118 | if (!dent_rate || !dent_enable || !dent_local) | ||
119 | return -ENOMEM; | ||
120 | |||
121 | strncpy(temp, clock->dbg_name, ARRAY_SIZE(temp)-1); | ||
122 | for (ptr = temp; *ptr; ptr++) | ||
123 | *ptr = tolower(*ptr); | ||
124 | |||
125 | debugfs_create_file(temp, S_IRUGO | S_IWUSR, dent_rate, | ||
126 | clock, &clock_rate_fops); | ||
127 | debugfs_create_file(temp, S_IRUGO | S_IWUSR, dent_enable, | ||
128 | clock, &clock_enable_fops); | ||
129 | debugfs_create_file(temp, S_IRUGO, dent_local, | ||
130 | clock, &clock_local_fops); | ||
131 | |||
132 | return 0; | ||
133 | } | ||
diff --git a/arch/arm/mach-msm/clock.c b/arch/arm/mach-msm/clock.c index 8f71f8d9fa98..8c2b4dd4a877 100644 --- a/arch/arm/mach-msm/clock.c +++ b/arch/arm/mach-msm/clock.c | |||
@@ -15,16 +15,10 @@ | |||
15 | */ | 15 | */ |
16 | 16 | ||
17 | #include <linux/kernel.h> | 17 | #include <linux/kernel.h> |
18 | #include <linux/init.h> | ||
19 | #include <linux/module.h> | ||
20 | #include <linux/list.h> | 18 | #include <linux/list.h> |
21 | #include <linux/err.h> | 19 | #include <linux/err.h> |
22 | #include <linux/clk.h> | ||
23 | #include <linux/spinlock.h> | 20 | #include <linux/spinlock.h> |
24 | #include <linux/debugfs.h> | ||
25 | #include <linux/ctype.h> | ||
26 | #include <linux/pm_qos_params.h> | 21 | #include <linux/pm_qos_params.h> |
27 | #include <mach/clk.h> | ||
28 | 22 | ||
29 | #include "clock.h" | 23 | #include "clock.h" |
30 | #include "proc_comm.h" | 24 | #include "proc_comm.h" |
@@ -34,8 +28,6 @@ | |||
34 | static DEFINE_MUTEX(clocks_mutex); | 28 | static DEFINE_MUTEX(clocks_mutex); |
35 | static DEFINE_SPINLOCK(clocks_lock); | 29 | static DEFINE_SPINLOCK(clocks_lock); |
36 | static LIST_HEAD(clocks); | 30 | static LIST_HEAD(clocks); |
37 | struct clk *msm_clocks; | ||
38 | unsigned msm_num_clocks; | ||
39 | 31 | ||
40 | /* | 32 | /* |
41 | * Standard clock functions defined in include/linux/clk.h | 33 | * Standard clock functions defined in include/linux/clk.h |
@@ -183,11 +175,9 @@ void __init msm_clock_init(struct clk *clock_tbl, unsigned num_clocks) | |||
183 | unsigned n; | 175 | unsigned n; |
184 | 176 | ||
185 | mutex_lock(&clocks_mutex); | 177 | mutex_lock(&clocks_mutex); |
186 | msm_clocks = clock_tbl; | 178 | for (n = 0; n < num_clocks; n++) { |
187 | msm_num_clocks = num_clocks; | 179 | set_clock_ops(&clock_tbl[n]); |
188 | for (n = 0; n < msm_num_clocks; n++) { | 180 | list_add_tail(&clock_tbl[n].list, &clocks); |
189 | set_clock_ops(&msm_clocks[n]); | ||
190 | list_add_tail(&msm_clocks[n].list, &clocks); | ||
191 | } | 181 | } |
192 | mutex_unlock(&clocks_mutex); | 182 | mutex_unlock(&clocks_mutex); |
193 | 183 | ||
@@ -196,115 +186,6 @@ void __init msm_clock_init(struct clk *clock_tbl, unsigned num_clocks) | |||
196 | 186 | ||
197 | } | 187 | } |
198 | 188 | ||
199 | #if defined(CONFIG_DEBUG_FS) | ||
200 | static struct clk *msm_clock_get_nth(unsigned index) | ||
201 | { | ||
202 | if (index < msm_num_clocks) | ||
203 | return msm_clocks + index; | ||
204 | else | ||
205 | return 0; | ||
206 | } | ||
207 | |||
208 | static int clock_debug_rate_set(void *data, u64 val) | ||
209 | { | ||
210 | struct clk *clock = data; | ||
211 | int ret; | ||
212 | |||
213 | /* Only increases to max rate will succeed, but that's actually good | ||
214 | * for debugging purposes. So we don't check for error. */ | ||
215 | if (clock->flags & CLK_MAX) | ||
216 | clk_set_max_rate(clock, val); | ||
217 | if (clock->flags & CLK_MIN) | ||
218 | ret = clk_set_min_rate(clock, val); | ||
219 | else | ||
220 | ret = clk_set_rate(clock, val); | ||
221 | if (ret != 0) | ||
222 | printk(KERN_ERR "clk_set%s_rate failed (%d)\n", | ||
223 | (clock->flags & CLK_MIN) ? "_min" : "", ret); | ||
224 | return ret; | ||
225 | } | ||
226 | |||
227 | static int clock_debug_rate_get(void *data, u64 *val) | ||
228 | { | ||
229 | struct clk *clock = data; | ||
230 | *val = clk_get_rate(clock); | ||
231 | return 0; | ||
232 | } | ||
233 | |||
234 | static int clock_debug_enable_set(void *data, u64 val) | ||
235 | { | ||
236 | struct clk *clock = data; | ||
237 | int rc = 0; | ||
238 | |||
239 | if (val) | ||
240 | rc = clock->ops->enable(clock->id); | ||
241 | else | ||
242 | clock->ops->disable(clock->id); | ||
243 | |||
244 | return rc; | ||
245 | } | ||
246 | |||
247 | static int clock_debug_enable_get(void *data, u64 *val) | ||
248 | { | ||
249 | struct clk *clock = data; | ||
250 | |||
251 | *val = clock->ops->is_enabled(clock->id); | ||
252 | |||
253 | return 0; | ||
254 | } | ||
255 | |||
256 | static int clock_debug_local_get(void *data, u64 *val) | ||
257 | { | ||
258 | struct clk *clock = data; | ||
259 | |||
260 | *val = clock->ops != &clk_ops_pcom; | ||
261 | |||
262 | return 0; | ||
263 | } | ||
264 | |||
265 | DEFINE_SIMPLE_ATTRIBUTE(clock_rate_fops, clock_debug_rate_get, | ||
266 | clock_debug_rate_set, "%llu\n"); | ||
267 | DEFINE_SIMPLE_ATTRIBUTE(clock_enable_fops, clock_debug_enable_get, | ||
268 | clock_debug_enable_set, "%llu\n"); | ||
269 | DEFINE_SIMPLE_ATTRIBUTE(clock_local_fops, clock_debug_local_get, | ||
270 | NULL, "%llu\n"); | ||
271 | |||
272 | static int __init clock_debug_init(void) | ||
273 | { | ||
274 | struct dentry *dent_rate, *dent_enable, *dent_local; | ||
275 | struct clk *clock; | ||
276 | unsigned n = 0; | ||
277 | char temp[50], *ptr; | ||
278 | |||
279 | dent_rate = debugfs_create_dir("clk_rate", 0); | ||
280 | if (IS_ERR(dent_rate)) | ||
281 | return PTR_ERR(dent_rate); | ||
282 | |||
283 | dent_enable = debugfs_create_dir("clk_enable", 0); | ||
284 | if (IS_ERR(dent_enable)) | ||
285 | return PTR_ERR(dent_enable); | ||
286 | |||
287 | dent_local = debugfs_create_dir("clk_local", NULL); | ||
288 | if (IS_ERR(dent_local)) | ||
289 | return PTR_ERR(dent_local); | ||
290 | |||
291 | while ((clock = msm_clock_get_nth(n++)) != 0) { | ||
292 | strncpy(temp, clock->dbg_name, ARRAY_SIZE(temp)-1); | ||
293 | for (ptr = temp; *ptr; ptr++) | ||
294 | *ptr = tolower(*ptr); | ||
295 | debugfs_create_file(temp, 0644, dent_rate, | ||
296 | clock, &clock_rate_fops); | ||
297 | debugfs_create_file(temp, 0644, dent_enable, | ||
298 | clock, &clock_enable_fops); | ||
299 | debugfs_create_file(temp, S_IRUGO, dent_local, | ||
300 | clock, &clock_local_fops); | ||
301 | } | ||
302 | return 0; | ||
303 | } | ||
304 | |||
305 | device_initcall(clock_debug_init); | ||
306 | #endif | ||
307 | |||
308 | /* The bootloader and/or AMSS may have left various clocks enabled. | 189 | /* The bootloader and/or AMSS may have left various clocks enabled. |
309 | * Disable any clocks that belong to us (CLKFLAG_AUTO_OFF) but have | 190 | * Disable any clocks that belong to us (CLKFLAG_AUTO_OFF) but have |
310 | * not been explicitly enabled by a clk_enable() call. | 191 | * not been explicitly enabled by a clk_enable() call. |
@@ -315,8 +196,10 @@ static int __init clock_late_init(void) | |||
315 | struct clk *clk; | 196 | struct clk *clk; |
316 | unsigned count = 0; | 197 | unsigned count = 0; |
317 | 198 | ||
199 | clock_debug_init(); | ||
318 | mutex_lock(&clocks_mutex); | 200 | mutex_lock(&clocks_mutex); |
319 | list_for_each_entry(clk, &clocks, list) { | 201 | list_for_each_entry(clk, &clocks, list) { |
202 | clock_debug_add(clk); | ||
320 | if (clk->flags & CLKFLAG_AUTO_OFF) { | 203 | if (clk->flags & CLKFLAG_AUTO_OFF) { |
321 | spin_lock_irqsave(&clocks_lock, flags); | 204 | spin_lock_irqsave(&clocks_lock, flags); |
322 | if (!clk->count) { | 205 | if (!clk->count) { |
diff --git a/arch/arm/mach-msm/clock.h b/arch/arm/mach-msm/clock.h index 6a0cadeabb9d..70216b0e9681 100644 --- a/arch/arm/mach-msm/clock.h +++ b/arch/arm/mach-msm/clock.h | |||
@@ -17,6 +17,7 @@ | |||
17 | #ifndef __ARCH_ARM_MACH_MSM_CLOCK_H | 17 | #ifndef __ARCH_ARM_MACH_MSM_CLOCK_H |
18 | #define __ARCH_ARM_MACH_MSM_CLOCK_H | 18 | #define __ARCH_ARM_MACH_MSM_CLOCK_H |
19 | 19 | ||
20 | #include <linux/init.h> | ||
20 | #include <linux/list.h> | 21 | #include <linux/list.h> |
21 | #include <mach/clk.h> | 22 | #include <mach/clk.h> |
22 | 23 | ||
@@ -61,4 +62,12 @@ struct clk { | |||
61 | #define CLK_MAX CLKFLAG_MAX | 62 | #define CLK_MAX CLKFLAG_MAX |
62 | #define CLK_MINMAX (CLK_MIN | CLK_MAX) | 63 | #define CLK_MINMAX (CLK_MIN | CLK_MAX) |
63 | 64 | ||
65 | #ifdef CONFIG_DEBUG_FS | ||
66 | int __init clock_debug_init(void); | ||
67 | int __init clock_debug_add(struct clk *clock); | ||
68 | #else | ||
69 | static inline int __init clock_debug_init(void) { return 0; } | ||
70 | static inline int __init clock_debug_add(struct clk *clock) { return 0; } | ||
71 | #endif | ||
72 | |||
64 | #endif | 73 | #endif |