Merge 4d659d25ef72ab61f3808723e889dd0c7e80be55 on remote branch

Change-Id: Icbb2aa4a7637232db91bb473427e6573e333b0fc
diff --git a/AndroidBoot.mk b/AndroidBoot.mk
index 6c67721..56c0ab7 100644
--- a/AndroidBoot.mk
+++ b/AndroidBoot.mk
@@ -45,6 +45,12 @@
   QSEECOM_SECAPP_REGION_2MB := QSEECOM_SECAPP_REGION_2MB=0
 endif
 
+ifeq ($(TARGET_USES_OTA_KEY_FOR_ROT),true)
+  VB1_KEY_USED := VB1_KEY_USED=1
+else
+  VB1_KEY_USED := VB1_KEY_USED=0
+endif
+
 ifeq ($(BOARD_AVB_ENABLE),true)
   VERIFIED_BOOT_2 := VERIFIED_BOOT_2=1
 else
@@ -131,7 +137,7 @@
 # ELF binary for ABOOT
 TARGET_ABOOT_ELF := $(PRODUCT_OUT)/aboot.elf
 $(TARGET_ABOOT_ELF): ABOOT_CLEAN | $(ABOOT_OUT)
-	$(MAKE) -C $(LK_PATH) TOOLCHAIN_PREFIX=$(CROSS_COMPILE) BOOTLOADER_OUT=$(CROOT_DIR)/$(ABOOT_OUT) $(BOOTLOADER_PLATFORM) $(EMMC_BOOT) $(SIGNED_KERNEL) $(VERIFIED_BOOT) $(VERIFIED_BOOT_2) $(TARGET_DTBO_NOT_SUPPORTED) $(ENABLE_DISPLAY) $(ENABLE_KASLRSEED) $(ENABLE_BOOTDEVICE_MOUNT) $(DEVICE_STATUS) $(BUILD_VARIANT) $(BOARD_NAME) $(ENABLE_VB_ATTEST) $(OSVERSION_IN_BOOTIMAGE) $(QSEECOM_SECAPP_REGION_2MB) $(TARGET_USE_SYSTEM_AS_ROOT_IMAGE) $(DYNAMIC_PARTITION_SUPPORT)
+	$(MAKE) -C $(LK_PATH) TOOLCHAIN_PREFIX=$(CROSS_COMPILE) BOOTLOADER_OUT=$(CROOT_DIR)/$(ABOOT_OUT) $(BOOTLOADER_PLATFORM) $(EMMC_BOOT) $(SIGNED_KERNEL) $(VERIFIED_BOOT) $(VERIFIED_BOOT_2) $(VB1_KEY_USED) $(TARGET_DTBO_NOT_SUPPORTED) $(ENABLE_DISPLAY) $(ENABLE_KASLRSEED) $(ENABLE_BOOTDEVICE_MOUNT) $(DEVICE_STATUS) $(BUILD_VARIANT) $(BOARD_NAME) $(ENABLE_VB_ATTEST) $(OSVERSION_IN_BOOTIMAGE) $(QSEECOM_SECAPP_REGION_2MB) $(TARGET_USE_SYSTEM_AS_ROOT_IMAGE) $(DYNAMIC_PARTITION_SUPPORT)
 
 # NAND variant output
 TARGET_NAND_BOOTLOADER := $(PRODUCT_OUT)/appsboot.mbn
@@ -160,7 +166,7 @@
 
 # Top level for eMMC variant targets
 $(TARGET_EMMC_BOOTLOADER): emmc_appsbootldr_clean | $(EMMC_BOOTLOADER_OUT) $(INSTALLED_KEYSTOREIMAGE_TARGET)
