aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEsben Haabendal <eha@doredevelopment.dk>2011-03-07 22:45:28 -0500
committerGrant Likely <grant.likely@secretlab.ca>2011-03-07 22:45:28 -0500
commit290293eda2c6dd368476d71433bdef07c39a6829 (patch)
tree3bc7815356d324774f85526ea18586e37146bb38
parentadef658ddf71e709eb1bdc181b86c62b933b967b (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>
-rw-r--r--Documentation/powerpc/dts-bindings/mmc-spi-slot.txt9
-rw-r--r--drivers/mmc/host/of_mmc_spi.c26
2 files changed, 32 insertions, 3 deletions
diff --git a/Documentation/powerpc/dts-bindings/mmc-spi-slot.txt b/Documentation/powerpc/dts-bindings/mmc-spi-slot.txt
index c39ac2891951..89a0084df2f7 100644
--- a/Documentation/powerpc/dts-bindings/mmc-spi-slot.txt
+++ b/Documentation/powerpc/dts-bindings/mmc-spi-slot.txt
@@ -7,8 +7,13 @@ Required properties:
7- voltage-ranges : two cells are required, first cell specifies minimum 7- voltage-ranges : two cells are required, first cell specifies minimum
8 slot voltage (mV), second cell specifies maximum slot voltage (mV). 8 slot voltage (mV), second cell specifies maximum slot voltage (mV).
9 Several ranges could be specified. 9 Several ranges could be specified.
10- gpios : (optional) may specify GPIOs in this order: Card-Detect GPIO, 10
11Optional properties:
12- gpios : may specify GPIOs in this order: Card-Detect GPIO,
11 Write-Protect GPIO. 13 Write-Protect GPIO.
14- interrupts : the interrupt of a card detect interrupt.
15- interrupt-parent : the phandle for the interrupt controller that
16 services interrupts for this device.
12 17
13Example: 18Example:
14 19
@@ -20,4 +25,6 @@ Example:
20 &qe_pio_d 15 0>; 25 &qe_pio_d 15 0>;
21 voltage-ranges = <3300 3300>; 26 voltage-ranges = <3300 3300>;
22 spi-max-frequency = <50000000>; 27 spi-max-frequency = <50000000>;
28 interrupts = <42>;
29 interrupt-parent = <&PIC>;
23 }; 30 };
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 {
34struct of_mmc_spi { 34struct 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
65static 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
74static 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
64struct mmc_spi_platform_data *mmc_spi_get_pdata(struct spi_device *spi) 81struct 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;