aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mmc
diff options
context:
space:
mode:
authorGuennadi Liakhovetski <g.liakhovetski@gmx.de>2012-04-30 17:31:57 -0400
committerChris Ball <cjb@laptop.org>2012-07-10 23:04:04 -0400
commitfd0ea65d3e675e479e022b6cfc9ebe1864c76afc (patch)
tree8869d7965ccb05b9ca635d21c983d84a552ee21e /drivers/mmc
parent0f506a96693d8ad4aeccbd98dbd54a3c7357cfa8 (diff)
mmc: extend and rename cd-gpio helpers to handle more slot GPIO functions
GPIOs can be used in MMC/SD-card slots not only for hotplug detection, but also to implement the write-protection pin. Rename cd-gpio helpers to slot-gpio to make addition of further slot GPIO functions possible. Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de> Signed-off-by: Chris Ball <cjb@laptop.org>
Diffstat (limited to 'drivers/mmc')
-rw-r--r--drivers/mmc/core/Makefile2
-rw-r--r--drivers/mmc/core/slot-gpio.c (renamed from drivers/mmc/core/cd-gpio.c)48
-rw-r--r--drivers/mmc/host/tmio_mmc_pio.c6
3 files changed, 28 insertions, 28 deletions
diff --git a/drivers/mmc/core/Makefile b/drivers/mmc/core/Makefile
index dca4428380f1..38ed210ce2f3 100644
--- a/drivers/mmc/core/Makefile
+++ b/drivers/mmc/core/Makefile
@@ -7,6 +7,6 @@ mmc_core-y := core.o bus.o host.o \
7 mmc.o mmc_ops.o sd.o sd_ops.o \ 7 mmc.o mmc_ops.o sd.o sd_ops.o \
8 sdio.o sdio_ops.o sdio_bus.o \ 8 sdio.o sdio_ops.o sdio_bus.o \
9 sdio_cis.o sdio_io.o sdio_irq.o \ 9 sdio_cis.o sdio_io.o sdio_irq.o \
10 quirks.o cd-gpio.o 10 quirks.o slot-gpio.o
11 11
12mmc_core-$(CONFIG_DEBUG_FS) += debugfs.o 12mmc_core-$(CONFIG_DEBUG_FS) += debugfs.o
diff --git a/drivers/mmc/core/cd-gpio.c b/drivers/mmc/core/slot-gpio.c
index 8f5dc08d6598..979671053436 100644
--- a/drivers/mmc/core/cd-gpio.c
+++ b/drivers/mmc/core/slot-gpio.c
@@ -12,72 +12,72 @@
12#include <linux/gpio.h> 12#include <linux/gpio.h>
13#include <linux/interrupt.h> 13#include <linux/interrupt.h>
14#include <linux/jiffies.h> 14#include <linux/jiffies.h>
15#include <linux/mmc/cd-gpio.h>
16#include <linux/mmc/host.h> 15#include <linux/mmc/host.h>
16#include <linux/mmc/slot-gpio.h>
17#include <linux/module.h> 17#include <linux/module.h>
18#include <linux/slab.h> 18#include <linux/slab.h>
19 19
20struct mmc_cd_gpio { 20struct mmc_gpio {
21 unsigned int gpio; 21 unsigned int cd_gpio;
22 char label[0]; 22 char cd_label[0];
23}; 23};
24 24
25static irqreturn_t mmc_cd_gpio_irqt(int irq, void *dev_id) 25static irqreturn_t mmc_gpio_cd_irqt(int irq, void *dev_id)
26{ 26{
27 /* Schedule a card detection after a debounce timeout */ 27 /* Schedule a card detection after a debounce timeout */
28 mmc_detect_change(dev_id, msecs_to_jiffies(100)); 28 mmc_detect_change(dev_id, msecs_to_jiffies(100));
29 return IRQ_HANDLED; 29 return IRQ_HANDLED;
30} 30}
31 31
32int mmc_cd_gpio_request(struct mmc_host *host, unsigned int gpio) 32int mmc_gpio_request_cd(struct mmc_host *host, unsigned int gpio)
33{ 33{
34 size_t len = strlen(dev_name(host->parent)) + 4; 34 size_t len = strlen(dev_name(host->parent)) + 4;
35 struct mmc_cd_gpio *cd; 35 struct mmc_gpio *ctx;
36 int irq = gpio_to_irq(gpio); 36 int irq = gpio_to_irq(gpio);
37 int ret; 37 int ret;
38 38
39 if (irq < 0) 39 if (irq < 0)
40 return irq; 40 return irq;
41 41
42 cd = kmalloc(sizeof(*cd) + len, GFP_KERNEL); 42 ctx = kmalloc(sizeof(*ctx) + len, GFP_KERNEL);
43 if (!cd) 43 if (!ctx)
44 return -ENOMEM; 44 return -ENOMEM;
45 45
46 snprintf(cd->label, len, "%s cd", dev_name(host->parent)); 46 snprintf(ctx->cd_label, len, "%s cd", dev_name(host->parent));
47 47
48 ret = gpio_request_one(gpio, GPIOF_DIR_IN, cd->label); 48 ret = gpio_request_one(gpio, GPIOF_DIR_IN, ctx->cd_label);
49 if (ret < 0) 49 if (ret < 0)
50 goto egpioreq; 50 goto egpioreq;
51 51
52 ret = request_threaded_irq(irq, NULL, mmc_cd_gpio_irqt, 52 ret = request_threaded_irq(irq, NULL, mmc_gpio_cd_irqt,
53 IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING | 53 IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
54 IRQF_ONESHOT, cd->label, host); 54 ctx->cd_label, host);
55 if (ret < 0) 55 if (ret < 0)
56 goto eirqreq; 56 goto eirqreq;
57 57
58 cd->gpio = gpio; 58 ctx->cd_gpio = gpio;
59 host->hotplug.irq = irq; 59 host->hotplug.irq = irq;
60 host->hotplug.handler_priv = cd; 60 host->hotplug.handler_priv = ctx;
61 61
62 return 0; 62 return 0;
63 63
64eirqreq: 64eirqreq:
65 gpio_free(gpio); 65 gpio_free(gpio);
66egpioreq: 66egpioreq:
67 kfree(cd); 67 kfree(ctx);
68 return ret; 68 return ret;
69} 69}
70EXPORT_SYMBOL(mmc_cd_gpio_request); 70EXPORT_SYMBOL(mmc_gpio_request_cd);
71 71
72void mmc_cd_gpio_free(struct mmc_host *host) 72void mmc_gpio_free_cd(struct mmc_host *host)
73{ 73{
74 struct mmc_cd_gpio *cd = host->hotplug.handler_priv; 74 struct mmc_gpio *ctx = host->hotplug.handler_priv;
75 75
76 if (!cd) 76 if (!ctx)
77 return; 77 return;
78 78
79 free_irq(host->hotplug.irq, host); 79 free_irq(host->hotplug.irq, host);
80 gpio_free(cd->gpio); 80 gpio_free(ctx->cd_gpio);
81 kfree(cd); 81 kfree(ctx);
82} 82}
83EXPORT_SYMBOL(mmc_cd_gpio_free); 83EXPORT_SYMBOL(mmc_gpio_free_cd);
diff --git a/drivers/mmc/host/tmio_mmc_pio.c b/drivers/mmc/host/tmio_mmc_pio.c
index 0ad3917cafd1..7ffc489bed35 100644
--- a/drivers/mmc/host/tmio_mmc_pio.c
+++ b/drivers/mmc/host/tmio_mmc_pio.c
@@ -34,9 +34,9 @@
34#include <linux/io.h> 34#include <linux/io.h>
35#include <linux/irq.h> 35#include <linux/irq.h>
36#include <linux/mfd/tmio.h> 36#include <linux/mfd/tmio.h>
37#include <linux/mmc/cd-gpio.h>
38#include <linux/mmc/host.h> 37#include <linux/mmc/host.h>
39#include <linux/mmc/mmc.h> 38#include <linux/mmc/mmc.h>
39#include <linux/mmc/slot-gpio.h>
40#include <linux/mmc/tmio.h> 40#include <linux/mmc/tmio.h>
41#include <linux/module.h> 41#include <linux/module.h>
42#include <linux/pagemap.h> 42#include <linux/pagemap.h>
@@ -977,7 +977,7 @@ int __devinit tmio_mmc_host_probe(struct tmio_mmc_host **host,
977 tmio_mmc_enable_mmc_irqs(_host, irq_mask); 977 tmio_mmc_enable_mmc_irqs(_host, irq_mask);
978 978
979 if (pdata->flags & TMIO_MMC_USE_GPIO_CD) { 979 if (pdata->flags & TMIO_MMC_USE_GPIO_CD) {
980 ret = mmc_cd_gpio_request(mmc, pdata->cd_gpio); 980 ret = mmc_gpio_request_cd(mmc, pdata->cd_gpio);
981 if (ret < 0) { 981 if (ret < 0) {
982 tmio_mmc_host_remove(_host); 982 tmio_mmc_host_remove(_host);
983 return ret; 983 return ret;
@@ -1009,7 +1009,7 @@ void tmio_mmc_host_remove(struct tmio_mmc_host *host)
1009 * This means we can miss a card-eject, but this is anyway 1009 * This means we can miss a card-eject, but this is anyway
1010 * possible, because of delayed processing of hotplug events. 1010 * possible, because of delayed processing of hotplug events.
1011 */ 1011 */
1012 mmc_cd_gpio_free(mmc); 1012 mmc_gpio_free_cd(mmc);
1013 1013
1014 if (!host->native_hotplug) 1014 if (!host->native_hotplug)
1015 pm_runtime_get_sync(&pdev->dev); 1015 pm_runtime_get_sync(&pdev->dev);