Skip to contentSkip to conversation

ufs: host: mediatek: Power Management and Stability Enhancements

PATCH Superseded [email protected] 2 participants 13 messages Aug 25, 2025 – Aug 26, 2025

Subsystems (3)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

[email protected]

author maintainer
#0 lore raw

cover ufs: host: mediatek: Power Management and Stability Enhancements

From: Peter Wang <[email protected]>

These patches collectively enhance the UFS host driver's reliability, power management efficiency, and error recovery mechanisms on MediaTek platforms. They address critical issues and introduce optimizations that improve system stability and performance.

Peter Wang (7):
ufs: host: mediatek: Enhance recovery on hibernation exit failure
ufs: host: mediatek: Enhance recovery on resume failure
ufs: host: mediatek: Correct system PM flow
ufs: host: mediatek: Support UFS PHY runtime PM and correct sequence
ufs: host: mediatek: Disable auto-hibern8 during power mode changes
ufs: host: mediatek: Fix unbalanced IRQ enable issue
ufs: host: mediatek: Fix device power control

Alice Chao (2):
ufs: host: mediatek: Correct resume flow for LPM and MTCMOS
ufs: host: mediatek: Fix adapt issue after PA_Init

Sanjeev Y (1):
ufs: host: mediatek: Return error directly on idle wait timeout

 drivers/ufs/host/ufs-mediatek.c | 176 ++++++++++++++++++++++++++------
 drivers/ufs/host/ufs-mediatek.h |   1 +
 2 files changed, 147 insertions(+), 30 deletions(-)
Signature · 1 line
2.45.2
author maintainer
#1 lore raw

PATCH 1/10 ufs: host: mediatek: Enhance recovery on hibernation exit failure

From: Peter Wang <[email protected]>

This patch improves the recovery process when exiting hibernation mode fails. It triggers the error handler and breaks the suspend operation, ensuring that the system can recover from hibernation errors more effectively. The error handling mechanism is activated by setting 'force_reset' and scheduling the error handler work.

---
 drivers/ufs/host/ufs-mediatek.c | 19 ++++++++++++++++---
 1 file changed, 16 insertions(+), 3 deletions(-)
drivers/ufs/host/ufs-mediatek.c +16 -3
index 5ef0ba4527e4..3882bcc85305 100644
@@ -1686,8 +1686,9 @@ static void ufs_mtk_dev_vreg_set_lpm(struct ufs_hba *hba, bool lpm)
 	}
 }
 
