From patchwork Thu Aug 12 06:46:02 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhangfei Gao X-Patchwork-Id: 176992 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: Thu, 12 Aug 2010 07:46:08 +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 1OjRYF-0001tr-T6 for chris@printf.net; Thu, 12 Aug 2010 07:46:08 +0100 Received: by mail.laptop.org (Postfix) id F3BFA24A89; Thu, 12 Aug 2010 02:45:49 -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 E1A6F24A86 for ; Thu, 12 Aug 2010 02:45:49 -0400 (EDT) X-ASG-Debug-ID: 1281595565-0b74ef230001-zHW3sV Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by spam.laptop.org with ESMTP id 3D905sFBglyDldK0 for ; Thu, 12 Aug 2010 02:46:05 -0400 (EDT) X-Barracuda-Envelope-From: linux-mmc-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751858Ab0HLGqF (ORCPT ); Thu, 12 Aug 2010 02:46:05 -0400 Received: from mail-wy0-f174.google.com ([74.125.82.174]:45144 "EHLO mail-wy0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751475Ab0HLGqE (ORCPT ); Thu, 12 Aug 2010 02:46:04 -0400 Received: by wyb32 with SMTP id 32so1037348wyb.19 for ; Wed, 11 Aug 2010 23:46:02 -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=WDm6DN8tuOr3Eo300/R6D3DtywdY/i+QC1jbDYEFEbs=; b=c6UMVqhP08FAGcnl3g0pWLbWbkIT5D4r9uOBooONaGfSC2u0eu5E5QmiPb3dUGpF0h BqQC4tQ04kUq5jSMJ8Y45CQ8OqVE8sq5gAxD+jabkCRBYfEiFGoBL9/0Tvx0EAPQkVnb Li2HJioeBFRBmyFU349oS6M9ZpaCyx43AmzoU= 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=w7oUcssRrS+YJm5ArNgwa4kwdPu9XxNOkKY56nEwO/y+h6LtIx12ziw79UBV0hfLqL yZxKEkk99NvU6O4N3JcxNI5Olq4OBTYzcMTzFHUnxXLVW4WcWeb76ReODlDDiPHEaS/o FEXNyZWUJnHe52u5cn1StzPgO9wT86SkLah40= MIME-Version: 1.0 Received: by 10.216.236.29 with SMTP id v29mr6317942weq.7.1281595562353; Wed, 11 Aug 2010 23:46:02 -0700 (PDT) Received: by 10.216.154.3 with HTTP; Wed, 11 Aug 2010 23:46:02 -0700 (PDT) In-Reply-To: References: <20100809101042.GA8293@console-pimps.org> <20100810163244.GA12837@console-pimps.org> Date: Thu, 12 Aug 2010 02:46:02 -0400 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: 1281595565 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.37750 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------------------------- From b17eb3ca9dd23af63ada240e8f77bdd873e853a7 Mon Sep 17 00:00:00 2001 From: Zhangfei Gao Date: Fri, 6 Aug 2010 07:10:01 +0800 Subject: [PATCH] sdhc: support 10-bit divided clock Mode Signed-off-by: Zhangfei Gao Reviewed-by: Matt Fleming --- drivers/mmc/host/sdhci.c | 16 ++++++++++++---- drivers/mmc/host/sdhci.h | 4 ++++ 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c index 7855121..ccfbc40 100644 --- a/drivers/mmc/host/sdhci.c +++ b/drivers/mmc/host/sdhci.c @@ -983,7 +983,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; @@ -1001,13 +1001,21 @@ 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; + + if(host->max_clk <= clock) + div = 1; + for (div = 2; 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); @@ -1707,7 +1715,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 036cfae..d7ef7e4 100644 --- a/drivers/mmc/host/sdhci.h +++ b/drivers/mmc/host/sdhci.h @@ -86,6 +86,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 @@ -178,6 +181,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; -- 1.7.0.4