On Tue, 7 Sep 2010, Pavan Kondeti wrote: > I am developing OTG driver for MSM chips. I would like to start first with > with basic OTG (based on Id pin detection) then extend the driver to implement > OTG2.0 functionality (SRP and HNP). > > When Id becomes false, HCD will be added and HCD will be removed when Id > becomes true. When VBUS becomes true (session valid), gadget is connected. We > have usb_gadget_vbus_connect to achieve the later. But a similar API is > missing for host. > > I was working on 2.6.32 kernel and did not look at the recent kernel. It seems > usb/core/hcd.h is moved to include/linux/usb. So I can happily call > usb_add_hcd() and usb_remove_hcd() from OTG without introducing another API > between OTG-->HOST. Is it really necessary to remove the HCD when the port is switched to device mode? Wouldn't it be good enough to unconfigure the root hub, i.e., usb_set_configuration(hcd->self.root_hub, 0)? And of course, to reconfigure it when switching back to host mode. (You could also clear the HW_ACCESSIBLE flag if you wanted.) > As I told above, HCD calls usb_add_hcd() upon Id ground condition. But > usb_remove_hcd() can not be called during HNP due to timing issues. So HCD > simply set hcd->state to halt, clears CD_FLAG_HW_ACCESSIBLE bit, and set root > hub device state to USB_STATE_NOTATTACHED. But these all can be directly in > OTG given that hcd.h available to outside usb/core. You can't call usb_set_configuration in interrupt context. But you can call usb_driver_set_configuration -- although you will have to wait for it to take effect. Alan Stern -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html