From owner-svn-src-head@FreeBSD.ORG Fri Nov 30 02:35:13 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id CB6A7E97; Fri, 30 Nov 2012 02:35:13 +0000 (UTC) (envelope-from gonzo@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 950948FC08; Fri, 30 Nov 2012 02:35:13 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.5/8.14.5) with ESMTP id qAU2ZDHg099935; Fri, 30 Nov 2012 02:35:13 GMT (envelope-from gonzo@svn.freebsd.org) Received: (from gonzo@localhost) by svn.freebsd.org (8.14.5/8.14.5/Submit) id qAU2ZDYR099933; Fri, 30 Nov 2012 02:35:13 GMT (envelope-from gonzo@svn.freebsd.org) Message-Id: <201211300235.qAU2ZDYR099933@svn.freebsd.org> From: Oleksandr Tymoshenko Date: Fri, 30 Nov 2012 02:35:13 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r243689 - head/sys/dev/sdhci X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 30 Nov 2012 02:35:13 -0000 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