Skip to contentSkip to conversation

scsi: ufs-mediatek: create device link of reset control

PATCH Applied [email protected] 3 participants 3 messages Jun 2, 2021 – Jun 16, 2021

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 scsi: ufs-mediatek: create device link of reset control

From: Peter Wang <[email protected]>

Mediatek UFS reset function is relied on Reset Control provided by reset-ti-syscon. To make Reset Control work properly, select reset-ti-syscon to ensure it being built with ufs-mediatek together. In addition, establish device link to wait until reset-ti-syscon initialization is done during UFS probing flow.

---
 drivers/scsi/ufs/Kconfig        |    1 +
 drivers/scsi/ufs/ufs-mediatek.c |   29 +++++++++++++++++++++++++++++
 2 files changed, 30 insertions(+)
drivers/scsi/ufs/Kconfig +1 -0
index 07cf415..2d13795 100644
@@ -115,6 +115,7 @@ config SCSI_UFS_MEDIATEK
 	tristate "Mediatek specific hooks to UFS controller platform driver"
 	depends on SCSI_UFSHCD_PLATFORM && ARCH_MEDIATEK
 	select PHY_MTK_UFS
+	select RESET_TI_SYSCON
 	help
 	  This selects the Mediatek specific additions to UFSHCD platform driver.
 	  UFS host on Mediatek needs some vendor specific configuration before
drivers/scsi/ufs/ufs-mediatek.c +29 -0
index a981f26..d27e65e 100644
@@ -1067,9 +1067,38 @@ 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_link *link;
+
+	reset_node = of_find_compatible_node(NULL, NULL,
+					     "ti,syscon-reset");
+	if (!reset_node) {
+		dev_notice(dev, "find ti,syscon-reset fail\n");
+		goto skip_reset;
+	}
+	reset_pdev = of_find_device_by_node(reset_node);
+	if (!reset_pdev) {
+		dev_notice(dev, "find reset_pdev fail\n");
+		goto skip_reset;
+	}
+	link = device_link_add(dev, &reset_pdev->dev,
+		DL_FLAG_AUTOPROBE_CONSUMER);
+	if (!link) {
+		dev_notice(dev, "add reset device_link fail\n");
+		goto skip_reset;
+	}
+	/* supplier is not probed */
+	if (link->status == DL_STATE_DORMANT) {
+		err = -EPROBE_DEFER;
+		goto out;
+	}
 
+skip_reset:
 	/* perform generic probe */
 	err = ufshcd_pltfrm_init(pdev, &ufs_hba_mtk_vops);
+
+out:
 	if (err)
 		dev_info(dev, "probe failed %d\n", err);
 
Signature · 1 line
1.7.9.5
Reviewed-by on v2 1/1
#1 lore raw

Hi Peter,

Quoted 9 lines · On Wed, 2021-06-02 at 10:42 +0800, [email protected] wrote:

From: Peter Wang <[email protected]>

Mediatek UFS reset function is relied on Reset Control provided by reset-ti-syscon. To make Reset Control work properly, select reset-ti-syscon to ensure it being built with ufs-mediatek together. In addition, establish device link to wait until reset-ti-syscon initialization is done during UFS probing flow.

#2 lore raw
In reply to [email protected]
Quoted 6 lines

Mediatek UFS reset function is relied on Reset Control provided by reset-ti-syscon. To make Reset Control work properly, select reset-ti-syscon to ensure it being built with ufs-mediatek together. In addition, establish device link to wait until reset-ti-syscon initialization is done during UFS probing flow.

Applied to 5.14/scsi-staging, thanks!

Signature · 1 line
Martin K. Petersen	Oracle Linux Engineering