diff options
author | Shawn Guo <shawn.guo@linaro.org> | 2012-12-11 09:32:20 -0500 |
---|---|---|
committer | Chris Ball <cjb@laptop.org> | 2013-02-11 12:51:24 -0500 |
commit | fbe5fdd12c4cdae61a8c3d371e564371177da86e (patch) | |
tree | bdcda448cd93de95d267c99cf79a064cd54e3252 /drivers/mmc/host/sdhci-esdhc-imx.c | |
parent | 164cda5236acf833f22a3edafdf8b95a7de7b402 (diff) |
mmc: sdhci-esdhc-imx: use slot-gpio helpers for CD and WP
Use slot-gpio helpers to save some code in the driver.
Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
Signed-off-by: Chris Ball <cjb@laptop.org>
Diffstat (limited to 'drivers/mmc/host/sdhci-esdhc-imx.c')
-rw-r--r-- | drivers/mmc/host/sdhci-esdhc-imx.c | 56 |
1 files changed, 16 insertions, 40 deletions
diff --git a/drivers/mmc/host/sdhci-esdhc-imx.c b/drivers/mmc/host/sdhci-esdhc-imx.c index e07df812ff1e..dd7fcc137644 100644 --- a/drivers/mmc/host/sdhci-esdhc-imx.c +++ b/drivers/mmc/host/sdhci-esdhc-imx.c | |||
@@ -21,6 +21,7 @@ | |||
21 | #include <linux/mmc/host.h> | 21 | #include <linux/mmc/host.h> |
22 | #include <linux/mmc/mmc.h> | 22 | #include <linux/mmc/mmc.h> |
23 | #include <linux/mmc/sdio.h> | 23 | #include <linux/mmc/sdio.h> |
24 | #include <linux/mmc/slot-gpio.h> | ||
24 | #include <linux/of.h> | 25 | #include <linux/of.h> |
25 | #include <linux/of_device.h> | 26 | #include <linux/of_device.h> |
26 | #include <linux/of_gpio.h> | 27 | #include <linux/of_gpio.h> |
@@ -147,17 +148,16 @@ static u32 esdhc_readl_le(struct sdhci_host *host, int reg) | |||
147 | struct pltfm_imx_data *imx_data = pltfm_host->priv; | 148 | struct pltfm_imx_data *imx_data = pltfm_host->priv; |
148 | struct esdhc_platform_data *boarddata = &imx_data->boarddata; | 149 | struct esdhc_platform_data *boarddata = &imx_data->boarddata; |
149 | 150 | ||
150 | /* fake CARD_PRESENT flag */ | ||
151 | u32 val = readl(host->ioaddr + reg); | 151 | u32 val = readl(host->ioaddr + reg); |
152 | 152 | ||
153 | if (unlikely((reg == SDHCI_PRESENT_STATE) | 153 | if (unlikely(reg == SDHCI_PRESENT_STATE)) { |
154 | && gpio_is_valid(boarddata->cd_gpio))) { | 154 | /* |
155 | if (gpio_get_value(boarddata->cd_gpio)) | 155 | * After SDHCI core gets improved to never query |
156 | /* no card, if a valid gpio says so... */ | 156 | * SDHCI_CARD_PRESENT state in GPIO case, we can |
157 | * remove this check. | ||
158 | */ | ||
159 | if (boarddata->cd_type == ESDHC_CD_GPIO) | ||
157 | val &= ~SDHCI_CARD_PRESENT; | 160 | val &= ~SDHCI_CARD_PRESENT; |
158 | else | ||
159 | /* ... in all other cases assume card is present */ | ||
160 | val |= SDHCI_CARD_PRESENT; | ||
161 | } | 161 | } |
162 | 162 | ||
163 | if (unlikely(reg == SDHCI_CAPABILITIES)) { | 163 | if (unlikely(reg == SDHCI_CAPABILITIES)) { |
@@ -362,8 +362,7 @@ static unsigned int esdhc_pltfm_get_ro(struct sdhci_host *host) | |||
362 | 362 | ||
363 | switch (boarddata->wp_type) { | 363 | switch (boarddata->wp_type) { |
364 | case ESDHC_WP_GPIO: | 364 | case ESDHC_WP_GPIO: |
365 | if (gpio_is_valid(boarddata->wp_gpio)) | 365 | return mmc_gpio_get_ro(host->mmc); |
366 | return gpio_get_value(boarddata->wp_gpio); | ||
367 | case ESDHC_WP_CONTROLLER: | 366 | case ESDHC_WP_CONTROLLER: |
368 | return !(readl(host->ioaddr + SDHCI_PRESENT_STATE) & | 367 | return !(readl(host->ioaddr + SDHCI_PRESENT_STATE) & |
369 | SDHCI_WRITE_PROTECT); | 368 | SDHCI_WRITE_PROTECT); |
@@ -394,14 +393,6 @@ static struct sdhci_pltfm_data sdhci_esdhc_imx_pdata = { | |||
394 | .ops = &sdhci_esdhc_ops, | 393 | .ops = &sdhci_esdhc_ops, |
395 | }; | 394 | }; |
396 | 395 | ||
397 | static irqreturn_t cd_irq(int irq, void *data) | ||
398 | { | ||
399 | struct sdhci_host *sdhost = (struct sdhci_host *)data; | ||
400 | |||
401 | tasklet_schedule(&sdhost->card_tasklet); | ||
402 | return IRQ_HANDLED; | ||
403 | }; | ||
404 | |||
405 | #ifdef CONFIG_OF | 396 | #ifdef CONFIG_OF |
406 | static int | 397 | static int |
407 | sdhci_esdhc_imx_probe_dt(struct platform_device *pdev, | 398 | sdhci_esdhc_imx_probe_dt(struct platform_device *pdev, |
@@ -527,37 +518,22 @@ static int sdhci_esdhc_imx_probe(struct platform_device *pdev) | |||
527 | 518 | ||
528 | /* write_protect */ | 519 | /* write_protect */ |
529 | if (boarddata->wp_type == ESDHC_WP_GPIO) { | 520 | if (boarddata->wp_type == ESDHC_WP_GPIO) { |
530 | err = devm_gpio_request_one(&pdev->dev, boarddata->wp_gpio, | 521 | err = mmc_gpio_request_ro(host->mmc, boarddata->wp_gpio); |
531 | GPIOF_IN, "ESDHC_WP"); | ||
532 | if (err) { | 522 | if (err) { |
533 | dev_warn(mmc_dev(host->mmc), | 523 | dev_err(mmc_dev(host->mmc), |
534 | "no write-protect pin available!\n"); | 524 | "failed to request write-protect gpio!\n"); |
535 | boarddata->wp_gpio = -EINVAL; | 525 | goto disable_clk; |
536 | } | 526 | } |
537 | } else { | 527 | host->mmc->caps2 |= MMC_CAP2_RO_ACTIVE_HIGH; |
538 | boarddata->wp_gpio = -EINVAL; | ||
539 | } | 528 | } |
540 | 529 | ||
541 | /* card_detect */ | 530 | /* card_detect */ |
542 | if (boarddata->cd_type != ESDHC_CD_GPIO) | ||
543 | boarddata->cd_gpio = -EINVAL; | ||
544 | |||
545 | switch (boarddata->cd_type) { | 531 | switch (boarddata->cd_type) { |
546 | case ESDHC_CD_GPIO: | 532 | case ESDHC_CD_GPIO: |
547 | err = devm_gpio_request_one(&pdev->dev, boarddata->cd_gpio, | 533 | err = mmc_gpio_request_cd(host->mmc, boarddata->cd_gpio); |
548 | GPIOF_IN, "ESDHC_CD"); | ||
549 | if (err) { | 534 | if (err) { |
550 | dev_err(mmc_dev(host->mmc), | 535 | dev_err(mmc_dev(host->mmc), |
551 | "no card-detect pin available!\n"); | 536 | "failed to request card-detect gpio!\n"); |
552 | goto disable_clk; | ||
553 | } | ||
554 | |||
555 | err = devm_request_irq(&pdev->dev, | ||
556 | gpio_to_irq(boarddata->cd_gpio), cd_irq, | ||
557 | IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING, | ||
558 | mmc_hostname(host->mmc), host); | ||
559 | if (err) { | ||
560 | dev_err(mmc_dev(host->mmc), "request irq error\n"); | ||
561 | goto disable_clk; | 537 | goto disable_clk; |
562 | } | 538 | } |
563 | /* fall through */ | 539 | /* fall through */ |