diff options
Diffstat (limited to 'drivers/mmc')
-rw-r--r-- | drivers/mmc/host/mmc_spi.c | 4 | ||||
-rw-r--r-- | drivers/mmc/host/of_mmc_spi.c | 26 |
2 files changed, 24 insertions, 6 deletions
diff --git a/drivers/mmc/host/mmc_spi.c b/drivers/mmc/host/mmc_spi.c index fd877f633dd2..2f7fc0c5146f 100644 --- a/drivers/mmc/host/mmc_spi.c +++ b/drivers/mmc/host/mmc_spi.c | |||
@@ -1516,21 +1516,17 @@ static int __devexit mmc_spi_remove(struct spi_device *spi) | |||
1516 | return 0; | 1516 | return 0; |
1517 | } | 1517 | } |
1518 | 1518 | ||
1519 | #if defined(CONFIG_OF) | ||
1520 | static struct of_device_id mmc_spi_of_match_table[] __devinitdata = { | 1519 | static struct of_device_id mmc_spi_of_match_table[] __devinitdata = { |
1521 | { .compatible = "mmc-spi-slot", }, | 1520 | { .compatible = "mmc-spi-slot", }, |
1522 | {}, | 1521 | {}, |
1523 | }; | 1522 | }; |
1524 | #endif | ||
1525 | 1523 | ||
1526 | static struct spi_driver mmc_spi_driver = { | 1524 | static struct spi_driver mmc_spi_driver = { |
1527 | .driver = { | 1525 | .driver = { |
1528 | .name = "mmc_spi", | 1526 | .name = "mmc_spi", |
1529 | .bus = &spi_bus_type, | 1527 | .bus = &spi_bus_type, |
1530 | .owner = THIS_MODULE, | 1528 | .owner = THIS_MODULE, |
1531 | #if defined(CONFIG_OF) | ||
1532 | .of_match_table = mmc_spi_of_match_table, | 1529 | .of_match_table = mmc_spi_of_match_table, |
1533 | #endif | ||
1534 | }, | 1530 | }, |
1535 | .probe = mmc_spi_probe, | 1531 | .probe = mmc_spi_probe, |
1536 | .remove = __devexit_p(mmc_spi_remove), | 1532 | .remove = __devexit_p(mmc_spi_remove), |
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; |