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

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

Merge "gpio-usbdetect: disable gpio trigger USB device mode"

parents 079baed6 0738f39f
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -20,6 +20,8 @@ Optional Properties:
	disconnect.
- qcom,gpio-mode-sel: If present, specifies a gpio to switch to host mode if
	value is 0 or device mode if 1.
- qcom,disable-device-mode: If present then don't treat GPIO high as Vbus high.
	And only notify host mode similar to ID line.

Example:

+9 −4
Original line number Diff line number Diff line
/* Copyright (c) 2013-2016, The Linux Foundation. All rights reserved.
/* Copyright (c) 2013-2017, 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
@@ -33,6 +33,7 @@ struct gpio_usbdetect {
	struct regulator	*vdd12;
	int			gpio_usbdetect;
	bool			notify_host_mode;
	bool			disable_device_mode;
};

static int gpio_enable_ldos(struct gpio_usbdetect *usb, int on)
@@ -162,9 +163,11 @@ static irqreturn_t gpio_usbdetect_vbus_irq(int irq, void *data)
		if (usb->notify_host_mode)
			power_supply_set_usb_otg(usb->usb_psy, 0);

		if (!usb->disable_device_mode) {
			power_supply_set_supply_type(usb->usb_psy,
						POWER_SUPPLY_TYPE_USB);
			power_supply_set_present(usb->usb_psy, vbus);
		}
	} else {
		/* notify gpio_state = LOW as disconnect */
		power_supply_set_supply_type(usb->usb_psy,
@@ -199,6 +202,8 @@ static int gpio_usbdetect_probe(struct platform_device *pdev)
	usb->usb_psy = usb_psy;
	usb->notify_host_mode = of_property_read_bool(pdev->dev.of_node,
					"qcom,notify-host-mode");
	usb->disable_device_mode = of_property_read_bool(pdev->dev.of_node,
					"qcom,disable-device-mode");
	rc = gpio_enable_ldos(usb, 1);
	if (rc)
		return rc;