Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp2891191pxb; Sun, 15 Nov 2020 22:54:35 -0800 (PST) X-Google-Smtp-Source: ABdhPJyy+gkWrvJ7epGVoCBrLnwKwlAPUVNF8FOWhKbwRBtQ6MUp2Z6mrMjrp/1wBR8QOXcE6RxX X-Received: by 2002:aa7:c94b:: with SMTP id h11mr13813812edt.322.1605509674782; Sun, 15 Nov 2020 22:54:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605509674; cv=none; d=google.com; s=arc-20160816; b=GoDZt/TdpO0W+u2RqziZgFepUrQCamSWgDMg1cs2VgBt21oosYIx+2WJrIetrS46qt u7DP2cIaYBSmH/VKjO7Ojqm6iCiNTy3m94X9pv3707yPjIzaTZOkFKTzCfHQm3Ar241U yQg/8X9rTV+UCYETBcLGesV3J5f6X6FqqB03ezD2uBtcsIO6K0sIn+uz1RJ8LBta1Hea SubPNPwYEZWIZPzGoB7Hp0CXPnO4hY6QFH2wTfAAswuCSQ3K7tj6/Hihpt1hNSp51dYv 1gHU21Ih2AVyignBLus9LM8DmoHYiXRoarMy4Y4nykrf/sVDMU5rghIg5TOoR4xTyj74 /egA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from; bh=MFIIUuOXnZDvPRdKw9P+iY42D/uSxePvasNaWtf7si8=; b=PNLiVjN8NJh9ABKg26OfUhghoRQp0ovi9Zs6ZB9YUEcbBr8VNQjFHySjYyTzTHReun axhDEhyqZU3coS4Ro483n8+QNM0xpTf2fa9kZOt/5yCIp3DLM0yqRr2IANeyJda2lJ/y fZOBqI0/lJZJAw6vHGZByoKO1zxRM8PanOy3Mdn5/rDykaX9rkeFgQkSwEcLJoFQjttY +4C9RridFPijZxeokKOmB4pDAMpfhAFYb/vpFAwyr2w+QvQPrCdKvphN1jaur01nMyxF SZIb/IFymtpnoZ3uIMBSUCX/oxOvqsGyddvyAtRuOE1ldAEtHsxMcg7JE25znIdQ0sEN O3iw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mediatek.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w5si11618313edi.111.2020.11.15.22.54.12; Sun, 15 Nov 2020 22:54:34 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mediatek.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727300AbgKPGvG (ORCPT + 99 others); Mon, 16 Nov 2020 01:51:06 -0500 Received: from mailgw01.mediatek.com ([210.61.82.183]:56409 "EHLO mailgw01.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1727166AbgKPGvF (ORCPT ); Mon, 16 Nov 2020 01:51:05 -0500 X-UUID: 63e5d1246d63429b928920b9aacebae1-20201116 X-UUID: 63e5d1246d63429b928920b9aacebae1-20201116 Received: from mtkcas08.mediatek.inc [(172.21.101.126)] by mailgw01.mediatek.com (envelope-from ) (Cellopoint E-mail Firewall v4.1.14 Build 0819 with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 1379785335; Mon, 16 Nov 2020 14:50:57 +0800 Received: from mtkcas08.mediatek.inc (172.21.101.126) by mtkmbs02n2.mediatek.inc (172.21.101.101) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Mon, 16 Nov 2020 14:50:55 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by mtkcas08.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Mon, 16 Nov 2020 14:50:55 +0800 From: Stanley Chu To: , , , , CC: , , , , , , , , , , , , , , , , , Stanley Chu Subject: [PATCH v1 1/9] scsi: ufs-mediatek: Refactor performance scaling functions Date: Mon, 16 Nov 2020 14:50:46 +0800 Message-ID: <20201116065054.7658-2-stanley.chu@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20201116065054.7658-1-stanley.chu@mediatek.com> References: <20201116065054.7658-1-stanley.chu@mediatek.com> MIME-Version: 1.0 Content-Type: text/plain X-TM-SNTS-SMTP: 7BA158C2F014F9EBECDA729273DE98A4D70B8A66006E120B5A876D526A8E02762000:8 X-MTK: N Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Refactor preformance scaling related functions in MediaTek UFS driver. Signed-off-by: Stanley Chu --- drivers/scsi/ufs/ufs-mediatek.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/drivers/scsi/ufs/ufs-mediatek.c b/drivers/scsi/ufs/ufs-mediatek.c index 7fed7630d36c..b9b423752ee1 100644 --- a/drivers/scsi/ufs/ufs-mediatek.c +++ b/drivers/scsi/ufs/ufs-mediatek.c @@ -514,6 +514,19 @@ static void ufs_mtk_init_host_caps(struct ufs_hba *hba) dev_info(hba->dev, "caps: 0x%x", host->caps); } +static void ufs_mtk_scale_perf(struct ufs_hba *hba, bool up) +{ + struct ufs_mtk_host *host = ufshcd_get_variant(hba); + + ufs_mtk_boost_crypt(hba, up); + ufs_mtk_setup_ref_clk(hba, up); + + if (up) + phy_power_on(host->mphy); + else + phy_power_off(host->mphy); +} + /** * ufs_mtk_setup_clocks - enables/disable clocks * @hba: host controller instance @@ -555,15 +568,10 @@ static int ufs_mtk_setup_clocks(struct ufs_hba *hba, bool on, clk_pwr_off = true; } - if (clk_pwr_off) { - ufs_mtk_boost_crypt(hba, on); - ufs_mtk_setup_ref_clk(hba, on); - phy_power_off(host->mphy); - } + if (clk_pwr_off) + ufs_mtk_scale_perf(hba, false); } else if (on && status == POST_CHANGE) { - phy_power_on(host->mphy); - ufs_mtk_setup_ref_clk(hba, on); - ufs_mtk_boost_crypt(hba, on); + ufs_mtk_scale_perf(hba, true); } return ret; -- 2.18.0