diff mbox series

[1/4] ufs: add device_reset callback

Message ID 20240910-topic-ufs-qcom-controller-v1-1-54c0d2231b10@linaro.org
State Accepted
Delegated to: Neil Armstrong
Headers show
Series ufs: add support for Qualcomm UFS Controller | expand

Commit Message

Neil Armstrong Sept. 10, 2024, 9:50 a.m. UTC
Add device_reset op to permit resetting the UFS device if
the UFS controller drivers supports the operation.

Signed-off-by: Neil Armstrong <neil.armstrong@linaro.org>
---
 drivers/ufs/ufs.c | 8 ++++++++
 drivers/ufs/ufs.h | 9 +++++++++
 2 files changed, 17 insertions(+)
diff mbox series

Patch

diff --git a/drivers/ufs/ufs.c b/drivers/ufs/ufs.c
index e34e4586224..de8ba011d57 100644
--- a/drivers/ufs/ufs.c
+++ b/drivers/ufs/ufs.c
@@ -125,6 +125,11 @@  static void ufshcd_print_pwr_info(struct ufs_hba *hba)
 		hba->pwr_info.hs_rate);
 }
 
+static void ufshcd_device_reset(struct ufs_hba *hba)
+{
+	ufshcd_vops_device_reset(hba);
+}
+
 /**
  * ufshcd_ready_for_uic_cmd - Check if controller is ready
  *                            to accept UIC commands
@@ -1997,6 +2002,9 @@  int ufshcd_probe(struct udevice *ufs_dev, struct ufs_hba_ops *hba_ops)
 
 	mb();
 
+	/* Reset the attached device */
+	ufshcd_device_reset(hba);
+
 	err = ufshcd_hba_enable(hba);
 	if (err) {
 		dev_err(hba->dev, "Host controller enable failed\n");
diff --git a/drivers/ufs/ufs.h b/drivers/ufs/ufs.h
index e8a14411560..faaebf1f9f7 100644
--- a/drivers/ufs/ufs.h
+++ b/drivers/ufs/ufs.h
@@ -701,6 +701,7 @@  struct ufs_hba_ops {
 	int (*link_startup_notify)(struct ufs_hba *hba,
 				   enum ufs_notify_change_status);
 	int (*phy_initialization)(struct ufs_hba *hba);
+	int (*device_reset)(struct ufs_hba *hba);
 };
 
 struct ufs_hba {
@@ -878,6 +879,14 @@  static inline int ufshcd_ops_link_startup_notify(struct ufs_hba *hba,
 	return 0;
 }
 
+static inline int ufshcd_vops_device_reset(struct ufs_hba *hba)
+{
+	if (hba->ops && hba->ops->device_reset)
+		return hba->ops->device_reset(hba);
+
+	return 0;
+}
+
 /* Controller UFSHCI version */
 enum {
 	UFSHCI_VERSION_10 = 0x00010000, /* 1.0 */