From patchwork Wed Aug 11 07:44:54 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhangfei Gao X-Patchwork-Id: 176772 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: Wed, 11 Aug 2010 08:45:04 +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 1Oj5zk-0006QQ-0H for chris@printf.net; Wed, 11 Aug 2010 08:45:04 +0100 Received: by mail.laptop.org (Postfix) id 043FD24833; Wed, 11 Aug 2010 03:44:46 -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 E60CA24832 for ; Wed, 11 Aug 2010 03:44:45 -0400 (EDT) X-ASG-Debug-ID: 1281512700-0b74b1a00001-zHW3sV Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by spam.laptop.org with ESMTP id 7pFkwtbgVAJHJqtB for ; Wed, 11 Aug 2010 03:45:00 -0400 (EDT) X-Barracuda-Envelope-From: linux-mmc-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752619Ab0HKHo4 (ORCPT ); Wed, 11 Aug 2010 03:44:56 -0400 Received: from mail-wy0-f174.google.com ([74.125.82.174]:57889 "EHLO mail-wy0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754029Ab0HKHo4 (ORCPT ); Wed, 11 Aug 2010 03:44:56 -0400 Received: by wyb32 with SMTP id 32so1575563wyb.19 for ; Wed, 11 Aug 2010 00:44:54 -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=uAo8eVUZhoSppeoKw+DzQFzweWa8pOThGOaOIgJbVYw=; b=lGphvVmH8i510Ya+rqoWOAfkUwcrsHqoRR8/Zt98px3P3cdOYJpbzOYRfU9aGvJmD8 yIZaquLDLUGxTjdd0eWpH1aHbJkxzuDEymFHjkyMIakh7/YrU/pn2ypw3d8D3hoNboCi It96mfaZ9jO7BBzSh4I3Prlmdgjlv4IMwlx/E= 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=p6fEzWy4pppo9Binmfj/4YiMsczvZK9vSGxFtpL75E9xeG1ullvKLK5nmmIIm+j5Up jOF0iOU53HZlwkKHHU7fT+Lq/iq16HEViGDtFHmOvlfKvspzbsTK8ZA8vwEkb3p5AC9n blMSmp0RT0oQaViPvEq/QqrQ28hCyRm2CzIN0= MIME-Version: 1.0 Received: by 10.227.141.138 with SMTP id m10mr16200367wbu.20.1281512694377; Wed, 11 Aug 2010 00:44:54 -0700 (PDT) Received: by 10.216.154.3 with HTTP; Wed, 11 Aug 2010 00:44:54 -0700 (PDT) In-Reply-To: <20100810163244.GA12837@console-pimps.org> References: <20100809101042.GA8293@console-pimps.org> <20100810163244.GA12837@console-pimps.org> Date: Wed, 11 Aug 2010 15:44:54 +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: 1281512700 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= X-Barracuda-Spam-Report: Code version 3.2, rules version 3.2.2.37658 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------------------------- diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c index c6d1bd8..b2d5e5e 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;