From patchwork Tue Oct 30 05:28:27 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Seungwon Jeon X-Patchwork-Id: 1668341 Return-Path: X-Original-To: patchwork-linux-mmc@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id DBB8CDF2AB for ; Tue, 30 Oct 2012 05:28:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753742Ab2J3F2a (ORCPT ); Tue, 30 Oct 2012 01:28:30 -0400 Received: from mailout3.samsung.com ([203.254.224.33]:65124 "EHLO mailout3.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753736Ab2J3F23 (ORCPT ); Tue, 30 Oct 2012 01:28:29 -0400 Received: from epcpsbgm1.samsung.com (epcpsbgm1 [203.254.230.26]) by mailout3.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0MCO00AKHXUTQ8N0@mailout3.samsung.com> for linux-mmc@vger.kernel.org; Tue, 30 Oct 2012 14:28:28 +0900 (KST) X-AuditID: cbfee61a-b7fa66d0000004cf-30-508f657c7b3f Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id FA.98.01231.C756F805; Tue, 30 Oct 2012 14:28:28 +0900 (KST) Received: from DOTGIHJUN01 ([12.23.118.161]) by mmp2.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0MCO00MI8XVFJTC0@mmp2.samsung.com> for linux-mmc@vger.kernel.org; Tue, 30 Oct 2012 14:28:28 +0900 (KST) From: Seungwon Jeon To: linux-mmc@vger.kernel.org Cc: 'Chris Ball' , =?utf-8?Q?'Heiko_St=C3=BCbner'?= , 'Chander Kashyap' References: <004801cdad17$498d9140$dca8b3c0$%jun@samsung.com> <201210191010.48776.heiko@sntech.de> <87liepq8qo.fsf@octavius.laptop.org> <201210292337.35620.heiko@sntech.de> In-reply-to: Subject: [PATCH v2 1/2] mmc: sdhci-s3c: ensure non-transaction of bus before clk_disable Date: Tue, 30 Oct 2012 14:28:27 +0900 Message-id: <00af01cdb65f$64009300$2c01b900$%jun@samsung.com> MIME-version: 1.0 Content-type: text/plain; charset=utf-8 Content-transfer-encoding: 7bit X-Mailer: Microsoft Office Outlook 12.0 Thread-index: Ac22JgMPkQo3PX5PToiIfwakzap/IgAK/vjAAAITDcA= Content-language: ko X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrDLMWRmVeSWpSXmKPExsVy+t9jQd2a1P4Ag6+PeC2O/O9ndGD0+LxJ LoAxissmJTUnsyy1SN8ugSvj8MqrTAUTZCoa735ja2DskOhi5OSQEDCReP3zEDuELSZx4d56 ti5GLg4hgemMEit2XGKHcGYxSRy595gJpIpNQEvi75s3zCC2iICsxM8/F8A6mAU6GSVmvt4M 1bGBUWL9z7uMIFWcAjwS6/50gnUIC0RJ3J/6mw3EZhFQlWjp+MgCYvMK2EosvNnACmELSvyY fA8ozgE0VV1iypRckDCzgLzE5jVvmUHCEkDhR391QUwRASuJ+Q+TISpEJPa9eMc4gVFoFpI5 sxDmzEIyZxaSjgWMLKsYRVMLkguKk9JzDfWKE3OLS/PS9ZLzczcxgsP4mdQOxpUNFocYBTgY lXh4N6zpCxBiTSwrrsw9xCjBwawkwpvv3R8gxJuSWFmVWpQfX1Sak1p8iFGag0VJnLfZIyVA SCA9sSQ1OzW1ILUIJsvEwSnVwLgg1mLjiuLjbZPl2u99cTb0ebFto7XXubOLguZHeXK268o6 Zkeddbwba8F3OeOupx6n5WrGOXlrWewnX4p392Z92OQRmMtXeajIPqU8omBmVMUEWxfHgp9y F6qy3Taq5a55H7RFPXRPw2XWI4U56VUi1/rvxHhedtjXx/FL9eqp2ZvvHZ1SqMRSnJFoqMVc VJwIAIbldbpfAgAA Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org clock shoud be supplied during bus transaction. This patch defers clk_disabe in runtime_suspend if cmd/data line is used. Signed-off-by: Seungwon Jeon Acked-by: Heiko Stuebner --- Rebased with mmc-next. drivers/mmc/host/sdhci-s3c.c | 13 +++++++++---- drivers/mmc/host/sdhci.c | 20 ++++---------------- drivers/mmc/host/sdhci.h | 11 +++++++++++ 3 files changed, 24 insertions(+), 20 deletions(-) diff --git a/drivers/mmc/host/sdhci-s3c.c b/drivers/mmc/host/sdhci-s3c.c index a093e2e..a79b153 100644 --- a/drivers/mmc/host/sdhci-s3c.c +++ b/drivers/mmc/host/sdhci-s3c.c @@ -845,12 +845,17 @@ static int sdhci_s3c_runtime_suspend(struct device *dev) struct sdhci_host *host = dev_get_drvdata(dev); struct sdhci_s3c *ourhost = to_s3c(host); struct clk *busclk = ourhost->clk_io; - int ret; + int ret = 0; - ret = sdhci_runtime_suspend_host(host); + if (!(readl(host->ioaddr + SDHCI_PRESENT_STATE) & + (SDHCI_CMD_INHIBIT | SDHCI_DATA_INHIBIT))) { + ret = sdhci_runtime_suspend_host(host); + clk_disable_unprepare(ourhost->clk_bus[ourhost->cur_clk]); + clk_disable_unprepare(busclk); + } else { + sdhci_runtime_pm_put(host); + } - clk_disable_unprepare(ourhost->clk_bus[ourhost->cur_clk]); - clk_disable_unprepare(busclk); return ret; } diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c index f05a377..d62646d 100644 --- a/drivers/mmc/host/sdhci.c +++ b/drivers/mmc/host/sdhci.c @@ -54,20 +54,6 @@ static void sdhci_finish_command(struct sdhci_host *); static int sdhci_execute_tuning(struct mmc_host *mmc, u32 opcode); static void sdhci_tuning_timer(unsigned long data); -#ifdef CONFIG_PM_RUNTIME -static int sdhci_runtime_pm_get(struct sdhci_host *host); -static int sdhci_runtime_pm_put(struct sdhci_host *host); -#else -static inline int sdhci_runtime_pm_get(struct sdhci_host *host) -{ - return 0; -} -static inline int sdhci_runtime_pm_put(struct sdhci_host *host) -{ - return 0; -} -#endif - static void sdhci_dumpregs(struct sdhci_host *host) { pr_debug(DRIVER_NAME ": =========== REGISTER DUMP (%s)===========\n", @@ -2535,16 +2521,18 @@ EXPORT_SYMBOL_GPL(sdhci_enable_irq_wakeups); #ifdef CONFIG_PM_RUNTIME -static int sdhci_runtime_pm_get(struct sdhci_host *host) +int sdhci_runtime_pm_get(struct sdhci_host *host) { return pm_runtime_get_sync(host->mmc->parent); } +EXPORT_SYMBOL_GPL(sdhci_runtime_pm_get); -static int sdhci_runtime_pm_put(struct sdhci_host *host) +int sdhci_runtime_pm_put(struct sdhci_host *host) { pm_runtime_mark_last_busy(host->mmc->parent); return pm_runtime_put_autosuspend(host->mmc->parent); } +EXPORT_SYMBOL_GPL(sdhci_runtime_pm_put); int sdhci_runtime_suspend_host(struct sdhci_host *host) { diff --git a/drivers/mmc/host/sdhci.h b/drivers/mmc/host/sdhci.h index 71a4a7e..a42a192 100644 --- a/drivers/mmc/host/sdhci.h +++ b/drivers/mmc/host/sdhci.h @@ -385,8 +385,19 @@ extern void sdhci_enable_irq_wakeups(struct sdhci_host *host); #endif #ifdef CONFIG_PM_RUNTIME +extern int sdhci_runtime_pm_get(struct sdhci_host *host); +extern int sdhci_runtime_pm_put(struct sdhci_host *host); extern int sdhci_runtime_suspend_host(struct sdhci_host *host); extern int sdhci_runtime_resume_host(struct sdhci_host *host); +#else +inline int sdhci_runtime_pm_get(struct sdhci_host *host) +{ + return 0; +} +inline int sdhci_runtime_pm_put(struct sdhci_host *host) +{ + return 0; +} #endif #endif /* __SDHCI_HW_H */