mvebu: add inital support for Marvell Armada XP/370 SoCs
[openwrt.git] / target / linux / mvebu / patches-3.8 / 006-mmc_mvsdio_use_slot_gpio.patch
1 The MMC core subsystem provides in drivers/mmc/core/slot-gpio.c a nice
2 set of helper functions to simplify the management of the write
3 protect GPIO in MMC host drivers. This patch migrates the mvsdio
4 driver to using those helpers, which will make the ->probe() code
5 simpler, and therefore ease the process of adding a Device Tree
6 binding for this driver.
7
8 Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
9 ---
10  drivers/mmc/host/mvsdio.c |   34 +++++-----------------------------
11  1 file changed, 5 insertions(+), 29 deletions(-)
12
13 diff --git a/drivers/mmc/host/mvsdio.c b/drivers/mmc/host/mvsdio.c
14 index de4c20b..a24a22f 100644
15 --- a/drivers/mmc/host/mvsdio.c
16 +++ b/drivers/mmc/host/mvsdio.c
17 @@ -22,6 +22,7 @@
18  #include <linux/clk.h>
19  #include <linux/gpio.h>
20  #include <linux/mmc/host.h>
21 +#include <linux/mmc/slot-gpio.h>
22  
23  #include <asm/sizes.h>
24  #include <asm/unaligned.h>
25 @@ -54,7 +55,6 @@ struct mvsd_host {
26         int irq;
27         struct clk *clk;
28         int gpio_card_detect;
29 -       int gpio_write_protect;
30  };
31  
32  #define mvsd_write(offs, val)  writel(val, iobase + (offs))
33 @@ -566,20 +566,6 @@ static void mvsd_enable_sdio_irq(struct mmc_host *mmc, int enable)
34         spin_unlock_irqrestore(&host->lock, flags);
35  }
36  
37 -static int mvsd_get_ro(struct mmc_host *mmc)
38 -{
39 -       struct mvsd_host *host = mmc_priv(mmc);
40 -
41 -       if (host->gpio_write_protect)
42 -               return gpio_get_value(host->gpio_write_protect);
43 -
44 -       /*
45 -        * Board doesn't support read only detection; let the mmc core
46 -        * decide what to do.
47 -        */
48 -       return -ENOSYS;
49 -}
50 -
51  static void mvsd_power_up(struct mvsd_host *host)
52  {
53         void __iomem *iobase = host->base;
54 @@ -676,7 +662,7 @@ static void mvsd_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
55  
56  static const struct mmc_host_ops mvsd_ops = {
57         .request                = mvsd_request,
58 -       .get_ro                 = mvsd_get_ro,
59 +       .get_ro                 = mmc_gpio_get_ro,
60         .set_ios                = mvsd_set_ios,
61         .enable_sdio_irq        = mvsd_enable_sdio_irq,
62  };
63 @@ -798,15 +784,7 @@ static int __init mvsd_probe(struct platform_device *pdev)
64         if (!host->gpio_card_detect)
65                 mmc->caps |= MMC_CAP_NEEDS_POLL;
66  
67 -       if (mvsd_data->gpio_write_protect) {
68 -               ret = gpio_request(mvsd_data->gpio_write_protect,
69 -                                  DRIVER_NAME " wp");
70 -               if (ret == 0) {
71 -                       gpio_direction_input(mvsd_data->gpio_write_protect);
72 -                       host->gpio_write_protect =
73 -                               mvsd_data->gpio_write_protect;
74 -               }
75 -       }
76 +       mmc_gpio_request_ro(mmc, mvsd_data->gpio_write_protect);
77  
78         setup_timer(&host->timer, mvsd_timeout_timer, (unsigned long)host);
79         platform_set_drvdata(pdev, mmc);
80 @@ -831,8 +809,7 @@ out:
81                         free_irq(gpio_to_irq(host->gpio_card_detect), host);
82                         gpio_free(host->gpio_card_detect);
83                 }
84 -               if (host->gpio_write_protect)
85 -                       gpio_free(host->gpio_write_protect);
86 +               mmc_gpio_free_ro(mmc);
87                 if (host->base)
88                         iounmap(host->base);
89         }
90 @@ -861,8 +838,7 @@ static int __exit mvsd_remove(struct platform_device *pdev)
91                 }
92                 mmc_remove_host(mmc);
93                 free_irq(host->irq, host);
94 -               if (host->gpio_write_protect)
95 -                       gpio_free(host->gpio_write_protect);
96 +               mmc_gpio_free_ro(mmc);
97                 del_timer_sync(&host->timer);
98                 mvsd_power_down(host);
99                 iounmap(host->base);
100 -- 
101 1.7.9.5