From 2f211b5dc9fa03287af3f623b4a823ec7944a14a Mon Sep 17 00:00:00 2001 From: Ajay Agarwal Date: Tue, 30 May 2017 10:22:04 +0530 Subject: [PATCH 1/2] usb: dwc3: Allow DWC3 to handle non-extcon controller instance Extcon is required by the USB controller to switch between host and peripheral modes using BSV and ID events. If the DT node of a particular controller does not have 'extcon' property set but the mode is set to host only using dr_mode = "host", then we do not fail the probe and bring up the controller in host mode. Add another case to the probe that when extcon prop is not set and the controller mode is set to DRD, then bring up the device in host mode. User can always change the mode using sysfs. Change-Id: Iad44748b99a944fab93ff86a34787bd93dcb4ed6 Signed-off-by: Ajay Agarwal --- drivers/usb/dwc3/dwc3-msm.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/drivers/usb/dwc3/dwc3-msm.c b/drivers/usb/dwc3/dwc3-msm.c index 4ed46d9ca279..c2d788bc4bc5 100644 --- a/drivers/usb/dwc3/dwc3-msm.c +++ b/drivers/usb/dwc3/dwc3-msm.c @@ -2671,12 +2671,16 @@ static int dwc3_msm_extcon_register(struct dwc3_msm *mdwc) { struct device_node *node = mdwc->dev->of_node; struct extcon_dev *edev; + struct dwc3 *dwc; int ret = 0; + dwc = platform_get_drvdata(mdwc->dwc3); if (!of_property_read_bool(node, "extcon")) { - if (usb_get_dr_mode(&mdwc->dwc3->dev) == USB_DR_MODE_HOST) + dev_dbg(mdwc->dev, "extcon property doesn't exist\n"); + if (usb_get_dr_mode(&mdwc->dwc3->dev) == USB_DR_MODE_HOST + || dwc->is_drd) return 0; - dev_err(mdwc->dev, "extcon property doesn't exist\n"); + dev_err(mdwc->dev, "Neither host nor DRD, fail probe\n"); return -EINVAL; } @@ -3137,8 +3141,9 @@ static int dwc3_msm_probe(struct platform_device *pdev) device_create_file(&pdev->dev, &dev_attr_speed); host_mode = usb_get_dr_mode(&mdwc->dwc3->dev) == USB_DR_MODE_HOST; - if (!dwc->is_drd && host_mode) { - dev_dbg(&pdev->dev, "DWC3 in host only mode\n"); + if (host_mode || + (dwc->is_drd && !of_property_read_bool(node, "extcon"))) { + dev_dbg(&pdev->dev, "DWC3 in default host mode\n"); mdwc->id_state = DWC3_ID_GROUND; dwc3_ext_event_notify(mdwc); } From bcf8bc839ec0ebcf800336f84713c412caa553c1 Mon Sep 17 00:00:00 2001 From: Ajay Agarwal Date: Sat, 27 May 2017 14:01:07 +0530 Subject: [PATCH 2/2] ARM: dts: msm: Enable DRD mode for 2nd USB controller on MSM8996 Auto Enable DRD mode for secondary USB controller of MSM8996 Auto target. User can change the mode using sysfs. Eg: echo peripheral > /sys/devices/soc/7600000.hsusb/mode (Device) echo host > /sys/devices/soc/7600000.hsusb/mode (Host) echo none > /sys/devices/soc/7600000.hsusb/mode (Disconnect) Change-Id: Ia1d9c115b6fed01a7ab3a9f0489d6eb9d735a282 Signed-off-by: Ajay Agarwal --- arch/arm/boot/dts/qcom/msm8996-agave-adp.dtsi | 3 --- 1 file changed, 3 deletions(-) diff --git a/arch/arm/boot/dts/qcom/msm8996-agave-adp.dtsi b/arch/arm/boot/dts/qcom/msm8996-agave-adp.dtsi index eae8c29fe21e..d7d41153e754 100644 --- a/arch/arm/boot/dts/qcom/msm8996-agave-adp.dtsi +++ b/arch/arm/boot/dts/qcom/msm8996-agave-adp.dtsi @@ -1160,9 +1160,6 @@ &usb2s { status = "ok"; - dwc3@7600000 { - dr_mode = "host"; - }; }; &usb3 {