]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
scsi: ufs: core: Add a vop to map clock frequency to gear speed
authorCan Guo <quic_cang@quicinc.com>
Thu, 13 Feb 2025 08:00:03 +0000 (16:00 +0800)
committerMartin K. Petersen <martin.petersen@oracle.com>
Fri, 21 Feb 2025 02:53:49 +0000 (21:53 -0500)
Add a vop to map UFS host controller clock frequencies to the corresponding
maximum supported UFS high speed gear speeds. During clock scaling, we can
map the target clock frequency, demanded by devfreq, to the maximum
supported gear speed, so that devfreq can scale the gear to the highest
gear speed supported at the target clock frequency, instead of just scaling
up/down the gear between the min and max gear speeds.

Co-developed-by: Ziqi Chen <quic_ziqichen@quicinc.com>
Signed-off-by: Ziqi Chen <quic_ziqichen@quicinc.com>
Signed-off-by: Can Guo <quic_cang@quicinc.com>
Link: https://lore.kernel.org/r/20250213080008.2984807-4-quic_ziqichen@quicinc.com
Reviewed-by: Bean Huo <beanhuo@micron.com>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Tested-by: Neil Armstrong <neil.armstrong@linaro.org>
Reviewed-by: Peter Wang <peter.wang@mediatek.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/ufs/core/ufshcd-priv.h
include/ufs/ufshcd.h

index dbdcf5219f2672ed8e831d3709770b7f3c8b0730..37851efa6d5a6ba0410004b3245a4acefb51499e 100644 (file)
@@ -271,6 +271,14 @@ static inline int ufshcd_mcq_vops_config_esi(struct ufs_hba *hba)
        return -EOPNOTSUPP;
 }
 
+static inline u32 ufshcd_vops_freq_to_gear_speed(struct ufs_hba *hba, unsigned long freq)
+{
+       if (hba->vops && hba->vops->freq_to_gear_speed)
+               return hba->vops->freq_to_gear_speed(hba, freq);
+
+       return 0;
+}
+
 extern const struct ufs_pm_lvl_states ufs_pm_lvl_states[];
 
 /**
index e069fc6bc35caa5fa2d89d8243771b1bf4899fe6..199c2cec29d0b598d6ce91e99c4eb9eeb9bb7060 100644 (file)
@@ -336,6 +336,7 @@ struct ufs_pwr_mode_info {
  * @get_outstanding_cqs: called to get outstanding completion queues
  * @config_esi: called to config Event Specific Interrupt
  * @config_scsi_dev: called to configure SCSI device parameters
+ * @freq_to_gear_speed: called to map clock frequency to the max supported gear speed
  */
 struct ufs_hba_variant_ops {
        const char *name;
@@ -384,6 +385,7 @@ struct ufs_hba_variant_ops {
                                       unsigned long *ocqs);
        int     (*config_esi)(struct ufs_hba *hba);
        void    (*config_scsi_dev)(struct scsi_device *sdev);
+       u32     (*freq_to_gear_speed)(struct ufs_hba *hba, unsigned long freq);
 };
 
 /* clock gating state  */