linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Correct ordering of phy_init and phy_power_on
@ 2020-12-20 23:06 Ahmad Fatoum
  2020-12-21  3:15 ` Kishon Vijay Abraham I
  0 siblings, 1 reply; 3+ messages in thread
From: Ahmad Fatoum @ 2020-12-20 23:06 UTC (permalink / raw)
  To: Kishon Vijay Abraham I, Vinod Koul, Minas Harutyunyan, linux-usb
  Cc: linux-kernel, Pengutronix Kernel Team, linux-usb, Jules Maselbas

Hello,

I just noticed that USB controller drivers differ in the order in which they
do phy_init and phy_power_on. For example:

__dwc2_lowlevel_hw_enable():

	ret = phy_power_on(hsotg->phy);    
	if (ret == 0)                      
        	ret = phy_init(hsotg->phy);

dwc3_core_init():

	ret = dwc3_core_soft_reset(dwc); // internally does phy_init(dwc->usb2_generic_phy);
	/* [snip] */
	ret = phy_power_on(dwc->usb2_generic_phy);


My initial assumption has been init -> power_on, but at least the phy-stm32-usbphyc
(used with dwc2) is written with the assumption that exit -> power_off (and therefore
power_on -> init). If they are swapped, disabling fails.

So how was it meant to be?

Cheers,
Ahmad

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

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

* Re: Correct ordering of phy_init and phy_power_on
  2020-12-20 23:06 Correct ordering of phy_init and phy_power_on Ahmad Fatoum
@ 2020-12-21  3:15 ` Kishon Vijay Abraham I
  2020-12-22  9:08   ` Ahmad Fatoum
  0 siblings, 1 reply; 3+ messages in thread
From: Kishon Vijay Abraham I @ 2020-12-21  3:15 UTC (permalink / raw)
  To: Ahmad Fatoum, Vinod Koul, Minas Harutyunyan, linux-usb
  Cc: linux-kernel, Pengutronix Kernel Team, Jules Maselbas

Hi,

On 21/12/20 4:36 am, Ahmad Fatoum wrote:
> Hello,
> 
> I just noticed that USB controller drivers differ in the order in which they
> do phy_init and phy_power_on. For example:
> 
> __dwc2_lowlevel_hw_enable():
> 
> 	ret = phy_power_on(hsotg->phy);    
> 	if (ret == 0)                      
>         	ret = phy_init(hsotg->phy);
> 
> dwc3_core_init():
> 
> 	ret = dwc3_core_soft_reset(dwc); // internally does phy_init(dwc->usb2_generic_phy);
> 	/* [snip] */
> 	ret = phy_power_on(dwc->usb2_generic_phy);
> 
> 
> My initial assumption has been init -> power_on, but at least the phy-stm32-usbphyc
> (used with dwc2) is written with the assumption that exit -> power_off (and therefore
> power_on -> init). If they are swapped, disabling fails.
> 
> So how was it meant to be?

It is intended to be ->init() and then ->power_on(). So ideally it
should be the way dwc3 is.

Thanks,
Kishon

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

* Re: Correct ordering of phy_init and phy_power_on
  2020-12-21  3:15 ` Kishon Vijay Abraham I
@ 2020-12-22  9:08   ` Ahmad Fatoum
  0 siblings, 0 replies; 3+ messages in thread
From: Ahmad Fatoum @ 2020-12-22  9:08 UTC (permalink / raw)
  To: Kishon Vijay Abraham I, Vinod Koul, Minas Harutyunyan, linux-usb
  Cc: linux-kernel, Pengutronix Kernel Team, Jules Maselbas

Hello Kishon,

On 21.12.20 04:15, Kishon Vijay Abraham I wrote:
>> So how was it meant to be?
> 
> It is intended to be ->init() and then ->power_on(). So ideally it
> should be the way dwc3 is.

Thanks. Should we do something about the inconsistency?

Amend documentation and maybe print a warning when order is wrong,
so users are encouraged to fix their drivers?

The way it is, you can't properly mix some of the PHY and USB controller drivers.

Cheers,
Ahmad

> 
> Thanks,
> Kishon
> 

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

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

end of thread, other threads:[~2020-12-22  9:09 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-20 23:06 Correct ordering of phy_init and phy_power_on Ahmad Fatoum
2020-12-21  3:15 ` Kishon Vijay Abraham I
2020-12-22  9:08   ` Ahmad Fatoum

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).