scsi: ufs-qcom: enable/disable the device ref clock

This change enables the device ref clock before changing to HS mode
and disables it if entered to PWM mode.

Reviewed-by: Gilad Broner <gbroner@codeaurora.org>
Signed-off-by: Yaniv Gardi <ygardi@codeaurora.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
This commit is contained in:
Yaniv Gardi 2016-03-10 17:37:20 +02:00 committed by Martin K. Petersen
parent 4b9ad0b88c
commit f37aabcf58
2 changed files with 21 additions and 0 deletions

View File

@ -980,6 +980,10 @@ static int ufs_qcom_pwr_change_notify(struct ufs_hba *hba,
goto out; goto out;
} }
/* enable the device ref clock before changing to HS mode */
if (!ufshcd_is_hs_mode(&hba->pwr_info) &&
ufshcd_is_hs_mode(dev_req_params))
ufs_qcom_dev_ref_clk_ctrl(host, true);
break; break;
case POST_CHANGE: case POST_CHANGE:
if (ufs_qcom_cfg_timers(hba, dev_req_params->gear_rx, if (ufs_qcom_cfg_timers(hba, dev_req_params->gear_rx,
@ -1007,6 +1011,11 @@ static int ufs_qcom_pwr_change_notify(struct ufs_hba *hba,
memcpy(&host->dev_req_params, memcpy(&host->dev_req_params,
dev_req_params, sizeof(*dev_req_params)); dev_req_params, sizeof(*dev_req_params));
ufs_qcom_update_bus_bw_vote(host); ufs_qcom_update_bus_bw_vote(host);
/* disable the device ref clock if entered PWM mode */
if (ufshcd_is_hs_mode(&hba->pwr_info) &&
!ufshcd_is_hs_mode(dev_req_params))
ufs_qcom_dev_ref_clk_ctrl(host, false);
break; break;
default: default:
ret = -EINVAL; ret = -EINVAL;
@ -1108,6 +1117,9 @@ static int ufs_qcom_setup_clocks(struct ufs_hba *hba, bool on)
ufs_qcom_phy_disable_iface_clk(host->generic_phy); ufs_qcom_phy_disable_iface_clk(host->generic_phy);
goto out; goto out;
} }
/* enable the device ref clock for HS mode*/
if (ufshcd_is_hs_mode(&hba->pwr_info))
ufs_qcom_dev_ref_clk_ctrl(host, true);
vote = host->bus_vote.saved_vote; vote = host->bus_vote.saved_vote;
if (vote == host->bus_vote.min_bw_vote) if (vote == host->bus_vote.min_bw_vote)
ufs_qcom_update_bus_bw_vote(host); ufs_qcom_update_bus_bw_vote(host);

View File

@ -54,6 +54,7 @@
#include <linux/clk.h> #include <linux/clk.h>
#include <linux/completion.h> #include <linux/completion.h>
#include <linux/regulator/consumer.h> #include <linux/regulator/consumer.h>
#include "unipro.h"
#include <asm/irq.h> #include <asm/irq.h>
#include <asm/byteorder.h> #include <asm/byteorder.h>
@ -689,6 +690,14 @@ static inline int ufshcd_dme_peer_get(struct ufs_hba *hba,
int ufshcd_read_device_desc(struct ufs_hba *hba, u8 *buf, u32 size); int ufshcd_read_device_desc(struct ufs_hba *hba, u8 *buf, u32 size);
static inline bool ufshcd_is_hs_mode(struct ufs_pa_layer_attr *pwr_info)
{
return (pwr_info->pwr_rx == FAST_MODE ||
pwr_info->pwr_rx == FASTAUTO_MODE) &&
(pwr_info->pwr_tx == FAST_MODE ||
pwr_info->pwr_tx == FASTAUTO_MODE);
}
#define ASCII_STD true #define ASCII_STD true
int ufshcd_read_string_desc(struct ufs_hba *hba, int desc_index, u8 *buf, int ufshcd_read_string_desc(struct ufs_hba *hba, int desc_index, u8 *buf,