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

Commit 25bdfd2b authored by Jack Pham's avatar Jack Pham
Browse files

usb: dwc3-msm: Reduce usage of usb power_supply



On platforms with multiple USB controller instances, usually only
one is associated with the charger and the single instance of the
"usb" power_supply. Thus the non-charging instances do not need
to access it.

Even in that case it is now only useful for setting max current
based on enumeration in device mode. It is no longer required to
query for PROP_PRESENT during probe so getting of the usb_psy can
be removed there as well. Finally remove setting of
PROP_BOOST_CURRENT which is also no longer used.

Change-Id: I6f393105b65c6580a92e3161d16b1e2dce11a37d
Signed-off-by: default avatarJack Pham <jackp@codeaurora.org>
parent 76f60b6d
Loading
Loading
Loading
Loading
+2 −45
Original line number Diff line number Diff line
@@ -3110,7 +3110,6 @@ static int dwc3_msm_probe(struct platform_device *pdev)
{
	struct device_node *node = pdev->dev.of_node, *dwc3_node;
	struct device	*dev = &pdev->dev;
	union power_supply_propval pval = {0};
	struct dwc3_msm *mdwc;
	struct dwc3	*dwc;
	struct resource *res;
@@ -3361,26 +3360,12 @@ static int dwc3_msm_probe(struct platform_device *pdev)
	}

	mutex_init(&mdwc->suspend_resume_mutex);
	mdwc->usb_psy = power_supply_get_by_name("usb");
	if (!mdwc->usb_psy) {
		dev_warn(mdwc->dev, "Could not get usb power_supply\n");
		pval.intval = -EINVAL;
	} else {
		power_supply_get_property(mdwc->usb_psy,
			POWER_SUPPLY_PROP_PRESENT, &pval);
	}

	ret = dwc3_msm_extcon_register(mdwc);
	if (ret)
		goto put_psy;
		goto put_dwc3;

	if (!pval.intval) {
		/* USB cable is not connected */
	schedule_delayed_work(&mdwc->sm_work, 0);
	} else {
		if (!mdwc->vbus_active && mdwc->id_state && pval.intval > 0)
			dev_info(mdwc->dev, "charger detection in progress\n");
	}

	device_create_file(&pdev->dev, &dev_attr_mode);
	device_create_file(&pdev->dev, &dev_attr_speed);
@@ -3395,10 +3380,6 @@ static int dwc3_msm_probe(struct platform_device *pdev)

	return 0;

put_psy:
	if (mdwc->usb_psy)
		power_supply_put(mdwc->usb_psy);

put_dwc3:
	if (mdwc->bus_perf_client)
		msm_bus_scale_unregister_client(mdwc->bus_perf_client);
@@ -3499,18 +3480,10 @@ static int dwc3_msm_host_notifier(struct notifier_block *nb,
	struct dwc3_msm *mdwc = container_of(nb, struct dwc3_msm, host_nb);
	struct dwc3 *dwc = platform_get_drvdata(mdwc->dwc3);
	struct usb_device *udev = ptr;
	union power_supply_propval pval;
	unsigned int max_power;

	if (event != USB_DEVICE_ADD && event != USB_DEVICE_REMOVE)
		return NOTIFY_DONE;

	if (!mdwc->usb_psy) {
		mdwc->usb_psy = power_supply_get_by_name("usb");
		if (!mdwc->usb_psy)
			return NOTIFY_DONE;
	}

	/*
	 * For direct-attach devices, new udev is direct child of root hub
	 * i.e. dwc -> xhci -> root_hub -> udev
@@ -3533,23 +3506,7 @@ static int dwc3_msm_host_notifier(struct notifier_block *nb,
			} else {
				mdwc->max_rh_port_speed = USB_SPEED_SUPER;
			}

			if (udev->speed >= USB_SPEED_SUPER)
				max_power = udev->actconfig->desc.bMaxPower * 8;
			else
				max_power = udev->actconfig->desc.bMaxPower * 2;
			dev_dbg(mdwc->dev, "%s configured bMaxPower:%d (mA)\n",
					dev_name(&udev->dev), max_power);

			/* inform PMIC of max power so it can optimize boost */
			pval.intval = max_power * 1000;
			power_supply_set_property(mdwc->usb_psy,
					POWER_SUPPLY_PROP_BOOST_CURRENT, &pval);
		} else {
			pval.intval = 0;
			power_supply_set_property(mdwc->usb_psy,
					POWER_SUPPLY_PROP_BOOST_CURRENT, &pval);

			/* set rate back to default core clk rate */
			clk_set_rate(mdwc->core_clk, mdwc->core_clk_rate);
			dev_dbg(mdwc->dev, "set core clk rate %ld\n",