Hi, (please Cc myself for PHY-related questions ;-) On Wed, Nov 14, 2012 at 10:35:42AM +0800, Chao Xie wrote: > The USB controller in our SOC can support otg/ehci/udc, and there is a > PHY around the controller. It means that when we want to enable otg or > ehci or udc, we have to enable the PHY. fair enough ;-) In any system you need a PHY not only OTG-capable systems. I guess the only systems which are PHY-less are HSIC/SSIC systems AFAICT. > Then i want to add a PHY driver, but the PHY does not bind to OTG. It > means that if we want only udc fucntion, we still need the phy. The > struct usb_phy has a pointer to usb_otg. To make use of the phy usb_otg is pretty much optional. If it's not, then it's a bug which needs to be addressed ;-) > driver, can i have the following callings? > > 1. write a phy driver, and initialize phy->init and phy->shutdown. > Then in probe function invoke usb_add_phy(phy, USB_PHY_TYPE_USB2) yes. > 2. in the udc driver > in probe function, call usb_get_phy(USB_PHY_TYPE_USB2), and when please stick to devm_usb_get_phy() > want to start udc, call phy->init() to initialize the PHY, and when > want to stop udc, call phy->shutdown to shutdown the phy sounds perfectly fine. > when udc is started, and usally we will check whether phy->otg is NULL > or not, if it is not NULL, invoke otg_set_peripheral to set the OTG to > be device-B. It means that if we have otg enabled, the phy->otg will > not be NULL, otherwise we only have udc supported. this sounds correct, except that I'd expect usb_otg_set_peripheral() to do that check for you. If it's not doing, it's another bug which should be addressed. Patches are highly welcome in that area ;-) > 3. in the otg driver in the probe function, initialize the otg(struct > usb_otg), then call usb_get_phy(USB_PHY_TYPE_USB2), and set phy->otg = > otg. what do you call "the OTG driver" ? > 4. in the ehci driver in the probe function, call > usb_get_phy(USB_PHY_TYPE_USB2), and when want to enable ehci, call > phy->init first. sounds correct, but you need to make sure that before you initialize EHCI, UDC has been stoped, otherwise you might have a race condition where you call usb_phy_init() twice. > when start ehci, we will check whether phy->otg is NULL or not, if it > is not NULL, invoke otg_set_host to make otg be host-A. makes sense, but as I said above, you should be able to call usb_otg_set_host() directly without doing the check, and have the API itself handle that check for you. cheers -- balbi
Attachment:
signature.asc
Description: Digital signature