public inbox for linux-mmc@vger.kernel.org
 help / color / mirror / Atom feed
From: Adrian Hunter <adrian.hunter@intel.com>
To: Ulf Hansson <ulf.hansson@linaro.org>, Chris Ball <chris@printf.net>
Cc: linux-mmc <linux-mmc@vger.kernel.org>,
	Philip Rakity <prakity@nvidia.com>,
	Adrian Hunter <adrian.hunter@intel.com>,
	"Rafael J. Wysocki" <rafael.j.wysocki@intel.com>,
	Mika Westerberg <mika.westerberg@linux.intel.com>
Subject: [PATCH 09/12] mmc: core: Add function to read driver-strength device property
Date: Thu,  5 Feb 2015 15:13:46 +0200	[thread overview]
Message-ID: <1423142029-22521-10-git-send-email-adrian.hunter@intel.com> (raw)
In-Reply-To: <1423142029-22521-1-git-send-email-adrian.hunter@intel.com>

Add a function to read a new "driver-strength" device property.

Currently there is no documentation for device properties,
so add "driver-strength" to mmc devicetree bindings.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Cc: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Cc: Mika Westerberg <mika.westerberg@linux.intel.com>
---
 Documentation/devicetree/bindings/mmc/mmc.txt |  4 ++++
 drivers/mmc/core/host.c                       | 21 +++++++++++++++++++++
 include/linux/mmc/host.h                      |  2 ++
 3 files changed, 27 insertions(+)

diff --git a/Documentation/devicetree/bindings/mmc/mmc.txt b/Documentation/devicetree/bindings/mmc/mmc.txt
index 438899e..cfcb66b 100644
--- a/Documentation/devicetree/bindings/mmc/mmc.txt
+++ b/Documentation/devicetree/bindings/mmc/mmc.txt
@@ -43,6 +43,10 @@ Optional properties:
 - dsr: Value the card's (optional) Driver Stage Register (DSR) should be
   programmed with. Valid range: [0 .. 0xffff].
 
+Device properties (use device_property_ API):
+- driver-strength: Optional driver strength value for a card using UHS-I or
+  HS200/HS400
+
 *NOTE* on CD and WP polarity. To use common for all SD/MMC host controllers line
 polarity properties, we have to fix the meaning of the "normal" and "inverted"
 line levels. We choose to follow the SDHCI standard, which specifies both those
diff --git a/drivers/mmc/core/host.c b/drivers/mmc/core/host.c
index 20354a5..bf19d14 100644
--- a/drivers/mmc/core/host.c
+++ b/drivers/mmc/core/host.c
@@ -22,6 +22,7 @@
 #include <linux/leds.h>
 #include <linux/slab.h>
 #include <linux/suspend.h>
+#include <linux/property.h>
 
 #include <linux/mmc/host.h>
 #include <linux/mmc/card.h>
@@ -516,6 +517,26 @@ int mmc_of_parse(struct mmc_host *host)
 
 EXPORT_SYMBOL(mmc_of_parse);
 
+int mmc_host_read_drive_strength(struct mmc_host *host)
+{
+	struct device *dev = host->parent;
+	u8 drive_strength;
+	int err;
+
+	if (!device_property_present(dev, "driver-strength"))
+		return -ENODATA;
+
+	err = device_property_read_u8(dev, "driver-strength", &drive_strength);
+	if (err) {
+		dev_err(dev, "Bad \"driver-strength\" property, error %d\n",
+			err);
+		return -EINVAL;
+	}
+
+	return drive_strength;
+}
+EXPORT_SYMBOL(mmc_host_read_drive_strength);
+
 /**
  *	mmc_alloc_host - initialise the per-host structure.
  *	@extra: sizeof private data structure
diff --git a/include/linux/mmc/host.h b/include/linux/mmc/host.h
index 967e7db..d876892 100644
--- a/include/linux/mmc/host.h
+++ b/include/linux/mmc/host.h
@@ -394,6 +394,8 @@ void mmc_remove_host(struct mmc_host *);
 void mmc_free_host(struct mmc_host *);
 int mmc_of_parse(struct mmc_host *host);
 
+int mmc_host_read_drive_strength(struct mmc_host *host);
+
 static inline void *mmc_priv(struct mmc_host *host)
 {
 	return (void *)host->private;
-- 
1.9.1


  parent reply	other threads:[~2015-02-05 13:18 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-05 13:13 [PATCH 00/12] mmc: Add support for drive strength for eMMCs Adrian Hunter
2015-02-05 13:13 ` [PATCH 01/12] mmc: core: Reset driver type to default Adrian Hunter
2015-02-05 13:13 ` [PATCH 02/12] mmc: core: Allow card drive strength to be different to host Adrian Hunter
2015-02-05 13:13 ` [PATCH 03/12] mmc: core: Simplify card drive strength mask Adrian Hunter
2015-02-05 13:13 ` [PATCH 04/12] mmc: core: Add 'card' to drive strength selection callback Adrian Hunter
2015-02-05 13:13 ` [PATCH 05/12] mmc: core: Factor out common code in drive strength selection Adrian Hunter
2015-02-05 13:13 ` [PATCH 06/12] mmc: core: Record card drive strength Adrian Hunter
2015-02-05 13:13 ` [PATCH 07/12] mmc: mmc: Read card's valid driver strength mask Adrian Hunter
2015-02-05 13:13 ` [PATCH 08/12] mmc: mmc: Add driver strength selection Adrian Hunter
2015-02-05 13:13 ` Adrian Hunter [this message]
2015-02-05 13:13 ` [PATCH 10/12] mmc: sdhci: Add a callback to select drive strength Adrian Hunter
2015-02-05 13:13 ` [PATCH 11/12] mmc: sdhci-pci: Add support for drive strength selection for SPT Adrian Hunter
2015-02-05 13:13 ` [PATCH 12/12] mmc: sdhci-pci: Enable HS400 for some Intel host controllers Adrian Hunter

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=1423142029-22521-10-git-send-email-adrian.hunter@intel.com \
    --to=adrian.hunter@intel.com \
    --cc=chris@printf.net \
    --cc=linux-mmc@vger.kernel.org \
    --cc=mika.westerberg@linux.intel.com \
    --cc=prakity@nvidia.com \
    --cc=rafael.j.wysocki@intel.com \
    --cc=ulf.hansson@linaro.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