-static void ufs_mtk_auto_hibern8_disable(struct ufs_hba *hba)
+static int ufs_mtk_auto_hibern8_disable(struct ufs_hba *hba)
 {
+	unsigned long flags;
 	int ret;
 
 	/* disable auto-hibern8 */
@@ -1697,8 +1698,20 @@ static void ufs_mtk_auto_hibern8_disable(struct ufs_hba *hba)
 	ufs_mtk_wait_idle_state(hba, 5);
 
 	ret = ufs_mtk_wait_link_state(hba, VS_LINK_UP, 100);
-	if (ret)
+	if (ret) {
 		dev_warn(hba->dev, "exit h8 state fail, ret=%d\n", ret);
+
+		spin_lock_irqsave(hba->host->host_lock, flags);
+		hba->force_reset = true;
+		hba->ufshcd_state = UFSHCD_STATE_EH_SCHEDULED_FATAL;
+		schedule_work(&hba->eh_work);
+		spin_unlock_irqrestore(hba->host->host_lock, flags);
+
+		/* trigger error handler and break suspend */
+		ret = -EBUSY;
+	}
+
+	return ret;
 }
 
 static int ufs_mtk_suspend(struct ufs_hba *hba, enum ufs_pm_op pm_op,
@@ -1709,7 +1722,7 @@ static int ufs_mtk_suspend(struct ufs_hba *hba, enum ufs_pm_op pm_op,
 
 	if (status == PRE_CHANGE) {
 		if (ufshcd_is_auto_hibern8_supported(hba))
-			ufs_mtk_auto_hibern8_disable(hba);
+			return ufs_mtk_auto_hibern8_disable(hba);
 		return 0;
 	}
 
Signature · 1 line
2.45.2
#2 lore raw

Re: [PATCH v1 01/10] ufs: host: mediatek: Enhance recovery on hibernation exit failure

Quoted 10 lines · On 8/25/25 3:10 AM, [email protected] wrote:
drivers/ufs/host/ufs-mediatek.c +4 -1
@@ -1697,8 +1698,20 @@ static void ufs_mtk_auto_hibern8_disable(struct ufs_hba *hba)
  	ufs_mtk_wait_idle_state(hba, 5);
 
  	ret = ufs_mtk_wait_link_state(hba, VS_LINK_UP, 100);
-	if (ret)
+	if (ret) {
  		dev_warn(hba->dev, "exit h8 state fail, ret=%d\n", ret);
+
+		spin_lock_irqsave(hba->host->host_lock, flags);
+		hba->force_reset = true;

drivers/ufs/host/ufs-mediatek.c static void ufs_mtk_auto_hibern8_disable(struct ufs_hba *hba) · line 1715

Quoted 10 lines
drivers/ufs/host/ufs-mediatek.c +9 -0
+		hba->ufshcd_state = UFSHCD_STATE_EH_SCHEDULED_FATAL;
+		schedule_work(&hba->eh_work);
+		spin_unlock_irqrestore(hba->host->host_lock, flags);
+
+		/* trigger error handler and break suspend */
+		ret = -EBUSY;
+	}
+
+	return ret;
  }

Hi Peter,

UFS host drivers shouldn't touch hba->force_reset, hba->ufshcd_state nor hba->eh_work. Please add a helper function in the UFS driver core and export it.

Thanks,

Bart.

author maintainer
#3 lore raw

Re: [PATCH v1 01/10] ufs: host: mediatek: Enhance recovery on hibernation exit failure

Quoted 4 lines · Bart Van Assche

Hi Peter,

Quoted 8 lines

UFS host drivers shouldn't touch hba->force_reset, hba->ufshcd_state nor
hba->eh_work. Please add a helper function in the UFS driver core and export it.

Thanks,

Bart.

Hi Bart,

I will export ufshcd_force_error_recovery in the next version. Thank you for your suggestion.

Peter

author maintainer
#4 lore raw

PATCH 2/10 ufs: host: mediatek: Enhance recovery on resume failure

In reply to [email protected]

From: Peter Wang <[email protected]>

This patch improves the recovery process when a resume operation fails. If both the resume and recovery fail, it logs the device's power status and returns 0 to prevent I/O hang..

---
 drivers/ufs/host/ufs-mediatek.c | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)
drivers/ufs/host/ufs-mediatek.c +14 -1
index 3882bcc85305..d396878cc9a4 100644
@@ -1780,8 +1780,21 @@ static int ufs_mtk_resume(struct ufs_hba *hba, enum ufs_pm_op pm_op)
 	}
 
 	return 0;
+
 fail:
-	return ufshcd_link_recovery(hba);
+	/*
+	 * Check if the platform (parent) device has resumed, and ensure that
+	 * power, clock, and MTCMOS are all turned on.
+	 */
+	err = ufshcd_link_recovery(hba);
+	if (err) {
+		dev_err(hba->dev, "Device PM: req=%d, status:%d, err:%d\n",
+			hba->dev->power.request,
+			hba->dev->power.runtime_status,
+			hba->dev->power.runtime_error);
+	}
+
+	return 0; /* Cannot return a failure, otherwise, the I/O will hang. */
 }
 
 static void ufs_mtk_dbg_register_dump(struct ufs_hba *hba)
Signature · 1 line
2.45.2
author maintainer
#5 lore raw

PATCH 3/10 ufs: host: mediatek: Correct system PM flow

In reply to [email protected]

From: Peter Wang <[email protected]>

This patch refines the system power management (PM) flow by skipping low power mode (LPM) and MTCMOS settings if runtime PM has already been applied. This optimization prevents redundant operations, ensuring a more efficient PM process.

---
 drivers/ufs/host/ufs-mediatek.c | 17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)
drivers/ufs/host/ufs-mediatek.c +14 -3
index d396878cc9a4..1a8848246611 100644
@@ -2309,27 +2309,38 @@ static int ufs_mtk_system_suspend(struct device *dev)
 
 	ret = ufshcd_system_suspend(dev);
 	if (ret)
-		return ret;
+		goto out;
+
+	if (pm_runtime_suspended(hba->dev))
+		goto out;
 
 	ufs_mtk_dev_vreg_set_lpm(hba, true);
 
 	if (ufs_mtk_is_rtff_mtcmos(hba))
 		ufs_mtk_mtcmos_ctrl(false, res);
 
-	return 0;
+out:
+	return ret;
 }
 
 static int ufs_mtk_system_resume(struct device *dev)
 {
+	int ret = 0;
 	struct ufs_hba *hba = dev_get_drvdata(dev);
 	struct arm_smccc_res res;
 
+	if (pm_runtime_suspended(hba->dev))
+		goto out;
+
 	ufs_mtk_dev_vreg_set_lpm(hba, false);
 
 	if (ufs_mtk_is_rtff_mtcmos(hba))
 		ufs_mtk_mtcmos_ctrl(true, res);
 
-	return ufshcd_system_resume(dev);
+out:
+	ret = ufshcd_system_resume(dev);
+
+	return ret;
 }
 #endif
 
Signature · 1 line
2.45.2
author maintainer
#6 lore raw

PATCH 4/10 ufs: host: mediatek: Correct resume flow for LPM and MTCMOS

In reply to [email protected]

From: Alice Chao <[email protected]>

This patch corrects the system resume flow by ensuring that MTCMOS is turned on before setting LPM to false.
During system suspend, LPM is set to true and MTCMOS is turned off. The updated resume sequence ensures proper power management and system stability.

---
 drivers/ufs/host/ufs-mediatek.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/ufs/host/ufs-mediatek.c +2 -2
index 1a8848246611..9c90d804aaa0 100644
@@ -2332,11 +2332,11 @@ static int ufs_mtk_system_resume(struct device *dev)
 	if (pm_runtime_suspended(hba->dev))
 		goto out;
 
-	ufs_mtk_dev_vreg_set_lpm(hba, false);
-
 	if (ufs_mtk_is_rtff_mtcmos(hba))
 		ufs_mtk_mtcmos_ctrl(true, res);
 
+	ufs_mtk_dev_vreg_set_lpm(hba, false);
+
 out:
 	ret = ufshcd_system_resume(dev);
 
Signature · 1 line
2.45.2
author maintainer
#7 lore raw

PATCH 5/10 ufs: host: mediatek: Support UFS PHY runtime PM and correct sequence

In reply to [email protected]

From: Peter Wang <[email protected]>

This patch adds support for UFS PHY runtime power management by probing the PHY device and enabling its runtime PM. It ensures the correct sequence of operations during suspend and resume:
PHY suspend -> UFS suspend -> UFS resume -> PHY resume. This enhancement improves power management efficiency and system stability.

---
 drivers/ufs/host/ufs-mediatek.c | 53 +++++++++++++++++++++++++++++----
 drivers/ufs/host/ufs-mediatek.h |  1 +
 2 files changed, 48 insertions(+), 6 deletions(-)
drivers/ufs/host/ufs-mediatek.c +47 -6
index 9c90d804aaa0..f9def0b68921 100644
@@ -2248,10 +2248,12 @@ static const struct ufs_hba_variant_ops ufs_hba_mtk_vops = {
 static int ufs_mtk_probe(struct platform_device *pdev)
 {
 	int err;
-	struct device *dev = &pdev->dev;
-	struct device_node *reset_node;
-	struct platform_device *reset_pdev;
+	struct device *dev = &pdev->dev, *phy_dev = NULL;
+	struct device_node *reset_node, *phy_node = NULL;
+	struct platform_device *reset_pdev, *phy_pdev = NULL;
 	struct device_link *link;
+	struct ufs_hba *hba;
+	struct ufs_mtk_host *host;
 
 	reset_node = of_find_compatible_node(NULL, NULL,
 					     "ti,syscon-reset");
@@ -2278,13 +2280,44 @@ static int ufs_mtk_probe(struct platform_device *pdev)
 	}
 
 skip_reset:
+	/* find phy node */
+	phy_node = of_parse_phandle(dev->of_node, "phys", 0);
+
+	if (phy_node) {
+		phy_pdev = of_find_device_by_node(phy_node);
+		if (!phy_pdev)
+			goto skip_phy;
+		phy_dev = &phy_pdev->dev;
+
+		pm_runtime_set_active(phy_dev);
+		pm_runtime_enable(phy_dev);
+		pm_runtime_get_sync(phy_dev);
+
+		put_device(phy_dev);
+		dev_info(dev, "phys node found\n");
+	} else {
+		dev_notice(dev, "phys node not found\n");
+	}
+
+skip_phy:
 	/* perform generic probe */
 	err = ufshcd_pltfrm_init(pdev, &ufs_hba_mtk_vops);
-
-out:
-	if (err)
+	if (err) {
 		dev_err(dev, "probe failed %d\n", err);
+		goto out;
+	}
+
+	hba = platform_get_drvdata(pdev);
+	if (!hba)
+		goto out;
+
+	if (phy_node && phy_dev) {
+		host = ufshcd_get_variant(hba);
+		host->phy_dev = phy_dev;
+	}
 
+out:
+	of_node_put(phy_node);
 	of_node_put(reset_node);
 	return err;
 }
