Commit 07728b77 authored by Thomas Petazzoni's avatar Thomas Petazzoni Committed by Chris Ball

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: default avatarThomas Petazzoni <thomas.petazzoni@free-electrons.com>
Signed-off-by: default avatarAndrew Lunn <andrew@lunn.ch>
Tested-by: default avatarStefan Peter <s.peter@mpl.ch>
Tested-by: default avatarFlorian Fainelli <florian@openwrt.org>
Signed-off-by: default avatarJason Cooper <jason@lakedaemon.net>
Signed-off-by: default avatarChris Ball <cjb@laptop.org>
parent 3724482d
...@@ -52,7 +52,6 @@ struct mvsd_host { ...@@ -52,7 +52,6 @@ struct mvsd_host {
struct mmc_host *mmc; struct mmc_host *mmc;
struct device *dev; struct device *dev;
struct clk *clk; struct clk *clk;
int gpio_card_detect;
}; };
#define mvsd_write(offs, val) writel(val, iobase + (offs)) #define mvsd_write(offs, val) writel(val, iobase + (offs))
...@@ -538,13 +537,6 @@ static void mvsd_timeout_timer(unsigned long data) ...@@ -538,13 +537,6 @@ static void mvsd_timeout_timer(unsigned long data)
mmc_request_done(host->mmc, mrq); mmc_request_done(host->mmc, mrq);
} }
static irqreturn_t mvsd_card_detect_irq(int irq, void *dev)
{
struct mvsd_host *host = dev;
mmc_detect_change(host->mmc, msecs_to_jiffies(100));
return IRQ_HANDLED;
}
static void mvsd_enable_sdio_irq(struct mmc_host *mmc, int enable) static void mvsd_enable_sdio_irq(struct mmc_host *mmc, int enable)
{ {
struct mvsd_host *host = mmc_priv(mmc); struct mvsd_host *host = mmc_priv(mmc);
...@@ -757,26 +749,11 @@ static int __init mvsd_probe(struct platform_device *pdev) ...@@ -757,26 +749,11 @@ static int __init mvsd_probe(struct platform_device *pdev)
if (!IS_ERR(host->clk)) if (!IS_ERR(host->clk))
clk_prepare_enable(host->clk); clk_prepare_enable(host->clk);
if (mvsd_data->gpio_card_detect) { if (gpio_is_valid(mvsd_data->gpio_card_detect)) {
ret = devm_gpio_request_one(&pdev->dev, ret = mmc_gpio_request_cd(mmc, mvsd_data->gpio_card_detect);
mvsd_data->gpio_card_detect, if (ret)
GPIOF_IN, DRIVER_NAME " cd"); goto out;
if (ret == 0) { } else
irq = gpio_to_irq(mvsd_data->gpio_card_detect);
ret = devm_request_irq(&pdev->dev, irq,
mvsd_card_detect_irq,
IRQ_TYPE_EDGE_RISING |
IRQ_TYPE_EDGE_FALLING,
DRIVER_NAME " cd", host);
if (ret == 0)
host->gpio_card_detect =
mvsd_data->gpio_card_detect;
else
devm_gpio_free(&pdev->dev,
mvsd_data->gpio_card_detect);
}
}
if (!host->gpio_card_detect)
mmc->caps |= MMC_CAP_NEEDS_POLL; mmc->caps |= MMC_CAP_NEEDS_POLL;
mmc_gpio_request_ro(mmc, mvsd_data->gpio_write_protect); mmc_gpio_request_ro(mmc, mvsd_data->gpio_write_protect);
...@@ -789,15 +766,16 @@ static int __init mvsd_probe(struct platform_device *pdev) ...@@ -789,15 +766,16 @@ static int __init mvsd_probe(struct platform_device *pdev)
pr_notice("%s: %s driver initialized, ", pr_notice("%s: %s driver initialized, ",
mmc_hostname(mmc), DRIVER_NAME); mmc_hostname(mmc), DRIVER_NAME);
if (host->gpio_card_detect) if (!(mmc->caps & MMC_CAP_NEEDS_POLL))
printk("using GPIO %d for card detection\n", printk("using GPIO %d for card detection\n",
host->gpio_card_detect); mvsd_data->gpio_card_detect);
else else
printk("lacking card detect (fall back to polling)\n"); printk("lacking card detect (fall back to polling)\n");
return 0; return 0;
out: out:
if (mmc) { if (mmc) {
mmc_gpio_free_cd(mmc);
mmc_gpio_free_ro(mmc); mmc_gpio_free_ro(mmc);
if (!IS_ERR(host->clk)) if (!IS_ERR(host->clk))
clk_disable_unprepare(host->clk); clk_disable_unprepare(host->clk);
...@@ -813,6 +791,7 @@ static int __exit mvsd_remove(struct platform_device *pdev) ...@@ -813,6 +791,7 @@ static int __exit mvsd_remove(struct platform_device *pdev)
struct mvsd_host *host = mmc_priv(mmc); struct mvsd_host *host = mmc_priv(mmc);
mmc_gpio_free_cd(mmc);
mmc_gpio_free_ro(mmc); mmc_gpio_free_ro(mmc);
mmc_remove_host(mmc); mmc_remove_host(mmc);
del_timer_sync(&host->timer); del_timer_sync(&host->timer);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment