[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <1694411968-14413-2-git-send-email-quic_cang@quicinc.com>
Date: Sun, 10 Sep 2023 22:59:22 -0700
From: Can Guo <quic_cang@...cinc.com>
To: quic_cang@...cinc.com, mani@...nel.org, quic_nguyenb@...cinc.com,
quic_nitirawa@...cinc.com, martin.petersen@...cle.com
Cc: linux-scsi@...r.kernel.org, Andy Gross <agross@...nel.org>,
Bjorn Andersson <andersson@...nel.org>,
Konrad Dybcio <konrad.dybcio@...aro.org>,
"James E.J. Bottomley" <jejb@...ux.ibm.com>,
linux-arm-msm@...r.kernel.org (open list:UNIVERSAL FLASH STORAGE HOST
CONTROLLER DRIVER...), linux-kernel@...r.kernel.org (open list)
Subject: [PATCH 1/6] scsi: ufs: ufs-qcom: Setup host power mode during init
Setup host power mode and its limitations during UFS host driver init to
avoid repetitive work during every power mode change.
Co-developed-by: Bao D. Nguyen <quic_nguyenb@...cinc.com>
Signed-off-by: Can Guo <quic_cang@...cinc.com>
Signed-off-by: Bao D. Nguyen <quic_nguyenb@...cinc.com>
---
drivers/ufs/host/ufs-qcom.c | 27 ++++++++++++++++++---------
drivers/ufs/host/ufs-qcom.h | 1 +
2 files changed, 19 insertions(+), 9 deletions(-)
diff --git a/drivers/ufs/host/ufs-qcom.c b/drivers/ufs/host/ufs-qcom.c
index c3215d3..710f079 100644
--- a/drivers/ufs/host/ufs-qcom.c
+++ b/drivers/ufs/host/ufs-qcom.c
@@ -443,7 +443,11 @@ static u32 ufs_qcom_get_hs_gear(struct ufs_hba *hba)
static int ufs_qcom_power_up_sequence(struct ufs_hba *hba)
{
struct ufs_qcom_host *host = ufshcd_get_variant(hba);
+ struct ufs_dev_params *host_pwr_cap = &host->host_pwr_cap;
struct phy *phy = host->generic_phy;
+ enum phy_mode mode = host_pwr_cap->hs_rate == PA_HS_MODE_B ?
+ PHY_MODE_UFS_HS_B :
+ PHY_MODE_UFS_HS_A;
int ret;
/* Reset UFS Host Controller and PHY */
@@ -460,7 +464,7 @@ static int ufs_qcom_power_up_sequence(struct ufs_hba *hba)
return ret;
}
- phy_set_mode_ext(phy, PHY_MODE_UFS_HS_B, host->phy_gear);
+ phy_set_mode_ext(phy, mode, host->phy_gear);
/* power on phy - start serdes and phy's power and clocks */
ret = phy_power_on(phy);
@@ -884,7 +888,6 @@ static int ufs_qcom_pwr_change_notify(struct ufs_hba *hba,
struct ufs_pa_layer_attr *dev_req_params)
{
struct ufs_qcom_host *host = ufshcd_get_variant(hba);
- struct ufs_dev_params ufs_qcom_cap;
int ret = 0;
if (!dev_req_params) {
@@ -894,13 +897,7 @@ static int ufs_qcom_pwr_change_notify(struct ufs_hba *hba,
switch (status) {
case PRE_CHANGE:
- ufshcd_init_pwr_dev_param(&ufs_qcom_cap);
- ufs_qcom_cap.hs_rate = UFS_QCOM_LIMIT_HS_RATE;
-
- /* This driver only supports symmetic gear setting i.e., hs_tx_gear == hs_rx_gear */
- ufs_qcom_cap.hs_tx_gear = ufs_qcom_cap.hs_rx_gear = ufs_qcom_get_hs_gear(hba);
-
- ret = ufshcd_get_pwr_dev_param(&ufs_qcom_cap,
+ ret = ufshcd_get_pwr_dev_param(&host->host_pwr_cap,
dev_max_params,
dev_req_params);
if (ret) {
@@ -1037,6 +1034,17 @@ static void ufs_qcom_advertise_quirks(struct ufs_hba *hba)
hba->quirks |= UFSHCD_QUIRK_REINIT_AFTER_MAX_GEAR_SWITCH;
}
+static void ufs_qcom_set_pwr_mode_limits(struct ufs_hba *hba)
+{
+ struct ufs_qcom_host *host = ufshcd_get_variant(hba);
+ struct ufs_dev_params *host_pwr_cap = &host->host_pwr_cap;
+
+ ufshcd_init_pwr_dev_param(host_pwr_cap);
+
+ /* This driver only supports symmetic gear setting i.e., hs_tx_gear == hs_rx_gear */
+ host_pwr_cap->hs_tx_gear = host_pwr_cap->hs_rx_gear = ufs_qcom_get_hs_gear(hba);
+}
+
static void ufs_qcom_set_caps(struct ufs_hba *hba)
{
struct ufs_qcom_host *host = ufshcd_get_variant(hba);
@@ -1259,6 +1267,7 @@ static int ufs_qcom_init(struct ufs_hba *hba)
if (err)
goto out_variant_clear;
+ ufs_qcom_set_pwr_mode_limits(hba);
ufs_qcom_set_caps(hba);
ufs_qcom_advertise_quirks(hba);
diff --git a/drivers/ufs/host/ufs-qcom.h b/drivers/ufs/host/ufs-qcom.h
index fa54248..4db64d9 100644
--- a/drivers/ufs/host/ufs-qcom.h
+++ b/drivers/ufs/host/ufs-qcom.h
@@ -227,6 +227,7 @@ struct ufs_qcom_host {
struct gpio_desc *device_reset;
+ struct ufs_dev_params host_pwr_cap;
u32 phy_gear;
bool esi_enabled;
--
2.7.4
Powered by blists - more mailing lists