-	$(MAKE) -C $(LK_PATH) TOOLCHAIN_PREFIX=$(CROSS_COMPILE) BOOTLOADER_OUT=$(CROOT_DIR)/$(EMMC_BOOTLOADER_OUT) $(BOOTLOADER_PLATFORM) EMMC_BOOT=1 $(SIGNED_KERNEL) $(VERIFIED_BOOT) $(VERIFIED_BOOT_2) $(TARGET_DTBO_NOT_SUPPORTED) $(ENABLE_DISPLAY) $(ENABLE_KASLRSEED) $(ENABLE_BOOTDEVICE_MOUNT) $(DEVICE_STATUS) $(BUILD_VARIANT) $(BOARD_NAME) $(ENABLE_VB_ATTEST) $(OSVERSION_IN_BOOTIMAGE) $(ENABLE_BG_SUPPORT) $(QSEECOM_SECAPP_REGION_2MB) $(TARGET_USE_SYSTEM_AS_ROOT_IMAGE) $(DYNAMIC_PARTITION_SUPPORT)
+	$(MAKE) -C $(LK_PATH) TOOLCHAIN_PREFIX=$(CROSS_COMPILE) BOOTLOADER_OUT=$(CROOT_DIR)/$(EMMC_BOOTLOADER_OUT) $(BOOTLOADER_PLATFORM) EMMC_BOOT=1 $(SIGNED_KERNEL) $(VERIFIED_BOOT) $(VERIFIED_BOOT_2) $(VB1_KEY_USED) $(TARGET_DTBO_NOT_SUPPORTED) $(ENABLE_DISPLAY) $(ENABLE_KASLRSEED) $(ENABLE_BOOTDEVICE_MOUNT) $(DEVICE_STATUS) $(BUILD_VARIANT) $(BOARD_NAME) $(ENABLE_VB_ATTEST) $(OSVERSION_IN_BOOTIMAGE) $(ENABLE_BG_SUPPORT) $(QSEECOM_SECAPP_REGION_2MB) $(TARGET_USE_SYSTEM_AS_ROOT_IMAGE) $(DYNAMIC_PARTITION_SUPPORT)
 
 # Keep build NAND & eMMC as default for targets still using TARGET_BOOTLOADER
 TARGET_BOOTLOADER := $(PRODUCT_OUT)/EMMCBOOT.MBN
