[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <1286896642-27772-1-git-send-email-ext-andriy.shevchenko@nokia.com>
Date: Tue, 12 Oct 2010 18:17:22 +0300
From: Andy Shevchenko <andy.shevchenko@...il.com>
To: linux-mmc@...r.kernel.org, linux-kernel@...r.kernel.org
Cc: Chris Ball <cjb@...top.org>,
Andrew Morton <akpm@...ux-foundation.org>,
Andy Shevchenko <ext-andriy.shevchenko@...ia.com>
Subject: [PATCH] mmc: append a file to change host clock at run time
For debugging power managment features there is quite convenient to have a
possibility to change MMC host controller clock at run time. This patch adds
'clock' file under MMC host root of debugfs.
Usage as follows:
# cat /sys/kernel/debug/mmc0/clock
24000000
# 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 second piece of example shows limits which are applied accordingly to used
host driver.
Signed-off-by: Andy Shevchenko <ext-andriy.shevchenko@...ia.com>
---
drivers/mmc/core/debugfs.c | 33 +++++++++++++++++++++++++++++++--
1 files changed, 31 insertions(+), 2 deletions(-)
diff --git a/drivers/mmc/core/debugfs.c b/drivers/mmc/core/debugfs.c
index 96d10f4..4ff109f 100644
--- a/drivers/mmc/core/debugfs.c
+++ b/drivers/mmc/core/debugfs.c
@@ -133,6 +133,31 @@ static const struct file_operations mmc_ios_fops = {
.release = single_release,
};
+static int mmc_clock_opt_get(void *data, u64 *val)
+{
+ struct mmc_host *host = data;
+
+ *val = host->ios.clock;
+
+ return 0;
+}
+
+static int mmc_clock_opt_set(void *data, u64 val)
+{
+ struct mmc_host *host = data;
+
+ /* We need this check due to input value is u64 */
+ if (val > host->f_max)
+ return -EINVAL;
+
+ mmc_set_clock(host, (unsigned int) val);
+
+ return 0;
+}
+
+DEFINE_SIMPLE_ATTRIBUTE(mmc_clock_fops, mmc_clock_opt_get, mmc_clock_opt_set,
+ "%llu\n");
+
void mmc_add_host_debugfs(struct mmc_host *host)
{
struct dentry *root;
@@ -149,11 +174,15 @@ void mmc_add_host_debugfs(struct mmc_host *host)
host->debugfs_root = root;
if (!debugfs_create_file("ios", S_IRUSR, root, host, &mmc_ios_fops))
- goto err_ios;
+ goto err_node;
+
+ if (!debugfs_create_file("clock", S_IRUSR | S_IWUSR, root, host,
+ &mmc_clock_fops))
+ goto err_node;
return;
-err_ios:
+err_node:
debugfs_remove_recursive(root);
host->debugfs_root = NULL;
err_root:
--
1.6.3.3
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists