aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mmc
diff options
context:
space:
mode:
authorAndy Shevchenko <andy.shevchenko@gmail.com>2010-10-13 04:22:22 -0400
committerChris Ball <cjb@laptop.org>2010-10-23 09:11:20 -0400
commit703aae3d09a4b351866f1a97b2afafb905bdbf1e (patch)
treeb177dbc351fc54c23fd683dac2dab110c74e3bfa /drivers/mmc
parent643a81ff3c5a89ae5c0768f89b29d3e1d08be5c3 (diff)
mmc: add a file to debugfs for changing host clock at runtime
For debugging power management features it is convenient to have the possibility of changing the MMC host controller clock at runtime. This patch adds a 'clock' file for this under the MMC host root of debugfs. Usage is as follows: # cat /sys/kernel/debug/mmc0/clock 52000000 # echo "1000000000" > /sys/kernel/debug/mmc0/clock # cat /sys/kernel/debug/mmc0/clock 52000000 # echo "48000000" > /sys/kernel/debug/mmc0/clock # cat /sys/kernel/debug/mmc0/clock 48000000 The middle example shows limits being applied by the host driver. Signed-off-by: Andy Shevchenko <ext-andriy.shevchenko@nokia.com> Cc: Adrian Hunter <adrian.hunter@nokia.com> [cjb: modify changelog language] Signed-off-by: Chris Ball <cjb@laptop.org>
Diffstat (limited to 'drivers/mmc')
-rw-r--r--drivers/mmc/core/debugfs.c35
1 files changed, 33 insertions, 2 deletions
diff --git a/drivers/mmc/core/debugfs.c b/drivers/mmc/core/debugfs.c
index 46bc6d7551a3..eed1405fd742 100644
--- a/drivers/mmc/core/debugfs.c
+++ b/drivers/mmc/core/debugfs.c
@@ -134,6 +134,33 @@ static const struct file_operations mmc_ios_fops = {
134 .release = single_release, 134 .release = single_release,
135}; 135};
136 136
137static int mmc_clock_opt_get(void *data, u64 *val)
138{
139 struct mmc_host *host = data;
140
141 *val = host->ios.clock;
142
143 return 0;
144}
145
146static int mmc_clock_opt_set(void *data, u64 val)
147{
148 struct mmc_host *host = data;
149
150 /* We need this check due to input value is u64 */
151 if (val > host->f_max)
152 return -EINVAL;
153
154 mmc_claim_host(host);
155 mmc_set_clock(host, (unsigned int) val);
156 mmc_release_host(host);
157
158 return 0;
159}
160
161DEFINE_SIMPLE_ATTRIBUTE(mmc_clock_fops, mmc_clock_opt_get, mmc_clock_opt_set,
162 "%llu\n");
163
137void mmc_add_host_debugfs(struct mmc_host *host) 164void mmc_add_host_debugfs(struct mmc_host *host)
138{ 165{
139 struct dentry *root; 166 struct dentry *root;
@@ -150,11 +177,15 @@ void mmc_add_host_debugfs(struct mmc_host *host)
150 host->debugfs_root = root; 177 host->debugfs_root = root;
151 178
152 if (!debugfs_create_file("ios", S_IRUSR, root, host, &mmc_ios_fops)) 179 if (!debugfs_create_file("ios", S_IRUSR, root, host, &mmc_ios_fops))
153 goto err_ios; 180 goto err_node;
181
182 if (!debugfs_create_file("clock", S_IRUSR | S_IWUSR, root, host,
183 &mmc_clock_fops))
184 goto err_node;
154 185
155 return; 186 return;
156 187
157err_ios: 188err_node:
158 debugfs_remove_recursive(root); 189 debugfs_remove_recursive(root);
159 host->debugfs_root = NULL; 190 host->debugfs_root = NULL;
160err_root: 191err_root: