Skip to contentSkip to conversation

phy: ath79-usb: support the analog reset

PATCH Superseded Rosen Penev 2 participants 2 messages Nov 6

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 phy: ath79-usb: support the analog reset

From AR934x on, the analog part of the USB PHY has its own reset. The old platform code released it after the PHY reset on AR934x, and left it to the bootloader on QCA955x.

Take it as an optional "phy-analog" reset, release it after the PHY one when powering on, and assert it first when powering off. This is the reset handling OpenWrt has used on its AR934x, QCA955x and QCA956x boards.

---
 drivers/phy/qualcomm/phy-ath79-usb.c | 33 +++++++++++++++++++++++++---
 1 file changed, 30 insertions(+), 3 deletions(-)
drivers/phy/qualcomm/phy-ath79-usb.c +30 -3
index 8e9565846b2f..1e7868fc0b5f 100644
@@ -12,6 +12,7 @@
 
 struct ath79_usb_phy {
 	struct reset_control *reset;
+	struct reset_control *analog_reset;
 	/* The suspend override logic is inverted, hence the no prefix
 	 * to make the code a bit easier to understand.
 	 */
@@ -30,7 +31,19 @@ static int ath79_usb_phy_power_on(struct phy *phy)
 	}
 
 	err = reset_control_deassert(priv->reset);
-	if (err && priv->no_suspend_override)
+	if (err)
+		goto err_suspend_override;
+
+	err = reset_control_deassert(priv->analog_reset);
+	if (err) {
+		reset_control_assert(priv->reset);
+		goto err_suspend_override;
+	}
+
+	return 0;
+
+err_suspend_override:
+	if (priv->no_suspend_override)
 		reset_control_deassert(priv->no_suspend_override);
 
 	return err;
@@ -41,14 +54,22 @@ static int ath79_usb_phy_power_off(struct phy *phy)
 	struct ath79_usb_phy *priv = phy_get_drvdata(phy);
 	int err = 0;
 
-	err = reset_control_assert(priv->reset);
+	err = reset_control_assert(priv->analog_reset);
 	if (err)
 		return err;
 
+	err = reset_control_assert(priv->reset);
+	if (err) {
+		reset_control_deassert(priv->analog_reset);
+		return err;
+	}
+
 	if (priv->no_suspend_override) {
 		err = reset_control_deassert(priv->no_suspend_override);
-		if (err)
+		if (err) {
 			reset_control_deassert(priv->reset);
+			reset_control_deassert(priv->analog_reset);
+		}
 	}
 
 	return err;
@@ -78,6 +99,12 @@ static int ath79_usb_phy_probe(struct platform_device *pdev)
 	if (IS_ERR(priv->no_suspend_override))
 		return PTR_ERR(priv->no_suspend_override);
 
+	/* AR934x and later also hold the analog part in reset */
+	priv->analog_reset = devm_reset_control_get_optional(&pdev->dev,
+							     "phy-analog");
+	if (IS_ERR(priv->analog_reset))
+		return PTR_ERR(priv->analog_reset);
+
 	phy = devm_phy_create(&pdev->dev, NULL, &ath79_usb_phy_ops);
 	if (IS_ERR(phy))
 		return PTR_ERR(phy);
Signature · 1 line
2.56.0
#1 lore raw
Quoted 18 lines · Rosen Penev

From AR934x on, the analog part of the USB PHY has its own reset. The old platform code released it after the PHY reset on AR934x, and left it to the bootloader on QCA955x.

Take it as an optional "phy-analog" reset, release it after the PHY one when powering on, and assert it first when powering off. This is the reset handling OpenWrt has used on its AR934x, QCA955x and QCA956x boards.

---
 drivers/phy/qualcomm/phy-ath79-usb.c | 33 +++++++++++++++++++++++++---
 1 file changed, 30 insertions(+), 3 deletions(-)
drivers/phy/qualcomm/phy-ath79-usb.c +0 -0
index 8e9565846b2f..1e7868fc0b5f 100644

[...]

drivers/phy/qualcomm/phy-ath79-usb.c static int ath79_usb_phy_probe(struct platform_device *pdev) · line 104

Quoted 7 lines
drivers/phy/qualcomm/phy-ath79-usb.c +3 -0
@@ -78,6 +99,12 @@ static int ath79_usb_phy_probe(struct platform_device *pdev)
 	if (IS_ERR(priv->no_suspend_override))
 		return PTR_ERR(priv->no_suspend_override);
 
+	/* AR934x and later also hold the analog part in reset */
+	priv->analog_reset = devm_reset_control_get_optional(&pdev->dev,
+							     "phy-analog");

Documentation/devicetree/bindings/phy/qca,ar7100-usb-phy.yaml only specifies "phy" and "suspend-override".

regards
Philipp