linux-mmc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/3] sdhci: Implement CAP_CLOCK_BASE_BROKEN quirk
@ 2010-02-19 19:48 Anton Vorontsov
  2010-02-19 19:55 ` David Vrabel
  0 siblings, 1 reply; 4+ messages in thread
From: Anton Vorontsov @ 2010-02-19 19:48 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Richard Röjfors, Pierre Ossman, Ben Dooks, linux-mmc,
	linux-kernel

Some hosts (e.g. as found in CNS3xxx SOCs) report wrong value in
CLOCK_BASE capability field, and currently there is no way to
force the SDHCI core to use the platform-provided base clock value.

This patch implements CAP_CLOCK_BASE_BROKEN quirk. When enabled,
the SDHCI core will always use base clock frequency provided by
the platform.

Signed-off-by: Anton Vorontsov <avorontsov@ru.mvista.com>
---
 drivers/mmc/host/sdhci.c |    3 ++-
 drivers/mmc/host/sdhci.h |    2 ++
 2 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
index c279fbc..aedf4a1 100644
--- a/drivers/mmc/host/sdhci.c
+++ b/drivers/mmc/host/sdhci.c
@@ -1745,7 +1745,8 @@ int sdhci_add_host(struct sdhci_host *host)
 	host->max_clk =
 		(caps & SDHCI_CLOCK_BASE_MASK) >> SDHCI_CLOCK_BASE_SHIFT;
 	host->max_clk *= 1000000;
-	if (host->max_clk == 0) {
+	if (host->max_clk == 0 || host->quirks &
+			SDHCI_QUIRK_CAP_CLOCK_BASE_BROKEN) {
 		if (!host->ops->get_max_clock) {
 			printk(KERN_ERR
 			       "%s: Hardware doesn't specify base clock "
diff --git a/drivers/mmc/host/sdhci.h b/drivers/mmc/host/sdhci.h
index 842f46f..831bf7f 100644
--- a/drivers/mmc/host/sdhci.h
+++ b/drivers/mmc/host/sdhci.h
@@ -236,6 +236,8 @@ struct sdhci_host {
 #define SDHCI_QUIRK_DELAY_AFTER_POWER			(1<<23)
 /* Controller uses SDCLK instead of TMCLK for data timeouts */
 #define SDHCI_QUIRK_DATA_TIMEOUT_USES_SDCLK		(1<<24)
+/* Controller reports wrong base clock capability */
+#define SDHCI_QUIRK_CAP_CLOCK_BASE_BROKEN		(1<<25)
 
 	int			irq;		/* Device IRQ */
 	void __iomem *		ioaddr;		/* Mapped address */
-- 
1.7.0

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

* Re: [PATCH 1/3] sdhci: Implement CAP_CLOCK_BASE_BROKEN quirk
  2010-02-19 19:48 [PATCH 1/3] sdhci: Implement CAP_CLOCK_BASE_BROKEN quirk Anton Vorontsov
@ 2010-02-19 19:55 ` David Vrabel
  2010-02-19 20:11   ` Anton Vorontsov
  0 siblings, 1 reply; 4+ messages in thread
From: David Vrabel @ 2010-02-19 19:55 UTC (permalink / raw)
  To: Anton Vorontsov
  Cc: Andrew Morton, Richard Röjfors, Pierre Ossman, Ben Dooks,
	linux-mmc, linux-kernel

Anton Vorontsov wrote:
> Some hosts (e.g. as found in CNS3xxx SOCs) report wrong value in
> CLOCK_BASE capability field, and currently there is no way to
> force the SDHCI core to use the platform-provided base clock value.

I don't think this needs a new quirk. Change the sdhci driver to check
if the platform provides a value before reading the standard register.

David
-- 
David Vrabel, Senior Software Engineer, Drivers
CSR, Churchill House, Cambridge Business Park,  Tel: +44 (0)1223 692562
Cowley Road, Cambridge, CB4 0WZ                 http://www.csr.com/


Member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom

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

* Re: [PATCH 1/3] sdhci: Implement CAP_CLOCK_BASE_BROKEN quirk
  2010-02-19 19:55 ` David Vrabel
