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

Commit 826388f7 authored by Manu Gautam's avatar Manu Gautam
Browse files

msm: qpnp-usbdetect: Report initial VBUS state on bootup



Interrupt for Vbus detection may not be fired if system boots up
with USB cable connected or Vbus HIGH. Read Vbus state on bootup
and call power_supply API explicitly to report Vbus state.

Change-Id: Ic5b4fd6ba495e7bd7c78de4a7e0ac68e851b4cc4
Signed-off-by: default avatarManu Gautam <mgautam@codeaurora.org>
parent d2056c0d
Loading
Loading
Loading
Loading
+10 −2
Original line number Diff line number Diff line
/* Copyright (c) 2013, The Linux Foundation. All rights reserved.
/* Copyright (c) 2013-2014, 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
@@ -43,7 +43,8 @@ static int qpnp_usbdetect_probe(struct platform_device *pdev)
{
	struct qpnp_usbdetect *usb;
	struct power_supply *usb_psy;
	int rc;
	int rc, vbus;
	unsigned long flags;

	usb_psy = power_supply_get_by_name("usb");
	if (!usb_psy) {
@@ -91,6 +92,13 @@ static int qpnp_usbdetect_probe(struct platform_device *pdev)
	enable_irq_wake(usb->vbus_det_irq);
	dev_set_drvdata(&pdev->dev, usb);

	/* Read and report initial VBUS state */
	local_irq_save(flags);
	vbus = !!irq_read_line(usb->vbus_det_irq);
	local_irq_restore(flags);

	power_supply_set_present(usb->usb_psy, vbus);

	return 0;
}