Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit be53d5c4 authored by Ajay Agarwal's avatar Ajay Agarwal
Browse files

usb: dwc3-msm: Add support for default none mode if extcon absent



On some platforms, the objective is to keep the controller in
'none' mode if it is dual role capable and extcon is absent. User
can later switch to required mode from userspace or via sysfs.
Add required support for default 'none' mode based on DT property
'qcom,default-mode-none'.

Change-Id: Icefee47a0a1a068a3c18f3a05593c883335a16b0
Signed-off-by: default avatarAjay Agarwal <ajaya@codeaurora.org>
parent cdbe2d3e
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -84,6 +84,8 @@ Optional properties :
- qcom,host-poweroff-in-pm-suspend: If present, allow PM suspend to happen
	irrespective of runtimePM state of host and power collapse the core.
	This also leads to reset-resume of connected devices on PM resume.
- qcom,default-mode-none: If present, do not start any mode on probe for an OTG
	capable DWC3 which does not have extcon handle.
- qcom,default-mode-host: If present, start host mode on probe for an OTG
	capable DWC3 which does not have extcon handle.

+23 −8
Original line number Diff line number Diff line
/* Copyright (c) 2012-2018, The Linux Foundation. All rights reserved.
/* Copyright (c) 2012-2019, The Linux Foundation. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
@@ -3753,16 +3753,31 @@ static int dwc3_msm_probe(struct platform_device *pdev)
			queue_delayed_work(mdwc->sm_usb_wq, &mdwc->sm_work, 0);
		}
	} else {
		if ((dwc->dr_mode == USB_DR_MODE_OTG &&
		     !of_property_read_bool(node, "qcom,default-mode-host")) ||
		     dwc->dr_mode == USB_DR_MODE_PERIPHERAL) {
			dev_dbg(mdwc->dev, "%s: no extcon, start peripheral mode\n",
		switch (dwc->dr_mode) {
		case USB_DR_MODE_OTG:
			if (of_property_read_bool(node,
						"qcom,default-mode-host")) {
				dev_dbg(mdwc->dev, "%s: start host mode\n",
								__func__);
				mdwc->id_state = DWC3_ID_GROUND;
			} else if (of_property_read_bool(node,
						"qcom,default-mode-none")) {
				dev_dbg(mdwc->dev, "%s: stay in none mode\n",
								__func__);
			mdwc->vbus_active = true;
			} else {
			dev_dbg(mdwc->dev, "%s: no extcon, start host mode\n",
				dev_dbg(mdwc->dev, "%s: start peripheral mode\n",
								__func__);
				mdwc->vbus_active = true;
			}
			break;
		case USB_DR_MODE_HOST:
			mdwc->id_state = DWC3_ID_GROUND;
			break;
		case USB_DR_MODE_PERIPHERAL:
			/* fall through */
		default:
			mdwc->vbus_active = true;
			break;
		}

		dwc3_ext_event_notify(mdwc);