From 913d3c8e4f325427e38d06334d7b78091406ae3a Mon Sep 17 00:00:00 2001 From: Jianing Ren Date: Fri, 5 Jun 2020 15:02:03 +0800 Subject: [PATCH] usb: dwc3: gadget: add phy calibration during chirpk state The USB2.0 OTG PHY of RV1126/1109 which is designed for lower power consumption provides only 8.8mA current source on DM at chirpK state. Multiplied by 45 Ohm host termination resistance, voltage is about 400mV. If the threshold voltage of host is greater than 400mV, the high speed handshake will fail and SoC communicate at full speed. So swing calibration is necessary. Because we use this interface for swing calibration. This patch also disable phy calibration in setting host mode for rockchip platform. Change-Id: Ic1c8bb6aac95b3d0d61d99becb4facea1bbecb25 Signed-off-by: Jianing Ren --- drivers/usb/dwc3/core.c | 13 ++++++++++--- drivers/usb/dwc3/gadget.c | 4 ++++ 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c index 535fb9a9b9bb..d6a009415168 100644 --- a/drivers/usb/dwc3/core.c +++ b/drivers/usb/dwc3/core.c @@ -171,7 +171,9 @@ static void __dwc3_set_mode(struct work_struct *work) otg_set_vbus(dwc->usb2_phy->otg, true); phy_set_mode(dwc->usb2_generic_phy, PHY_MODE_USB_HOST); phy_set_mode(dwc->usb3_generic_phy, PHY_MODE_USB_HOST); - phy_calibrate(dwc->usb2_generic_phy); + if (!of_device_is_compatible(dwc->dev->parent->of_node, + "rockchip,rk3399-dwc3")) + phy_calibrate(dwc->usb2_generic_phy); } break; case DWC3_GCTL_PRTCAP_DEVICE: @@ -242,7 +244,10 @@ runtime: PHY_MODE_USB_HOST); phy_set_mode(dwc->usb3_generic_phy, PHY_MODE_USB_HOST); - phy_calibrate(dwc->usb2_generic_phy); + if (!of_device_is_compatible( + dwc->dev->parent->of_node, + "rockchip,rk3399-dwc3")) + phy_calibrate(dwc->usb2_generic_phy); } break; case DWC3_GCTL_PRTCAP_DEVICE: @@ -1276,7 +1281,9 @@ static int dwc3_core_init_mode(struct dwc3 *dwc) dev_err(dev, "failed to initialize host\n"); return ret; } - phy_calibrate(dwc->usb2_generic_phy); + if (!of_device_is_compatible(dwc->dev->parent->of_node, + "rockchip,rk3399-dwc3")) + phy_calibrate(dwc->usb2_generic_phy); break; case USB_DR_MODE_OTG: INIT_WORK(&dwc->drd_work, __dwc3_set_mode); diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c index 6cf2ebb88d8e..d535425bb6bf 100644 --- a/drivers/usb/dwc3/gadget.c +++ b/drivers/usb/dwc3/gadget.c @@ -2894,6 +2894,10 @@ static void dwc3_gadget_reset_interrupt(struct dwc3 *dwc) { u32 reg; + if (of_device_is_compatible(dwc->dev->parent->of_node, + "rockchip,rk3399-dwc3")) + phy_calibrate(dwc->usb2_generic_phy); + /* * WORKAROUND: DWC3 revisions <1.88a have an issue which * would cause a missing Disconnect Event if there's a