From patchwork Mon Feb 28 11:32:05 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Zhu X-Patchwork-Id: 595421 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 p1SBWgNf026157 for ; Mon, 28 Feb 2011 11:32:42 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753650Ab1B1Lcc (ORCPT ); Mon, 28 Feb 2011 06:32:32 -0500 Received: from tx2ehsobe004.messaging.microsoft.com ([65.55.88.14]:24742 "EHLO TX2EHSOBE008.bigfish.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753641Ab1B1Lca (ORCPT ); Mon, 28 Feb 2011 06:32:30 -0500 Received: from mail10-tx2-R.bigfish.com (10.9.14.248) by TX2EHSOBE008.bigfish.com (10.9.40.28) with Microsoft SMTP Server id 14.1.225.8; Mon, 28 Feb 2011 11:32:29 +0000 Received: from mail10-tx2 (localhost.localdomain [127.0.0.1]) by mail10-tx2-R.bigfish.com (Postfix) with ESMTP id AB8021B48307; Mon, 28 Feb 2011 11:32:29 +0000 (UTC) X-SpamScore: -2 X-BigFish: VS-2(zzbb2cKzz1202hzz8275bh1497iz2dh2a8h668h61h) X-Spam-TCS-SCL: 0:0 X-Forefront-Antispam-Report: KIP:(null); UIP:(null); IPVD:NLI; H:de01egw01.freescale.net; RD:de01egw01.freescale.net; EFVD:NLI Received: from mail10-tx2 (localhost.localdomain [127.0.0.1]) by mail10-tx2 (MessageSwitch) id 1298892748904024_23737; Mon, 28 Feb 2011 11:32:28 +0000 (UTC) Received: from TX2EHSMHS024.bigfish.com (unknown [10.9.14.254]) by mail10-tx2.bigfish.com (Postfix) with ESMTP id CA724240054; Mon, 28 Feb 2011 11:32:28 +0000 (UTC) Received: from de01egw01.freescale.net (192.88.165.102) by TX2EHSMHS024.bigfish.com (10.9.99.124) with Microsoft SMTP Server (TLS) id 14.1.225.8; Mon, 28 Feb 2011 11:32:28 +0000 Received: from az33smr01.freescale.net (az33smr01.freescale.net [10.64.34.199]) by de01egw01.freescale.net (8.14.3/8.14.3) with ESMTP id p1SBWQMV025455; Mon, 28 Feb 2011 04:32:27 -0700 (MST) Received: from x-VirtualBox.ap.freescale.net (udp161219uds.ap.freescale.net [10.192.242.95] (may be forged)) by az33smr01.freescale.net (8.13.1/8.13.0) with ESMTP id p1SBW7cl007621; Mon, 28 Feb 2011 05:32:22 -0600 (CST) From: Richard Zhu To: CC: , , , , , , , , , , Richard Zhu Subject: [PATCH V3 4/4] mmc: sdhci-esdhc: enable esdhc on imx53 Date: Mon, 28 Feb 2011 19:32:05 +0800 Message-ID: <1298892725-23672-4-git-send-email-Hong-Xing.Zhu@freescale.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1298892725-23672-1-git-send-email-Hong-Xing.Zhu@freescale.com> References: <1298892725-23672-1-git-send-email-Hong-Xing.Zhu@freescale.com> MIME-Version: 1.0 X-OriginatorOrg: freescale.com 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.6 (demeter1.kernel.org [140.211.167.41]); Mon, 28 Feb 2011 11:32:42 +0000 (UTC) diff --git a/drivers/mmc/host/sdhci-esdhc-imx.c b/drivers/mmc/host/sdhci-esdhc-imx.c index 9b82910..32af7c4 100644 --- a/drivers/mmc/host/sdhci-esdhc-imx.c +++ b/drivers/mmc/host/sdhci-esdhc-imx.c @@ -15,13 +15,41 @@ #include #include #include +#include #include #include +#include +#include #include #include "sdhci.h" #include "sdhci-pltfm.h" #include "sdhci-esdhc.h" +/* Abort type definition in the command register */ +#define SDHCI_CMD_ABORTCMD 0xC0 +/* VENDOR SPEC register */ +#define SDHCI_VENDOR_SPEC 0xC0 + +/* + * The CMDTYPE of the CMD register(offset 0xE) should be set to + * "11" when the STOP CMD12 is issued on imx53 to abort one + * open ended multi-blk IO. Otherwise one the TC INT wouldn't + * be generated. + * In exact block transfer, the controller doesn't complete the + * operations automatically as required at the end of the + * transfer and remains on hold if the abort command is not sent. + * As a result, the TC flag is not asserted and SW received timeout + * exeception. Bit1 of Vendor Spec registor is used to fix it. + */ +#define IMX_MULTIBLK_NO_INT (1 << 0) + +struct pltfm_imx_data { + int flags; + u32 mod_val; +}; + +static struct sdhci_ops sdhci_esdhc_ops; + static inline void esdhc_clrset_le(struct sdhci_host *host, u32 mask, u32 val, int reg) { void __iomem *base = host->ioaddr + (reg & ~0x3); @@ -38,20 +66,51 @@ static u16 esdhc_readw_le(struct sdhci_host *host, int reg) return readw(host->ioaddr + reg); } +static void esdhc_writel_le(struct sdhci_host *host, u32 val, int reg) +{ + switch (reg) { + case SDHCI_INT_STATUS: + if (val & SDHCI_INT_DATA_END) { + u32 v; + v = readl(host->ioaddr + SDHCI_VENDOR_SPEC); + if (v & 0x2) { + v &= ~0x2; + writel(v, host->ioaddr + SDHCI_VENDOR_SPEC); + } + } + break; + } + writel(val, host->ioaddr + reg); +} + static void esdhc_writew_le(struct sdhci_host *host, u16 val, int reg) { struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); + struct pltfm_imx_data *imx_data = + (struct pltfm_imx_data *)pltfm_host->priv; switch (reg) { case SDHCI_TRANSFER_MODE: + if ((host->cmd->opcode == SD_IO_RW_EXTENDED) + && (host->cmd->data->blocks > 1) + && (host->cmd->data->flags & MMC_DATA_READ) + && (imx_data->flags & IMX_MULTIBLK_NO_INT)) { + u32 v; + v = readl(host->ioaddr + SDHCI_VENDOR_SPEC); + v |= 0x2; + writel(v, host->ioaddr + SDHCI_VENDOR_SPEC); + } /* * Postpone this write, we must do it together with a * command write that is down below. */ - pltfm_host->scratchpad = val; + imx_data->mod_val = val; return; case SDHCI_COMMAND: - writel(val << 16 | pltfm_host->scratchpad, + if ((host->cmd->opcode == MMC_STOP_TRANSMISSION) + && (imx_data->flags & IMX_MULTIBLK_NO_INT)) + val |= SDHCI_CMD_ABORTCMD; + writel(val << 16 | imx_data->mod_val, host->ioaddr + SDHCI_TRANSFER_MODE); return; case SDHCI_BLOCK_SIZE: @@ -104,6 +163,10 @@ static int esdhc_pltfm_init(struct sdhci_host *host, struct sdhci_pltfm_data *pd { struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); struct clk *clk; + struct pltfm_imx_data *imx_data; + + imx_data = kzalloc(sizeof(struct pltfm_imx_data), GFP_KERNEL); + pltfm_host->priv = (void *)imx_data; clk = clk_get(mmc_dev(host->mmc), NULL); if (IS_ERR(clk)) { @@ -113,22 +176,30 @@ static int esdhc_pltfm_init(struct sdhci_host *host, struct sdhci_pltfm_data *pd clk_enable(clk); pltfm_host->clk = clk; - if (cpu_is_mx35() || cpu_is_mx51()) + if (!cpu_is_mx25()) host->quirks |= SDHCI_QUIRK_BROKEN_TIMEOUT_VAL; /* Fix errata ENGcm07207 which is present on i.MX25 and i.MX35 */ if (cpu_is_mx25() || cpu_is_mx35()) host->quirks |= SDHCI_QUIRK_NO_MULTIBLOCK; + if (!(cpu_is_mx25() || cpu_is_mx35() || cpu_is_mx51())) { + imx_data->flags |= IMX_MULTIBLK_NO_INT; + sdhci_esdhc_ops.write_l = esdhc_writel_le; + } + return 0; } static void esdhc_pltfm_exit(struct sdhci_host *host) { struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); + struct pltfm_imx_data *imx_data = + (struct pltfm_imx_data *)pltfm_host->priv; clk_disable(pltfm_host->clk); clk_put(pltfm_host->clk); + kfree(imx_data); } static struct sdhci_ops sdhci_esdhc_ops = { diff --git a/drivers/mmc/host/sdhci-pltfm.h b/drivers/mmc/host/sdhci-pltfm.h index ea2e44d..2b37016 100644 --- a/drivers/mmc/host/sdhci-pltfm.h +++ b/drivers/mmc/host/sdhci-pltfm.h @@ -17,7 +17,7 @@ struct sdhci_pltfm_host { struct clk *clk; - u32 scratchpad; /* to handle quirks across io-accessor calls */ + void *priv; /* to handle quirks across io-accessor calls */ }; extern struct sdhci_pltfm_data sdhci_cns3xxx_pdata;