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: 4774331 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 F2E699F38D for ; Mon, 25 Aug 2014 12:30:42 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 209FC200D6 for ; Mon, 25 Aug 2014 12:30:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D70D82010B for ; Mon, 25 Aug 2014 12:30:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932339AbaHYM3V (ORCPT ); Mon, 25 Aug 2014 08:29:21 -0400 Received: from mail-wg0-f48.google.com ([74.125.82.48]:34639 "EHLO mail-wg0-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932325AbaHYM0f (ORCPT ); Mon, 25 Aug 2014 08:26:35 -0400 Received: by mail-wg0-f48.google.com with SMTP id x13so12978210wgg.19 for ; Mon, 25 Aug 2014 05:26:34 -0700 (PDT) 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=kCWRF4EgAddgVixsGr24MgWKQd/gN6uBWWsITEplNcI=; b=dgKi1EFyiu69aq5KwGPBUys11x1H93lieQ4cH9KXQtdRvn1XYB47d0BRlRAY+gUfF8 ud+47a428NSk6d/g647nVe39XtwMO1XGoiD5fBwIqZuX2DBYTbm9XsBTgvSfeTSaapu2 1xXQ8VAiaulpOyVzfLUPf80YzS0fZWHy0XPUAyjel+bgVQfgDaDLcdtiqrkZP5Oscbtz kaN6mTIK+/UgOKZJrZKBQGXG9UG0y53GTC2O3af6ATpJOM/AkRZW43vhW0qGQ/wiBdj8 zMBg4aSBMAEPG8mI7D5ga2ItxrAG3XqPoe6kt3hdu+uP+fXWzr7akWvd7HBV51qNt/ke RANQ== X-Gm-Message-State: ALoCoQlOqa319/Zp5Vcq9gzCAwXDoJbHpfKvt3sxQOYJyyCEeuVPKfirWgYuSdpkHAkkR5R2etNv 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> 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=unavailable 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 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;