From patchwork Fri Nov 8 06:06:16 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 21422 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ie0-f199.google.com (mail-ie0-f199.google.com [209.85.223.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 1CB75244F2 for ; Fri, 8 Nov 2013 06:06:39 +0000 (UTC) Received: by mail-ie0-f199.google.com with SMTP id qd12sf5362444ieb.6 for ; Thu, 07 Nov 2013 22:06:38 -0800 (PST) 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=6EvkMQeauUL06KATHrN3ZOBXlptvdrxXFdvr4JJQb1E=; b=cWnZmwtggqKfUWKzB7bjp2WBJWUk1sXcyiTz2B8Jz83YfglN7IBJbm7DwPRQTuSKdB PHqfikcEAH0/Q2GnQU3ly2z9MjRgYFY3fov4CcgjjjQGNtEDSCpA1bg/FB1IWYw3fDFL OuPOdXIbyb8w1hNxNWUSjTi5MZZcvwbWiEKVmnnwoA/clfNdgvW4Mr2j/oWNSi4grhPN OZnyNLhWpl4aX8NLIu2qFNwI+/oX0B66TOnZtN1rOx7YM5fBM9yojSs19Vv3sl34LnxA STW7hm4XwkprCW27r17/znJ3hCb+MMdhTTa6FBo9ahO3uQ0JF8oMR/Sshv0HTaYh466n 1zrA== X-Gm-Message-State: ALoCoQkgZX+BVQibP9XZhouLU14dMRYkmj9/mwqaLiH32KYJsz8AjvwbVzZndITwhKS+co/m2brc X-Received: by 10.182.109.137 with SMTP id hs9mr4153896obb.21.1383890798685; Thu, 07 Nov 2013 22:06:38 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.51.169 with SMTP id l9ls1514107qeo.97.gmail; Thu, 07 Nov 2013 22:06:38 -0800 (PST) X-Received: by 10.58.144.168 with SMTP id sn8mr139666veb.33.1383890798580; Thu, 07 Nov 2013 22:06:38 -0800 (PST) Received: from mail-ve0-f178.google.com (mail-ve0-f178.google.com [209.85.128.178]) by mx.google.com with ESMTPS id rw8si3275840vdc.5.2013.11.07.22.06.38 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 07 Nov 2013 22:06:38 -0800 (PST) Received-SPF: neutral (google.com: 209.85.128.178 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.128.178; Received: by mail-ve0-f178.google.com with SMTP id db12so1156080veb.37 for ; Thu, 07 Nov 2013 22:06:38 -0800 (PST) X-Received: by 10.58.46.77 with SMTP id t13mr220677vem.32.1383890798469; Thu, 07 Nov 2013 22:06:38 -0800 (PST) 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.220.174.196 with SMTP id u4csp6974vcz; Thu, 7 Nov 2013 22:06:37 -0800 (PST) X-Received: by 10.152.37.169 with SMTP id z9mr9396940laj.5.1383890797455; Thu, 07 Nov 2013 22:06:37 -0800 (PST) Received: from mail-la0-f43.google.com (mail-la0-f43.google.com [209.85.215.43]) by mx.google.com with ESMTPS id nw5si3121895lbb.41.2013.11.07.22.06.37 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 07 Nov 2013 22:06:37 -0800 (PST) Received-SPF: neutral (google.com: 209.85.215.43 is neither permitted nor denied by best guess record for domain of ulf.hansson@linaro.org) client-ip=209.85.215.43; Received: by mail-la0-f43.google.com with SMTP id n7so344710lam.30 for ; Thu, 07 Nov 2013 22:06:36 -0800 (PST) X-Received: by 10.152.244.170 with SMTP id xh10mr3465534lac.15.1383890796881; Thu, 07 Nov 2013 22:06:36 -0800 (PST) Received: from linaro-ulf.lan (90-231-160-185-no158.tbcn.telia.com. [90.231.160.185]) by mx.google.com with ESMTPSA id f4sm6860209lah.0.2013.11.07.22.06.35 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 07 Nov 2013 22:06:36 -0800 (PST) From: Ulf Hansson To: linux-mmc@vger.kernel.org, Chris Ball Cc: Ulf Hansson , Guennadi Liakhovetski Subject: [PATCH 8/8] mmc: tmio: Handle clock gating from runtime PM functions Date: Fri, 8 Nov 2013 07:06:16 +0100 Message-Id: <1383890776-6912-9-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1383890776-6912-1-git-send-email-ulf.hansson@linaro.org> References: <1383890776-6912-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=neutral (google.com: 209.85.128.178 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) 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 exported runtime PM functions to provide tmio variants to use this in a common way. Cc: Guennadi Liakhovetski 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 58d3c05..3b41568 100644 --- a/drivers/mmc/host/tmio_mmc.h +++ b/drivers/mmc/host/tmio_mmc.h @@ -74,9 +74,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 cbb96a8..bb18892 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; @@ -773,9 +774,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; @@ -917,6 +918,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)); @@ -1034,7 +1037,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; } @@ -1160,6 +1163,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) tmio_mmc_enable_dma(host, true); + 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); + } + return 0; } EXPORT_SYMBOL(tmio_mmc_host_runtime_resume);