From patchwork Fri May 6 09:14:15 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adrian Hunter X-Patchwork-Id: 761482 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter2.kernel.org (8.14.4/8.14.3) with ESMTP id p469HFvV007990 for ; Fri, 6 May 2011 09:18:18 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756016Ab1EFJSR (ORCPT ); Fri, 6 May 2011 05:18:17 -0400 Received: from smtp.nokia.com ([147.243.128.24]:41065 "EHLO mgw-da01.nokia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753711Ab1EFJSQ (ORCPT ); Fri, 6 May 2011 05:18:16 -0400 Received: from nokia.com (localhost [127.0.0.1]) by mgw-da01.nokia.com (Switch-3.4.4/Switch-3.4.3) with ESMTP id p469ESUQ017638; Fri, 6 May 2011 12:15:28 +0300 Received: from localhost.localdomain ([helruo-dhcp022207.ntc.nokia.com [172.21.22.207]]) by mgw-da01.nokia.com with RELAY id p469EHe8017428 ; Fri, 6 May 2011 12:15:04 +0300 From: Adrian Hunter To: Tony Lindgren Cc: Madhusudhan Chikkature , linux-omap Mailing List , linux-mmc Mailing List , linux-arm Mailing List , Adrian Hunter Subject: [PATCH V2 16/16] mmc: omap_hsmmc: add a hardware reset before initialization Date: Fri, 6 May 2011 12:14:15 +0300 Message-Id: <1304673255-31634-17-git-send-email-adrian.hunter@nokia.com> X-Mailer: git-send-email 1.7.0.4 In-Reply-To: <1304673255-31634-1-git-send-email-adrian.hunter@nokia.com> References: <1304673255-31634-1-git-send-email-adrian.hunter@nokia.com> X-Nokia-AV: Clean Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter2.kernel.org [140.211.167.43]); Fri, 06 May 2011 09:18:18 +0000 (UTC) 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 --- 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);