Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp2961614ybl; Mon, 20 Jan 2020 12:53:42 -0800 (PST) X-Google-Smtp-Source: APXvYqzDHfkEdmKQBFdtIxXUJFenWTw8iVULb/rfixBiTBAZHmMfh1XPhGMZSQk4APrQgz3jGTDC X-Received: by 2002:aca:d985:: with SMTP id q127mr521805oig.132.1579553622046; Mon, 20 Jan 2020 12:53:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579553622; cv=none; d=google.com; s=arc-20160816; b=E53kJnc6raRFq+BkJHHFCv8502D/GHMeQmOhmCh3pHgy4DFPYEZ9EkgQIFqUK4zwF9 38+NYg04QFcpkhq5oOPBQgDkVwgeVTwBqL6IpDIwVX+jq+7RjES5Ke3nMLNYEwTza6vc SIYM/EU0But7srCVka1hbWg2mzRwNdgPu983I/d+KYp7sqXf7VDJE/vWzlYSUNL5RE1D P54RgXvCA3jay+OO47OTWAPMizyzjuS1S5j7PTiCrqlQpNFtRlg0eULsv4HgntrW1Cnk M1YdCrBEwMdG+TmzplkWNrq9y0eMWtQDuaFOvmP1jP6GctxsfAWOPHICTQCScfmP2kkv jLTg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dmarc-filter :dkim-signature; bh=/F/P/PamSf53/0NktI+vEIZjO2L7dILbSNYBUNX/1aI=; b=nn3+EZhlv0iFknyspC45itV2qBeAzHg5mrWVfSfYmNvaDeQtR88ZUONF4OMjmZNeNW 8rUiIN9ilzc9vfWmXaXPlzck9yrb9NTw5oWr+QOVXxcg4EsfwlIcclKniV85jBzQ3Egq p2L47jplzrJcCq00LP3EneOr/hvy+GxxaNGDy9nFvEp8y/lqGxhA4K1opyp/IYmLU8pv TlfuXTnt69t29Vy9608FPpw9vBjoBwDmgT4g8B3tYmA4FuXm//FGQa73He6w9+D79SQC h1OxRHTXhIvIKgEKIOrd/3sNftdF9VcYc6NKDN/Fmzj7Rroi6jW/LxygTsM0eT5tbW4F Av3A== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@mg.codeaurora.org header.s=smtp header.b=Bbj6LHyQ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e26si9071907otp.140.2020.01.20.12.53.30; Mon, 20 Jan 2020 12:53:42 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@mg.codeaurora.org header.s=smtp header.b=Bbj6LHyQ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727829AbgATUw3 (ORCPT + 99 others); Mon, 20 Jan 2020 15:52:29 -0500 Received: from mail25.static.mailgun.info ([104.130.122.25]:18232 "EHLO mail25.static.mailgun.info" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726874AbgATUw0 (ORCPT ); Mon, 20 Jan 2020 15:52:26 -0500 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1579553546; h=Content-Transfer-Encoding: Content-Type: In-Reply-To: MIME-Version: Date: Message-ID: From: References: Cc: To: Subject: Sender; bh=/F/P/PamSf53/0NktI+vEIZjO2L7dILbSNYBUNX/1aI=; b=Bbj6LHyQQqgA5Lp6RyqeKtaQQjU4ewgFMPe11S+GGMUQvDR5QRq2pbFsueSfNMlGOUFtgzlO DIT2aHzKowj3yvcx3v5nN1wYOp2b6KxGq2FGGu07mFywr4c2ccmL2jVDsetD232Z5KKrqrfN aSI78MGxhxW3HQE7mHi7eIri6pk= X-Mailgun-Sending-Ip: 104.130.122.25 X-Mailgun-Sid: WyI0MWYwYSIsICJsaW51eC1rZXJuZWxAdmdlci5rZXJuZWwub3JnIiwgImJlOWU0YSJd Received: from smtp.codeaurora.org (ec2-35-166-182-171.us-west-2.compute.amazonaws.com [35.166.182.171]) by mxa.mailgun.org with ESMTP id 5e261305.7f6447773fb8-smtp-out-n03; Mon, 20 Jan 2020 20:52:21 -0000 (UTC) Received: by smtp.codeaurora.org (Postfix, from userid 1001) id A1680C4479C; Mon, 20 Jan 2020 20:52:19 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-caf-mail-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=2.0 tests=ALL_TRUSTED,SPF_NONE autolearn=unavailable autolearn_force=no version=3.4.0 Received: from [10.46.161.159] (i-global254.qualcomm.com [199.106.103.254]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: asutoshd) by smtp.codeaurora.org (Postfix) with ESMTPSA id E6EB9C433CB; Mon, 20 Jan 2020 20:52:17 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org E6EB9C433CB Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; spf=none smtp.mailfrom=asutoshd@codeaurora.org Subject: Re: [PATCH v1 3/3] scsi: ufs-mediatek: enable low-power mode for hibern8 state To: Stanley Chu , linux-scsi@vger.kernel.org, martin.petersen@oracle.com, avri.altman@wdc.com, alim.akhtar@samsung.com, jejb@linux.ibm.com Cc: beanhuo@micron.com, cang@codeaurora.org, matthias.bgg@gmail.com, bvanassche@acm.org, linux-mediatek@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, kuohong.wang@mediatek.com, peter.wang@mediatek.com, chun-hung.wu@mediatek.com, andy.teng@mediatek.com References: <20200117035108.19699-1-stanley.chu@mediatek.com> <20200117035108.19699-4-stanley.chu@mediatek.com> From: "Asutosh Das (asd)" Message-ID: <38b2614d-1fdd-8bad-63a1-e9bc5698cc66@codeaurora.org> Date: Mon, 20 Jan 2020 12:52:17 -0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.4.1 MIME-Version: 1.0 In-Reply-To: <20200117035108.19699-4-stanley.chu@mediatek.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 1/16/2020 7:51 PM, Stanley Chu wrote: > In MediaTek Chipsets, UniPro link and ufshci can enter proprietary > low-power mode while link is in hibern8 state. > > Signed-off-by: Stanley Chu > --- Reviewed-by: Asutosh Das > drivers/scsi/ufs/ufs-mediatek.c | 53 +++++++++++++++++++++++++++++++++ > 1 file changed, 53 insertions(+) > > diff --git a/drivers/scsi/ufs/ufs-mediatek.c b/drivers/scsi/ufs/ufs-mediatek.c > index d5194d0c4ef5..f32f3f34f6d0 100644 > --- a/drivers/scsi/ufs/ufs-mediatek.c > +++ b/drivers/scsi/ufs/ufs-mediatek.c > @@ -382,11 +382,60 @@ static void ufs_mtk_device_reset(struct ufs_hba *hba) > dev_info(hba->dev, "device reset done\n"); > } > > +static int ufs_mtk_link_set_hpm(struct ufs_hba *hba) > +{ > + int err; > + > + err = ufshcd_hba_enable(hba); > + if (err) > + return err; > + > + err = ufshcd_dme_set(hba, > + UIC_ARG_MIB_SEL(VS_UNIPROPOWERDOWNCONTROL, 0), > + 0); > + if (err) > + return err; > + > + err = ufshcd_uic_hibern8_exit(hba); > + if (!err) > + ufshcd_set_link_active(hba); > + else > + return err; > + > + err = ufshcd_make_hba_operational(hba); > + if (err) > + return err; > + > + return 0; > +} > + > +static int ufs_mtk_link_set_lpm(struct ufs_hba *hba) > +{ > + int err; > + > + err = ufshcd_dme_set(hba, > + UIC_ARG_MIB_SEL(VS_UNIPROPOWERDOWNCONTROL, 0), > + 1); > + if (err) { > + /* Resume UniPro state for following error recovery */ > + ufshcd_dme_set(hba, > + UIC_ARG_MIB_SEL(VS_UNIPROPOWERDOWNCONTROL, 0), > + 0); > + return err; > + } > + > + return 0; > +} > + > static int ufs_mtk_suspend(struct ufs_hba *hba, enum ufs_pm_op pm_op) > { > + int err; > struct ufs_mtk_host *host = ufshcd_get_variant(hba); > > if (ufshcd_is_link_hibern8(hba)) { > + err = ufs_mtk_link_set_lpm(hba); > + if (err) > + return -EAGAIN; > phy_power_off(host->mphy); > ufs_mtk_setup_ref_clk(hba, false); > } > @@ -397,10 +446,14 @@ static int ufs_mtk_suspend(struct ufs_hba *hba, enum ufs_pm_op pm_op) > static int ufs_mtk_resume(struct ufs_hba *hba, enum ufs_pm_op pm_op) > { > struct ufs_mtk_host *host = ufshcd_get_variant(hba); > + int err; > > if (ufshcd_is_link_hibern8(hba)) { > ufs_mtk_setup_ref_clk(hba, true); > phy_power_on(host->mphy); > + err = ufs_mtk_link_set_hpm(hba); > + if (err) > + return err; > } > > return 0; > -- The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, Linux Foundation Collaborative Project