diff options
author | Gregory Herrero <gregory.herrero@intel.com> | 2015-01-09 12:39:09 (GMT) |
---|---|---|
committer | Felipe Balbi <balbi@ti.com> | 2015-01-12 21:34:54 (GMT) |
commit | 1b7a66b4d3399da5e0b13cf90fb4bd33b7197ff2 (patch) | |
tree | b6a73723f6b19e849a6898a0593f40fb61038c9b | |
parent | 596d696a5d0e066f2ed4bd6b0e40dedd52513c7c (diff) | |
download | linux-1b7a66b4d3399da5e0b13cf90fb4bd33b7197ff2.tar.xz |
usb: dwc2: gadget: force gadget initialization in dev mode
When booting with id pin grounded, dwc2 default to host mode.
Thus, force device mode prior initializing gadget part.
Else fifo init will fail since fifo values are not correct
in host mode.
Tested-by: Robert Baldyga <r.baldyga@samsung.com>
Acked-by: Paul Zimmerman <paulz@synopsys.com>
Signed-off-by: Gregory Herrero <gregory.herrero@intel.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
-rw-r--r-- | drivers/usb/dwc2/gadget.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c index f477709..df9080d 100644 --- a/drivers/usb/dwc2/gadget.c +++ b/drivers/usb/dwc2/gadget.c @@ -3675,6 +3675,19 @@ int dwc2_gadget_init(struct dwc2_hsotg *hsotg, int irq) /* usb phy enable */ s3c_hsotg_phy_enable(hsotg); + /* + * Force Device mode before initialization. + * This allows correctly configuring fifo for device mode. + */ + __bic32(hsotg->regs + GUSBCFG, GUSBCFG_FORCEHOSTMODE); + __orr32(hsotg->regs + GUSBCFG, GUSBCFG_FORCEDEVMODE); + + /* + * According to Synopsys databook, this sleep is needed for the force + * device mode to take effect. + */ + msleep(25); + s3c_hsotg_corereset(hsotg); ret = s3c_hsotg_hw_cfg(hsotg); if (ret) { @@ -3684,6 +3697,9 @@ int dwc2_gadget_init(struct dwc2_hsotg *hsotg, int irq) s3c_hsotg_init(hsotg); + /* Switch back to default configuration */ + __bic32(hsotg->regs + GUSBCFG, GUSBCFG_FORCEDEVMODE); + hsotg->ctrl_buff = devm_kzalloc(hsotg->dev, DWC2_CTRL_BUFF_SIZE, GFP_KERNEL); if (!hsotg->ctrl_buff) { |