From patchwork Mon Aug 25 12:25:57 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 35901 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-qc0-f198.google.com (mail-qc0-f198.google.com [209.85.216.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id D1889203C0 for ; Mon, 25 Aug 2014 12:26:36 +0000 (UTC) Received: by mail-qc0-f198.google.com with SMTP id r5sf41879033qcx.5 for ; Mon, 25 Aug 2014 05:26:36 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=kCWRF4EgAddgVixsGr24MgWKQd/gN6uBWWsITEplNcI=; b=I9Kigudv9mN269GZEQjfn7xZzZAxVtW87VvIlTDJgkX/6hh8vb1SG3pDkCqZaTDOv3 ZTTSius/+5zdUzPvSA+swVaSvlnGutK/GfAdIAe8+nxjKPUFrMTG8zu9LP1emS6WFjms kvtOE7ToUKcoTCeCNSTStd6Oas3ZshpnKpu1KotW+ddkUj1HYNM3cpVbchjYcBgbxkCC XO3iWcm/o7dw+3h0TzzjWOp3+BBDqJnMzwPE797yJZV8d6ZgxFnBjbhvN2MrDioDkWC3 thbhCMhEygUuXYcShQiTO2NArrXH5iMeF6BFFKNIWOXLhzR7aLQanMBXi9wj0tv1Xij1 mOoQ== X-Gm-Message-State: ALoCoQmnaWQsvE/IeMoEIb3wKM9JOOTuyDQS3IZprkC3TV/ZZ6UUgCFGkmlAY70qoGfgpM7m+lYn X-Received: by 10.236.159.198 with SMTP id s46mr1056532yhk.17.1408969596417; Mon, 25 Aug 2014 05:26:36 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.81.200 with SMTP id f66ls1842199qgd.24.gmail; Mon, 25 Aug 2014 05:26:36 -0700 (PDT) X-Received: by 10.52.98.201 with SMTP id ek9mr5372369vdb.35.1408969596296; Mon, 25 Aug 2014 05:26:36 -0700 (PDT) Received: from mail-vc0-f175.google.com (mail-vc0-f175.google.com [209.85.220.175]) by mx.google.com with ESMTPS id h18si17215019vdt.8.2014.08.25.05.26.36 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 25 Aug 2014 05:26:36 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.175 as permitted sender) client-ip=209.85.220.175; Received: by mail-vc0-f175.google.com with SMTP id ik5so14714793vcb.6 for ; Mon, 25 Aug 2014 05:26:36 -0700 (PDT) X-Received: by 10.52.119.229 with SMTP id kx5mr5125939vdb.40.1408969596226; Mon, 25 Aug 2014 05:26:36 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.221.45.67 with SMTP id uj3csp113261vcb; Mon, 25 Aug 2014 05:26:35 -0700 (PDT) X-Received: by 10.195.12.4 with SMTP id em4mr2833978wjd.98.1408969594967; Mon, 25 Aug 2014 05:26:34 -0700 (PDT) Received: from mail-wg0-f49.google.com (mail-wg0-f49.google.com [74.125.82.49]) by mx.google.com with ESMTPS id j6si41863wia.48.2014.08.25.05.26.34 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 25 Aug 2014 05:26:34 -0700 (PDT) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 74.125.82.49 as permitted sender) client-ip=74.125.82.49; Received: by mail-wg0-f49.google.com with SMTP id k14so13026895wgh.20 for ; Mon, 25 Aug 2014 05:26:34 -0700 (PDT) X-Received: by 10.194.71.136 with SMTP id v8mr20925903wju.38.1408969594156; Mon, 25 Aug 2014 05:26:34 -0700 (PDT) Received: from localhost.localdomain ([85.235.11.236]) by mx.google.com with ESMTPSA id u5sm145337wia.17.2014.08.25.05.26.33 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 25 Aug 2014 05:26:33 -0700 (PDT) From: Ulf Hansson To: linux-mmc@vger.kernel.org, Ian Molton , Chris Ball Cc: Geert Uytterhoeven , Linux-sh list , linux-kernel@vger.kernel.org, Ulf Hansson Subject: [PATCH 05/12] mmc: tmio: Handle clock gating from runtime PM functions Date: Mon, 25 Aug 2014 14:25:57 +0200 Message-Id: <1408969564-6335-6-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1408969564-6335-1-git-send-email-ulf.hansson@linaro.org> References: <1408969564-6335-1-git-send-email-ulf.hansson@linaro.org> X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: ulf.hansson@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.175 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Add clock gating control as a part of the tmio library functions for runtime PM. Signed-off-by: Ulf Hansson --- drivers/mmc/host/tmio_mmc.h | 3 ++- drivers/mmc/host/tmio_mmc_pio.c | 28 ++++++++++++++++++++++++---- 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/drivers/mmc/host/tmio_mmc.h b/drivers/mmc/host/tmio_mmc.h index f837723..f1ee3e4 100644 --- a/drivers/mmc/host/tmio_mmc.h +++ b/drivers/mmc/host/tmio_mmc.h @@ -73,9 +73,10 @@ struct tmio_mmc_host { struct delayed_work delayed_reset_work; struct work_struct done; - /* Cache IRQ mask */ + /* Cache */ u32 sdcard_irq_mask; u32 sdio_irq_mask; + unsigned int clk_cache; spinlock_t lock; /* protect host private data */ unsigned long last_req_ts; diff --git a/drivers/mmc/host/tmio_mmc_pio.c b/drivers/mmc/host/tmio_mmc_pio.c index e573a15..2345177 100644 --- a/drivers/mmc/host/tmio_mmc_pio.c +++ b/drivers/mmc/host/tmio_mmc_pio.c @@ -149,7 +149,8 @@ static void tmio_mmc_enable_sdio_irq(struct mmc_host *mmc, int enable) } } -static void tmio_mmc_set_clock(struct tmio_mmc_host *host, int new_clock) +static void tmio_mmc_set_clock(struct tmio_mmc_host *host, + unsigned int new_clock) { u32 clk = 0, clock; @@ -767,9 +768,9 @@ fail: pm_runtime_put_autosuspend(mmc_dev(mmc)); } -static int tmio_mmc_clk_update(struct mmc_host *mmc) +static int tmio_mmc_clk_update(struct tmio_mmc_host *host) { - struct tmio_mmc_host *host = mmc_priv(mmc); + struct mmc_host *mmc = host->mmc; struct tmio_mmc_data *pdata = host->pdata; int ret; @@ -911,6 +912,8 @@ static void tmio_mmc_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) ios->clock, ios->power_mode); host->mrq = NULL; + host->clk_cache = ios->clock; + mutex_unlock(&host->ios_lock); pm_runtime_mark_last_busy(mmc_dev(mmc)); @@ -1036,7 +1039,7 @@ int tmio_mmc_host_probe(struct tmio_mmc_host **host, mmc->caps & MMC_CAP_NONREMOVABLE || mmc->slot.cd_irq >= 0); - if (tmio_mmc_clk_update(mmc) < 0) { + if (tmio_mmc_clk_update(_host) < 0) { mmc->f_max = pdata->hclk; mmc->f_min = mmc->f_max / 512; } @@ -1162,6 +1165,15 @@ EXPORT_SYMBOL(tmio_mmc_host_resume); #ifdef CONFIG_PM_RUNTIME int tmio_mmc_host_runtime_suspend(struct device *dev) { + struct mmc_host *mmc = dev_get_drvdata(dev); + struct tmio_mmc_host *host = mmc_priv(mmc); + + if (host->clk_cache) + tmio_mmc_clk_stop(host); + + if (host->pdata->clk_disable) + host->pdata->clk_disable(host->pdev); + return 0; } EXPORT_SYMBOL(tmio_mmc_host_runtime_suspend); @@ -1171,6 +1183,14 @@ int tmio_mmc_host_runtime_resume(struct device *dev) struct mmc_host *mmc = dev_get_drvdata(dev); struct tmio_mmc_host *host = mmc_priv(mmc); + tmio_mmc_reset(host); + tmio_mmc_clk_update(host); + + if (host->clk_cache) { + tmio_mmc_set_clock(host, host->clk_cache); + tmio_mmc_clk_start(host); + } + tmio_mmc_enable_dma(host, true); return 0;