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

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

Merge "platform: msm: gpio-usbdetect: Report charger types in REAL_TYPE"

parents 655c90f4 d41465fb
Loading
Loading
Loading
Loading
+27 −5
Original line number Diff line number Diff line
@@ -193,6 +193,28 @@ queue_chg_work:
	return IRQ_HANDLED;
}

static int gpio_usbdetect_notify_usb_type(struct gpio_usbdetect *usb,
					enum power_supply_type type)
{
	int rc;
	union power_supply_propval pval = {0, };

	pval.intval = type;
	rc = usb->usb_psy->set_property(usb->usb_psy,
			POWER_SUPPLY_PROP_REAL_TYPE, &pval);
	if (rc < 0) {
		if (rc == -EINVAL) {
			rc = usb->usb_psy->set_property(usb->usb_psy,
					POWER_SUPPLY_PROP_TYPE, &pval);
			if (!rc)
				return 0;
		}
		pr_err("notify charger type to usb_psy failed, rc=%d\n", rc);
	}

	return rc;
}

static void gpio_usbdetect_chg_work(struct work_struct *w)
{
	struct gpio_usbdetect *usb = container_of(w, struct gpio_usbdetect,
@@ -202,7 +224,7 @@ static void gpio_usbdetect_chg_work(struct work_struct *w)
		dev_dbg(&usb->pdev->dev, "ID:%d VBUS:%d\n",
						usb->id, usb->vbus);
		if (!usb->id) {
			power_supply_set_supply_type(usb->usb_psy,
			gpio_usbdetect_notify_usb_type(usb,
					POWER_SUPPLY_TYPE_UNKNOWN);
			power_supply_set_present(usb->usb_psy, 0);
			power_supply_set_usb_otg(usb->usb_psy, 1);
@@ -217,11 +239,11 @@ static void gpio_usbdetect_chg_work(struct work_struct *w)
			gpio_set_value(usb->dpdm_switch_gpio, 0);

		if (usb->vbus) {
			power_supply_set_supply_type(usb->usb_psy,
			gpio_usbdetect_notify_usb_type(usb,
						POWER_SUPPLY_TYPE_USB);
			power_supply_set_present(usb->usb_psy, usb->vbus);
		} else {
			power_supply_set_supply_type(usb->usb_psy,
			gpio_usbdetect_notify_usb_type(usb,
					POWER_SUPPLY_TYPE_UNKNOWN);
			power_supply_set_present(usb->usb_psy, usb->vbus);
		}
@@ -234,13 +256,13 @@ static void gpio_usbdetect_chg_work(struct work_struct *w)
			power_supply_set_usb_otg(usb->usb_psy, 0);

		if (!usb->disable_device_mode) {
			power_supply_set_supply_type(usb->usb_psy,
			gpio_usbdetect_notify_usb_type(usb,
						POWER_SUPPLY_TYPE_USB);
			power_supply_set_present(usb->usb_psy, usb->vbus);
		}
	} else {
		/* notify gpio_state = LOW as disconnect */
		power_supply_set_supply_type(usb->usb_psy,
		gpio_usbdetect_notify_usb_type(usb,
				POWER_SUPPLY_TYPE_UNKNOWN);
		power_supply_set_present(usb->usb_psy, usb->vbus);