@ 2010-02-19 20:11   ` Anton Vorontsov
  0 siblings, 0 replies; 4+ messages in thread
From: Anton Vorontsov @ 2010-02-19 20:11 UTC (permalink / raw)
  To: David Vrabel
  Cc: Andrew Morton, Richard Röjfors, Pierre Ossman, Ben Dooks,
	linux-mmc, linux-kernel

On Fri, Feb 19, 2010 at 07:55:30PM +0000, David Vrabel wrote:
> Anton Vorontsov wrote:
> > Some hosts (e.g. as found in CNS3xxx SOCs) report wrong value in
> > CLOCK_BASE capability field, and currently there is no way to
> > force the SDHCI core to use the platform-provided base clock value.
> 
> I don't think this needs a new quirk. Change the sdhci driver to check
> if the platform provides a value before reading the standard register.

Well, Pierre once said that by default we should conform to the
SDHCI spec, and any diviations from the spec should be handled by
the quirks:

http://linux.derkeiler.com/Mailing-Lists/Kernel/2009-02/msg03385.html

Spec clearly states that base clock == 0 is the case when we should
fall back to the platform-provided clocks.

So, for controllers that conform to the spec, following might be
true:

- Platform provides its own (alternate) clock, but
- SDHCI block choose not to use it, and doesn't clear bits in the
  capability register
- Then the driver should not use the platform provided clock.

Thanks,

-- 
Anton Vorontsov
email: cbouatmailru@gmail.com
irc://irc.freenode.net/bd2

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

* [PATCH 1/3] sdhci: Implement CAP_CLOCK_BASE_BROKEN quirk
  2010-03-16 18:34 [PATCH resend 0/3] sdhci-pltfm: Few additions and enhancements Anton Vorontsov
@ 2010-03-16 18:34 ` Anton Vorontsov
  0 siblings, 0 replies; 4+ messages in thread
From: Anton Vorontsov @ 2010-03-16 18:34 UTC (permalink / raw)
  To: Andrew Morton
  Cc: David Vrabel, Richard Röjfors, Pierre Ossman, Ben Dooks,
	linux-mmc, linux-kernel

Some hosts (e.g. as found in CNS3xxx SOCs) report wrong value in
CLOCK_BASE capability field, and currently there is no way to
force the SDHCI core to use the platform-provided base clock value.

This patch implements CAP_CLOCK_BASE_BROKEN quirk. When enabled,
the SDHCI core will always use base clock frequency provided by
the platform.

Signed-off-by: Anton Vorontsov <avorontsov@ru.mvista.com>
---
 drivers/mmc/host/sdhci.c |    3 ++-
 drivers/mmc/host/sdhci.h |    2 ++
 2 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
index d6ab62d..b03e875 100644
--- a/drivers/mmc/host/sdhci.c
+++ b/drivers/mmc/host/sdhci.c
@@ -1743,7 +1743,8 @@ int sdhci_add_host(struct sdhci_host *host)
 	host->max_clk =
 		(caps & SDHCI_CLOCK_BASE_MASK) >> SDHCI_CLOCK_BASE_SHIFT;
 	host->max_clk *= 1000000;
-	if (host->max_clk == 0) {
+	if (host->max_clk == 0 || host->quirks &
+			SDHCI_QUIRK_CAP_CLOCK_BASE_BROKEN) {
 		if (!host->ops->get_max_clock) {
 			printk(KERN_ERR
 			       "%s: Hardware doesn't specify base clock "
diff --git a/drivers/mmc/host/sdhci.h b/drivers/mmc/host/sdhci.h
index 842f46f..831bf7f 100644
--- a/drivers/mmc/host/sdhci.h
+++ b/drivers/mmc/host/sdhci.h
@@ -236,6 +236,8 @@ struct sdhci_host {
 #define SDHCI_QUIRK_DELAY_AFTER_POWER			(1<<23)
 /* Controller uses SDCLK instead of TMCLK for data timeouts */
 #define SDHCI_QUIRK_DATA_TIMEOUT_USES_SDCLK		(1<<24)
+/* Controller reports wrong base clock capability */
+#define SDHCI_QUIRK_CAP_CLOCK_BASE_BROKEN		(1<<25)
 
 	int			irq;		/* Device IRQ */
 	void __iomem *		ioaddr;		/* Mapped address */
-- 
1.7.0


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

end of thread, other threads:[~2010-03-16 18:34 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-02-19 19:48 [PATCH 1/3] sdhci: Implement CAP_CLOCK_BASE_BROKEN quirk Anton Vorontsov
2010-02-19 19:55 ` David Vrabel
2010-02-19 20:11   ` Anton Vorontsov
  -- strict thread matches above, loose matches on Subject: below --
2010-03-16 18:34 [PATCH resend 0/3] sdhci-pltfm: Few additions and enhancements Anton Vorontsov
2010-03-16 18:34 ` [PATCH 1/3] sdhci: Implement CAP_CLOCK_BASE_BROKEN quirk Anton Vorontsov

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