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

Commit 411ce1fd authored by Pratham Pratap's avatar Pratham Pratap
Browse files

usb: dwc3: Enable multiple UDC support



Allow binding between UDC and gadget driver to take
place based on usb-core-id.Since only one instance of
USB power-supply can exist, user can pass qcom,psy-not-used
with other instances of dwc3 which will be by default in
host mode. User can change the mode later 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: I965ba0950e9ef647d8e8fec0b2f4e0c7987329a6
Signed-off-by: default avatarPratham Pratap <prathampratap@codeaurora.org>
parent 79459f1b
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -52,6 +52,7 @@ Optional properties :
  runtimePM state of host.
- qcom,psy-not-used: If present then driver won't be registering usb power_supply.
  Without usb_psy, user should be able to change modes using sysfs.
- qcom,usb-core-id: Differentiates between primary and secondary controller.

Sub nodes:
- Sub node for "DWC3- USB3 controller".
+6 −0
Original line number Diff line number Diff line
@@ -783,6 +783,7 @@ static int dwc3_probe(struct platform_device *pdev)
	u8			lpm_nyet_threshold;
	u8			hird_threshold;
	u32			num_evt_buffs;
	u32			core_id;
	int			irq;

	int			ret;
@@ -896,6 +897,11 @@ static int dwc3_probe(struct platform_device *pdev)
		if (!ret)
			dwc->num_gsi_event_buffers = num_evt_buffs;

		ret = of_property_read_u32(node,
				"qcom,usb-core-id", &core_id);
		if (!ret)
			dwc->core_id = core_id;

		if (dwc->enable_bus_suspend) {
			pm_runtime_set_autosuspend_delay(dev, 500);
			pm_runtime_use_autosuspend(dev);
+1 −0
Original line number Diff line number Diff line
@@ -881,6 +881,7 @@ struct dwc3 {
	u32			num_event_buffers;
	u32			num_normal_event_buffers;
	u32			num_gsi_event_buffers;
	u32			core_id;

	u32			u1;
	u32			u1u2;
+10 −0
Original line number Diff line number Diff line
@@ -3249,6 +3249,16 @@ static int dwc3_msm_probe(struct platform_device *pdev)
		dwc3_ext_event_notify(mdwc);
	}

	/* If the controller is in DRD mode and USB power supply
	 * is not used make the default mode of contoller as HOST
	 * mode. User can change it later using sysfs
	 */
	if (dwc->is_drd && mdwc->psy_not_used) {
		dev_dbg(&pdev->dev, "DWC3 in host mode\n");
		mdwc->id_state = DWC3_ID_GROUND;
		dwc3_ext_event_notify(mdwc);
	}

	return 0;

put_dwc3:
+3 −0
Original line number Diff line number Diff line
@@ -3690,6 +3690,9 @@ int dwc3_gadget_init(struct dwc3 *dwc)
	 * sure we're starting from a well known location.
	 */

	dwc->gadget.usb_core_id = dwc->core_id;
	dev_dbg(dwc->dev, "%s core_id : %d\n", __func__, dwc->core_id);

	ret = dwc3_gadget_init_endpoints(dwc);
	if (ret)
		goto err4;