Commits

Anonymous committed 5194a3d

power: charger: need sometime to handle the usb disconnecting events

When being completely charged in the offmode charging and pulling out TA
from sleep condition, I gave 1 sec. delay until entering sleep condition again,
in order to prevent the phenomenon that a device doesn't turn off.

We need sometime for an userspace application to handle the usb disconnection
events. There is no effect of power consumption.

Change-Id: I0851cc2b47c3780fd68d3e8965fd0d6f5b7e8312

Comments (0)

Files changed (1)

drivers/power/pm8921-charger.c

 #define EOC_CHECK_PERIOD_MS	10000
 /* check for USB unplug every 200 msecs */
 #define UNPLUG_CHECK_WAIT_PERIOD_MS 200
+/* wait for 1s to complete the chg gone handling */
+#define CHG_GONE_WAIT_TIMEOUT 1000
 
 enum chg_fsm_state {
 	FSM_STATE_OFF_0 = 0,
 	struct delayed_work		unplug_usbcheck_work;
 	struct delayed_work		vin_collapse_check_work;
 	struct wake_lock		eoc_wake_lock;
+	struct wake_lock		chg_gone_wake_lock;
 	enum pm8921_chg_cold_thr	cold_thr;
 	enum pm8921_chg_hot_thr		hot_thr;
 	int				rconn_mohm;
 	struct pm8921_chg_chip *chip = data;
 	int chg_gone, usb_chg_plugged_in;
 
+	wake_lock_timeout(&chip->chg_gone_wake_lock,
+			msecs_to_jiffies(CHG_GONE_WAIT_TIMEOUT));
+
 	usb_chg_plugged_in = is_usb_chg_plugged_in(chip);
 	chg_gone = pm_chg_get_rt_status(chip, CHG_GONE_IRQ);
 
 	the_chip = chip;
 
 	wake_lock_init(&chip->eoc_wake_lock, WAKE_LOCK_SUSPEND, "pm8921_eoc");
+	wake_lock_init(&chip->chg_gone_wake_lock,
+			WAKE_LOCK_SUSPEND, "pm8921_chg_gone");
+
 	INIT_DELAYED_WORK(&chip->eoc_work, eoc_worker);
 	INIT_DELAYED_WORK(&chip->vin_collapse_check_work,
 						vin_collapse_check_worker);
 {
 	struct pm8921_chg_chip *chip = platform_get_drvdata(pdev);
 
+	wake_lock_destroy(&chip->chg_gone_wake_lock);
 	device_remove_file(&pdev->dev, &dev_attr_charge);
 	free_irqs(chip);
 	platform_set_drvdata(pdev, NULL);