@@ -2348,6 +2381,7 @@ static int ufs_mtk_system_resume(struct device *dev)
 static int ufs_mtk_runtime_suspend(struct device *dev)
 {
 	struct ufs_hba *hba = dev_get_drvdata(dev);
+	struct ufs_mtk_host *host = ufshcd_get_variant(hba);
 	struct arm_smccc_res res;
 	int ret = 0;
 
@@ -2360,17 +2394,24 @@ static int ufs_mtk_runtime_suspend(struct device *dev)
 	if (ufs_mtk_is_rtff_mtcmos(hba))
 		ufs_mtk_mtcmos_ctrl(false, res);
 
+	if (host->phy_dev)
+		pm_runtime_put_sync(host->phy_dev);
+
 	return 0;
 }
 
 static int ufs_mtk_runtime_resume(struct device *dev)
 {
 	struct ufs_hba *hba = dev_get_drvdata(dev);
+	struct ufs_mtk_host *host = ufshcd_get_variant(hba);
 	struct arm_smccc_res res;
 
 	if (ufs_mtk_is_rtff_mtcmos(hba))
 		ufs_mtk_mtcmos_ctrl(true, res);
 
+	if (host->phy_dev)
+		pm_runtime_get_sync(host->phy_dev);
+
 	ufs_mtk_dev_vreg_set_lpm(hba, false);
 
 	return ufshcd_runtime_resume(dev);
drivers/ufs/host/ufs-mediatek.h +1 -0
index e46dc5fa209d..dfbf78bd8664 100644
@@ -193,6 +193,7 @@ struct ufs_mtk_host {
 	bool is_mcq_intr_enabled;
 	int mcq_nr_intr;
 	struct ufs_mtk_mcq_intr_info mcq_intr_info[UFSHCD_MAX_Q_NR];
+	struct device *phy_dev;
 };
 
 /* MTK delay of autosuspend: 500 ms */
Signature · 1 line
2.45.2
author maintainer
#8 lore raw

PATCH 6/10 ufs: host: mediatek: Disable auto-hibern8 during power mode changes

In reply to [email protected]

From: Peter Wang <[email protected]>

This patch ensures that auto-hibern8 is disabled when changing power modes to prevent unintended entry into auto-hibern8 during these transitions. The original auto-hibern8 timer value is restored after the power mode change is complete, maintaining system stability and preventing potential issues during power state transitions.

---
 drivers/ufs/host/ufs-mediatek.c | 63 ++++++++++++++++++---------------
 1 file changed, 35 insertions(+), 28 deletions(-)
drivers/ufs/host/ufs-mediatek.c +35 -28
index f9def0b68921..b1ea998d3218 100644
@@ -1429,19 +1429,54 @@ static int ufs_mtk_pre_pwr_change(struct ufs_hba *hba,
 	return ret;
 }
 
+static int ufs_mtk_auto_hibern8_disable(struct ufs_hba *hba)
+{
+	unsigned long flags;
+	int ret;
+
+	/* disable auto-hibern8 */
+	ufshcd_writel(hba, 0, REG_AUTO_HIBERNATE_IDLE_TIMER);
+
+	/* wait host return to idle state when auto-hibern8 off */
+	ufs_mtk_wait_idle_state(hba, 5);
+
+	ret = ufs_mtk_wait_link_state(hba, VS_LINK_UP, 100);
+	if (ret) {
+		dev_warn(hba->dev, "exit h8 state fail, ret=%d\n", ret);
+
+		spin_lock_irqsave(hba->host->host_lock, flags);
+		hba->force_reset = true;
+		hba->ufshcd_state = UFSHCD_STATE_EH_SCHEDULED_FATAL;
+		schedule_work(&hba->eh_work);
+		spin_unlock_irqrestore(hba->host->host_lock, flags);
+
+		/* trigger error handler and break suspend */
+		ret = -EBUSY;
+	}
+
+	return ret;
+}
+
 static int ufs_mtk_pwr_change_notify(struct ufs_hba *hba,
 				enum ufs_notify_change_status stage,
 				const struct ufs_pa_layer_attr *dev_max_params,
 				struct ufs_pa_layer_attr *dev_req_params)
 {
 	int ret = 0;
+	static u32 reg;
 
 	switch (stage) {
 	case PRE_CHANGE:
+		if (ufshcd_is_auto_hibern8_supported(hba)) {
+			reg = ufshcd_readl(hba, REG_AUTO_HIBERNATE_IDLE_TIMER);
+			ufs_mtk_auto_hibern8_disable(hba);
+		}
 		ret = ufs_mtk_pre_pwr_change(hba, dev_max_params,
 					     dev_req_params);
 		break;
 	case POST_CHANGE:
+		if (ufshcd_is_auto_hibern8_supported(hba))
+			ufshcd_writel(hba, reg, REG_AUTO_HIBERNATE_IDLE_TIMER);
 		break;
 	default:
 		ret = -EINVAL;
@@ -1686,34 +1721,6 @@ static void ufs_mtk_dev_vreg_set_lpm(struct ufs_hba *hba, bool lpm)
 	}
 }
 
-static int ufs_mtk_auto_hibern8_disable(struct ufs_hba *hba)
-{
-	unsigned long flags;
-	int ret;
-
-	/* disable auto-hibern8 */
-	ufshcd_writel(hba, 0, REG_AUTO_HIBERNATE_IDLE_TIMER);
-
-	/* wait host return to idle state when auto-hibern8 off */
-	ufs_mtk_wait_idle_state(hba, 5);
-
-	ret = ufs_mtk_wait_link_state(hba, VS_LINK_UP, 100);
-	if (ret) {
-		dev_warn(hba->dev, "exit h8 state fail, ret=%d\n", ret);
-
-		spin_lock_irqsave(hba->host->host_lock, flags);
-		hba->force_reset = true;
-		hba->ufshcd_state = UFSHCD_STATE_EH_SCHEDULED_FATAL;
-		schedule_work(&hba->eh_work);
-		spin_unlock_irqrestore(hba->host->host_lock, flags);
-
-		/* trigger error handler and break suspend */
-		ret = -EBUSY;
-	}
-
-	return ret;
-}
-
 static int ufs_mtk_suspend(struct ufs_hba *hba, enum ufs_pm_op pm_op,
 	enum ufs_notify_change_status status)
 {
Signature · 1 line
2.45.2
author maintainer
#9 lore raw

PATCH 7/10 ufs: host: mediatek: Return error directly on idle wait timeout

In reply to [email protected]

From: Sanjeev Y <[email protected]>

This patch optimizes the recovery flow by returning an error code immediately if a wait idle timeout occurs, rather than proceeding to wait for the link to reach the up state. This change shortens the recovery process and improves error handling efficiency when idle state transitions fail.

---
 drivers/ufs/host/ufs-mediatek.c | 20 ++++++++++++++++----
 1 file changed, 16 insertions(+), 4 deletions(-)
drivers/ufs/host/ufs-mediatek.c +16 -4
index b1ea998d3218..5037bf2ae5c0 100644
@@ -416,7 +416,7 @@ static void ufs_mtk_dbg_sel(struct ufs_hba *hba)
 	}
 }
 
