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

Commit dc2ecf77 authored by Sriharsha Allenki's avatar Sriharsha Allenki Committed by Jack Pham
Browse files

usb: dwc3: Start the core in host mode only if there is no extcon



The current driver starts the core in host mode even if
there is extcon available for that core. This causes
the id_state to be overwritten to ID_GROUND irrespective
of the current extcon state.
Fix this starting the core in host mode by default only
if there is no extcon present.

Change-Id: Idd0885942e5e854f0aafc4a26a6eb27033f00935
Signed-off-by: default avatarSriharsha Allenki <sallenki@codeaurora.org>
parent ce2d64b7
Loading
Loading
Loading
Loading
+16 −23
Original line number Diff line number Diff line
@@ -3005,17 +3005,6 @@ static int dwc3_msm_extcon_register(struct dwc3_msm *mdwc)
	struct extcon_dev *edev;
	int idx, extcon_cnt, ret = 0;
	bool check_vbus_state, check_id_state, phandle_found = false;
	struct dwc3 *dwc = platform_get_drvdata(mdwc->dwc3);

	if (!of_property_read_bool(node, "extcon")) {
		if (dwc3_is_otg_or_drd(dwc)) {
			dev_dbg(mdwc->dev, "%s: no extcon, simulate vbus connect\n",
								__func__);
			mdwc->vbus_active = true;
			queue_work(mdwc->dwc3_wq, &mdwc->resume_work);
		}
		return 0;
	}

	extcon_cnt = of_count_phandle_with_args(node, "extcon", NULL);
	if (extcon_cnt < 0) {
@@ -3309,7 +3298,6 @@ static int dwc3_msm_probe(struct platform_device *pdev)
	struct dwc3_msm *mdwc;
	struct dwc3	*dwc;
	struct resource *res;
	bool host_mode;
	int ret = 0, size = 0, i;
	u32 val;
	unsigned long irq_type;
@@ -3580,24 +3568,29 @@ static int dwc3_msm_probe(struct platform_device *pdev)

	mutex_init(&mdwc->suspend_resume_mutex);

	if (of_property_read_bool(node, "extcon")) {
		ret = dwc3_msm_extcon_register(mdwc);
		if (ret)
			goto put_dwc3;
	} else {
		if (dwc3_is_otg_or_drd(dwc) ||
				dwc->dr_mode == USB_DR_MODE_PERIPHERAL) {
			dev_dbg(mdwc->dev, "%s: no extcon, simulate vbus connect\n",
								__func__);
			mdwc->vbus_active = true;
		} else if (dwc->dr_mode == USB_DR_MODE_HOST) {
			dev_dbg(mdwc->dev, "DWC3 in host only mode\n");
			mdwc->id_state = DWC3_ID_GROUND;
		}

	schedule_delayed_work(&mdwc->sm_work, 0);
		dwc3_ext_event_notify(mdwc);
	}

	device_create_file(&pdev->dev, &dev_attr_mode);
	device_create_file(&pdev->dev, &dev_attr_speed);
	device_create_file(&pdev->dev, &dev_attr_usb_compliance_mode);
	device_create_file(&pdev->dev, &dev_attr_bus_vote);

	host_mode = usb_get_dr_mode(&mdwc->dwc3->dev) == USB_DR_MODE_HOST;
	if (host_mode) {
		dev_dbg(&pdev->dev, "DWC3 in host only mode\n");
		mdwc->id_state = DWC3_ID_GROUND;
		dwc3_ext_event_notify(mdwc);
	}

	return 0;

put_dwc3: