From patchwork Wed Nov 19 19:37:21 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 5340621 Return-Path: X-Original-To: patchwork-linux-mmc@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 70E7DC11AC for ; Wed, 19 Nov 2014 19:37:31 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 8909B201FA for ; Wed, 19 Nov 2014 19:37:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8E180201FB for ; Wed, 19 Nov 2014 19:37:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755576AbaKSTh2 (ORCPT ); Wed, 19 Nov 2014 14:37:28 -0500 Received: from mail-ig0-f175.google.com ([209.85.213.175]:63814 "EHLO mail-ig0-f175.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755334AbaKSTh1 (ORCPT ); Wed, 19 Nov 2014 14:37:27 -0500 Received: by mail-ig0-f175.google.com with SMTP id h15so3536240igd.14 for ; Wed, 19 Nov 2014 11:37:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id; bh=sELk8bIz4Z2va9XqcGNuV5rAVcDsndAXxiSzvuip3Z0=; b=Fhkdvi7GFs/uCkjcQijnYMUQZSh6Vka1AL9uHXG5kZ99LDNKYQ56XJxR9qMzEaTyF1 /8Y9AV5EbEALk4CytmEqksGVuEnZcyD9VNpJNiFyuvnbv5/wvNbGkvVIN7/987wmbhwO y2iCowtl9B1wVko1i17vAd8u5+94XnuSb2ig8= 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; bh=sELk8bIz4Z2va9XqcGNuV5rAVcDsndAXxiSzvuip3Z0=; b=PNfje52J7tKevaELJ05CWhzWT2wVKANbu0FkjJOLSyz4G9wsRuqpzt/CrTcH2Bhjw9 WVStXHBlXBtMe5UqyI7Kdrk4VKL/H+E3SFslnJG35B3hAb57kBfwE2BX6R/ngtpgNAsA cFsBz2/fLBmWiX8hazSni2BbVmfyYGbORXsnPQTNN7ILLDOBYyigW7+7I+ORfBeqmO3r fMQVMI0hlZO/mlt0sa9wIEHgdI64Tn+oFnUVMsLicBN2u7+h6Bxi6bgfFiHVYjxyoo8M HMbfQatfzwgccDoWAE+N0ehG/nuMvvEs5I2R+6QirSlZj14m/IS4JbXf2n4O8c4gn0UE Ro+g== X-Gm-Message-State: ALoCoQndGGIuRFs2xkLPQpiZhYA9MfWnAEY7iR/OEhEG7gvKO8eorK5fRqJ6uRWsXsM4OYCzByb+ X-Received: by 10.50.25.100 with SMTP id b4mr5150189igg.17.1416425846854; Wed, 19 Nov 2014 11:37:26 -0800 (PST) Received: from tictac.mtv.corp.google.com ([172.22.65.76]) by mx.google.com with ESMTPSA id j2sm361284igj.14.2014.11.19.11.37.25 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 19 Nov 2014 11:37:26 -0800 (PST) From: Doug Anderson To: Jaehoon Chung , Seungwon Jeon , Ulf Hansson Cc: Alim Akhtar , Sonny Rao , Andrew Bresticker , Heiko Stuebner , linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org, Doug Anderson , chris@printf.net, linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2] mmc: dw_mmc: Turn the card clock off at suspend time Date: Wed, 19 Nov 2014 11:37:21 -0800 Message-Id: <1416425841-12681-1-git-send-email-dianders@chromium.org> X-Mailer: git-send-email 2.1.0.rc2.206.gedb03e5 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.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID,T_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 Since the dw_mmc driver was first added to Linux it's had a TODO in it that we should turn off the card clock during suspend. I have no idea for sure why it wasn't done originally, but if I had to guess I'd guess it was related to the lack of a common clock framework. Let's do it now. There is no reason for the card clock to be left on during suspend and most systems will eventually turn it off anyway (when whole clock trees are disabled). However, it's good to be explicit that it's disabled at the time that the MMC subsystem is disabled. This actually fixes a bug on Rockchip rk3288 where an SDIO card wakes the system back up during suspend. Signed-off-by: Doug Anderson --- Changes in v2: - Handle fact that ciu_clk is optional (abrestic) - Check for errors enabling ciu_clk (abrestic) drivers/mmc/host/dw_mmc.c | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/drivers/mmc/host/dw_mmc.c b/drivers/mmc/host/dw_mmc.c index 5a37c33..49f4013 100644 --- a/drivers/mmc/host/dw_mmc.c +++ b/drivers/mmc/host/dw_mmc.c @@ -2825,11 +2825,11 @@ EXPORT_SYMBOL(dw_mci_remove); #ifdef CONFIG_PM_SLEEP -/* - * TODO: we should probably disable the clock to the card in the suspend path. - */ int dw_mci_suspend(struct dw_mci *host) { + if (!IS_ERR(host->ciu_clk)) + clk_disable(host->ciu_clk); + return 0; } EXPORT_SYMBOL(dw_mci_suspend); @@ -2838,9 +2838,15 @@ int dw_mci_resume(struct dw_mci *host) { int i, ret; + if (!IS_ERR(host->ciu_clk)) { + ret = clk_enable(host->ciu_clk); + if (ret) + return ret; + } + if (!dw_mci_ctrl_reset(host, SDMMC_CTRL_ALL_RESET_FLAGS)) { ret = -ENODEV; - return ret; + goto exit_ciu_enabled; } if (host->use_dma && host->dma_ops->init) @@ -2871,7 +2877,14 @@ int dw_mci_resume(struct dw_mci *host) dw_mci_setup_bus(slot, true); } } + return 0; + +exit_ciu_enabled: + if (!IS_ERR(host->ciu_clk)) + clk_disable(host->ciu_clk); + + return ret; } EXPORT_SYMBOL(dw_mci_resume); #endif /* CONFIG_PM_SLEEP */