From: Giuseppe CAVALLARO <peppe.cavallaro@st.com>
To: Adrian Hunter <adrian.hunter@intel.com>
Cc: linux-mmc@vger.kernel.org
Subject: Re: [PATCH] mmc: debugfs: expose the SDCLK frq in sys ios (v3)
Date: Thu, 03 Nov 2011 07:46:19 +0100 [thread overview]
Message-ID: <4EB238BB.7040007@st.com> (raw)
In-Reply-To: <4EB11D89.5010909@intel.com>
On 11/2/2011 11:38 AM, Adrian Hunter wrote:
> On 27/10/11 09:16, Giuseppe CAVALLARO wrote:
>> 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>
>> ---
>> drivers/mmc/core/debugfs.c | 2 ++
>> drivers/mmc/host/sdhci.c | 10 ++++++++++
>> include/linux/mmc/host.h | 2 ++
>> 3 files changed, 14 insertions(+), 0 deletions(-)
>>
>> diff --git a/drivers/mmc/core/debugfs.c b/drivers/mmc/core/debugfs.c
>> index 998797e..0b9a4aa 100644
>> --- a/drivers/mmc/core/debugfs.c
>> +++ b/drivers/mmc/core/debugfs.c
>> @@ -46,6 +46,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");
>> diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
>> index 0e02cc1..6bfdec5 100644
>> --- a/drivers/mmc/host/sdhci.c
>> +++ b/drivers/mmc/host/sdhci.c
>> @@ -1043,9 +1043,12 @@ 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;
>>
>> + host->mmc->actual_clock = 0;
>> +
>
> This needs to come after "if (clock == host->clock) return;"
fixed in V4
thx
peppe
>
>> if (clock == host->clock)
>> return;
>>
>> @@ -1086,6 +1089,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 {
>> @@ -1099,6 +1104,7 @@ static void sdhci_set_clock(struct sdhci_host *host, unsigned int clock)
>> break;
>> }
>> }
>> + real_div = div;
>> div >>= 1;
>> }
>> } else {
>> @@ -1107,9 +1113,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;
>> diff --git a/include/linux/mmc/host.h b/include/linux/mmc/host.h
>> index 1d09562..d815311 100644
>> --- a/include/linux/mmc/host.h
>> +++ b/include/linux/mmc/host.h
>> @@ -302,6 +302,8 @@ struct mmc_host {
>>
>> struct mmc_async_req *areq; /* active async req */
>>
>> + unsigned int actual_clock; /* Actual HC clock rate */
>> +
>> unsigned long private[0] ____cacheline_aligned;
>> };
>>
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
prev parent reply other threads:[~2011-11-03 6:46 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
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 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=4EB238BB.7040007@st.com \
--to=peppe.cavallaro@st.com \
--cc=adrian.hunter@intel.com \
--cc=linux-mmc@vger.kernel.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.