linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] of_mmc_spi: add card detect irq support
@ 2010-08-30 12:04 Esben Haabendal
  2010-08-30 13:29 ` Anton Vorontsov
  0 siblings, 1 reply; 10+ messages in thread
From: Esben Haabendal @ 2010-08-30 12:04 UTC (permalink / raw)
  To: linuxppc-dev

Signed-off-by: Esben Haabendal <eha@doredevelopment.dk>
---
 drivers/mmc/host/of_mmc_spi.c |   25 +++++++++++++++++++++++--
 1 files changed, 23 insertions(+), 2 deletions(-)

diff --git a/drivers/mmc/host/of_mmc_spi.c b/drivers/mmc/host/of_mmc_spi.c
index 1247e5d..e872b61 100644
--- a/drivers/mmc/host/of_mmc_spi.c
+++ b/drivers/mmc/host/of_mmc_spi.c
@@ -34,6 +34,7 @@ enum {
 struct of_mmc_spi {
        int gpios[NUM_GPIOS];
        bool alow_gpios[NUM_GPIOS];
+       int detect_irq;
        struct mmc_spi_platform_data pdata;
 };

@@ -61,6 +62,20 @@ static int of_mmc_spi_get_ro(struct device *dev)
        return of_mmc_spi_read_gpio(dev, WP_GPIO);
 }

+static int of_mmc_spi_init(struct device *dev,
+                          irqreturn_t (*irqhandler)(int, void *), void *mm=
c)
+{
+       struct of_mmc_spi *oms =3D to_of_mmc_spi(dev);
+       return request_threaded_irq(
+               oms->detect_irq, NULL, irqhandler, 0, dev_name(dev), mmc);
+}
+
+static void of_mmc_spi_exit(struct device *dev, void *mmc)
+{
+       struct of_mmc_spi *oms =3D to_of_mmc_spi(dev);
+       free_irq(oms->detect_irq, mmc);
+}
+
 struct mmc_spi_platform_data *mmc_spi_get_pdata(struct spi_device *spi)
 {
        struct device *dev =3D &spi->dev;
@@ -121,8 +136,14 @@ struct mmc_spi_platform_data
*mmc_spi_get_pdata(struct spi_device *spi)
        if (gpio_is_valid(oms->gpios[WP_GPIO]))
                oms->pdata.get_ro =3D of_mmc_spi_get_ro;

-       /* We don't support interrupts yet, let's poll. */
-       oms->pdata.caps |=3D MMC_CAP_NEEDS_POLL;
+       oms->detect_irq =3D irq_of_parse_and_map(np, 0);
+       if (oms->detect_irq !=3D NO_IRQ) {
+               oms->pdata.init =3D of_mmc_spi_init;
+               oms->pdata.exit =3D of_mmc_spi_exit;
+       }
+       else {
+               oms->pdata.caps |=3D MMC_CAP_NEEDS_POLL;
+       }

        dev->platform_data =3D &oms->pdata;
        return dev->platform_data;
--=20
1.7.1.1

--=20
Esben Haabendal, Senior Software Consultant
Dor=E9Development ApS, Ved Stranden 1, 9560 Hadsund, DK-Denmark
Phone: +45 51 92 53 93, E-mail: eha@doredevelopment.dk
WWW: http://www.doredevelopment.dk

^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2011-03-08  3:52 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-08-30 12:04 [PATCH] of_mmc_spi: add card detect irq support Esben Haabendal
2010-08-30 13:29 ` Anton Vorontsov
2010-08-30 16:04   ` Esben Haabendal
2010-08-30 16:11     ` Anton Vorontsov
2010-08-30 16:38       ` David Brownell
2010-08-30 17:49         ` Grant Likely
2010-12-28 16:05           ` Anton Vorontsov
2011-03-08  3:52             ` Grant Likely
2010-08-30 17:46     ` Grant Likely
2010-08-31  6:14       ` Esben Haabendal

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).