aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Petazzoni <thomas.petazzoni@free-electrons.com>2013-01-16 08:13:58 -0500
committerChris Ball <cjb@laptop.org>2013-02-11 13:28:53 -0500
commit07728b77c03dc0721daaf551976d95e6f714af1a (patch)
treee661a4a38d2993094016c5b1c9b061c43c8a95ef
parent3724482d4ce4790d4534bcecebfda2c7133244c7 (diff)
mmc: mvsdio: use slot-gpio for card detect gpio
The MMC core subsystem provides in drivers/mmc/core/slot-gpio.c a nice set of helper functions to simplify the management of the card detect GPIO in MMC host drivers. This patch migrates the mvsdio driver to using those helpers, which will make the ->probe() code simpler, and therefore ease the process of adding a Device Tree binding for this driver. Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com> Signed-off-by: Andrew Lunn <andrew@lunn.ch> Tested-by: Stefan Peter <s.peter@mpl.ch> Tested-by: Florian Fainelli <florian@openwrt.org> Signed-off-by: Jason Cooper <jason@lakedaemon.net> Signed-off-by: Chris Ball <cjb@laptop.org>
-rw-r--r--drivers/mmc/host/mvsdio.c39
1 files changed, 9 insertions, 30 deletions
diff --git a/drivers/mmc/host/mvsdio.c b/drivers/mmc/host/mvsdio.c
index c6dc8fd696ab..704b7a3fe873 100644
--- a/drivers/mmc/host/mvsdio.c
+++ b/drivers/mmc/host/mvsdio.c
@@ -52,7 +52,6 @@ struct mvsd_host {
52 struct mmc_host *mmc; 52 struct mmc_host *mmc;
53 struct device *dev; 53 struct device *dev;
54 struct clk *clk; 54 struct clk *clk;
55 int gpio_card_detect;
56}; 55};
57 56
58#define mvsd_write(offs, val) writel(val, iobase + (offs)) 57#define mvsd_write(offs, val) writel(val, iobase + (offs))
@@ -538,13 +537,6 @@ static void mvsd_timeout_timer(unsigned long data)
538 mmc_request_done(host->mmc, mrq); 537 mmc_request_done(host->mmc, mrq);
539} 538}
540 539
541static irqreturn_t mvsd_card_detect_irq(int irq, void *dev)
542{
543 struct mvsd_host *host = dev;
544 mmc_detect_change(host->mmc, msecs_to_jiffies(100));
545 return IRQ_HANDLED;
546}
547
548static void mvsd_enable_sdio_irq(struct mmc_host *mmc, int enable) 540static void mvsd_enable_sdio_irq(struct mmc_host *mmc, int enable)
549{ 541{
550 struct mvsd_host *host = mmc_priv(mmc); 542 struct mvsd_host *host = mmc_priv(mmc);
@@ -757,26 +749,11 @@ static int __init mvsd_probe(struct platform_device *pdev)
757 if (!IS_ERR(host->clk)) 749 if (!IS_ERR(host->clk))
758 clk_prepare_enable(host->clk); 750 clk_prepare_enable(host->clk);
759 751
760 if (mvsd_data->gpio_card_detect) { 752 if (gpio_is_valid(mvsd_data->gpio_card_detect)) {
761 ret = devm_gpio_request_one(&pdev->dev, 753 ret = mmc_gpio_request_cd(mmc, mvsd_data->gpio_card_detect);
762 mvsd_data->gpio_card_detect, 754 if (ret)
763 GPIOF_IN, DRIVER_NAME " cd"); 755 goto out;
764 if (ret == 0) { 756 } else
765 irq = gpio_to_irq(mvsd_data->gpio_card_detect);
766 ret = devm_request_irq(&pdev->dev, irq,
767 mvsd_card_detect_irq,
768 IRQ_TYPE_EDGE_RISING |
769 IRQ_TYPE_EDGE_FALLING,
770 DRIVER_NAME " cd", host);
771 if (ret == 0)
772 host->gpio_card_detect =
773 mvsd_data->gpio_card_detect;
774 else
775 devm_gpio_free(&pdev->dev,
776 mvsd_data->gpio_card_detect);
777 }
778 }
779 if (!host->gpio_card_detect)
780 mmc->caps |= MMC_CAP_NEEDS_POLL; 757 mmc->caps |= MMC_CAP_NEEDS_POLL;
781 758
782 mmc_gpio_request_ro(mmc, mvsd_data->gpio_write_protect); 759 mmc_gpio_request_ro(mmc, mvsd_data->gpio_write_protect);
@@ -789,15 +766,16 @@ static int __init mvsd_probe(struct platform_device *pdev)
789 766
790 pr_notice("%s: %s driver initialized, ", 767 pr_notice("%s: %s driver initialized, ",
791 mmc_hostname(mmc), DRIVER_NAME); 768 mmc_hostname(mmc), DRIVER_NAME);
792 if (host->gpio_card_detect) 769 if (!(mmc->caps & MMC_CAP_NEEDS_POLL))
793 printk("using GPIO %d for card detection\n", 770 printk("using GPIO %d for card detection\n",
794 host->gpio_card_detect); 771 mvsd_data->gpio_card_detect);
795 else 772 else
796 printk("lacking card detect (fall back to polling)\n"); 773 printk("lacking card detect (fall back to polling)\n");
797 return 0; 774 return 0;
798 775
799out: 776out:
800 if (mmc) { 777 if (mmc) {
778 mmc_gpio_free_cd(mmc);
801 mmc_gpio_free_ro(mmc); 779 mmc_gpio_free_ro(mmc);
802 if (!IS_ERR(host->clk)) 780 if (!IS_ERR(host->clk))
803 clk_disable_unprepare(host->clk); 781 clk_disable_unprepare(host->clk);
@@ -813,6 +791,7 @@ static int __exit mvsd_remove(struct platform_device *pdev)
813 791
814 struct mvsd_host *host = mmc_priv(mmc); 792 struct mvsd_host *host = mmc_priv(mmc);
815 793
794 mmc_gpio_free_cd(mmc);
816 mmc_gpio_free_ro(mmc); 795 mmc_gpio_free_ro(mmc);
817 mmc_remove_host(mmc); 796 mmc_remove_host(mmc);
818 del_timer_sync(&host->timer); 797 del_timer_sync(&host->timer);