mvebu: switch to 3.10
[openwrt/staging/chunkeey.git] / target / linux / mvebu / patches-3.8 / 006-mmc_mvsdio_use_slot_gpio.patch
1 From patchwork Wed Jan 16 13:13:57 2013
2 Content-Type: text/plain; charset="utf-8"
3 MIME-Version: 1.0
4 Content-Transfer-Encoding: 7bit
5 Subject: [2/5] mmc: mvsdio: use slot-gpio infrastructure for write protect gpio
6 Date: Wed, 16 Jan 2013 13:13:57 -0000
7 From: Andrew Lunn <andrew@lunn.ch>
8 X-Patchwork-Id: 1987931
9 Message-Id: <1358342040-7130-3-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>
15
16 From: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
17
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 write
20 protect GPIO in MMC host drivers. This patch migrates the mvsdio
21 driver to using those helpers, which will make the ->probe() code
22 simpler, and therefore ease the process of adding a Device Tree
23 binding for this driver.
24
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>
30
31 ---
32 drivers/mmc/host/mvsdio.c | 30 +++++-------------------------
33 1 file changed, 5 insertions(+), 25 deletions(-)
34
35 --- a/drivers/mmc/host/mvsdio.c
36 +++ b/drivers/mmc/host/mvsdio.c
37 @@ -22,6 +22,7 @@
38 #include <linux/clk.h>
39 #include <linux/gpio.h>
40 #include <linux/mmc/host.h>
41 +#include <linux/mmc/slot-gpio.h>
42
43 #include <asm/sizes.h>
44 #include <asm/unaligned.h>
45 @@ -52,7 +53,6 @@ struct mvsd_host {
46 struct device *dev;
47 struct clk *clk;
48 int gpio_card_detect;
49 - int gpio_write_protect;
50 };
51
52 #define mvsd_write(offs, val) writel(val, iobase + (offs))
53 @@ -564,20 +564,6 @@ static void mvsd_enable_sdio_irq(struct
54 spin_unlock_irqrestore(&host->lock, flags);
55 }
56
57 -static int mvsd_get_ro(struct mmc_host *mmc)
58 -{
59 - struct mvsd_host *host = mmc_priv(mmc);
60 -
61 - if (host->gpio_write_protect)
62 - return gpio_get_value(host->gpio_write_protect);
63 -
64 - /*
65 - * Board doesn't support read only detection; let the mmc core
66 - * decide what to do.
67 - */
68 - return -ENOSYS;
69 -}
70 -
71 static void mvsd_power_up(struct mvsd_host *host)
72 {
73 void __iomem *iobase = host->base;
74 @@ -674,7 +660,7 @@ static void mvsd_set_ios(struct mmc_host
75
76 static const struct mmc_host_ops mvsd_ops = {
77 .request = mvsd_request,
78 - .get_ro = mvsd_get_ro,
79 + .get_ro = mmc_gpio_get_ro,
80 .set_ios = mvsd_set_ios,
81 .enable_sdio_irq = mvsd_enable_sdio_irq,
82 };
83 @@ -793,15 +779,7 @@ static int __init mvsd_probe(struct plat
84 if (!host->gpio_card_detect)
85 mmc->caps |= MMC_CAP_NEEDS_POLL;
86
87 - if (mvsd_data->gpio_write_protect) {
88 - ret = devm_gpio_request_one(&pdev->dev,
89 - mvsd_data->gpio_write_protect,
90 - GPIOF_IN, DRIVER_NAME " wp");
91 - if (ret == 0) {
92 - host->gpio_write_protect =
93 - mvsd_data->gpio_write_protect;
94 - }
95 - }
96 + mmc_gpio_request_ro(mmc, mvsd_data->gpio_write_protect);
97
98 setup_timer(&host->timer, mvsd_timeout_timer, (unsigned long)host);
99 platform_set_drvdata(pdev, mmc);
100 @@ -820,6 +798,7 @@ static int __init mvsd_probe(struct plat
101
102 out:
103 if (mmc) {
104 + mmc_gpio_free_ro(mmc);
105 if (!IS_ERR(host->clk))
106 clk_disable_unprepare(host->clk);
107 mmc_free_host(mmc);
108 @@ -834,6 +813,7 @@ static int __exit mvsd_remove(struct pla
109
110 struct mvsd_host *host = mmc_priv(mmc);
111
112 + mmc_gpio_free_ro(mmc);
113 mmc_remove_host(mmc);
114 del_timer_sync(&host->timer);
115 mvsd_power_down(host);