linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] phy: sun4i-usb: Make sure to disable PHY0 passby for peripheral mode
@ 2019-03-14 13:05 Paul Kocialkowski
  2019-04-15 11:17 ` Paul Kocialkowski
  0 siblings, 1 reply; 3+ messages in thread
From: Paul Kocialkowski @ 2019-03-14 13:05 UTC (permalink / raw)
  To: linux-kernel, linux-arm-kernel, linux-sunxi
  Cc: Kishon Vijay Abraham I, Maxime Ripard, Chen-Yu Tsai,
	Thomas Petazzoni, Jagan Teki, Hans de Goede, Paul Kocialkowski

On platforms where the MUSB and HCI controllers share PHY0, PHY passby
is required when using the HCI controller with the PHY, but it must be
disabled when the MUSB controller is used instead.

Without this, PHY0 passby is always enabled, which results in broken
peripheral mode on such platforms (e.g. H3/H5).

Fixes: ba4bdc9e1dc0 ("PHY: sunxi: Add driver for sunxi usb phy")

Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
---
 drivers/phy/allwinner/phy-sun4i-usb.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/phy/allwinner/phy-sun4i-usb.c b/drivers/phy/allwinner/phy-sun4i-usb.c
index 5163097b43df..7b23920e0068 100644
--- a/drivers/phy/allwinner/phy-sun4i-usb.c
+++ b/drivers/phy/allwinner/phy-sun4i-usb.c
@@ -551,6 +551,7 @@ static void sun4i_usb_phy0_id_vbus_det_scan(struct work_struct *work)
 	struct sun4i_usb_phy_data *data =
 		container_of(work, struct sun4i_usb_phy_data, detect.work);
 	struct phy *phy0 = data->phys[0].phy;
+	struct sun4i_usb_phy *phy = phy_get_drvdata(phy0);
 	bool force_session_end, id_notify = false, vbus_notify = false;
 	int id_det, vbus_det;
 
@@ -607,6 +608,9 @@ static void sun4i_usb_phy0_id_vbus_det_scan(struct work_struct *work)
 			mutex_unlock(&phy0->mutex);
 		}
 
+		/* Enable PHY0 passby for host mode only. */
+		sun4i_usb_phy_passby(phy, !id_det);
+
 		/* Re-route PHY0 if necessary */
 		if (data->cfg->phy0_dual_route)
 			sun4i_usb_phy0_reroute(data, id_det);
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] phy: sun4i-usb: Make sure to disable PHY0 passby for peripheral mode
  2019-03-14 13:05 [PATCH] phy: sun4i-usb: Make sure to disable PHY0 passby for peripheral mode Paul Kocialkowski
@ 2019-04-15 11:17 ` Paul Kocialkowski
  2019-04-17  5:32   ` Kishon Vijay Abraham I
  0 siblings, 1 reply; 3+ messages in thread
From: Paul Kocialkowski @ 2019-04-15 11:17 UTC (permalink / raw)
  To: linux-kernel, linux-arm-kernel, linux-sunxi
  Cc: Kishon Vijay Abraham I, Maxime Ripard, Chen-Yu Tsai,
	Thomas Petazzoni, Jagan Teki, Hans de Goede

Hi,

Le jeudi 14 mars 2019 à 14:05 +0100, Paul Kocialkowski a écrit :
> On platforms where the MUSB and HCI controllers share PHY0, PHY passby
> is required when using the HCI controller with the PHY, but it must be
> disabled when the MUSB controller is used instead.
> 
> Without this, PHY0 passby is always enabled, which results in broken
> peripheral mode on such platforms (e.g. H3/H5).
> 
> Fixes: ba4bdc9e1dc0 ("PHY: sunxi: Add driver for sunxi usb phy")

Does anyone have feedback about this? I was hoping to get it merged
rather soon since it pretty much fixes USB gadget on H3/R40/V3/V3s.

Cheers,

Paul

> Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
> ---
>  drivers/phy/allwinner/phy-sun4i-usb.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/drivers/phy/allwinner/phy-sun4i-usb.c b/drivers/phy/allwinner/phy-sun4i-usb.c
> index 5163097b43df..7b23920e0068 100644
> --- a/drivers/phy/allwinner/phy-sun4i-usb.c
> +++ b/drivers/phy/allwinner/phy-sun4i-usb.c
> @@ -551,6 +551,7 @@ static void sun4i_usb_phy0_id_vbus_det_scan(struct work_struct *work)
>  	struct sun4i_usb_phy_data *data =
>  		container_of(work, struct sun4i_usb_phy_data, detect.work);
>  	struct phy *phy0 = data->phys[0].phy;
> +	struct sun4i_usb_phy *phy = phy_get_drvdata(phy0);
>  	bool force_session_end, id_notify = false, vbus_notify = false;
>  	int id_det, vbus_det;
>  
> @@ -607,6 +608,9 @@ static void sun4i_usb_phy0_id_vbus_det_scan(struct work_struct *work)
>  			mutex_unlock(&phy0->mutex);
>  		}
>  
> +		/* Enable PHY0 passby for host mode only. */
> +		sun4i_usb_phy_passby(phy, !id_det);
> +
>  		/* Re-route PHY0 if necessary */
>  		if (data->cfg->phy0_dual_route)
>  			sun4i_usb_phy0_reroute(data, id_det);
-- 
Paul Kocialkowski, Bootlin
Embedded Linux and kernel engineering
https://bootlin.com


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] phy: sun4i-usb: Make sure to disable PHY0 passby for peripheral mode
  2019-04-15 11:17 ` Paul Kocialkowski
@ 2019-04-17  5:32   ` Kishon Vijay Abraham I
  0 siblings, 0 replies; 3+ messages in thread
From: Kishon Vijay Abraham I @ 2019-04-17  5:32 UTC (permalink / raw)
  To: Paul Kocialkowski, linux-kernel, linux-arm-kernel, linux-sunxi
  Cc: Maxime Ripard, Chen-Yu Tsai, Thomas Petazzoni, Jagan Teki, Hans de Goede



On 15/04/19 4:47 PM, Paul Kocialkowski wrote:
> Hi,
> 
> Le jeudi 14 mars 2019 à 14:05 +0100, Paul Kocialkowski a écrit :
>> On platforms where the MUSB and HCI controllers share PHY0, PHY passby
>> is required when using the HCI controller with the PHY, but it must be
>> disabled when the MUSB controller is used instead.
>>
>> Without this, PHY0 passby is always enabled, which results in broken
>> peripheral mode on such platforms (e.g. H3/H5).
>>
>> Fixes: ba4bdc9e1dc0 ("PHY: sunxi: Add driver for sunxi usb phy")
> 
> Does anyone have feedback about this? I was hoping to get it merged
> rather soon since it pretty much fixes USB gadget on H3/R40/V3/V3s.

merged now, thanks.

-Kishon
> 
> Cheers,
> 
> Paul
> 
>> Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
>> ---
>>  drivers/phy/allwinner/phy-sun4i-usb.c | 4 ++++
>>  1 file changed, 4 insertions(+)
>>
>> diff --git a/drivers/phy/allwinner/phy-sun4i-usb.c b/drivers/phy/allwinner/phy-sun4i-usb.c
>> index 5163097b43df..7b23920e0068 100644
>> --- a/drivers/phy/allwinner/phy-sun4i-usb.c
>> +++ b/drivers/phy/allwinner/phy-sun4i-usb.c
>> @@ -551,6 +551,7 @@ static void sun4i_usb_phy0_id_vbus_det_scan(struct work_struct *work)
>>  	struct sun4i_usb_phy_data *data =
>>  		container_of(work, struct sun4i_usb_phy_data, detect.work);
>>  	struct phy *phy0 = data->phys[0].phy;
>> +	struct sun4i_usb_phy *phy = phy_get_drvdata(phy0);
>>  	bool force_session_end, id_notify = false, vbus_notify = false;
>>  	int id_det, vbus_det;
>>  
>> @@ -607,6 +608,9 @@ static void sun4i_usb_phy0_id_vbus_det_scan(struct work_struct *work)
>>  			mutex_unlock(&phy0->mutex);
>>  		}
>>  
>> +		/* Enable PHY0 passby for host mode only. */
>> +		sun4i_usb_phy_passby(phy, !id_det);
>> +
>>  		/* Re-route PHY0 if necessary */
>>  		if (data->cfg->phy0_dual_route)
>>  			sun4i_usb_phy0_reroute(data, id_det);

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-04-17  5:34 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-14 13:05 [PATCH] phy: sun4i-usb: Make sure to disable PHY0 passby for peripheral mode Paul Kocialkowski
2019-04-15 11:17 ` Paul Kocialkowski
2019-04-17  5:32   ` Kishon Vijay Abraham I

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).