1 From patchwork Wed Jan 16 13:13:58 2013
2 Content-Type: text/plain; charset="utf-8"
4 Content-Transfer-Encoding: 7bit
5 Subject: [3/5] mmc: mvsdio: use slot-gpio for card detect gpio
6 Date: Wed, 16 Jan 2013 13:13:58 -0000
7 From: Andrew Lunn <andrew@lunn.ch>
8 X-Patchwork-Id: 1987941
9 Message-Id: <1358342040-7130-4-git-send-email-andrew@lunn.ch>
10 To: Jason Cooper <jason@lakedaemon.net>
11 Cc: linux ARM <linux-arm-kernel@lists.infradead.org>,
12 linux-mmc@vger.kernel.org, linux@arm.linux.org.uk,
13 Thomas Petazzoni <thomas.petazzoni@free-electrons.com>,
14 Andrew Lunn <andrew@lunn.ch>
16 From: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
18 The MMC core subsystem provides in drivers/mmc/core/slot-gpio.c a nice
19 set of helper functions to simplify the management of the card detect
20 GPIO in MMC host drivers. This patch migrates the mvsdio driver to
21 using those helpers, which will make the ->probe() code simpler, and
22 therefore ease the process of adding a Device Tree binding for this
25 Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
26 Signed-off-by: Andrew Lunn <andrew@lunn.ch>
27 Tested-by: Stefan Peter <s.peter@mpl.ch>
28 Tested-by: Florian Fainelli <florian@openwrt.org>
29 Signed-off-by: Jason Cooper <jason@lakedaemon.net>
32 drivers/mmc/host/mvsdio.c | 39 +++++++++------------------------------
33 1 file changed, 9 insertions(+), 30 deletions(-)
35 --- a/drivers/mmc/host/mvsdio.c
36 +++ b/drivers/mmc/host/mvsdio.c
37 @@ -52,7 +52,6 @@ struct mvsd_host {
41 - int gpio_card_detect;
44 #define mvsd_write(offs, val) writel(val, iobase + (offs))
45 @@ -538,13 +537,6 @@ static void mvsd_timeout_timer(unsigned
46 mmc_request_done(host->mmc, mrq);
49 -static irqreturn_t mvsd_card_detect_irq(int irq, void *dev)
51 - struct mvsd_host *host = dev;
52 - mmc_detect_change(host->mmc, msecs_to_jiffies(100));
56 static void mvsd_enable_sdio_irq(struct mmc_host *mmc, int enable)
58 struct mvsd_host *host = mmc_priv(mmc);
59 @@ -757,26 +749,11 @@ static int __init mvsd_probe(struct plat
60 if (!IS_ERR(host->clk))
61 clk_prepare_enable(host->clk);
63 - if (mvsd_data->gpio_card_detect) {
64 - ret = devm_gpio_request_one(&pdev->dev,
65 - mvsd_data->gpio_card_detect,
66 - GPIOF_IN, DRIVER_NAME " cd");
68 - irq = gpio_to_irq(mvsd_data->gpio_card_detect);
69 - ret = devm_request_irq(&pdev->dev, irq,
70 - mvsd_card_detect_irq,
71 - IRQ_TYPE_EDGE_RISING |
72 - IRQ_TYPE_EDGE_FALLING,
73 - DRIVER_NAME " cd", host);
75 - host->gpio_card_detect =
76 - mvsd_data->gpio_card_detect;
78 - devm_gpio_free(&pdev->dev,
79 - mvsd_data->gpio_card_detect);
82 - if (!host->gpio_card_detect)
83 + if (gpio_is_valid(mvsd_data->gpio_card_detect)) {
84 + ret = mmc_gpio_request_cd(mmc, mvsd_data->gpio_card_detect);
88 mmc->caps |= MMC_CAP_NEEDS_POLL;
90 mmc_gpio_request_ro(mmc, mvsd_data->gpio_write_protect);
91 @@ -789,15 +766,16 @@ static int __init mvsd_probe(struct plat
93 pr_notice("%s: %s driver initialized, ",
94 mmc_hostname(mmc), DRIVER_NAME);
95 - if (host->gpio_card_detect)
96 + if (!(mmc->caps & MMC_CAP_NEEDS_POLL))
97 printk("using GPIO %d for card detection\n",
98 - host->gpio_card_detect);
99 + mvsd_data->gpio_card_detect);
101 printk("lacking card detect (fall back to polling)\n");
106 + mmc_gpio_free_cd(mmc);
107 mmc_gpio_free_ro(mmc);
108 if (!IS_ERR(host->clk))
109 clk_disable_unprepare(host->clk);
110 @@ -813,6 +791,7 @@ static int __exit mvsd_remove(struct pla
112 struct mvsd_host *host = mmc_priv(mmc);
114 + mmc_gpio_free_cd(mmc);
115 mmc_gpio_free_ro(mmc);
116 mmc_remove_host(mmc);
117 del_timer_sync(&host->timer);