diff --git a/dev/pmic/pm8x41/include/qpnp-fg-gen3.h b/dev/pmic/pm8x41/include/qpnp-fg-gen3.h
new file mode 100644
index 0000000..baae8e3
--- /dev/null
+++ b/dev/pmic/pm8x41/include/qpnp-fg-gen3.h
@@ -0,0 +1,38 @@
+/* Copyright (c) 2015, 2019, The Linux Foundation. All rights reserved.
+
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *   * Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ *   * Redistributions in binary form must reproduce the above
+ *     copyright notice, this list of conditions and the following
+ *     disclaimer in the documentation and/or other materials provided
+ *     with the distribution.
+ *   * Neither the name of The Linux Foundation nor the names of its
+ *     contributors may be used to endorse or promote products derived
+ *     from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _QPNP_FG_GEN3_H_
+#define _QPNP_FG_GEN3_H_
+
+#include <stdint.h>
+#include <sys/types.h>
+
+uint32_t fg_gen3_get_battery_voltage(void);
+int fg_gen3_get_battery_current(void);
+
+#endif
diff --git a/dev/pmic/pm8x41/include/qpnp-smb2.h b/dev/pmic/pm8x41/include/qpnp-smb2.h
new file mode 100644
index 0000000..fb905b9
--- /dev/null
+++ b/dev/pmic/pm8x41/include/qpnp-smb2.h
@@ -0,0 +1,34 @@
+/* Copyright (c) 2015, 2019, The Linux Foundation. All rights reserved.
+
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *   * Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ *   * Redistributions in binary form must reproduce the above
+ *     copyright notice, this list of conditions and the following
+ *     disclaimer in the documentation and/or other materials provided
+ *     with the distribution.
+ *   * Neither the name of The Linux Foundation nor the names of its
+ *     contributors may be used to endorse or promote products derived
+ *     from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _QPNP_SMB2_H_
+#define _QPNP_SMB2_H_
+
+void weak_battery_charging(void);
+
+#endif
diff --git a/dev/pmic/pm8x41/qpnp-fg-gen3.c b/dev/pmic/pm8x41/qpnp-fg-gen3.c
new file mode 100644
index 0000000..39d5457
--- /dev/null
+++ b/dev/pmic/pm8x41/qpnp-fg-gen3.c
@@ -0,0 +1,101 @@
+/* Copyright (c) 2015, 2019, The Linux Foundation. All rights reserved.
+
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *   * Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ *   * Redistributions in binary form must reproduce the above
+ *     copyright notice, this list of conditions and the following
+ *     disclaimer in the documentation and/or other materials provided
+ *     with the distribution.
+ *   * Neither the name of The Linux Foundation nor the names of its
+ *     contributors may be used to endorse or promote products derived
+ *     from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <bits.h>
+#include <debug.h>
+#include <stdlib.h>
+#include <pm8x41.h>
+#include <pm8x41_hw.h>
+#include <qpnp-fg-gen3.h>
+#include <reg.h>
+
+#define BATT_INFO_VBATT_LSB	0x41A0
+#define BATT_INFO_VBATT_MSB	0x41A1
+#define BATT_INFO_CURR_LSB	0x41A2
+#define BATT_INFO_CURR_MSB	0x41A3
+
+#define BATT_VOLTAGE_NUMR	122070
+#define BATT_VOLTAGE_DENR	1000
+#define BATT_CURRENT_NUMR	488281
+#define BATT_CURRENT_DENR	1000
+
+#define DIV_ROUND_UP(n, d) (((n) + (d) - 1) / (d))
+
+static int64_t twos_compliment_extend(int64_t val, int sign_bit_pos)
+{
+	int i, nbytes = DIV_ROUND_UP(sign_bit_pos, 8);
+	int64_t mask, val_out;
+
+	val_out = val;
+	mask = 1 << sign_bit_pos;
+	if (val & mask) {
+		for (i = 8; i > nbytes; i--) {
+			mask = 0xFFLL << ((i - 1) * 8);
+			val_out |= mask;
+		}
+
+		if ((nbytes * 8) - 1 > sign_bit_pos) {
+			mask = 1 << sign_bit_pos;
+			for (i = 1; i <= (nbytes * 8) - sign_bit_pos; i++)
+				val_out |= mask << i;
+		}
+	}
+
+	return val_out;
+}
+
+uint32_t fg_gen3_get_battery_voltage(void)
+{
+	uint8_t buff[2];
+	uint16_t temp;
+	uint32_t vbat = 0;
+
+	buff[0] = REG_READ(BATT_INFO_VBATT_LSB);
+	buff[1] = REG_READ(BATT_INFO_VBATT_MSB);
+	temp = buff[1] << 8 | buff[0];
+	/* {MSB,LSB} to decode the voltage level, refer register description. */
+	vbat = (((uint64_t)temp)*BATT_VOLTAGE_NUMR/BATT_VOLTAGE_DENR);
+
+	return vbat;
+}
+
+int fg_gen3_get_battery_current(void)
+{
+	uint8_t buff[2];
+	int current = 0;
+	int64_t temp = 0;
+
+	buff[0] = REG_READ(BATT_INFO_CURR_LSB);
+	buff[1] = REG_READ(BATT_INFO_CURR_MSB);
+	temp = buff[1] << 8 | buff[0];
+	/* Sign bit is bit 15 */
+	temp = twos_compliment_extend(temp, 15);
+	current = (((int64_t)temp)*BATT_CURRENT_NUMR/BATT_CURRENT_DENR);
+
+	return current;
+}
diff --git a/dev/pmic/pm8x41/qpnp-smb2.c b/dev/pmic/pm8x41/qpnp-smb2.c
new file mode 100644
index 0000000..07f5265
--- /dev/null
+++ b/dev/pmic/pm8x41/qpnp-smb2.c
@@ -0,0 +1,133 @@
+/* Copyright (c) 2015, 2019, The Linux Foundation. All rights reserved.
+
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *   * Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ *   * Redistributions in binary form must reproduce the above
+ *     copyright notice, this list of conditions and the following
+ *     disclaimer in the documentation and/or other materials provided
+ *     with the distribution.
+ *   * Neither the name of The Linux Foundation nor the names of its
+ *     contributors may be used to endorse or promote products derived
+ *     from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <bits.h>
+#include <debug.h>
+#include <pm8x41.h>
+#include <pm8x41_hw.h>
+#include <qpnp-smb2.h>
+#include <qpnp-fg-gen3.h>
+#include <qtimer.h>
+#include <reboot.h>
+#include <target.h>
+
+#define BATT_CHARGER_STATUS_1_REG	0x1006
+#define BATT_CHARGER_STATUS_2_REG	0x1007
+#define BATT_IF_INT_RT_STS	0x1210
+#define USBIN_PLUGIN_RT_STS_REG	0x1310
+
+#define BATT_STATUS_MASK	0x07
+#define DISABLE_CHARGE	0x07
+
+static bool is_battery_present(void)
+{
+	uint8_t val = 0;
+
+	val = REG_READ(BATT_IF_INT_RT_STS);
+
+	/*
+	 * If BATT_TERMINAL_MISSING_RT_STS BIT(5) or BATT_THERM_OR_ID_MISSING_RT_STS BIT(4)
+	 * are set, battery is not present.
+	 */
+	if ((val & BIT(5)) | (val & BIT(4)))
+		return false;
+
+	return true;
+}
+
+static void dump_jeita_status(void)
+{
+	uint8_t val = 0;
+
+	val = REG_READ(BATT_CHARGER_STATUS_2_REG);
+	dprintf(INFO,"BATT_CHARGER_STATUS_2_REG value : %d\n",val);
+}
+
+static bool is_usb_present(void)
+{
+	uint8_t val = 0;
+
+	val = REG_READ(USBIN_PLUGIN_RT_STS_REG);
+
+	if (val & BIT(4))
+		return true;
+
+	return false;
+}
+
+static bool is_battery_charging(void)
+{
+	uint8_t val = 0;
+
+	val = REG_READ(BATT_CHARGER_STATUS_1_REG);
+	dprintf(INFO,"BATT_CHARGER_STATUS_1_REG value : %d\n",val);
+	val = val & BATT_STATUS_MASK;
+
+	if (val == DISABLE_CHARGE)
+		return false;
+
+	return true;
+}
+
+void weak_battery_charging(void)
+{
+	uint32_t current_vbat = 0;
+	int batt_curr = 0;
+
+	current_vbat = fg_gen3_get_battery_voltage();
+	batt_curr = fg_gen3_get_battery_current();
+	dprintf(INFO,"Entering LK charging loop: Battery current=%d mA voltage=%d mV\n",
+								batt_curr,current_vbat);
+
+	while (current_vbat < LK_BATT_VOLT_THRESHOLD)
+	{
+		if (!is_battery_present()) {
+			dprintf(CRITICAL, "Battery is not present.Exiting weak battery charging\n");
+			break;
+		}
+
+		if (!is_usb_present()) {
+			dprintf(CRITICAL, "Shutting down because USB is not present\n");
+			shutdown_device();
+		}
+
+		if (!is_battery_charging()) {
+			dump_jeita_status();
+			dprintf(CRITICAL, "Shutting down because battery is not charging\n");
+			shutdown_device();
+		}
+
+		current_vbat = fg_gen3_get_battery_voltage();
+		batt_curr = fg_gen3_get_battery_current();
+		dprintf(INFO, "Battery Charging: current=%d mA voltage=%d mV\n",
+							batt_curr,current_vbat);
+		mdelay(1000);
+	}
+
+	dprintf(INFO,"Battery Charging is completed Booting to HLOS\n");
+}
diff --git a/dev/pmic/pm8x41/rules.mk b/dev/pmic/pm8x41/rules.mk
index 19d15be..2ee5c00 100644
--- a/dev/pmic/pm8x41/rules.mk
+++ b/dev/pmic/pm8x41/rules.mk
@@ -7,6 +7,12 @@
 	$(LOCAL_DIR)/pm8x41_adc.o \
 	$(LOCAL_DIR)/pm8x41_wled.o
 
