All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
From: aisheng.dong@freescale.com (Dong Aisheng)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 3/6] mmc: sdhci: make max-frequency property in device tree work
Date: Thu, 18 Jun 2015 02:05:34 +0800	[thread overview]
Message-ID: <1434564337-24720-4-git-send-email-aisheng.dong@freescale.com> (raw)
In-Reply-To: <1434564337-24720-1-git-send-email-aisheng.dong@freescale.com>

Device tree provides option to specify the max freqency with property
"max-frequency" in dts and common parse function mmc_of_parse() will
parse it and use this value to set host->f_max to tell the MMC core
the maxinum frequency the host works.

However, current sdhci driver will finally overwrite this value with
host->max_clk regardless of the max-frequency property.

This patch makes sure not overwrite the max-frequency set from device
tree and do basic sanity check.

Signed-off-by: Dong Aisheng <aisheng.dong@freescale.com>
---
 drivers/mmc/host/sdhci.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
index bc14452..0781c92 100644
--- a/drivers/mmc/host/sdhci.c
+++ b/drivers/mmc/host/sdhci.c
@@ -2866,6 +2866,7 @@ int sdhci_add_host(struct sdhci_host *host)
 	u32 max_current_caps;
 	unsigned int ocr_avail;
 	unsigned int override_timeout_clk;
+	u32 max_clk;
 	int ret;
 
 	WARN_ON(host == NULL);
@@ -3047,18 +3048,22 @@ int sdhci_add_host(struct sdhci_host *host)
 	 * Set host parameters.
 	 */
 	mmc->ops = &sdhci_ops;
-	mmc->f_max = host->max_clk;
+	max_clk = host->max_clk;
+
 	if (host->ops->get_min_clock)
 		mmc->f_min = host->ops->get_min_clock(host);
 	else if (host->version >= SDHCI_SPEC_300) {
 		if (host->clk_mul) {
 			mmc->f_min = (host->max_clk * host->clk_mul) / 1024;
-			mmc->f_max = host->max_clk * host->clk_mul;
+			max_clk = host->max_clk * host->clk_mul;
 		} else
 			mmc->f_min = host->max_clk / SDHCI_MAX_DIV_SPEC_300;
 	} else
 		mmc->f_min = host->max_clk / SDHCI_MAX_DIV_SPEC_200;
 
+	if (!mmc->f_max || (mmc->f_max && (mmc->f_max > max_clk)))
+		mmc->f_max = max_clk;
+
 	if (!(host->quirks & SDHCI_QUIRK_DATA_TIMEOUT_USES_SDCLK)) {
 		host->timeout_clk = (caps[0] & SDHCI_TIMEOUT_CLK_MASK) >>
 					SDHCI_TIMEOUT_CLK_SHIFT;
-- 
1.9.1

WARNING: multiple messages have this Message-ID (diff)
From: Dong Aisheng <aisheng.dong@freescale.com>
To: linux-mmc@vger.kernel.org
Cc: ulf.hansson@linaro.org, chris@printf.net, shawn.guo@linaro.org,
	b29396@freescale.com, fabio.estevam@freescale.com,
	gwenhael.goavec-merou@armadeus.com, marex@denx.de,
	s.trumtrar@pengutronix.de, s.hauer@pengutronix.de,
	lisovy@gmail.com, ipaton0@gmail.com, smoch@web.de, hs@denx.de,
	rmk+kernel@arm.linux.org.uk, tharvey@gateworks.com,
	rabeeh@solid-run.com, troy.kisky@boundarydevices.com,
	p.zabel@pengutronix.de, robertcnelson@gmail.com,
	LW@KARO-electronics.de, linux-arm-kernel@lists.infradead.org
Subject: [PATCH 3/6] mmc: sdhci: make max-frequency property in device tree work
Date: Thu, 18 Jun 2015 02:05:34 +0800	[thread overview]
Message-ID: <1434564337-24720-4-git-send-email-aisheng.dong@freescale.com> (raw)
In-Reply-To: <1434564337-24720-1-git-send-email-aisheng.dong@freescale.com>

Device tree provides option to specify the max freqency with property
"max-frequency" in dts and common parse function mmc_of_parse() will
parse it and use this value to set host->f_max to tell the MMC core
the maxinum frequency the host works.

However, current sdhci driver will finally overwrite this value with
host->max_clk regardless of the max-frequency property.

This patch makes sure not overwrite the max-frequency set from device
tree and do basic sanity check.

Signed-off-by: Dong Aisheng <aisheng.dong@freescale.com>
---
 drivers/mmc/host/sdhci.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
index bc14452..0781c92 100644
--- a/drivers/mmc/host/sdhci.c
+++ b/drivers/mmc/host/sdhci.c
@@ -2866,6 +2866,7 @@ int sdhci_add_host(struct sdhci_host *host)
 	u32 max_current_caps;
 	unsigned int ocr_avail;
 	unsigned int override_timeout_clk;
+	u32 max_clk;
 	int ret;
 
 	WARN_ON(host == NULL);
@@ -3047,18 +3048,22 @@ int sdhci_add_host(struct sdhci_host *host)
 	 * Set host parameters.
 	 */
 	mmc->ops = &sdhci_ops;
-	mmc->f_max = host->max_clk;
+	max_clk = host->max_clk;
+
 	if (host->ops->get_min_clock)
 		mmc->f_min = host->ops->get_min_clock(host);
 	else if (host->version >= SDHCI_SPEC_300) {
 		if (host->clk_mul) {
 			mmc->f_min = (host->max_clk * host->clk_mul) / 1024;
-			mmc->f_max = host->max_clk * host->clk_mul;
+			max_clk = host->max_clk * host->clk_mul;
 		} else
 			mmc->f_min = host->max_clk / SDHCI_MAX_DIV_SPEC_300;
 	} else
 		mmc->f_min = host->max_clk / SDHCI_MAX_DIV_SPEC_200;
 
+	if (!mmc->f_max || (mmc->f_max && (mmc->f_max > max_clk)))
+		mmc->f_max = max_clk;
+
 	if (!(host->quirks & SDHCI_QUIRK_DATA_TIMEOUT_USES_SDCLK)) {
 		host->timeout_clk = (caps[0] & SDHCI_TIMEOUT_CLK_MASK) >>
 					SDHCI_TIMEOUT_CLK_SHIFT;
-- 
1.9.1


  parent reply	other threads:[~2015-06-17 18:05 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-17 18:05 [PATCH 0/6] mmc: sdhci-esdhci-imx: fix cd/wp regression Dong Aisheng
2015-06-17 18:05 ` Dong Aisheng
2015-06-17 18:05 ` [PATCH 1/6] mmc: sdhci-esdhc-imx: fix cd regression for dt platform Dong Aisheng
2015-06-17 18:05   ` Dong Aisheng
2015-06-17 18:05 ` [PATCH 2/6] mmc: sdhci-esdhc-imx: move all non dt probe code into one function Dong Aisheng
2015-06-17 18:05   ` Dong Aisheng
2015-06-17 18:05 ` Dong Aisheng [this message]
2015-06-17 18:05   ` [PATCH 3/6] mmc: sdhci: make max-frequency property in device tree work Dong Aisheng
2015-06-17 18:05 ` [PATCH 4/6] mmc: sdhci-esdhc-imx: remove duplicated dts parsing Dong Aisheng
2015-06-17 18:05   ` Dong Aisheng
2015-07-09  7:38   ` Shawn Guo
2015-07-09  7:38     ` Shawn Guo
2015-07-09  8:59     ` Dong Aisheng
2015-07-09  8:59       ` Dong Aisheng
2015-06-17 18:05 ` [PATCH 5/6] mmc: sdhci-esdhc-imx: clear f_max in boarddata Dong Aisheng
2015-06-17 18:05   ` Dong Aisheng
2015-06-17 18:05 ` [PATCH 6/6] dts: mmc: fsl-imx-esdhc: remove fsl, cd-controller support Dong Aisheng
2015-06-17 18:05   ` [PATCH 6/6] dts: mmc: fsl-imx-esdhc: remove fsl,cd-controller support Dong Aisheng
2015-07-06 11:57 ` [PATCH 0/6] mmc: sdhci-esdhci-imx: fix cd/wp regression Johan Derycke
2015-07-09  7:50 ` Shawn Guo
2015-07-09  7:50   ` Shawn Guo
2015-07-09  9:29   ` Dong Aisheng
2015-07-09  9:29     ` Dong Aisheng
2015-07-09 13:27     ` Shawn Guo
2015-07-09 13:27       ` Shawn Guo
2015-07-09 17:02       ` Enrico Weigelt, metux IT consult
2015-07-09 17:02         ` Enrico Weigelt, metux IT consult
2015-07-13 11:43       ` Dong Aisheng
2015-07-13 11:43         ` Dong Aisheng
2015-07-14  5:25         ` Soeren Moch
2015-07-14  5:25           ` Soeren Moch
2015-07-22 13:59           ` Dong Aisheng
2015-07-22 13:59             ` Dong Aisheng
2015-07-20 12:44         ` Ulf Hansson
2015-07-20 12:44           ` Ulf Hansson
2015-07-22 14:05           ` Dong Aisheng
2015-07-22 14:05             ` Dong Aisheng

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=1434564337-24720-4-git-send-email-aisheng.dong@freescale.com \
    --to=aisheng.dong@freescale.com \
    --cc=linux-arm-kernel@lists.infradead.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.