From patchwork Mon Aug 9 12:33:16 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhangfei Gao X-Patchwork-Id: 176422 Return-path: X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on void.printf.net X-Spam-Level: X-Spam-Status: No, score=-1.0 required=2.9 tests=RCVD_IN_DNSWL_LOW autolearn=disabled version=3.2.5 Envelope-to: chris@printf.net Delivery-date: Mon, 09 Aug 2010 13:33:25 +0100 Received: from lists.laptop.org ([18.85.2.145] helo=mail.laptop.org) by void.printf.net with esmtp (Exim 4.69) (envelope-from ) id 1OiRXg-0005LI-An for chris@printf.net; Mon, 09 Aug 2010 13:33:24 +0100 Received: by mail.laptop.org (Postfix) id 681DA24339; Mon, 9 Aug 2010 08:33:06 -0400 (EDT) Delivered-To: cjb@laptop.org Received: from spam.laptop.org (spam.laptop.org [18.85.46.23]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.laptop.org (Postfix) with ESMTPS id 4DE4924337 for ; Mon, 9 Aug 2010 08:33:06 -0400 (EDT) X-ASG-Debug-ID: 1281357198-0b74209c0001-zHW3sV Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by spam.laptop.org with ESMTP id dRhbpzIdSpQsZOuD for ; Mon, 09 Aug 2010 08:33:18 -0400 (EDT) X-Barracuda-Envelope-From: linux-mmc-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756343Ab0HIMdS (ORCPT ); Mon, 9 Aug 2010 08:33:18 -0400 Received: from mail-yx0-f174.google.com ([209.85.213.174]:36606 "EHLO mail-yx0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754140Ab0HIMdR (ORCPT ); Mon, 9 Aug 2010 08:33:17 -0400 Received: by yxg6 with SMTP id 6so3368811yxg.19 for ; Mon, 09 Aug 2010 05:33:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:in-reply-to :references:date:message-id:subject:from:to:cc:content-type; bh=vF1J21ygkGsbW89Rd0gACooZEmB3UloBkiQvoaxvItI=; b=LVYdAw+/nDqT3dJ35nC1zjI0VhGV8yiR5lgGH2SiSt+xMDVX7ppyNTzPFVtS2EkReM v0ANoJKgDsdloIDfyDff4ojvaZSI/lNnTO04jopwW5FJryHoY+8pKN9j5+/d0AjXfI8j GV8b7XHFtIDlCHbJFvgQmzu48ihMvNCPYJjX8= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; b=alhysyovajS1OYa/1aacXVYV/0Mb+caOBid3CdoQUGnBLUYRtZOLYDWeYlcta8Saf9 PRR8MKBHoYSK5vRVR+0+LGFnnXBSmor1ZQo4TdCuDbvw39fahoWll1tFd36WXSiRa7BR apmKgIiUQT9/SnWnbK6gPJw4joDk0q+NYMDvE= MIME-Version: 1.0 Received: by 10.100.96.14 with SMTP id t14mr17816732anb.155.1281357196276; Mon, 09 Aug 2010 05:33:16 -0700 (PDT) Received: by 10.231.199.12 with HTTP; Mon, 9 Aug 2010 05:33:16 -0700 (PDT) In-Reply-To: <20100809101042.GA8293@console-pimps.org> References: <20100809101042.GA8293@console-pimps.org> Date: Mon, 9 Aug 2010 20:33:16 +0800 Message-ID: X-ASG-Orig-Subj: Re: [patch 1/1]sdhci: sdhc spec 3.0 add some modification Subject: Re: [patch 1/1]sdhci: sdhc spec 3.0 add some modification From: zhangfei gao To: Matt Fleming Cc: Kyungmin Park , linux-mmc@vger.kernel.org, Anton Vorontsov , Ben Dooks , Wolfram Sang Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org X-Barracuda-Connect: vger.kernel.org[209.132.180.67] X-Barracuda-Start-Time: 1281357198 X-Barracuda-URL: http://18.85.46.23:8000/cgi-mod/mark.cgi X-Virus-Scanned: by bsmtpd at laptop.org X-Barracuda-Spam-Score: 0.00 X-Barracuda-Spam-Status: No, SCORE=0.00 using global scores of TAG_LEVEL=3.5 QUARANTINE_LEVEL=1000.0 KILL_LEVEL=5.5 tests=INFO_TLD X-Barracuda-Spam-Report: Code version 3.2, rules version 3.2.2.37487 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------------------------- 0.00 INFO_TLD URI: Contains an URL in the INFO top-level domain diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c index c6d1bd8..c4b3d6f 100644 --- a/drivers/mmc/host/sdhci.c +++ b/drivers/mmc/host/sdhci.c @@ -978,7 +978,7 @@ static void sdhci_finish_command(struct sdhci_host *host) static void sdhci_set_clock(struct sdhci_host *host, unsigned int clock) { - int div; + int div, max_div; u16 clk; unsigned long timeout; @@ -996,13 +996,19 @@ static void sdhci_set_clock(struct sdhci_host *host, unsigned int clock) if (clock == 0) goto out; - for (div = 1;div < 256;div *= 2) { + if (host->version >= SDHCI_SPEC_300) + max_div = 2046; + else + max_div = 256; + + for (div = 1;div < max_div;div *= 2) { if ((host->max_clk / div) <= clock) break; } div >>= 1; - clk = div << SDHCI_DIVIDER_SHIFT; + clk = (div & SDHCI_DIV_MASK) << SDHCI_DIVIDER_SHIFT; + clk |= ((div & SDHCI_DIV_HI_MASK) >> SDHCI_DIVIDER_SHIFT) << SDHCI_DIVIDER_SHIFT_HI; clk |= SDHCI_CLOCK_INT_EN; sdhci_writew(host, clk, SDHCI_CLOCK_CONTROL); @@ -1681,7 +1687,7 @@ int sdhci_add_host(struct sdhci_host *host) host->version = sdhci_readw(host, SDHCI_HOST_VERSION); host->version = (host->version & SDHCI_SPEC_VER_MASK) >> SDHCI_SPEC_VER_SHIFT; - if (host->version > SDHCI_SPEC_200) { + if (host->version > SDHCI_SPEC_300) { printk(KERN_ERR "%s: Unknown controller version (%d). " "You may experience problems.\n", mmc_hostname(mmc), host->version); diff --git a/drivers/mmc/host/sdhci.h b/drivers/mmc/host/sdhci.h index c846813..7c09b4f 100644 --- a/drivers/mmc/host/sdhci.h +++ b/drivers/mmc/host/sdhci.h @@ -85,6 +85,9 @@ #define SDHCI_CLOCK_CONTROL 0x2C #define SDHCI_DIVIDER_SHIFT 8 +#define SDHCI_DIVIDER_SHIFT_HI 6 +#define SDHCI_DIV_MASK 0xFF +#define SDHCI_DIV_HI_MASK 0x300 #define SDHCI_CLOCK_CARD_EN 0x0004 #define SDHCI_CLOCK_INT_STABLE 0x0002 #define SDHCI_CLOCK_INT_EN 0x0001 @@ -177,6 +180,7 @@ #define SDHCI_SPEC_VER_SHIFT 0 #define SDHCI_SPEC_100 0 #define SDHCI_SPEC_200 1 +#define SDHCI_SPEC_300 2 struct sdhci_ops;