ath79: phy-ar7200-usb: adapt old behavior of arch/mips/ath79/dev-usb.c
[ Upstream commit 6cca6fffa0 ]
Do not put usb-phy into reset if clearing the usb-phy reset or
setting the suspend_override has failed.
Reorder (de)asserts like in arch/mips/ath79/dev-usb.c.
Add an optional reset_control "usb-phy-analog", which is needed for
ar934x SoCs like in the old mach-driver arch/mips/ath79/dev-usb.c.
Tested-By: Lech Perczak <lech.perczak@gmail.com> [TL-WDR4300]
Signed-off-by: Johann Neuhauser <johann@it-neuhauser.de>
[added reference to upstream commit, Tested-by]
Signed-off-by: Petr Štetiar <ynezz@true.cz>
			
			
This commit is contained in:
		 Johann Neuhauser
					Johann Neuhauser
				
			
				
					committed by
					
						 Petr Štetiar
						Petr Štetiar
					
				
			
			
				
	
			
			
			 Petr Štetiar
						Petr Štetiar
					
				
			
						parent
						
							b2660e67f0
						
					
				
				
					commit
					c9b6bb43ce
				
			| @@ -194,7 +194,7 @@ Signed-off-by: John Crispin <john@phrozen.org> | |||||||
| +MODULE_LICENSE("GPL"); | +MODULE_LICENSE("GPL"); | ||||||
| --- /dev/null | --- /dev/null | ||||||
| +++ b/drivers/phy/phy-ar7200-usb.c | +++ b/drivers/phy/phy-ar7200-usb.c | ||||||
| @@ -0,0 +1,123 @@ | @@ -0,0 +1,135 @@ | ||||||
| +/* | +/* | ||||||
| + * Copyright (C) 2015 Alban Bedel <albeu@free.fr> | + * Copyright (C) 2015 Alban Bedel <albeu@free.fr> | ||||||
| + * | + * | ||||||
| @@ -212,6 +212,7 @@ Signed-off-by: John Crispin <john@phrozen.org> | |||||||
| + | + | ||||||
| +struct ar7200_usb_phy { | +struct ar7200_usb_phy { | ||||||
| +	struct reset_control	*rst_phy; | +	struct reset_control	*rst_phy; | ||||||
|  | +	struct reset_control	*rst_phy_analog; | ||||||
| +	struct reset_control	*suspend_override; | +	struct reset_control	*suspend_override; | ||||||
| +	struct phy		*phy; | +	struct phy		*phy; | ||||||
| +	int			gpio; | +	int			gpio; | ||||||
| @@ -222,12 +223,12 @@ Signed-off-by: John Crispin <john@phrozen.org> | |||||||
| +	struct ar7200_usb_phy *priv = phy_get_drvdata(phy); | +	struct ar7200_usb_phy *priv = phy_get_drvdata(phy); | ||||||
| +	int err = 0; | +	int err = 0; | ||||||
| + | + | ||||||
| +	if (priv->rst_phy) | +	if (priv->suspend_override) | ||||||
| +		err = reset_control_deassert(priv->rst_phy); |  | ||||||
| +	if (!err && priv->suspend_override) |  | ||||||
| +		err = reset_control_assert(priv->suspend_override); | +		err = reset_control_assert(priv->suspend_override); | ||||||
| +	if (err && priv->rst_phy) | +	if (priv->rst_phy) | ||||||
| +		err = reset_control_assert(priv->rst_phy); | +		err |= reset_control_deassert(priv->rst_phy); | ||||||
|  | +	if (priv->rst_phy_analog) | ||||||
|  | +		err |= reset_control_deassert(priv->rst_phy_analog); | ||||||
| + | + | ||||||
| +	return err; | +	return err; | ||||||
| +} | +} | ||||||
| @@ -241,6 +242,8 @@ Signed-off-by: John Crispin <john@phrozen.org> | |||||||
| +		err = reset_control_deassert(priv->suspend_override); | +		err = reset_control_deassert(priv->suspend_override); | ||||||
| +	if (priv->rst_phy) | +	if (priv->rst_phy) | ||||||
| +		err |= reset_control_assert(priv->rst_phy); | +		err |= reset_control_assert(priv->rst_phy); | ||||||
|  | +	if (priv->rst_phy_analog) | ||||||
|  | +		err |= reset_control_assert(priv->rst_phy_analog); | ||||||
| + | + | ||||||
| +	return err; | +	return err; | ||||||
| +} | +} | ||||||
| @@ -266,6 +269,15 @@ Signed-off-by: John Crispin <john@phrozen.org> | |||||||
| +		return PTR_ERR(priv->rst_phy); | +		return PTR_ERR(priv->rst_phy); | ||||||
| +	} | +	} | ||||||
| + | + | ||||||
|  | +	priv->rst_phy_analog = devm_reset_control_get_optional( | ||||||
|  | +		&pdev->dev, "usb-phy-analog"); | ||||||
|  | +	if (IS_ERR(priv->rst_phy_analog)) { | ||||||
|  | +		if (PTR_ERR(priv->rst_phy_analog) == -ENOENT) | ||||||
|  | +			priv->rst_phy_analog = NULL; | ||||||
|  | +		else | ||||||
|  | +			return PTR_ERR(priv->rst_phy_analog); | ||||||
|  | +	} | ||||||
|  | + | ||||||
| +	priv->suspend_override = devm_reset_control_get_optional( | +	priv->suspend_override = devm_reset_control_get_optional( | ||||||
| +		&pdev->dev, "usb-suspend-override"); | +		&pdev->dev, "usb-suspend-override"); | ||||||
| +	if (IS_ERR(priv->suspend_override)) { | +	if (IS_ERR(priv->suspend_override)) { | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user