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: 3156371 Return-Path: X-Original-To: patchwork-linux-mmc@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 0D18B9F407 for ; Fri, 8 Nov 2013 06:06:43 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1F04120279 for ; Fri, 8 Nov 2013 06:06:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 323D8203AE for ; Fri, 8 Nov 2013 06:06:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751877Ab3KHGGi (ORCPT ); Fri, 8 Nov 2013 01:06:38 -0500 Received: from mail-la0-f47.google.com ([209.85.215.47]:42165 "EHLO mail-la0-f47.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751290Ab3KHGGi (ORCPT ); Fri, 8 Nov 2013 01:06:38 -0500 Received: by mail-la0-f47.google.com with SMTP id er20so1345266lab.6 for ; Thu, 07 Nov 2013 22:06:36 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=6EvkMQeauUL06KATHrN3ZOBXlptvdrxXFdvr4JJQb1E=; b=P0ujm6JNY1E8zDBujQ2v6TwzeS9mYCYleNbYdthrVi+oFY2LHHujeZxheJoqzEI32y awoqJO7TioBI0BMOBa044hDXXIyr4L0YWuCx9up4XWc6lymBhsWkXB2veEXBBlDmplBT HVhKLgmbORTqdRmwYn7Mzhktr6JjCkcVbGUF0SKa49bSV36QG0GPAmG8BCxFW9yt9Lkw ZX6UflpntDlWYVy5Wz6+FgTNDUAKMumqhdePAe9iaG8YLuGaGgyKGBT4qHnWnKsc0eZr Zg5cGpTemDy/Mp9/7VW4LuGe/8ivglQw2wQvclxF2PsOBADGZQSaGmlDiHSVD1YkuHH8 zP9Q== X-Gm-Message-State: ALoCoQkSh4pPG+Qgrs/4WL4dWWtBsrMLTgnLZG6jWyA0iR1wH1D+QeICuOWz+XNjSxwrDNwCxuRu 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> Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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);