From patchwork Mon Nov 19 05:27:25 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Huang Changming-R66093 X-Patchwork-Id: 1763251 Return-Path: X-Original-To: patchwork-linux-mmc@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id ED3A03FCA5 for ; Mon, 19 Nov 2012 06:13:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751707Ab2KSGNq (ORCPT ); Mon, 19 Nov 2012 01:13:46 -0500 Received: from co1ehsobe001.messaging.microsoft.com ([216.32.180.184]:3852 "EHLO co1outboundpool.messaging.microsoft.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751265Ab2KSGNq (ORCPT ); Mon, 19 Nov 2012 01:13:46 -0500 Received: from mail15-co1-R.bigfish.com (10.243.78.228) by CO1EHSOBE001.bigfish.com (10.243.66.64) with Microsoft SMTP Server id 14.1.225.23; Mon, 19 Nov 2012 06:13:44 +0000 Received: from mail15-co1 (localhost [127.0.0.1]) by mail15-co1-R.bigfish.com (Postfix) with ESMTP id 9F08E2C0226; Mon, 19 Nov 2012 06:13:44 +0000 (UTC) X-Forefront-Antispam-Report: CIP:70.37.183.190; KIP:(null); UIP:(null); IPV:NLI; H:mail.freescale.net; RD:none; EFVD:NLI X-SpamScore: 0 X-BigFish: VS0(zzzz1de0h1202h1d1ah1d2ahzz8275bh8275dhz2dh2a8h668h839hd24he5bhf0ah1288h12a5h12a9h12bdh12e5h137ah139eh13b6h1441h1504h1537h162dh1631h1155h) Received: from mail15-co1 (localhost.localdomain [127.0.0.1]) by mail15-co1 (MessageSwitch) id 1353305622457755_26407; Mon, 19 Nov 2012 06:13:42 +0000 (UTC) Received: from CO1EHSMHS005.bigfish.com (unknown [10.243.78.237]) by mail15-co1.bigfish.com (Postfix) with ESMTP id 638A9C800D8; Mon, 19 Nov 2012 06:13:42 +0000 (UTC) Received: from mail.freescale.net (70.37.183.190) by CO1EHSMHS005.bigfish.com (10.243.66.15) with Microsoft SMTP Server (TLS) id 14.1.225.23; Mon, 19 Nov 2012 06:13:42 +0000 Received: from tx30smr01.am.freescale.net (10.81.153.31) by 039-SN1MMR1-001.039d.mgd.msft.net (10.84.1.13) with Microsoft SMTP Server (TLS) id 14.2.318.3; Mon, 19 Nov 2012 06:13:41 +0000 Received: from localhost (rock.ap.freescale.net [10.193.20.106]) by tx30smr01.am.freescale.net (8.14.3/8.14.0) with ESMTP id qAJ6DcV3018386; Sun, 18 Nov 2012 23:13:40 -0700 From: To: CC: Jerry Huang , Chris Ball Subject: [PATCH 2/3 v6] SDHCI: add sdhci_get_cd callback to detect the card Date: Mon, 19 Nov 2012 13:27:25 +0800 Message-ID: <1353302846-19514-2-git-send-email-r66093@freescale.com> X-Mailer: git-send-email 1.6.4 In-Reply-To: <1353302846-19514-1-git-send-email-r66093@freescale.com> References: <1353302846-19514-1-git-send-email-r66093@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 From: Jerry Huang Add callback function sdhci_get_cd to detect the card. And one new callback added to implement the card detect in sdhci struncture. If special platform has the card detect callback, it will return the card state, the value zero is for absent cardi and one is for present card. If the controller don't support card detect, sdhci_get_cd will return -ENOSYS. Signed-off-by: Jerry Huang Reviewed-by: Anton Vorontsov CC: Chris Ball --- changes for v2: - when controller don't support get_cd, return -ENOSYS - add new callback for sdhci to detect the card - add the CC changes for v3: - use pin_lock only when get_cd defined changes for v4: - enalbe the controller clock in platform, instead of core changes for v5: - remove the copyright changes for v6: - fix the incorrect style and add the reviewed-by. drivers/mmc/host/sdhci.c | 22 ++++++++++++++++++++++ drivers/mmc/host/sdhci.h | 2 ++ 2 files changed, 24 insertions(+) diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c index e746b3d6..038826a 100644 --- a/drivers/mmc/host/sdhci.c +++ b/drivers/mmc/host/sdhci.c @@ -1576,6 +1576,27 @@ static int sdhci_get_ro(struct mmc_host *mmc) return ret; } +/* + * Return values for the sdhci_get_cd callback: + * 0: for a absent card + * 1: for a present card + * -ENOSYS: when not supported (equal to NULL callback) + */ +static int sdhci_get_cd(struct mmc_host *mmc) +{ + struct sdhci_host *host = mmc_priv(mmc); + unsigned long flags; + int present = -ENOSYS; + + if (host->ops->get_cd) { + spin_lock_irqsave(&host->lock, flags); + present = host->ops->get_cd(host); + spin_unlock_irqrestore(&host->lock, flags); + } + + return present; +} + static void sdhci_enable_sdio_irq_nolock(struct sdhci_host *host, int enable) { if (host->flags & SDHCI_DEVICE_DEAD) @@ -1998,6 +2019,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, .hw_reset = sdhci_hw_reset, .enable_sdio_irq = sdhci_enable_sdio_irq, .start_signal_voltage_switch = sdhci_start_signal_voltage_switch, diff --git a/drivers/mmc/host/sdhci.h b/drivers/mmc/host/sdhci.h index 71a4a7e..7c8f08d 100644 --- a/drivers/mmc/host/sdhci.h +++ b/drivers/mmc/host/sdhci.h @@ -69,6 +69,7 @@ #define SDHCI_SPACE_AVAILABLE 0x00000400 #define SDHCI_DATA_AVAILABLE 0x00000800 #define SDHCI_CARD_PRESENT 0x00010000 +#define SDHCI_CARD_CDPL 0x00040000 #define SDHCI_WRITE_PROTECT 0x00080000 #define SDHCI_DATA_LVL_MASK 0x00F00000 #define SDHCI_DATA_LVL_SHIFT 20 @@ -263,6 +264,7 @@ struct sdhci_ops { void (*set_clock)(struct sdhci_host *host, unsigned int clock); + int (*get_cd)(struct sdhci_host *host); int (*enable_dma)(struct sdhci_host *host); unsigned int (*get_max_clock)(struct sdhci_host *host); unsigned int (*get_min_clock)(struct sdhci_host *host);