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

Commit d4f80331 authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "msm: qpnp-usbdetect: Make vin-supply optional"

parents 5cf60f84 ef0c01ba
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -11,7 +11,9 @@ Required Properties:
 - compatible: must be "qcom,qpnp-usbdetect"
 - interrupts: an interrupt triggered by the output of the detection circuit
 - interrupt-names: must be "vbus_det_irq"
 - vin-supply: phandle to a regulator that supplies 5V to this circuit

Optional Properties:
 - vin-supply: phandle to a regulator that powers this circuit, if needed

Example:

+20 −12
Original line number Diff line number Diff line
@@ -59,21 +59,27 @@ static int qpnp_usbdetect_probe(struct platform_device *pdev)
	usb->pdev = pdev;
	usb->usb_psy = usb_psy;

	if (of_get_property(pdev->dev.of_node, "vin-supply", NULL)) {
		usb->vin = devm_regulator_get(&pdev->dev, "vin");
		if (IS_ERR(usb->vin)) {
			dev_err(&pdev->dev, "Failed to get VIN regulator: %ld\n",
				PTR_ERR(usb->vin));
			return PTR_ERR(usb->vin);
		}
	}

	if (usb->vin) {
		rc = regulator_enable(usb->vin);
		if (rc) {
		dev_err(&pdev->dev, "Failed to enable VIN regulator: %d\n", rc);
			dev_err(&pdev->dev, "Failed to enable VIN regulator: %d\n",
				rc);
			return rc;
		}
	}

	usb->vbus_det_irq = platform_get_irq_byname(pdev, "vbus_det_irq");
	if (usb->vbus_det_irq < 0) {
		if (usb->vin)
			regulator_disable(usb->vin);
		return usb->vbus_det_irq;
	}
@@ -85,6 +91,7 @@ static int qpnp_usbdetect_probe(struct platform_device *pdev)
	if (rc) {
		dev_err(&pdev->dev, "request for vbus_det_irq failed: %d\n",
			rc);
		if (usb->vin)
			regulator_disable(usb->vin);
		return rc;
	}
@@ -108,6 +115,7 @@ static int qpnp_usbdetect_remove(struct platform_device *pdev)

	disable_irq_wake(usb->vbus_det_irq);
	disable_irq(usb->vbus_det_irq);
	if (usb->vin)
		regulator_disable(usb->vin);

	return 0;