diff options
| author | Glenn Elliott <gelliott@cs.unc.edu> | 2012-03-04 19:47:13 -0500 |
|---|---|---|
| committer | Glenn Elliott <gelliott@cs.unc.edu> | 2012-03-04 19:47:13 -0500 |
| commit | c71c03bda1e86c9d5198c5d83f712e695c4f2a1e (patch) | |
| tree | ecb166cb3e2b7e2adb3b5e292245fefd23381ac8 /drivers/mmc/host/of_mmc_spi.c | |
| parent | ea53c912f8a86a8567697115b6a0d8152beee5c8 (diff) | |
| parent | 6a00f206debf8a5c8899055726ad127dbeeed098 (diff) | |
Merge branch 'mpi-master' into wip-k-fmlpwip-k-fmlp
Conflicts:
litmus/sched_cedf.c
Diffstat (limited to 'drivers/mmc/host/of_mmc_spi.c')
| -rw-r--r-- | drivers/mmc/host/of_mmc_spi.c | 33 |
1 files changed, 31 insertions, 2 deletions
diff --git a/drivers/mmc/host/of_mmc_spi.c b/drivers/mmc/host/of_mmc_spi.c index 1247e5de9faa..ab66f2454dc4 100644 --- a/drivers/mmc/host/of_mmc_spi.c +++ b/drivers/mmc/host/of_mmc_spi.c | |||
| @@ -15,14 +15,21 @@ | |||
| 15 | #include <linux/module.h> | 15 | #include <linux/module.h> |
| 16 | #include <linux/device.h> | 16 | #include <linux/device.h> |
| 17 | #include <linux/slab.h> | 17 | #include <linux/slab.h> |
| 18 | #include <linux/irq.h> | ||
| 18 | #include <linux/gpio.h> | 19 | #include <linux/gpio.h> |
| 19 | #include <linux/of.h> | 20 | #include <linux/of.h> |
| 20 | #include <linux/of_gpio.h> | 21 | #include <linux/of_gpio.h> |
| 22 | #include <linux/of_irq.h> | ||
| 21 | #include <linux/spi/spi.h> | 23 | #include <linux/spi/spi.h> |
| 22 | #include <linux/spi/mmc_spi.h> | 24 | #include <linux/spi/mmc_spi.h> |
| 23 | #include <linux/mmc/core.h> | 25 | #include <linux/mmc/core.h> |
| 24 | #include <linux/mmc/host.h> | 26 | #include <linux/mmc/host.h> |
| 25 | 27 | ||
| 28 | /* For archs that don't support NO_IRQ (such as mips), provide a dummy value */ | ||
| 29 | #ifndef NO_IRQ | ||
| 30 | #define NO_IRQ 0 | ||
| 31 | #endif | ||
| 32 | |||
| 26 | MODULE_LICENSE("GPL"); | 33 | MODULE_LICENSE("GPL"); |
| 27 | 34 | ||
| 28 | enum { | 35 | enum { |
| @@ -34,6 +41,7 @@ enum { | |||
| 34 | struct of_mmc_spi { | 41 | struct of_mmc_spi { |
| 35 | int gpios[NUM_GPIOS]; | 42 | int gpios[NUM_GPIOS]; |
| 36 | bool alow_gpios[NUM_GPIOS]; | 43 | bool alow_gpios[NUM_GPIOS]; |
| 44 | int detect_irq; | ||
| 37 | struct mmc_spi_platform_data pdata; | 45 | struct mmc_spi_platform_data pdata; |
| 38 | }; | 46 | }; |
| 39 | 47 | ||
| @@ -61,6 +69,22 @@ static int of_mmc_spi_get_ro(struct device *dev) | |||
| 61 | return of_mmc_spi_read_gpio(dev, WP_GPIO); | 69 | return of_mmc_spi_read_gpio(dev, WP_GPIO); |
| 62 | } | 70 | } |
| 63 | 71 | ||
| 72 | static int of_mmc_spi_init(struct device *dev, | ||
| 73 | irqreturn_t (*irqhandler)(int, void *), void *mmc) | ||
| 74 | { | ||
| 75 | struct of_mmc_spi *oms = to_of_mmc_spi(dev); | ||
| 76 | |||
| 77 | return request_threaded_irq(oms->detect_irq, NULL, irqhandler, 0, | ||
| 78 | dev_name(dev), mmc); | ||
| 79 | } | ||
| 80 | |||
| 81 | static void of_mmc_spi_exit(struct device *dev, void *mmc) | ||
| 82 | { | ||
| 83 | struct of_mmc_spi *oms = to_of_mmc_spi(dev); | ||
| 84 | |||
| 85 | free_irq(oms->detect_irq, mmc); | ||
| 86 | } | ||
| 87 | |||
| 64 | struct mmc_spi_platform_data *mmc_spi_get_pdata(struct spi_device *spi) | 88 | struct mmc_spi_platform_data *mmc_spi_get_pdata(struct spi_device *spi) |
| 65 | { | 89 | { |
| 66 | struct device *dev = &spi->dev; | 90 | struct device *dev = &spi->dev; |
| @@ -121,8 +145,13 @@ struct mmc_spi_platform_data *mmc_spi_get_pdata(struct spi_device *spi) | |||
| 121 | if (gpio_is_valid(oms->gpios[WP_GPIO])) | 145 | if (gpio_is_valid(oms->gpios[WP_GPIO])) |
| 122 | oms->pdata.get_ro = of_mmc_spi_get_ro; | 146 | oms->pdata.get_ro = of_mmc_spi_get_ro; |
| 123 | 147 | ||
| 124 | /* We don't support interrupts yet, let's poll. */ | 148 | oms->detect_irq = irq_of_parse_and_map(np, 0); |
| 125 | oms->pdata.caps |= MMC_CAP_NEEDS_POLL; | 149 | if (oms->detect_irq != NO_IRQ) { |
| 150 | oms->pdata.init = of_mmc_spi_init; | ||
| 151 | oms->pdata.exit = of_mmc_spi_exit; | ||
| 152 | } else { | ||
| 153 | oms->pdata.caps |= MMC_CAP_NEEDS_POLL; | ||
| 154 | } | ||
| 126 | 155 | ||
| 127 | dev->platform_data = &oms->pdata; | 156 | dev->platform_data = &oms->pdata; |
| 128 | return dev->platform_data; | 157 | return dev->platform_data; |
