public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Rob Emanuele <rob@emanuele.us>
To: nicolas.ferre@atmel.com
Cc: haavard.skinnemoen@atmel.com,
	linux-arm-kernel@lists.arm.linux.org.uk,
	linux-kernel@vger.kernel.org, Rob Emanuele <rob@emanuele.us>
Subject: [PATCH 5/6] atmel-mci: Power control option for each MMC Slot
Date: Tue, 16 Jun 2009 17:54:38 -0700	[thread overview]
Message-ID: <1245200079-6323-5-git-send-email-rob@emanuele.us> (raw)
In-Reply-To: <1245200079-6323-1-git-send-email-rob@emanuele.us>

Add support to the atmel-mci driver for a VCC pin in order to conserve power by removing power from an MMC Slot.

Signed-off-by: Rob Emanuele <rob@emanuele.us>
---
 drivers/mmc/host/atmel-mci.c |   33 ++++++++++++++++++++-------------
 include/linux/atmel-mci.h    |    2 ++
 2 files changed, 22 insertions(+), 13 deletions(-)

diff --git a/drivers/mmc/host/atmel-mci.c b/drivers/mmc/host/atmel-mci.c
index 601dae7..63cd5c7 100644
--- a/drivers/mmc/host/atmel-mci.c
+++ b/drivers/mmc/host/atmel-mci.c
@@ -214,6 +214,8 @@ struct atmel_mci_slot {
 	int			detect_pin;
 	int			wp_pin;
 	bool			detect_is_active_high;
+	int			vcc_pin;
+	bool			vcc_active_low;
 
 	struct timer_list	detect_timer;
 };
@@ -932,23 +934,19 @@ static void atmci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
 	}
 
 	switch (ios->power_mode) {
+	case MMC_POWER_OFF:
+		if (gpio_is_valid(slot->vcc_pin))
+			gpio_set_value(slot->vcc_pin, slot->vcc_active_low);
+		break;
 	case MMC_POWER_UP:
+		if (gpio_is_valid(slot->vcc_pin))
+			gpio_set_value(slot->vcc_pin, !slot->vcc_active_low);
 		set_bit(ATMCI_CARD_NEED_INIT, &slot->flags);
 		break;
-	default:
-		/*
-		 * TODO: None of the currently available AVR32-based
-		 * boards allow MMC power to be turned off. Implement
-		 * power control when this can be tested properly.
-		 *
-		 * We also need to hook this into the clock management
-		 * somehow so that newly inserted cards aren't
-		 * subjected to a fast clock before we have a chance
-		 * to figure out what the maximum rate is. Currently,
-		 * there's no way to avoid this, and there never will
-		 * be for boards that don't support power control.
-		 */
+	case MMC_POWER_ON:
 		break;
+	default:
+		WARN_ON(1);
 	}
 }
 
@@ -1507,6 +1505,8 @@ static int __init atmci_init_slot(struct atmel_mci *host,
 	slot->detect_pin = slot_data->detect_pin;
 	slot->wp_pin = slot_data->wp_pin;
 	slot->detect_is_active_high = slot_data->detect_is_active_high;
+	slot->vcc_pin = slot_data->vcc_pin;
+	slot->vcc_active_low = slot_data->vcc_active_low;
 	slot->sdc_reg = sdc_reg;
 
 	mmc->ops = &atmci_ops;
@@ -1544,6 +1544,13 @@ static int __init atmci_init_slot(struct atmel_mci *host,
 		}
 	}
 
+	if (gpio_is_valid(slot->vcc_pin)) {
+		if (gpio_request(slot->vcc_pin, "mmc_pow")) {
+			dev_dbg(&mmc->class_dev, "no power pin available\n");
+			slot->vcc_pin = -EBUSY;
+		}
+	}
+
 	host->slot[id] = slot;
 	mmc_add_host(mmc);
 
diff --git a/include/linux/atmel-mci.h b/include/linux/atmel-mci.h
index 57b1846..7c15a7c 100644
--- a/include/linux/atmel-mci.h
+++ b/include/linux/atmel-mci.h
@@ -26,6 +26,8 @@ struct mci_slot_pdata {
 	int			detect_pin;
 	int			wp_pin;
 	bool			detect_is_active_high;
+	int			vcc_pin;
+	unsigned		vcc_active_low:1;
 };
 
 /**
-- 
1.6.0.4


  parent reply	other threads:[~2009-06-17  0:56 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-06-17  0:54 [PATCH 1/6] atmel-mci: Unified Atmel MCI drivers (AVR32 & AT91) Rob Emanuele
2009-06-17  0:54 ` [PATCH 2/6] atmel-mci: Platform configuration to the the atmel-mci driver Rob Emanuele
2009-06-17 10:27   ` Nicolas Ferre
2009-06-18 19:58   ` Andrew Victor
2009-06-18 20:00     ` Andrew Victor
2009-06-17  0:54 ` [PATCH 3/6] atmel-mci: Optional controller reset before every command Rob Emanuele
2009-06-17  8:32   ` Marc Pignat
2009-06-17 18:27     ` Robert Emanuele
2009-06-17  0:54 ` [PATCH 4/6] atmel-mci: CLKDIV cap to restrict the MCI controller speed Rob Emanuele
2009-06-17  0:54 ` Rob Emanuele [this message]
2009-06-17  8:08   ` [PATCH 5/6] atmel-mci: Power control option for each MMC Slot Marc Pignat
2009-06-17  0:54 ` [PATCH 6/6] atmel-mci: Platform driver MMC slot power control Rob Emanuele
2009-06-17  1:23   ` Ryan Mallon
2009-06-17  9:56 ` [PATCH 1/6] atmel-mci: Unified Atmel MCI drivers (AVR32 & AT91) Nicolas Ferre
2009-06-17 10:08   ` Haavard Skinnemoen
2009-06-23 16:28     ` Nicolas Ferre
     [not found] ` <95818a17c2b96d3769f4e1d3de26208647111758.1245778411.git.nicolas.ferre@atmel.com>
2009-06-23 17:39   ` [PATCH 1/2] " Nicolas Ferre
2009-09-02  7:31     ` Haavard Skinnemoen
     [not found]   ` <f8889fb59887a970581697beb313363a6a065606.1245778411.git.nicolas.ferre@atmel.com>
2009-06-23 17:39     ` [PATCH 2/2] AT91: atmel-mci: Platform configuration to the the atmel-mci driver Nicolas Ferre
2009-06-23 21:36     ` Jean-Christophe PLAGNIOL-VILLARD
2009-06-26 19:26       ` Robert Emanuele

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1245200079-6323-5-git-send-email-rob@emanuele.us \
    --to=rob@emanuele.us \
    --cc=haavard.skinnemoen@atmel.com \
    --cc=linux-arm-kernel@lists.arm.linux.org.uk \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nicolas.ferre@atmel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox