linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: adrian.hunter@nokia.com (Adrian Hunter)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH V2 16/16] mmc: omap_hsmmc: add a hardware reset before initialization
Date: Fri,  6 May 2011 12:14:15 +0300	[thread overview]
Message-ID: <1304673255-31634-17-git-send-email-adrian.hunter@nokia.com> (raw)
In-Reply-To: <1304673255-31634-1-git-send-email-adrian.hunter@nokia.com>

After a warm restart, an eMMC which cannot be powered off is
in an unknown state, so reset it to be sure it will initialize.

Signed-off-by: Adrian Hunter <adrian.hunter@nokia.com>
---
 drivers/mmc/host/omap_hsmmc.c |   38 +++++++++++++++++++++++++++++++++++++-
 1 files changed, 37 insertions(+), 1 deletions(-)

diff --git a/drivers/mmc/host/omap_hsmmc.c b/drivers/mmc/host/omap_hsmmc.c
index e1c9017..70b8ef8 100644
--- a/drivers/mmc/host/omap_hsmmc.c
+++ b/drivers/mmc/host/omap_hsmmc.c
@@ -530,10 +530,25 @@ static int omap_hsmmc_gpio_init(struct omap_mmc_platform_data *pdata)
 	} else
 		pdata->slots[0].gpio_wp = -EINVAL;
 
+	if (gpio_is_valid(pdata->slots[0].gpio_hw_reset)) {
+		ret = gpio_request(pdata->slots[0].gpio_hw_reset,
+				   "mmc_hw_reset");
+		if (ret)
+			goto err_free_wp;
+		ret = gpio_direction_output(pdata->slots[0].gpio_hw_reset, 1);
+		if (ret)
+			goto err_free_hw_reset;
+	} else
+		pdata->slots[0].gpio_hw_reset = -EINVAL;
+
 	return 0;
 
+
+err_free_hw_reset:
+	gpio_free(pdata->slots[0].gpio_hw_reset);
 err_free_wp:
-	gpio_free(pdata->slots[0].gpio_wp);
+	if (gpio_is_valid(pdata->slots[0].gpio_wp))
+		gpio_free(pdata->slots[0].gpio_wp);
 err_free_cd:
 	if (gpio_is_valid(pdata->slots[0].switch_pin))
 err_free_sp:
@@ -543,6 +558,8 @@ err_free_sp:
 
 static void omap_hsmmc_gpio_free(struct omap_mmc_platform_data *pdata)
 {
+	if (gpio_is_valid(pdata->slots[0].gpio_hw_reset))
+		gpio_free(pdata->slots[0].gpio_hw_reset);
 	if (gpio_is_valid(pdata->slots[0].gpio_wp))
 		gpio_free(pdata->slots[0].gpio_wp);
 	if (gpio_is_valid(pdata->slots[0].switch_pin))
@@ -803,6 +820,18 @@ static void omap_hsmmc_context_save(struct omap_hsmmc_host *host)
 
 #endif
 
+static void omap_hsmmc_do_hw_reset(struct omap_hsmmc_host *host)
+{
+	if (!gpio_is_valid(mmc_slot(host).gpio_hw_reset))
+		return;
+
+	gpio_set_value_cansleep(mmc_slot(host).gpio_hw_reset, 0);
+	udelay(9);
+	gpio_set_value_cansleep(mmc_slot(host).gpio_hw_reset, 1);
+	usleep_range(1000, 2000);
+	printk(KERN_INFO "%s: hardware reset done\n", mmc_hostname(host->mmc));
+}
+
 /*
  * Send init stream sequence to card
  * before sending IDLE command
@@ -815,6 +844,13 @@ static void send_init_stream(struct omap_hsmmc_host *host)
 	if (host->protect_card)
 		return;
 
+	/*
+	 * After a warm restart, an eMMC which cannot be powered off is in an
+	 * unknown state so reset it to be sure it will initialize.
+	 */
+	if (mmc_slot(host).no_off)
+		omap_hsmmc_do_hw_reset(host);
+
 	disable_irq(host->irq);
 
 	OMAP_HSMMC_WRITE(host->base, IE, INT_EN_MASK);
-- 
1.7.0.4

  parent reply	other threads:[~2011-05-06  9:14 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-06  9:13 [PATCH V2 00/16] omap_hsmmc patches Adrian Hunter
2011-05-06  9:14 ` [PATCH V2 01/16] mmc: omap_hsmmc: fix missing mmc_release_host() in no_off case Adrian Hunter
2011-05-06  9:14 ` [PATCH V2 02/16] mmc: omap_hsmmc: correct debug report error status mnemonics Adrian Hunter
2011-05-06  9:14 ` [PATCH V2 03/16] mmc: omap_hsmmc: move hardcoded frequency constants to definition block Adrian Hunter
2011-05-06  9:14 ` [PATCH V2 04/16] mmc: omap_hsmmc: reduce a bit the error handlers in probe() Adrian Hunter
2011-05-06 11:34   ` Varadarajan, Charulatha
2011-05-06 11:38     ` Andy Shevchenko
2011-05-06  9:14 ` [PATCH V2 05/16] mmc: omap_hsmmc: split duplicate code to calc_divisor() function Adrian Hunter
2011-05-06  9:14 ` [PATCH V2 06/16] mmc: omap_hsmmc: introduce start_clock and re-use stop_clock Adrian Hunter
2011-05-06  9:14 ` [PATCH V2 07/16] mmc: omap_hsmmc: fix few bugs when set the clock divisor Adrian Hunter
2011-05-06  9:14 ` [PATCH V2 08/16] mmc: omap_hsmmc: split same pieces of code to separate functions Adrian Hunter
2011-05-06  9:14 ` [PATCH V2 09/16] OMAP: hsmmc: Do not mux the slot if non default muxing is already done Adrian Hunter
2011-05-06  9:14 ` [PATCH V2 10/16] OMAP: board-rm680: set MMC nomux flag Adrian Hunter
2011-05-06  9:14 ` [PATCH V2 11/16] mmc: omap_hsmmc: ensure pbias configuration is always done Adrian Hunter
2011-09-29 13:40   ` T Krishnamoorthy, Balaji
2011-10-14 14:01     ` Chris Ball
2011-05-06  9:14 ` [PATCH V2 12/16] mmc: omap_hsmmc: fix oops in omap_hsmmc_dma_cb Adrian Hunter
2011-05-06  9:14 ` [PATCH V2 13/16] OMAP: hsmmc: implement clock switcher Adrian Hunter
2011-05-12 10:37   ` Tony Lindgren
2011-05-06  9:14 ` [PATCH V2 14/16] mmc: omap_hsmmc: adjust host controller clock in regard to current OPP Adrian Hunter
2011-05-06  9:14 ` [PATCH V2 15/16] OMAP: hsmmc: add platform data for eMMC hardware reset gpio Adrian Hunter
2011-05-12 10:38   ` Tony Lindgren
2011-05-06  9:14 ` Adrian Hunter [this message]
2011-05-06 13:26   ` [PATCH V2 16/16] mmc: omap_hsmmc: add a hardware reset before initialization Varadarajan, Charulatha
2011-07-13 10:48 ` [PATCH V2 00/16] omap_hsmmc patches Grazvydas Ignotas
2011-07-13 15:36   ` Chris Ball
2011-07-15  9:32     ` Grazvydas Ignotas
2011-09-02 10:53       ` Tony Lindgren

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=1304673255-31634-17-git-send-email-adrian.hunter@nokia.com \
    --to=adrian.hunter@nokia.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    /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;
as well as URLs for NNTP newsgroup(s).