linux-mmc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] sdhci: expose the SDCLK frq in sys ios
@ 2011-10-19 13:45 Giuseppe CAVALLARO
  2011-10-20  6:22 ` Adrian Hunter
                   ` (2 more replies)
  0 siblings, 3 replies; 13+ messages in thread
From: Giuseppe CAVALLARO @ 2011-10-19 13:45 UTC (permalink / raw)
  To: linux-mmc; +Cc: Giuseppe Cavallaro

This patch is to expose the SDCLK frequency in the ios /sys entry.

For example, if the max clk for a normal speed card is 20MHz
this will be reported in /sys/kernel/debug/mmc0/ios instead of
the real SDCLK frequency (calculated as Baseclock / divisor;
divisor used for programming the Clock Control Register).

Signed-off-by: Giuseppe Cavallaro <peppe.cavallaro@st.com>
---
 drivers/mmc/host/sdhci.c |    9 ++++++++-
 1 files changed, 8 insertions(+), 1 deletions(-)

diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
index 0e02cc1..6bdf64f 100644
--- a/drivers/mmc/host/sdhci.c
+++ b/drivers/mmc/host/sdhci.c
@@ -1045,6 +1045,7 @@ static void sdhci_set_clock(struct sdhci_host *host, unsigned int clock)
 	int div = 0; /* Initialized for compiler warning */
 	u16 clk = 0;
 	unsigned long timeout;
+	unsigned int new_hc_clock = host->max_clk;
 
 	if (clock == host->clock)
 		return;
@@ -1134,7 +1135,10 @@ static void sdhci_set_clock(struct sdhci_host *host, unsigned int clock)
 	sdhci_writew(host, clk, SDHCI_CLOCK_CONTROL);
 
 out:
-	host->clock = clock;
+	if (div)
+		new_hc_clock = host->max_clk / div;
+
+	host->clock = new_hc_clock;
 }
 
 static void sdhci_set_power(struct sdhci_host *host, unsigned short power)
@@ -1293,6 +1297,9 @@ static void sdhci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
 
 	sdhci_set_clock(host, ios->clock);
 
+	/* Clock provided to the HC */
+	ios->clock = host->clock;
+
 	if (ios->power_mode == MMC_POWER_OFF)
 		sdhci_set_power(host, -1);
 	else
-- 
1.7.4.4


^ permalink raw reply related	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2011-11-03  6:46 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-10-19 13:45 [PATCH] sdhci: expose the SDCLK frq in sys ios Giuseppe CAVALLARO
2011-10-20  6:22 ` Adrian Hunter
2011-10-20  6:31   ` Giuseppe CAVALLARO
2011-10-20  7:38     ` Adrian Hunter
2011-10-20  8:00       ` Giuseppe CAVALLARO
2011-10-21  8:16 ` [PATCH] mmc: debugfs: expose the SDCLK frq in sys ios (v2) Giuseppe CAVALLARO
2011-10-25  8:40   ` Adrian Hunter
2011-10-26 11:21     ` Giuseppe CAVALLARO
2011-10-27  6:16 ` [PATCH] mmc: debugfs: expose the SDCLK frq in sys ios (v3) Giuseppe CAVALLARO
2011-10-27 22:02   ` Sebastian Rasmussen
2011-11-03  6:46     ` Giuseppe CAVALLARO
2011-11-02 10:38   ` Adrian Hunter
2011-11-03  6:46     ` Giuseppe CAVALLARO

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).