From patchwork Thu Feb 24 19:00:52 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Eric_B=C3=A9nard?= X-Patchwork-Id: 588271 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 p1OJAf1Q000385 for ; Thu, 24 Feb 2011 19:10:41 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756243Ab1BXTK1 (ORCPT ); Thu, 24 Feb 2011 14:10:27 -0500 Received: from smtpfb2-g21.free.fr ([212.27.42.10]:57950 "EHLO smtpfb2-g21.free.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755545Ab1BXTKY (ORCPT ); Thu, 24 Feb 2011 14:10:24 -0500 X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Thu, 24 Feb 2011 19:10:42 +0000 (UTC) X-Greylist: delayed 562 seconds by postgrey-1.27 at vger.kernel.org; Thu, 24 Feb 2011 14:10:22 EST Received: from smtp2-g21.free.fr (smtp2-g21.free.fr [212.27.42.2]) by smtpfb2-g21.free.fr (Postfix) with ESMTP id B2F01D1A9D2 for ; Thu, 24 Feb 2011 20:01:32 +0100 (CET) Received: from [192.168.1.15] (unknown [82.240.38.71]) by smtp2-g21.free.fr (Postfix) with ESMTP id 4B90F4B02BB; Thu, 24 Feb 2011 20:00:53 +0100 (CET) Message-ID: <4D66AAE4.4000308@eukrea.com> Date: Thu, 24 Feb 2011 20:00:52 +0100 From: Eric Benard User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.13) Gecko/20101209 Fedora/3.1.7-0.35.b3pre.fc14 Lightning/1.0b3pre Thunderbird/3.1.7 MIME-Version: 1.0 To: "Arnaud Patard (Rtp)" CC: Wolfram Sang , Chris Ball , linux-mmc@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH V3 0/5] sdhci-esdhc-imx: use gpio for write protection and card detection References: <1298469118-25282-1-git-send-email-w.sang@pengutronix.de> <87k4gp3bl1.fsf@lebrac.rtp-net.org> In-Reply-To: <87k4gp3bl1.fsf@lebrac.rtp-net.org> Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org diff --git a/drivers/mmc/host/sdhci-esdhc-imx.c b/drivers/mmc/host/sdhci-esdhc-imx.c index 8ac039a..be11151 100644 --- a/drivers/mmc/host/sdhci-esdhc-imx.c +++ b/drivers/mmc/host/sdhci-esdhc-imx.c @@ -217,6 +217,8 @@ static int esdhc_pltfm_init(struct sdhci_host *host, struct sdhci_pltfm_data *pd /* Now we have a working card_detect again */ host->quirks &= ~SDHCI_QUIRK_BROKEN_CARD_DETECTION; } + if (cpu_is_mx51()) + host->quirks &= ~SDHCI_QUIRK_BROKEN_CARD_DETECTION; return 0; diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c index 9e15f41..11ef076 100644 --- a/drivers/mmc/host/sdhci.c +++ b/drivers/mmc/host/sdhci.c @@ -127,10 +127,14 @@ static void sdhci_set_card_detection(struct sdhci_host *host, bool enable) if (host->quirks & SDHCI_QUIRK_BROKEN_CARD_DETECTION) return; - if (enable) + sdhci_mask_irqs(host, irqs); + if (enable) { + if (!(sdhci_readl(host, SDHCI_PRESENT_STATE) & SDHCI_CARD_PRESENT)) + irqs = SDHCI_INT_CARD_INSERT; + else + irqs = SDHCI_INT_CARD_REMOVE; sdhci_unmask_irqs(host, irqs); - else - sdhci_mask_irqs(host, irqs); + } } static void sdhci_enable_card_detection(struct sdhci_host *host) @@ -992,6 +996,9 @@ static void sdhci_set_clock(struct sdhci_host *host, unsigned int clock) u16 clk; unsigned long timeout; + if ((clock == 0) && (SDHCI_INT_CARD_INSERT & sdhci_readl(host, SDHCI_INT_ENABLE))) + goto out; + if (clock == host->clock) return; @@ -1001,6 +1008,7 @@ static void sdhci_set_clock(struct sdhci_host *host, unsigned int clock) return; } + sdhci_writew(host, 0, SDHCI_CLOCK_CONTROL); if (clock == 0) @@ -1583,9 +1591,18 @@ static irqreturn_t sdhci_irq(int irq, void *dev_id) DBG("*** %s got interrupt: 0x%08x\n", mmc_hostname(host->mmc), intmask); - if (intmask & (SDHCI_INT_CARD_INSERT | SDHCI_INT_CARD_REMOVE)) { - sdhci_writel(host, intmask & (SDHCI_INT_CARD_INSERT | - SDHCI_INT_CARD_REMOVE), SDHCI_INT_STATUS); + if (intmask & SDHCI_INT_CARD_INSERT) { + sdhci_unmask_irqs(host, SDHCI_INT_CARD_REMOVE); + sdhci_mask_irqs(host, SDHCI_INT_CARD_INSERT); + sdhci_writel(host, intmask & SDHCI_INT_CARD_INSERT, + SDHCI_INT_STATUS); + tasklet_schedule(&host->card_tasklet); + } + if (intmask & SDHCI_INT_CARD_REMOVE) { + sdhci_unmask_irqs(host, SDHCI_INT_CARD_INSERT); + sdhci_mask_irqs(host, SDHCI_INT_CARD_REMOVE); + sdhci_writel(host, intmask & SDHCI_INT_CARD_REMOVE, + SDHCI_INT_STATUS); tasklet_schedule(&host->card_tasklet); }