]> git.proxmox.com Git - mirror_ubuntu-eoan-kernel.git/commitdiff
sdio: add CD disable support
authorOhad Ben-Cohen <ohad@wizery.com>
Tue, 22 Sep 2009 23:45:07 +0000 (16:45 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Wed, 23 Sep 2009 14:39:36 +0000 (07:39 -0700)
Add support to disconnect the pull-up resistor on CD/DAT[3] (pin 1)
of the card. This may be desired on certain setups of boards,
controllers and embedded sdio devices which do not need the card's
pull-up. As a result, card detection is disabled and power is saved.

[akpm@linux-foundation.org: simplify sdio_disable_cd() a bit]
Signed-off-by: Ohad Ben-Cohen <ohad@wizery.com>
Acked-by: Matt Fleming <matt@console-pimps.org>
Cc: Ian Molton <ian@mnementh.co.uk>
Cc: "Roberto A. Foglietta" <roberto.foglietta@gmail.com>
Cc: Philip Langdale <philipl@overt.org>
Cc: Pierre Ossman <pierre@ossman.eu>
Cc: David Vrabel <david.vrabel@csr.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
drivers/mmc/core/sdio.c
include/linux/mmc/card.h

index 6f221dc029ad82f75c78ffbd9bd2978ecb2e03c3..2d24a123f0b0c6c809b4e27f3aa7e2b10c2c8e7b 100644 (file)
@@ -164,6 +164,29 @@ static int sdio_enable_wide(struct mmc_card *card)
        return 0;
 }
 
+/*
+ * If desired, disconnect the pull-up resistor on CD/DAT[3] (pin 1)
+ * of the card. This may be required on certain setups of boards,
+ * controllers and embedded sdio device which do not need the card's
+ * pull-up. As a result, card detection is disabled and power is saved.
+ */
+static int sdio_disable_cd(struct mmc_card *card)
+{
+       int ret;
+       u8 ctrl;
+
+       if (!card->cccr.disable_cd)
+               return 0;
+
+       ret = mmc_io_rw_direct(card, 0, 0, SDIO_CCCR_IF, 0, &ctrl);
+       if (ret)
+               return ret;
+
+       ctrl |= SDIO_BUS_CD_DISABLE;
+
+       return mmc_io_rw_direct(card, 1, 0, SDIO_CCCR_IF, ctrl, NULL);
+}
+
 /*
  * Test if the card supports high-speed mode and, if so, switch to it.
  */
@@ -384,6 +407,13 @@ int mmc_attach_sdio(struct mmc_host *host, u32 ocr)
        if (err)
                goto remove;
 
+       /*
+        * If needed, disconnect card detection pull-up resistor.
+        */
+       err = sdio_disable_cd(card);
+       if (err)
+               goto remove;
+
        /*
         * Initialize (but don't add) all present functions.
         */
index 58f59174c64b83511ccfbbc212549f63b90b3286..00db39cceadc9c07c23587957f9874a874de40cb 100644 (file)
@@ -64,7 +64,8 @@ struct sdio_cccr {
                                low_speed:1,
                                wide_bus:1,
                                high_power:1,
-                               high_speed:1;
+                               high_speed:1,
+                               disable_cd:1;
 };
 
 struct sdio_cis {