target: msmtitanium: Improve logic for power off charging trigger
Use usb present rt_stat combined with pon reason to decide whether
entering into power off charging phase.
Change-Id: I8ca5099d8273fabf3e65bf457bfe3024cdf92601
CRs-Fixed: 967637
diff --git a/target/msmtitanium/init.c b/target/msmtitanium/init.c
index 952b33f..9d53acd 100644
--- a/target/msmtitanium/init.c
+++ b/target/msmtitanium/init.c
@@ -348,12 +348,16 @@
return _emmc_recovery_init();
}
+#define SMBCHG_USB_RT_STS 0x21310
+#define USBIN_UV_RT_STS BIT(0)
unsigned target_pause_for_battery_charge(void)
{
uint8_t pon_reason = pm8x41_get_pon_reason();
uint8_t is_cold_boot = pm8x41_get_is_cold_boot();
- dprintf(INFO, "%s : pon_reason is %d cold_boot:%d\n", __func__,
- pon_reason, is_cold_boot);
+ bool usb_present_sts = !(USBIN_UV_RT_STS &
+ pm8x41_reg_read(SMBCHG_USB_RT_STS));
+ dprintf(INFO, "%s : pon_reason is:0x%x cold_boot:%d usb_sts:%d\n", __func__,
+ pon_reason, is_cold_boot, usb_present_sts);
/* In case of fastboot reboot,adb reboot or if we see the power key
* pressed we do not want go into charger mode.
* fastboot reboot is warm boot with PON hard reset bit not set
@@ -362,7 +366,7 @@
if (is_cold_boot &&
(!(pon_reason & HARD_RST)) &&
(!(pon_reason & KPDPWR_N)) &&
- ((pon_reason & USB_CHG) || (pon_reason & DC_CHG) || (pon_reason & CBLPWR_N)))
+ usb_present_sts)
return 1;
else
return 0;