Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Esben Haabendal and committed by
Grant Likely
290293ed adef658d

+32 -3
+8 -1
Documentation/powerpc/dts-bindings/mmc-spi-slot.txt
··· 7 7 - voltage-ranges : two cells are required, first cell specifies minimum 8 8 slot voltage (mV), second cell specifies maximum slot voltage (mV). 9 9 Several ranges could be specified. 10 - - gpios : (optional) may specify GPIOs in this order: Card-Detect GPIO, 10 + 11 + Optional properties: 12 + - gpios : may specify GPIOs in this order: Card-Detect GPIO, 11 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 13 18 Example: 14 19 ··· 25 20 &qe_pio_d 15 0>; 26 21 voltage-ranges = <3300 3300>; 27 22 spi-max-frequency = <50000000>; 23 + interrupts = <42>; 24 + interrupt-parent = <&PIC>; 28 25 };
+24 -2
drivers/mmc/host/of_mmc_spi.c
··· 34 34 struct of_mmc_spi { 35 35 int gpios[NUM_GPIOS]; 36 36 bool alow_gpios[NUM_GPIOS]; 37 + int detect_irq; 37 38 struct mmc_spi_platform_data pdata; 38 39 }; 39 40 ··· 60 59 static int of_mmc_spi_get_ro(struct device *dev) 61 60 { 62 61 return of_mmc_spi_read_gpio(dev, WP_GPIO); 62 + } 63 + 64 + static int of_mmc_spi_init(struct device *dev, 65 + irqreturn_t (*irqhandler)(int, void *), void *mmc) 66 + { 67 + struct of_mmc_spi *oms = to_of_mmc_spi(dev); 68 + 69 + return request_threaded_irq(oms->detect_irq, NULL, irqhandler, 0, 70 + dev_name(dev), mmc); 71 + } 72 + 73 + static void of_mmc_spi_exit(struct device *dev, void *mmc) 74 + { 75 + struct of_mmc_spi *oms = to_of_mmc_spi(dev); 76 + 77 + free_irq(oms->detect_irq, mmc); 63 78 } 64 79 65 80 struct mmc_spi_platform_data *mmc_spi_get_pdata(struct spi_device *spi) ··· 138 121 if (gpio_is_valid(oms->gpios[WP_GPIO])) 139 122 oms->pdata.get_ro = of_mmc_spi_get_ro; 140 123 141 - /* We don't support interrupts yet, let's poll. */ 142 - oms->pdata.caps |= MMC_CAP_NEEDS_POLL; 124 + oms->detect_irq = irq_of_parse_and_map(np, 0); 125 + if (oms->detect_irq != NO_IRQ) { 126 + oms->pdata.init = of_mmc_spi_init; 127 + oms->pdata.exit = of_mmc_spi_exit; 128 + } else { 129 + oms->pdata.caps |= MMC_CAP_NEEDS_POLL; 130 + } 143 131 144 132 dev->platform_data = &oms->pdata; 145 133 return dev->platform_data;