Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8694f78e authored by Bao D. Nguyen's avatar Bao D. Nguyen
Browse files

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



Add support to query the system suspend and runtime suspend
pm levels from the device tree. Note if the pm level is set to
power down, the device's vcc will be turned
off during system suspend, and the host will do full device
power up sequence during system resume. This may have some impact
on the system resume latency and UFS device life time.

Change-Id: I9f1aaeb14e7947f0a5e474ebb3ea5981e5e502a7
Signed-off-by: default avatarBao D. Nguyen <nguyenb@codeaurora.org>
parent 4027c201
Loading
Loading
Loading
Loading
+24 −0
Original line number Diff line number Diff line
@@ -1598,6 +1598,28 @@ static int ufs_qcom_quirk_host_pa_saveconfigtime(struct ufs_hba *hba)
	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;
}