@ -830,10 +830,8 @@ static int ufs_qcom_suspend(struct ufs_hba *hba, enum ufs_pm_op pm_op)
*/
if ( ! ufs_qcom_is_link_active ( hba ) ) {
ufs_qcom_disable_lane_clks ( host ) ;
if ( host - > is_phy_pwr_on ) {
phy_power_off ( phy ) ;
host - > is_phy_pwr_on = false ;
}
phy_power_off ( phy ) ;
if ( host - > vddp_ref_clk & & ufs_qcom_is_link_off ( hba ) )
ret = ufs_qcom_disable_vreg ( hba - > dev ,
host - > vddp_ref_clk ) ;
@ -860,15 +858,13 @@ static int ufs_qcom_resume(struct ufs_hba *hba, enum ufs_pm_op pm_op)
struct phy * phy = host - > generic_phy ;
int err ;
if ( ! host - > is_phy_pwr_on ) {
err = phy_power_on ( phy ) ;
if ( err ) {
dev_err ( hba - > dev , " %s: failed enabling regs, err = %d \n " ,
__func__ , err ) ;
goto out ;
}
host - > is_phy_pwr_on = true ;
err = phy_power_on ( phy ) ;
if ( err ) {
dev_err ( hba - > dev , " %s: failed enabling regs, err = %d \n " ,
__func__ , err ) ;
goto out ;
}
if ( host - > vddp_ref_clk & & ( hba - > rpm_lvl > UFS_PM_LVL_3 | |
hba - > spm_lvl > UFS_PM_LVL_3 ) )
ufs_qcom_enable_vreg ( hba - > dev ,
@ -1524,10 +1520,8 @@ static int ufs_qcom_setup_clocks(struct ufs_hba *hba, bool on,
return 0 ;
if ( on & & ( status = = POST_CHANGE ) ) {
if ( ! host - > is_phy_pwr_on ) {
phy_power_on ( host - > generic_phy ) ;
host - > is_phy_pwr_on = true ;
}
phy_power_on ( host - > generic_phy ) ;
/* enable the device ref clock for HS mode*/
if ( ufshcd_is_hs_mode ( & hba - > pwr_info ) )
ufs_qcom_dev_ref_clk_ctrl ( host , true ) ;
@ -1544,10 +1538,7 @@ static int ufs_qcom_setup_clocks(struct ufs_hba *hba, bool on,
ufs_qcom_dev_ref_clk_ctrl ( host , false ) ;
/* powering off PHY during aggressive clk gating */
if ( host - > is_phy_pwr_on ) {
phy_power_off ( host - > generic_phy ) ;
host - > is_phy_pwr_on = false ;
}
phy_power_off ( host - > generic_phy ) ;
}
}
@ -2148,6 +2139,8 @@ static int ufs_qcom_init(struct ufs_hba *hba)
host - > dev_ref_clk_en_mask = BIT ( 5 ) ;
}
}
/* use binary power_count to avoid race condition of phy on/off */
host - > generic_phy - > is_binary_power_count = true ;
/* update phy revision information before calling phy_init() */
ufs_qcom_phy_save_controller_version ( host - > generic_phy ,
@ -2156,13 +2149,15 @@ static int ufs_qcom_init(struct ufs_hba *hba)
err = ufs_qcom_parse_reg_info ( host , " qcom,vddp-ref-clk " ,
& host - > vddp_ref_clk ) ;
phy_init ( host - > generic_phy ) ;
err = phy_power_on ( host - > generic_phy ) ;
if ( err )
goto out_unregister_bus ;
if ( host - > vddp_ref_clk ) {
err = ufs_qcom_enable_vreg ( dev , host - > vddp_ref_clk ) ;
if ( err ) {
dev_err ( dev , " %s: failed enabling ref clk supply: %d \n " ,
__func__ , err ) ;
goto out_unregister_bus ;
goto out_disable_phy ;
}
}
@ -2209,6 +2204,8 @@ out_set_load_vccq_parent:
out_disable_vddp :
if ( host - > vddp_ref_clk )
ufs_qcom_disable_vreg ( dev , host - > vddp_ref_clk ) ;
out_disable_phy :
phy_power_off ( host - > generic_phy ) ;
out_unregister_bus :
phy_exit ( host - > generic_phy ) ;
msm_bus_scale_unregister_client ( host - > bus_vote . client_handle ) ;
@ -2232,10 +2229,7 @@ static void ufs_qcom_exit(struct ufs_hba *hba)
msm_bus_scale_unregister_client ( host - > bus_vote . client_handle ) ;
ufs_qcom_disable_lane_clks ( host ) ;
if ( host - > is_phy_pwr_on ) {
phy_power_off ( host - > generic_phy ) ;
host - > is_phy_pwr_on = false ;
}
phy_power_off ( host - > generic_phy ) ;
phy_exit ( host - > generic_phy ) ;
ufs_qcom_pm_qos_remove ( host ) ;
}