> From: Kever Yang [mailto:kever.yang@xxxxxxxxxxxxxx] > Sent: Wednesday, July 30, 2014 6:06 PM > > Some devices with A female host port and without use of usb_id pin > will need this for the otg controller works as device role > during firmware period and works as host role in rich os. > > Signed-off-by: Kever Yang <kever.yang@xxxxxxxxxxxxxx> > > --- > > Changes in v2: > - put spaces around '+' operator > - expand the comment for dr_mode > - handle dr_mode is USB_DR_MODE_OTG > > drivers/usb/dwc2/core.c | 18 ++++++++++++++++++ > drivers/usb/dwc2/core.h | 5 +++++ > drivers/usb/dwc2/platform.c | 4 ++++ > 3 files changed, 27 insertions(+) > > diff --git a/drivers/usb/dwc2/core.c b/drivers/usb/dwc2/core.c > index 27d2c9b..738bec2 100644 > --- a/drivers/usb/dwc2/core.c > +++ b/drivers/usb/dwc2/core.c > @@ -118,6 +118,7 @@ static int dwc2_core_reset(struct dwc2_hsotg *hsotg) > { > u32 greset; > int count = 0; > + u32 gusbcfg; > > dev_vdbg(hsotg->dev, "%s()\n", __func__); > > @@ -148,6 +149,23 @@ static int dwc2_core_reset(struct dwc2_hsotg *hsotg) > } > } while (greset & GRSTCTL_CSFTRST); > > + if (hsotg->dr_mode == USB_DR_MODE_HOST) { > + gusbcfg = readl(hsotg->regs + GUSBCFG); > + gusbcfg &= ~GUSBCFG_FORCEDEVMODE; > + gusbcfg |= GUSBCFG_FORCEHOSTMODE; > + writel(gusbcfg, hsotg->regs + GUSBCFG); > + } else if (hsotg->dr_mode == USB_DR_MODE_PERIPHERAL) { > + gusbcfg = readl(hsotg->regs + GUSBCFG); > + gusbcfg &= ~GUSBCFG_FORCEHOSTMODE; > + gusbcfg |= GUSBCFG_FORCEDEVMODE; > + writel(gusbcfg, hsotg->regs + GUSBCFG); > + } else if (hsotg->dr_mode == USB_DR_MODE_OTG) { > + gusbcfg = readl(hsotg->regs + GUSBCFG); > + gusbcfg &= ~GUSBCFG_FORCEHOSTMODE; > + gusbcfg &= ~GUSBCFG_FORCEDEVMODE; > + writel(gusbcfg, hsotg->regs + GUSBCFG); > + } > + > /* > * NOTE: This long sleep is _very_ important, otherwise the core will > * not stay in host mode after a connector ID change! > diff --git a/drivers/usb/dwc2/core.h b/drivers/usb/dwc2/core.h > index 1efd10c..a34681c 100644 > --- a/drivers/usb/dwc2/core.h > +++ b/drivers/usb/dwc2/core.h > @@ -501,6 +501,10 @@ struct dwc2_hw_params { > * a_peripheral and b_device=>b_host) this may not match > * the core, but allows the software to determine > * transitions > + * @dr_mode: Requested mode of operation, one of following: > + * - USB_DR_MODE_PERIPHERAL > + * - USB_DR_MODE_HOST > + * - USB_DR_MODE_OTG > * @queuing_high_bandwidth: True if multiple packets of a high-bandwidth > * transfer are in process of being queued > * @srp_success: Stores status of SRP request in the case of a FS PHY > @@ -592,6 +596,7 @@ struct dwc2_hsotg { > /** Params to actually use */ > struct dwc2_core_params *core_params; > enum usb_otg_state op_state; > + enum usb_dr_mode dr_mode; Can you please fix the odd spacing here? Once you do that, you can add my acked-by. -- Paul -- To unsubscribe from this list: send the line "unsubscribe linux-doc" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html