]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
mmc: debugfs: expose the SDCLK frq in sys ios (V6)
authorGiuseppe CAVALLARO <peppe.cavallaro@st.com>
Fri, 4 Nov 2011 12:53:19 +0000 (13:53 +0100)
committerChris Ball <cjb@laptop.org>
Sat, 12 Nov 2011 01:58:11 +0000 (20:58 -0500)
This patch is to expose the actual SDCLK frequency in
/sys/kernel/debug/mmcX/ios entry.

For example, if the max clk for a normal speed card is 20MHz this
is reported in /sys/kernel/debug/mmcX/ios.  Unfortunately the actual
SDCLK frequency (i.e. Baseclock / divisor) is not reported at all:
for example, in that case, on Arasan HC, it should be 48/4=12 (MHz).

Signed-off-by: Giuseppe Cavallaro <peppe.cavallaro@st.com>
Acked-by: Adrian Hunter <adrian.hunter@intel.com>
Signed-off-by: Chris Ball <cjb@laptop.org>
drivers/mmc/core/debugfs.c
drivers/mmc/host/sdhci.c
include/linux/mmc/host.h

index 6045ea469362ebf3875f57af34c13451d9c665ad..03f47f005203c2b5bed23ab1e39cbaf57284ee78 100644 (file)
@@ -56,6 +56,8 @@ static int mmc_ios_show(struct seq_file *s, void *data)
        const char *str;
 
        seq_printf(s, "clock:\t\t%u Hz\n", ios->clock);
+       if (host->actual_clock)
+               seq_printf(s, "actual clock:\t%u Hz\n", host->actual_clock);
        seq_printf(s, "vdd:\t\t%u ", ios->vdd);
        if ((1 << ios->vdd) & MMC_VDD_165_195)
                seq_printf(s, "(1.65 - 1.95 V)\n");
index 6d8eea3235411e875250b3a8b7f588c2290304ec..f900239dea6524b5f387afacd75372e45f11da0e 100644 (file)
@@ -1066,12 +1066,15 @@ static void sdhci_finish_command(struct sdhci_host *host)
 static void sdhci_set_clock(struct sdhci_host *host, unsigned int clock)
 {
        int div = 0; /* Initialized for compiler warning */
+       int real_div = div, clk_mul = 1;
        u16 clk = 0;
        unsigned long timeout;
 
        if (clock == host->clock)
                return;
 
+       host->mmc->actual_clock = 0;
+
        if (host->ops->set_clock) {
                host->ops->set_clock(host, clock);
                if (host->quirks & SDHCI_QUIRK_NONSTANDARD_CLOCK)
@@ -1109,6 +1112,8 @@ static void sdhci_set_clock(struct sdhci_host *host, unsigned int clock)
                                 * Control register.
                                 */
                                clk = SDHCI_PROG_CLOCK_MODE;
+                               real_div = div;
+                               clk_mul = host->clk_mul;
                                div--;
                        }
                } else {
@@ -1122,6 +1127,7 @@ static void sdhci_set_clock(struct sdhci_host *host, unsigned int clock)
                                                break;
                                }
                        }
+                       real_div = div;
                        div >>= 1;
                }
        } else {
@@ -1130,9 +1136,13 @@ static void sdhci_set_clock(struct sdhci_host *host, unsigned int clock)
                        if ((host->max_clk / div) <= clock)
                                break;
                }
+               real_div = div;
                div >>= 1;
        }
 
+       if (real_div)
+               host->mmc->actual_clock = (host->max_clk * clk_mul) / real_div;
+
        clk |= (div & SDHCI_DIV_MASK) << SDHCI_DIVIDER_SHIFT;
        clk |= ((div & SDHCI_DIV_HI_MASK) >> SDHCI_DIV_MASK_LEN)
                << SDHCI_DIVIDER_HI_SHIFT;
index 7206c808e2b53bfb3839b60d197427bdfe45c361..706f72279a17a67e210f153110225addc61c6e6e 100644 (file)
@@ -325,6 +325,8 @@ struct mmc_host {
        struct fault_attr       fail_mmc_request;
 #endif
 
+       unsigned int            actual_clock;   /* Actual HC clock rate */
+
        unsigned long           private[0] ____cacheline_aligned;
 };