From patchwork Tue Nov 9 14:17:21 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhangfei Gao X-Patchwork-Id: 311272 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id oA9EHQE7027401 for ; Tue, 9 Nov 2010 14:17:26 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753121Ab0KIORY (ORCPT ); Tue, 9 Nov 2010 09:17:24 -0500 Received: from mail-yx0-f174.google.com ([209.85.213.174]:61117 "EHLO mail-yx0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751736Ab0KIORX (ORCPT ); Tue, 9 Nov 2010 09:17:23 -0500 Received: by yxe1 with SMTP id 1so82978yxe.19 for ; Tue, 09 Nov 2010 06:17:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:date:message-id :subject:from:to:cc:content-type; bh=8usbU9UZ3UMPwjLvJ+6UujHcAtwTcRmj2gXFjE3Zgnc=; b=bD+cIHqRVn1QsgAB0i3Yx5dBqg3dxtchuG8Zx2iwc695YlIoyIlmz2YFPS1ZQEr8Zb yYRQUjuQwWIRw+6xmUTAYv2HMOGt8QHH5vFfyhnGgBS4keDQJYZYZPa2HWvm+cPx5D0v ZkNk2Vr8R4FAkw2hG67OMQyxUiAVZPR/L5OqA= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:cc:content-type; b=VqNaREFwDFbuNXLEH85yDewCPHo7MahNvRZwMUhM3aqXy+jiaFL19J3/7WbfoXrhuz hmZ1oCgOq+cgOg6zMnV4HaHDQJPue22ZAfpMKy1uzQvXL8EEUMlGFS5imXMGAoTaG89A Q5QQjuyuke/Hmd5KOGw8gkp6qAsGGu4OrR2y0= MIME-Version: 1.0 Received: by 10.204.112.10 with SMTP id u10mr446908bkp.146.1289312241964; Tue, 09 Nov 2010 06:17:21 -0800 (PST) Received: by 10.223.1.80 with HTTP; Tue, 9 Nov 2010 06:17:21 -0800 (PST) Date: Tue, 9 Nov 2010 09:17:21 -0500 Message-ID: Subject: [PATCH 1/1]sdhci-pxa: support tune_timming for various cards From: zhangfei gao To: linux-mmc@vger.kernel.org Cc: Chris Ball , Haojian Zhuang , Eric Miao Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter1.kernel.org [140.211.167.41]); Tue, 09 Nov 2010 14:17:26 +0000 (UTC) From 6619812b749aa12ebf0efbe057366c2f99051bfe Mon Sep 17 00:00:00 2001 From: Zhangfei Gao Date: Tue, 2 Nov 2010 07:37:44 -0400 Subject: [PATCH] sdhci-pxa: support tune_timming for various cards 1. Add pdata check, in case pdata is NULL 2. Add tune_timming to adjust read data/command timming without performance impact when crc error, as a result a, sd could work at 50M b, emmc could work at ddr50 mode 3. Remove clock_enable checking, since clock gating is still on-going in core stack. Signed-off-by: Zhangfei Gao --- arch/arm/plat-pxa/include/plat/sdhci.h | 2 + drivers/mmc/host/sdhci-pxa.c | 51 +++++++++++++++++++++++-------- 2 files changed, 40 insertions(+), 13 deletions(-) diff --git a/arch/arm/plat-pxa/include/plat/sdhci.h b/arch/arm/plat-pxa/include/plat/sdhci.h index fc5ceab..8c340b1 100644 --- a/arch/arm/plat-pxa/include/plat/sdhci.h +++ b/arch/arm/plat-pxa/include/plat/sdhci.h @@ -24,11 +24,13 @@ * @max_speed: the maximum speed supported * @quirks: quirks of specific device * @flags: flags for platform requirement + * @clk_delay: clk_delay vlaue to tunning various cards */ struct sdhci_pxa_platdata { unsigned int max_speed; unsigned int quirks; unsigned int flags; + unsigned int clk_delay; }; #endif /* __PLAT_PXA_SDHCI_H */ diff --git a/drivers/mmc/host/sdhci-pxa.c b/drivers/mmc/host/sdhci-pxa.c index 8455c46..cf514f8 100644 --- a/drivers/mmc/host/sdhci-pxa.c +++ b/drivers/mmc/host/sdhci-pxa.c @@ -32,6 +32,11 @@ #define SD_FIFO_PARAM 0x104 #define DIS_PAD_SD_CLK_GATE 0x400 +#define SD_CLOCK_AND_BURST_SIZE_SETUP 0x10A +#define SDCLK_SEL 0x100 +#define SDCLK_DELAY_SHIFT 9 +#define SDCLK_DELAY_MASK 0x1f + struct sdhci_pxa { struct sdhci_host *host; struct sdhci_pxa_platdata *pdata; @@ -46,6 +51,26 @@ struct sdhci_pxa { * SDHCI core callbacks * * * \*****************************************************************************/ +static void tune_timming(struct sdhci_host *host) +{ + struct sdhci_pxa *pxa = sdhci_priv(host); + + /* + * tune timming of read data/command when crc error happen + * No perfermance impact + */ + if (pxa->pdata && 0 != pxa->pdata->clk_delay) { + u16 tmp; + + tmp = readw(host->ioaddr + SD_CLOCK_AND_BURST_SIZE_SETUP); + tmp |= (pxa->pdata->clk_delay & SDCLK_DELAY_MASK) + << SDCLK_DELAY_SHIFT; + tmp |= SDCLK_SEL; + writew(tmp, host->ioaddr + SD_CLOCK_AND_BURST_SIZE_SETUP); + } + +} + static void set_clock(struct sdhci_host *host, unsigned int clock) { struct sdhci_pxa *pxa = sdhci_priv(host); @@ -57,15 +82,16 @@ static void set_clock(struct sdhci_host *host, unsigned int clock) pxa->clk_enable = 0; } } else { - if (0 == pxa->clk_enable) { - if (pxa->pdata->flags & PXA_FLAG_DISABLE_CLOCK_GATING) { - tmp = readl(host->ioaddr + SD_FIFO_PARAM); - tmp |= DIS_PAD_SD_CLK_GATE; - writel(tmp, host->ioaddr + SD_FIFO_PARAM); - } - clk_enable(pxa->clk); - pxa->clk_enable = 1; + tune_timming(host); + if (pxa->pdata && + pxa->pdata->flags & PXA_FLAG_DISABLE_CLOCK_GATING) { + + tmp = readl(host->ioaddr + SD_FIFO_PARAM); + tmp |= DIS_PAD_SD_CLK_GATE; + writel(tmp, host->ioaddr + SD_FIFO_PARAM); } + clk_enable(pxa->clk); + pxa->clk_enable = 1; } } @@ -138,13 +164,13 @@ static int __devinit sdhci_pxa_probe(struct platform_device *pdev) host->irq = irq; host->quirks = SDHCI_QUIRK_BROKEN_ADMA | SDHCI_QUIRK_BROKEN_TIMEOUT_VAL; - if (pxa->pdata->flags & PXA_FLAG_CARD_PERMANENT) { + if (pdata && pdata->flags & PXA_FLAG_CARD_PERMANENT) { /* on-chip device */ host->quirks |= SDHCI_QUIRK_BROKEN_CARD_DETECTION; host->mmc->caps |= MMC_CAP_NONREMOVABLE; } - if (pdata->quirks) + if (pdata && pdata->quirks) host->quirks |= pdata->quirks; ret = sdhci_add_host(host); @@ -153,9 +179,8 @@ static int __devinit sdhci_pxa_probe(struct platform_device *pdev) goto out; } - if (pxa->pdata->max_speed) - host->mmc->f_max = pxa->pdata->max_speed; - + if (pdata && pdata->max_speed) + host->mmc->f_max = pdata->max_speed; platform_set_drvdata(pdev, host); return 0; -- 1.7.0.4