From patchwork Fri May 20 07:35:12 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Huang Changming-R66093 X-Patchwork-Id: 802682 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 p4K8NP2D027205 for ; Fri, 20 May 2011 08:23:25 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934871Ab1ETIXY (ORCPT ); Fri, 20 May 2011 04:23:24 -0400 Received: from va3ehsobe001.messaging.microsoft.com ([216.32.180.11]:2636 "EHLO VA3EHSOBE001.bigfish.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934688Ab1ETIXX (ORCPT ); Fri, 20 May 2011 04:23:23 -0400 Received: from mail119-va3-R.bigfish.com (10.7.14.238) by VA3EHSOBE001.bigfish.com (10.7.40.21) with Microsoft SMTP Server id 14.1.225.22; Fri, 20 May 2011 08:23:21 +0000 Received: from mail119-va3 (localhost.localdomain [127.0.0.1]) by mail119-va3-R.bigfish.com (Postfix) with ESMTP id BFAA616E8652 for ; Fri, 20 May 2011 08:23:21 +0000 (UTC) X-SpamScore: 0 X-BigFish: VS0(zzzz1202hzz8275bhz2dh2a8h668h839h62h) X-Spam-TCS-SCL: 1: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 mail119-va3 (localhost.localdomain [127.0.0.1]) by mail119-va3 (MessageSwitch) id 1305879801638854_25920; Fri, 20 May 2011 08:23:21 +0000 (UTC) Received: from VA3EHSMHS015.bigfish.com (unknown [10.7.14.252]) by mail119-va3.bigfish.com (Postfix) with ESMTP id 9645613D8050 for ; Fri, 20 May 2011 08:23:21 +0000 (UTC) Received: from mail.freescale.net (70.37.183.190) by VA3EHSMHS015.bigfish.com (10.7.99.25) with Microsoft SMTP Server (TLS) id 14.1.225.22; Fri, 20 May 2011 08:23:20 +0000 Received: from az33smr02.freescale.net (10.64.34.200) by 039-SN1MMR1-003.039d.mgd.msft.net (10.84.1.16) with Microsoft SMTP Server id 14.1.270.2; Fri, 20 May 2011 03:23:19 -0500 Received: from localhost (rock.ap.freescale.net [10.193.20.106]) by az33smr02.freescale.net (8.13.1/8.13.0) with ESMTP id p4K8NHkw025781; Fri, 20 May 2011 03:23:18 -0500 (CDT) From: To: CC: Jerry Huang Subject: [PATCH 1/3] SDHCI: add sdhci_get_cd callback to detect the card Date: Fri, 20 May 2011 15:35:12 +0800 Message-ID: <1305876914-23714-1-git-send-email-r66093@freescale.com> X-Mailer: git-send-email 1.6.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]); Fri, 20 May 2011 08:23:25 +0000 (UTC) From: Jerry Huang Add callback function sdhci_get_cd to detect the card. In order to check if the card is present, we will read the PRESENT STATE register and check the bit15. Signed-off-by: Jerry Huang --- drivers/mmc/host/sdhci.c | 19 +++++++++++++++++++ 1 files changed, 19 insertions(+), 0 deletions(-) diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c index 9e15f41..2e60372 100644 --- a/drivers/mmc/host/sdhci.c +++ b/drivers/mmc/host/sdhci.c @@ -1262,6 +1262,24 @@ static int sdhci_get_ro(struct mmc_host *mmc) !is_readonly : is_readonly; } +static int sdhci_get_cd(struct mmc_host *mmc) +{ + struct sdhci_host *host = mmc_priv(mmc); + unsigned long flags; + int present; + + spin_lock_irqsave(&host->lock, flags); + + if (host->flags & SDHCI_DEVICE_DEAD) + present = 0; + else + present = sdhci_readl(host, SDHCI_PRESENT_STATE); + + spin_unlock_irqrestore(&host->lock, flags); + + return present & SDHCI_CARD_PRESENT; +} + static void sdhci_enable_sdio_irq(struct mmc_host *mmc, int enable) { struct sdhci_host *host; @@ -1288,6 +1306,7 @@ static const struct mmc_host_ops sdhci_ops = { .request = sdhci_request, .set_ios = sdhci_set_ios, .get_ro = sdhci_get_ro, + .get_cd = sdhci_get_cd, .enable_sdio_irq = sdhci_enable_sdio_irq, };