> ^and > What does the OTG port number mean? It is always 1? > If there are two OTG port, how about the value of the otg_port? > [Li Jun] Here the OTG port number means the USB host port number to which a device attaches, which is 1 based, since HNP does not support hub(i.e. no intervening hub between the Host and the B-device), and only one OTG port per one OTG controller, so I set it to be 1. If there are 2 OTG controllers in one device, each OTG port will work the same way. Please wrap you answer to 80 characters next time. > > > > > Signed-off-by: Li Jun <b47624@xxxxxxxxxxxxx> > > --- > > drivers/usb/chipidea/host.c | 13 +++++++++---- > > drivers/usb/chipidea/host.h | 9 +++++++++ > > 2 files changed, 18 insertions(+), 4 deletions(-) > > > > diff --git a/drivers/usb/chipidea/host.c b/drivers/usb/chipidea/host.c > > index 526cd77..bba54c3 100644 > > --- a/drivers/usb/chipidea/host.c > > +++ b/drivers/usb/chipidea/host.c > > @@ -66,7 +66,7 @@ static int host_start(struct ci_hdrc *ci) > > ehci->has_hostpc = ci->hw_bank.lpm; > > ehci->has_tdi_phy_lpm = ci->hw_bank.lpm; > > > > - if (ci->platdata->reg_vbus) { > > + if ((ci->platdata->reg_vbus) && !ci_host_is_otg(ci)) { > > The first () is not needed. > [Li Jun] I will remove it. > Any ways to unify the vbus controller for both OTG and non-OTG cases? > [Li Jun] Both cases have diff V-bus handling, in OTG HNP case, V-bus is controlled by HNP fsm, it's not always on when in host mode. > > > ret = regulator_enable(ci->platdata->reg_vbus); > > if (ret) { > > dev_err(ci->dev, > > @@ -79,8 +79,13 @@ static int host_start(struct ci_hdrc *ci) > > ret = usb_add_hcd(hcd, 0, 0); > > if (ret) > > goto disable_reg; > > - else > > + else { > > ci->hcd = hcd; > > + if (ci_host_is_otg(ci)) { > > + ci->transceiver->otg->host = &hcd->self; > > + ci->transceiver->otg->host->otg_port = 1; > > + } > > + } > > > > if (ci->platdata->flags & CI_HDRC_DISABLE_STREAMING) > > hw_write(ci, OP_USBMODE, USBMODE_CI_SDIS, USBMODE_CI_SDIS); @@ > > -88,7 +93,7 @@ static int host_start(struct ci_hdrc *ci) > > return ret; > > > > disable_reg: > > - if (ci->platdata->reg_vbus) > > + if ((ci->platdata->reg_vbus) && !ci_host_is_otg(ci)) > > regulator_disable(ci->platdata->reg_vbus); > > > > put_hcd: > > @@ -104,7 +109,7 @@ static void host_stop(struct ci_hdrc *ci) > > if (hcd) { > > usb_remove_hcd(hcd); > > usb_put_hcd(hcd); > > - if (ci->platdata->reg_vbus) > > + if ((ci->platdata->reg_vbus) && !ci_host_is_otg(ci)) > > regulator_disable(ci->platdata->reg_vbus); > > } > > } > > diff --git a/drivers/usb/chipidea/host.h b/drivers/usb/chipidea/host.h > > index 5707bf3..f98d084 100644 > > --- a/drivers/usb/chipidea/host.h > > +++ b/drivers/usb/chipidea/host.h > > @@ -6,6 +6,15 @@ > > int ci_hdrc_host_init(struct ci_hdrc *ci); void > > ci_hdrc_host_destroy(struct ci_hdrc *ci); > > > > +static inline bool ci_host_is_otg(struct ci_hdrc *ci) { #ifdef > > +CONFIG_USB_OTG_FSM > > CONFIG_USB_OTG? > [Li Jun] Both can work for me, CONFIG_USB_OTG_FSM is more dedicated for OTG fsm. Since we all use CONFIG_USB_OTG at current code, please use it. In fact, I don't think CONFIG_USB_OTG_FSM is necessary, I have a patch to delete it, waiting Felipe's response. http://marc.info/?l=linux-usb&m=138934291507546&w=2 Peter > > > + return (ci->is_otg) && (ci->platdata->dr_mode == USB_DR_MODE_OTG); > > Why ci->platdata->dr_mode == USB_DR_MODE_OTG is needed to judge if a host port is OTG port? > [Li Jun] This is used to judge if a OTG port is working in OTG mode with HNP enabled. > > Besides, if the user chooses dr_mode as non USB_DR_MODE_OTG, and kernel configuration chooses CONFIG_USB_OTG, the port should responds as host only port. DT entries can always override kernel configuration. > [Li Jun] yes, if dr_mode is not USB_DR_MODE_OTG, OTG port will work in host-only or device-only mode, even CONFIG_USB_OTG_FSM is selected. > > > +#else > > + return false; > > +#endif > > +} > > + > > #else > > > > static inline int ci_hdrc_host_init(struct ci_hdrc *ci) > > -- > > 1.7.8 > > > > > > -- > > Best Regards, > Peter Chen > -- Best Regards, Peter Chen -- 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