* [PATCH] mmc: debugfs: expose the SDCLK frq in sys ios (V4)
@ 2011-11-03 6:45 Giuseppe CAVALLARO
2011-11-03 7:41 ` Adrian Hunter
2011-11-04 7:16 ` [PATCH] mmc: debugfs: expose the SDCLK frq in sys ios (V5) Giuseppe CAVALLARO
0 siblings, 2 replies; 8+ messages in thread
From: Giuseppe CAVALLARO @ 2011-11-03 6:45 UTC (permalink / raw)
To: linux-mmc; +Cc: sebras, adrian.hunter, Giuseppe Cavallaro
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 | 9 +++++++++
include/linux/mmc/host.h | 2 ++
3 files changed, 13 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..3ee94dc 100644
--- a/drivers/mmc/host/sdhci.c
+++ b/drivers/mmc/host/sdhci.c
@@ -1043,12 +1043,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)
@@ -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,12 @@ static void sdhci_set_clock(struct sdhci_host *host, unsigned int clock)
if ((host->max_clk / div) <= clock)
break;
}
+ real_div = div;
div >>= 1;
}
+ 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;
};
--
1.7.4.4
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH] mmc: debugfs: expose the SDCLK frq in sys ios (V4)
2011-11-03 6:45 [PATCH] mmc: debugfs: expose the SDCLK frq in sys ios (V4) Giuseppe CAVALLARO
@ 2011-11-03 7:41 ` Adrian Hunter
2011-11-04 6:56 ` Giuseppe CAVALLARO
2011-11-04 7:16 ` [PATCH] mmc: debugfs: expose the SDCLK frq in sys ios (V5) Giuseppe CAVALLARO
1 sibling, 1 reply; 8+ messages in thread
From: Adrian Hunter @ 2011-11-03 7:41 UTC (permalink / raw)
To: Giuseppe CAVALLARO; +Cc: linux-mmc, sebras
On 03/11/11 08:45, 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>
This did not apply cleanly to Chris' mmc-next branch. Maybe you
could rebase
> ---
> drivers/mmc/core/debugfs.c | 2 ++
> drivers/mmc/host/sdhci.c | 9 +++++++++
> include/linux/mmc/host.h | 2 ++
> 3 files changed, 13 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..3ee94dc 100644
> --- a/drivers/mmc/host/sdhci.c
> +++ b/drivers/mmc/host/sdhci.c
> @@ -1043,12 +1043,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)
> @@ -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,12 @@ static void sdhci_set_clock(struct sdhci_host *host, unsigned int clock)
> if ((host->max_clk / div) <= clock)
> break;
> }
> + real_div = div;
> div >>= 1;
> }
>
You dropped the "if (real_div)" from V3 but it is needed in one case
i.e. (ctrl & SDHCI_CTRL_PRESET_VAL_ENABLE)
> + 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;
> };
>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] mmc: debugfs: expose the SDCLK frq in sys ios (V4)
2011-11-03 7:41 ` Adrian Hunter
@ 2011-11-04 6:56 ` Giuseppe CAVALLARO
0 siblings, 0 replies; 8+ messages in thread
From: Giuseppe CAVALLARO @ 2011-11-04 6:56 UTC (permalink / raw)
To: Adrian Hunter; +Cc: linux-mmc, sebras
On 11/3/2011 8:41 AM, Adrian Hunter wrote:
> On 03/11/11 08:45, 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>
>
> This did not apply cleanly to Chris' mmc-next branch. Maybe you
> could rebase
Yes I could and send again.
Peppe
>> ---
>> drivers/mmc/core/debugfs.c | 2 ++
>> drivers/mmc/host/sdhci.c | 9 +++++++++
>> include/linux/mmc/host.h | 2 ++
>> 3 files changed, 13 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..3ee94dc 100644
>> --- a/drivers/mmc/host/sdhci.c
>> +++ b/drivers/mmc/host/sdhci.c
>> @@ -1043,12 +1043,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)
>> @@ -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,12 @@ static void sdhci_set_clock(struct sdhci_host *host, unsigned int clock)
>> if ((host->max_clk / div) <= clock)
>> break;
>> }
>> + real_div = div;
>> div >>= 1;
>> }
>>
>
> You dropped the "if (real_div)" from V3 but it is needed in one case
> i.e. (ctrl & SDHCI_CTRL_PRESET_VAL_ENABLE)
>
>
>> + 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
>
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH] mmc: debugfs: expose the SDCLK frq in sys ios (V5)
2011-11-03 6:45 [PATCH] mmc: debugfs: expose the SDCLK frq in sys ios (V4) Giuseppe CAVALLARO
2011-11-03 7:41 ` Adrian Hunter
@ 2011-11-04 7:16 ` Giuseppe CAVALLARO
2011-11-04 9:00 ` Adrian Hunter
1 sibling, 1 reply; 8+ messages in thread
From: Giuseppe CAVALLARO @ 2011-11-04 7:16 UTC (permalink / raw)
To: linux-mmc; +Cc: adrian.hunter, Giuseppe Cavallaro
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 | 9 +++++++++
include/linux/mmc/host.h | 2 ++
3 files changed, 13 insertions(+), 0 deletions(-)
diff --git a/drivers/mmc/core/debugfs.c b/drivers/mmc/core/debugfs.c
index c3f24a7..688f4f8 100644
--- a/drivers/mmc/core/debugfs.c
+++ b/drivers/mmc/core/debugfs.c
@@ -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");
diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
index 6d8eea3..f801609 100644
--- a/drivers/mmc/host/sdhci.c
+++ b/drivers/mmc/host/sdhci.c
@@ -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,12 @@ static void sdhci_set_clock(struct sdhci_host *host, unsigned int clock)
if ((host->max_clk / div) <= clock)
break;
}
+ real_div = div;
div >>= 1;
}
+ 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 a3ac9c4..cea064f 100644
--- a/include/linux/mmc/host.h
+++ b/include/linux/mmc/host.h
@@ -323,6 +323,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;
};
--
1.7.4.4
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH] mmc: debugfs: expose the SDCLK frq in sys ios (V5)
2011-11-04 7:16 ` [PATCH] mmc: debugfs: expose the SDCLK frq in sys ios (V5) Giuseppe CAVALLARO
@ 2011-11-04 9:00 ` Adrian Hunter
2011-11-04 12:53 ` [PATCH] mmc: debugfs: expose the SDCLK frq in sys ios (V6) Giuseppe CAVALLARO
0 siblings, 1 reply; 8+ messages in thread
From: Adrian Hunter @ 2011-11-04 9:00 UTC (permalink / raw)
To: Giuseppe CAVALLARO; +Cc: linux-mmc
On 04/11/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 | 9 +++++++++
> include/linux/mmc/host.h | 2 ++
> 3 files changed, 13 insertions(+), 0 deletions(-)
>
> diff --git a/drivers/mmc/core/debugfs.c b/drivers/mmc/core/debugfs.c
> index c3f24a7..688f4f8 100644
> --- a/drivers/mmc/core/debugfs.c
> +++ b/drivers/mmc/core/debugfs.c
> @@ -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");
> diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
> index 6d8eea3..f801609 100644
> --- a/drivers/mmc/host/sdhci.c
> +++ b/drivers/mmc/host/sdhci.c
> @@ -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,12 @@ static void sdhci_set_clock(struct sdhci_host *host, unsigned int clock)
> if ((host->max_clk / div) <= clock)
> break;
> }
> + real_div = div;
> div >>= 1;
> }
>
> + host->mmc->actual_clock = (host->max_clk * clk_mul) / real_div;
Still missing the "if (real_div)" from V3 but it is needed in one case
i.e. (ctrl & SDHCI_CTRL_PRESET_VAL_ENABLE)
> +
> 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 a3ac9c4..cea064f 100644
> --- a/include/linux/mmc/host.h
> +++ b/include/linux/mmc/host.h
> @@ -323,6 +323,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;
> };
>
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH] mmc: debugfs: expose the SDCLK frq in sys ios (V6)
2011-11-04 9:00 ` Adrian Hunter
@ 2011-11-04 12:53 ` Giuseppe CAVALLARO
2011-11-04 13:37 ` Adrian Hunter
0 siblings, 1 reply; 8+ messages in thread
From: Giuseppe CAVALLARO @ 2011-11-04 12:53 UTC (permalink / raw)
To: linux-mmc; +Cc: adrian.hunter, Giuseppe Cavallaro
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 c3f24a7..688f4f8 100644
--- a/drivers/mmc/core/debugfs.c
+++ b/drivers/mmc/core/debugfs.c
@@ -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");
diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
index 6d8eea3..f900239 100644
--- a/drivers/mmc/host/sdhci.c
+++ b/drivers/mmc/host/sdhci.c
@@ -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;
diff --git a/include/linux/mmc/host.h b/include/linux/mmc/host.h
index a3ac9c4..cea064f 100644
--- a/include/linux/mmc/host.h
+++ b/include/linux/mmc/host.h
@@ -323,6 +323,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;
};
--
1.7.4.4
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH] mmc: debugfs: expose the SDCLK frq in sys ios (V6)
2011-11-04 12:53 ` [PATCH] mmc: debugfs: expose the SDCLK frq in sys ios (V6) Giuseppe CAVALLARO
@ 2011-11-04 13:37 ` Adrian Hunter
2011-11-12 1:59 ` Chris Ball
0 siblings, 1 reply; 8+ messages in thread
From: Adrian Hunter @ 2011-11-04 13:37 UTC (permalink / raw)
To: Giuseppe CAVALLARO; +Cc: linux-mmc, Chris Ball
On 04/11/11 14:53, 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>
Acked-by: Adrian Hunter <adrian.hunter@intel.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(-)
>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] mmc: debugfs: expose the SDCLK frq in sys ios (V6)
2011-11-04 13:37 ` Adrian Hunter
@ 2011-11-12 1:59 ` Chris Ball
0 siblings, 0 replies; 8+ messages in thread
From: Chris Ball @ 2011-11-12 1:59 UTC (permalink / raw)
To: Adrian Hunter; +Cc: Giuseppe CAVALLARO, linux-mmc
Hi,
On Fri, Nov 04 2011, Adrian Hunter wrote:
> On 04/11/11 14:53, 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>
>
> Acked-by: Adrian Hunter <adrian.hunter@intel.com>
Pushed to mmc-next for 3.3 with Adrian's ACK, thanks.
- Chris.
--
Chris Ball <cjb@laptop.org> <http://printf.net/>
One Laptop Per Child
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2011-11-12 1:59 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-11-03 6:45 [PATCH] mmc: debugfs: expose the SDCLK frq in sys ios (V4) Giuseppe CAVALLARO
2011-11-03 7:41 ` Adrian Hunter
2011-11-04 6:56 ` Giuseppe CAVALLARO
2011-11-04 7:16 ` [PATCH] mmc: debugfs: expose the SDCLK frq in sys ios (V5) Giuseppe CAVALLARO
2011-11-04 9:00 ` Adrian Hunter
2011-11-04 12:53 ` [PATCH] mmc: debugfs: expose the SDCLK frq in sys ios (V6) Giuseppe CAVALLARO
2011-11-04 13:37 ` Adrian Hunter
2011-11-12 1:59 ` Chris Ball
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).