+ifeq ($(ENABLE_WEAK_BATT_CHRG_SUPPORT),1)
+OBJS += \
+	$(LOCAL_DIR)/qpnp-smb2.o \
+	$(LOCAL_DIR)/qpnp-fg-gen3.o
+endif
+
 ifeq ($(ENABLE_PON_VIB_SUPPORT),true)
 OBJS += \
 	$(LOCAL_DIR)/pm8x41_vib.o
diff --git a/makefile b/makefile
index 9822cc5..9e9e861 100644
--- a/makefile
+++ b/makefile
@@ -127,6 +127,10 @@
   DEFINES += _SIGNED_KERNEL=1
 endif
 
+ifeq ($(VB1_KEY_USED),1)
+  DEFINES += VB1_KEY_USED=1
+endif
+
 ifeq ($(DYNAMIC_PARTITION_SUPPORT),1)
   DEFINES += DYNAMIC_PARTITION_SUPPORT=1
 endif
diff --git a/platform/msm_shared/boot_verifier.c b/platform/msm_shared/boot_verifier.c
index 4a219f1..7ee4cba 100644
--- a/platform/msm_shared/boot_verifier.c
+++ b/platform/msm_shared/boot_verifier.c
@@ -450,7 +450,7 @@
 }
 #endif
 
