From patchwork Thu Jan 4 15:30:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Nazzareno Trimarchi X-Patchwork-Id: 10144981 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 3CAAE601A1 for ; Thu, 4 Jan 2018 15:31:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2E6B9287AB for ; Thu, 4 Jan 2018 15:31:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 21041287D5; Thu, 4 Jan 2018 15:31:19 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.3 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_WEB, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 781DF287C9 for ; Thu, 4 Jan 2018 15:31:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751762AbeADPbQ (ORCPT ); Thu, 4 Jan 2018 10:31:16 -0500 Received: from mail-wr0-f195.google.com ([209.85.128.195]:33525 "EHLO mail-wr0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753120AbeADPbG (ORCPT ); Thu, 4 Jan 2018 10:31:06 -0500 Received: by mail-wr0-f195.google.com with SMTP id p6so1810468wrd.0 for ; Thu, 04 Jan 2018 07:31:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=XIR2ts6XdcyhB2wY92xSnp2rY16NB0Rqedo2LgypqSA=; b=lBJsyreiR9MxE/CJWp5qh+n/lDyo2oFageanzZSa7O+oRUk48/63CUFt7OJhRYoltY SxYxOYj3jobNWJl8z0MlPRGupWMjsaKnE/2kcefgtWWJntxqhQiuLn4q6f+jIUG9LWh/ YP5rxnZn45ysH8O3wWgswnsQG5n76HFHDNJqIQ1D0orq1A/nqkj1zbUkekT9mAxMQjw8 s4DR8YM/GPoUJ0ptIyg5/MRGaJTQFohCs6dLbdeggSJhZpGmlhUKSl3PiIJgLUoqUzwR an7CKE6bJrSapoDN6x+KRKOlZv9q4VgHhRj7CU+uIr0ooxmuWosmwZzuBGRwKvEuKDG8 UAUQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=XIR2ts6XdcyhB2wY92xSnp2rY16NB0Rqedo2LgypqSA=; b=WkxviMiM1oCuQms9cbIvvYFTH4t0ANbP62IcZ396jJs1npLWEWvi0SKlIe7wkvD+A7 BLWWLzc+gXsWqSHnFygg634LJFKxjQ/gv/ztMMS4O5lsWAVibsBR4rNa7OpOaMzvawbt bSGP8wwjtzbL5+9zLGR2reos2eTbxOH6A4zmlfuyLhM7HlhGC/MRv8Sa8eEkIUiGgaF7 WiWZw70FReR8Pmp5S9nNFO4+c4UZrv28/FGlOMXO8c7ZlDps4BLDF3gW0lg86tkbUSkR TK99SCCBWbZ/VXYgParg8eu48Iw7QWwyBkhCPFkSnr41Pmm6gW6P9fhjPotz7KzY7S+J nhBg== X-Gm-Message-State: AKGB3mKwr8f3GfoUuHeQ5m3asG880oOMkHJLgI+lEARZPawRrxlZNtIH kQL/be3wUQvSJn+IhDUkez56QQ== X-Google-Smtp-Source: ACJfBou1yH1Z6OVbAem1kkGGPXddVi4LiPEiQjgePDqauGGxXNTApjK9yG9VZ6039Ap3hqSyQa4B2A== X-Received: by 10.223.135.227 with SMTP id c32mr5025333wrc.183.1515079865159; Thu, 04 Jan 2018 07:31:05 -0800 (PST) Received: from localhost.localdomain ([5.170.79.192]) by smtp.gmail.com with ESMTPSA id b48sm9482358wrb.1.2018.01.04.07.31.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 04 Jan 2018 07:31:04 -0800 (PST) From: Michael Trimarchi To: Ulf Hansson Cc: Michael Trimarchi , linux-mmc@vger.kernel.org, Adrian Hunter Subject: [PATCH 3/3] mmc: sdhci-esdhc-imx: Enable/Disable mmc clock during runtime suspend Date: Thu, 4 Jan 2018 16:30:59 +0100 Message-Id: <1515079859-18401-3-git-send-email-michael@amarulasolutions.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1515079859-18401-1-git-send-email-michael@amarulasolutions.com> References: <1515079859-18401-1-git-send-email-michael@amarulasolutions.com> Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP mmc clock can be stopped during runtime suspend and restart during runtime resume if the sdio irq is not enabled. Stop sdio clock reduce EMI of the device when the bus is not in use. Signed-off-by: Michael Trimarchi --- Changes V2->V3: - move clock re-order on a separated patch Changes V1->V2: - rebase to latest linux - address sdio irq wakeup - move the clock enable clk_ahb up to be balance with the runtime suspend function and to make function more clean by the end without two if condition --- drivers/mmc/host/sdhci-esdhc-imx.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/mmc/host/sdhci-esdhc-imx.c b/drivers/mmc/host/sdhci-esdhc-imx.c index 6d4e323..53cc1b6 100644 --- a/drivers/mmc/host/sdhci-esdhc-imx.c +++ b/drivers/mmc/host/sdhci-esdhc-imx.c @@ -193,6 +193,7 @@ struct pltfm_imx_data { struct clk *clk_ipg; struct clk *clk_ahb; struct clk *clk_per; + unsigned int actual_clock; enum { NO_CMD_PENDING, /* no multiblock command pending */ MULTIBLK_IN_PROCESS, /* exact multiblock cmd in process */ @@ -1396,6 +1397,8 @@ static int sdhci_esdhc_runtime_suspend(struct device *dev) mmc_retune_needed(host->mmc); if (!sdhci_sdio_irq_enabled(host)) { + imx_data->actual_clock = host->mmc->actual_clock; + esdhc_pltfm_set_clock(host, 0); clk_disable_unprepare(imx_data->clk_per); clk_disable_unprepare(imx_data->clk_ipg); } @@ -1422,6 +1425,7 @@ static int sdhci_esdhc_runtime_resume(struct device *dev) err = clk_prepare_enable(imx_data->clk_ipg); if (err) goto disable_per_clk; + esdhc_pltfm_set_clock(host, imx_data->actual_clock); } err = sdhci_runtime_resume_host(host);