Merge "scsi: ufs: Support query the spm/rpm level from device tree"

This commit is contained in:
qctecmdr 2020-07-24 05:35:51 -07:00 • committed by Gerrit - the friendly Code Review server
commit bccedceede

View file

@ -1598,6 +1598,28 @@ out:
return err;
}
static inline bool
ufshcd_is_valid_pm_lvl(enum ufs_pm_level lvl)
{
return lvl >= 0 && lvl < UFS_PM_LVL_MAX;
}
static void ufshcd_parse_pm_levels(struct ufs_hba *hba)
{
struct device *dev = hba->dev;
struct device_node *np = dev->of_node;
enum ufs_pm_level rpm_lvl = UFS_PM_LVL_MAX, spm_lvl = UFS_PM_LVL_MAX;
if (!np)
return;
if (!of_property_read_u32(np, "rpm-level", &rpm_lvl) &&
ufshcd_is_valid_pm_lvl(rpm_lvl))
hba->rpm_lvl = rpm_lvl;
if (!of_property_read_u32(np, "spm-level", &spm_lvl) &&
ufshcd_is_valid_pm_lvl(spm_lvl))
hba->spm_lvl = spm_lvl;
}
static int ufs_qcom_apply_dev_quirks(struct ufs_hba *hba)
{
unsigned long flags;
@ -1619,6 +1641,8 @@ static int ufs_qcom_apply_dev_quirks(struct ufs_hba *hba)
if (hba->dev_info.wmanufacturerid == UFS_VENDOR_WDC)
hba->dev_quirks |= UFS_DEVICE_QUIRK_HOST_PA_TACTIVATE;
ufshcd_parse_pm_levels(hba);
return err;
}