Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 30 Nov 2012 02:35:13 +0000 (UTC)
From:      Oleksandr Tymoshenko <gonzo@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r243689 - head/sys/dev/sdhci
Message-ID:  <201211300235.qAU2ZDYR099933@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: gonzo
Date: Fri Nov 30 02:35:13 2012
New Revision: 243689
URL: http://svnweb.freebsd.org/changeset/base/243689

Log:
  - Get proper maximum clock frequency for SDHCI v3.0 and higher

Modified:
  head/sys/dev/sdhci/sdhci.c
  head/sys/dev/sdhci/sdhci.h

Modified: head/sys/dev/sdhci/sdhci.c
==============================================================================
--- head/sys/dev/sdhci/sdhci.c	Fri Nov 30 02:32:37 2012	(r243688)
+++ head/sys/dev/sdhci/sdhci.c	Fri Nov 30 02:35:13 2012	(r243689)
@@ -96,6 +96,8 @@ static void sdhci_card_task(void *, int)
 #define SDHCI_ASSERT_LOCKED(_slot)	mtx_assert(&_slot->mtx, MA_OWNED);
 #define SDHCI_ASSERT_UNLOCKED(_slot)	mtx_assert(&_slot->mtx, MA_NOTOWNED);
 
+#define	SDHCI_DEFAULT_MAX_FREQ	50
+
 static void
 sdhci_getaddr(void *arg, bus_dma_segment_t *segs, int nsegs, int error)
 {
@@ -516,12 +518,16 @@ sdhci_init_slot(device_t dev, struct sdh
 	else
 		caps = RD4(slot, SDHCI_CAPABILITIES);
 	/* Calculate base clock frequency. */
-	slot->max_clk =
-		(caps & SDHCI_CLOCK_BASE_MASK) >> SDHCI_CLOCK_BASE_SHIFT;
+	if (slot->version >= SDHCI_SPEC_300)
+		slot->max_clk = (caps & SDHCI_CLOCK_V3_BASE_MASK) 
+		    >> SDHCI_CLOCK_BASE_SHIFT;
+	else	
+		slot->max_clk = (caps & SDHCI_CLOCK_BASE_MASK) 
+		    >> SDHCI_CLOCK_BASE_SHIFT;
 	if (slot->max_clk == 0) {
-		slot->max_clk = 50;
+		slot->max_clk = SDHCI_DEFAULT_MAX_FREQ;
 		device_printf(dev, "Hardware doesn't specify base clock "
-		    "frequency.\n");
+		    "frequency, using %dMHz as default.\n", SDHCI_DEFAULT_MAX_FREQ);
 	}
 	slot->max_clk *= 1000000;
 	/* Calculate timeout clock frequency. */

Modified: head/sys/dev/sdhci/sdhci.h
==============================================================================
--- head/sys/dev/sdhci/sdhci.h	Fri Nov 30 02:32:37 2012	(r243688)
+++ head/sys/dev/sdhci/sdhci.h	Fri Nov 30 02:35:13 2012	(r243689)
@@ -191,6 +191,7 @@
 #define  SDHCI_TIMEOUT_CLK_SHIFT 0
 #define  SDHCI_TIMEOUT_CLK_UNIT	0x00000080
 #define  SDHCI_CLOCK_BASE_MASK	0x00003F00
+#define  SDHCI_CLOCK_V3_BASE_MASK	0x0000FF00
 #define  SDHCI_CLOCK_BASE_SHIFT	8
 #define  SDHCI_MAX_BLOCK_MASK	0x00030000
 #define  SDHCI_MAX_BLOCK_SHIFT  16



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201211300235.qAU2ZDYR099933>