Skip to content
This repository was archived by the owner on Nov 8, 2023. It is now read-only.

Commit baf5dda

Browse files
Mani-Sadhasivammartinkpetersen
authored andcommitted
scsi: ufs: ufs-qcom: Add support for reinitializing the UFS device
Starting from Qualcomm UFS version 4, the UFS device needs to be reinitialized after switching to maximum gear by the UFS core. Hence, add support for it by enabling the UFSHCD_QUIRK_REINIT_AFTER_MAX_GEAR_SWITCH quirk, implementing reinit_notify() callback and using the agreed gear speed for setting the PHY mode. Suggested-by: Can Guo <[email protected]> Tested-by: Andrew Halaney <[email protected]> # Qdrive3/sa8540p-ride Signed-off-by: Manivannan Sadhasivam <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
1 parent c270986 commit baf5dda

File tree

2 files changed

+24
-4
lines changed

2 files changed

+24
-4
lines changed

drivers/ufs/host/ufs-qcom.c

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -293,17 +293,13 @@ static int ufs_qcom_power_up_sequence(struct ufs_hba *hba)
293293
struct ufs_qcom_host *host = ufshcd_get_variant(hba);
294294
struct phy *phy = host->generic_phy;
295295
int ret;
296-
bool is_rate_B = UFS_QCOM_LIMIT_HS_RATE == PA_HS_MODE_B;
297296

298297
/* Reset UFS Host Controller and PHY */
299298
ret = ufs_qcom_host_reset(hba);
300299
if (ret)
301300
dev_warn(hba->dev, "%s: host reset returned %d\n",
302301
__func__, ret);
303302

304-
if (is_rate_B)
305-
phy_set_mode(phy, PHY_MODE_UFS_HS_B);
306-
307303
/* phy initialization - calibrate the phy */
308304
ret = phy_init(phy);
309305
if (ret) {
@@ -312,6 +308,8 @@ static int ufs_qcom_power_up_sequence(struct ufs_hba *hba)
312308
return ret;
313309
}
314310

311+
phy_set_mode_ext(phy, PHY_MODE_UFS_HS_B, host->hs_gear);
312+
315313
/* power on phy - start serdes and phy's power and clocks */
316314
ret = phy_power_on(phy);
317315
if (ret) {
@@ -714,6 +712,9 @@ static int ufs_qcom_pwr_change_notify(struct ufs_hba *hba,
714712
return ret;
715713
}
716714

715+
/* Use the agreed gear */
716+
host->hs_gear = dev_req_params->gear_tx;
717+
717718
/* enable the device ref clock before changing to HS mode */
718719
if (!ufshcd_is_hs_mode(&hba->pwr_info) &&
719720
ufshcd_is_hs_mode(dev_req_params))
@@ -827,6 +828,9 @@ static void ufs_qcom_advertise_quirks(struct ufs_hba *hba)
827828
| UFSHCD_QUIRK_DME_PEER_ACCESS_AUTO_MODE
828829
| UFSHCD_QUIRK_BROKEN_PA_RXHSUNTERMCAP);
829830
}
831+
832+
if (host->hw_ver.major > 0x3)
833+
hba->quirks |= UFSHCD_QUIRK_REINIT_AFTER_MAX_GEAR_SWITCH;
830834
}
831835

832836
static void ufs_qcom_set_caps(struct ufs_hba *hba)
@@ -1034,6 +1038,12 @@ static int ufs_qcom_init(struct ufs_hba *hba)
10341038
dev_warn(dev, "%s: failed to configure the testbus %d\n",
10351039
__func__, err);
10361040

1041+
/*
1042+
* Power up the PHY using the minimum supported gear (UFS_HS_G2).
1043+
* Switching to max gear will be performed during reinit if supported.
1044+
*/
1045+
host->hs_gear = UFS_HS_G2;
1046+
10371047
return 0;
10381048

10391049
out_variant_clear:
@@ -1377,6 +1387,13 @@ static void ufs_qcom_config_scaling_param(struct ufs_hba *hba,
13771387
}
13781388
#endif
13791389

1390+
static void ufs_qcom_reinit_notify(struct ufs_hba *hba)
1391+
{
1392+
struct ufs_qcom_host *host = ufshcd_get_variant(hba);
1393+
1394+
phy_power_off(host->generic_phy);
1395+
}
1396+
13801397
/*
13811398
* struct ufs_hba_qcom_vops - UFS QCOM specific variant operations
13821399
*
@@ -1400,6 +1417,7 @@ static const struct ufs_hba_variant_ops ufs_hba_qcom_vops = {
14001417
.device_reset = ufs_qcom_device_reset,
14011418
.config_scaling_param = ufs_qcom_config_scaling_param,
14021419
.program_key = ufs_qcom_ice_program_key,
1420+
.reinit_notify = ufs_qcom_reinit_notify,
14031421
};
14041422

14051423
/**

drivers/ufs/host/ufs-qcom.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,8 @@ struct ufs_qcom_host {
206206
struct reset_controller_dev rcdev;
207207

208208
struct gpio_desc *device_reset;
209+
210+
u32 hs_gear;
209211
};
210212

211213
static inline u32

0 commit comments

Comments
 (0)