From patchwork Thu Jan 4 13:58:44 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: 10144761 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 2822F605BD for ; Thu, 4 Jan 2018 13:58:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1D6FD2861D for ; Thu, 4 Jan 2018 13:58:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 127A328635; Thu, 4 Jan 2018 13:58:51 +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=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,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 A6B302861E for ; Thu, 4 Jan 2018 13:58:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752998AbeADN6u (ORCPT ); Thu, 4 Jan 2018 08:58:50 -0500 Received: from mail-wm0-f67.google.com ([74.125.82.67]:35885 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753013AbeADN6t (ORCPT ); Thu, 4 Jan 2018 08:58:49 -0500 Received: by mail-wm0-f67.google.com with SMTP id b76so3630202wmg.1 for ; Thu, 04 Jan 2018 05:58:48 -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=YR7Mc6fkRdXI4UteKfqeCRKXX1oFTsYW6zdKK+r9h8Y=; b=MgXhwuqhyEu+6gK+VP2wNBR6/UUj73ihART/s44fkpO9p63G53ocnc6Pt3gKzWE9JO QXvhCKc+TuDZXnpUiI9vfzYUbkh5Zus7LCUcbOQfA3cL5J5feABvwPYoy3rTPuKoPrY1 Zf8l8UN7zLJsA/yxnAJzcIfX/OZ7aWfT8ab4ufULGRWNV5gokHvqkW2qbRZbKOZmoYyk rr6Q+l3Qiyrw1OpeLq4sR0JFbt9NFsxe1sSEY5NeMhfTMrw+Eo1IvChjR4zg7PiUgkf1 Kx9F++w5uSYTOgDnvIpksRdHXlwwiOlXa/T5mVX6yVrzGpk9ESCzu3AsGAq8HTNdH8EE sgVQ== 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=YR7Mc6fkRdXI4UteKfqeCRKXX1oFTsYW6zdKK+r9h8Y=; b=SZZrXLv8+/JkYq2JO0U8AHmrzNZuaJbDGtQ2VYZlBHuiThNI7GsNJGVo/liJAzCzd2 d5pCDnBbI3WZ2pIA8KC9u/gFE2sQI9RhE/rbwwjjiSIse2jJ75M7+iRjNkT6rpHZmA+K LhY7pOsYaPzT30tzb6sCYRzpWqnaJXSNkQnEGc0FwN+daaHKjOMnsTXluIbNyZv6ZgM7 cVeu9LoYyus92qL8nUw4L3UqJHBj9hbNKSGnx4c1bHL+kYCMbBMJTaNAyS9268MqHmtS uI7McZVcW5WM47OKL1rCV5e/IcM+yOoljS0ot0iEeS0JRNeq+cCowbt7izwL0Wkm7rkV NdUw== X-Gm-Message-State: AKGB3mIfHCgI3DR5NPiEHow8CJMGN0/f86SBJ/O0RlGuxPmiIY9/kqpk gQgwdfgRYMAMQ1iEATCzE3DhRm71uD4= X-Google-Smtp-Source: ACJfBou0fD+BN1QmNr+JZY4IgOe2vy/7rDUbC6yTj6yv/m3FtFaERAMDQLTj16hg07tEhFqGlsmFmw== X-Received: by 10.28.238.135 with SMTP id j7mr4457940wmi.140.1515074327962; Thu, 04 Jan 2018 05:58:47 -0800 (PST) Received: from localhost.localdomain ([5.170.79.2]) by smtp.gmail.com with ESMTPSA id z5sm2950205wre.94.2018.01.04.05.58.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 04 Jan 2018 05:58:47 -0800 (PST) From: Michael Trimarchi To: Ulf Hansson Cc: Michael Trimarchi , linux-mmc@vger.kernel.org, Adrian Hunter Subject: [PATCH V2 2/2] mmc: sdhci-esdhc-imx: Enable/Disable mmc clock during runtime suspend Date: Thu, 4 Jan 2018 14:58:44 +0100 Message-Id: <1515074324-12933-2-git-send-email-michael@amarulasolutions.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1515074324-12933-1-git-send-email-michael@amarulasolutions.com> References: <1515074324-12933-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 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 | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/drivers/mmc/host/sdhci-esdhc-imx.c b/drivers/mmc/host/sdhci-esdhc-imx.c index d08c21e..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); } @@ -1411,31 +1414,34 @@ static int sdhci_esdhc_runtime_resume(struct device *dev) struct pltfm_imx_data *imx_data = sdhci_pltfm_priv(pltfm_host); int err; + err = clk_prepare_enable(imx_data->clk_ahb); + if (err) + return err; + if (!sdhci_sdio_irq_enabled(host)) { err = clk_prepare_enable(imx_data->clk_per); if (err) - return err; + goto disable_ahb_clk; err = clk_prepare_enable(imx_data->clk_ipg); if (err) goto disable_per_clk; + esdhc_pltfm_set_clock(host, imx_data->actual_clock); } - err = clk_prepare_enable(imx_data->clk_ahb); - if (err) - goto disable_ipg_clk; + err = sdhci_runtime_resume_host(host); if (err) - goto disable_ahb_clk; + goto disable_ipg_clk; return 0; -disable_ahb_clk: - clk_disable_unprepare(imx_data->clk_ahb); disable_ipg_clk: if (!sdhci_sdio_irq_enabled(host)) clk_disable_unprepare(imx_data->clk_ipg); disable_per_clk: if (!sdhci_sdio_irq_enabled(host)) clk_disable_unprepare(imx_data->clk_per); +disable_ahb_clk: + clk_disable_unprepare(imx_data->clk_ahb); return err; } #endif