linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sayali Lokhande <sayalil@codeaurora.org>
To: adrian.hunter@intel.com, ulf.hansson@linaro.org,
	robh+dt@kernel.org, robh@kernel.org, mark.rutland@arm.com
Cc: linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org,
	shawn.lin@rock-chips.com, linux-arm-msm@vger.kernel.org,
	georgi.djakov@linaro.org, devicetree@vger.kernel.org,
	asutoshd@codeaurora.org, stummala@codeaurora.org,
	venkatg@codeaurora.org, vviswana@codeaurora.org,
	bjorn.andersson@linaro.org, riteshh@codeaurora.org,
	vbadigan@codeaurora.org, dianders@google.com,
	sayalil@codeaurora.org,
	Sujit Reddy Thumma <sthumma@codeaurora.org>
Subject: [PATCH V1 7/7] mmc: core: Add a debugfs entry to set max clock rate
Date: Mon,  8 Oct 2018 18:28:06 +0530	[thread overview]
Message-ID: <1539003486-24087-8-git-send-email-sayalil@codeaurora.org> (raw)
In-Reply-To: <1539003486-24087-1-git-send-email-sayalil@codeaurora.org>

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

Signed-off-by: Sujit Reddy Thumma <sthumma@codeaurora.org>
Signed-off-by: Sayali Lokhande <sayalil@codeaurora.org>
---
 drivers/mmc/core/debugfs.c | 44 ++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 44 insertions(+)

diff --git a/drivers/mmc/core/debugfs.c b/drivers/mmc/core/debugfs.c
index 630ca8e..26499f7 100644
--- a/drivers/mmc/core/debugfs.c
+++ b/drivers/mmc/core/debugfs.c
@@ -262,6 +262,46 @@ static int mmc_scale_set(void *data, u64 val)
 DEFINE_SIMPLE_ATTRIBUTE(mmc_scale_fops, mmc_scale_get, mmc_scale_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;
@@ -290,6 +330,10 @@ void mmc_add_host_debugfs(struct mmc_host *host)
 			&mmc_clock_fops))
 		goto err_node;
 
+	if (!debugfs_create_file("max_clock", 0600, root, host,
+		&mmc_max_clock_fops))
+		goto err_node;
+
 	if (!debugfs_create_file("scale", 0600, root, host,
 		&mmc_scale_fops))
 		goto err_node;
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project


      parent reply	other threads:[~2018-10-08 12:59 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-08 12:57 [PATCH V1 0/7] Add devfreq based clock scaling support for mmc Sayali Lokhande
2018-10-08 12:58 ` [PATCH V1 1/7] devfreq: Add new flag to do simple clock scaling Sayali Lokhande
2018-10-08 12:58 ` [PATCH V1 2/7] mmc: core: devfreq: Add devfreq based clock scaling support Sayali Lokhande
2018-10-17 14:04   ` Rob Herring
2018-10-08 12:58 ` [PATCH V1 3/7] mmc: core: Add sysfs entries for dynamic control of clock scaling Sayali Lokhande
2018-10-08 12:58 ` [PATCH V1 4/7] mmc: core: add support for devfreq suspend/resume Sayali Lokhande
2018-10-08 12:58 ` [PATCH V1 5/7] mmc: sdhci-msm: Kconfig: select devfreq ondemand for sdhci-msm Sayali Lokhande
2018-10-08 12:58 ` [PATCH V1 6/7] mmc: sdhci-msm: Enable clock scaling property Sayali Lokhande
2018-10-08 12:58 ` Sayali Lokhande [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1539003486-24087-8-git-send-email-sayalil@codeaurora.org \
    --to=sayalil@codeaurora.org \
    --cc=adrian.hunter@intel.com \
    --cc=asutoshd@codeaurora.org \
    --cc=bjorn.andersson@linaro.org \
    --cc=devicetree@vger.kernel.org \
    --cc=dianders@google.com \
    --cc=georgi.djakov@linaro.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mmc@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=riteshh@codeaurora.org \
    --cc=robh+dt@kernel.org \
    --cc=robh@kernel.org \
    --cc=shawn.lin@rock-chips.com \
    --cc=sthumma@codeaurora.org \
    --cc=stummala@codeaurora.org \
    --cc=ulf.hansson@linaro.org \
    --cc=vbadigan@codeaurora.org \
    --cc=venkatg@codeaurora.org \
    --cc=vviswana@codeaurora.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).