summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorSujit Reddy Thumma <sthumma@codeaurora.org>2012-11-09 18:32:32 +0530
committerSubhash Jadavani <subhashj@codeaurora.org>2016-05-27 10:29:15 -0700
commit7d7218224b477ffb208655be43996fdfdb9d8370 (patch)
tree9cc0618db545d66da7e91bd0cc5148c75fd0a535 /drivers
parentf3bca6c7763f02d8f1318aa840e4a3780ab219f2 (diff)
mmc: core: Add a debugfs entry to set max clock rate
Limiting the max frequency supported by host controller to a certain value can be useful for testing power consumption at various frequencies that are supported by the host. Note: If the card supports less than desired value then the frequency of operation would be limited to that frequency. Usage: mount -t debugfs none /sys/kernel/debug echo <desired_frequency> > /sys/kernel/debug/mmcX/max_clock cat /sys/kernel/debug/mmcX/max_clock Change-Id: I9e9a7e368f56d8e16548780288211bd8775fd048 Signed-off-by: Sujit Reddy Thumma <sthumma@codeaurora.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/mmc/core/debugfs.c44
1 files changed, 44 insertions, 0 deletions
diff --git a/drivers/mmc/core/debugfs.c b/drivers/mmc/core/debugfs.c
index f4db93e03e88..cbc83344e0c7 100644
--- a/drivers/mmc/core/debugfs.c
+++ b/drivers/mmc/core/debugfs.c
@@ -233,6 +233,46 @@ static int mmc_clock_opt_set(void *data, u64 val)
DEFINE_SIMPLE_ATTRIBUTE(mmc_clock_fops, mmc_clock_opt_get, mmc_clock_opt_set,
"%llu\n");
+static int mmc_max_clock_get(void *data, u64 *val)
+{
+ struct mmc_host *host = data;
+
+ if (!host)
+ return -EINVAL;
+
+ *val = host->f_max;
+
+ return 0;
+}
+
+static int mmc_max_clock_set(void *data, u64 val)
+{
+ struct mmc_host *host = data;
+ int err = -EINVAL;
+ unsigned long freq = val;
+ unsigned int old_freq;
+
+ if (!host || (val < host->f_min))
+ goto out;
+
+ mmc_claim_host(host);
+ if (host->bus_ops && host->bus_ops->change_bus_speed) {
+ old_freq = host->f_max;
+ host->f_max = freq;
+
+ err = host->bus_ops->change_bus_speed(host, &freq);
+
+ if (err)
+ host->f_max = old_freq;
+ }
+ mmc_release_host(host);
+out:
+ return err;
+}
+
+DEFINE_SIMPLE_ATTRIBUTE(mmc_max_clock_fops, mmc_max_clock_get,
+ mmc_max_clock_set, "%llu\n");
+
void mmc_add_host_debugfs(struct mmc_host *host)
{
struct dentry *root;
@@ -255,6 +295,10 @@ void mmc_add_host_debugfs(struct mmc_host *host)
&mmc_clock_fops))
goto err_node;
+ if (!debugfs_create_file("max_clock", S_IRUSR | S_IWUSR, root, host,
+ &mmc_max_clock_fops))
+ goto err_node;
+
#ifdef CONFIG_MMC_CLKGATE
if (!debugfs_create_u32("clk_delay", (S_IRUSR | S_IWUSR),
root, &host->clk_delay))