Re: [PATCH v2 18/20] mmc: sdio: enable a default power off mode of the card

2010-07-25 Thread Ohad Ben-Cohen
On Thu, Jul 22, 2010 at 2:35 PM, Roger Quadros roger.quad...@nokia.com wrote:
 On 07/21/2010 08:33 PM, ext Ohad Ben-Cohen wrote:

 Add support for an SDIO device to stay powered off even without
 the presence of an SDIO function driver. A host should explicitly
 ask for it by means of MMC_CAP_DONT_POWER_CARD, and the SDIO
 function driver should know it needs to call sdio_claim_power
 before accessing the device.

 Signed-off-by: Ohad Ben-Coheno...@wizery.com

 Shouldn't this be the default behaviour? If there is no function driver for
 any of the functions of the card, then sdio core shold power off the card.

 I don't see a need for a special capability flag for this.

 in fact MMC_CAP_DONT_POWER_CARD does not seem like an mmc host's capability

Totally agree.

I didn't want to change the current behavior of the cards/funcs so I
looked for a way to explicitly power down only specific cards.

Alternatively we could power down all cards at the end
mmc_attach_sdio, and then power them up selectively in sdio_bus_probe,
just before calling probe. If the probe succeeds, the function driver
takes over. If the probe fails, we can power them down again.

Is that what you meant ?

This would work both if the sdio function driver is already loaded, or
will only be loaded at a later time. But I'm not too fond of the extra
power on/off cycles that it will introduce for each card..

Thanks,
Ohad.

 flag, it seems more like a request from the board to keep the card powered
 off.

 regards,
 -roger

--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v2 18/20] mmc: sdio: enable a default power off mode of the card

2010-07-25 Thread Nicolas Pitre
On Sun, 25 Jul 2010, Ohad Ben-Cohen wrote:

 On Thu, Jul 22, 2010 at 2:35 PM, Roger Quadros roger.quad...@nokia.com 
 wrote:
  On 07/21/2010 08:33 PM, ext Ohad Ben-Cohen wrote:
 
  Add support for an SDIO device to stay powered off even without
  the presence of an SDIO function driver. A host should explicitly
  ask for it by means of MMC_CAP_DONT_POWER_CARD, and the SDIO
  function driver should know it needs to call sdio_claim_power
  before accessing the device.
 
  Signed-off-by: Ohad Ben-Coheno...@wizery.com
 
  Shouldn't this be the default behaviour? If there is no function driver for
  any of the functions of the card, then sdio core shold power off the card.
 
  I don't see a need for a special capability flag for this.
 
  in fact MMC_CAP_DONT_POWER_CARD does not seem like an mmc host's capability
 
 Totally agree.
 
 I didn't want to change the current behavior of the cards/funcs so I
 looked for a way to explicitly power down only specific cards.
 
 Alternatively we could power down all cards at the end
 mmc_attach_sdio, and then power them up selectively in sdio_bus_probe,
 just before calling probe. If the probe succeeds, the function driver
 takes over. If the probe fails, we can power them down again.

Exactly!

 Is that what you meant ?
 
 This would work both if the sdio function driver is already loaded, or
 will only be loaded at a later time. But I'm not too fond of the extra
 power on/off cycles that it will introduce for each card..

This is still way better than introducing knowledge about specific cards 
in the host drivers.


Nicolas
--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v2 18/20] mmc: sdio: enable a default power off mode of the card

2010-07-25 Thread Ohad Ben-Cohen
On Sun, Jul 25, 2010 at 4:56 PM, Nicolas Pitre n...@fluxnic.net wrote:
 On Sun, 25 Jul 2010, Ohad Ben-Cohen wrote:

 On Thu, Jul 22, 2010 at 2:35 PM, Roger Quadros roger.quad...@nokia.com 
 wrote:
  On 07/21/2010 08:33 PM, ext Ohad Ben-Cohen wrote:
 
  Add support for an SDIO device to stay powered off even without
  the presence of an SDIO function driver. A host should explicitly
  ask for it by means of MMC_CAP_DONT_POWER_CARD, and the SDIO
  function driver should know it needs to call sdio_claim_power
  before accessing the device.
 
  Signed-off-by: Ohad Ben-Coheno...@wizery.com
 
  Shouldn't this be the default behaviour? If there is no function driver for
  any of the functions of the card, then sdio core shold power off the card.
 
  I don't see a need for a special capability flag for this.
 
  in fact MMC_CAP_DONT_POWER_CARD does not seem like an mmc host's capability

 Totally agree.

 I didn't want to change the current behavior of the cards/funcs so I
 looked for a way to explicitly power down only specific cards.

 Alternatively we could power down all cards at the end
 mmc_attach_sdio, and then power them up selectively in sdio_bus_probe,
 just before calling probe. If the probe succeeds, the function driver
 takes over. If the probe fails, we can power them down again.

 Exactly!

Ok, v3 is on the way :)

(featuring no special host CAP, fix locking issues, and power down
unclaimed cards also on resume)
--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v2 18/20] mmc: sdio: enable a default power off mode of the card

2010-07-22 Thread Roger Quadros

On 07/21/2010 08:33 PM, ext Ohad Ben-Cohen wrote:

Add support for an SDIO device to stay powered off even without
the presence of an SDIO function driver. A host should explicitly
ask for it by means of MMC_CAP_DONT_POWER_CARD, and the SDIO
function driver should know it needs to call sdio_claim_power
before accessing the device.

Signed-off-by: Ohad Ben-Coheno...@wizery.com


Shouldn't this be the default behaviour? If there is no function driver for any 
of the functions of the card, then sdio core shold power off the card.


I don't see a need for a special capability flag for this.

in fact MMC_CAP_DONT_POWER_CARD does not seem like an mmc host's capability 
flag, it seems more like a request from the board to keep the card powered off.


regards,
-roger
--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 18/20] mmc: sdio: enable a default power off mode of the card

2010-07-21 Thread Ohad Ben-Cohen
Add support for an SDIO device to stay powered off even without
the presence of an SDIO function driver. A host should explicitly
ask for it by means of MMC_CAP_DONT_POWER_CARD, and the SDIO
function driver should know it needs to call sdio_claim_power
before accessing the device.

Signed-off-by: Ohad Ben-Cohen o...@wizery.com
---
 drivers/mmc/core/sdio.c  |   15 +--
 include/linux/mmc/host.h |1 +
 2 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/drivers/mmc/core/sdio.c b/drivers/mmc/core/sdio.c
index 5c0fbfa..164353f 100644
--- a/drivers/mmc/core/sdio.c
+++ b/drivers/mmc/core/sdio.c
@@ -80,8 +80,9 @@ static int sdio_init_func(struct mmc_card *card, unsigned int 
fn)
return ret;
 
/* For each SDIO function initialized, increase the power claim
-* reference count of the card */
-   atomic_inc(card-power_claims);
+* reference count of the card, unless explicitly requested not to */
+   if (!(card-host-caps  MMC_CAP_DONT_POWER_CARD))
+   atomic_inc(card-power_claims);
 
return 0;
 
@@ -607,6 +608,16 @@ int mmc_attach_sdio(struct mmc_host *host, u32 ocr)
mmc_release_host(host);
 
/*
+* If power is not required for this card, power it off.
+* The sdio function will need to call sdio_claim_power.
+*/
+   if (!atomic_read(card-power_claims)) {
+   pr_info(%s: power is not claimed, releasing\n,
+   mmc_hostname(host));
+   mmc_release_power(host);
+   }
+
+   /*
 * First add the card to the driver model...
 */
err = mmc_add_card(host-card);
diff --git a/include/linux/mmc/host.h b/include/linux/mmc/host.h
index 3675d58..756cf38 100644
--- a/include/linux/mmc/host.h
+++ b/include/linux/mmc/host.h
@@ -155,6 +155,7 @@ struct mmc_host {
 #define MMC_CAP_DISABLE(1  7)/* Can the host be 
disabled */
 #define MMC_CAP_NONREMOVABLE   (1  8)/* Nonremovable e.g. eMMC */
 #define MMC_CAP_WAIT_WHILE_BUSY(1  9)/* Waits while card is 
busy */
+#define MMC_CAP_DONT_POWER_CARD(1  10)   /* Keep the card 
powered off */
 
mmc_pm_flag_t   pm_caps;/* supported pm features */
 
-- 
1.7.0.4

--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html