-static void ufs_mtk_wait_idle_state(struct ufs_hba *hba,
+static int ufs_mtk_wait_idle_state(struct ufs_hba *hba,
 			    unsigned long retry_ms)
 {
 	u64 timeout, time_checked;
@@ -452,8 +452,12 @@ static void ufs_mtk_wait_idle_state(struct ufs_hba *hba,
 			break;
 	} while (time_checked < timeout);
 
-	if (wait_idle && sm != VS_HCE_BASE)
+	if (wait_idle && sm != VS_HCE_BASE) {
 		dev_info(hba->dev, "wait idle tmo: 0x%x\n", val);
+		return -ETIMEDOUT;
+	}
+
+	return 0;
 }
 
 static int ufs_mtk_wait_link_state(struct ufs_hba *hba, u32 state,
@@ -1438,9 +1442,13 @@ static int ufs_mtk_auto_hibern8_disable(struct ufs_hba *hba)
 	ufshcd_writel(hba, 0, REG_AUTO_HIBERNATE_IDLE_TIMER);
 
 	/* wait host return to idle state when auto-hibern8 off */
-	ufs_mtk_wait_idle_state(hba, 5);
+	ret = ufs_mtk_wait_idle_state(hba, 5);
+	if (ret)
+		goto out;
 
 	ret = ufs_mtk_wait_link_state(hba, VS_LINK_UP, 100);
+
+out:
 	if (ret) {
 		dev_warn(hba->dev, "exit h8 state fail, ret=%d\n", ret);
 
@@ -1619,7 +1627,11 @@ static int ufs_mtk_link_set_hpm(struct ufs_hba *hba)
 		return err;
 
 	/* Check link state to make sure exit h8 success */
-	ufs_mtk_wait_idle_state(hba, 5);
+	err = ufs_mtk_wait_idle_state(hba, 5);
+	if (err) {
+		dev_warn(hba->dev, "wait idle fail, err=%d\n", err);
+		return err;
+	}
 	err = ufs_mtk_wait_link_state(hba, VS_LINK_UP, 100);
 	if (err) {
 		dev_warn(hba->dev, "exit h8 state fail, err=%d\n", err);
Signature · 1 line
2.45.2
author maintainer
#10 lore raw

PATCH 8/10 ufs: host: mediatek: Fix adapt issue after PA_Init

In reply to [email protected]

From: Alice Chao <[email protected]>

This patch addresses the issue where the host does not send adapt to the device after PA_Init success.
It ensures that the adapt process is correctly initiated for devices with IP version MT6899 and above, resolving communication issues between the host and device.

---
 drivers/ufs/host/ufs-mediatek.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
drivers/ufs/host/ufs-mediatek.c +11 -0
index 5037bf2ae5c0..d12dd0edd389 100644
@@ -1556,8 +1556,19 @@ static int ufs_mtk_pre_link(struct ufs_hba *hba)
 
 	return ret;
 }
+
 static void ufs_mtk_post_link(struct ufs_hba *hba)
 {
+	struct ufs_mtk_host *host = ufshcd_get_variant(hba);
+	u32 tmp;
+
+	/* fix device PA_INIT no adapt */
+	if (host->ip_ver >= IP_VER_MT6899) {
+		ufshcd_dme_get(hba, UIC_ARG_MIB(VS_DEBUGOMC), &tmp);
+		tmp |= 0x100;
+		ufshcd_dme_set(hba, UIC_ARG_MIB(VS_DEBUGOMC), tmp);
+	}
+
 	/* enable unipro clock gating feature */
 	ufs_mtk_cfg_unipro_cg(hba, true);
 }
Signature · 1 line
2.45.2
author maintainer
#11 lore raw

PATCH 9/10 ufs: host: mediatek: Fix unbalanced IRQ enable issue

In reply to [email protected]

From: Peter Wang <[email protected]>

This patch resolves the issue of unbalanced IRQ enablement by setting the 'is_mcq_intr_enabled' flag after the first successful IRQ enablement. This ensures proper tracking of the IRQ state and prevents potential mismatches in IRQ handling.

---
 drivers/ufs/host/ufs-mediatek.c | 1 +
 1 file changed, 1 insertion(+)
drivers/ufs/host/ufs-mediatek.c +1 -0
index d12dd0edd389..934c643633d3 100644
@@ -2195,6 +2195,7 @@ static int ufs_mtk_config_mcq_irq(struct ufs_hba *hba)
 			return ret;
 		}
 	}
+	host->is_mcq_intr_enabled = true;
 
 	return 0;
 }
Signature · 1 line
2.45.2
author maintainer
#12 lore raw

PATCH 10/10 ufs: host: mediatek: Fix device power control

In reply to [email protected]

From: Peter Wang <[email protected]>

This patch adjusts the timing of device power control to ensure that low power mode (LPM) is entered only after VCC is turned off. This change prevents VCCQ/VCCQ2 from entering LPM prematurely, ensuring proper power management and device stability.

---
 drivers/ufs/host/ufs-mediatek.c | 7 +++++++
 1 file changed, 7 insertions(+)
drivers/ufs/host/ufs-mediatek.c +7 -0
index 934c643633d3..ec45a40f04d0 100644
@@ -2347,6 +2347,13 @@ static int ufs_mtk_probe(struct platform_device *pdev)
 		host->phy_dev = phy_dev;
 	}
 
+	/*
+	 * Because the default power setting of VSx (the upper layer of
+	 * VCCQ/VCCQ2) is HWLP, we need to prevent VCCQ/VCCQ2 from
+	 * entering LPM.
+	 */
+	ufs_mtk_dev_vreg_set_lpm(hba, false);
+
 out:
 	of_node_put(phy_node);
 	of_node_put(reset_node);
Signature · 1 line
2.45.2