diff options
author | Esben Haabendal <eha@doredevelopment.dk> | 2011-03-07 22:45:28 -0500 |
---|---|---|
committer | Grant Likely <grant.likely@secretlab.ca> | 2011-03-07 22:45:28 -0500 |
commit | 290293eda2c6dd368476d71433bdef07c39a6829 (patch) | |
tree | 3bc7815356d324774f85526ea18586e37146bb38 /drivers | |
parent | adef658ddf71e709eb1bdc181b86c62b933b967b (diff) |
of_mmc_spi: add card detect irq support
Signed-off-by: Esben Haabendal <eha@doredevelopment.dk>
Acked-by: Anton Vorontsov <cbouatmailru@gmail.com>
Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/mmc/host/of_mmc_spi.c | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/drivers/mmc/host/of_mmc_spi.c b/drivers/mmc/host/of_mmc_spi.c index 1247e5de9faa..5530def54e5b 100644 --- a/drivers/mmc/host/of_mmc_spi.c +++ b/drivers/mmc/host/of_mmc_spi.c | |||
@@ -34,6 +34,7 @@ enum { | |||
34 | struct of_mmc_spi { | 34 | struct of_mmc_spi { |
35 | int gpios[NUM_GPIOS]; | 35 | int gpios[NUM_GPIOS]; |
36 | bool alow_gpios[NUM_GPIOS]; | 36 | bool alow_gpios[NUM_GPIOS]; |
37 | int detect_irq; | ||
37 | struct mmc_spi_platform_data pdata; | 38 | struct mmc_spi_platform_data pdata; |
38 | }; | 39 | }; |
39 | 40 | ||
@@ -61,6 +62,22 @@ static int of_mmc_spi_get_ro(struct device *dev) | |||
61 | return of_mmc_spi_read_gpio(dev, WP_GPIO); | 62 | return of_mmc_spi_read_gpio(dev, WP_GPIO); |
62 | } | 63 | } |
63 | 64 | ||
65 | static int of_mmc_spi_init(struct device *dev, | ||
66 | irqreturn_t (*irqhandler)(int, void *), void *mmc) | ||
67 | { | ||
68 | struct of_mmc_spi *oms = to_of_mmc_spi(dev); | ||
69 | |||
70 | return request_threaded_irq(oms->detect_irq, NULL, irqhandler, 0, | ||
71 | dev_name(dev), mmc); | ||
72 | } | ||
73 | |||
74 | static void of_mmc_spi_exit(struct device *dev, void *mmc) | ||
75 | { | ||
76 | struct of_mmc_spi *oms = to_of_mmc_spi(dev); | ||
77 | |||
78 | free_irq(oms->detect_irq, mmc); | ||
79 | } | ||
80 | |||
64 | struct mmc_spi_platform_data *mmc_spi_get_pdata(struct spi_device *spi) | 81 | struct mmc_spi_platform_data *mmc_spi_get_pdata(struct spi_device *spi) |
65 | { | 82 | { |
66 | struct device *dev = &spi->dev; | 83 | struct device *dev = &spi->dev; |
@@ -121,8 +138,13 @@ struct mmc_spi_platform_data *mmc_spi_get_pdata(struct spi_device *spi) | |||
121 | if (gpio_is_valid(oms->gpios[WP_GPIO])) | 138 | if (gpio_is_valid(oms->gpios[WP_GPIO])) |
122 | oms->pdata.get_ro = of_mmc_spi_get_ro; | 139 | oms->pdata.get_ro = of_mmc_spi_get_ro; |
123 | 140 | ||
124 | /* We don't support interrupts yet, let's poll. */ | 141 | oms->detect_irq = irq_of_parse_and_map(np, 0); |
125 | oms->pdata.caps |= MMC_CAP_NEEDS_POLL; | 142 | if (oms->detect_irq != NO_IRQ) { |
143 | oms->pdata.init = of_mmc_spi_init; | ||
144 | oms->pdata.exit = of_mmc_spi_exit; | ||
145 | } else { | ||
146 | oms->pdata.caps |= MMC_CAP_NEEDS_POLL; | ||
147 | } | ||
126 | 148 | ||
127 | dev->platform_data = &oms->pdata; | 149 | dev->platform_data = &oms->pdata; |
128 | return dev->platform_data; | 150 | return dev->platform_data; |