Commit 958d1a4c authored by Felipe Balbi's avatar Felipe Balbi

usb: dwc3: core: program PHY for proper DRD modes

If PHY is entering Host mode, we need to enable VBUS.
Signed-off-by: default avatarFelipe Balbi <felipe.balbi@linux.intel.com>
parent f54edb53
...@@ -151,11 +151,24 @@ static void __dwc3_set_mode(struct work_struct *work) ...@@ -151,11 +151,24 @@ static void __dwc3_set_mode(struct work_struct *work)
switch (dwc->desired_dr_role) { switch (dwc->desired_dr_role) {
case DWC3_GCTL_PRTCAP_HOST: case DWC3_GCTL_PRTCAP_HOST:
ret = dwc3_host_init(dwc); ret = dwc3_host_init(dwc);
if (ret) if (ret) {
dev_err(dwc->dev, "failed to initialize host\n"); dev_err(dwc->dev, "failed to initialize host\n");
} else {
if (dwc->usb2_phy)
otg_set_vbus(dwc->usb2_phy->otg, true);
if (dwc->usb2_generic_phy)
phy_set_mode(dwc->usb2_generic_phy, PHY_MODE_USB_HOST);
}
break; break;
case DWC3_GCTL_PRTCAP_DEVICE: case DWC3_GCTL_PRTCAP_DEVICE:
dwc3_event_buffers_setup(dwc); dwc3_event_buffers_setup(dwc);
if (dwc->usb2_phy)
otg_set_vbus(dwc->usb2_phy->otg, false);
if (dwc->usb2_generic_phy)
phy_set_mode(dwc->usb2_generic_phy, PHY_MODE_USB_DEVICE);
ret = dwc3_gadget_init(dwc); ret = dwc3_gadget_init(dwc);
if (ret) if (ret)
dev_err(dwc->dev, "failed to initialize peripheral\n"); dev_err(dwc->dev, "failed to initialize peripheral\n");
...@@ -915,6 +928,12 @@ static int dwc3_core_init_mode(struct dwc3 *dwc) ...@@ -915,6 +928,12 @@ static int dwc3_core_init_mode(struct dwc3 *dwc)
switch (dwc->dr_mode) { switch (dwc->dr_mode) {
case USB_DR_MODE_PERIPHERAL: case USB_DR_MODE_PERIPHERAL:
dwc3_set_prtcap(dwc, DWC3_GCTL_PRTCAP_DEVICE); dwc3_set_prtcap(dwc, DWC3_GCTL_PRTCAP_DEVICE);
if (dwc->usb2_phy)
otg_set_vbus(dwc->usb2_phy->otg, false);
if (dwc->usb2_generic_phy)
phy_set_mode(dwc->usb2_generic_phy, PHY_MODE_USB_DEVICE);
ret = dwc3_gadget_init(dwc); ret = dwc3_gadget_init(dwc);
if (ret) { if (ret) {
if (ret != -EPROBE_DEFER) if (ret != -EPROBE_DEFER)
...@@ -924,6 +943,12 @@ static int dwc3_core_init_mode(struct dwc3 *dwc) ...@@ -924,6 +943,12 @@ static int dwc3_core_init_mode(struct dwc3 *dwc)
break; break;
case USB_DR_MODE_HOST: case USB_DR_MODE_HOST:
dwc3_set_prtcap(dwc, DWC3_GCTL_PRTCAP_HOST); dwc3_set_prtcap(dwc, DWC3_GCTL_PRTCAP_HOST);
if (dwc->usb2_phy)
otg_set_vbus(dwc->usb2_phy->otg, true);
if (dwc->usb2_generic_phy)
phy_set_mode(dwc->usb2_generic_phy, PHY_MODE_USB_HOST);
ret = dwc3_host_init(dwc); ret = dwc3_host_init(dwc);
if (ret) { if (ret) {
if (ret != -EPROBE_DEFER) if (ret != -EPROBE_DEFER)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment