[T106][ZXW-22]7520V3SCV2.01.01.02P42U09_VEC_V0.8_AP_VEC origin source commit

Change-Id: Ic6e05d89ecd62fc34f82b23dcf306c93764aec4b
diff --git a/boot/common/src/uboot/drivers/charger/Makefile b/boot/common/src/uboot/drivers/charger/Makefile
new file mode 100755
index 0000000..30f120b
--- /dev/null
+++ b/boot/common/src/uboot/drivers/charger/Makefile
@@ -0,0 +1,46 @@
+#
+# (C) Copyright 2000-2007
+# Wolfgang Denk, DENX Software Engineering, wd@denx.de.
+#
+# See file CREDITS for list of people who contributed to this
+# project.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation; either version 2 of
+# the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+
+include $(TOPDIR)/config.mk
+
+LIB	:= $(obj)libcharger.o
+#COBJS-$(CONFIG_CHARGER_ZX234502) += zx234502.o
+COBJS-y += zx234502.o
+
+COBJS	:= $(sort $(COBJS-y))
+SRCS	:= $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+
+all:	$(LIB)
+
+$(LIB):	$(obj).depend $(OBJS)
+	$(call cmd_link_o_target, $(OBJS))
+
+#########################################################################
+
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
+
+sinclude $(obj).depend
+
+#########################################################################
diff --git a/boot/common/src/uboot/drivers/charger/zx234502.c b/boot/common/src/uboot/drivers/charger/zx234502.c
new file mode 100644
index 0000000..06316a1
--- /dev/null
+++ b/boot/common/src/uboot/drivers/charger/zx234502.c
@@ -0,0 +1,137 @@
+/*********************************************************************
+ Copyright 2016 by  ZIXC Corporation.
+*
+* FileName::    zx234290.c
+* File Mark:
+* Description:
+* Others:
+* Version:
+* Author:
+* Date:
+
+* History 1:
+*     Date:
+*     Version:
+*     Author:
+*     Modification:
+* History 2:
+**********************************************************************/
+
+#include <common.h>
+#include <errno.h>
+#include <command.h>
+#include <malloc.h>
+#include <asm/io.h>
+#include <boot_mode.h>
+#include <i2c.h>
+#include <zx234502.h>
+
+
+
+/*******************************************************************************
+ * Function:    zx234290_i2c_read_reg
+ * Description:
+ * Parameters:
+ *	 Input:
+ *
+ *	 Output:
+ *
+ * Returns:
+ *
+ *
+ * Others:
+ ********************************************************************************/
+int zx234502_i2c_read_reg(ushort reg, uchar *val)
+{
+    return i2c_read(1, ZX234502_I2C_SLAVE_ADDR, reg, 8, val, 1);
+}
+
+
+
+/*******************************************************************************
+ * Function:    zx234290_i2c_write_reg
+ * Description:
+ * Parameters:
+ *	 Input:
+ *
+ *	 Output:
+ *
+ * Returns:
+ *
+ *
+ * Others:
+ ********************************************************************************/
+int zx234502_i2c_write_reg(ushort reg, uchar *val)
+{
+    return i2c_write(1, ZX234502_I2C_SLAVE_ADDR, reg, 8, val, 1);
+}
+
+/*******************************************************************************
+ * Function:    zx234502_boost_flag
+ * Description:
+ * Parameters:
+ *	 Input:
+ *
+ *	 Output:
+ *
+ * Returns:
+ *
+ *
+ * Others:
+ ********************************************************************************/
+int zx234502_boost_flag(int *boost_flag)
+{
+    int ret = 0;
+    uchar reg = 0;
+
+
+    ret = zx234502_i2c_read_reg(ZX234502_REG_PIS, &reg);
+    if( ret != 0 ){
+		printf( "[zx234502_boost_flag]ERROR!!\n");
+        return 1;
+    }
+    printf( "    [zx234502_boost_flag][ZX234502_REG_PIS = 0x%x] ...\n", reg);
+
+    *boost_flag = reg & ZX234502_REG_PIS_POWERON_IT_MASK;
+
+    return 0;
+}
+
+/*******************************************************************************
+ * Function:    zx234502_battery_status
+ * Description:
+ * Parameters:
+ *	 Input:
+ *
+ *	 Output:
+ *
+ * Returns:
+ *
+ *
+ * Others:
+ ********************************************************************************/
+int zx234502_battery_status(int *bat_state)
+{
+    int ret = 0;
+    uchar reg = 0;
+
+    ret = zx234502_i2c_read_reg(ZX234502_REG_CBIS, &reg);
+    if( ret != 0 ){
+		printf( "[zx234502_battery_status]ERROR!!\n");
+        return 1;
+    }
+    printf( "    [zx234502_boost_flag][zx234502_battery_status = 0x%x] ...\n", reg);
+
+    *bat_state = reg & ZX234502_REG_CBIS_NOBAT_MASK;
+
+    return 0;
+}
+
+int zx234502_charger_enable()
+{
+	unsigned char  reg = 0;
+	reg &= ~0xF;
+	zx234502_i2c_write_reg(0, &reg);
+
+    return 0;
+}