On Wed, Mar 26, 2014 at 10:14:31AM +0800, Peter Chen wrote:
> On Wed, Mar 19, 2014 at 06:01:35PM +0800, Li Jun wrote:
> > Leave vbus on/off hanlded by OTG fsm if in OTG mode.
> > 
> > Signed-off-by: Li Jun <b47...@freescale.com>
> > ---
> >  drivers/usb/chipidea/host.c |    6 +++---
> >  drivers/usb/chipidea/host.h |    9 +++++++++
> >  2 files changed, 12 insertions(+), 3 deletions(-)
> > 
> > diff --git a/drivers/usb/chipidea/host.c b/drivers/usb/chipidea/host.c
> > index a8ac6c1..4b609bc 100644
> > --- a/drivers/usb/chipidea/host.c
> > +++ b/drivers/usb/chipidea/host.c
> > @@ -67,7 +67,7 @@ static int host_start(struct ci_hdrc *ci)
> >     ehci->has_tdi_phy_lpm = ci->hw_bank.lpm;
> >     ehci->imx28_write_fix = ci->imx28_write_fix;
> >  
> > -   if (ci->platdata->reg_vbus) {
> > +   if (ci->platdata->reg_vbus && !ci_host_is_otg(ci)) {
> >             ret = regulator_enable(ci->platdata->reg_vbus);
> >             if (ret) {
> >                     dev_err(ci->dev,
> > @@ -89,7 +89,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:
> > @@ -105,7 +105,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
> > +   return (ci->is_otg) && (ci->platdata->dr_mode == USB_DR_MODE_OTG);
> > +#else
> > +   return false;
> > +#endif
> > +}
> > +
> >  #else
> 
> I talked at last round email, we need to use below condition to stand
> for OTG condition:
> 
> 
> static inline bool ci_host_is_otg(struct ci_hdrc *ci)
> {
> #ifdef CONFIG_USB_OTG_FSM
>       return ci->is_otg && ci->roles[CI_ROLE_HOST] && 
> ci->roles[CI_ROLE_GADGET];
> #else
>       return false;
> #endif
> }
> 
> The user may only choose host or gadget support at configuration menu.
> 

To be more robust with many configurations, this is a good suggestion, I will
use this runtime check, thanks!

> >  
> >  static inline int ci_hdrc_host_init(struct ci_hdrc *ci)
> > -- 
> > 1.7.9.5
> > 
> > 
> 
> -- 
> 
> Best Regards,
> Peter Chen
> 

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to