diff options
| author | Subhash Jadavani <subhashj@codeaurora.org> | 2015-01-28 15:39:13 -0800 |
|---|---|---|
| committer | David Keitel <dkeitel@codeaurora.org> | 2016-03-22 10:58:43 -0700 |
| commit | 1811e9b0bb3f9233cecef815f338ce029fb9681e (patch) | |
| tree | 311bf080f8b93473494fd8c893b7d20bf7e3ae0b | |
| parent | 8ef05b55a0303f01b8c020b877797224aca3a834 (diff) | |
scsi: ufs: add pre & post status change to clk_scale_notify ops
Some UFS host controller implementation may require vendor specific
configurations before and after changing the UFS controller
clock frequencies. This change adds the support for this.
Change-Id: Id4171ef8786fa6883d9af914dc2a675cb62c6a72
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
[venkatg@codeaurora.org: resolved trivial merge conflicts]
Signed-off-by: Venkat Gopalakrishnan <venkatg@codeaurora.org>
| -rw-r--r-- | drivers/scsi/ufs/ufs-qcom.c | 7 | ||||
| -rw-r--r-- | drivers/scsi/ufs/ufshcd.c | 54 |
2 files changed, 48 insertions, 13 deletions
diff --git a/drivers/scsi/ufs/ufs-qcom.c b/drivers/scsi/ufs/ufs-qcom.c index cdde478eb511..f2d0fc1fdaf0 100644 --- a/drivers/scsi/ufs/ufs-qcom.c +++ b/drivers/scsi/ufs/ufs-qcom.c @@ -1387,18 +1387,21 @@ static void ufs_qcom_exit(struct ufs_hba *hba) } -void ufs_qcom_clk_scale_notify(struct ufs_hba *hba) +int ufs_qcom_clk_scale_notify(struct ufs_hba *hba, + bool scale_up, bool status) { struct ufs_qcom_host *host = hba->priv; struct ufs_pa_layer_attr *dev_req_params = &host->dev_req_params; if (!dev_req_params) - return; + return 0; ufs_qcom_cfg_timers(hba, dev_req_params->gear_rx, dev_req_params->pwr_rx, dev_req_params->hs_rate, false); ufs_qcom_update_bus_bw_vote(host); + + return 0; } /* diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index f9ac27847f8c..a1e659750731 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -997,14 +997,14 @@ static int ufshcd_send_request_sense_all_lus(struct ufs_hba *hba) } /** - * ufshcd_scale_clks - scale up or scale down UFS controller clocks + * ufshcd_set_clk_freq - set UFS controller clock frequencies * @hba: per adapter instance - * @scale_up: True if scaling up and false if scaling down + * @scale_up: If True, set max possible frequency othewise set low frequency * * Returns 0 if successful * Returns < 0 for any other errors */ -static int ufshcd_scale_clks(struct ufs_hba *hba, bool scale_up) +static int ufshcd_set_clk_freq(struct ufs_hba *hba, bool scale_up) { int ret = 0; struct ufs_clk_info *clki; @@ -1058,6 +1058,39 @@ out: return ret; } +/** + * ufshcd_scale_clks - scale up or scale down UFS controller clocks + * @hba: per adapter instance + * @scale_up: True if scaling up and false if scaling down + * + * Returns 0 if successful + * Returns < 0 for any other errors + */ +static int ufshcd_scale_clks(struct ufs_hba *hba, bool scale_up) +{ + int ret = 0; + + if (hba->vops && hba->vops->clk_scale_notify) { + ret = hba->vops->clk_scale_notify(hba, scale_up, PRE_CHANGE); + if (ret) + return ret; + } + + ret = ufshcd_set_clk_freq(hba, scale_up); + if (ret) + return ret; + + if (hba->vops && hba->vops->clk_scale_notify) { + ret = hba->vops->clk_scale_notify(hba, scale_up, POST_CHANGE); + if (ret) { + ufshcd_set_clk_freq(hba, !scale_up); + return ret; + } + } + + return ret; +} + static void ufshcd_ungate_work(struct work_struct *work) { int ret; @@ -5931,7 +5964,7 @@ static int ufshcd_host_reset_and_restore(struct ufs_hba *hba) spin_unlock_irqrestore(hba->host->host_lock, flags); /* scale up clocks to max frequency before full reinitialization */ - ufshcd_scale_clks(hba, true); + ufshcd_set_clk_freq(hba, true); err = ufshcd_hba_enable(hba); if (err) @@ -8195,11 +8228,8 @@ static int ufshcd_devfreq_scale(struct ufs_hba *hba, bool scale_up) } ret = ufshcd_scale_clks(hba, scale_up); - if (ret) { - if (!scale_up) - ufshcd_scale_gear(hba, true); - goto out; - } + if (ret) + goto scale_up_gear; /* scale up the gear after scaling up clocks */ if (scale_up) { @@ -8209,9 +8239,11 @@ static int ufshcd_devfreq_scale(struct ufs_hba *hba, bool scale_up) goto out; } } + goto out; - ret = ufshcd_vops_clk_scale_notify(hba, scale_up, POST_CHANGE); - +scale_up_gear: + if (!scale_up) + ufshcd_scale_gear(hba, true); out: return ret; } |
