From: Jerry Huang <Chang-Ming.Huang@xxxxxxxxxxxxx> In order to check if the card is present, we will read the PRESENT STATE register and check the bit13(Card detect pin level) and bit15(CINS). Signed-off-by: Jerry Huang <Chang-Ming.Huang@xxxxxxxxxxxxx> CC: Chris Ball <cjb@xxxxxxxxxx> --- changes for v2: - add new callback for esdhc to detect the card state - add the CC drivers/mmc/host/sdhci-of-esdhc.c | 18 +++++++++++++++++- 1 files changed, 17 insertions(+), 1 deletions(-) diff --git a/drivers/mmc/host/sdhci-of-esdhc.c b/drivers/mmc/host/sdhci-of-esdhc.c index 59e9d00..cb71810 100644 --- a/drivers/mmc/host/sdhci-of-esdhc.c +++ b/drivers/mmc/host/sdhci-of-esdhc.c @@ -1,7 +1,7 @@ /* * Freescale eSDHC controller driver. * - * Copyright (c) 2007, 2010 Freescale Semiconductor, Inc. + * Copyright (c) 2007, 2010-2011 Freescale Semiconductor, Inc. * Copyright (c) 2009 MontaVista Software, Inc. * * Authors: Xiaobo Xie <X.Xie@xxxxxxxxxxxxx> @@ -82,6 +82,21 @@ static unsigned int esdhc_of_get_min_clock(struct sdhci_host *host) return pltfm_host->clock / 256 / 16; } +/* Return: none zero - the card is presetn; 0 - card is absent */ +static int esdhc_of_get_cd(struct sdhci_host *host) +{ + int present; + + if (host->flags & SDHCI_DEVICE_DEAD) + present = 0; + else { + present = sdhci_be32bs_readl(host, SDHCI_PRESENT_STATE); + present &= (SDHCI_CARD_PRESENT | SDHCI_CARD_CDPL); + } + + return present; +} + static struct sdhci_ops sdhci_esdhc_ops = { .read_l = sdhci_be32bs_readl, .read_w = esdhc_readw, @@ -93,6 +108,7 @@ static struct sdhci_ops sdhci_esdhc_ops = { .enable_dma = esdhc_of_enable_dma, .get_max_clock = esdhc_of_get_max_clock, .get_min_clock = esdhc_of_get_min_clock, + .get_cd = esdhc_of_get_cd, }; static struct sdhci_pltfm_data sdhci_esdhc_pdata = { -- 1.7.5.4 -- To unsubscribe from this list: send the line "unsubscribe linux-mmc" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html