From patchwork Thu Oct 18 09:53:21 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Seungwon Jeon X-Patchwork-Id: 1609291 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 9F571DFB34 for ; Thu, 18 Oct 2012 09:53:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754159Ab2JRJxY (ORCPT ); Thu, 18 Oct 2012 05:53:24 -0400 Received: from mailout3.samsung.com ([203.254.224.33]:43614 "EHLO mailout3.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752029Ab2JRJxX (ORCPT ); Thu, 18 Oct 2012 05:53:23 -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 <0MC3006MG24MNM10@mailout3.samsung.com> for linux-mmc@vger.kernel.org; Thu, 18 Oct 2012 18:53:22 +0900 (KST) X-AuditID: cbfee61a-b7f976d000001eb9-36-507fd191358f Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id D2.B7.07865.191DF705; Thu, 18 Oct 2012 18:53:22 +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 <0MC300M9H24X2G60@mmp2.samsung.com> for linux-mmc@vger.kernel.org; Thu, 18 Oct 2012 18:53:21 +0900 (KST) From: Seungwon Jeon To: linux-mmc@vger.kernel.org Cc: =?utf-8?Q?'Heiko_St=C3=BCbner'?= , 'Chander Kashyap' , 'Chris Ball' Subject: [PATCH] mmc: sdhci-s3c: ensure non-transaction of bus before clk_disable Date: Thu, 18 Oct 2012 18:53:21 +0900 Message-id: <004701cdad16$6886e890$3994b9b0$%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: Ac2tFmfkaBRK1jYGT5i9FMWwA6u/7A== Content-language: ko X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrELMWRmVeSWpSXmKPExsVy+t9jQd1JF+sDDJ7fYrQ48r+f0YHR4/Mm uQDGKC6blNSczLLUIn27BK6MNfskCxaJVHz4/ZK9gXGtYBcjB4eEgInE+j+GXYycQKaYxIV7 69m6GLk4hASmM0rMfLCdEcKZxSRxobufEaSKTUBL4u+bN8wgtoiArMTPPxfAOpgF2hklDv5q ZwdJCAsES+zf8ALMZhFQlbj3rQesmVfAVuLtztVsELagxI/J91hArmAWUJeYMiUXJMwsIC+x ec1bZojj1CUe/dWFWKUncerIBRaIEhGJfS/eMU5gFJiFZNAshEGzkAyahaRjASPLKkbR1ILk guKk9FxDveLE3OLSvHS95PzcTYzgkHwmtYNxZYPFIUYBDkYlHt5LPfUBQqyJZcWVuYcYJTiY lUR4V24CCvGmJFZWpRblxxeV5qQWH2KU5mBREudt9kgJEBJITyxJzU5NLUgtgskycXBKNTBO +7H09XStNX5XlPWkXqlaPUn6wX3mx8n93NcmPnFd7ctoGr37ula99NbEbSk7Vabfn6+feZ3l xcdIw0kThKKaf65L3L6Z83t/sc2lUzkskS4/bc40/4j8ICgotXbZjJKermWt2VNXBzbxtH6a Lxtw+PuHheaG1nGXeN/m/Nx+jHX/rLLFKl/TlViKMxINtZiLihMBsZ0RKEUCAAA= Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org Clock should be supplied during bus transaction. This patch defers clk_disabe in runtime_suspend if CMD/DATA line is used. Signed-off-by: Seungwon Jeon --- drivers/mmc/host/sdhci-s3c.c | 13 +++++++++---- drivers/mmc/host/sdhci.c | 6 ++++-- drivers/mmc/host/sdhci.h | 2 ++ 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/drivers/mmc/host/sdhci-s3c.c b/drivers/mmc/host/sdhci-s3c.c index 2903949..490b781 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(ourhost->clk_bus[ourhost->cur_clk]); + clk_disable(busclk); + } else { + sdhci_runtime_pm_put(host); + } - clk_disable(ourhost->clk_bus[ourhost->cur_clk]); - clk_disable(busclk); return ret; } diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c index 7922adb..deeffce 100644 --- a/drivers/mmc/host/sdhci.c +++ b/drivers/mmc/host/sdhci.c @@ -2535,16 +2535,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 97653ea..fbf9a08 100644 --- a/drivers/mmc/host/sdhci.h +++ b/drivers/mmc/host/sdhci.h @@ -384,6 +384,8 @@ 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); #endif