From patchwork Mon Feb 20 08:03:11 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ritesh Harjani X-Patchwork-Id: 9582099 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 9164A6047C for ; Mon, 20 Feb 2017 08:04:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 826C9287FB for ; Mon, 20 Feb 2017 08:04:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7709728851; Mon, 20 Feb 2017 08:04:35 +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=unavailable 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 3651B287FB for ; Mon, 20 Feb 2017 08:04:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752411AbdBTIEN (ORCPT ); Mon, 20 Feb 2017 03:04:13 -0500 Received: from smtp.codeaurora.org ([198.145.29.96]:45010 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752406AbdBTIEL (ORCPT ); Mon, 20 Feb 2017 03:04:11 -0500 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 366D660D8F; Mon, 20 Feb 2017 08:04:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1487577850; bh=jK/vVIZ41nCQcZ7yOx2+pOadFphKCOQA3VHDXJLSTF4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=b8v/1/UqUVMu404R5xaMfXaHwPDFTZRkHAxA/dY+clt91umsRp/uvfuN7Xr5ehjzB DSzpEw+XaI7lPZVvN/SjAo7xCUYz8W5mkDpQtzCnYgRQ+FiqUSb3jrEwvx+D6n1YL+ 8cg4E43C0zVKZOyXgwahGoBFhofnoaFcyKRh7/Xo= Received: from rharjani-linux.qualcomm.com (unknown [202.46.23.54]) (using TLSv1.1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: riteshh@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 7FD2960D0A; Mon, 20 Feb 2017 08:03:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1487577845; bh=jK/vVIZ41nCQcZ7yOx2+pOadFphKCOQA3VHDXJLSTF4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PwCeY4mBMEZYZ0bKhpNxnXOTgyOqwl6LWslYITSmj0ywVmUFaOJTv4PxpVFrVd4GB AOJ+/o73kDasuxcPvUIfWpr0EcKSatD5sSBT+RVrbbjEj6AflUrf2LG03XLKYF3ilK 0vmZIpsC2QDTLW6A/m1f3TGUjLIvAY2Hc25d0omM= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 7FD2960D0A Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=riteshh@codeaurora.org From: Ritesh Harjani To: ulf.hansson@linaro.org, linux-mmc@vger.kernel.org, adrian.hunter@intel.com Cc: shawn.lin@rock-chips.com, devicetree@vger.kernel.org, andy.gross@linaro.org, linux-arm-msm@vger.kernel.org, georgi.djakov@linaro.org, alex.lemberg@sandisk.com, mateusz.nowak@intel.com, Yuliy.Izrailov@sandisk.com, asutoshd@codeaurora.org, david.griego@linaro.org, stummala@codeaurora.org, venkatg@codeaurora.org, pramod.gurav@linaro.org, jeremymc@redhat.com, linux-kernel@vger.kernel.org, Ritesh Harjani Subject: [RFC PATCH 3/4] mmc: mmc: add support for CMD5 awake Date: Mon, 20 Feb 2017 13:33:11 +0530 Message-Id: <1487577792-12510-4-git-send-email-riteshh@codeaurora.org> X-Mailer: git-send-email 1.8.2.1 In-Reply-To: <1487577792-12510-1-git-send-email-riteshh@codeaurora.org> References: <1487577792-12510-1-git-send-email-riteshh@codeaurora.org> 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 This patch adds CMD5 awake support for emmc. This will be used to awake emmc from suspend together with partial_init support to reduce resume latencies. Signed-off-by: Ritesh Harjani --- drivers/mmc/core/mmc.c | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c index 7fd7228..83bcc86 100644 --- a/drivers/mmc/core/mmc.c +++ b/drivers/mmc/core/mmc.c @@ -1827,7 +1827,7 @@ static int mmc_can_sleep(struct mmc_card *card) return (card && card->ext_csd.rev >= 3); } -static int mmc_sleep(struct mmc_host *host) +static int mmc_sleepawake(struct mmc_host *host, bool sleep) { struct mmc_command cmd = {}; struct mmc_card *card = host->card; @@ -1837,13 +1837,16 @@ static int mmc_sleep(struct mmc_host *host) /* Re-tuning can't be done once the card is deselected */ mmc_retune_hold(host); - err = mmc_deselect_cards(host); - if (err) - goto out_release; + if (sleep) { + err = mmc_deselect_cards(host); + if (err) + goto out_release; + } cmd.opcode = MMC_SLEEP_AWAKE; cmd.arg = card->rca << 16; - cmd.arg |= 1 << 15; + if (sleep) + cmd.arg |= 1 << 15; /* * If the max_busy_timeout of the host is specified, validate it against @@ -1871,11 +1874,24 @@ static int mmc_sleep(struct mmc_host *host) if (!cmd.busy_timeout || !(host->caps & MMC_CAP_WAIT_WHILE_BUSY)) mmc_delay(timeout_ms); + if (!sleep) + err = mmc_select_card(card); + out_release: mmc_retune_release(host); return err; } +static int mmc_sleep(struct mmc_host *host) +{ + return mmc_sleepawake(host, true); +} + +static int mmc_awake(struct mmc_host *host) +{ + return mmc_sleepawake(host, false); +} + static int mmc_can_poweroff_notify(const struct mmc_card *card) { return card &&