From patchwork Mon Jul 18 05:20:02 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tony Lin X-Patchwork-Id: 985492 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.4) with ESMTP id p6I4tBXu013952 for ; Mon, 18 Jul 2011 04:55:11 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751027Ab1GREzK (ORCPT ); Mon, 18 Jul 2011 00:55:10 -0400 Received: from ch1ehsobe002.messaging.microsoft.com ([216.32.181.182]:41295 "EHLO ch1outboundpool.messaging.microsoft.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750855Ab1GREzJ (ORCPT ); Mon, 18 Jul 2011 00:55:09 -0400 Received: from mail56-ch1-R.bigfish.com (216.32.181.169) by CH1EHSOBE014.bigfish.com (10.43.70.64) with Microsoft SMTP Server id 14.1.225.22; Mon, 18 Jul 2011 04:55:08 +0000 Received: from mail56-ch1 (localhost.localdomain [127.0.0.1]) by mail56-ch1-R.bigfish.com (Postfix) with ESMTP id 33C0EAC811D; Mon, 18 Jul 2011 04:55:08 +0000 (UTC) X-SpamScore: 0 X-BigFish: VS0(zzzz1202hzz8275bhz2dh2a8h668h839h63h) X-Spam-TCS-SCL: 2:0 X-Forefront-Antispam-Report: CIP:70.37.183.190; KIP:(null); UIP:(null); IPVD:NLI; H:mail.freescale.net; RD:none; EFVD:NLI Received: from mail56-ch1 (localhost.localdomain [127.0.0.1]) by mail56-ch1 (MessageSwitch) id 131096490849447_9422; Mon, 18 Jul 2011 04:55:08 +0000 (UTC) Received: from CH1EHSMHS035.bigfish.com (snatpool1.int.messaging.microsoft.com [10.43.68.250]) by mail56-ch1.bigfish.com (Postfix) with ESMTP id F2E6A160004C; Mon, 18 Jul 2011 04:55:07 +0000 (UTC) Received: from mail.freescale.net (70.37.183.190) by CH1EHSMHS035.bigfish.com (10.43.70.35) with Microsoft SMTP Server (TLS) id 14.1.225.22; Mon, 18 Jul 2011 04:55:07 +0000 Received: from az33smr01.freescale.net (10.64.34.199) by 039-SN1MMR1-003.039d.mgd.msft.net (10.84.1.16) with Microsoft SMTP Server id 14.1.289.8; Sun, 17 Jul 2011 23:54:59 -0500 Received: from localhost.localdomain (shlinux2.ap.freescale.net [10.192.224.44]) by az33smr01.freescale.net (8.13.1/8.13.0) with ESMTP id p6I4svIY024174; Sun, 17 Jul 2011 23:54:57 -0500 (CDT) From: Tony Lin To: CC: , Subject: [PATCH 1/1] fix card interrupt losing issue on freescale eSDHC Date: Mon, 18 Jul 2011 13:20:02 +0800 Message-ID: <1310966402-12318-1-git-send-email-tony.lin@freescale.com> X-Mailer: git-send-email 1.7.0.4 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, 18 Jul 2011 04:55:11 +0000 (UTC) apply workaround for imx eSDHC controller to avoid missing card interrupt so that SDIO function is workable Signed-off-by: Tony Lin --- drivers/mmc/host/sdhci-esdhc-imx.c | 39 +++++++++++++++++++++++++++-------- 1 files changed, 30 insertions(+), 9 deletions(-) diff --git a/drivers/mmc/host/sdhci-esdhc-imx.c b/drivers/mmc/host/sdhci-esdhc-imx.c index a19967d..da77cae 100644 --- a/drivers/mmc/host/sdhci-esdhc-imx.c +++ b/drivers/mmc/host/sdhci-esdhc-imx.c @@ -32,6 +32,8 @@ #define SDHCI_VENDOR_SPEC_SDIO_QUIRK 0x00000002 #define ESDHC_FLAG_GPIO_FOR_CD_WP (1 << 0) + +#define SDHCI_CTRL_D3CD 0x08 /* * The CMDTYPE of the CMD register (offset 0xE) should be set to * "11" when the STOP CMD12 is issued on imx53 to abort one @@ -87,14 +89,31 @@ static void esdhc_writel_le(struct sdhci_host *host, u32 val, int reg) { struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); struct pltfm_imx_data *imx_data = pltfm_host->priv; - - if (unlikely((reg == SDHCI_INT_ENABLE || reg == SDHCI_SIGNAL_ENABLE) - && (imx_data->flags & ESDHC_FLAG_GPIO_FOR_CD_WP))) - /* - * these interrupts won't work with a custom card_detect gpio - * (only applied to mx25/35) - */ - val &= ~(SDHCI_INT_CARD_REMOVE | SDHCI_INT_CARD_INSERT); + u32 data; + + if (unlikely((reg == SDHCI_INT_ENABLE || reg == SDHCI_SIGNAL_ENABLE))) { + if (imx_data->flags & ESDHC_FLAG_GPIO_FOR_CD_WP) + /* + * these interrupts won't work with a custom + * card_detect gpio (only applied to mx25/35) + */ + val &= ~(SDHCI_INT_CARD_REMOVE | \ + SDHCI_INT_CARD_INSERT); + + if (val & SDHCI_INT_CARD_INT) { + /* + * clear D3CD bit and set D3CD bit to avoid + * missing card interrupt + * this is a eSDHC controller problem so that + * we need to apply following workaround + */ + data = readl(host->ioaddr + SDHCI_HOST_CONTROL); + data &= ~SDHCI_CTRL_D3CD; + writel(data, host->ioaddr + SDHCI_HOST_CONTROL); + data |= SDHCI_CTRL_D3CD; + writel(data, host->ioaddr + SDHCI_HOST_CONTROL); + } + } if (unlikely((imx_data->flags & ESDHC_FLAG_MULTIBLK_NO_INT) && (reg == SDHCI_INT_STATUS) @@ -165,7 +184,9 @@ static void esdhc_writeb_le(struct sdhci_host *host, u8 val, int reg) return; case SDHCI_HOST_CONTROL: /* FSL messed up here, so we can just keep those two */ - new_val = val & (SDHCI_CTRL_LED | SDHCI_CTRL_4BITBUS); + new_val = val & (SDHCI_CTRL_LED | \ + SDHCI_CTRL_4BITBUS | \ + SDHCI_CTRL_D3CD); /* ensure the endianess */ new_val |= ESDHC_HOST_CONTROL_LE; /* DMA mode bits are shifted */