106 lines
		
	
	
		
			3.2 KiB
		
	
	
	
		
			Diff
		
	
	
	
	
	
			
		
		
	
	
			106 lines
		
	
	
		
			3.2 KiB
		
	
	
	
		
			Diff
		
	
	
	
	
	
From f2c61b02ed90ebab65ffde60d7349c53e1839dac Mon Sep 17 00:00:00 2001
 | 
						|
From: Amjad Ouled-Ameur <aouledameur@baylibre.com>
 | 
						|
Date: Fri, 13 Nov 2020 07:46:15 +0000
 | 
						|
Subject: [PATCH 37/88] FROMLIST(v1): usb: dwc3: meson-g12a: fix shared reset
 | 
						|
 control use
 | 
						|
 | 
						|
reset_control_(de)assert() calls are called on a shared reset line when
 | 
						|
reset_control_reset has been used. This is not allowed by the reset
 | 
						|
framework.
 | 
						|
 | 
						|
Use reset_control_rearm() call in suspend() and remove() as a way to state
 | 
						|
that the resource is no longer used, hence the shared reset line
 | 
						|
may be triggered again by other devices. Use reset_control_rearm() also in
 | 
						|
case probe fails after reset() has been called.
 | 
						|
 | 
						|
reset_control_rearm() keeps use of triggered_count sane in the reset
 | 
						|
framework, use of reset_control_reset() on shared reset line should be
 | 
						|
balanced with reset_control_rearm().
 | 
						|
 | 
						|
Signed-off-by: Amjad Ouled-Ameur <aouledameur@baylibre.com>
 | 
						|
Reported-by: Jerome Brunet <jbrunet@baylibre.com>
 | 
						|
---
 | 
						|
 drivers/usb/dwc3/dwc3-meson-g12a.c | 19 +++++++++++++------
 | 
						|
 1 file changed, 13 insertions(+), 6 deletions(-)
 | 
						|
 | 
						|
diff --git a/drivers/usb/dwc3/dwc3-meson-g12a.c b/drivers/usb/dwc3/dwc3-meson-g12a.c
 | 
						|
index bdf1f98dfad8..6570146cabc5 100644
 | 
						|
--- a/drivers/usb/dwc3/dwc3-meson-g12a.c
 | 
						|
+++ b/drivers/usb/dwc3/dwc3-meson-g12a.c
 | 
						|
@@ -750,7 +750,7 @@ static int dwc3_meson_g12a_probe(struct platform_device *pdev)
 | 
						|
 
 | 
						|
 	ret = dwc3_meson_g12a_get_phys(priv);
 | 
						|
 	if (ret)
 | 
						|
-		goto err_disable_clks;
 | 
						|
+		goto err_rearm;
 | 
						|
 
 | 
						|
 	ret = priv->drvdata->setup_regmaps(priv, base);
 | 
						|
 	if (ret)
 | 
						|
@@ -759,7 +759,7 @@ static int dwc3_meson_g12a_probe(struct platform_device *pdev)
 | 
						|
 	if (priv->vbus) {
 | 
						|
 		ret = regulator_enable(priv->vbus);
 | 
						|
 		if (ret)
 | 
						|
-			goto err_disable_clks;
 | 
						|
+			goto err_rearm;
 | 
						|
 	}
 | 
						|
 
 | 
						|
 	/* Get dr_mode */
 | 
						|
@@ -772,13 +772,13 @@ static int dwc3_meson_g12a_probe(struct platform_device *pdev)
 | 
						|
 
 | 
						|
 	ret = priv->drvdata->usb_init(priv);
 | 
						|
 	if (ret)
 | 
						|
-		goto err_disable_clks;
 | 
						|
+		goto err_rearm;
 | 
						|
 
 | 
						|
 	/* Init PHYs */
 | 
						|
 	for (i = 0 ; i < PHY_COUNT ; ++i) {
 | 
						|
 		ret = phy_init(priv->phys[i]);
 | 
						|
 		if (ret)
 | 
						|
-			goto err_disable_clks;
 | 
						|
+			goto err_rearm;
 | 
						|
 	}
 | 
						|
 
 | 
						|
 	/* Set PHY Power */
 | 
						|
@@ -816,6 +816,9 @@ static int dwc3_meson_g12a_probe(struct platform_device *pdev)
 | 
						|
 	for (i = 0 ; i < PHY_COUNT ; ++i)
 | 
						|
 		phy_exit(priv->phys[i]);
 | 
						|
 
 | 
						|
+err_rearm:
 | 
						|
+	reset_control_rearm(priv->reset);
 | 
						|
+
 | 
						|
 err_disable_clks:
 | 
						|
 	clk_bulk_disable_unprepare(priv->drvdata->num_clks,
 | 
						|
 				   priv->drvdata->clks);
 | 
						|
@@ -843,6 +846,8 @@ static int dwc3_meson_g12a_remove(struct platform_device *pdev)
 | 
						|
 	pm_runtime_put_noidle(dev);
 | 
						|
 	pm_runtime_set_suspended(dev);
 | 
						|
 
 | 
						|
+	reset_control_rearm(priv->reset);
 | 
						|
+
 | 
						|
 	clk_bulk_disable_unprepare(priv->drvdata->num_clks,
 | 
						|
 				   priv->drvdata->clks);
 | 
						|
 
 | 
						|
@@ -883,7 +888,7 @@ static int __maybe_unused dwc3_meson_g12a_suspend(struct device *dev)
 | 
						|
 		phy_exit(priv->phys[i]);
 | 
						|
 	}
 | 
						|
 
 | 
						|
-	reset_control_assert(priv->reset);
 | 
						|
+	reset_control_rearm(priv->reset);
 | 
						|
 
 | 
						|
 	return 0;
 | 
						|
 }
 | 
						|
@@ -893,7 +898,9 @@ static int __maybe_unused dwc3_meson_g12a_resume(struct device *dev)
 | 
						|
 	struct dwc3_meson_g12a *priv = dev_get_drvdata(dev);
 | 
						|
 	int i, ret;
 | 
						|
 
 | 
						|
-	reset_control_deassert(priv->reset);
 | 
						|
+	ret = reset_control_reset(priv->reset);
 | 
						|
+	if (ret)
 | 
						|
+		return ret;
 | 
						|
 
 | 
						|
 	ret = priv->drvdata->usb_init(priv);
 | 
						|
 	if (ret)
 | 
						|
-- 
 | 
						|
2.17.1
 | 
						|
 |