From patchwork Fri May 27 14:56:00 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guennadi Liakhovetski X-Patchwork-Id: 824352 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 p4REu7DC025411 for ; Fri, 27 May 2011 14:56:07 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751525Ab1E0O4G (ORCPT ); Fri, 27 May 2011 10:56:06 -0400 Received: from moutng.kundenserver.de ([212.227.17.10]:58818 "EHLO moutng.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750922Ab1E0O4F (ORCPT ); Fri, 27 May 2011 10:56:05 -0400 Received: from axis700.grange (dslb-094-221-103-246.pools.arcor-ip.net [94.221.103.246]) by mrelayeu.kundenserver.de (node=mrbap3) with ESMTP (Nemesis) id 0LqCzQ-1PmDnF0smO-00doh6; Fri, 27 May 2011 16:56:02 +0200 Received: by axis700.grange (Postfix, from userid 1000) id D3CFC189B6D; Fri, 27 May 2011 16:56:00 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by axis700.grange (Postfix) with ESMTP id CA49B189B6B; Fri, 27 May 2011 16:56:00 +0200 (CEST) Date: Fri, 27 May 2011 16:56:00 +0200 (CEST) From: Guennadi Liakhovetski X-X-Sender: lyakh@axis700.grange To: linux-sh@vger.kernel.org cc: linux-mmc@vger.kernel.org, Ian Molton , Magnus Damm , Simon Horman Subject: [PATCH/RFC] mmc: tmio: maximize power saving Message-ID: MIME-Version: 1.0 X-Provags-ID: V02:K0:i3byqp0mHPt79gifFMis4napDHvmaBjjOk+oYGFTJIf qwBV0zYbG+efpi6mfXawROvmpVshOS0XJCBG3rKqeiSDhVkcm3 4ORuJR0F7LsKUguHdxf8/NKesgj3dFxdgXeps3eBER/4/LC1TY zjk3uCBlJid4AQVY6faj8BfpXkmNKeQPLaMYq12qcZTlEBRyw+ Zbi42v0o9xaHVAZRhxyML/xFq1/dAQHqm4SKH0mFO0= 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, 27 May 2011 14:56:07 +0000 (UTC) This patch uses runtime PM to allow the system to power down the MMC controller, when the MMC closk is switched off. Signed-off-by: Guennadi Liakhovetski --- drivers/mmc/host/tmio_mmc_pio.c | 39 +++++++++++++++++++-------------------- 1 files changed, 19 insertions(+), 20 deletions(-) diff --git a/drivers/mmc/host/tmio_mmc_pio.c b/drivers/mmc/host/tmio_mmc_pio.c index ad6347b..a36535e 100644 --- a/drivers/mmc/host/tmio_mmc_pio.c +++ b/drivers/mmc/host/tmio_mmc_pio.c @@ -771,33 +771,30 @@ static void tmio_mmc_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) spin_unlock_irqrestore(&host->lock, flags); - if (ios->clock) - tmio_mmc_set_clock(host, ios->clock); - - /* Power sequence - OFF -> UP -> ON */ - if (ios->power_mode == MMC_POWER_UP) { - if ((pdata->flags & TMIO_MMC_HAS_COLD_CD) && !pdata->power) { + /* + * pdata->power == false only if COLD_CD is available, otherwise only + * in short time intervals during probing or resuming + */ + if (ios->power_mode == MMC_POWER_ON && ios->clock) { + if (!pdata->power) { pm_runtime_get_sync(&host->pdev->dev); pdata->power = true; } + tmio_mmc_set_clock(host, ios->clock); /* power up SD bus */ if (host->set_pwr) host->set_pwr(host->pdev, 1); - } else if (ios->power_mode == MMC_POWER_OFF || !ios->clock) { - /* power down SD bus */ - if (ios->power_mode == MMC_POWER_OFF) { - if (host->set_pwr) - host->set_pwr(host->pdev, 0); - if ((pdata->flags & TMIO_MMC_HAS_COLD_CD) && - pdata->power) { - pdata->power = false; - pm_runtime_put(&host->pdev->dev); - } - } - tmio_mmc_clk_stop(host); - } else { /* start bus clock */ tmio_mmc_clk_start(host); + } else if (ios->power_mode != MMC_POWER_UP) { + if (host->set_pwr) + host->set_pwr(host->pdev, 0); + if ((pdata->flags & TMIO_MMC_HAS_COLD_CD) && + pdata->power) { + pdata->power = false; + pm_runtime_put(&host->pdev->dev); + } + tmio_mmc_clk_stop(host); } switch (ios->bus_width) { @@ -921,8 +918,10 @@ int __devinit tmio_mmc_host_probe(struct tmio_mmc_host **host, tmio_mmc_request_dma(_host, pdata); /* We have to keep the device powered for its card detection to work */ - if (!(pdata->flags & TMIO_MMC_HAS_COLD_CD)) + if (!(pdata->flags & TMIO_MMC_HAS_COLD_CD)) { + pdata->power = true; pm_runtime_get_noresume(&pdev->dev); + } mmc_add_host(mmc);