-#if VERIFIED_BOOT_2
+#if VERIFIED_BOOT_2 && !VB1_KEY_USED
 bool send_rot_command(uint32_t is_unlocked)
 {
 	int ret = 0;
diff --git a/project/msm8952.mk b/project/msm8952.mk
index a9cf70e..ac8da71 100644
--- a/project/msm8952.mk
+++ b/project/msm8952.mk
@@ -99,6 +99,13 @@
 DEFINES += SMD_SUPPORT=1
 endif
 
+#Enable Weak battery charging feature
+ENABLE_WEAK_BATT_CHRG_SUPPORT := 1
+
+ifeq ($(ENABLE_WEAK_BATT_CHRG_SUPPORT),1)
+DEFINES += WEAK_BATT_CHRG_SUPPORT=1
+DEFINES += LK_BATT_VOLT_THRESHOLD=3400000
+endif
 
 ifeq ($(ENABLE_MDTP_SUPPORT),1)
 DEFINES += MDTP_SUPPORT=1
diff --git a/target/msm8952/init.c b/target/msm8952/init.c
index 65967fb..c95899f 100644
--- a/target/msm8952/init.c
+++ b/target/msm8952/init.c
@@ -69,6 +69,10 @@
 #include <vibrator.h>
 #endif
 
+#if WEAK_BATT_CHRG_SUPPORT
+#include <qpnp-smb2.h>
+#endif
+
 #if PON_VIB_SUPPORT
 #define VIBRATE_TIME    250
 #endif
@@ -345,6 +349,12 @@
 		vib_timed_turn_on(VIBRATE_TIME);
 #endif
 
+#if WEAK_BATT_CHRG_SUPPORT
+	if(sdm429_pm660_target())
+		/* Start Weak Battery Charging */
+		weak_battery_charging();
+#endif
+
 	if (target_use_signed_kernel())
 		target_crypto_init_params();