diff options
author | Jerry Huang <Chang-Ming.Huang@freescale.com> | 2013-03-06 06:02:22 (GMT) |
---|---|---|
committer | Fleming Andrew-AFLEMING <AFLEMING@freescale.com> | 2013-03-27 22:14:52 (GMT) |
commit | 7596754e8c919bc9b3686749c7ebabf8217953c4 (patch) | |
tree | 16af03239bb3d613b43f6081181e5fec8f961d52 /drivers/mmc | |
parent | 1b8905547d2af23695cbc1dee13bf4e446db59e5 (diff) | |
download | linux-fsl-qoriq-7596754e8c919bc9b3686749c7ebabf8217953c4.tar.xz |
ESDHC: add callback esdhc_of_get_cd to detect card
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@freescale.com>
Change-Id: I6a46de392ba4eb30ca675ae55b33709be9e7a770
Reviewed-on: http://git.am.freescale.net:8181/488
Reviewed-by: Xie Xiaobo-R63061 <X.Xie@freescale.com>
Reviewed-by: Fleming Andrew-AFLEMING <AFLEMING@freescale.com>
Tested-by: Fleming Andrew-AFLEMING <AFLEMING@freescale.com>
Diffstat (limited to 'drivers/mmc')
-rw-r--r-- | drivers/mmc/host/sdhci-of-esdhc.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/drivers/mmc/host/sdhci-of-esdhc.c b/drivers/mmc/host/sdhci-of-esdhc.c index f32526d..dbb32a5 100644 --- a/drivers/mmc/host/sdhci-of-esdhc.c +++ b/drivers/mmc/host/sdhci-of-esdhc.c @@ -230,6 +230,31 @@ static void esdhc_of_platform_init(struct sdhci_host *host) host->quirks &= ~SDHCI_QUIRK_NO_BUSY_IRQ; } +/* Return: 1 - the card is present; 0 - card is absent */ +static int esdhc_of_get_cd(struct sdhci_host *host) +{ + u32 present; + u32 sysctl; + + if (host->flags & SDHCI_DEVICE_DEAD) + return 0; + + sysctl = sdhci_be32bs_readl(host, SDHCI_CLOCK_CONTROL); + + /* Enable the controller clock to update the present state */ + sdhci_be32bs_writel(host, sysctl | SDHCI_CLOCK_INT_EN, + SDHCI_CLOCK_CONTROL); + + /* Detect the card present or absent */ + present = sdhci_be32bs_readl(host, SDHCI_PRESENT_STATE); + present &= (SDHCI_CARD_PRESENT | SDHCI_CARD_CDPL); + + /* Resave the previous to System control register */ + sdhci_be32bs_writel(host, sysctl, SDHCI_CLOCK_CONTROL); + + return !!present; +} + static struct sdhci_ops sdhci_esdhc_ops = { .read_l = esdhc_readl, .read_w = esdhc_readw, @@ -242,6 +267,7 @@ static struct sdhci_ops sdhci_esdhc_ops = { .get_max_clock = esdhc_of_get_max_clock, .get_min_clock = esdhc_of_get_min_clock, .platform_init = esdhc_of_platform_init, + .get_cd = esdhc_of_get_cd, #ifdef CONFIG_PM .platform_suspend = esdhc_of_suspend, .platform_resume = esdhc_of_resume, |