summaryrefslogtreecommitdiff
path: root/board/wmt/wmt_battery/gauge
diff options
context:
space:
mode:
Diffstat (limited to 'board/wmt/wmt_battery/gauge')
-rwxr-xr-xboard/wmt/wmt_battery/gauge/bq27541/bq_battery_i2c.c133
-rw-r--r--board/wmt/wmt_battery/gauge/bq27541/bq_battery_i2c.h11
-rwxr-xr-xboard/wmt/wmt_battery/gauge/sp2541/sp2541_battery.c220
-rwxr-xr-xboard/wmt/wmt_battery/gauge/sp2541/sp2541_battery.h110
-rwxr-xr-xboard/wmt/wmt_battery/gauge/upi/Makefile47
-rwxr-xr-xboard/wmt/wmt_battery/gauge/upi/ggb/ug31xx_ggb_data_uboot_20130809_184039.h233
-rwxr-xr-xboard/wmt/wmt_battery/gauge/upi/ggb/ug31xx_ggb_data_uboot_cw500_20130801_103638.h232
-rwxr-xr-xboard/wmt/wmt_battery/gauge/upi/ggb/ug31xx_ggb_data_uboot_mp718_20131004_070110.h233
-rwxr-xr-xboard/wmt/wmt_battery/gauge/upi/ggb/ug31xx_ggb_data_uboot_t73v_20131120_001204.h233
-rwxr-xr-xboard/wmt/wmt_battery/gauge/upi/ggb/ug31xx_ggb_data_uboot_wms7320_20130718_200031.h233
-rwxr-xr-xboard/wmt/wmt_battery/gauge/upi/ggb/ug31xx_ggb_data_uboot_wms8309_c7_20130725_164935.h232
-rwxr-xr-xboard/wmt/wmt_battery/gauge/upi/ggb/ug31xx_ggb_data_uboot_wms8309_c7_20130910_130553.h233
-rwxr-xr-xboard/wmt/wmt_battery/gauge/upi/ggb/ug31xx_ggb_data_uboot_wms8309_dw7_2900_20131129_194524.h233
-rwxr-xr-xboard/wmt/wmt_battery/gauge/upi/ggb/ug31xx_ggb_data_uboot_wms8309_dw7_4000_20131129_194502.h233
-rwxr-xr-xboard/wmt/wmt_battery/gauge/upi/ggb/ug31xx_ggb_data_uboot_wms8309_wm8_20130820_110949.h233
-rwxr-xr-xboard/wmt/wmt_battery/gauge/upi/global.h31
-rwxr-xr-xboard/wmt/wmt_battery/gauge/upi/stdafx.h8
-rwxr-xr-xboard/wmt/wmt_battery/gauge/upi/timer.h302
-rwxr-xr-xboard/wmt/wmt_battery/gauge/upi/typeDefine.h462
-rwxr-xr-xboard/wmt/wmt_battery/gauge/upi/types.h16
-rwxr-xr-xboard/wmt/wmt_battery/gauge/upi/uG31xx.h129
-rwxr-xr-xboard/wmt/wmt_battery/gauge/upi/uG31xx_API.h507
-rwxr-xr-xboard/wmt/wmt_battery/gauge/upi/uG31xx_API_Backup.h54
-rwxr-xr-xboard/wmt/wmt_battery/gauge/upi/uG31xx_API_Capacity.h132
-rwxr-xr-xboard/wmt/wmt_battery/gauge/upi/uG31xx_API_Measurement.c1482
-rwxr-xr-xboard/wmt/wmt_battery/gauge/upi/uG31xx_API_Measurement.h128
-rwxr-xr-xboard/wmt/wmt_battery/gauge/upi/uG31xx_API_Otp.c917
-rwxr-xr-xboard/wmt/wmt_battery/gauge/upi/uG31xx_API_Otp.h84
-rwxr-xr-xboard/wmt/wmt_battery/gauge/upi/uG31xx_API_System.c1216
-rwxr-xr-xboard/wmt/wmt_battery/gauge/upi/uG31xx_API_System.h211
-rwxr-xr-xboard/wmt/wmt_battery/gauge/upi/uG31xx_Platform.h21
-rwxr-xr-xboard/wmt/wmt_battery/gauge/upi/uG31xx_Reg_Def.h667
-rwxr-xr-xboard/wmt/wmt_battery/gauge/upi/ug31xx_boot.c804
-rwxr-xr-xboard/wmt/wmt_battery/gauge/upi/ug31xx_boot.h71
-rwxr-xr-xboard/wmt/wmt_battery/gauge/upi/ug31xx_boot_i2c.c212
-rwxr-xr-xboard/wmt/wmt_battery/gauge/upi/ug31xx_boot_i2c.h75
-rwxr-xr-xboard/wmt/wmt_battery/gauge/vt1603/vt1603.h132
-rwxr-xr-xboard/wmt/wmt_battery/gauge/vt1603/vt1603_battery.c639
-rwxr-xr-xboard/wmt/wmt_battery/gauge/vt1603/vt1603_battery.h119
39 files changed, 11268 insertions, 0 deletions
diff --git a/board/wmt/wmt_battery/gauge/bq27541/bq_battery_i2c.c b/board/wmt/wmt_battery/gauge/bq27541/bq_battery_i2c.c
new file mode 100755
index 0000000..5a7521f
--- /dev/null
+++ b/board/wmt/wmt_battery/gauge/bq27541/bq_battery_i2c.c
@@ -0,0 +1,133 @@
+#include <common.h>
+#include <command.h>
+#include <linux/ctype.h>
+#include <asm/errno.h>
+#include "../../../include/i2c.h"
+#include "../../wmt_battery.h"
+#include "bq_battery_i2c.h"
+#define I2C_BUS_ID 3
+
+static int i2c_bus = I2C_BUS_ID;
+
+static short bq_battery_read_voltage(void);
+static short bq_battery_read_current(void);
+
+static int bq_i2c_read(unsigned char reg, unsigned char *rt_value, unsigned int len)
+{
+ struct i2c_msg_s msg[1];
+ unsigned char data[2];
+ int err;
+
+ msg->addr = BQ_I2C_DEFAULT_ADDR;
+ msg->flags = 0;
+ msg->len = 1;
+ msg->buf = data;
+
+ data[0] = reg;
+ err = wmt_i2c_transfer(msg, 1, i2c_bus);
+
+ if (err >= 0) {
+ msg->len = len;
+ msg->flags = I2C_M_RD;
+ msg->buf = rt_value;
+ err = wmt_i2c_transfer(msg, 1, i2c_bus);
+ }
+ return err;
+}
+
+static int bq_batt_init(void)
+{
+ char *env, *p;
+ char *endp;
+ p = env = getenv("wmt.battery.param");
+ if (!p)
+ return -EINVAL;
+
+ if (prefixcmp(p, "bq27xx"))
+ return -EINVAL;
+
+ p = strchr(env, ':');
+ p++;
+ i2c_bus = simple_strtol(p, &endp, 10);
+
+ return 0;
+}
+
+static short bq_battery_read_capacity(void)
+{
+ short ret = 0;
+ unsigned char value[2] = {0};
+ bq_i2c_read(BQ_REG_NAC, value, 2);
+ ret = value[1] << 8 | value[0];
+
+ //printf("%s %d\n",__FUNCTION__,ret);
+ return ret;
+}
+
+static short bq_battery_read_temperature(void)
+{
+ short ret = 0;
+ unsigned char value[2] = {0};
+ bq_i2c_read(BQ_REG_TEMP, value, 2);
+ ret = (value[1] << 8 | value[0]) - 2731;
+ return ret;
+}
+
+static unsigned short bq_battery_read_percentage(void)
+{
+ unsigned short ret = 0;
+ unsigned char value[2];
+ value[0] = 0;
+ value[1] = 0;
+ bq_i2c_read(BQ_REG_SOC, value, 2);
+ ret = value[1] << 8 | value[0];
+ printf("Current percentage: %d\%\n", ret);
+ printf("Voltage: %dmV\n", bq_battery_read_voltage());
+ printf("Current: %dmA\n", bq_battery_read_current());
+ printf("temperature: %d\n", bq_battery_read_temperature());
+ printf("capacity: %d\n", bq_battery_read_capacity());
+
+ return ret;
+}
+
+static short bq_battery_read_voltage(void)
+{
+ short ret = 0;
+ unsigned char value[2] = {0};
+ bq_i2c_read(BQ_REG_VOLT, value, 2);
+ ret = (value[1] << 8 | value[0]) * 2;
+
+ return ret;
+}
+
+static short bq_battery_read_current(void)
+{
+ short ret = 0;
+ unsigned char value[2] = {0};
+ bq_i2c_read(BQ_REG_AI, value, 2);
+ ret = value[1] << 8 | value[0];
+
+ return ret;
+}
+
+static int bq_check_bl(void)
+{
+ int percentage = bq_battery_read_percentage();
+
+ if (percentage < 0)
+ return -1;
+ return (percentage < 3);
+}
+
+
+
+struct battery_dev bq_battery_dev = {
+ .name = "bq27xx",
+ .is_gauge = 1,
+ .init = bq_batt_init,
+ .get_capacity = bq_battery_read_percentage,
+ .get_voltage = bq_battery_read_voltage,
+ .get_current = bq_battery_read_current,
+ .check_batlow = bq_check_bl,
+};
+
diff --git a/board/wmt/wmt_battery/gauge/bq27541/bq_battery_i2c.h b/board/wmt/wmt_battery/gauge/bq27541/bq_battery_i2c.h
new file mode 100644
index 0000000..e9651e8
--- /dev/null
+++ b/board/wmt/wmt_battery/gauge/bq27541/bq_battery_i2c.h
@@ -0,0 +1,11 @@
+#define BQ_REG_FCC 0x12
+#define BQ_REG_TEMP 0x06
+#define BQ_REG_SOC 0x2c
+#define BQ_REG_VOLT 0x08
+#define BQ_REG_NAC 0x0C /* Nominal available capaciy */
+#define BQ_REG_AI 0x14
+
+#define BQ_I2C_BUS 3
+#define BQ_I2C_DEFAULT_ADDR 0x55
+
+//unsigned short bq_battery_read_percentage(void);
diff --git a/board/wmt/wmt_battery/gauge/sp2541/sp2541_battery.c b/board/wmt/wmt_battery/gauge/sp2541/sp2541_battery.c
new file mode 100755
index 0000000..00a17a9
--- /dev/null
+++ b/board/wmt/wmt_battery/gauge/sp2541/sp2541_battery.c
@@ -0,0 +1,220 @@
+#include <common.h>
+#include <command.h>
+#include <linux/ctype.h>
+#include <asm/errno.h>
+#include "../../../include/i2c.h"
+#include "../../wmt_battery.h"
+#include "sp2541_battery.h"
+
+static int i2c_bus = I2C_BUS_ID;
+
+static int sp2541_read(u8 cmd, u8 reg, u8 *rt_value, unsigned int len)
+{
+ struct i2c_msg_s msg[2];
+ unsigned char data[2] = {cmd, reg};
+
+ msg[0].addr = SP2541_I2C_ADDR;
+ msg[0].flags = 0;
+ msg[0].len = 2;
+ msg[0].buf = data;
+
+ msg[1].addr = SP2541_I2C_ADDR;
+ msg[1].flags = I2C_M_RD;
+ msg[1].len = len;
+ msg[1].buf = rt_value;
+
+ return wmt_i2c_transfer(msg, 2, i2c_bus);
+}
+
+static int sp2541_write(u8 cmd, u8 reg, u8 const buf)
+{
+ struct i2c_msg_s msg;
+ char data[3] = {cmd, reg, buf};
+
+ msg.addr = SP2541_I2C_ADDR;
+ msg.flags = 0;
+ msg.len = 3;
+ msg.buf = data;
+ return wmt_i2c_transfer(&msg, 1, i2c_bus);
+}
+
+static int EEPROM_read_byte(int addr, u8 *data)
+{
+ u8 addr_hi, addr_lo, i;
+ u8 tmp = -1;
+ addr_hi = (addr >> 8) & 0xFF;
+ addr_lo = addr & 0xFF;
+ if (sp2541_write(EEPROM_WRITE_CMD, 0x00, addr_lo) < 0)
+ return -1;
+ if (sp2541_write(EEPROM_WRITE_CMD, 0x01, addr_hi) < 0)
+ return -1;
+ if (sp2541_write(EEPROM_WRITE_CMD, 0x03, 0x06) < 0)
+ return -1;
+ for (i=0; i<10; i++) {
+ sp2541_read(EEPROM_READ_CMD, 0x03, &tmp, 1);
+ if (tmp == 0)
+ break;
+ }
+ if (i == 10)
+ return -1;
+ if (sp2541_read(EEPROM_READ_CMD, 0x02, data, 1) < 0)
+ return -1;
+ return 0;
+}
+
+static int EEPROM_write_byte(int addr, u8 data)
+{
+ u8 addr_hi, addr_lo, i;
+ u8 tmp = -1;
+ addr_hi = (addr >> 8) & 0xFF;
+ addr_lo = addr & 0xFF;
+ if (sp2541_write(EEPROM_WRITE_CMD, 0x00, addr_lo) < 0)
+ return -1;
+ if (sp2541_write(EEPROM_WRITE_CMD, 0x01, addr_hi) < 0)
+ return -1;
+ if (sp2541_write(EEPROM_WRITE_CMD, 0x02, data) < 0)
+ return -1;
+ if (sp2541_write(EEPROM_WRITE_CMD, 0x03, 0x05) < 0)
+ return -1;
+ for (i=0; i<10; i++) {
+ sp2541_read(EEPROM_READ_CMD, 0x03, &tmp, 1);
+ if (tmp == 0)
+ break;
+ }
+ if (i == 10)
+ return -1;
+ return 0;
+}
+
+static int sp2541_init(void)
+{
+ char *env, *p;
+ char *endp;
+ p = env = getenv("wmt.battery.param");
+ if (!p)
+ return -EINVAL;
+
+ if (prefixcmp(p, "sp2541"))
+ return -EINVAL;
+
+ p = strchr(env, ':');
+ p++;
+ i2c_bus = simple_strtol(p, &endp, 10);
+ if (*endp != ':')
+ return -EINVAL;
+
+ return 0;
+}
+
+static int sp2541_get_capacity(void)
+{
+ unsigned char buf[2];
+ int ret;
+
+ ret = sp2541_read(RAM_READ_CMD, SP2541_REG_SOC, buf, 2);
+ if (ret<0) {
+ printf("error reading capacity\n");
+ return ret;
+ }
+ ret = buf[0] | buf[1] << 8;
+ printf("Current capacity: %d\%\n", ret);
+ return ret;
+}
+
+static int sp2541_get_voltage(void)
+{
+ unsigned char buf[2];
+ int ret;
+
+ ret = sp2541_read(RAM_READ_CMD, SP2541_REG_VOLT, buf, 2);
+ if (ret<0) {
+ printf("error reading capacity\n");
+ return ret;
+ }
+ return buf[0] | buf[1] << 8;
+}
+
+static int sp2541_get_current(void)
+{
+ unsigned char buf[2];
+ int ret;
+
+ ret = sp2541_read(RAM_READ_CMD, SP2541_REG_AI, buf, 2);
+ if (ret<0) {
+ printf("error reading capacity\n");
+ return ret;
+ }
+ return buf[0] | buf[1] << 8;
+}
+
+static int sp2541_check_bl(void)
+{
+ int capacity;
+
+ capacity = sp2541_get_capacity();
+ if (capacity < 0)
+ return -1;
+ return (capacity < 3);
+}
+
+
+struct battery_dev sp2541_battery_dev = {
+ .name = "sp2541",
+ .is_gauge = 1,
+ .init = sp2541_init,
+ .get_capacity = sp2541_get_capacity,
+ .get_voltage = sp2541_get_voltage,
+ .get_current = sp2541_get_current,
+ .check_batlow = sp2541_check_bl,
+};
+
+
+static int do_sp2541(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
+{
+ int i, j;
+ int capacity,voltage,current;
+ u8 data_buf;
+ int eeprom_data;
+ int ret;
+
+ if (sp2541_init())
+ return 0;
+ capacity = sp2541_get_capacity();
+ voltage = sp2541_get_voltage();
+ current = sp2541_get_current();
+ printf("capacity = %d\n", capacity);
+ printf("voltage = %d\n", voltage);
+ printf("current = %d\n", current);
+
+ /*for (i = 0; i < ARRAY_SIZE(default_table); i++) {
+ printf("{0x%x, %d, %x}\n", default_table[i].addr, default_table[i].len, default_table[i].data);
+ for (j = 0; j < default_table[i].len; j++) {
+ data_buf = (default_table[i].data >> (8*(default_table[i].len-j-1))) & 0xFF;
+ ret = EEPROM_write_byte(default_table[i].addr + j, data_buf);
+ if (ret<0) {
+ printf("error write eeprom.\n");
+ return 0;
+ }
+ }
+ }*/
+ for (i = 0; i < ARRAY_SIZE(default_table); i++) {
+ eeprom_data = 0;
+ for (j = 0; j < default_table[i].len; j++) {
+ ret = EEPROM_read_byte(default_table[i].addr + j, &data_buf);
+ if (ret<0) {
+ printf("error read eeprom.\n");
+ return 0;
+ }
+ eeprom_data = (eeprom_data << 8*j) | data_buf;
+ }
+ //printf("{0x%x, %d, %x}\n", default_table[i].addr, default_table[i].len, default_table[i].data);
+ printf("0x%x: %x\n", default_table[i].addr, eeprom_data);
+ }
+ return 0;
+}
+
+U_BOOT_CMD(
+ sp2541, 1, 1, do_sp2541,
+ "sp2541\n",
+ NULL
+);
diff --git a/board/wmt/wmt_battery/gauge/sp2541/sp2541_battery.h b/board/wmt/wmt_battery/gauge/sp2541/sp2541_battery.h
new file mode 100755
index 0000000..bdb8006
--- /dev/null
+++ b/board/wmt/wmt_battery/gauge/sp2541/sp2541_battery.h
@@ -0,0 +1,110 @@
+
+#ifndef __SP2541_BATTERY_H_
+#define __SP2541_BATTERY_H_
+
+
+#define SP2541_I2C_ADDR 0x14
+#define I2C_BUS_ID 3
+
+#define RAM_READ_CMD 0x55
+#define EEPROM_READ_CMD 0xF5
+#define EEPROM_WRITE_CMD 0xFA
+
+#define SP2541_REG_VOLT 0x08
+#define SP2541_REG_AI 0x14
+#define SP2541_REG_SOC 0x2c
+
+struct eeprom_table {
+ unsigned int addr;
+ unsigned int len;
+ int data;
+};
+
+static struct eeprom_table default_table[] = {
+ {0x0120, 1, 0x0D},
+ {0x0121, 1, 0x1B},
+ {0x0122, 1, 0x0E},
+ {0x0123, 1, 0x39},
+ {0x0124, 1, 0x0E},
+ {0x0125, 1, 0x5E},
+ {0x0126, 1, 0x0E},
+ {0x0127, 1, 0x75},
+ {0x0128, 1, 0x0E},
+ {0x0129, 1, 0x93},
+ {0x012A, 1, 0x0E},
+ {0x012B, 1, 0xA9},
+ {0x012C, 1, 0x0E},
+ {0x012D, 1, 0xB3},
+ {0x012E, 1, 0x0E},
+ {0x012F, 1, 0xB7},
+ {0x0130, 1, 0x0E},
+ {0x0131, 1, 0xC2},
+ {0x0132, 1, 0x0E},
+ {0x0133, 1, 0xCF},
+ {0x0134, 1, 0x0E},
+ {0x0135, 1, 0xDF},
+ {0x0136, 1, 0x0E},
+ {0x0137, 1, 0xF5},
+ {0x0138, 1, 0x0F},
+ {0x0139, 1, 0x16},
+ {0x013A, 1, 0x0F},
+ {0x013B, 1, 0x37},
+ {0x013C, 1, 0x0F},
+ {0x013D, 1, 0x55},
+ {0x013E, 1, 0x0F},
+ {0x013F, 1, 0x79},
+ {0x0140, 1, 0x0F},
+ {0x0141, 1, 0x9A},
+ {0x0142, 1, 0x0F},
+ {0x0143, 1, 0xBF},
+ {0x0144, 1, 0x0F},
+ {0x0145, 1, 0xEB},
+ {0x0146, 1, 0x10},
+ {0x0147, 1, 0x1B},
+ {0x0148, 1, 0x10},
+ {0x0149, 1, 0x5A},
+ {0x0150, 1, 0x0C},
+ {0x0151, 1, 0x1D},
+ {0x0152, 1, 0x0D},
+ {0x0153, 1, 0x76},
+ {0x0154, 1, 0x0D},
+ {0x0155, 1, 0xC6},
+ {0x0156, 1, 0x0D},
+ {0x0157, 1, 0xE6},
+ {0x0158, 1, 0x0E},
+ {0x0159, 1, 0x04},
+ {0x015A, 1, 0x0E},
+ {0x015B, 1, 0x18},
+ {0x015C, 1, 0x0E},
+ {0x015D, 1, 0x27},
+ {0x015E, 1, 0x0E},
+ {0x015F, 1, 0x32},
+ {0x0160, 1, 0x0E},
+ {0x0161, 1, 0x3D},
+ {0x0162, 1, 0x0E},
+ {0x0163, 1, 0x4A},
+ {0x0164, 1, 0x0E},
+ {0x0165, 1, 0x5D},
+ {0x0166, 1, 0x0E},
+ {0x0167, 1, 0x70},
+ {0x0168, 1, 0x0E},
+ {0x0169, 1, 0x86},
+ {0x016A, 1, 0x0E},
+ {0x016B, 1, 0xA2},
+ {0x016C, 1, 0x0E},
+ {0x016D, 1, 0xC0},
+ {0x016E, 1, 0x0E},
+ {0x016F, 1, 0xE3},
+ {0x0170, 1, 0x0F},
+ {0x0171, 1, 0x08},
+ {0x0172, 1, 0x0F},
+ {0x0173, 1, 0x37},
+ {0x0174, 1, 0x0F},
+ {0x0175, 1, 0x65},
+ {0x0176, 1, 0x0F},
+ {0x0177, 1, 0x9C},
+ {0x0178, 1, 0x10},
+ {0x0179, 1, 0x5A},
+};
+
+#endif /* #ifndef __SP2541_BATTERY_H_ */
diff --git a/board/wmt/wmt_battery/gauge/upi/Makefile b/board/wmt/wmt_battery/gauge/upi/Makefile
new file mode 100755
index 0000000..0c082a2
--- /dev/null
+++ b/board/wmt/wmt_battery/gauge/upi/Makefile
@@ -0,0 +1,47 @@
+#
+# See file CREDITS for list of people who contributed to this
+# project.
+#
+# Some descriptions of such software. Copyright (c) 2008 WonderMedia Technologies, Inc.
+#
+# 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, see <http://www.gnu.org/licenses/>.
+#
+# WonderMedia Technologies, Inc.
+# 10F, 529, Chung-Cheng Road, Hsin-Tien, Taipei 231, R.O.C.
+#
+
+include $(TOPDIR)/config.mk
+
+LIB = libbattupi.a
+
+OBJS := uG31xx_API_Measurement.o \
+ uG31xx_API_Otp.o uG31xx_API_System.o \
+ ug31xx_boot.o ug31xx_boot_i2c.o
+
+#SOBJS := lowlevel_init.o
+
+#$(LIB): $(OBJS) $(SOBJS)
+# $(AR) crv $@ $^
+
+clean:
+ rm -f $(OBJS)
+
+distclean: clean
+ rm -f $(LIB) core *.bak .depend
+
+#########################################################################
+
+.depend: Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
+ $(CC) -M $(CPPFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+
+-include .depend
+
+#########################################################################
diff --git a/board/wmt/wmt_battery/gauge/upi/ggb/ug31xx_ggb_data_uboot_20130809_184039.h b/board/wmt/wmt_battery/gauge/upi/ggb/ug31xx_ggb_data_uboot_20130809_184039.h
new file mode 100755
index 0000000..06baa26
--- /dev/null
+++ b/board/wmt/wmt_battery/gauge/upi/ggb/ug31xx_ggb_data_uboot_20130809_184039.h
@@ -0,0 +1,233 @@
+
+/* This file is auto-generated. Don't edit this file. */
+
+/// R-Sense = 20
+/// ILMD = 3000
+/// EDVF = 3500
+/// Taper Current = 150
+/// Taper Voltage = 4150
+/// Taper Time = 60
+
+char FactoryGGBXFile[] = {
+ 0x5f,0x47,0x47,0x5f,0x33,0xc9,0x00,0x00,
+ 0x27,0xf8,0x45,0x95,0x0e,0x00,0x00,0x00,
+ 0xbd,0x06,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x57,0x6f,0x6e,0x64,
+ 0x65,0x72,0x6d,0x65,0x64,0x69,0x61,0x00,
+ 0x00,0x00,0x00,0x00,0x43,0x57,0x35,0x30,
+ 0x30,0x2d,0x33,0x30,0x30,0x30,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x6d,0x4d,
+ 0x61,0x78,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x53,0x5a,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x01,0x02,0x01,0x00,0x01,0x01,0x00,0x00,
+ 0x70,0x00,0x64,0x00,0x00,0x00,0x00,0x14,
+ 0x00,0x00,0xb8,0x0b,0xac,0x0d,0x14,0x00,
+ 0x96,0x00,0x36,0x10,0x3c,0x00,0x06,0x00,
+ 0x00,0x00,0x00,0x00,0xe4,0x0c,0x48,0x0d,
+ 0x00,0x00,0x32,0x00,0x26,0x02,0xf4,0x01,
+ 0x5c,0xff,0x77,0x01,0x63,0x05,0x00,0x00,
+ 0x00,0x00,0x01,0x00,0xf0,0xdf,0xf4,0x67,
+ 0xe8,0xcf,0xee,0x1b,0xe8,0x03,0xe8,0x03,
+ 0x00,0x00,0xe8,0x03,0x00,0x00,0x10,0x27,
+ 0x1e,0x61,0xae,0x5c,0xce,0x57,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0x0e,0xac,
+ 0x0d,0x00,0x00,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0x68,0x10,0xb9,0x0f,0x0a,0x0f,0x5b,
+ 0x0e,0xac,0x0d,0x00,0x00,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0x68,0x10,0xb9,0x0f,0x0a,
+ 0x0f,0x5b,0x0e,0xac,0x0d,0x00,0x00,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0x68,0x10,0xb9,
+ 0x0f,0x0a,0x0f,0x5b,0x0e,0xac,0x0d,0x00,
+ 0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x68,
+ 0x10,0xb9,0x0f,0x0a,0x0f,0x5b,0x0e,0xac,
+ 0x0d,0x00,0x00,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0x68,0x10,0xb9,0x0f,0x0a,0x0f,0x5b,
+ 0x0e,0xac,0x0d,0x00,0x00,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0x68,0x10,0xb9,0x0f,0x0a,
+ 0x0f,0x5b,0x0e,0xac,0x0d,0x00,0x00,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0x68,0x10,0xb9,
+ 0x0f,0x0a,0x0f,0x5b,0x0e,0xac,0x0d,0x00,
+ 0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x68,
+ 0x10,0xb9,0x0f,0x0a,0x0f,0x5b,0x0e,0xac,
+ 0x0d,0x00,0x00,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0x68,0x10,0xb9,0x0f,0x0a,0x0f,0x5b,
+ 0x0e,0xac,0x0d,0x00,0x00,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0x68,0x10,0xb9,0x0f,0x0a,
+ 0x0f,0x5b,0x0e,0xac,0x0d,0x00,0x00,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xc7,0x08,0xb5,
+ 0x02,0xbc,0x01,0xb4,0x01,0xa2,0x02,0x4b,
+ 0x04,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x6c,
+ 0x0c,0xa2,0x03,0x6a,0x03,0x6f,0x03,0xf1,
+ 0x01,0xb9,0x00,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xa4,0x0c,0x6f,0x04,0xae,0x03,0x34,
+ 0x04,0x53,0x00,0x8b,0x00,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0x83,0x08,0x10,0x03,0x93,
+ 0x01,0xc6,0x01,0x1a,0x02,0x9e,0x05,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0x6f,0x0d,0x8d,
+ 0x03,0xbe,0x03,0x93,0x03,0x91,0x02,0xe3,
+ 0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xd3,
+ 0x0d,0x72,0x04,0x1b,0x04,0xc1,0x04,0x85,
+ 0x00,0x87,0x00,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xa5,0x07,0x57,0x03,0x14,0x02,0x1e,
+ 0x01,0x1c,0x01,0x1c,0x07,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0x89,0x0e,0x6e,0x03,0x71,
+ 0x03,0x34,0x04,0x76,0x03,0x7e,0x01,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0x71,0x0f,0x39,
+ 0x04,0x19,0x04,0xb1,0x05,0x6e,0x01,0xa0,
+ 0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x93,
+ 0x07,0x3c,0x03,0x19,0x02,0x29,0x02,0x15,
+ 0x00,0x06,0x0b,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xf9,0x0e,0x9c,0x03,0x85,0x03,0x77,
+ 0x03,0x61,0x04,0xe0,0x03,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0x18,0x11,0x5b,0x04,0x47,
+ 0x03,0xfe,0x05,0x78,0x03,0x3f,0x01,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,
+};
+
diff --git a/board/wmt/wmt_battery/gauge/upi/ggb/ug31xx_ggb_data_uboot_cw500_20130801_103638.h b/board/wmt/wmt_battery/gauge/upi/ggb/ug31xx_ggb_data_uboot_cw500_20130801_103638.h
new file mode 100755
index 0000000..672ccb8
--- /dev/null
+++ b/board/wmt/wmt_battery/gauge/upi/ggb/ug31xx_ggb_data_uboot_cw500_20130801_103638.h
@@ -0,0 +1,232 @@
+
+/* This file is auto-generated. Don't edit this file. */
+
+/// R-Sense = 20
+/// ILMD = 4000
+/// EDVF = 3500
+/// Taper Current = 150
+/// Taper Voltage = 4150
+/// Taper Time = 60
+
+char FactoryGGBXFile_cw500 [] = {
+ 0x5f,0x47,0x47,0x5f,0xed,0xc9,0x00,0x00,
+ 0xb6,0xfa,0x3a,0x95,0x0e,0x00,0x00,0x00,
+ 0xbd,0x06,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x57,0x6f,0x6e,0x64,
+ 0x65,0x72,0x6d,0x65,0x64,0x69,0x61,0x00,
+ 0x00,0x00,0x00,0x00,0x43,0x57,0x35,0x30,
+ 0x30,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x6d,0x4d,
+ 0x61,0x78,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x53,0x5a,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x01,0x02,0x01,0x00,0x01,0x01,0x00,0x00,
+ 0x70,0x00,0x64,0x00,0x00,0x00,0x00,0x14,
+ 0x00,0x00,0xa0,0x0f,0xac,0x0d,0x14,0x00,
+ 0x96,0x00,0x36,0x10,0x3c,0x00,0x06,0x00,
+ 0x00,0x00,0x00,0x00,0xe4,0x0c,0x48,0x0d,
+ 0x00,0x00,0x32,0x00,0x26,0x02,0xf4,0x01,
+ 0x5c,0xff,0x77,0x01,0x63,0x05,0x00,0x00,
+ 0x00,0x00,0x01,0x00,0xf0,0xdf,0xf4,0x67,
+ 0xe8,0xcf,0xee,0x1b,0xe8,0x03,0xe8,0x03,
+ 0x00,0x00,0xe8,0x03,0x00,0x00,0x10,0x27,
+ 0x1e,0x61,0xae,0x5c,0xce,0x57,0x94,0x52,
+ 0x14,0x4d,0x6a,0x47,0xac,0x41,0xff,0x3b,
+ 0x77,0x36,0x2b,0x31,0x2c,0x2c,0x85,0x27,
+ 0x3d,0x23,0x58,0x1f,0xd3,0x1b,0xab,0x18,
+ 0xdb,0x15,0x5c,0x13,0x27,0x11,0xe8,0x03,
+ 0xbc,0x02,0xc2,0x01,0xc8,0x00,0x00,0x00,
+ 0x1e,0x00,0xe8,0x03,0xff,0x77,0x00,0x00,
+ 0x00,0x00,0x01,0x00,0x00,0xEE,0xEE,0xEE,0x68,0x10,0x68,
+ 0x10,0x68,0x10,0x68,0x10,0x68,0x10,0x58,
+ 0x10,0x37,0x10,0x19,0x10,0xfe,0x0f,0xe5,
+ 0x0f,0xcf,0x0f,0xbb,0x0f,0xa9,0x0f,0x98,
+ 0x0f,0x87,0x0f,0x75,0x0f,0x5c,0x0f,0x3e,
+ 0x0f,0x24,0x0f,0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 0x0e,0xa9,0x0e,0x9e,0x0e,0x92,0x0e,0x81,
+ 0x0e,0x6f,0x0e,0x54,0x0e,0x2f,0x0e,0xf6,
+ 0x0d,0xac,0x0d,0x68,0x10,0x2a,0x10,0xfc,
+ 0x0f,0xa3,0x0f,0x59,0x0f,0x35,0x0f,0x1b,
+ 0x0f,0xff,0x0e,0xe6,0x0e,0xd2,0x0e,0xc1,
+ 0x0e,0xb5,0x0e,0xa9,0x0e,0x9e,0x0e,0x92,
+ 0x0e,0x81,0x0e,0x6f,0x0e,0x54,0x0e,0x2f,
+ 0x0e,0xf6,0x0d,0xac,0x0d,0x68,0x10,0xb9,
+ 0x0f,0x0a,0x0f,0x5b,0x0e,0xac,0x0d,0x00,
+ 0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x68,
+ 0x10,0xb9,0x0f,0x0a,0x0f,0x5b,0x0e,0xac,
+ 0x0d,0x00,0x00,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0x68,0x10,0xb9,0x0f,0x0a,0x0f,0x5b,
+ 0x0e,0xac,0x0d,0x00,0x00,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0x68,0x10,0xb9,0x0f,0x0a,
+ 0x0f,0x5b,0x0e,0xac,0x0d,0x00,0x00,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0x68,0x10,0xb9,
+ 0x0f,0x0a,0x0f,0x5b,0x0e,0xac,0x0d,0x00,
+ 0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x68,
+ 0x10,0xb9,0x0f,0x0a,0x0f,0x5b,0x0e,0xac,
+ 0x0d,0x00,0x00,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0x68,0x10,0xb9,0x0f,0x0a,0x0f,0x5b,
+ 0x0e,0xac,0x0d,0x00,0x00,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0x68,0x10,0xb9,0x0f,0x0a,
+ 0x0f,0x5b,0x0e,0xac,0x0d,0x00,0x00,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0x68,0x10,0xb9,
+ 0x0f,0x0a,0x0f,0x5b,0x0e,0xac,0x0d,0x00,
+ 0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x68,
+ 0x10,0xb9,0x0f,0x0a,0x0f,0x5b,0x0e,0xac,
+ 0x0d,0x00,0x00,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0x68,0x10,0xb9,0x0f,0x0a,0x0f,0x5b,
+ 0x0e,0xac,0x0d,0x00,0x00,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0x68,0x10,0xb9,0x0f,0x0a,
+ 0x0f,0x5b,0x0e,0xac,0x0d,0x00,0x00,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0x4a,0x09,0x00,
+ 0x00,0x54,0x01,0x12,0x03,0xe3,0x04,0x4b,
+ 0x04,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xf0,
+ 0x0c,0xed,0x00,0x02,0x03,0xcd,0x04,0x32,
+ 0x04,0xb9,0x00,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0x27,0x0d,0xba,0x01,0x46,0x03,0x92,
+ 0x05,0x94,0x02,0x8b,0x00,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0x99,0x07,0x00,0x00,0x97,
+ 0x00,0xbd,0x02,0x44,0x04,0x9e,0x05,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0x86,0x0c,0x7d,
+ 0x00,0xc2,0x02,0x8a,0x04,0xbb,0x04,0xe3,
+ 0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xea,
+ 0x0c,0x62,0x01,0x1f,0x03,0xb8,0x05,0xaf,
+ 0x02,0x87,0x00,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xc1,0x04,0x00,0x00,0xed,0x00,0xe3,
+ 0x00,0xf0,0x02,0x1c,0x07,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xa5,0x0b,0x17,0x00,0x4a,
+ 0x02,0xf9,0x03,0x4a,0x05,0x7e,0x01,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0x8e,0x0c,0xe2,
+ 0x00,0xf2,0x02,0x76,0x05,0x42,0x03,0xa0,
+ 0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x08,
+ 0x02,0x00,0x00,0x0e,0x00,0x9e,0x00,0x5b,
+ 0x01,0x06,0x0b,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0x6f,0x09,0x60,0x00,0x7a,0x01,0xec,
+ 0x01,0xa7,0x05,0xe0,0x03,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0x8d,0x0b,0x1f,0x01,0x3c,
+ 0x01,0x73,0x04,0xbe,0x04,0x3f,0x01,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,
+};
diff --git a/board/wmt/wmt_battery/gauge/upi/ggb/ug31xx_ggb_data_uboot_mp718_20131004_070110.h b/board/wmt/wmt_battery/gauge/upi/ggb/ug31xx_ggb_data_uboot_mp718_20131004_070110.h
new file mode 100755
index 0000000..f0b23b8
--- /dev/null
+++ b/board/wmt/wmt_battery/gauge/upi/ggb/ug31xx_ggb_data_uboot_mp718_20131004_070110.h
@@ -0,0 +1,233 @@
+
+/* This file is auto-generated. Don't edit this file. */
+
+/// R-Sense = 20
+/// ILMD = 6800
+/// EDVF = 3400
+/// Taper Current = 100
+/// Taper Voltage = 4150
+/// Taper Time = 60
+
+char FactoryGGBXFile_mp718 [] = {
+ 0x5f,0x47,0x47,0x5f,0x65,0xcb,0x00,0x00,
+ 0xb6,0xd6,0x8d,0x95,0x0e,0x00,0x00,0x00,
+ 0xbd,0x06,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x57,0x6f,0x6e,0x64,
+ 0x65,0x72,0x6d,0x65,0x64,0x69,0x61,0x00,
+ 0x00,0x00,0x00,0x00,0x4d,0x37,0x31,0x38,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x57,0x6f,
+ 0x6e,0x64,0x65,0x72,0x6d,0x65,0x64,0x69,
+ 0x61,0x00,0x00,0x00,0x00,0x00,0x53,0x5a,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x01,0x01,0x02,0x00,0x01,0x01,0x00,0x00,
+ 0x70,0x00,0x64,0x00,0x00,0x00,0x00,0x14,
+ 0x00,0x00,0x90,0x1a,0x48,0x0d,0x14,0x00,
+ 0x64,0x00,0x36,0x10,0x3c,0x00,0x06,0x00,
+ 0x00,0x00,0x00,0x00,0xe4,0x0c,0x48,0x0d,
+ 0x00,0x00,0x32,0x00,0x26,0x02,0xf4,0x01,
+ 0x5c,0xff,0x77,0x01,0x63,0x05,0x00,0x00,
+ 0x00,0x00,0x01,0x00,0xf0,0xdf,0xf4,0x67,
+ 0xe8,0xcf,0xee,0x1b,0xe8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0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x68,
+ 0x10,0xa0,0x0f,0xd8,0x0e,0x10,0x0e,0x48,
+ 0x0d,0x00,0x00,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0x68,0x10,0xa0,0x0f,0xd8,0x0e,0x10,
+ 0x0e,0x48,0x0d,0x00,0x00,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0x68,0x10,0xa0,0x0f,0xd8,
+ 0x0e,0x10,0x0e,0x48,0x0d,0x00,0x00,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0x68,0x10,0xa0,
+ 0x0f,0xd8,0x0e,0x10,0x0e,0x48,0x0d,0x00,
+ 0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x68,
+ 0x10,0xa0,0x0f,0xd8,0x0e,0x10,0x0e,0x48,
+ 0x0d,0x00,0x00,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0x68,0x10,0xa0,0x0f,0xd8,0x0e,0x10,
+ 0x0e,0x48,0x0d,0x00,0x00,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0x68,0x10,0xa0,0x0f,0xd8,
+ 0x0e,0x10,0x0e,0x48,0x0d,0x00,0x00,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0x68,0x10,0xa0,
+ 0x0f,0xd8,0x0e,0x10,0x0e,0x48,0x0d,0x00,
+ 0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x68,
+ 0x10,0xa0,0x0f,0xd8,0x0e,0x10,0x0e,0x48,
+ 0x0d,0x00,0x00,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0x68,0x10,0xa0,0x0f,0xd8,0x0e,0x10,
+ 0x0e,0x48,0x0d,0x00,0x00,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0x68,0x10,0xa0,0x0f,0xd8,
+ 0x0e,0x10,0x0e,0x48,0x0d,0x00,0x00,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0x42,0x1a,0x70,
+ 0x01,0x50,0x06,0x08,0x0d,0x78,0x05,0x20,
+ 0x01,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xf7,
+ 0x1a,0x89,0x03,0xd3,0x07,0x7a,0x0d,0x20,
+ 0x02,0xb5,0x00,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0x2d,0x1b,0x75,0x04,0x57,0x08,0x39,
+ 0x0d,0x27,0x01,0x9a,0x00,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xbf,0x18,0xa1,0x00,0x67,
+ 0x05,0xbb,0x0a,0xfa,0x07,0xee,0x01,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0x4b,0x1a,0xc2,
+ 0x02,0x4f,0x07,0xab,0x0d,0x8e,0x02,0xe2,
+ 0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xcb,
+ 0x1a,0xee,0x03,0x17,0x08,0x63,0x0d,0x60,
+ 0x01,0xa6,0x00,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0x84,0x16,0x3a,0x00,0x03,0x04,0x71,
+ 0x08,0xd5,0x09,0xda,0x02,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0x79,0x19,0x22,0x02,0xbc,
+ 0x06,0xa3,0x0d,0xf7,0x02,0x35,0x01,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0x5b,0x1a,0x69,
+ 0x03,0xc1,0x07,0x84,0x0d,0xad,0x01,0xc3,
+ 0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x22,
+ 0x12,0x0c,0x00,0x1c,0x02,0xf3,0x05,0x05,
+ 0x0a,0x69,0x06,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0x09,0x18,0x57,0x01,0xe5,0x05,0xc1,
+ 0x0c,0x0a,0x04,0x05,0x02,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0x5d,0x19,0x9a,0x02,0x1e,
+ 0x07,0x67,0x0d,0x3c,0x02,0x35,0x01,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,
+};
+
diff --git a/board/wmt/wmt_battery/gauge/upi/ggb/ug31xx_ggb_data_uboot_t73v_20131120_001204.h b/board/wmt/wmt_battery/gauge/upi/ggb/ug31xx_ggb_data_uboot_t73v_20131120_001204.h
new file mode 100755
index 0000000..4a8ff93
--- /dev/null
+++ b/board/wmt/wmt_battery/gauge/upi/ggb/ug31xx_ggb_data_uboot_t73v_20131120_001204.h
@@ -0,0 +1,233 @@
+
+/* This file is auto-generated. Don't edit this file. */
+
+/// R-Sense = 20
+/// ILMD = 3000
+/// EDVF = 3400
+/// Taper Current = 150
+/// Taper Voltage = 4150
+/// Taper Time = 60
+
+char FactoryGGBXFile_t73v [] = {
+ 0x5f,0x47,0x47,0x5f,0x00,0xc6,0x00,0x00,
+ 0xd4,0x1b,0xca,0x95,0x0e,0x00,0x00,0x00,
+ 0xbd,0x06,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x47,0x6f,0x6f,0x64,
+ 0x74,0x69,0x6d,0x65,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x54,0x37,0x33,0x56,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x4c,0x55,
+ 0x53,0x54,0x59,0x2d,0x33,0x37,0x37,0x30,
+ 0x31,0x30,0x30,0x50,0x4c,0x00,0x31,0x33,
+ 0x31,0x30,0x31,0x36,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x01,0x02,0x01,0x00,0x01,0x01,0x00,0x00,
+ 0x70,0x00,0x64,0x00,0x00,0x00,0x00,0x14,
+ 0x00,0x00,0xb8,0x0b,0x48,0x0d,0x14,0x00,
+ 0x96,0x00,0x36,0x10,0x3c,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x74,0x0e,0xd8,0x0e,
+ 0x00,0x00,0x32,0x00,0x26,0x02,0xf4,0x01,
+ 0x5c,0xff,0x77,0x01,0x63,0x05,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0xf0,0xdf,0xf4,0x67,
+ 0xe8,0xcf,0xee,0x1b,0xe8,0x03,0xe8,0x03,
+ 0x00,0x00,0xe8,0x03,0x00,0x00,0x10,0x27,
+ 0x05,0x62,0x8a,0x5d,0x9c,0x58,0x4c,0x53,
+ 0xb3,0x4d,0xeb,0x47,0x15,0x42,0x4b,0x3c,
+ 0xc7,0x36,0x80,0x31,0x86,0x2c,0xe5,0x27,
+ 0xa2,0x23,0xc0,0x1f,0x3d,0x1c,0x17,0x19,
+ 0x47,0x16,0xc6,0x13,0x8e,0x11,0xe8,0x03,
+ 0x84,0x03,0xee,0x02,0x58,0x02,0xc2,0x01,
+ 0x1e,0x00,0xe8,0x03,0xff,0x77,0x00,0x00,
+ 0x00,0x00,0x21,0x38,0x00,0xEE,0xEE,0xEE,0x68,0x10,0x68,
+ 0x10,0x68,0x10,0x68,0x10,0x49,0x10,0x23,
+ 0x10,0x01,0x10,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ff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0x68,0x10,0xa0,0x0f,0xd8,
+ 0x0e,0x10,0x0e,0x48,0x0d,0x00,0x00,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0x68,0x10,0xa0,
+ 0x0f,0xd8,0x0e,0x10,0x0e,0x48,0x0d,0x00,
+ 0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x68,
+ 0x10,0xa0,0x0f,0xd8,0x0e,0x10,0x0e,0x48,
+ 0x0d,0x00,0x00,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0x68,0x10,0xa0,0x0f,0xd8,0x0e,0x10,
+ 0x0e,0x48,0x0d,0x00,0x00,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0x68,0x10,0xa0,0x0f,0xd8,
+ 0x0e,0x10,0x0e,0x48,0x0d,0x00,0x00,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0x68,0x10,0xa0,
+ 0x0f,0xd8,0x0e,0x10,0x0e,0x48,0x0d,0x00,
+ 0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x68,
+ 0x10,0xa0,0x0f,0xd8,0x0e,0x10,0x0e,0x48,
+ 0x0d,0x00,0x00,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0x68,0x10,0xa0,0x0f,0xd8,0x0e,0x10,
+ 0x0e,0x48,0x0d,0x00,0x00,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0x68,0x10,0xa0,0x0f,0xd8,
+ 0x0e,0x10,0x0e,0x48,0x0d,0x00,0x00,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0x3b,0x0b,0x66,
+ 0x00,0x7d,0x02,0xe4,0x04,0x72,0x03,0x82,
+ 0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x82,
+ 0x0b,0x79,0x01,0x1b,0x03,0x3b,0x06,0xb1,
+ 0x00,0x4c,0x00,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0x96,0x0b,0xe7,0x01,0x69,0x03,0xd9,
+ 0x05,0x6c,0x00,0x41,0x00,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0x3b,0x0b,0x66,0x00,0x7d,
+ 0x02,0xe4,0x04,0x72,0x03,0x82,0x00,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0x82,0x0b,0x79,
+ 0x01,0x1b,0x03,0x3b,0x06,0xb1,0x00,0x4c,
+ 0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x96,
+ 0x0b,0xe7,0x01,0x69,0x03,0xd9,0x05,0x6c,
+ 0x00,0x41,0x00,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0x3b,0x0b,0x66,0x00,0x7d,0x02,0xe4,
+ 0x04,0x72,0x03,0x82,0x00,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0x82,0x0b,0x79,0x01,0x1b,
+ 0x03,0x3b,0x06,0xb1,0x00,0x4c,0x00,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0x96,0x0b,0xe7,
+ 0x01,0x69,0x03,0xd9,0x05,0x6c,0x00,0x41,
+ 0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x3b,
+ 0x0b,0x66,0x00,0x7d,0x02,0xe4,0x04,0x72,
+ 0x03,0x82,0x00,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0x82,0x0b,0x79,0x01,0x1b,0x03,0x3b,
+ 0x06,0xb1,0x00,0x4c,0x00,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0x96,0x0b,0xe7,0x01,0x69,
+ 0x03,0xd9,0x05,0x6c,0x00,0x41,0x00,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,
+};
+
diff --git a/board/wmt/wmt_battery/gauge/upi/ggb/ug31xx_ggb_data_uboot_wms7320_20130718_200031.h b/board/wmt/wmt_battery/gauge/upi/ggb/ug31xx_ggb_data_uboot_wms7320_20130718_200031.h
new file mode 100755
index 0000000..105e0a0
--- /dev/null
+++ b/board/wmt/wmt_battery/gauge/upi/ggb/ug31xx_ggb_data_uboot_wms7320_20130718_200031.h
@@ -0,0 +1,233 @@
+
+/* This file is auto-generated. Don't edit this file. */
+
+/// R-Sense = 20
+/// ILMD = 4000
+/// EDVF = 3400
+/// Taper Current = 100
+/// Taper Voltage = 4150
+/// Taper Time = 60
+
+char FactoryGGBXFile_wms7320 [] = {
+ 0x5f,0x47,0x47,0x5f,0x6d,0xc8,0x00,0x00,
+ 0x5f,0x5b,0x2a,0x95,0x0e,0x00,0x00,0x00,
+ 0xbd,0x06,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x57,0x6f,0x6e,0x64,
+ 0x65,0x72,0x6d,0x65,0x64,0x69,0x61,0x00,
+ 0x00,0x00,0x00,0x00,0x57,0x4d,0x53,0x37,
+ 0x33,0x32,0x30,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x57,0x6f,
+ 0x6e,0x64,0x65,0x72,0x6d,0x65,0x64,0x69,
+ 0x61,0x00,0x00,0x00,0x00,0x00,0x53,0x5a,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x01,0x01,0x02,0x00,0x01,0x01,0x00,0x00,
+ 0x70,0x00,0x64,0x00,0x00,0x00,0x00,0x14,
+ 0x00,0x00,0xa0,0x0f,0x48,0x0d,0x14,0x00,
+ 0x64,0x00,0x36,0x10,0x3c,0x00,0x06,0x00,
+ 0x00,0x00,0x00,0x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d,0x68,0x10,0xa0,
+ 0x0f,0xd8,0x0e,0x10,0x0e,0x48,0x0d,0x00,
+ 0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x68,
+ 0x10,0xa0,0x0f,0xd8,0x0e,0x10,0x0e,0x48,
+ 0x0d,0x00,0x00,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0x68,0x10,0xa0,0x0f,0xd8,0x0e,0x10,
+ 0x0e,0x48,0x0d,0x00,0x00,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0x68,0x10,0xa0,0x0f,0xd8,
+ 0x0e,0x10,0x0e,0x48,0x0d,0x00,0x00,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0x68,0x10,0xa0,
+ 0x0f,0xd8,0x0e,0x10,0x0e,0x48,0x0d,0x00,
+ 0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x68,
+ 0x10,0xa0,0x0f,0xd8,0x0e,0x10,0x0e,0x48,
+ 0x0d,0x00,0x00,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0x68,0x10,0xa0,0x0f,0xd8,0x0e,0x10,
+ 0x0e,0x48,0x0d,0x00,0x00,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0x68,0x10,0xa0,0x0f,0xd8,
+ 0x0e,0x10,0x0e,0x48,0x0d,0x00,0x00,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0x68,0x10,0xa0,
+ 0x0f,0xd8,0x0e,0x10,0x0e,0x48,0x0d,0x00,
+ 0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x68,
+ 0x10,0xa0,0x0f,0xd8,0x0e,0x10,0x0e,0x48,
+ 0x0d,0x00,0x00,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0x68,0x10,0xa0,0x0f,0xd8,0x0e,0x10,
+ 0x0e,0x48,0x0d,0x00,0x00,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0x68,0x10,0xa0,0x0f,0xd8,
+ 0x0e,0x10,0x0e,0x48,0x0d,0x00,0x00,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xb9,0x07,0x00,
+ 0x00,0x7c,0x00,0xaa,0x02,0x91,0x04,0xa2,
+ 0x04,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xf1,
+ 0x0b,0xb2,0x00,0xde,0x02,0xcf,0x04,0x91,
+ 0x03,0x9c,0x00,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xec,0x0b,0x3b,0x01,0xf1,0x02,0x7f,
+ 0x05,0x3f,0x02,0x81,0x00,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xe0,0x02,0x00,0x00,0x00,
+ 0x00,0x1b,0x00,0xc5,0x02,0xcf,0x0a,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xe8,0x0b,0x00,
+ 0x00,0x83,0x01,0xdc,0x03,0x88,0x06,0x4f,
+ 0x03,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xbe,
+ 0x0d,0x43,0x00,0x72,0x03,0x24,0x07,0xe3,
+ 0x02,0x85,0x01,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xe2,0x03,0x00,0x00,0x83,0x00,0xe2,
+ 0x02,0x7c,0x00,0x82,0x06,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xa2,0x09,0x49,0x00,0xcc,
+ 0x00,0x57,0x03,0x34,0x05,0xb6,0x01,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0x8a,0x0a,0x61,
+ 0x00,0xd6,0x01,0x83,0x05,0xcf,0x02,0xa8,
+ 0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xb3,
+ 0x00,0x00,0x00,0x00,0x00,0x29,0x00,0x89,
+ 0x00,0x17,0x04,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xf4,0x04,0x00,0x00,0x58,0x01,0x7c,
+ 0x00,0x20,0x03,0x1c,0x07,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xa5,0x09,0xab,0x00,0x38,
+ 0x03,0x87,0x00,0x39,0x05,0x6c,0x02,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,
+};
+
diff --git a/board/wmt/wmt_battery/gauge/upi/ggb/ug31xx_ggb_data_uboot_wms8309_c7_20130725_164935.h b/board/wmt/wmt_battery/gauge/upi/ggb/ug31xx_ggb_data_uboot_wms8309_c7_20130725_164935.h
new file mode 100755
index 0000000..1478984
--- /dev/null
+++ b/board/wmt/wmt_battery/gauge/upi/ggb/ug31xx_ggb_data_uboot_wms8309_c7_20130725_164935.h
@@ -0,0 +1,232 @@
+
+/* This file is auto-generated. Don't edit this file. */
+
+/// R-Sense = 20
+/// ILMD = 3900
+/// EDVF = 3500
+/// Taper Current = 150
+/// Taper Voltage = 4150
+/// Taper Time = 60
+
+char FactoryGGBXFile_wms8309_c7_3900mAh [] = {
+ 0x5f,0x47,0x47,0x5f,0xbb,0xfa,0x00,0x00,
+ 0x1f,0x69,0x33,0x95,0x0e,0x00,0x00,0x00,
+ 0xbd,0x06,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x57,0x6f,0x6e,0x64,
+ 0x65,0x72,0x6d,0x65,0x64,0x69,0x61,0x00,
+ 0x00,0x00,0x00,0x00,0x57,0x4d,0x53,0x38,
+ 0x33,0x30,0x39,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x6d,0x4d,
+ 0x61,0x78,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x53,0x5a,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x01,0x01,0x02,0x00,0x01,0x01,0x00,0x00,
+ 0x70,0x00,0x64,0x00,0x00,0x00,0x00,0x14,
+ 0x00,0x00,0x3c,0x0f,0xac,0x0d,0x14,0x00,
+ 0x96,0x00,0x36,0x10,0x3c,0x00,0x06,0x00,
+ 0x00,0x00,0x00,0x00,0xe4,0x0c,0x48,0x0d,
+ 0x00,0x00,0x32,0x00,0x26,0x02,0xf4,0x01,
+ 0x5c,0xff,0x77,0x01,0x63,0x05,0x00,0x00,
+ 0x00,0x00,0x01,0x00,0xf0,0xdf,0xf4,0x67,
+ 0xe8,0xcf,0xee,0x1b,0xe8,0x03,0xe8,0x03,
+ 0x00,0x00,0xe8,0x03,0x00,0x00,0x10,0x27,
+ 0x1e,0x61,0xae,0x5c,0xce,0x57,0x94,0x52,
+ 0x14,0x4d,0x6a,0x47,0xac,0x41,0xff,0x3b,
+ 0x77,0x36,0x2b,0x31,0x2c,0x2c,0x85,0x27,
+ 0x3d,0x23,0x58,0x1f,0xd3,0x1b,0xab,0x18,
+ 0xdb,0x15,0x5c,0x13,0x27,0x11,0xe8,0x03,
+ 0xbc,0x02,0xc2,0x01,0xc8,0x00,0x00,0x00,
+ 0x1e,0x00,0xe8,0x03,0xff,0x77,0x00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,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0x68,0x10,0xb9,0x0f,0x0a,
+ 0x0f,0x5b,0x0e,0xac,0x0d,0x00,0x00,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0x68,0x10,0xb9,
+ 0x0f,0x0a,0x0f,0x5b,0x0e,0xac,0x0d,0x00,
+ 0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x68,
+ 0x10,0xb9,0x0f,0x0a,0x0f,0x5b,0x0e,0xac,
+ 0x0d,0x00,0x00,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0x68,0x10,0xb9,0x0f,0x0a,0x0f,0x5b,
+ 0x0e,0xac,0x0d,0x00,0x00,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0x68,0x10,0xb9,0x0f,0x0a,
+ 0x0f,0x5b,0x0e,0xac,0x0d,0x00,0x00,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0x68,0x10,0xb9,
+ 0x0f,0x0a,0x0f,0x5b,0x0e,0xac,0x0d,0x00,
+ 0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x68,
+ 0x10,0xb9,0x0f,0x0a,0x0f,0x5b,0x0e,0xac,
+ 0x0d,0x00,0x00,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0x68,0x10,0xb9,0x0f,0x0a,0x0f,0x5b,
+ 0x0e,0xac,0x0d,0x00,0x00,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0x68,0x10,0xb9,0x0f,0x0a,
+ 0x0f,0x5b,0x0e,0xac,0x0d,0x00,0x00,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0x1c,0x0e,0x02,
+ 0x01,0xef,0x02,0x18,0x05,0x12,0x05,0xd8,
+ 0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x62,
+ 0x0e,0xf2,0x01,0x50,0x03,0xcb,0x06,0x53,
+ 0x02,0x9e,0x00,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0x74,0x0e,0x4c,0x02,0x6c,0x03,0xf3,
+ 0x06,0xc8,0x01,0x95,0x00,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0x83,0x0d,0x85,0x00,0x83,
+ 0x02,0x8e,0x04,0xec,0x05,0x24,0x01,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0x20,0x0e,0xa4,
+ 0x01,0x17,0x03,0x03,0x07,0x60,0x02,0xa1,
+ 0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x48,
+ 0x0e,0x24,0x02,0x3d,0x03,0x45,0x07,0xa0,
+ 0x01,0x8f,0x00,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0x76,0x0c,0x2b,0x00,0x0b,0x02,0xd2,
+ 0x03,0x6c,0x06,0xd6,0x01,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xb6,0x0d,0x2c,0x01,0xed,
+ 0x02,0xa8,0x06,0xf3,0x02,0xc5,0x00,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xf5,0x0d,0xd1,
+ 0x01,0x12,0x03,0x4b,0x07,0xc5,0x01,0x97,
+ 0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x7d,
+ 0x09,0x0d,0x00,0xf4,0x00,0x9d,0x02,0xde,
+ 0x05,0xfe,0x03,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0x95,0x0c,0x7e,0x00,0x1b,0x02,0x32,
+ 0x05,0xc8,0x04,0x37,0x01,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0x0f,0x0d,0xef,0x00,0xd3,
+ 0x02,0x15,0x07,0x36,0x02,0xc5,0x00,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,
+};
diff --git a/board/wmt/wmt_battery/gauge/upi/ggb/ug31xx_ggb_data_uboot_wms8309_c7_20130910_130553.h b/board/wmt/wmt_battery/gauge/upi/ggb/ug31xx_ggb_data_uboot_wms8309_c7_20130910_130553.h
new file mode 100755
index 0000000..224e8b6
--- /dev/null
+++ b/board/wmt/wmt_battery/gauge/upi/ggb/ug31xx_ggb_data_uboot_wms8309_c7_20130910_130553.h
@@ -0,0 +1,233 @@
+
+/* This file is auto-generated. Don't edit this file. */
+
+/// R-Sense = 20
+/// ILMD = 3000
+/// EDVF = 3500
+/// Taper Current = 150
+/// Taper Voltage = 4150
+/// Taper Time = 60
+
+char FactoryGGBXFile_wms8309_c7_3000mAh [] = {
+ 0x5f,0x47,0x47,0x5f,0x56,0xbe,0x00,0x00,
+ 0x31,0x88,0x6e,0x95,0x0e,0x00,0x00,0x00,
+ 0xbd,0x06,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x57,0x6f,0x6e,0x64,
+ 0x65,0x72,0x6d,0x65,0x64,0x69,0x61,0x00,
+ 0x00,0x00,0x00,0x00,0x43,0x57,0x35,0x30,
+ 0x30,0x2d,0x33,0x30,0x30,0x30,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x6d,0x4d,
+ 0x61,0x78,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x53,0x5a,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x01,0x02,0x01,0x00,0x01,0x01,0x00,0x00,
+ 0x70,0x00,0x64,0x00,0x00,0x00,0x00,0x14,
+ 0x00,0x00,0xb8,0x0b,0xac,0x0d,0x14,0x00,
+ 0x96,0x00,0x36,0x10,0x3c,0x00,0x06,0x00,
+ 0x00,0x00,0x00,0x00,0xe4,0x0c,0x48,0x0d,
+ 0x00,0x00,0x32,0x00,0x26,0x02,0xf4,0x01,
+ 0x5c,0xff,0x77,0x01,0x63,0x05,0x00,0x00,
+ 0x00,0x00,0x01,0x00,0xf0,0xdf,0xf4,0x67,
+ 0xe8,0xcf,0xee,0x1b,0xe8,0x03,0xe8,0x03,
+ 0x00,0x00,0xe8,0x03,0x00,0x00,0x10,0x27,
+ 0x1e,0x61,0xae,0x5c,0xce,0x57,0x94,0x52,
+ 0x14,0x4d,0x6a,0x47,0xac,0x41,0xff,0x3b,
+ 0x77,0x36,0x2b,0x31,0x2c,0x2c,0x85,0x27,
+ 0x3d,0x23,0x58,0x1f,0xd3,0x1b,0xab,0x18,
+ 0xdb,0x15,0x5c,0x13,0x27,0x11,0xe8,0x03,
+ 0xbc,0x02,0xc2,0x01,0xc8,0x00,0x00,0x00,
+ 0x1e,0x00,0xe8,0x03,0xff,0x77,0x00,0x00,
+ 0x00,0x00,0x01,0x00,0x00,0xEE,0xEE,0xEE,0x68,0x10,0x68,
+ 0x10,0x68,0x10,0x68,0x10,0x68,0x10,0x68,
+ 0x10,0x68,0x10,0x68,0x10,0x68,0x10,0x68,
+ 0x10,0x59,0x10,0x44,0x10,0x32,0x10,0x20,
+ 0x10,0x0b,0x10,0xef,0x0f,0xc8,0x0f,0x9c,
+ 0x0f,0x77,0x0f,0x28,0x0f,0xac,0x0d,0x68,
+ 0x10,0x0c,0x10,0xeb,0x0f,0xd5,0x0f,0xc4,
+ 0x0f,0xb4,0x0f,0xa0,0x0f,0x83,0x0f,0x66,
+ 0x0f,0x4d,0x0f,0x37,0x0f,0x28,0x0f,0x16,
+ 0x0f,0x03,0x0f,0xea,0x0e,0xcc,0x0e,0xab,
+ 0x0e,0x84,0x0e,0x5c,0x0e,0x2d,0x0e,0xac,
+ 0x0d,0x68,0x10,0x0c,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e,0xb5,0x0e,0x99,0x0e,0x79,0x0e,0x4f,
+ 0x0e,0x0b,0x0e,0xac,0x0d,0x68,0x10,0xb9,
+ 0x0f,0x0a,0x0f,0x5b,0x0e,0xac,0x0d,0x00,
+ 0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x68,
+ 0x10,0xb9,0x0f,0x0a,0x0f,0x5b,0x0e,0xac,
+ 0x0d,0x00,0x00,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0x68,0x10,0xb9,0x0f,0x0a,0x0f,0x5b,
+ 0x0e,0xac,0x0d,0x00,0x00,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0x68,0x10,0xb9,0x0f,0x0a,
+ 0x0f,0x5b,0x0e,0xac,0x0d,0x00,0x00,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0x68,0x10,0xb9,
+ 0x0f,0x0a,0x0f,0x5b,0x0e,0xac,0x0d,0x00,
+ 0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x68,
+ 0x10,0xb9,0x0f,0x0a,0x0f,0x5b,0x0e,0xac,
+ 0x0d,0x00,0x00,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0x68,0x10,0xb9,0x0f,0x0a,0x0f,0x5b,
+ 0x0e,0xac,0x0d,0x00,0x00,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0x68,0x10,0xb9,0x0f,0x0a,
+ 0x0f,0x5b,0x0e,0xac,0x0d,0x00,0x00,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0x68,0x10,0xb9,
+ 0x0f,0x0a,0x0f,0x5b,0x0e,0xac,0x0d,0x00,
+ 0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x68,
+ 0x10,0xb9,0x0f,0x0a,0x0f,0x5b,0x0e,0xac,
+ 0x0d,0x00,0x00,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0x68,0x10,0xb9,0x0f,0x0a,0x0f,0x5b,
+ 0x0e,0xac,0x0d,0x00,0x00,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0x68,0x10,0xb9,0x0f,0x0a,
+ 0x0f,0x5b,0x0e,0xac,0x0d,0x00,0x00,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0x2a,0x09,0x00,
+ 0x00,0xcf,0x00,0x51,0x04,0x0a,0x04,0x51,
+ 0x02,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xed,
+ 0x0a,0x7d,0x00,0x26,0x04,0x44,0x04,0x05,
+ 0x02,0x9d,0x00,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0x0e,0x0b,0x6c,0x01,0x7f,0x04,0xc0,
+ 0x03,0x62,0x01,0x7e,0x00,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xe5,0x08,0x00,0x00,0xad,
+ 0x00,0x1b,0x04,0x1c,0x04,0x85,0x02,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xe7,0x0a,0x69,
+ 0x00,0x07,0x04,0x5b,0x04,0x19,0x02,0x99,
+ 0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x0e,
+ 0x0b,0x4d,0x01,0x7b,0x04,0xe0,0x03,0x64,
+ 0x01,0x75,0x00,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0x09,0x08,0x00,0x00,0x59,0x00,0x7e,
+ 0x03,0x31,0x04,0x30,0x03,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0x94,0x0a,0x3e,0x00,0xb1,
+ 0x03,0x5a,0x04,0x4a,0x02,0xc4,0x00,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xeb,0x0a,0x05,
+ 0x01,0x70,0x04,0xf7,0x03,0x7e,0x01,0x79,
+ 0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xeb,
+ 0x05,0x00,0x00,0x14,0x00,0xd9,0x01,0xfd,
+ 0x03,0xbf,0x04,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0x95,0x09,0x10,0x00,0x99,0x02,0x53,
+ 0x04,0x97,0x02,0x52,0x01,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0x53,0x0a,0x79,0x00,0x10,
+ 0x04,0x11,0x04,0xb7,0x01,0xa0,0x00,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,
+};
+
diff --git a/board/wmt/wmt_battery/gauge/upi/ggb/ug31xx_ggb_data_uboot_wms8309_dw7_2900_20131129_194524.h b/board/wmt/wmt_battery/gauge/upi/ggb/ug31xx_ggb_data_uboot_wms8309_dw7_2900_20131129_194524.h
new file mode 100755
index 0000000..46aee48
--- /dev/null
+++ b/board/wmt/wmt_battery/gauge/upi/ggb/ug31xx_ggb_data_uboot_wms8309_dw7_2900_20131129_194524.h
@@ -0,0 +1,233 @@
+
+/* This file is auto-generated. Don't edit this file. */
+
+/// R-Sense = 20
+/// ILMD = 2900
+/// EDVF = 3500
+/// Taper Current = 150
+/// Taper Voltage = 4150
+/// Taper Time = 60
+
+char FactoryGGBXFile_wms8309_dw7_2900mAh[] = {
+ 0x5f,0x47,0x47,0x5f,0x32,0xc4,0x00,0x00,
+ 0x54,0x0c,0xd7,0x95,0x0e,0x00,0x00,0x00,
+ 0xbd,0x06,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x6d,0x4d,0x61,0x78,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x44,0x57,0x37,0x2d,
+ 0x32,0x39,0x30,0x30,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x56,0x4b,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x34,0x30,
+ 0x35,0x35,0x39,0x35,0x50,0x4c,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x01,0x01,0x01,0x00,0x01,0x01,0x00,0x00,
+ 0x70,0x00,0x64,0x00,0x00,0x00,0x00,0x14,
+ 0x00,0x00,0x54,0x0b,0xac,0x0d,0x14,0x00,
+ 0x96,0x00,0x36,0x10,0x3c,0x00,0x06,0x00,
+ 0x00,0x00,0x00,0x00,0xb8,0x0b,0x80,0x0c,
+ 0x00,0x00,0x32,0x00,0x26,0x02,0xf4,0x01,
+ 0x5c,0xff,0x77,0x01,0x63,0x05,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0xf0,0xdf,0xf4,0x67,
+ 0xe8,0xcf,0xee,0x1b,0xe8,0x03,0xe8,0x03,
+ 0x00,0x00,0xe8,0x03,0x00,0x00,0x10,0x27,
+ 0x05,0x62,0x8a,0x5d,0x9c,0x58,0x4c,0x53,
+ 0xb3,0x4d,0xeb,0x47,0x15,0x42,0x4b,0x3c,
+ 0xc7,0x36,0x80,0x31,0x86,0x2c,0xe5,0x27,
+ 0xa2,0x23,0xc0,0x1f,0x3d,0x1c,0x17,0x19,
+ 0x47,0x16,0xc6,0x13,0x8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,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0x68,0x10,0xb9,0x0f,0x0a,0x0f,0x5b,
+ 0x0e,0xac,0x0d,0x00,0x00,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0x68,0x10,0xb9,0x0f,0x0a,
+ 0x0f,0x5b,0x0e,0xac,0x0d,0x00,0x00,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0x68,0x10,0xb9,
+ 0x0f,0x0a,0x0f,0x5b,0x0e,0xac,0x0d,0x00,
+ 0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x68,
+ 0x10,0xb9,0x0f,0x0a,0x0f,0x5b,0x0e,0xac,
+ 0x0d,0x00,0x00,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0x68,0x10,0xb9,0x0f,0x0a,0x0f,0x5b,
+ 0x0e,0xac,0x0d,0x00,0x00,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0x68,0x10,0xb9,0x0f,0x0a,
+ 0x0f,0x5b,0x0e,0xac,0x0d,0x00,0x00,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0x68,0x10,0xb9,
+ 0x0f,0x0a,0x0f,0x5b,0x0e,0xac,0x0d,0x00,
+ 0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x68,
+ 0x10,0xb9,0x0f,0x0a,0x0f,0x5b,0x0e,0xac,
+ 0x0d,0x00,0x00,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0x68,0x10,0xb9,0x0f,0x0a,0x0f,0x5b,
+ 0x0e,0xac,0x0d,0x00,0x00,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0x68,0x10,0xb9,0x0f,0x0a,
+ 0x0f,0x5b,0x0e,0xac,0x0d,0x00,0x00,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xb5,0x08,0x00,
+ 0x00,0x89,0x01,0x8c,0x02,0x9f,0x04,0xe0,
+ 0x01,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x27,
+ 0x0a,0xdf,0x00,0x58,0x02,0x28,0x04,0xc6,
+ 0x02,0x76,0x00,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0x3e,0x0a,0x58,0x01,0x7c,0x02,0xa9,
+ 0x04,0xbf,0x01,0x63,0x00,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0x0f,0x08,0x00,0x00,0x28,
+ 0x01,0x5c,0x02,0x8a,0x04,0x3b,0x02,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xea,0x09,0xac,
+ 0x00,0x34,0x02,0x1b,0x04,0xee,0x02,0x73,
+ 0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x09,
+ 0x0a,0x2f,0x01,0x5f,0x02,0xd2,0x04,0xa7,
+ 0x01,0x5c,0x00,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xb5,0x06,0x00,0x00,0x9e,0x00,0x17,
+ 0x02,0x00,0x04,0x49,0x03,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0x9f,0x09,0x61,0x00,0x0c,
+ 0x02,0xc3,0x03,0x6e,0x03,0x86,0x00,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xd4,0x09,0xee,
+ 0x00,0x49,0x02,0xd0,0x04,0xcb,0x01,0x5d,
+ 0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x5e,
+ 0x04,0x00,0x00,0x22,0x00,0x48,0x01,0xf3,
+ 0x02,0xb6,0x05,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0x2c,0x09,0x88,0x00,0xf9,0x00,0x1b,
+ 0x03,0x8f,0x04,0xf9,0x00,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0x71,0x09,0x8d,0x00,0xd5,
+ 0x01,0xcf,0x04,0x3e,0x02,0x6f,0x00,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,
+};
+
diff --git a/board/wmt/wmt_battery/gauge/upi/ggb/ug31xx_ggb_data_uboot_wms8309_dw7_4000_20131129_194502.h b/board/wmt/wmt_battery/gauge/upi/ggb/ug31xx_ggb_data_uboot_wms8309_dw7_4000_20131129_194502.h
new file mode 100755
index 0000000..0d96a79
--- /dev/null
+++ b/board/wmt/wmt_battery/gauge/upi/ggb/ug31xx_ggb_data_uboot_wms8309_dw7_4000_20131129_194502.h
@@ -0,0 +1,233 @@
+
+/* This file is auto-generated. Don't edit this file. */
+
+/// R-Sense = 20
+/// ILMD = 4000
+/// EDVF = 3500
+/// Taper Current = 150
+/// Taper Voltage = 4150
+/// Taper Time = 60
+
+char FactoryGGBXFile_wms8309_dw7_4000mAh[] = {
+ 0x5f,0x47,0x47,0x5f,0xda,0xc4,0x00,0x00,
+ 0x3e,0x0c,0xd7,0x95,0x0e,0x00,0x00,0x00,
+ 0xbd,0x06,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x6d,0x4d,0x61,0x78,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x44,0x57,0x37,0x2d,
+ 0x34,0x30,0x30,0x30,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x56,0x4b,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x34,0x32,
+ 0x35,0x37,0x31,0x33,0x35,0x50,0x4c,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x01,0x01,0x01,0x00,0x01,0x01,0x00,0x00,
+ 0x70,0x00,0x64,0x00,0x00,0x00,0x00,0x14,
+ 0x00,0x00,0xa0,0x0f,0xac,0x0d,0x14,0x00,
+ 0x96,0x00,0x36,0x10,0x3c,0x00,0x06,0x00,
+ 0x00,0x00,0x00,0x00,0xb8,0x0b,0x80,0x0c,
+ 0x00,0x00,0x32,0x00,0x26,0x02,0xf4,0x01,
+ 0x5c,0xff,0x77,0x01,0x63,0x05,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0xf0,0xdf,0xf4,0x67,
+ 0xe8,0xcf,0xee,0x1b,0x20,0x04,0x20,0x04,
+ 0xd6,0xff,0xe8,0x03,0x00,0x00,0x10,0x27,
+ 0x05,0x62,0x8a,0x5d,0x9c,0x58,0x4c,0x53,
+ 0xb3,0x4d,0xeb,0x47,0x15,0x42,0x4b,0x3c,
+ 0xc7,0x36,0x80,0x31,0x86,0x2c,0xe5,0x27,
+ 0xa2,0x23,0xc0,0x1f,0x3d,0x1c,0x17,0x19,
+ 0x47,0x16,0xc6,0x13,0x8e,0x11,0xe8,0x03,
+ 0x84,0x03,0xee,0x02,0x58,0x02,0xc2,0x01,
+ 0x1e,0x00,0xe8,0x03,0xff,0x77,0x00,0x00,
+ 0x00,0x00,0x21,0x38,0x00,0xEE,0xEE,0xEE,0x68,0x10,0x68,
+ 0x10,0x68,0x10,0x68,0x10,0x68,0x10,0x58,
+ 0x10,0x37,0x10,0x19,0x10,0xfe,0x0f,0xe5,
+ 0x0f,0xcf,0x0f,0xbb,0x0f,0xa9,0x0f,0x98,
+ 0x0f,0x87,0x0f,0x75,0x0f,0x5c,0x0f,0x3e,
+ 0x0f,0x24,0x0f,0xf5,0x0e,0xac,0x0d,0x68,
+ 0x10,0x2c,0x10,0x06,0x10,0xdf,0x0f,0xba,
+ 0x0f,0x9a,0x0f,0x7d,0x0f,0x67,0x0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10,0x1f,
+ 0x10,0x00,0x10,0xe1,0x0f,0x9a,0x0f,0x4b,
+ 0x0f,0x10,0x0f,0xf2,0x0e,0xdb,0x0e,0xc9,
+ 0x0e,0xbc,0x0e,0xad,0x0e,0x9d,0x0e,0x8c,
+ 0x0e,0x7a,0x0e,0x6b,0x0e,0x58,0x0e,0x44,
+ 0x0e,0x10,0x0e,0xac,0x0d,0x68,0x10,0xb9,
+ 0x0f,0x0a,0x0f,0x5b,0x0e,0xac,0x0d,0x00,
+ 0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x68,
+ 0x10,0xb9,0x0f,0x0a,0x0f,0x5b,0x0e,0xac,
+ 0x0d,0x00,0x00,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0x68,0x10,0xb9,0x0f,0x0a,0x0f,0x5b,
+ 0x0e,0xac,0x0d,0x00,0x00,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0x68,0x10,0xb9,0x0f,0x0a,
+ 0x0f,0x5b,0x0e,0xac,0x0d,0x00,0x00,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0x68,0x10,0xb9,
+ 0x0f,0x0a,0x0f,0x5b,0x0e,0xac,0x0d,0x00,
+ 0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x68,
+ 0x10,0xb9,0x0f,0x0a,0x0f,0x5b,0x0e,0xac,
+ 0x0d,0x00,0x00,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0x68,0x10,0xb9,0x0f,0x0a,0x0f,0x5b,
+ 0x0e,0xac,0x0d,0x00,0x00,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0x68,0x10,0xb9,0x0f,0x0a,
+ 0x0f,0x5b,0x0e,0xac,0x0d,0x00,0x00,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0x68,0x10,0xb9,
+ 0x0f,0x0a,0x0f,0x5b,0x0e,0xac,0x0d,0x00,
+ 0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x68,
+ 0x10,0xb9,0x0f,0x0a,0x0f,0x5b,0x0e,0xac,
+ 0x0d,0x00,0x00,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0x68,0x10,0xb9,0x0f,0x0a,0x0f,0x5b,
+ 0x0e,0xac,0x0d,0x00,0x00,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0x68,0x10,0xb9,0x0f,0x0a,
+ 0x0f,0x5b,0x0e,0xac,0x0d,0x00,0x00,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0x07,0x00,
+ 0x00,0x4f,0x01,0xe0,0x02,0xcf,0x03,0xc2,
+ 0x02,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x2b,
+ 0x0a,0xe7,0x00,0xce,0x02,0xdf,0x03,0x95,
+ 0x02,0xac,0x00,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0x5f,0x0a,0x8b,0x01,0x42,0x03,0xe0,
+ 0x03,0xb1,0x01,0x8a,0x00,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xd0,0x06,0x00,0x00,0xac,
+ 0x00,0x8c,0x02,0x97,0x03,0xaa,0x03,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xd1,0x09,0x8b,
+ 0x00,0x91,0x02,0xd3,0x03,0xe1,0x02,0xc7,
+ 0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x1d,
+ 0x0a,0x47,0x01,0x14,0x03,0xfa,0x03,0xc7,
+ 0x01,0x89,0x00,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0x4f,0x04,0x00,0x00,0x84,0x01,0xb6,
+ 0x00,0x14,0x02,0xed,0x04,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0x28,0x09,0x1a,0x00,0x29,
+ 0x02,0x9a,0x03,0x4a,0x03,0x2f,0x01,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xc0,0x09,0xdb,
+ 0x00,0xc3,0x02,0x07,0x04,0x19,0x02,0x9e,
+ 0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x26,
+ 0x02,0x00,0x00,0x93,0x00,0xa4,0x00,0xef,
+ 0x00,0xdb,0x0a,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xcf,0x08,0xee,0x00,0x40,0x02,0xc6,
+ 0x00,0xd9,0x04,0x16,0x03,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xa3,0x09,0x96,0x01,0x2a,
+ 0x01,0x81,0x03,0x60,0x03,0xf9,0x00,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,
+};
+
diff --git a/board/wmt/wmt_battery/gauge/upi/ggb/ug31xx_ggb_data_uboot_wms8309_wm8_20130820_110949.h b/board/wmt/wmt_battery/gauge/upi/ggb/ug31xx_ggb_data_uboot_wms8309_wm8_20130820_110949.h
new file mode 100755
index 0000000..b5dd5be
--- /dev/null
+++ b/board/wmt/wmt_battery/gauge/upi/ggb/ug31xx_ggb_data_uboot_wms8309_wm8_20130820_110949.h
@@ -0,0 +1,233 @@
+
+/* This file is auto-generated. Don't edit this file. */
+
+/// R-Sense = 20
+/// ILMD = 5000
+/// EDVF = 3500
+/// Taper Current = 200
+/// Taper Voltage = 4150
+/// Taper Time = 60
+
+char FactoryGGBXFile_wms8309_wm8 [] = {
+ 0x5f,0x47,0x47,0x5f,0x1d,0xcc,0x00,0x00,
+ 0xfd,0x0e,0x54,0x95,0x0e,0x00,0x00,0x00,
+ 0xbd,0x06,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x57,0x4d,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x57,0x4d,0x53,0x38,
+ 0x33,0x30,0x39,0x2d,0x31,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x57,0x4d,
+ 0x38,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x33,0x37,
+ 0x31,0x30,0x38,0x31,0x30,0x33,0x50,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x01,0x01,0x02,0x00,0x01,0x01,0x00,0x00,
+ 0x70,0x00,0x64,0x00,0x00,0x00,0x00,0x14,
+ 0x00,0x00,0x88,0x13,0xac,0x0d,0x14,0x00,
+ 0xc8,0x00,0x36,0x10,0x3c,0x00,0x06,0x00,
+ 0x00,0x00,0x00,0x00,0xe4,0x0c,0x48,0x0d,
+ 0x00,0x00,0x32,0x00,0x26,0x02,0xf4,0x01,
+ 0x5c,0xff,0x77,0x01,0x63,0x05,0x00,0x00,
+ 0x00,0x00,0x01,0x00,0xf0,0xdf,0xf4,0x67,
+ 0xe8,0xcf,0xee,0x1b,0xe8,0x03,0xe8,0x03,
+ 0x00,0x00,0xe8,0x03,0x00,0x00,0x10,0x27,
+ 0x1e,0x61,0xae,0x5c,0xce,0x57,0x94,0x52,
+ 0x14,0x4d,0x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x0e,0xac,
+ 0x0d,0x00,0x00,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0x68,0x10,0xb9,0x0f,0x0a,0x0f,0x5b,
+ 0x0e,0xac,0x0d,0x00,0x00,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0x68,0x10,0xb9,0x0f,0x0a,
+ 0x0f,0x5b,0x0e,0xac,0x0d,0x00,0x00,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0x68,0x10,0xb9,
+ 0x0f,0x0a,0x0f,0x5b,0x0e,0xac,0x0d,0x00,
+ 0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x68,
+ 0x10,0xb9,0x0f,0x0a,0x0f,0x5b,0x0e,0xac,
+ 0x0d,0x00,0x00,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0x68,0x10,0xb9,0x0f,0x0a,0x0f,0x5b,
+ 0x0e,0xac,0x0d,0x00,0x00,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0x68,0x10,0xb9,0x0f,0x0a,
+ 0x0f,0x5b,0x0e,0xac,0x0d,0x00,0x00,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0x68,0x10,0xb9,
+ 0x0f,0x0a,0x0f,0x5b,0x0e,0xac,0x0d,0x00,
+ 0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x68,
+ 0x10,0xb9,0x0f,0x0a,0x0f,0x5b,0x0e,0xac,
+ 0x0d,0x00,0x00,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0x68,0x10,0xb9,0x0f,0x0a,0x0f,0x5b,
+ 0x0e,0xac,0x0d,0x00,0x00,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0x68,0x10,0xb9,0x0f,0x0a,
+ 0x0f,0x5b,0x0e,0xac,0x0d,0x00,0x00,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xf9,0x11,0xc1,
+ 0x00,0xb7,0x03,0xc5,0x05,0xba,0x07,0xa4,
+ 0x01,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x0c,
+ 0x13,0x48,0x02,0x75,0x04,0x96,0x08,0xb7,
+ 0x03,0xbd,0x00,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0x35,0x13,0xdf,0x02,0xb8,0x04,0xd9,
+ 0x08,0xc4,0x02,0xa8,0x00,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0x1a,0x12,0x20,0x00,0x23,
+ 0x03,0x2c,0x05,0xaa,0x09,0x97,0x02,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0x11,0x14,0xa2,
+ 0x01,0x50,0x04,0xca,0x09,0x53,0x04,0xcb,
+ 0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x4c,
+ 0x14,0x5e,0x02,0xd0,0x04,0x51,0x0a,0xcc,
+ 0x02,0xaa,0x00,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0x2e,0x0f,0x11,0x00,0x9b,0x02,0x7c,
+ 0x04,0x05,0x08,0x05,0x04,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0x35,0x12,0x48,0x01,0xec,
+ 0x03,0xd7,0x07,0x28,0x05,0xec,0x00,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0x9b,0x12,0x23,
+ 0x02,0x58,0x04,0x31,0x09,0xef,0x02,0xa3,
+ 0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x7a,
+ 0x0a,0x00,0x00,0xb4,0x00,0x89,0x03,0x3d,
+ 0x06,0x96,0x08,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xb9,0x10,0x73,0x01,0xae,0x01,0xe4,
+ 0x05,0xb3,0x07,0xb6,0x01,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0x48,0x12,0xab,0x01,0x0d,
+ 0x04,0xb1,0x08,0xde,0x03,0xdd,0x00,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,
+};
+
diff --git a/board/wmt/wmt_battery/gauge/upi/global.h b/board/wmt/wmt_battery/gauge/upi/global.h
new file mode 100755
index 0000000..e328bec
--- /dev/null
+++ b/board/wmt/wmt_battery/gauge/upi/global.h
@@ -0,0 +1,31 @@
+#ifndef _GLOBAL_H_
+#define _GLOBAL_H_
+
+#define UG31XX_DEBUG_ENABLE
+//#define UG31XX_RESET_DATABASE ///< [AT-PM] : DEFAULT off ; 04/13/2013
+
+#if defined (uG31xx_OS_WINDOWS)
+
+ #pragma pack(push)
+ #pragma pack(1)
+
+ #ifdef UG31XX_DEBUG_ENABLE
+ #define DEBUG_LOG
+ #define uG31xx_NAC_LMD_ADJUST_DEBUG_ENABLE
+ #define TABLE_BACKUP_DEBUG_ENABLE
+ #define DEBUG_LOG_AT_PM
+ #define CALIBRATE_ADC_DEBUG_LOG
+ #endif ///< end of UG31XX_DEBUG_ENABLE
+
+ #define EXPORTS _declspec(dllexport)
+
+#elif defined(uG31xx_OS_ANDROID)
+
+ #define EXPORTS
+
+#endif
+
+#define ENABLE_BQ27520_SW_CMD
+//#define ENABLE_NTC_CHECK
+
+#endif
diff --git a/board/wmt/wmt_battery/gauge/upi/stdafx.h b/board/wmt/wmt_battery/gauge/upi/stdafx.h
new file mode 100755
index 0000000..8db0f14
--- /dev/null
+++ b/board/wmt/wmt_battery/gauge/upi/stdafx.h
@@ -0,0 +1,8 @@
+/**
+ * @filename stdafx.h
+ *
+ * Dummy header file
+ *
+ * @author AllenTeng <allen_teng@upi-semi.com>
+ */
+
diff --git a/board/wmt/wmt_battery/gauge/upi/timer.h b/board/wmt/wmt_battery/gauge/upi/timer.h
new file mode 100755
index 0000000..6abd913
--- /dev/null
+++ b/board/wmt/wmt_battery/gauge/upi/timer.h
@@ -0,0 +1,302 @@
+#ifndef _LINUX_TIMER_H
+#define _LINUX_TIMER_H
+
+#include <linux/list.h>
+#include <linux/ktime.h>
+#include <linux/stddef.h>
+#include <linux/debugobjects.h>
+#include <linux/stringify.h>
+
+struct tvec_base;
+
+struct timer_list {
+ /*
+ * All fields that change during normal runtime grouped to the
+ * same cacheline
+ */
+ struct list_head entry;
+ unsigned long expires;
+ struct tvec_base *base;
+
+ void (*function)(unsigned long);
+ unsigned long data;
+
+ int slack;
+
+#ifdef CONFIG_TIMER_STATS
+ int start_pid;
+ void *start_site;
+ char start_comm[16];
+#endif
+#ifdef CONFIG_LOCKDEP
+ struct lockdep_map lockdep_map;
+#endif
+};
+
+extern struct tvec_base boot_tvec_bases;
+
+#ifdef CONFIG_LOCKDEP
+/*
+ * NB: because we have to copy the lockdep_map, setting the lockdep_map key
+ * (second argument) here is required, otherwise it could be initialised to
+ * the copy of the lockdep_map later! We use the pointer to and the string
+ * "<file>:<line>" as the key resp. the name of the lockdep_map.
+ */
+#define __TIMER_LOCKDEP_MAP_INITIALIZER(_kn) \
+ .lockdep_map = STATIC_LOCKDEP_MAP_INIT(_kn, &_kn),
+#else
+#define __TIMER_LOCKDEP_MAP_INITIALIZER(_kn)
+#endif
+
+/*
+ * Note that all tvec_bases are 2 byte aligned and lower bit of
+ * base in timer_list is guaranteed to be zero. Use the LSB to
+ * indicate whether the timer is deferrable.
+ *
+ * A deferrable timer will work normally when the system is busy, but
+ * will not cause a CPU to come out of idle just to service it; instead,
+ * the timer will be serviced when the CPU eventually wakes up with a
+ * subsequent non-deferrable timer.
+ */
+#define TBASE_DEFERRABLE_FLAG (0x1)
+
+#define TIMER_INITIALIZER(_function, _expires, _data) { \
+ .entry = { .prev = TIMER_ENTRY_STATIC }, \
+ .function = (_function), \
+ .expires = (_expires), \
+ .data = (_data), \
+ .base = &boot_tvec_bases, \
+ .slack = -1, \
+ __TIMER_LOCKDEP_MAP_INITIALIZER( \
+ __FILE__ ":" __stringify(__LINE__)) \
+ }
+
+#define TBASE_MAKE_DEFERRED(ptr) ((struct tvec_base *) \
+ ((unsigned char *)(ptr) + TBASE_DEFERRABLE_FLAG))
+
+#define TIMER_DEFERRED_INITIALIZER(_function, _expires, _data) {\
+ .entry = { .prev = TIMER_ENTRY_STATIC }, \
+ .function = (_function), \
+ .expires = (_expires), \
+ .data = (_data), \
+ .base = TBASE_MAKE_DEFERRED(&boot_tvec_bases), \
+ __TIMER_LOCKDEP_MAP_INITIALIZER( \
+ __FILE__ ":" __stringify(__LINE__)) \
+ }
+
+#define DEFINE_TIMER(_name, _function, _expires, _data) \
+ struct timer_list _name = \
+ TIMER_INITIALIZER(_function, _expires, _data)
+
+void init_timer_key(struct timer_list *timer,
+ const char *name,
+ struct lock_class_key *key);
+void init_timer_deferrable_key(struct timer_list *timer,
+ const char *name,
+ struct lock_class_key *key);
+
+#ifdef CONFIG_LOCKDEP
+#define init_timer(timer) \
+ do { \
+ static struct lock_class_key __key; \
+ init_timer_key((timer), #timer, &__key); \
+ } while (0)
+
+#define init_timer_deferrable(timer) \
+ do { \
+ static struct lock_class_key __key; \
+ init_timer_deferrable_key((timer), #timer, &__key); \
+ } while (0)
+
+#define init_timer_on_stack(timer) \
+ do { \
+ static struct lock_class_key __key; \
+ init_timer_on_stack_key((timer), #timer, &__key); \
+ } while (0)
+
+#define setup_timer(timer, fn, data) \
+ do { \
+ static struct lock_class_key __key; \
+ setup_timer_key((timer), #timer, &__key, (fn), (data));\
+ } while (0)
+
+#define setup_timer_on_stack(timer, fn, data) \
+ do { \
+ static struct lock_class_key __key; \
+ setup_timer_on_stack_key((timer), #timer, &__key, \
+ (fn), (data)); \
+ } while (0)
+#define setup_deferrable_timer_on_stack(timer, fn, data) \
+ do { \
+ static struct lock_class_key __key; \
+ setup_deferrable_timer_on_stack_key((timer), #timer, \
+ &__key, (fn), \
+ (data)); \
+ } while (0)
+#else
+#define init_timer(timer)\
+ init_timer_key((timer), NULL, NULL)
+#define init_timer_deferrable(timer)\
+ init_timer_deferrable_key((timer), NULL, NULL)
+#define init_timer_on_stack(timer)\
+ init_timer_on_stack_key((timer), NULL, NULL)
+#define setup_timer(timer, fn, data)\
+ setup_timer_key((timer), NULL, NULL, (fn), (data))
+#define setup_timer_on_stack(timer, fn, data)\
+ setup_timer_on_stack_key((timer), NULL, NULL, (fn), (data))
+#define setup_deferrable_timer_on_stack(timer, fn, data)\
+ setup_deferrable_timer_on_stack_key((timer), NULL, NULL, (fn), (data))
+#endif
+
+#ifdef CONFIG_DEBUG_OBJECTS_TIMERS
+extern void init_timer_on_stack_key(struct timer_list *timer,
+ const char *name,
+ struct lock_class_key *key);
+extern void destroy_timer_on_stack(struct timer_list *timer);
+#else
+static inline void destroy_timer_on_stack(struct timer_list *timer) { }
+static inline void init_timer_on_stack_key(struct timer_list *timer,
+ const char *name,
+ struct lock_class_key *key)
+{
+ init_timer_key(timer, name, key);
+}
+#endif
+
+static inline void setup_timer_key(struct timer_list * timer,
+ const char *name,
+ struct lock_class_key *key,
+ void (*function)(unsigned long),
+ unsigned long data)
+{
+ timer->function = function;
+ timer->data = data;
+ init_timer_key(timer, name, key);
+}
+
+static inline void setup_timer_on_stack_key(struct timer_list *timer,
+ const char *name,
+ struct lock_class_key *key,
+ void (*function)(unsigned long),
+ unsigned long data)
+{
+ timer->function = function;
+ timer->data = data;
+ init_timer_on_stack_key(timer, name, key);
+}
+
+extern void setup_deferrable_timer_on_stack_key(struct timer_list *timer,
+ const char *name,
+ struct lock_class_key *key,
+ void (*function)(unsigned long),
+ unsigned long data);
+
+/**
+ * timer_pending - is a timer pending?
+ * @timer: the timer in question
+ *
+ * timer_pending will tell whether a given timer is currently pending,
+ * or not. Callers must ensure serialization wrt. other operations done
+ * to this timer, eg. interrupt contexts, or other CPUs on SMP.
+ *
+ * return value: 1 if the timer is pending, 0 if not.
+ */
+static inline int timer_pending(const struct timer_list * timer)
+{
+ return timer->entry.next != NULL;
+}
+
+extern void add_timer_on(struct timer_list *timer, int cpu);
+extern int del_timer(struct timer_list * timer);
+extern int mod_timer(struct timer_list *timer, unsigned long expires);
+extern int mod_timer_pending(struct timer_list *timer, unsigned long expires);
+extern int mod_timer_pinned(struct timer_list *timer, unsigned long expires);
+
+extern void set_timer_slack(struct timer_list *time, int slack_hz);
+
+#define TIMER_NOT_PINNED 0
+#define TIMER_PINNED 1
+/*
+ * The jiffies value which is added to now, when there is no timer
+ * in the timer wheel:
+ */
+#define NEXT_TIMER_MAX_DELTA ((1UL << 30) - 1)
+
+/*
+ * Return when the next timer-wheel timeout occurs (in absolute jiffies),
+ * locks the timer base and does the comparison against the given
+ * jiffie.
+ */
+extern unsigned long get_next_timer_interrupt(unsigned long now);
+
+/*
+ * Timer-statistics info:
+ */
+#ifdef CONFIG_TIMER_STATS
+
+extern int timer_stats_active;
+
+#define TIMER_STATS_FLAG_DEFERRABLE 0x1
+
+extern void init_timer_stats(void);
+
+extern void timer_stats_update_stats(void *timer, pid_t pid, void *startf,
+ void *timerf, char *comm,
+ unsigned int timer_flag);
+
+extern void __timer_stats_timer_set_start_info(struct timer_list *timer,
+ void *addr);
+
+static inline void timer_stats_timer_set_start_info(struct timer_list *timer)
+{
+ if (likely(!timer_stats_active))
+ return;
+ __timer_stats_timer_set_start_info(timer, __builtin_return_address(0));
+}
+
+static inline void timer_stats_timer_clear_start_info(struct timer_list *timer)
+{
+ timer->start_site = NULL;
+}
+#else
+static inline void init_timer_stats(void)
+{
+}
+
+static inline void timer_stats_timer_set_start_info(struct timer_list *timer)
+{
+}
+
+static inline void timer_stats_timer_clear_start_info(struct timer_list *timer)
+{
+}
+#endif
+
+extern void add_timer(struct timer_list *timer);
+
+extern int try_to_del_timer_sync(struct timer_list *timer);
+
+#ifdef CONFIG_SMP
+ extern int del_timer_sync(struct timer_list *timer);
+#else
+# define del_timer_sync(t) del_timer(t)
+#endif
+
+#define del_singleshot_timer_sync(t) del_timer_sync(t)
+
+extern void init_timers(void);
+extern void run_local_timers(void);
+struct hrtimer;
+extern enum hrtimer_restart it_real_fn(struct hrtimer *);
+
+unsigned long __round_jiffies(unsigned long j, int cpu);
+unsigned long __round_jiffies_relative(unsigned long j, int cpu);
+unsigned long round_jiffies(unsigned long j);
+unsigned long round_jiffies_relative(unsigned long j);
+
+unsigned long __round_jiffies_up(unsigned long j, int cpu);
+unsigned long __round_jiffies_up_relative(unsigned long j, int cpu);
+unsigned long round_jiffies_up(unsigned long j);
+unsigned long round_jiffies_up_relative(unsigned long j);
+
+#endif
diff --git a/board/wmt/wmt_battery/gauge/upi/typeDefine.h b/board/wmt/wmt_battery/gauge/upi/typeDefine.h
new file mode 100755
index 0000000..6b41222
--- /dev/null
+++ b/board/wmt/wmt_battery/gauge/upi/typeDefine.h
@@ -0,0 +1,462 @@
+/// ===========================================
+/// typeDefine.h
+/// ===========================================
+
+#ifndef _TYPE_DEFINE_H_
+#define _TYPE_DEFINE_H_
+
+typedef unsigned char _upi_u8_;
+typedef unsigned short _upi_u16_;
+typedef unsigned int _upi_u32_;
+typedef unsigned long long _upi_u64_;
+typedef char _upi_s8_;
+typedef short _upi_s16_;
+typedef int _upi_s32_;
+typedef long long _upi_s64_;
+typedef char _upi_bool_;
+
+#define _UPI_TRUE_ (1)
+#define _UPI_FALSE_ (0)
+#define _UPI_NULL_ ((void *)0)
+
+
+#ifdef uG31xx_OS_WINDOWS
+#pragma pack(push)
+#pragma pack(1)
+#endif
+
+#define CELL_PARAMETER_ALARM_EN_UV (1<<0)
+#define CELL_PARAMETER_ALARM_EN_UET (1<<1)
+#define CELL_PARAMETER_ALARM_EN_OET (1<<2)
+
+typedef struct CELL_PARAMETER
+{
+ _upi_u16_ totalSize; //Total struct size
+ _upi_u16_ fw_ver; //CellParameter struct version
+
+ char customer[16]; //Customer name defined by uPI //####2012/08/29#####
+ char project[16]; //Project name defined by uPI
+ _upi_u16_ ggb_version; //0x0102 => 2.1
+
+ char customerSelfDef[16]; //Customer name record by customer
+ char projectSelfDef[16]; //Project name record by customer
+ _upi_u16_ cell_type_code;
+
+ _upi_u8_ ICType; /*[2:0]=000 -> uG3100 [2:0]=001 -> uG3101
+ [2:0]=010 -> uG3102 [2:0]=100 -> uG3103_2
+ [2:0]=101 -> uG3103_3 */
+
+ _upi_u8_ gpio1; /*bit[4] cbc_en32
+ bit[3] cbc_en21
+ bit[2] pwm
+ bit[1] alarm
+ bit[0] gpio */
+ _upi_u8_ gpio2; /*bit[4] cbc_en32
+ bit[3] cbc_en21
+ bit[2] pwm
+ bit[1] alarm
+ bit[0] gpio */
+ _upi_u8_ gpio34; //11/22/2011 -->reg92
+
+ _upi_u8_ cellNumber;
+ _upi_u8_ assignCellOneTo;
+ _upi_u8_ assignCellTwoTo;
+ _upi_u8_ assignCellThreeTo;
+
+ _upi_u16_ i2cAddress; //I2C Address(Hex)
+ _upi_u16_ clock;
+
+ _upi_u8_ tenBitAddressMode;
+ _upi_u8_ highSpeedMode;
+ _upi_u8_ chopCtrl; //11/22/2011 -->regC1
+ _upi_u8_ rSense;
+
+ _upi_s16_ adc1Offset; //11/22/2011 -->reg58/59
+ _upi_u16_ ILMD;
+
+ _upi_u16_ edv1Voltage;
+ _upi_u16_ standbyCurrent;
+
+ _upi_u16_ TPCurrent;
+ _upi_u16_ TPVoltage;
+
+ _upi_u16_ TPTime;
+ _upi_u16_ offsetR;
+
+ _upi_u16_ deltaR;
+ _upi_u16_ TpBypassCurrent; //20121029
+
+ _upi_s16_ uvAlarm;
+ _upi_s16_ uvRelease;
+
+ _upi_s16_ uetAlarm;
+ _upi_s16_ uetRelease;
+
+ _upi_s16_ oetAlarm;
+ _upi_s16_ oetRelease;
+
+ _upi_s16_ oscTuneJ;
+ _upi_s16_ oscTuneK;
+
+ _upi_u8_ maxDeltaQ;
+ _upi_u8_ timeInterval;
+ _upi_u8_ alarm_timer; //11/22/2011 00:*5,01:*10,10:*15,11:*20
+ _upi_u8_ pwm_timer; /*[1:0]=00:32k [1:0]=01:16k
+ [1:0]=10:8k [1:0]=11: 4k */
+
+ _upi_u8_ clkDivA; //11/22/2011
+ _upi_u8_ clkDivB; //11/22/2011
+ _upi_u8_ alarmEnable; /*[7]:COC [6]:DOC [5]:IT [4]:ET
+ [3]:VP [2]:V3 [1]:V2 [0]:V1 */
+ _upi_u8_ cbcEnable; /*[1]:CBC_EN32 [0]:CBC_EN21 */
+
+ _upi_u16_ vBat2_8V_IdealAdcCode; //ideal ADC Code
+ _upi_u16_ vBat2_6V_IdealAdcCode;
+
+ _upi_u16_ vBat3_12V_IdealAdcCode;
+ _upi_u16_ vBat3_9V_IdealAdcCode;
+
+ _upi_s16_ adc1_pgain;
+ _upi_s16_ adc1_ngain;
+
+ _upi_s16_ adc1_pos_offset;
+ _upi_u16_ adc2_gain;
+
+ _upi_s16_ adc2_offset;
+ _upi_u16_ R;
+
+ _upi_u16_ rtTable[ET_NUMS];
+ // SOV_TABLE %
+ _upi_u16_ SOV_TABLE[SOV_NUMS];
+
+ _upi_s16_ adc_d1; //2012/06/06/update for IT25
+ _upi_s16_ adc_d2; //2012/06/06/update for IT80
+
+ _upi_s16_ adc_d3; ///< [AT-PM] : Used for ADC calibration IT code ; 08/15/2012
+ _upi_s16_ adc_d4;
+
+ _upi_s16_ adc_d5;
+ _upi_u16_ NacLmdAdjustCfg;
+
+ _upi_u8_ otp1Scale;
+#if defined(uG31xx_OS_ANDROID)
+}__attribute__((aligned(4))) CELL_PARAMETER;
+#else ///< else of defined(uG31xx_OS_ANDROID)
+}CELL_PARAMETER;
+#endif ///< end of defined(uG31xx_OS_ANDROID)
+
+typedef struct CELL_TABLE
+{
+ _upi_s16_ INIT_OCV[TEMPERATURE_NUMS][OCV_TABLE_IDX_COUNT][OCV_NUMS]; //initial OCV Table,0.1C/0.2C OCV/charge table
+ _upi_s16_ CELL_VOLTAGE_TABLE[TEMPERATURE_NUMS][C_RATE_NUMS][OCV_NUMS]; //cell behavior Model,the voltage data
+ _upi_s16_ CELL_NAC_TABLE[TEMPERATURE_NUMS][C_RATE_NUMS][OCV_NUMS]; //cell behavior Model,the deltaQ
+#if defined(uG31xx_OS_ANDROID)
+} __attribute__((aligned(4))) CELL_TABLE;
+#else ///< else of defined(uG31xx_OS_ANDROID)
+}CELL_TABLE;
+#endif ///< end of defined(uG31xx_OS_ANDROID)
+
+typedef struct CELL_DATA
+{
+ CELL_PARAMETER cellParameter;
+ CELL_TABLE cellTable1;
+#if defined(uG31xx_OS_ANDROID)
+} __attribute__((aligned(4))) CELL_DATA;
+#else ///< else of defined(uG31xx_OS_ANDROID)
+}CELL_DATA;
+#endif ///< end of defined(uG31xx_OS_ANDROID)
+
+#if defined(uG31xx_OS_ANDROID)
+
+ //<ASUS-WAD+>
+ typedef struct _GGBX_FILE_HEADER
+ {
+ _upi_u32_ ggb_tag; //'_GG_'
+ _upi_u32_ sum16; //16 bits checksum, but store as 4 bytes
+ _upi_u64_ time_stamp; //seconds pass since 1970 year, 00:00:00
+ _upi_u64_ length; //size that not only include ggb content. (multi-file support)
+ _upi_u64_ num_ggb; //number of ggb files.
+ } __attribute__((aligned(4))) GGBX_FILE_HEADER;
+ //<ASUS-WAD->
+
+#endif ///< end of defined(uG31xx_OS_ANDROID)
+
+typedef struct ADC_CHECK
+{
+ _upi_u16_ regCounter; //check adc counter
+ _upi_u16_ regVbat1Ave; //check average voltage
+ _upi_u16_ lastCounter;
+ _upi_u16_ lastVBat1Ave;
+ _upi_u16_ failCounterCurrent;
+ _upi_u16_ failCounterVoltage;
+#if defined(uG31xx_OS_ANDROID)
+} __attribute__((aligned(4))) ADC_CHECK;
+#else ///< else of defined(uG31xx_OS_ANDROID)
+}ADC_CHECK;
+#endif ///< end of defined(uG31xx_OS_ANDROID)
+
+typedef struct USER_REGISTER
+{
+ _upi_u8_ mode;
+ _upi_u8_ ctrl1;
+ _upi_u8_ charge_low;
+ _upi_u8_ charge_high;
+ _upi_u8_ counter_low;
+ _upi_u8_ counter_high;
+ _upi_u8_ current_low;
+ _upi_u8_ current_high;
+ _upi_u8_ vbat1_low;
+ _upi_u8_ vbat1_high;
+ _upi_u8_ intr_temper_low;
+ _upi_u8_ intr_temper_high;
+ _upi_u8_ ave_current_low;
+ _upi_u8_ ave_current_high;
+ _upi_u8_ extr_temper_low;
+ _upi_u8_ extr_temper_high;
+ _upi_u8_ rid_low;
+ _upi_u8_ rid_high;
+ _upi_u8_ alarm1_status;
+ _upi_u8_ alarm2_status;
+ _upi_u8_ intr_status;
+ _upi_u8_ alram_en;
+ _upi_u8_ ctrl2;
+#if defined(uG31xx_OS_ANDROID)
+}__attribute__((aligned(4))) USER_REGISTER;
+#else ///< else of defined(uG31xx_OS_ANDROID)
+}USER_REGISTER;
+#endif ///< end of defined(uG31xx_OS_ANDROID)
+
+//2012/08/24/new add for system suspend
+typedef struct _GG_SUSPEND_INFO{
+ _upi_u16_ LMD; //battery Qmax (maH)
+ _upi_u16_ NAC; //battery NAC(maH)
+ _upi_u16_ RSOC; //Battery Current RSOC(%)
+ _upi_u32_ currentTime; //the time tick
+
+#if defined(uG31xx_OS_ANDROID)
+ }__attribute__((aligned(4))) GG_SUSPEND_INFO,*PGG_SUSPEND_INFO;
+#else ///< else of defined(uG31xx_OS_ANDROID)
+}GG_SUSPEND_INFO,*PGG_SUSPEND_INFO;
+#endif ///< end of defined(uG31xx_OS_ANDROID)
+
+typedef struct _GG_BATTERY_INFO{
+ _upi_u16_ LMD; //battery Qmax (maH)
+ _upi_u16_ NAC; //battery NAC(maH)
+ _upi_u16_ RSOC; //Battery Current RSOC(%)
+#if defined(uG31xx_OS_ANDROID)
+ }__attribute__((aligned(4))) GG_BATTERY_INFO;
+#else ///< else of defined(uG31xx_OS_ANDROID)
+}GG_BATTERY_INFO;
+#endif ///< end of defined(uG31xx_OS_ANDROID)
+
+/// [AT-PM] : Used for TI bq27520 like command ; 10/11/2012
+typedef struct GG_TI_BQ27520 {
+ _upi_u16_ CntlControlStatus;
+ _upi_u16_ CntlPrevMacWrite;
+
+ _upi_s16_ AR;
+
+ _upi_u16_ Temp;
+
+ _upi_u16_ Flags;
+ _upi_s16_ SINow;
+ _upi_s32_ SIBuf;
+ _upi_s16_ SISample;
+ _upi_u16_ SIWindow;
+
+ _upi_s16_ Mli;
+ _upi_u8_ MliDsgSoc;
+
+ _upi_u16_ AE;
+
+ _upi_s16_ AP;
+ _upi_u16_ APStartChgE;
+ _upi_u16_ APStartDsgE;
+ _upi_u32_ APChgTime;
+ _upi_u32_ APDsgTime;
+
+ _upi_u16_ CC;
+ _upi_u16_ CCBuf;
+ _upi_u16_ CCLastNac;
+
+ _upi_u16_ Dli;
+
+ _upi_u16_ Dlb;
+
+ _upi_s8_ FCSet;
+ _upi_s8_ FCClear;
+ _upi_u8_ Soc1Set;
+ _upi_u8_ Soc1Clear;
+ _upi_s8_ InitSI;
+ _upi_s16_ InitMaxLoadCurrent;
+ _upi_s16_ CCThreshold;
+ _upi_u32_ Opcfg;
+ _upi_u16_ Dcap;
+
+ _upi_u32_ LastTime;
+ _upi_u16_ DeltaSec;
+#if defined(uG31xx_OS_ANDROID)
+}__attribute__((aligned(4))) GG_TI_BQ27520, *PGG_TI_BQ27520;
+#else ///< else of defined(uG31xx_OS_ANDROID)
+} GG_TI_BQ27520, *PGG_TI_BQ27520;
+#endif ///< end of defined(uG31xx_OS_ANDROID)
+
+typedef struct GGAdcDeltaCodeMappingST {
+ _upi_s32_ Adc1V100;
+ _upi_s32_ Adc1V200;
+ _upi_s32_ Adc2V100;
+ _upi_s32_ Adc2V200;
+#if defined(uG31xx_OS_ANDROID)
+}__attribute__((aligned(4))) GGAdcDeltaCodeMappingType;
+#else ///< else of defined(uG31xx_OS_ANDROID)
+} GGAdcDeltaCodeMappingType;
+#endif ///< end of defined(uG31xx_OS_ANDROID)
+
+typedef struct TableBackupST {
+ _upi_u16_ lowerBound;
+ _upi_u8_ resolution;
+#if defined(uG31xx_OS_ANDROID)
+} __attribute__((aligned(4))) TableBackupType;
+#else ///< else of defined(uG31xx_OS_ANDROID)
+} TableBackupType;
+#endif ///< end of defined(uG31xx_OS_ANDROID)
+
+/* define the register of uG31xx */
+typedef struct _GG_USER_REG{
+ _upi_u8_ regMode; ///< [AT-PM] : 0x00 - MODE ; 04/08/2013
+ _upi_u8_ regCtrl1; ///< [AT-PM] : 0x01 - CTRL1 ; 04/08/2013
+ _upi_s16_ regCharge; ///< [AT-PM] : 0x02 - Charge ; 04/08/2013
+ _upi_u16_ regCounter; ///< [AT-PM] : 0x04 - Counter ; 04/08/2013
+ _upi_s16_ regCurrentAve; ///< [AT-PM] : 0x06 - Ave Current ; 04/08/2013
+ _upi_s16_ regVbat1Ave; ///< [AT-PM] : 0x08 - Ave VBat1 ; 04/08/2013
+ _upi_u16_ regITAve; ///< [AT-PM] : 0x0A - Ave IT ; 04/08/2013
+ _upi_s16_ regOffsetCurrentAve; ///< [AT-PM] : 0x0C - Ave Offset Current ; 04/08/2013
+ _upi_u16_ regETAve; ///< [AT-PM] : 0x0E - Ave ET ; 04/08/2013
+ _upi_u16_ regRidAve; ///< [AT-PM] : 0x10 - Ave RID ; 04/08/2013
+ _upi_u8_ regAlarm1Status; ///< [AT-PM] : 0x12 - Alarm1 Status ; 04/08/2013
+ _upi_u8_ regAlarm2Status; ///< [AT-PM] : 0x13 - Alarm2 Status ; 04/08/2013
+ _upi_u8_ regIntrStatus; ///< [AT-PM] : 0x14 - INTR Status ; 04/08/2013
+ _upi_u8_ regAlarmEnable; ///< [AT-PM] : 0x15 - Alarm EN ; 04/08/2013
+ _upi_u8_ regCtrl2; ///< [AT-PM] : 0x16 - CTRL2 ; 04/08/2013
+#if defined(uG31xx_OS_ANDROID)
+} __attribute__((aligned(4))) GG_USER_REG, *PGG_USER_REG;
+#else ///< else of defined(uG31xx_OS_ANDROID)
+} GG_USER_REG, *PGG_USER_REG;
+#endif ///< end of defined(uG31xx_OS_ANDROID)
+
+/* define the register of uG31xx */
+typedef struct _GG_USER2_REG{
+ _upi_s16_ regVbat2; //0x40,vBat2
+ _upi_s16_ regVbat3; //0x42,vBat3
+ _upi_s16_ regVbat1; //0x44,vBat1 Average
+ _upi_s16_ regVbat2Ave; //0x46,vBat2 Average
+ _upi_s16_ regVbat3Ave; //0x48,vBat3 Average
+ _upi_u16_ regV1; //0x4a,cell 1 Voltage
+ _upi_u16_ regV2; //0x4c,0xcell 2 Voltage
+ _upi_u16_ regV3; //0x4e,cell 3 Voltage
+ _upi_s16_ regIT; //0x50
+ _upi_s16_ regET; //0x52
+ _upi_u16_ regRID; //0x54
+ _upi_s16_ regCurrent; //0x56
+ _upi_s16_ regAdc1Offset; //0x58ADC1 offset
+#if defined(uG31xx_OS_ANDROID)
+}__attribute__((aligned(4))) GG_USER2_REG, *PGG_USER2_REG;
+#else ///< else of defined(uG31xx_OS_ANDROID)
+} GG_USER2_REG, *PGG_USER2_REG;
+#endif ///< end of defined(uG31xx_OS_ANDROID)
+
+#define ALARM_STATUS_UV (1<<0)
+#define ALARM_STATUS_UET (1<<1)
+#define ALARM_STATUS_OET (1<<2)
+
+/* define device information */
+typedef struct _GG_DEVICE_INFO{
+
+ _upi_s16_ oldRegCurrent; //for skip the ADC code Error
+ _upi_s16_ oldRegVbat1; //for skip the ADC code Error
+
+ _upi_s16_ vBat1_AdcCode; //debug use
+ _upi_s16_ vBat1_AveAdcCode;
+
+ _upi_s16_ fwCalAveCurrent_mA; //f/w calculate average current
+ _upi_u32_ lastTime; //
+ _upi_s16_ chargeRegister; //coulomb counter register
+ _upi_u16_ AdcCounter; //ADC convert counter
+
+ _upi_s16_ preChargeRegister; //coulomb counter register
+ _upi_s16_ aveCurrentRegister; //2012/0711/jacky
+ _upi_u16_ preAdcCounter;
+ _upi_s32_ fwChargeData_mAH; //fw calculate maH (Q= I * T)
+
+ _upi_s32_ chargeData_mAh; //maH calculate from charge register
+ _upi_u16_ voltage_mV; //total voltage
+ _upi_s16_ current_mA; // now current
+ _upi_s16_ AveCurrent_mA; // average current
+ _upi_s16_ IT; // internal temperature
+ _upi_s16_ ET; // external temperature
+
+ _upi_u16_ v1_mV; //v1 from hw register
+ _upi_u16_ v2_mV; //v2
+ _upi_u16_ v3_mV; //v3
+
+ _upi_u16_ vBat1Average_mV; //vbat1
+ _upi_u16_ vBat2Average_mV;
+ _upi_u16_ vBat3Average_mV;
+
+
+ _upi_u16_ vCell1_mV; //v Cell1
+ _upi_u16_ vCell2_mV; //v Cell2
+ _upi_u16_ vCell3_mV; //v Cell3
+
+ _upi_s16_ CaliAdc1Code; //2012/08/29/Jacky
+ _upi_s16_ CaliAdc2Code;
+
+ _upi_s16_ CoulombCounter;
+
+ _upi_s32_ CaliChargeReg;
+ _upi_u16_ Adc1ConvTime;
+
+ _upi_u8_ alarmStatus;
+#if defined(uG31xx_OS_ANDROID)
+} __attribute__((aligned(4))) GG_DEVICE_INFO, *PGG_DEVICE_INFO;
+#else ///< else of defined(uG31xx_OS_ANDROID)
+} GG_DEVICE_INFO, *PGG_DEVICE_INFO;
+#endif ///< end of defined(uG31xx_OS_ANDROID)
+
+
+/* define battery capacity */
+typedef struct _GG_CAPACITY {
+ _upi_u16_ LMD; //battery Qmax (maH)
+ _upi_u16_ NAC; //battery NAC(maH)
+ _upi_u16_ RSOC; //Battery Current RSOC(%)
+
+ _upi_u8_ Ready;
+#if defined(uG31xx_OS_ANDROID)
+} __attribute__((aligned(4))) GG_CAPACITY, *PGG_CAPACITY;
+#else ///< else of defined(uG31xx_OS_ANDROID)
+}GG_CAPACITY, *PGG_CAPACITY;
+#endif ///< end of defined(uG31xx_OS_ANDROID)
+
+typedef struct GG_MEAS_PARA_ST
+{
+ _upi_s16_ Adc1Gain;
+ _upi_s16_ Adc1Offset;
+
+ _upi_s16_ Adc2Gain;
+ _upi_s16_ Adc2Offset;
+
+ _upi_s16_ ITOffset;
+ _upi_s16_ ETOffset;
+
+ _upi_u8_ ProductType;
+#if defined(uG31xx_OS_ANDROID)
+}__attribute__((aligned(4))) GG_MEAS_PARA_TYPE;
+#else ///< else of defined(uG31xx_OS_ANDROID)
+} GG_MEAS_PARA_TYPE;
+#endif ///< end of defined(uG31xx_OS_ANDROID)
+
+#endif
+
+/// ===========================================
+/// End of typeDefine.h
+/// ===========================================
diff --git a/board/wmt/wmt_battery/gauge/upi/types.h b/board/wmt/wmt_battery/gauge/upi/types.h
new file mode 100755
index 0000000..28beab9
--- /dev/null
+++ b/board/wmt/wmt_battery/gauge/upi/types.h
@@ -0,0 +1,16 @@
+#ifndef __ASM_ARM_TYPES_H
+#define __ASM_ARM_TYPES_H
+
+#include <asm-generic/int-ll64.h>
+
+/*
+ * These aren't exported outside the kernel to avoid name space clashes
+ */
+#ifdef __KERNEL__
+
+#define BITS_PER_LONG 32
+
+#endif /* __KERNEL__ */
+
+#endif
+
diff --git a/board/wmt/wmt_battery/gauge/upi/uG31xx.h b/board/wmt/wmt_battery/gauge/upi/uG31xx.h
new file mode 100755
index 0000000..67b3dfe
--- /dev/null
+++ b/board/wmt/wmt_battery/gauge/upi/uG31xx.h
@@ -0,0 +1,129 @@
+/// ===========================================
+/// uG31xx.h
+/// ===========================================
+
+#ifndef _UG31XX_H_
+#define _UG31XX_H_
+
+#define SECURITY 1 //Security Mode enable
+#define NORMAL 0 //Security Mode OFF
+
+#define HIGH_SPEED 1 //HS Mode
+#define FULL_SPEED 0 //FIL speed
+
+#define TEN_BIT_ADDR 1 //10-bit address Mode
+#define SEVEN_BIT_ADDR 0 //7-bit address Mode
+
+#define I2C_SUCESS 1 //
+#define I2C_FAIL 0
+
+/// ===========================================================================
+/// Constant for Calibration
+/// ===========================================================================
+
+#define IT_TARGET_CODE25 (12155)
+#define IT_TARGET_CODE80 (14306)
+
+#define IT_CODE_25 (23171)
+#define IT_CODE_80 (27341)
+
+//constant
+//define IC type
+#define uG3100 0
+#define uG3101 1
+#define uG3102 2
+#define uG3103_2 4
+#define uG3103_3 5
+
+//constant
+//GPIO1/2 define
+#define FUN_GPIO 0x01
+#define FUN_ALARM 0x02
+#define FUN_PWM 0x04
+#define FUN_CBC_EN21 0x08
+#define FUN_CBC_EN32 0x10
+
+#define BIT_MACRO(x) ((_upi_u8_)1 << (x))
+
+#define MAX_CRATE_AVAILABLE (20)
+
+#define I2C_ADDRESS 0x70
+#define I2C_CLOCK 0x100
+
+//const for CELL_TABLE table
+#define TEMPERATURE_NUMS (4)
+#define C_RATE_NUMS (3) ///< [AT-PM] : 0.5, 0.2, 0.1, 0.02 ; 12/17/2013
+#define OCV_NUMS (21) //include the 0% & 100%
+#define SOV_NUMS (5) ///< [AT-PM] : 100%, 70%, 45%, 20%, 0% ; 12/17/2012
+#define ET_NUMS (19) ///< [AT-PM] : -10, -5, 0, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80 ; 01/25/2013
+
+#define NAC_LMD_ADJUST_CFG_NO_LMD_UPDATE_BETWEEN_10_90_EN (1<<0)
+#define NAC_LMD_ADJUST_CFG_LOCK_AND_SPEED_UP_START_SOV_MASK (15<<1)
+ #define NAC_LMD_ADJUST_CFG_LOCK_AND_SPEED_UP_START_SOV_00 (0<<1)
+ #define NAC_LMD_ADJUST_CFG_LOCK_AND_SPEED_UP_START_SOV_01 (1<<1)
+ #define NAC_LMD_ADJUST_CFG_LOCK_AND_SPEED_UP_START_SOV_02 (2<<1)
+ #define NAC_LMD_ADJUST_CFG_LOCK_AND_SPEED_UP_START_SOV_03 (3<<1)
+ #define NAC_LMD_ADJUST_CFG_LOCK_AND_SPEED_UP_START_SOV_04 (4<<1)
+ #define NAC_LMD_ADJUST_CFG_LOCK_AND_SPEED_UP_START_SOV_05 (5<<1)
+ #define NAC_LMD_ADJUST_CFG_LOCK_AND_SPEED_UP_START_SOV_06 (6<<1)
+ #define NAC_LMD_ADJUST_CFG_LOCK_AND_SPEED_UP_START_SOV_07 (7<<1)
+ #define NAC_LMD_ADJUST_CFG_LOCK_AND_SPEED_UP_START_SOV_08 (8<<1)
+ #define NAC_LMD_ADJUST_CFG_LOCK_AND_SPEED_UP_START_SOV_09 (9<<1)
+ #define NAC_LMD_ADJUST_CFG_LOCK_AND_SPEED_UP_START_SOV_10 (10<<1)
+ #define NAC_LMD_ADJUST_CFG_LOCK_AND_SPEED_UP_START_SOV_11 (11<<1)
+ #define NAC_LMD_ADJUST_CFG_LOCK_AND_SPEED_UP_START_SOV_12 (12<<1)
+ #define NAC_LMD_ADJUST_CFG_LOCK_AND_SPEED_UP_START_SOV_13 (13<<1)
+ #define NAC_LMD_ADJUST_CFG_LOCK_AND_SPEED_UP_START_SOV_14 (14<<1)
+ #define NAC_LMD_ADJUST_CFG_LOCK_AND_SPEED_UP_START_SOV_15 (15<<1)
+#define NAC_LMD_ADJUST_CFG_DISPLAY_CC_AS_FCC (1<<5)
+
+#if defined(uG31xx_OS_ANDROID)
+
+ #define GGBX_FILE_TAG 0x5F47475F // _GG_
+ #define GGBX_FACTORY_FILE_TAG 0x5F67675F // _gg_
+
+#endif ///< end of defined(uG31xx_OS_ANDROID)
+
+enum C_RATE_TABLE_VALUES {
+ C_RATE_TABLE_VALUE_0 = 50,
+ C_RATE_TABLE_VALUE_1 = 20,
+ C_RATE_TABLE_VALUE_2 = 10,
+ C_RATE_TABLE_VALUE_3 = 2
+};
+
+enum OCV_TABLE_IDX {
+ OCV_TABLE_IDX_CHARGE = 0,
+ OCV_TABLE_IDX_STAND_ALONE,
+ OCV_TABLE_IDX_100MA,
+ OCV_TABLE_IDX_COUNT,
+};
+
+#if defined (uG31xx_OS_WINDOWS)
+
+ #define SleepMiniSecond(x) Sleep(x)
+
+ #ifdef DEBUG_LOG
+
+ #define _L(X) __L(X)
+ #define __L(X) L##X
+
+ #endif
+
+#elif defined (uG31xx_OS_ANDROID)
+
+ //#define SleepMiniSecond(x) mdelay(x)
+ #define SleepMiniSecond(x) wmt_idle_us(x*1000)
+
+
+#endif
+
+#define CONST_PERCENTAGE (100)
+#define TIME_CONVERT_TIME_TO_MSEC (10)
+#define CONST_CONVERSION_COUNT_THRESHOLD (300)
+
+#endif
+
+/// ===========================================
+/// End of uG31xx.h
+/// ===========================================
+
diff --git a/board/wmt/wmt_battery/gauge/upi/uG31xx_API.h b/board/wmt/wmt_battery/gauge/upi/uG31xx_API.h
new file mode 100755
index 0000000..6adcb71
--- /dev/null
+++ b/board/wmt/wmt_battery/gauge/upi/uG31xx_API.h
@@ -0,0 +1,507 @@
+/// ===========================================
+/// uG31xx_API.h
+/// ===========================================
+
+#ifndef _UG31XXAPI_H_
+#define _UG31XXAPI_H_
+
+#include "uG31xx_Platform.h"
+
+#if defined (uG31xx_OS_WINDOWS)
+
+ #include <windows.h>
+
+#endif
+
+#include "global.h"
+#include "uG31xx.h"
+
+#if defined (uG31xx_OS_WINDOWS)
+
+ #include "../../uG31xx_I2C_DLL/uG3100Dll/uG31xx_I2C.h"
+ #include <assert.h>
+
+ #ifdef DEBUG_LOG
+
+ #include "wDebug.h"
+
+ #endif
+
+#elif defined (uG31xx_OS_ANDROID)
+
+ #ifdef uG31xx_BOOT_LOADER
+
+// #include <sys/types.h>
+// #include <platform/timer.h>
+
+// #define UPI_UBOOT_DEBUG_MSG
+
+ #include "ug31xx_boot_i2c.h"
+
+ #else ///< else of uG31xx_BOOT_LOADER
+
+ #include <linux/module.h>
+ #include <linux/delay.h>
+ #include <linux/fs.h>
+ #include <asm/uaccess.h>
+
+ #include "ug31xx_i2c.h"
+
+ #endif ///< end of uG31xx_BOOT_LOADER
+
+#endif
+
+#include "typeDefine.h"
+#include "uG31xx_Reg_Def.h"
+#include "uG31xx_API_Otp.h"
+#include "uG31xx_API_System.h"
+#include "uG31xx_API_Measurement.h"
+#include "uG31xx_API_Capacity.h"
+#include "uG31xx_API_Backup.h"
+
+#define UG31XX_API_MAIN_VERSION (13)
+#define UG31XX_API_OTP_VERSION ((UG31XX_OTP_VERSION_MAIN << 16) | UG31XX_OTP_VERSION_SUB)
+#define UG31XX_API_SUB_VERSION ((UG31XX_CAP_VERSION << 16) | (UG31XX_MEAS_VERSION << 8) | UG31XX_SYSTEM_VERSION)
+
+#define UG31XX_I2C_HIGH_SPEED_MODE (_UPI_FALSE_)
+#define UG31XX_I2C_TEM_BITS_MODE (_UPI_FALSE_)
+
+#ifdef UG31XX_DEBUG_ENABLE
+
+ #if defined(uG31xx_OS_ANDROID)
+
+ #ifdef uG31xx_BOOT_LOADER
+
+ #define __func__
+
+ #define UG31_LOGE(...)
+ #define UG31_LOGI(...)
+ #define UG31_LOGD(...)
+ #define UG31_LOGV(...)
+
+ extern int ug31_dprintk(int level, const char *fmt, ...);
+
+ #else ///< else of uG31xx_BOOT_LOADER
+
+ #define LOG_NORMAL (0)
+ #define LOG_ERROR (1)
+ #define LOG_DATA (2)
+ #define LOG_VERBOSE (3)
+
+ #define UG31_TAG "UG31"
+ #define UG31_LOGE(...) ug31_printk(LOG_ERROR, "<"UG31_TAG"/E>" __VA_ARGS__);
+ #define UG31_LOGI(...) ug31_printk(LOG_NORMAL, "<"UG31_TAG"/I>" __VA_ARGS__);
+ #define UG31_LOGD(...) ug31_printk(LOG_DATA, "<"UG31_TAG"/D>" __VA_ARGS__);
+ #define UG31_LOGV(...) ug31_printk(LOG_VERBOSE, "<"UG31_TAG"/V>" __VA_ARGS__);
+
+ extern int ug31_printk(int level, const char *fmt, ...);
+
+ #endif ///< end of uG31xx_BOOT_LOADER
+
+ #endif ///< end of defined(uG31xx_OS_ANDROID)
+
+ #if defined (uG31xx_OS_WINDOWS)
+
+ #define DEBUG_FILE (_T("uG3105"))
+ #define __func__ (_T(__FUNCTION__))
+
+ #define UG31_LOGE(...) wDebug::LOGE(DEBUG_FILE, 0, _T(__VA_ARGS__));
+ #define UG31_LOGI(...) wDebug::LOGE(DEBUG_FILE, 0, _T(__VA_ARGS__));
+ #define UG31_LOGD(...) wDebug::LOGE(DEBUG_FILE, 0, _T(__VA_ARGS__));
+ #define UG31_LOGV(...) wDebug::LOGE(DEBUG_FILE, 0, _T(__VA_ARGS__));
+
+ #endif ///< end of defined (uG31xx_OS_WINDOWS)
+
+#else ///< else of UG31XX_DEBUG_ENABLE
+
+ #define UG31_LOGE(...)
+ #define UG31_LOGI(...)
+ #define UG31_LOGD(...)
+ #define UG31_LOGV(...)
+
+#endif ///< end of UG31XX_DEBUG_ENABLE
+
+#if defined(uG31xx_OS_ANDROID)
+
+ extern _upi_u32_ GetTickCount(void);
+ extern _upi_u32_ GetSysTickCount(void);
+
+#endif
+
+/* data struct */
+typedef enum _GGSTATUS{
+ UG_SUCCESS = 0x00,
+ UG_FAIL = 0x01,
+ UG_NOT_DEF = 0x02,
+ UG_INIT_OCV_FAIL = 0x03,
+ UG_READ_GGB_FAIL = 0x04,
+ UG_ACTIVE_FAIL = 0x05,
+ UG_INIT_SUCCESS = 0x06,
+ UG_OTP_ISEMPTY = 0x07,
+ UG_OTP_PRODUCT_DISMATCH = 0x08,
+
+ UG_I2C_INIT_FAIL = 0x10,
+ UG_I2C_READ_SUCCESS = 0x11,
+ UG_I2C_READ_FAIL = 0x12,
+ UG_I2C_WRITE_SUCCESS = 0x13,
+ UG_I2C_WRITE_FAIL = 0x14,
+
+ UG_READ_REG_SUCCESS = 0x20,
+ UG_READ_REG_FAIL = 0x21,
+
+ UG_READ_DEVICE_INFO_SUCCESS = 0x22,
+ UG_READ_DEVICE_INFO_FAIL = 0x23,
+ UG_READ_DEVICE_ALARM_SUCCESS = 0x24,
+ UG_READ_DEVICE_ALARM_FAIL = 0x25,
+ UG_READ_DEVICE_RID_SUCCESS = 0x26,
+ UG_READ_DEVICE_RID_FAIL = 0x27,
+ UG_READ_ADC_FAIL = 0x28, //new add for filter ADC Error Code
+
+ UG_TI_CMD_OVERFLOW = 0x30,
+
+ UG_MEAS_FAIL = 0x40,
+ UG_MEAS_FAIL_BATTERY_REMOVED = 0x41,
+ UG_MEAS_FAIL_ADC_ABNORMAL = 0x42,
+ UG_MEAS_FAIL_NTC_SHORT = 0x43,
+
+ UG_CAP_DATA_READY = 0x50,
+ UG_CAP_DATA_NOT_READY = 0x51,
+}GGSTATUS;
+
+/*
+ GGSTATUS upiGG_Initial
+ Description: Initial and active uG31xx function
+ Input: .GGB(gas gauge battery) setting filename, need include complete path
+ Output: UG_INIT_SUCCESS -> initial uG31xx success
+ UG_READ_GGB_FAIL -> read GGB file fail
+ UG_INIT_I2C_FAIL -> initial I2C to open HID fail
+ UG_ACTIVE_FAIL -> active uG31xx fail
+*/
+#if defined (uG31xx_OS_WINDOWS)
+
+ EXPORTS GGSTATUS upiGG_Initial(char **pObj, const wchar_t* GGBFilename, const wchar_t* OtpFileName, const wchar_t* BackupFileName);
+
+#endif
+
+#if defined(uG31xx_OS_ANDROID)
+
+ GGSTATUS upiGG_Initial(char **pObj, GGBX_FILE_HEADER *pGGBXBuf);
+
+#endif
+
+/*
+ GGSTATUS upiGG_CountInitQmax
+ Description:
+ Input: None
+ Output: None
+*/
+//EXPORTS void upiGG_CountInitQmax(void);
+
+/*
+ GGSTATUS upiGG_ReadDevieRegister
+ Description: Read GG_USER_REG from device to global variable and output
+ Input: Pointer of sturct GG_USER_REG
+ Output: UG_READ_REG_SUCCESS -> read success
+ UG_READ_REG_FAIL -> read fail
+*/
+EXPORTS GGSTATUS upiGG_ReadAllRegister(char *pObj,GG_USER_REG* pExtUserReg, GG_USER2_REG* pExtUserReg2);
+
+/*
+ GGSTATUS upiGG_ReadDeviceInfo
+ Description: Read GG_USER_REG from device and calculate GG_DEVICE_INFO, then write to global variable and output
+ Input: Pointer of struct GG_DEVICE_INFO
+ Output: UG_READ_DEVICE_INFO_SUCCESS -> calculate derive information sucess
+ UG_READ_DEVICE_INFO_FAIL -> calculate derive information fail
+*/
+EXPORTS GGSTATUS upiGG_ReadDeviceInfo(char *pObj,GG_DEVICE_INFO* pExtDeviceInfo);
+
+/* GGSTATUS upiGG_ReadCapacity
+ Description:
+ Input:
+ Output: None
+*/
+EXPORTS void upiGG_ReadCapacity(char *pObj,GG_CAPACITY *pExtCapacity);
+
+/**
+ * @brief upiGG_GetAlarmStatus
+ *
+ * Get alarm status
+ *
+ * @para pAlarmStatus address of alarm status
+ * @return UG_READ_DEVICE_ALARM_SUCCESS if success
+ */
+EXPORTS GGSTATUS upiGG_GetAlarmStatus(char *pObj, _upi_u8_ *pAlarmStatus);
+
+/*
+new add function for System suspend & wakeup
+
+*/
+EXPORTS GGSTATUS upiGG_PreSuspend(char *pObj);
+EXPORTS GGSTATUS upiGG_Wakeup(char *pObj);
+
+/**
+ * @brief upiGG_DumpRegister
+ *
+ * Dump whole register value
+ *
+ * @para pBuf address of register value buffer
+ * @return data size
+ */
+EXPORTS _upi_u16_ upiGG_DumpRegister(char *pObj, _upi_u8_ *pBuf);
+
+/**
+ * @brief upiGG_DumpCellTable
+ *
+ * Dump cell NAC table
+ *
+ * @para pTable address of cell table
+ * @return _UPI_NULL_
+ */
+EXPORTS void upiGG_DumpCellTable(char *pObj, CELL_TABLE *pTable);
+EXPORTS GGSTATUS upiGG_UnInitial(char **pObj);
+EXPORTS void upiGG_DumpParameter(char *pObj, CELL_PARAMETER *pTable);
+
+#define upiGG_PrePowerOff (upiGG_PreSuspend)
+
+#ifdef ENABLE_BQ27520_SW_CMD
+
+/**
+ * @brief upiGG_AccessMeasurementParameter
+ *
+ * Access measurement parameter
+ *
+ * @para read set _UPI_TRUE_ to read data from API
+ * @para pMeasPara pointer of GG_MEAS_PARA_TYPE
+ * @return GGSTATUS
+ */
+EXPORTS GGSTATUS upiGG_AccessMeasurementParameter(char *pObj, _upi_bool_ read, GG_MEAS_PARA_TYPE *pMeasPara);
+
+#define UG_STD_CMD_CNTL (0x00)
+ #define UG_STD_CMD_CNTL_CONTROL_STATUS (0x0000)
+ #define UG_STD_CMD_CNTL_CONTROL_STATUS_DLOGEN (1<<15)
+ #define UG_STD_CMD_CNTL_CONTROL_STATUS_FAS (1<<14)
+ #define UG_STD_CMD_CNTL_CONTROL_STATUS_SS (1<<13)
+ #define UG_STD_CMD_CNTL_CONTROL_STATUS_CSV (1<<12)
+ #define UG_STD_CMD_CNTL_CONTROL_STATUS_CCA (1<<11)
+ #define UG_STD_CMD_CNTL_CONTROL_STATUS_BCA (1<<10)
+ #define UG_STD_CMD_CNTL_CONTROL_STATUS_OCVCMDCOMP (1<<9)
+ #define UG_STD_CMD_CNTL_CONTROL_STATUS_OCVFAIL (1<<8)
+ #define UG_STD_CMD_CNTL_CONTROL_STATUS_INITCOMP (1<<7)
+ #define UG_STD_CMD_CNTL_CONTROL_STATUS_HIBERNATE (1<<6)
+ #define UG_STD_CMD_CNTL_CONTROL_STATUS_SNOOZE (1<<5)
+ #define UG_STD_CMD_CNTL_CONTROL_STATUS_SLEEP (1<<4)
+ #define UG_STD_CMD_CNTL_CONTROL_STATUS_LDMD (1<<3)
+ #define UG_STD_CMD_CNTL_CONTROL_STATUS_RUP_DIS (1<<2)
+ #define UG_STD_CMD_CNTL_CONTROL_STATUS_VOK (1<<1)
+ #define UG_STD_CMD_CNTL_CONTROL_STATUS_QEN (1<<0)
+ #define UG_STD_CMD_CNTL_DEVICE_TYPE (0x0001)
+ #define UG_STD_CMD_CNTL_FW_VERSION (0x0002)
+ #define UG_STD_CMD_CNTL_PREV_MACWRITE (0x0007)
+ #define UG_STD_CMD_CNTL_CHEM_ID (0x0008)
+ #define UG_STD_CMD_CNTL_OCV_CMD (0x000C) ///< [AT-PM] : Not implemented ; 10/11/2012
+ #define UG_STD_CMD_CNTL_BAT_INSERT (0x000D)
+ #define UG_STD_CMD_CNTL_BAT_REMOVE (0x000E)
+ #define UG_STD_CMD_CNTL_SET_HIBERNATE (0x0011)
+ #define UG_STD_CMD_CNTL_CLEAR_HIBERNATE (0x0012)
+ #define UG_STD_CMD_CNTL_SET_SLEEP_PLUS (0x0013)
+ #define UG_STD_CMD_CNTL_CLEAR_SLEEP_PLUS (0x0014)
+ #define UG_STD_CMD_CNTL_FACTORY_RESTORE (0x0015)
+ #define UG_STD_CMD_CNTL_ENABLE_DLOG (0x0018)
+ #define UG_STD_CMD_CNTL_DISABLE_DLOG (0x0019)
+ #define UG_STD_CMD_CNTL_DF_VERSION (0x001F)
+ #define UG_STD_CMD_CNTL_SEALED (0x0020)
+ #define UG_STD_CMD_CNTL_RESET (0x0041)
+#define UG_STD_CMD_AR (0x02)
+#define UG_STD_CMD_ARTTE (0x04)
+#define UG_STD_CMD_TEMP (0x06)
+#define UG_STD_CMD_VOLT (0x08)
+#define UG_STD_CMD_FLAGS (0x0A)
+ #define UG_STD_CMD_FLAGS_OTC (1<<15)
+ #define UG_STD_CMD_FLAGS_OTD (1<<14)
+ #define UG_STD_CMD_FLAGS_RSVD13 (1<<13)
+ #define UG_STD_CMD_FLAGS_RSVD12 (1<<12)
+ #define UG_STD_CMD_FLAGS_CHG_INH (1<<11)
+ #define UG_STD_CMD_FLAGS_XCHG (1<<10)
+ #define UG_STD_CMD_FLAGS_FC (1<<9)
+ #define UG_STD_CMD_FLAGS_CHG (1<<8)
+ #define UG_STD_CMD_FLAGS_RSVD7 (1<<7)
+ #define UG_STD_CMD_FLAGS_RSVD6 (1<<6)
+ #define UG_STD_CMD_FLAGS_OCV_GD (1<<5)
+ #define UG_STD_CMD_FLAGS_WAIT_ID (1<<4)
+ #define UG_STD_CMD_FLAGS_BAT_DET (1<<3)
+ #define UG_STD_CMD_FLAGS_SOC1 (1<<2)
+ #define UG_STD_CMD_FLAGS_SYSDOWN (1<<1)
+ #define UG_STD_CMD_FLAGS_DSG (1<<0)
+#define UG_STD_CMD_NAC (0x0C)
+#define UG_STD_CMD_FAC (0x0E)
+#define UG_STD_CMD_RM (0x10)
+#define UG_STD_CMD_FCC (0x12)
+#define UG_STD_CMD_AI (0x14)
+#define UG_STD_CMD_TTE (0x16)
+#define UG_STD_CMD_TTF (0x18)
+#define UG_STD_CMD_SI (0x1A)
+#define UG_STD_CMD_STTE (0x1C)
+#define UG_STD_CMD_MLI (0x1E)
+#define UG_STD_CMD_MLTTE (0x20)
+#define UG_STD_CMD_AE (0x22)
+#define UG_STD_CMD_AP (0x24)
+#define UG_STD_CMD_TTECP (0x26)
+#define UG_STD_CMD_SOH (0x28)
+ #define UG_STD_CMD_SOH_VALUE_MASK (0x00FF)
+ #define UG_STD_CMD_SOH_STATUS_MASK (0xFF00)
+ #define UG_STD_CMD_SOH_STATUS_NOT_VALID (0x0000)
+ #define UG_STD_CMD_SOH_STATUS_INSTANT_READY (0x0100)
+ #define UG_STD_CMD_SOH_STATUS_INITIAL_READY (0x0200)
+ #define UG_STD_CMD_SOH_STATUS_READY (0x0300)
+#define UG_STD_CMD_CC (0x2A)
+#define UG_STD_CMD_SOC (0x2C)
+#define UG_STD_CMD_NIC (0x2E) ///< [AT-PM] : Not implemented ; 10/11/2012
+#define UG_STD_CMD_ICR (0x30)
+#define UG_STD_CMD_DLI (0x32)
+#define UG_STD_CMD_DLB (0x34)
+#define UG_STD_CMD_ITEMP (0x36)
+#define UG_STD_CMD_OPCFG (0x3A)
+ #define UG_STD_CMD_OPCFG_RESCAP (1<<31)
+ #define UG_STD_CMD_OPCFG_BATG_OVR (1<<30)
+ #define UG_STD_CMD_OPCFG_INT_BERM (1<<29)
+ #define UG_STD_CMD_OPCFG_PFC_CFG1 (1<<28)
+ #define UG_STD_CMD_OPCFG_PFC_CFG0 (1<<27)
+ #define UG_STD_CMD_OPCFG_IWAKE (1<<26)
+ #define UG_STD_CMD_OPCFG_RSNS1 (1<<25)
+ #define UG_STD_CMD_OPCFG_RSNS0 (1<<24)
+ #define UG_STD_CMD_OPCFG_INT_FOCV (1<<23)
+ #define UG_STD_CMD_OPCFG_IDSELEN (1<<22)
+ #define UG_STD_CMD_OPCFG_SLEEP (1<<21)
+ #define UG_STD_CMD_OPCFG_RMFCC (1<<20)
+ #define UG_STD_CMD_OPCFG_SOCI_POL (1<<19)
+ #define UG_STD_CMD_OPCFG_BATG_POL (1<<18)
+ #define UG_STD_CMD_OPCFG_BATL_POL (1<<17)
+ #define UG_STD_CMD_OPCFG_TEMPS (1<<16)
+ #define UG_STD_CMD_OPCFG_WRTEMP (1<<15)
+ #define UG_STD_CMD_OPCFG_BIE (1<<14)
+ #define UG_STD_CMD_OPCFG_BL_INT (1<<13)
+ #define UG_STD_CMD_OPCFG_GNDSEL (1<<12)
+ #define UG_STD_CMD_OPCFG_FCE (1<<11)
+ #define UG_STD_CMD_OPCFG_DFWRINDBL (1<<10)
+ #define UG_STD_CMD_OPCFG_RFACTSTEP (1<<9)
+ #define UG_STD_CMD_OPCFG_INDFACRES (1<<8)
+ #define UG_STD_CMD_OPCFG_BATGSPUEN (1<<7)
+ #define UG_STD_CMD_OPCFG_BATGWPUEN (1<<6)
+ #define UG_STD_CMD_OPCFG_BATLSPUEN (1<<5)
+ #define UG_STD_CMD_OPCFG_BATLWSPUEN (1<<4)
+ #define UG_STD_CMD_OPCFG_RSVD3 (1<<3)
+ #define UG_STD_CMD_OPCFG_SLPWKCHG (1<<2)
+ #define UG_STD_CMD_OPCFG_DELTAVOPT1 (1<<1)
+ #define UG_STD_CMD_OPCFG_DELTAVOPT0 (1<<0)
+#define UG_EXT_CMD_DCAP (0x3C)
+
+/**
+ * @brief upiGG_FetchDataCommand
+ *
+ * Fetch bq27520 like command
+ *
+ * @para read set _UPI_TRUE_ to read data from API
+ * @para pMeasPara pointer of GG_MEAS_PARA_TYPE
+ * @return GGSTATUS
+ */
+EXPORTS GGSTATUS upiGG_FetchDataCommand(char *pObj, _upi_u8_ CommandCode, _upi_u16_ *pData);
+
+typedef struct GG_FETCH_DATA_PARA_ST {
+ _upi_s8_ FCSet;
+ _upi_s8_ FCClear;
+ _upi_u8_ Soc1Set;
+ _upi_u8_ Soc1Clear;
+ _upi_s8_ InitSI;
+ _upi_s16_ InitMaxLoadCurrent;
+ _upi_u16_ CCThreshold;
+ _upi_u32_ Opcfg;
+ _upi_u16_ Dcap;
+#if defined(uG31xx_OS_ANDROID)
+}__attribute__((aligned(4))) GG_FETCH_DATA_PARA_TYPE;
+#else ///< else of defined(uG31xx_OS_ANDROID)
+} GG_FETCH_DATA_PARA_TYPE;
+#endif ///< end of defined(uG31xx_OS_ANDROID)
+
+/**
+ * @brief upiGG_FetchDataParameter
+ *
+ * Set the parameter for bq27520 like command
+ *
+ * @para data parameters of GG_FETCH_DATA_PARA_TYPE
+ * @return GGSTATUS
+ */
+EXPORTS GGSTATUS upiGG_FetchDataParameter(char *pObj, GG_FETCH_DATA_PARA_TYPE data);
+
+#endif //endif ENABLE_BQ27520_SW_CMD
+
+typedef struct GG_FETCH_DEBUG_DATA_ST {
+ /// [AT-PM] : Driver version ; 01/30/2013
+ int versionMain;
+ int versionOtp;
+ int versionSub;
+
+ /// [AT-PM] : Capacity related ; 01/30/2013
+ int capStatus;
+ int capSelfHour;
+ int capSelfMin;
+ int capSelfSec;
+ int capSelfMilliSec;
+ int capTPTime;
+ int capDelta;
+ int capDsgCharge;
+ int capDsgChargeStart;
+ int capDsgChargeTime;
+ int capPreDsgCharge;
+ int capTableUpdateIdx;
+
+ /// [AT-PM] : Measurement related ; 01/30/2013
+ int measCodeBat1;
+ int measCodeCurrent;
+ int measCodeIT;
+ int measCodeET;
+ int measCharge;
+ int measCCOffset;
+ int measAdc1ConvertTime;
+ int measAdc1Gain;
+ int measAdc1Offset;
+ int measAdc2Gain;
+ int measAdc2Offset;
+ int measLastCounter;
+ int measLastTimeTick;
+ int measLastDeltaQ;
+
+#if defined(uG31xx_OS_ANDROID)
+ }__attribute__((aligned(4))) GG_FETCH_DEBUG_DATA_TYPE;
+#else ///< else of defined(uG31xx_OS_ANDROID)
+ } GG_FETCH_DEBUG_DATA_TYPE;
+#endif ///< end of defined(uG31xx_OS_ANDROID)
+
+/**
+ * @brief upiGG_FetchDebugData
+ *
+ * Fetch debug information data
+ *
+ * @para pObj address of memory buffer
+ * @para data address of GG_FETCH_CAP_DATA_TYPE
+ * @return _UPI_NULL_
+ */
+EXPORTS void upiGG_FetchDebugData(char *pObj, GG_FETCH_DEBUG_DATA_TYPE *data);
+
+/**
+ * @brief upiGG_DebugSwitch
+ *
+ * Enable/disable debug information to UART
+ *
+ * @para Enable set _UPI_TRUE_ to enable it
+ * @return NULL
+ */
+EXPORTS void upiGG_DebugSwitch(_upi_bool_ enable);
+
+EXPORTS void upiGG_CheckBackupFile(char *pObj);
+
+#endif ///< end of _UG31XXAPI_H_
+
+/// ===========================================
+/// End of uG31xx_API.h
+/// ===========================================
+
diff --git a/board/wmt/wmt_battery/gauge/upi/uG31xx_API_Backup.h b/board/wmt/wmt_battery/gauge/upi/uG31xx_API_Backup.h
new file mode 100755
index 0000000..bcc4c50
--- /dev/null
+++ b/board/wmt/wmt_battery/gauge/upi/uG31xx_API_Backup.h
@@ -0,0 +1,54 @@
+/**
+ * @filename uG31xx_API_Backup.h
+ *
+ * Header of uG31xx_API_Backup.cpp
+ *
+ * @author AllenTeng <allen_teng@upi-semi.com>
+ */
+
+#define BACKUP_BOOL_TRUE (1)
+#define BACKUP_BOOL_FALSE (0)
+
+#define BACKUP_FILE_PATH ("/sdcard/upi_gg")
+
+enum BACKUP_FILE_STS {
+ BACKUP_FILE_STS_CHECKING = 0,
+ BACKUP_FILE_STS_NOT_EXIST,
+ BACKUP_FILE_STS_EXIST,
+ BACKUP_FILE_STS_COMPARE,
+};
+
+typedef unsigned char _backup_bool_;
+typedef unsigned char _backup_u8_;
+
+typedef struct BackupDataST {
+
+ CapacityDataType *capData;
+ SystemDataType *sysData;
+ MeasDataType *measData;
+
+ _backup_bool_ icDataAvailable;
+ _backup_u8_ backupFileSts;
+
+ #if defined (uG31xx_OS_WINDOWS)
+ const wchar_t* backupFileName;
+ #elif defined(uG31xx_OS_ANDROID)
+ char *backupFileName;
+ #endif
+
+#if defined(uG31xx_OS_ANDROID)
+ } __attribute__ ((aligned(4))) BackupDataType;
+#else ///< else of defined(uG31xx_OS_ANDROID)
+ } BackupDataType;
+#endif ///< end of defined(uG31xx_OS_ANDROID)
+
+/**
+ * @brief UpiBackupData
+ *
+ * Backup data from IC to system routine
+ *
+ * @para data address of BackupDataType
+ * @return _UPI_NULL_
+ */
+extern void UpiBackupData(BackupDataType *data);
+
diff --git a/board/wmt/wmt_battery/gauge/upi/uG31xx_API_Capacity.h b/board/wmt/wmt_battery/gauge/upi/uG31xx_API_Capacity.h
new file mode 100755
index 0000000..aa888ca
--- /dev/null
+++ b/board/wmt/wmt_battery/gauge/upi/uG31xx_API_Capacity.h
@@ -0,0 +1,132 @@
+/**
+ * @filename uG31xx_API_Capacity.h
+ *
+ * Header of uG31xx capacity algorithm
+ *
+ * @author AllenTeng <allen_teng@upi-semi.com>
+ */
+
+typedef _upi_bool_ _cap_bool_;
+typedef unsigned char _cap_u8_;
+typedef signed char _cap_s8_;
+typedef unsigned short _cap_u16_;
+typedef signed short _cap_s16_;
+typedef unsigned long _cap_u32_;
+typedef signed long _cap_s32_;
+
+#define CAP_FC_RELEASE_RSOC (99)
+#define UG31XX_CAP_VERSION (36)
+#define CAP_ENCRIPT_TABLE_SIZE (TEMPERATURE_NUMS*C_RATE_NUMS*(SOV_NUMS - 1))
+
+typedef struct CapacityDataST {
+
+ /// [AT-PM] : Data from GGB file ; 01/25/2013
+ CELL_PARAMETER *ggbParameter;
+ CELL_TABLE *ggbTable;
+
+ /// [AT-PM] : Measurement data ; 01/25/2013
+ MeasDataType *measurement;
+
+ /// [AT-PM] : Data for table backup ; 01/31/2013
+ TableBackupType tableBackup[SOV_NUMS];
+ _cap_u8_ encriptTable[CAP_ENCRIPT_TABLE_SIZE];
+
+ /// [AT-PM] : Capacity information ; 01/25/2013
+ _cap_u16_ rm;
+ _cap_u16_ fcc;
+ _cap_u16_ fccBackup;
+ _cap_u8_ rsoc;
+
+ /// [AT-PM] : Capacity operation variables ; 01/25/2013
+ _cap_u32_ status;
+
+ _cap_u32_ selfDsgMilliSec;
+ _cap_u8_ selfDsgSec;
+ _cap_u8_ selfDsgMin;
+ _cap_u8_ selfDsgHour;
+ _cap_u8_ selfDsgResidual;
+
+ _cap_u8_ lastRsoc;
+
+ _cap_u32_ tpTime;
+
+ _cap_s32_ dsgCharge;
+ _cap_s32_ dsgChargeStart;
+ _cap_u32_ dsgChargeTime;
+ _cap_s32_ preDsgCharge;
+
+ _cap_u8_ tableUpdateIdx;
+ _cap_u32_ tableUpdateDisqTime;
+ _cap_u8_ tableUpdateDelayCnt;
+
+ _cap_s8_ parseRMResidual;
+
+ _cap_s16_ reverseCap;
+ _cap_u8_ avgCRate;
+
+ _cap_s16_ ccRecord[SOV_NUMS];
+#if defined(uG31xx_OS_ANDROID)
+ } __attribute__ ((aligned(4))) CapacityDataType;
+#else ///< else of defined(uG31xx_OS_ANDROID)
+ } CapacityDataType;
+#endif ///< end of defined(uG31xx_OS_ANDROID)
+
+/**
+ * @brief UpiInitCapacity
+ *
+ * Initial capacity algorithm
+ *
+ * @para data address of CapacityDataType
+ * @return _UPI_NULL_
+ */
+extern void UpiInitCapacity(CapacityDataType *data);
+
+/**
+ * @brief UpiReadCapacity
+ *
+ * Read capacity information
+ *
+ * @para data address of CapacityDataType
+ * @return _UPI_NULL_
+ */
+extern void UpiReadCapacity(CapacityDataType *data);
+
+/**
+ * @brief UpiTableCapacity
+ *
+ * Look up capacity from table
+ *
+ * @para data address of CapacityDataType
+ * @return _UPI_NULL_
+ */
+extern void UpiTableCapacity(CapacityDataType *data);
+
+/**
+ * @brief UpiInitDsgCharge
+ *
+ * Initialize data->dsgCharge value
+ *
+ * @para data address of CapacityDataType
+ * @return _UPI_NULL_
+ */
+extern void UpiInitDsgCharge(CapacityDataType *data);
+
+/**
+ * @brief UpiInitNacTable
+ *
+ * Initialize NAC table
+ *
+ * @para data address of CapacityDataType
+ * @return _UPI_NULL_
+ */
+extern void UpiInitNacTable(CapacityDataType *data);
+
+/**
+ * @brief UpiSaveNacTable
+ *
+ * Save NAC table to IC
+ *
+ * @para data address of CapacityDataType
+ * @return _UPI_NULL_
+ */
+extern void UpiSaveNacTable(CapacityDataType *data);
diff --git a/board/wmt/wmt_battery/gauge/upi/uG31xx_API_Measurement.c b/board/wmt/wmt_battery/gauge/upi/uG31xx_API_Measurement.c
new file mode 100755
index 0000000..903b8c1
--- /dev/null
+++ b/board/wmt/wmt_battery/gauge/upi/uG31xx_API_Measurement.c
@@ -0,0 +1,1482 @@
+/**
+ * @filename uG31xx_API_Measurement.cpp
+ *
+ * guG31xx measurement API
+ *
+ * @author AllenTeng <allen_teng@upi-semi.com>
+ */
+
+#include "stdafx.h" //windows need this??
+#include "uG31xx_API.h"
+
+//#define MEAS_FAKE_INT_TEMP
+#ifdef MEAS_FAKE_INT_TEMP
+ #define MEAS_FAKE_INT_TEMP_OFFSET (200)
+#endif ///< end of MEAS_FAKE_INT_TEMP
+
+typedef struct MeasDataInternalST {
+
+ MeasDataType *info;
+
+ _meas_s16_ adc1CodeT25V100;
+ _meas_s16_ adc1CodeT25V200;
+ _meas_s16_ adc1CodeT80V100;
+ _meas_s16_ adc1CodeT80V200;
+
+ _meas_s16_ adc2CodeT25V100;
+ _meas_s16_ adc2CodeT25V200;
+ _meas_s16_ adc2CodeT80V100;
+ _meas_s16_ adc2CodeT80V200;
+
+ _meas_u32_ currTime;
+
+ _meas_u16_ codeBat1;
+ _meas_s16_ codeCurrent;
+ _meas_u16_ codeIntTemperature;
+ _meas_u16_ codeExtTemperature;
+ _meas_s16_ codeCharge;
+ _meas_u16_ codeCounter;
+ _meas_s16_ ccOffset;
+
+#if defined(uG31xx_OS_ANDROID)
+ } __attribute__ ((aligned(4))) MeasDataInternalType;
+#else ///< else of defined(uG31xx_OS_ANDROID)
+ } MeasDataInternalType;
+#endif ///< end of defined(uG31xx_OS_ANDROID)
+
+typedef struct AdcDeltaCodeMappingST {
+ _meas_s32_ Adc1V100;
+ _meas_s32_ Adc1V200;
+ _meas_s32_ Adc2V100;
+ _meas_s32_ Adc2V200;
+#if defined(uG31xx_OS_ANDROID)
+}__attribute__((aligned(4))) AdcDeltaCodeMappingType;
+#else ///< else of defined(uG31xx_OS_ANDROID)
+} AdcDeltaCodeMappingType;
+#endif ///< end of defined(uG31xx_OS_ANDROID)
+
+static AdcDeltaCodeMappingType AdcDeltaCodeMapping[] =
+{
+ { -12800, -25600, 1536, 0 }, ///< Index = 0
+ { -12544, -25088, 1600, 128 }, ///< Index = 1
+ { -13056, -26112, 1472, -128 }, ///< Index = 2
+ { -12288, -24576, 1664, 256 }, ///< Index = 3
+ { -13312, -26624, 1408, -256 }, ///< Index = 4
+ { -12032, -24064, 1728, 384 }, ///< Index = 5
+ { -13568, -27136, 1344, -384 }, ///< Index = 6
+ { -11776, -23552, 1792, 512 }, ///< Index = 7
+ { -13824, -27648, 1280, -512 }, ///< Index = 8
+ { -11520, -23040, 1856, 640 }, ///< Index = 9
+ { -14080, -28160, 1216, -640 }, ///< Index = 10
+ { -11264, -22528, 1920, 768 }, ///< Index = 11
+ { -14336, -28672, 1152, -768 }, ///< Index = 12
+ { -11008, -22016, 1984, 896 }, ///< Index = 13
+ { -14592, -29184, 1088, -896 }, ///< Index = 14
+ { -10752, -21504, 2048, 1024 }, ///< Index = 15
+ { -14848, -29696, 1024, -1024 }, ///< Index = 16
+ { -10496, -20992, 2112, 1152 }, ///< Index = 17
+ { -15104, -30208, 960, -1152 }, ///< Index = 18
+ { -10240, -20480, 2176, 1280 }, ///< Index = 19
+ { -15360, -30720, 896, -1280 }, ///< Index = 20
+ { -9984, -19968, 2240, 1408 }, ///< Index = 21
+ { -15616, -31232, 832, -1408 }, ///< Index = 22
+ { -9728, -19456, 2304, 1536 }, ///< Index = 23
+ { -15872, -31744, 768, -1536 }, ///< Index = 24
+ { -9472, -18944, 2368, 1664 }, ///< Index = 25
+ { -16128, -32256, 704, -1664 }, ///< Index = 26
+ { -9216, -18432, 2432, 1792 }, ///< Index = 27
+ { -16384, -32768, 640, -1792 }, ///< Index = 28
+ { -8960, -17920, 2496, 1920 }, ///< Index = 29
+ { -16640, -33280, 576, -1920 }, ///< Index = 30
+ { 0, 0, 0, 0 }, ///< Index = 31
+};
+
+#define ADC_TEMPERATURE_GAIN_CONST (1000)
+
+#define ADC1_CODE_100MV_NEGATIVE (0xFF00)
+#define ADC1_CODE_200MV_NEGATIVE (0xFE00)
+#define ADC1_CP_CODE_25_100MV (12288)
+#define ADC1_CP_CODE_25_200MV (24576)
+#define ADC1_DELTA_CODE_25_100MV_SIGN_BIT (1<<8)
+#define ADC1_DELTA_CODE_25_200MV_SIGN_BIT (1<<9)
+#define ADC1_TEMPERATURE_GAIN_100MV (869600)
+#define ADC1_TEMPERATURE_GAIN_200MV (-695680)
+
+/**
+ * @brief ConvertAdc1Data
+ *
+ * Convert ADC1 data from OTP
+ *
+ * @para obj address of MeasDataInternalType
+ * @return _UPI_NULL_
+ */
+void ConvertAdc1Data(MeasDataInternalType *obj)
+{
+ _meas_u16_ tmp16;
+ _meas_s32_ tmp32;
+
+ /// [AT-PM] : Get code T25 100mV ; 01/23/2013
+ tmp16 = obj->info->otp->adc1DeltaCodeT25V100;
+ if(tmp16 & ADC1_DELTA_CODE_25_100MV_SIGN_BIT)
+ {
+ tmp16 = tmp16 & (~ADC1_DELTA_CODE_25_100MV_SIGN_BIT);
+ if(tmp16 != 0)
+ {
+ tmp16 = tmp16 + ADC1_CODE_100MV_NEGATIVE;
+ }
+ }
+ tmp16 = tmp16 + ADC1_CP_CODE_25_100MV;
+ tmp32 = (_meas_s32_)(_meas_s16_)tmp16;
+ tmp32 = tmp32 + AdcDeltaCodeMapping[obj->info->otp->indexAdc1V100T25].Adc1V100;
+ obj->adc1CodeT25V100 = (_meas_s16_)tmp32;
+ #ifdef UPI_UBOOT_DEBUG_MSG
+ printf("[ConvertAdc1Data] adc1CodeT25V100 = %d\n", tmp32);
+ #endif ///< end of UPI_UBOOT_DEBUG_MSG
+
+ /// [AT-PM] : Get code T25 200mV ; 01/23/2013
+ tmp16 = obj->info->otp->adc1DeltaCodeT25V200;
+ if(tmp16 & ADC1_DELTA_CODE_25_200MV_SIGN_BIT)
+ {
+ tmp16 = tmp16 & (~ADC1_DELTA_CODE_25_200MV_SIGN_BIT);
+ if(tmp16 != 0)
+ {
+ tmp16 = tmp16 + ADC1_CODE_200MV_NEGATIVE;
+ }
+ }
+ tmp16 = tmp16 + ADC1_CP_CODE_25_200MV;
+ tmp32 = (_meas_s32_)(_meas_s16_)tmp16;
+ tmp32 = tmp32 + AdcDeltaCodeMapping[obj->info->otp->indexAdc1V200T25].Adc1V200;
+ obj->adc1CodeT25V200 = (_meas_s16_)tmp32;
+ #ifdef UPI_UBOOT_DEBUG_MSG
+ printf("[ConvertAdc1Data] adc1CodeT25V200 = %d\n", tmp32);
+ #endif ///< end of UPI_UBOOT_DEBUG_MSG
+
+ tmp32 = (_meas_s32_)obj->info->otp->aveIT80;
+ tmp32 = (tmp32 - obj->info->otp->aveIT25)*ADC_TEMPERATURE_GAIN_CONST;
+
+ /// [AT-PM] : Get code T80 100mV ; 01/23/2013
+ obj->adc1CodeT80V100 = (_meas_s16_)(tmp32/ADC1_TEMPERATURE_GAIN_100MV + obj->adc1CodeT25V100);
+ #ifdef UPI_UBOOT_DEBUG_MSG
+ printf("[ConvertAdc1Data] adc1CodeT80V100 = %d\n", obj->adc1CodeT80V100);
+ #endif ///< end of UPI_UBOOT_DEBUG_MSG
+
+ /// [AT-PM] : Get code T80 200mV ; 01/23/2013
+ obj->adc1CodeT80V200 = (_meas_s16_)(tmp32/ADC1_TEMPERATURE_GAIN_200MV + obj->adc1CodeT25V200);
+ #ifdef UPI_UBOOT_DEBUG_MSG
+ printf("[ConvertAdc1Data] adc1CodeT80V200 = %d\n", obj->adc1CodeT80V200);
+ #endif ///< end of UPI_UBOOT_DEBUG_MSG
+}
+
+#define ADC2_CODE_100MV_NEGATIVE (0xFFC0)
+#define ADC2_CODE_200MV_NEGATIVE (0xFF80)
+#define ADC2_CP_CODE_25_100MV (3072)
+#define ADC2_CP_CODE_25_200MV (6144)
+#define ADC2_DELTA_CODE_25_100MV_SIGN_BIT (1<<6)
+#define ADC2_DELTA_CODE_25_200MV_SIGN_BIT (1<<7)
+#define ADC2_TEMPERATURE_GAIN_100MV (-149130)
+#define ADC2_TEMPERATURE_GAIN_200MV (-136937)
+
+/**
+ * @brief ConvertAdc2Data
+ *
+ * Convert ADC2 data from OTP
+ *
+ * @para obj address of MeasDataInternalType
+ * @return _UPI_NULL_
+ */
+void ConvertAdc2Data(MeasDataInternalType *obj)
+{
+ _meas_u16_ tmp16;
+ _meas_s32_ tmp32;
+
+ /// [AT-PM] : Get code T25 100mV ; 01/23/2013
+ tmp16 = obj->info->otp->adc2DeltaCodeT25V100;
+ if(tmp16 & ADC2_DELTA_CODE_25_100MV_SIGN_BIT)
+ {
+ tmp16 = tmp16 & (~ADC2_DELTA_CODE_25_100MV_SIGN_BIT);
+ tmp16 = tmp16 + ADC2_CODE_100MV_NEGATIVE;
+ }
+ tmp16 = tmp16 + ADC2_CP_CODE_25_100MV;
+ tmp32 = (_meas_s32_)(_meas_s16_)tmp16;
+ tmp32 = tmp32 + AdcDeltaCodeMapping[obj->info->otp->indexAdc2V100T25].Adc2V100;
+ obj->adc2CodeT25V100 = (_meas_s16_)tmp32;
+ #ifdef UPI_UBOOT_DEBUG_MSG
+ printf("[ConvertAdc2Data] adc2CodeT25V100 = %d\n", tmp32);
+ #endif ///< end of UPI_UBOOT_DEBUG_MSG
+
+ /// [AT-PM] : Get code T25 200mV ; 01/23/2013
+ tmp16 = obj->info->otp->adc2DeltaCodeT25V200;
+ if(tmp16 & ADC2_DELTA_CODE_25_200MV_SIGN_BIT)
+ {
+ tmp16 = tmp16 & (~ADC2_DELTA_CODE_25_200MV_SIGN_BIT);
+ tmp16 = tmp16 + ADC2_CODE_200MV_NEGATIVE;
+ }
+ tmp16 = tmp16 + ADC2_CP_CODE_25_200MV;
+ tmp32 = (_meas_s32_)(_meas_s16_)tmp16;
+ tmp32 = tmp32 + AdcDeltaCodeMapping[obj->info->otp->indexAdc2V200T25].Adc2V200;
+ obj->adc2CodeT25V200 = (_meas_s16_)tmp32;
+ #ifdef UPI_UBOOT_DEBUG_MSG
+ printf("[ConvertAdc2Data] adc2CodeT25V200 = %d\n", tmp32);
+ #endif ///< end of UPI_UBOOT_DEBUG_MSG
+
+ tmp32 = (_meas_s32_)obj->info->otp->aveIT80;
+ tmp32 = (tmp32 - obj->info->otp->aveIT25)*ADC_TEMPERATURE_GAIN_CONST;
+
+ /// [AT-PM] : Get code T80 100mV ; 01/23/2013
+ obj->adc2CodeT80V100 = (_meas_s16_)(tmp32/ADC2_TEMPERATURE_GAIN_100MV + obj->adc2CodeT25V100);
+ #ifdef UPI_UBOOT_DEBUG_MSG
+ printf("[ConvertAdc2Data] adc2CodeT80V100 = %d\n", obj->adc2CodeT80V100);
+ #endif ///< end of UPI_UBOOT_DEBUG_MSG
+
+ /// [AT-PM] : Get code T80 200mV ; 01/23/2013
+ obj->adc2CodeT80V200 = (_meas_s16_)(tmp32/ADC2_TEMPERATURE_GAIN_200MV + obj->adc2CodeT25V200);
+ #ifdef UPI_UBOOT_DEBUG_MSG
+ printf("[ConvertAdc2Data] adc2CodeT80V200 = %d\n", obj->adc2CodeT80V200);
+ #endif ///< end of UPI_UBOOT_DEBUG_MSG
+}
+
+/**
+ * @brief CalAdc1Factors
+ *
+ * Calculate ADC1 gain slope and factor B
+ * Calculate ADC1 offset slope and factor O
+ *
+ * @para obj address of MeasDataInternalType
+ * @return _UPI_NULL_
+ */
+void CalAdc1Factors(MeasDataInternalType *obj)
+{
+ _meas_s32_ delta25;
+ _meas_s32_ delta80;
+ _meas_s64_ tmp64;
+
+ /// [AT-PM] : Calculate gain slope and factor B ; 01/23/2013
+ delta25 = (_meas_s32_)obj->adc1CodeT25V200;
+ delta25 = delta25 - obj->adc1CodeT25V100;
+ delta80 = (_meas_s32_)obj->adc1CodeT80V200;
+ delta80 = delta80 - obj->adc1CodeT80V100;
+
+ obj->info->adc1GainSlope = delta80 - delta25;
+ obj->info->adc1GainFactorB = delta25*(obj->info->otp->aveIT80) - delta80*(obj->info->otp->aveIT25);
+ #ifdef UPI_UBOOT_DEBUG_MSG
+ printf("[CalAdc1Factors] adc1GainSlope / adc1GainFactorB = %d / %d\n", obj->info->adc1GainSlope, obj->info->adc1GainFactorB);
+ #endif ///< end of UPI_UBOOT_DEBUG_MSG
+
+ /// [AT-PM] : Calculate offset slope and factor O ; 01/23/2013
+ delta25 = (_meas_s32_)obj->adc1CodeT25V100;
+ delta25 = delta25*2 - obj->adc1CodeT25V200;
+ delta80 = (_meas_s32_)obj->adc1CodeT80V100;
+ delta80 = delta80*2 - obj->adc1CodeT80V200;
+
+ obj->info->adc1OffsetSlope = delta80 - delta25;
+ obj->info->adc1OffsetFactorO = delta25*(obj->info->otp->aveIT80) - delta80*(obj->info->otp->aveIT25);
+ #ifdef UPI_UBOOT_DEBUG_MSG
+ printf("[CalAdc1Factors] adc1OffsetSlope / adc1OffsetFactorO = %d / %d\n", obj->info->adc1OffsetSlope, obj->info->adc1OffsetFactorO);
+ #endif ///< end of UPI_UBOOT_DEBUG_MSG
+
+ /// [AT-PM] : Calculate current ADC1 gain ; 01/23/2013
+ tmp64 = (_meas_s64_)obj->info->adc1GainSlope;
+ tmp64 = tmp64*(obj->codeIntTemperature) + obj->info->adc1GainFactorB;
+ obj->info->adc1Gain = (_meas_s32_)tmp64;
+
+ /// [AT-PM] : Calculate current ADC1 offset ; 01/23/2013
+ tmp64 = (_meas_s64_)obj->info->adc1OffsetSlope;
+ tmp64 = tmp64*(obj->codeIntTemperature) + obj->info->adc1OffsetFactorO;
+ obj->info->adc1Offset = (_meas_s32_)tmp64;
+ #ifdef UPI_UBOOT_DEBUG_MSG
+ printf("[CalAdc1Factors] adc1Gain / adc1Offset = %d / %d\n", obj->info->adc1Gain, obj->info->adc1Offset);
+ #endif ///< end of UPI_UBOOT_DEBUG_MSG
+}
+
+/**
+ * @brief CalAdc2Factors
+ *
+ * Calculate ADC2 gain slope and factor B
+ * Calculate ADC2 offset slope and factor O
+ *
+ * @para obj address of MeasDataInternalType
+ * @return _UPI_NULL_
+ */
+void CalAdc2Factors(MeasDataInternalType *obj)
+{
+ _meas_s32_ delta25;
+ _meas_s32_ delta80;
+ _meas_s64_ tmp64;
+
+ /// [AT-PM] : Calculate gain slope and factor B ; 01/23/2013
+ delta25 = (_meas_s32_)obj->adc2CodeT25V200;
+ delta25 = delta25 - obj->adc2CodeT25V100;
+ delta80 = (_meas_s32_)obj->adc2CodeT80V200;
+ delta80 = delta80 - obj->adc2CodeT80V100;
+
+ obj->info->adc2GainSlope = delta80 - delta25;
+ obj->info->adc2GainFactorB = delta25*(obj->info->otp->aveIT80) - delta80*(obj->info->otp->aveIT25);
+ #ifdef UPI_UBOOT_DEBUG_MSG
+ printf("[CalAdc2Factors] adc2GainSlope / adc2GainFactorB = %d / %d\n", obj->info->adc2GainSlope, obj->info->adc2GainFactorB);
+ #endif ///< end of UPI_UBOOT_DEBUG_MSG
+
+ /// [AT-PM] : Calculate offset slope and factor O ; 01/23/2013
+ delta25 = (_meas_s32_)obj->adc2CodeT25V100;
+ delta25 = delta25*2 - obj->adc2CodeT25V200;
+ delta80 = (_meas_s32_)obj->adc2CodeT80V100;
+ delta80 = delta80*2 - obj->adc2CodeT80V200;
+
+ obj->info->adc2OffsetSlope = delta80 - delta25;
+ obj->info->adc2OffsetFactorO = delta25*(obj->info->otp->aveIT80) - delta80*(obj->info->otp->aveIT25);
+ #ifdef UPI_UBOOT_DEBUG_MSG
+ printf("[CalAdc2Factors] adc2OffsetSlope / adc2OffsetFactorO = %d / %d\n", obj->info->adc2OffsetSlope, obj->info->adc2OffsetFactorO);
+ #endif ///< end of UPI_UBOOT_DEBUG_MSG
+
+ /// [AT-PM] : Calculate current ADC1 gain ; 01/23/2013
+ tmp64 = (_meas_s64_)obj->info->adc2GainSlope;
+ tmp64 = tmp64*(obj->codeIntTemperature) + obj->info->adc2GainFactorB;
+ obj->info->adc2Gain = (_meas_s32_)tmp64;
+
+ /// [AT-PM] : Calculate current ADC1 offset ; 01/23/2013
+ tmp64 = (_meas_s64_)obj->info->adc2OffsetSlope;
+ tmp64 = tmp64*(obj->codeIntTemperature) + obj->info->adc2OffsetFactorO;
+ obj->info->adc2Offset = (_meas_s32_)tmp64;
+ #ifdef UPI_UBOOT_DEBUG_MSG
+ printf("[CalAdc2Factors] adc2Gain / adc2Offset = %d / %d\n", obj->info->adc2Gain, obj->info->adc2Offset);
+ #endif ///< end of UPI_UBOOT_DEBUG_MSG
+}
+
+#define ADC1_IDEAL_CODE_100MV (614)
+#define ADC1_IDEAL_CODE_200MV (1229)
+#define ADC1_IDEAL_CODE_DELTA (ADC1_IDEAL_CODE_200MV - ADC1_IDEAL_CODE_100MV)
+
+/**
+ * @brief CalibrateAdc1Code
+ *
+ * Calibrate ADC1 code
+ *
+ * @para obj address of MeasDataInternalType
+ * @para code ADC1 code to be calibrated
+ * @return calibrated code
+ */
+_meas_s32_ CalibrateAdc1Code(MeasDataInternalType *obj, _meas_s32_ code)
+{
+ _meas_s64_ tmp64;
+ _meas_s32_ tmp32;
+ _meas_s32_ deltaIT;
+ _meas_s32_ gain;
+ _meas_s32_ offset;
+
+ deltaIT = (_meas_s32_)obj->info->otp->aveIT80;
+ deltaIT = deltaIT - obj->info->otp->aveIT25;
+
+ /// [AT-PM] : Pre-operation to avoid 64-bit division ; 01/23/2013
+ gain = obj->info->adc1Gain;
+ offset = obj->info->adc1Offset;
+ while(1)
+ {
+ tmp64 = (_meas_s64_)code;
+ tmp64 = tmp64*deltaIT - offset;
+ tmp64 = tmp64*ADC1_IDEAL_CODE_DELTA;
+ if((tmp64 < 2147483647) && (tmp64 > -2147483647))
+ {
+ break;
+ }
+ code = code/2;
+ deltaIT = deltaIT/2;
+ gain = gain/4;
+ offset = offset/4;
+ }
+
+ tmp32 = (_meas_s32_)tmp64;
+ tmp32 = tmp32/gain;
+ #ifdef UPI_UBOOT_DEBUG_MSG
+ printf("[CalibrateAdc1Code] %d -> %d\n", code, tmp32);
+ #endif ///< end of UPI_UBOOT_DEBUG_MSG
+ return (tmp32);
+}
+
+#define ADC2_IDEAL_CODE_100MV (ADC2_CP_CODE_25_100MV)
+#define ADC2_IDEAL_CODE_200MV (ADC2_CP_CODE_25_200MV)
+#define ADC2_IDEAL_CODE_DELTA (ADC2_IDEAL_CODE_200MV - ADC2_IDEAL_CODE_100MV)
+
+/**
+ * @brief CalibrateAdc2Code
+ *
+ * Calibrate ADC2 code
+ *
+ * @para obj address of MeasDataInternalType
+ * @para code ADC2 code to be calibrated
+ * @return calibrated code
+ */
+_meas_s32_ CalibrateAdc2Code(MeasDataInternalType *obj, _meas_s32_ code)
+{
+ _meas_s64_ tmp64;
+ _meas_s32_ tmp32;
+ _meas_s32_ deltaIT;
+ _meas_s32_ gain;
+ _meas_s32_ offset;
+
+ deltaIT = (_meas_s32_)obj->info->otp->aveIT80;
+ deltaIT = deltaIT - obj->info->otp->aveIT25;
+
+ /// [AT-PM] : Pre-operation to avoid 64-bit division ; 01/23/2013
+ gain = obj->info->adc2Gain;
+ offset = obj->info->adc2Offset;
+ while(1)
+ {
+ tmp64 = (_meas_s64_)code;
+ tmp64 = tmp64*deltaIT - offset;
+ tmp64 = tmp64*ADC2_IDEAL_CODE_DELTA;
+ if((tmp64 < 2147483647) && (tmp64 > -2147483647))
+ {
+ break;
+ }
+ code = code/2;
+ deltaIT = deltaIT/2;
+ gain = gain/4;
+ offset = offset/4;
+ }
+
+ tmp32 = (_meas_s32_)tmp64;
+ tmp32 = tmp32/gain;
+ #ifdef UPI_UBOOT_DEBUG_MSG
+ printf("[CalibrateAdc2Code] %d -> %d\n", code, tmp32);
+ #endif ///< end of UPI_UBOOT_DEBUG_MSG
+ return (tmp32);
+}
+
+#define IT_IDEAL_CODE_25 (24310)
+#define IT_IDEAL_CODE_80 (28612)
+#define IT_IDEAL_CODE_DELTA (IT_IDEAL_CODE_80 - IT_IDEAL_CODE_25)
+
+/**
+ * @brief CalibrateITCode
+ *
+ * Calibrate internal temperature code
+ *
+ * @para obj address of MeasDataInternalType
+ * @para itCode raw IT code
+ * @return calibrated IT code
+ */
+_meas_u16_ CalibrateITCode(MeasDataInternalType *obj, _meas_u16_ itCode)
+{
+ _meas_s32_ tmp32;
+
+ tmp32 = (_meas_s32_)itCode;
+ tmp32 = tmp32 - obj->info->otp->aveIT25;
+ tmp32 = tmp32*IT_IDEAL_CODE_DELTA;
+ tmp32 = tmp32/(obj->info->otp->aveIT80 - obj->info->otp->aveIT25);
+ tmp32 = tmp32 + IT_IDEAL_CODE_25;
+ return ((_meas_u16_)tmp32);
+}
+
+#define NORMAL_REGISTER (NORMAL)
+
+/**
+ * @brief CalibrateChargeCode
+ *
+ * Calibrate charge code
+ *
+ * @para obj address of MeasDataInternalType
+ * @return _UPI_NULL_
+ */
+void CalibrateChargeCode(MeasDataInternalType *obj)
+{
+ _meas_s32_ tmp32;
+ _meas_s64_ tmp64;
+ _meas_s32_ gain;
+ _meas_s32_ offset;
+
+ UG31_LOGI("[%s]: Raw Code = %d\n", __func__, obj->codeCharge);
+
+ /// [AT-PM] : Calibrate charge code ; 01/23/2013
+ obj->info->codeCharge = CalibrateAdc1Code(obj, ((_meas_s32_)obj->codeCharge)*2);
+
+ /// [AT-PM] : Calculate coulomb counter offset ; 01/23/2013
+ tmp32 = obj->info->adc1Offset/(obj->info->otp->aveIT80 - obj->info->otp->aveIT25)*(-1);
+ obj->info->ccOffset = (_meas_s16_)tmp32;
+
+ UG31_LOGI("[%s]: Calibrated Code = %d, Offset = %d\n", __func__, obj->info->codeCharge, obj->info->ccOffset);
+
+ /// [AT-PM] : Set coulomb counter offset ; 01/27/2013
+ API_I2C_Write(NORMAL_REGISTER,
+ UG31XX_I2C_HIGH_SPEED_MODE,
+ UG31XX_I2C_TEM_BITS_MODE,
+ REG_ADC1_OFFSET_LOW,
+ REG_ADC1_OFFSET_HIGH - REG_ADC1_OFFSET_LOW + 1,
+ (unsigned char *)&obj->info->ccOffset);
+
+ /// [AT-PM] : Remove the offset in calibrated charge code ; 01/23/2013
+ gain = obj->info->adc1Gain;
+ offset = obj->info->adc1Offset;
+ while(1)
+ {
+ tmp64 = (_meas_s64_)offset;
+ tmp64 = tmp64*ADC1_IDEAL_CODE_DELTA;
+ if((tmp64 < 2147483647) && (tmp64 > -2147483647))
+ {
+ break;
+ }
+ gain = gain/2;
+ offset = offset/2;
+ }
+ tmp32 = (_meas_s32_)tmp64;
+ tmp32 = tmp32/gain;
+ UG31_LOGI("[%s]: Compensation = %d x %d / %d\n", __func__,
+ obj->info->adc1Offset, ADC1_IDEAL_CODE_DELTA, obj->info->adc1Gain);
+ obj->info->codeCharge = obj->info->codeCharge + tmp32;
+ UG31_LOGI("[%s]: Charge = %d\n", __func__, obj->info->codeCharge);
+}
+
+#define ADC2_VOLTAGE_100MV (3000) ///< [AT-PM] : Unit in mV ; 01/25/2013
+#define ADC2_VOLTAGE_200MV (4000) ///< [AT-PM] : Unit in mV ; 01/25/2013
+#define ADC2_VOLTAGE_DELTA (ADC2_VOLTAGE_200MV - ADC2_VOLTAGE_100MV)
+
+/**
+ * @brief ConvertBat1
+ *
+ * Convert code of BAT1
+ *
+ * @para obj address of MeasDataInternalType
+ * @return _UPI_NULL_
+ */
+void ConvertBat1(MeasDataInternalType *obj)
+{
+ _meas_s32_ tmp32;
+
+ /// [AT-PM] : Convert from calibrated ADC code ; 01/25/2013
+ tmp32 = (_meas_s32_)obj->info->codeBat1;
+ tmp32 = tmp32 - ADC2_IDEAL_CODE_100MV;
+ tmp32 = tmp32*ADC2_VOLTAGE_DELTA/ADC2_IDEAL_CODE_DELTA;
+ tmp32 = tmp32 + ADC2_VOLTAGE_100MV;
+
+ /// [AT-PM] : Apply board factor ; 01/25/2013
+ tmp32 = tmp32 - BOARD_FACTOR_VOLTAGE_OFFSET;
+ tmp32 = tmp32*BOARD_FACTOR_CONST/BOARD_FACTOR_VOLTAGE_GAIN;
+
+ /// [AT-PM] : Apply calibration parameter ; 01/25/2013
+ tmp32 = tmp32 - obj->info->sysData->ggbParameter->adc2_offset;
+ tmp32 = tmp32*CALIBRATION_FACTOR_CONST/obj->info->sysData->ggbParameter->adc2_gain;
+ obj->info->bat1Voltage = (_meas_u16_)tmp32;
+}
+
+#define ADC1_VOLTAGE_100MV (-5000) ///< [AT-PM] : Unit in uV ; 01/25/2013
+#define ADC1_VOLTAGE_200MV (-10000) ///< [AT-PM] : Unit in uV ; 01/25/2013
+#define ADC1_VOLTAGE_DELTA (ADC1_VOLTAGE_200MV - ADC1_VOLTAGE_100MV)
+/**
+ * @brief ConvertCurrent
+ *
+ * Convert code of Current
+ *
+ * @para obj address of MeasDataInternalType
+ * @return _UPI_NULL_
+ */
+void ConvertCurrent(MeasDataInternalType *obj)
+{
+ _meas_s32_ tmp32;
+
+ /// [AT-PM] : Convert from calibrated ADC code ; 01/25/2013
+ tmp32 = (_meas_s32_)obj->info->codeCurrent;
+ tmp32 = tmp32 - ADC1_IDEAL_CODE_100MV;
+ tmp32 = tmp32*ADC1_VOLTAGE_DELTA/ADC1_IDEAL_CODE_DELTA;
+ tmp32 = tmp32 + ADC1_VOLTAGE_100MV;
+ tmp32 = tmp32/obj->info->sysData->ggbParameter->rSense;
+
+ /// [AT-PM] : Apply board factor ; 01/25/2013
+ tmp32 = tmp32 - BOARD_FACTOR_CURR_OFFSET;
+ tmp32 = tmp32*BOARD_FACTOR_CONST/BOARD_FACTOR_CURR_GAIN;
+
+ /// [AT-PM] : Apply calibration factor ; 01/25/2013
+ tmp32 = tmp32 - obj->info->sysData->ggbParameter->adc1_pos_offset;
+ if(tmp32 > 0)
+ {
+ tmp32 = tmp32*CALIBRATION_FACTOR_CONST/obj->info->sysData->ggbParameter->adc1_pgain;
+ }
+ else
+ {
+ tmp32 = tmp32*CALIBRATION_FACTOR_CONST/obj->info->sysData->ggbParameter->adc1_ngain;
+ }
+ obj->info->curr = (_meas_s16_)tmp32;
+}
+
+#define AMBIENT_TEMPERATURE_IN_FT (220)
+#define IT_CONST (100)
+#define IT_GAIN (392)
+#define IT_OFFSET (11172)
+
+static _meas_s16_ FTAmbientMappingTable[] =
+{
+ AMBIENT_TEMPERATURE_IN_FT, ///< Index = 0
+ AMBIENT_TEMPERATURE_IN_FT + 10, ///< Index = 1
+ AMBIENT_TEMPERATURE_IN_FT - 10, ///< Index = 2
+ AMBIENT_TEMPERATURE_IN_FT + 20, ///< Index = 3
+ AMBIENT_TEMPERATURE_IN_FT - 20, ///< Index = 4
+ AMBIENT_TEMPERATURE_IN_FT + 30, ///< Index = 5
+ AMBIENT_TEMPERATURE_IN_FT - 30, ///< Index = 6
+ AMBIENT_TEMPERATURE_IN_FT + 40, ///< Index = 7
+ AMBIENT_TEMPERATURE_IN_FT - 40, ///< Index = 8
+ AMBIENT_TEMPERATURE_IN_FT + 50, ///< Index = 9
+ AMBIENT_TEMPERATURE_IN_FT - 50, ///< Index = 10
+ AMBIENT_TEMPERATURE_IN_FT + 60, ///< Index = 11
+ AMBIENT_TEMPERATURE_IN_FT - 60, ///< Index = 12
+ AMBIENT_TEMPERATURE_IN_FT + 70, ///< Index = 13
+ AMBIENT_TEMPERATURE_IN_FT - 70, ///< Index = 14
+ AMBIENT_TEMPERATURE_IN_FT, ///< Index = 15
+};
+
+/**
+ * @brief ConvertIntTemperature
+ *
+ * Convert code of internal temperature
+ *
+ * @para obj address of MeasDataInternalType
+ * @return _UPI_NULL_
+ */
+void ConvertIntTemperature(MeasDataInternalType *obj)
+{
+ _meas_s32_ tmp32;
+ _meas_s32_ ftIT;
+
+ /// [AT-PM] : Convert from calibrated ADC code ; 01/25/2013
+ tmp32 = (_meas_s32_)obj->info->codeIntTemperature;
+ tmp32 = tmp32/2;
+ tmp32 = tmp32 - IT_OFFSET;
+ tmp32 = tmp32*IT_CONST/IT_GAIN;
+
+ /// [AT-PM] : Apply FT information ; 01/25/2013
+ ftIT = (_meas_s32_)CalibrateITCode(obj, obj->info->otp->ftIT);
+ ftIT = ftIT/2;
+ ftIT = ftIT - IT_OFFSET;
+ ftIT = ftIT*IT_CONST/IT_GAIN;
+ tmp32 = tmp32 - (ftIT - FTAmbientMappingTable[obj->info->otp->deltaET]);
+
+ /// [AT-PM] : Apply board factor ; 01/25/2013
+ tmp32 = tmp32 - BOARD_FACTOR_INTT_OFFSET;
+
+ /// [AT-PM] : Apply calibration factor ; 01/25/2013
+ tmp32 = tmp32 - obj->info->sysData->ggbParameter->adc_d5;
+ obj->info->intTemperature = (_meas_s16_)tmp32;
+}
+
+static _meas_s16_ ExtTemperatureTable[] = {
+ -100, ///< Index = 0
+ -50, ///< Index = 1
+ 0, ///< Index = 2
+ 50, ///< Index = 3
+ 100, ///< Index = 4
+ 150, ///< Index = 5
+ 200, ///< Index = 6
+ 250, ///< Index = 7
+ 300, ///< Index = 8
+ 350, ///< Index = 9
+ 400, ///< Index = 10
+ 450, ///< Index = 11
+ 500, ///< Index = 12
+ 550, ///< Index = 13
+ 600, ///< Index = 14
+ 650, ///< Index = 15
+ 700, ///< Index = 16
+ 750, ///< Index = 17
+ 800, ///< Index = 18
+};
+
+/**
+ * @brief ConvertExtTemperature
+ *
+ * Convert code of external temperature
+ *
+ * @para obj address of MeasDataInternalType
+ * @return _UPI_NULL_
+ */
+void ConvertExtTemperature(MeasDataInternalType *obj)
+{
+ _meas_u8_ idx;
+ _meas_s32_ tmp32;
+
+ idx = 0;
+ while(idx < ET_NUMS)
+ {
+ if(obj->info->codeExtTemperature >= obj->info->sysData->ggbParameter->rtTable[idx])
+ {
+ break;
+ }
+ idx = idx + 1;
+ }
+
+ if(idx == 0)
+ {
+ /// [AT-PM] : Minimum measurable temperature ; 01/25/2013
+ tmp32 = (_meas_s32_)ExtTemperatureTable[0];
+ }
+ else if(idx == ET_NUMS)
+ {
+ /// [AT-PM] : Maximum measurable temperature ; 01/25/2013
+ tmp32 = (_meas_s32_)ExtTemperatureTable[ET_NUMS - 1];
+ }
+ else
+ {
+ /// [AT-PM] : Calculate external temperature ; 01/25/2013
+ tmp32 = (_meas_s32_)obj->info->codeExtTemperature;
+ tmp32 = tmp32 - obj->info->sysData->ggbParameter->rtTable[idx];
+ tmp32 = tmp32*(ExtTemperatureTable[idx - 1] - ExtTemperatureTable[idx]);
+ tmp32 = tmp32/(obj->info->sysData->ggbParameter->rtTable[idx - 1] - obj->info->sysData->ggbParameter->rtTable[idx]);
+ tmp32 = tmp32 + ExtTemperatureTable[idx];
+ }
+
+ /// [AT-PM] : Apply board factor ; 01/25/2013
+ tmp32 = tmp32 - BOARD_FACTOR_EXTT_OFFSET;
+
+ /// [AT-PM] : Apply calibration factor ; 01/25/2013
+ tmp32 = tmp32 - obj->info->sysData->ggbParameter->adc_d4;
+ obj->info->extTemperature = (_meas_s16_)tmp32;
+}
+
+#define TIME_DEFAULT_ADC1_CONVERT_TIME (1253)
+#define MINIMUM_ADC1_COUNTER_FOR_CONVERT_TIME (10)
+#define MAXIMUM_ADC1_CONVERSION_TIME (0xf8)
+#define MINIMUM_ADC1_CONVERSION_TIME (0x08)
+
+/**
+ * @brief CalculateAdc1ConvertTime
+ *
+ * Calculate ADC1 conversion time
+ *
+ * @para obj address of MeasDataInternalType
+ * @return _UPI_NULL_
+ */
+void CalculateAdc1ConvertTime(MeasDataInternalType *obj)
+{
+ _meas_u32_ tmp32;
+
+ UG31_LOGI("[%s]: Initial conversion time = %d\n", __func__, obj->info->adc1ConvertTime);
+
+ /// [AT-PM] : First time to calculate ADC1 conversion time ; 01/25/2013
+ if(obj->info->adc1ConvertTime == 0)
+ {
+ obj->info->adc1ConvertTime = TIME_DEFAULT_ADC1_CONVERT_TIME;
+ obj->info->lastCounter = obj->codeCounter;
+ return;
+ }
+
+ #ifdef uG31xx_BOOT_LOADER
+ /// [AT-PM] : In bootloader, ADC1 converstion time is not calculated ; 02/12/2013
+ return;
+ #endif ///< end of uG31xx_BOOT_LOADER
+
+ /// [AT-PM] : Check counter overflow or time overflow; 01/25/2013
+ if((obj->codeCounter <= obj->info->lastCounter) || (obj->info->deltaTime == 0))
+ {
+ obj->info->lastCounter = obj->codeCounter;
+ return;
+ }
+
+ /// [AT-PM] : Limit the minimum counter ; 02/11/2013
+ tmp32 = (_meas_u32_)obj->codeCounter;
+ tmp32 = tmp32 - obj->info->lastCounter;
+ if(tmp32 < MINIMUM_ADC1_COUNTER_FOR_CONVERT_TIME)
+ {
+ obj->info->lastCounter = obj->codeCounter;
+ return;
+ }
+
+ /// [AT-PM] : Average ADC1 conversion time ; 01/25/2013
+ tmp32 = obj->info->deltaTime;
+ tmp32 = tmp32*TIME_CONVERT_TIME_TO_MSEC/(obj->codeCounter - obj->info->lastCounter);
+ tmp32 = tmp32 + obj->info->adc1ConvertTime;
+ tmp32 = tmp32/2;
+
+ /// [AT-PM] : Check conversion time is valid or not ; 02/13/2013
+ if((tmp32 > (MAXIMUM_ADC1_CONVERSION_TIME*TIME_CONVERT_TIME_TO_MSEC)) ||
+ (tmp32 < (MINIMUM_ADC1_CONVERSION_TIME*TIME_CONVERT_TIME_TO_MSEC)))
+ {
+ UG31_LOGI("[%s]: ***************************************************************************************\n", __func__);
+ UG31_LOGI("[%s]: ***************************************************************************************\n", __func__);
+ UG31_LOGI("[%s]: #### ##### ## ## #### ##### ## ## #### ## ###### ###### ## ## ######\n", __func__);
+ UG31_LOGI("[%s]: ## ## ## ## ### ## ## ## ## ## ### ### ## ## ## ###### ## ### ### ##\n", __func__);
+ UG31_LOGI("[%s]: ###### ##### ###### ## ## ##### ####### ###### ## ## ## ####### ###\n", __func__);
+ UG31_LOGI("[%s]: ## ## ## ## ## ### ## ## ## ## ## ## ## ## ## ## ## ## ## ##\n", __func__);
+ UG31_LOGI("[%s]: ## ## ##### ## ## #### ## ## ## ## ## ## ###### ## ###### ## ## ######\n", __func__);
+ UG31_LOGI("[%s]:\n", __func__);
+ UG31_LOGI("[%s]: Previous Time Tag = %d\n", __func__, obj->info->lastTimeTick - obj->info->deltaTime);
+ UG31_LOGI("[%s]: Current Time Tag = %d\n", __func__, obj->info->lastTimeTick);
+ UG31_LOGI("[%s]: Delta Time = %d\n", __func__, obj->info->deltaTime);
+ UG31_LOGI("[%s]: Previous ADC Count = %d\n", __func__, obj->info->lastCounter);
+ UG31_LOGI("[%s]: Current ADC Count = %d\n", __func__, obj->codeCounter);
+ UG31_LOGI("[%s]: Delta ADC Count = %d\n", __func__, obj->codeCounter - obj->info->lastCounter);
+ UG31_LOGI("[%s]: Old ADC Convert Time = %d\n", __func__, obj->info->adc1ConvertTime);
+ UG31_LOGI("[%s]: New ADC Convert Time = %d\n", __func__, tmp32);
+ UG31_LOGI("[%s]: ***************************************************************************************\n", __func__);
+ UG31_LOGI("[%s]: ***************************************************************************************\n", __func__);
+ tmp32 = (_meas_u32_)obj->info->adc1ConvertTime;
+ }
+ UG31_LOGI("[%s]: Conversion Time = %d ((%d - %d)/%d)\n", __func__,
+ tmp32, obj->codeCounter, obj->info->lastCounter, obj->info->deltaTime);
+ obj->info->adc1ConvertTime = (_meas_u16_)tmp32;
+ obj->info->lastCounter = obj->codeCounter;
+}
+
+#define TIME_MSEC_TO_SEC (1000)
+#define TIME_SEC_TO_HOUR (3600)
+#define COULOMB_COUNTER_LSB (4096)
+
+/**
+ * @brief ConvertCharge
+ *
+ * Convert code of charge
+ *
+ * @para obj address of MeasDataInternalType
+ * @return _UPI_NULL_
+ */
+void ConvertCharge(MeasDataInternalType *obj)
+{
+ _meas_s16_ tmp16;
+ _meas_s32_ tmp32;
+ _meas_s64_ tmp64;
+
+ /// [AT-PM] : Convert from calibrated ADC code ; 01/25/2013
+ tmp16 = ADC1_IDEAL_CODE_DELTA;
+ tmp32 = (_meas_s32_)obj->info->codeCharge;
+ tmp32 = tmp32 - ADC1_IDEAL_CODE_100MV;
+ while(1)
+ {
+ tmp64 = (_meas_s64_)tmp32;
+ tmp64 = tmp64*ADC1_VOLTAGE_DELTA;
+ if((tmp64 < 2147483647) && (tmp64 > -2147483647))
+ {
+ break;
+ }
+ tmp16 = tmp16/2;
+ tmp32 = tmp32/2;
+ }
+ tmp32 = (_meas_s32_)tmp64;
+ tmp32 = tmp32/tmp16;
+ tmp32 = tmp32 + ADC1_VOLTAGE_100MV;
+ tmp32 = tmp32/obj->info->sysData->ggbParameter->rSense;
+ UG31_LOGI("[%s]: ((%d - %d) x %d / %d + %d) / %d = %d\n", __func__,
+ obj->info->codeCharge, ADC1_IDEAL_CODE_100MV, ADC1_VOLTAGE_DELTA,
+ ADC1_IDEAL_CODE_DELTA, ADC1_VOLTAGE_100MV, obj->info->sysData->ggbParameter->rSense, tmp32);
+ /// [AT-PM] : Apply board factor ; 01/25/2013
+ tmp32 = tmp32 - BOARD_FACTOR_CURR_OFFSET;
+ tmp32 = tmp32*BOARD_FACTOR_CONST/BOARD_FACTOR_CURR_GAIN;
+ UG31_LOGI("[%s]: Board Factor (%d/%d) -> %d\n", __func__,
+ BOARD_FACTOR_CURR_GAIN, BOARD_FACTOR_CURR_OFFSET, tmp32);
+
+ /// [AT-PM] : Apply calibration factor ; 01/25/2013
+ tmp32 = tmp32 - obj->info->sysData->ggbParameter->adc1_pos_offset;
+ if(tmp32 > 0)
+ {
+ tmp32 = tmp32*CALIBRATION_FACTOR_CONST/obj->info->sysData->ggbParameter->adc1_pgain;
+ }
+ else
+ {
+ tmp32 = tmp32*CALIBRATION_FACTOR_CONST/obj->info->sysData->ggbParameter->adc1_ngain;
+ }
+ UG31_LOGI("[%s]: Calibration Factor (%d|%d/%d) -> %d\n", __func__,
+ obj->info->sysData->ggbParameter->adc1_pgain, obj->info->sysData->ggbParameter->adc1_ngain,
+ obj->info->sysData->ggbParameter->adc1_pos_offset, tmp32);
+
+ /// [AT-PM] : Apply time information ; 01/25/2013
+ if(obj->info->inSuspendMode == _UPI_FALSE_)
+ {
+ CalculateAdc1ConvertTime(obj);
+ }
+ tmp32 = tmp32*(obj->info->adc1ConvertTime)/TIME_MSEC_TO_SEC*COULOMB_COUNTER_LSB/TIME_SEC_TO_HOUR;
+ tmp32 = tmp32/TIME_CONVERT_TIME_TO_MSEC;
+
+ /// [AT-PM] : Update capacity information ; 01/25/2013
+ obj->info->deltaCap = (_meas_s16_)tmp32;
+ obj->info->stepCap = obj->info->deltaCap - obj->info->lastDeltaCap;
+ obj->info->lastDeltaCap = obj->info->deltaCap;
+ UG31_LOGI("[%s]: Capacity = %d (%d)\n", __func__, obj->info->deltaCap, obj->info->stepCap);
+}
+
+/**
+ * @brief TimeTick
+ *
+ * Get the time tick and calculate delta time
+ *
+ * @para obj address of MeasDataInternalType
+ * @return _UPI_NULL_
+ */
+void TimeTick(MeasDataInternalType *obj)
+{
+ if(obj->info->inSuspendMode == _UPI_TRUE_)
+ {
+ /// [AT-PM] : Prevent adc conversion count overflow ; 06/11/2013
+ if(obj->codeCounter < obj->info->lastCounter)
+ {
+ return;
+ }
+
+ /// [AT-PM] : Use conversion count to estimate delta time ; 06/11/2013
+ obj->info->deltaTime = (_meas_u32_)obj->codeCounter;
+ obj->info->deltaTime = obj->info->deltaTime - obj->info->lastCounter;
+ obj->info->deltaTime = obj->info->deltaTime*obj->info->adc1ConvertTime;
+ return;
+ }
+
+ obj->currTime = GetTickCount();
+
+ /// [AT-PM] : Prevent time tick overflow ; 01/25/2013
+ if(obj->currTime <= obj->info->lastTimeTick)
+ {
+ obj->info->deltaTime = 0;
+ obj->info->lastTimeTick = obj->currTime;
+ UG31_LOGI("[%s]: OVERFLOW -> %d < %d\n", __func__,
+ obj->currTime, obj->info->lastTimeTick);
+ return;
+ }
+
+ /// [AT-PM] : Calculate delta time ; 01/25/2013
+ obj->info->deltaTime = obj->currTime - obj->info->lastTimeTick;
+ UG31_LOGI("[%s]: Delta Time = %d - %d = %d\n", __func__,
+ obj->currTime, obj->info->lastTimeTick, obj->info->deltaTime);
+ obj->info->lastTimeTick = obj->currTime;
+}
+
+/**
+ * @brief ReadRegister
+ *
+ * Read measurement registers
+ *
+ * @para obj address of MeasDataInternalType
+ * @return _UPI_NULL_
+ */
+void ReadRegister(MeasDataInternalType *obj)
+{
+ /// [AT-PM] : Read VBat1Ave ; 01/27/2013
+ API_I2C_Read(NORMAL_REGISTER,
+ UG31XX_I2C_HIGH_SPEED_MODE,
+ UG31XX_I2C_TEM_BITS_MODE,
+ REG_AVE_VBAT1_LOW,
+ REG_AVE_VBAT1_HIGH - REG_AVE_VBAT1_LOW + 1,
+ (unsigned char *)&obj->codeBat1);
+
+ /// [AT-PM] : Read CurrentAve ; 01/27/2013
+ API_I2C_Read(NORMAL_REGISTER,
+ UG31XX_I2C_HIGH_SPEED_MODE,
+ UG31XX_I2C_TEM_BITS_MODE,
+ REG_AVE_CURRENT_LOW,
+ REG_AVE_CURRENT_HIGH - REG_AVE_CURRENT_LOW + 1,
+ (unsigned char *)&obj->codeCurrent);
+
+ /// [AT-PM] : Read ITAve ; 01/27/2013
+ API_I2C_Read(NORMAL_REGISTER,
+ UG31XX_I2C_HIGH_SPEED_MODE,
+ UG31XX_I2C_TEM_BITS_MODE,
+ REG_AVE_IT_LOW,
+ REG_AVE_IT_HIGH - REG_AVE_IT_LOW + 1,
+ (unsigned char *)&obj->codeIntTemperature);
+
+ /// [AT-PM] : Read ETAve ; 01/27/2013
+ API_I2C_Read(NORMAL_REGISTER,
+ UG31XX_I2C_HIGH_SPEED_MODE,
+ UG31XX_I2C_TEM_BITS_MODE,
+ REG_AVE_ET_LOW,
+ REG_AVE_ET_HIGH - REG_AVE_ET_LOW + 1,
+ (unsigned char *)&obj->codeExtTemperature);
+
+ /// [AT-PM] : Read Charge ; 01/27/2013
+ API_I2C_Read(NORMAL_REGISTER,
+ UG31XX_I2C_HIGH_SPEED_MODE,
+ UG31XX_I2C_TEM_BITS_MODE,
+ REG_CHARGE_LOW,
+ REG_CHARGE_HIGH - REG_CHARGE_LOW + 1,
+ (unsigned char *)&obj->codeCharge);
+
+ /// [AT-PM] : Read Counter ; 01/27/2013
+ API_I2C_Read(NORMAL_REGISTER,
+ UG31XX_I2C_HIGH_SPEED_MODE,
+ UG31XX_I2C_TEM_BITS_MODE,
+ REG_COUNTER_LOW,
+ REG_COUNTER_HIGH - REG_COUNTER_LOW + 1,
+ (unsigned char *)&obj->codeCounter);
+
+ /// [AT-PM] : Read Offset ; 01/27/2013
+ API_I2C_Read(NORMAL_REGISTER,
+ UG31XX_I2C_HIGH_SPEED_MODE,
+ UG31XX_I2C_TEM_BITS_MODE,
+ REG_ADC1_OFFSET_LOW,
+ REG_ADC1_OFFSET_HIGH - REG_ADC1_OFFSET_LOW + 1,
+ (unsigned char *)&obj->ccOffset);
+}
+
+/**
+ * @brief ResetCoulombCounter
+ *
+ * Reset coulomb counter
+ *
+ * @para obj address of MeasDataInternalType
+ * @return _UPI_NULL_
+ */
+void ResetCoulombCounter(MeasDataInternalType *obj)
+{
+ _meas_u8_ tmp8;
+
+ API_I2C_Read(NORMAL_REGISTER,
+ UG31XX_I2C_HIGH_SPEED_MODE,
+ UG31XX_I2C_TEM_BITS_MODE,
+ REG_CTRL1,
+ 1,
+ &tmp8);
+ tmp8 = tmp8 | CTRL1_GG_RST;
+ API_I2C_Write(NORMAL_REGISTER,
+ UG31XX_I2C_HIGH_SPEED_MODE,
+ UG31XX_I2C_TEM_BITS_MODE,
+ REG_CTRL1,
+ 1,
+ &tmp8);
+}
+
+/**
+ * @brief RevertCalibrateAdc2Code
+ *
+ * Revert calibrated ADC2 code
+ *
+ * @para data address of MeasDataType
+ * @para caliCode calibrated ADC2 code
+ * @return raw ADC2 code
+ */
+_meas_s32_ RevertCalibrateAdc2Code(MeasDataType *data, _meas_s32_ caliCode)
+{
+ _meas_s64_ tmp64;
+ _meas_s32_ tmp32;
+ _meas_s32_ deltaIT;
+ _meas_s32_ gain;
+ _meas_s32_ offset;
+ _meas_s32_ constant;
+
+ /// [AT-PM] : tmp32 = ( caliCode x gain / constant + offset ) / deltaIT ; 04/08/2013
+ gain = data->adc2Gain;
+ offset = data->adc2Offset;
+ deltaIT = (_meas_s32_)data->otp->aveIT80;
+ deltaIT = deltaIT - data->otp->aveIT25;
+ constant = ADC2_IDEAL_CODE_DELTA;
+ while(1)
+ {
+ tmp64 = (_meas_s64_)caliCode;
+ tmp64 = tmp64*gain;
+ if((tmp64 < 2147483647) && (tmp64 > -2147483647))
+ {
+ break;
+ }
+ caliCode = caliCode/2;
+ gain = gain/2;
+ constant = constant/4;
+ }
+ tmp32 = (_meas_s32_)tmp64;
+ tmp32 = tmp32/constant;
+ tmp32 = tmp32 + offset;
+ tmp32 = tmp32/deltaIT;
+ return (tmp32);
+}
+
+/**
+ * @brief RevertBat1Code
+ *
+ * Revert VBat1 code
+ *
+ * @para data address of MeasDataType
+ * @para volt voltage in mV to be reverted
+ * @return adc2 vbat1 code
+ */
+_meas_u16_ RevertBat1Code(MeasDataType *data, _upi_s16_ volt)
+{
+ _meas_s32_ tmp32;
+
+ tmp32 = (_meas_s32_)volt;
+
+ /// [AT-PM] : Revert calibration parameter ; 04/08/2013
+ tmp32 = tmp32*data->sysData->ggbParameter->adc2_gain/CALIBRATION_FACTOR_CONST;
+ tmp32 = tmp32 + data->sysData->ggbParameter->adc2_offset;
+
+ /// [AT-PM] : Revert board factor ; 04/08/2013
+ tmp32 = tmp32*BOARD_FACTOR_VOLTAGE_GAIN/BOARD_FACTOR_CONST;
+ tmp32 = tmp32 + BOARD_FACTOR_VOLTAGE_OFFSET;
+
+ /// [AT-PM] : Revert to calibrated ADC code ; 04/08/2013
+ tmp32 = tmp32 - ADC2_VOLTAGE_100MV;
+ tmp32 = tmp32*ADC2_IDEAL_CODE_DELTA/ADC2_VOLTAGE_DELTA;
+ tmp32 = tmp32 + ADC2_IDEAL_CODE_100MV;
+
+ /// [AT-PM] : Revert to raw code ; 04/08/2013
+ tmp32 = RevertCalibrateAdc2Code(data, tmp32);
+ return ((_meas_u16_)tmp32);
+}
+
+/**
+ * @brief RevertETCode
+ *
+ * Revert ET code
+ *
+ * @para data address of MeasDataType
+ * @para et external temperature in 0.1oC to be reverted
+ * @return adc1 et code
+ */
+_meas_u16_ RevertETCode(MeasDataType *data, _upi_s16_ et)
+{
+ _meas_s32_ tmp32;
+ _meas_u8_ idx;
+
+ tmp32 = (_meas_s32_)et;
+
+ /// [AT-PM] : Revert calibration factor ; 04/08/2013
+ tmp32 = tmp32 + data->sysData->ggbParameter->adc_d4;
+
+ /// [AT-PM] : Revert board factor ; 04/08/2013
+ tmp32 = tmp32 + BOARD_FACTOR_EXTT_OFFSET;
+
+ /// [AT-PM] : Revert external temperature calculation ; 04/08/2013
+ idx = 0;
+ while(idx < ET_NUMS)
+ {
+ if(tmp32 < ExtTemperatureTable[idx])
+ {
+ break;
+ }
+ idx = idx + 1;
+ }
+ if(idx == 0)
+ {
+ tmp32 = (_meas_s32_)data->sysData->ggbParameter->rtTable[0];
+ }
+ else if(idx >= ET_NUMS)
+ {
+ tmp32 = (_meas_s32_)data->sysData->ggbParameter->rtTable[ET_NUMS - 1];
+ }
+ else
+ {
+ tmp32 = tmp32 - ExtTemperatureTable[idx - 1];
+ tmp32 = tmp32*(data->sysData->ggbParameter->rtTable[idx] - data->sysData->ggbParameter->rtTable[idx - 1]);
+ tmp32 = tmp32/(ExtTemperatureTable[idx] - ExtTemperatureTable[idx - 1]);
+ tmp32 = tmp32 + data->sysData->ggbParameter->rtTable[idx - 1];
+ }
+ return ((_meas_u16_)tmp32);
+}
+
+#define MAX_ET_CODE_DIFF (200)
+#define MIN_ET_CODE_DIFF (-200)
+
+/**
+ * @brief CalibrateETCode
+ *
+ * Calibrate external temperature code
+ *
+ * @para obj address of MeasDataInternalType
+ * @return MEAS_RTN_CODE
+ */
+_meas_u16_ CalibrateETCode(MeasDataInternalType *obj)
+{
+ _meas_s16_ tmp16;
+
+ tmp16 = (_meas_s16_)obj->codeExtTemperature;
+ tmp16 = tmp16 - (obj->codeCurrent + obj->ccOffset);
+ if(obj->info->codeExtTemperature != 0)
+ {
+ #ifdef UPI_UBOOT_DEBUG_MSG
+ printf("[CalibrateETCode]: Last = %d, Current = %d\n", obj->info->codeExtTemperature, tmp16);
+ #endif ///< end of UPI_UBOOT_DEBUG_MSG
+ tmp16 = tmp16 - obj->info->codeExtTemperature;
+ if(tmp16 > MAX_ET_CODE_DIFF)
+ {
+ tmp16 = MAX_ET_CODE_DIFF;
+ UG31_LOGI("[%s]: Exceed maximum ET code difference (%d > %d)\n", __func__, tmp16, MAX_ET_CODE_DIFF);
+ }
+ if(tmp16 < MIN_ET_CODE_DIFF)
+ {
+ tmp16 = MIN_ET_CODE_DIFF;
+ UG31_LOGI("[%s]: Exceed minimum ET code difference (%d < %d)\n", __func__, tmp16, MIN_ET_CODE_DIFF);
+ }
+ tmp16 = tmp16 + obj->info->codeExtTemperature;
+ }
+ #ifdef UPI_UBOOT_DEBUG_MSG
+ printf("[CalibrateETCode]: ET code = %d\n", tmp16);
+ #endif ///< end of UPI_UBOOT_DEBUG_MSG
+ return ((_meas_u16_)tmp16);
+}
+
+/// =============================================
+/// [AT-PM] : Extern function region
+/// =============================================
+
+/**
+ * @brief UpiResetCoulombCounter
+ *
+ * Reset coulomb counter
+ *
+ * @para data address of MeasDataType
+ * @return _UPI_NULL_
+ */
+void UpiResetCoulombCounter(MeasDataType *data)
+{
+ MeasDataInternalType *obj;
+
+ #if defined(uG31xx_OS_ANDROID)
+ #ifdef uG31xx_BOOT_LOADER
+ obj = (MeasDataInternalType *)malloc(sizeof(MeasDataInternalType));
+ #else ///< else of uG31xx_BOOT_LOADER
+ obj = (MeasDataInternalType *)kmalloc(sizeof(MeasDataInternalType), GFP_KERNEL);
+ #endif ///< end of uG31xx_BOOT_LOADER
+ #else ///< else of defined(uG31xx_OS_ANDROID)
+ obj = (MeasDataInternalType *)malloc(sizeof(MeasDataInternalType));
+ #endif ///< end of defined(uG31xx_OS_ANDROID)
+ memset(obj, 0x00, sizeof(MeasDataInternalType));
+
+ obj->info = data;
+
+ /// [AT-PM] : Get delta time ; 01/25/2013
+ TimeTick(obj);
+
+ /// [AT-PM] : Read ADC code ; 01/27/2013
+ ReadRegister(obj);
+
+ /// [AT-PM] : Reset coulomb counter ; 01/30/2013
+ ResetCoulombCounter(obj);
+
+ /// [AT-PM] : Convert ADC characteristic from OTP ; 01/23/2013
+ ConvertAdc1Data(obj);
+
+ /// [AT-PM] : Calculate ADC gain and offset ; 01/23/2013
+ CalAdc1Factors(obj);
+
+ /// [AT-PM] : Calibrate ADC code ; 01/23/2013
+ CalibrateChargeCode(obj);
+
+ /// [AT-PM] : Convert into physical value ; 01/23/2013
+ ConvertCharge(obj);
+ data->lastDeltaCap = 0;
+
+ #if defined(uG31xx_OS_ANDROID)
+ #ifdef uG31xx_BOOT_LOADER
+ free(obj);
+ #else ///< else of uG31xx_BOOT_LOADER
+ kfree(obj);
+ #endif ///< end of uG31xx_BOOT_LOADER
+ #else ///< else of defined(uG31xx_OS_ANDROID)
+ free(obj);
+ #endif ///< end of defined(uG31xx_OS_ANDROID)
+}
+
+#define MAXIMUM_RETRY_CNT (10)
+#define MINIMUM_VBAT1_CODE (ADC2_IDEAL_CODE_100MV/2)
+#define MAXIMUM_CURRENT_CODE (ADC1_IDEAL_CODE_200MV*6)
+#define MINIMUM_CURRENT_CODE (ADC1_IDEAL_CODE_200MV*(-6))
+#define MINIMUM_IT_CODE (IT_IDEAL_CODE_25/2)
+#define MAXIMUM_IT_CODE (IT_IDEAL_CODE_80*11/10)
+#define MINIMUM_ET_CODE (1000)
+#define MAXIMUM_ET_CODE (28000)
+#define RESET_CC_CURRENT_MAGIC_NUMBER (2)
+
+/**
+ * @brief UpiMeasurement
+ *
+ * Measurement routine
+ *
+ * @para data address of MeasDataType
+ * @return MEAS_RTN_CODE
+ */
+MEAS_RTN_CODE UpiMeasurement(MeasDataType *data)
+{
+ MeasDataInternalType *obj;
+ _meas_u8_ retry;
+ MEAS_RTN_CODE rtn;
+ _meas_s16_ standbyUpper;
+ _meas_s16_ standbyLower;
+
+ UG31_LOGI("[%s]: Measurement version : %d\n", __func__, UG31XX_MEAS_VERSION);
+
+ #if defined(uG31xx_OS_ANDROID)
+ #ifdef uG31xx_BOOT_LOADER
+ obj = (MeasDataInternalType *)malloc(sizeof(MeasDataInternalType));
+ #else ///< else of uG31xx_BOOT_LOADER
+ obj = (MeasDataInternalType *)kmalloc(sizeof(MeasDataInternalType), GFP_KERNEL);
+ #endif ///< end of uG31xx_BOOT_LOADER
+ #else ///< else of defined(uG31xx_OS_ANDROID)
+ obj = (MeasDataInternalType *)malloc(sizeof(MeasDataInternalType));
+ #endif ///< end of defined(uG31xx_OS_ANDROID)
+ memset(obj, 0x00, sizeof(MeasDataInternalType));
+
+ obj->info = data;
+ rtn = MEAS_RTN_PASS;
+
+ /// [AT-PM] : Get delta time ; 01/25/2013
+ TimeTick(obj);
+
+ /// [AT-PM] : Read ADC code ; 01/27/2013
+ retry = 0;
+ while(retry < MAXIMUM_RETRY_CNT)
+ {
+ ReadRegister(obj);
+ #ifdef UPI_UBOOT_DEBUG_MSG
+ printf("[UpiMeasurement] Retry = %d\n", retry);
+ printf("[UpiMeasurement] VBAT1 Code = %d\n", obj->codeBat1);
+ printf("[UpiMeasurement] CURRENT Code = %d\n", obj->codeCurrent);
+ printf("[UpiMeasurement] IT Code = %d\n", obj->codeIntTemperature);
+ printf("[UpiMeasurement] ET Code = %d\n", obj->codeExtTemperature);
+ printf("[UpiMeasurement] COULOMB COUNTER Code = %d - %d\n", obj->codeCharge, obj->codeCounter);
+ #endif ///< end of UPI_UBOOT_DEBUG_MSG
+
+ if(obj->codeBat1 < MINIMUM_VBAT1_CODE)
+ {
+ UG31_LOGE("[%s]: Voltage code %d < %d -> Retry %d\n", __func__,
+ obj->codeBat1, MINIMUM_VBAT1_CODE, retry);
+ rtn = MEAS_RTN_BATTERY_REMOVED;
+ }
+ else if(obj->codeCurrent < MINIMUM_CURRENT_CODE)
+ {
+ UG31_LOGE("[%s]: Current code %d < %d\n", __func__,
+ obj->codeCurrent, MINIMUM_CURRENT_CODE);
+ obj->codeCurrent = MINIMUM_CURRENT_CODE;
+ break;
+ }
+ else if(obj->codeCurrent > MAXIMUM_CURRENT_CODE)
+ {
+ UG31_LOGE("[%s]: Current code %d > %d\n", __func__,
+ obj->codeCurrent, MAXIMUM_CURRENT_CODE);
+ obj->codeCurrent = MAXIMUM_CURRENT_CODE;
+ break;
+ }
+ else if(obj->codeIntTemperature < MINIMUM_IT_CODE)
+ {
+ UG31_LOGE("[%s]: Internal Temperature code %d < %d -> Retry %d\n", __func__,
+ obj->codeIntTemperature, MINIMUM_IT_CODE, retry);
+ rtn = MEAS_RTN_ADC_ABNORMAL;
+ }
+ else if(obj->codeIntTemperature > MAXIMUM_IT_CODE)
+ {
+ UG31_LOGE("[%s]: Internal Temperature code %d > %d -> Retry %d\n", __func__,
+ obj->codeIntTemperature, MAXIMUM_IT_CODE, retry);
+ rtn = MEAS_RTN_ADC_ABNORMAL;
+ }
+ else if(obj->codeExtTemperature < MINIMUM_ET_CODE)
+ {
+ UG31_LOGE("[%s]: External Temperature code %d < %d -> Retry %d\n", __func__,
+ obj->codeExtTemperature, MINIMUM_ET_CODE, retry);
+ rtn = MEAS_RTN_NTC_SHORT;
+ #ifndef ENABLE_NTC_CHECK
+ break;
+ #endif ///< end of ENABLE_NTC_CHECK
+ }
+ else if(obj->codeExtTemperature > MAXIMUM_ET_CODE)
+ {
+ UG31_LOGE("[%s]: External Temperature code %d > %d -> Retry %d\n", __func__,
+ obj->codeExtTemperature, MAXIMUM_ET_CODE, retry);
+ rtn = MEAS_RTN_BATTERY_REMOVED;
+ #ifndef ENABLE_NTC_CHECK
+ break;
+ #endif ///< end of ENABLE_NTC_CHECK
+ }
+ else
+ {
+ break;
+ }
+ retry = retry + 1;
+ SleepMiniSecond(1000);
+ }
+ if(retry >= MAXIMUM_RETRY_CNT)
+ {
+ #if defined(uG31xx_OS_ANDROID)
+ #ifdef uG31xx_BOOT_LOADER
+ free(obj);
+ #else ///< else of uG31xx_BOOT_LOADER
+ kfree(obj);
+ #endif ///< end of uG31xx_BOOT_LOADER
+ #else ///< else of defined(uG31xx_OS_ANDROID)
+ free(obj);
+ #endif ///< end of defined(uG31xx_OS_ANDROID)
+ return (rtn);
+ }
+ rtn = MEAS_RTN_PASS;
+
+ /// [AT-PM] : Convert ADC characteristic from OTP ; 01/23/2013
+ ConvertAdc1Data(obj);
+ ConvertAdc2Data(obj);
+
+ /// [AT-PM] : Calculate ADC gain and offset ; 01/23/2013
+ CalAdc1Factors(obj);
+ CalAdc2Factors(obj);
+
+ /// [AT-PM] : Calibrate ADC code ; 01/23/2013
+ data->codeBat1 = (_meas_u16_)CalibrateAdc2Code(obj, (_meas_s32_)obj->codeBat1);
+ UG31_LOGI("[%s]: VBat1 Code = %d -> %d\n", __func__, obj->codeBat1, data->codeBat1);
+ data->codeCurrent = (_meas_s16_)CalibrateAdc1Code(obj, (_meas_s32_)obj->codeCurrent);
+ UG31_LOGI("[%s]: Current Code = %d -> %d\n", __func__, obj->codeCurrent, data->codeCurrent);
+ CalibrateChargeCode(obj);
+ data->codeIntTemperature = CalibrateITCode(obj, obj->codeIntTemperature);
+ UG31_LOGI("[%s]: Internal Temperature Code = %d -> %d\n", __func__,
+ obj->codeIntTemperature, data->codeIntTemperature);
+ data->codeExtTemperature = CalibrateETCode(obj);
+ UG31_LOGI("[%s]: External Temperature Code = %d -> %d\n", __func__, obj->codeExtTemperature, data->codeExtTemperature);
+
+ /// [AT-PM] : Convert into physical value ; 01/23/2013
+ ConvertBat1(obj);
+ ConvertCurrent(obj);
+ ConvertIntTemperature(obj);
+ ConvertExtTemperature(obj);
+ ConvertCharge(obj);
+
+ /// [AT-PM] : Reset coulomb counter if necessary ; 01/27/2013
+ standbyUpper = (_meas_s16_)obj->info->sysData->ggbParameter->standbyCurrent;
+ standbyUpper = standbyUpper/RESET_CC_CURRENT_MAGIC_NUMBER;
+ standbyLower = standbyUpper*(-1);
+ if((obj->codeCounter > COULOMB_COUNTER_RESET_THRESHOLD_COUNTER) ||
+ (obj->codeCharge > COULOMB_COUNTER_RESET_THRESHOLD_CHARGE_CHG) ||
+ (obj->codeCharge < COULOMB_COUNTER_RESET_THREDHOLD_CHARGE_DSG) ||
+ ((obj->info->curr < standbyUpper) &&
+ (obj->info->curr > standbyLower) &&
+ (obj->codeCounter > CONST_CONVERSION_COUNT_THRESHOLD*RESET_CC_CURRENT_MAGIC_NUMBER)))
+ {
+ ResetCoulombCounter(obj);
+ data->lastDeltaCap = 0;
+ }
+
+ #ifdef MEAS_FAKE_INT_TEMP
+ data->extTemperature = data->intTemperature;
+ data->intTemperature = MEAS_FAKE_INT_TEMP_OFFSET + data->intTemperature%100;
+ #endif ///< end of MEAS_FAKE_INT_TEMP
+
+ UG31_LOGI("[%s]: %d mV / %d mA / %d 0.1oC / %d 0.1oC / %d mAh\n", __func__,
+ data->bat1Voltage, data->curr, data->intTemperature, data->extTemperature, data->deltaCap);
+ #if defined(uG31xx_OS_ANDROID)
+ #ifdef uG31xx_BOOT_LOADER
+ free(obj);
+ #else ///< else of uG31xx_BOOT_LOADER
+ kfree(obj);
+ #endif ///< end of uG31xx_BOOT_LOADER
+ #else ///< else of defined(uG31xx_OS_ANDROID)
+ free(obj);
+ #endif ///< end of defined(uG31xx_OS_ANDROID)
+ return (rtn);
+}
+
+/**
+ * @brief UpiMeasAlarmThreshold
+ *
+ * Get alarm threshold
+ *
+ * @para data address of MeasDataType
+ * @return MEAS_RTN_CODE
+ */
+MEAS_RTN_CODE UpiMeasAlarmThreshold(MeasDataType *data)
+{
+ MEAS_RTN_CODE rtn;
+
+ rtn = MEAS_RTN_PASS;
+
+ /// [AT-PM] : Calculate UV alarm and release threshold ; 04/08/2013
+ data->sysData->uvAlarm.alarmThrd = RevertBat1Code(data, data->sysData->ggbParameter->uvAlarm);
+ data->sysData->uvAlarm.releaseThrd = RevertBat1Code(data, data->sysData->ggbParameter->uvRelease);
+ UG31_LOGI("[%s]: UV Alarm -> %d / %d\n", __func__,
+ data->sysData->uvAlarm.alarmThrd, data->sysData->uvAlarm.releaseThrd);
+
+ /// [AT-PM] : Calculate UET alarm and release threshold ; 04/08/2013
+ data->sysData->uetAlarm.alarmThrd = RevertETCode(data, data->sysData->ggbParameter->uetAlarm);
+ data->sysData->uetAlarm.releaseThrd = RevertETCode(data, data->sysData->ggbParameter->uetRelease);
+ UG31_LOGI("[%s]: UET Alarm -> %d / %d\n", __func__,
+ data->sysData->uetAlarm.alarmThrd, data->sysData->uetAlarm.releaseThrd);
+
+ /// [AT-PM] : Calculate OET alarm and release threshold ; 04/08/2013
+ data->sysData->oetAlarm.alarmThrd = RevertETCode(data, data->sysData->ggbParameter->oetAlarm);
+ data->sysData->oetAlarm.releaseThrd = RevertETCode(data, data->sysData->ggbParameter->oetRelease);
+ UG31_LOGI("[%s]: OET Alarm -> %d / %d\n", __func__,
+ data->sysData->oetAlarm.alarmThrd, data->sysData->oetAlarm.releaseThrd);
+
+ return (rtn);
+}
+
diff --git a/board/wmt/wmt_battery/gauge/upi/uG31xx_API_Measurement.h b/board/wmt/wmt_battery/gauge/upi/uG31xx_API_Measurement.h
new file mode 100755
index 0000000..482b4b5
--- /dev/null
+++ b/board/wmt/wmt_battery/gauge/upi/uG31xx_API_Measurement.h
@@ -0,0 +1,128 @@
+/**
+ * @filename uG31xx_API_Measurement.h
+ *
+ * Header for uG31xx measurement API
+ *
+ * @author AllenTeng <allen_teng@upi-semi.com>
+ */
+
+typedef signed char _meas_s8_;
+typedef unsigned char _meas_u8_;
+typedef signed short _meas_s16_;
+typedef unsigned short _meas_u16_;
+typedef signed long _meas_s32_;
+typedef unsigned long _meas_u32_;
+typedef signed long long _meas_s64_;
+typedef char _meas_bool_;
+
+#define UG31XX_MEAS_VERSION (9)
+
+#define BOARD_FACTOR_CONST (1000)
+#define BOARD_FACTOR_VOLTAGE_GAIN (1000) ///< [AT-PM] : VBat1 board factor - gain ; 01/25/2013
+#define BOARD_FACTOR_VOLTAGE_OFFSET (0) ///< [AT-PM] : VBat1 board factor - offset ; 01/25/2013
+#define BOARD_FACTOR_CURR_GAIN (1014) ///< [AT-PM] : Current board factor - gain ; 01/25/2013
+#define BOARD_FACTOR_CURR_OFFSET (-7) ///< [AT-PM] : Current board factor - offset ; 01/25/2013
+#define BOARD_FACTOR_INTT_OFFSET (-23) ///< [AT-PM] : Internal Temperature board factor - offset ; 01/25/2013
+#define BOARD_FACTOR_EXTT_OFFSET (13) ///< [AT-PM] : External Temperature board factor - offset ; 01/25/2013
+
+#define CALIBRATION_FACTOR_CONST (1000)
+
+#define COULOMB_COUNTER_RESET_THRESHOLD_COUNTER (10000)
+#define COULOMB_COUNTER_RESET_THRESHOLD_CHARGE_CHG (30000)
+#define COULOMB_COUNTER_RESET_THREDHOLD_CHARGE_DSG (-30000)
+
+typedef enum _MEAS_RTN_CODE {
+ MEAS_RTN_PASS = 0,
+ MEAS_RTN_BATTERY_REMOVED,
+ MEAS_RTN_ADC_ABNORMAL,
+ MEAS_RTN_NTC_SHORT,
+} MEAS_RTN_CODE;
+
+typedef struct MeasDataST {
+
+ /// [AT-PM] : System data ; 04/08/2013
+ SystemDataType *sysData;
+
+ /// [AT-PM] : OTP data ; 01/23/2013
+ OtpDataType *otp;
+
+ /// [AT-PM] : Physical value ; 01/23/2013
+ _meas_u16_ bat1Voltage;
+ _meas_s16_ curr;
+ _meas_s16_ intTemperature;
+ _meas_s16_ extTemperature;
+ _meas_s16_ deltaCap;
+ _meas_s16_ stepCap;
+ _meas_u32_ deltaTime;
+
+
+ /// [AT-PM] : ADC code ; 01/23/2013
+ _meas_u16_ codeBat1;
+ _meas_s16_ codeCurrent;
+ _meas_u16_ codeIntTemperature;
+ _meas_u16_ codeExtTemperature;
+ _meas_s32_ codeCharge;
+
+ /// [AT-PM] : Coulomb counter offset ; 01/23/2013
+ _meas_s16_ ccOffset;
+
+ /// [AT-PM] : ADC1 characteristic ; 01/23/2013
+ _meas_u16_ adc1ConvertTime;
+ _meas_s32_ adc1Gain;
+ _meas_s32_ adc1GainSlope;
+ _meas_s32_ adc1GainFactorB;
+ _meas_s32_ adc1Offset;
+ _meas_s32_ adc1OffsetSlope;
+ _meas_s32_ adc1OffsetFactorO;
+
+ /// [AT-PM] : ADC2 characteristic ; 01/23/2013
+ _meas_s32_ adc2Gain;
+ _meas_s32_ adc2GainSlope;
+ _meas_s32_ adc2GainFactorB;
+ _meas_s32_ adc2Offset;
+ _meas_s32_ adc2OffsetSlope;
+ _meas_s32_ adc2OffsetFactorO;
+
+ /// [AT-PM] : Previous information ; 01/25/2013
+ _meas_u16_ lastCounter;
+ _meas_u32_ lastTimeTick;
+ _meas_s16_ lastDeltaCap;
+
+ /// [AT-PM] : In suspend mode operation ; 06/11/2013
+ _meas_bool_ inSuspendMode;
+#if defined(uG31xx_OS_ANDROID)
+} __attribute__ ((aligned(4))) MeasDataType;
+#else ///< else of defined(uG31xx_OS_ANDROID)
+} MeasDataType;
+#endif ///< end of defined(uG31xx_OS_ANDROID)
+
+/**
+ * @brief UpiResetCoulombCounter
+ *
+ * Reset coulomb counter
+ *
+ * @para data address of MeasDataType
+ * @return _UPI_NULL_
+ */
+extern void UpiResetCoulombCounter(MeasDataType *data);
+
+/**
+ * @brief UpiMeasurement
+ *
+ * Measurement routine
+ *
+ * @para data address of MeasDataType
+ * @return MEAS_RTN_CODE
+ */
+extern MEAS_RTN_CODE UpiMeasurement(MeasDataType *data);
+
+/**
+ * @brief UpiMeasAlarmThreshold
+ *
+ * Get alarm threshold
+ *
+ * @para data address of MeasDataType
+ * @return MEAS_RTN_CODE
+ */
+extern MEAS_RTN_CODE UpiMeasAlarmThreshold(MeasDataType *data);
+
diff --git a/board/wmt/wmt_battery/gauge/upi/uG31xx_API_Otp.c b/board/wmt/wmt_battery/gauge/upi/uG31xx_API_Otp.c
new file mode 100755
index 0000000..5ed47de
--- /dev/null
+++ b/board/wmt/wmt_battery/gauge/upi/uG31xx_API_Otp.c
@@ -0,0 +1,917 @@
+/**
+ * @filename uG31xx_API_Otp.cpp
+ *
+ * Convert OTP registers into readable value
+ *
+ * @author AllenTeng <allen_teng@upi-semi.com>
+ */
+
+#include "stdafx.h" //windows need this??
+#include "uG31xx_API.h"
+
+/// =============================================
+/// [AT-PM] : OTP register definition
+/// =============================================
+
+#define OTP1_OFFSET_E0 (0)
+ #define INDEX_ADC1_200_25_0 (1<<0)
+ #define INDEX_ADC1_200_25_1 (1<<1)
+ #define INDEX_ADC1_200_25_2 (1<<2)
+ #define INDEX_ADC1_200_25_3 (1<<3)
+ #define DELTA_VREF_0 (1<<4)
+ #define DELTA_VREF_1 (1<<5)
+ #define DELTA_VREF_2 (1<<6)
+ #define DELTA_VREF_3 (1<<7)
+
+#define OTP1_OFFSET_E1 (OTP1_OFFSET_E0 + 1)
+ #define INDEX_ADC1_100_25_0 (1<<0)
+ #define INDEX_ADC1_100_25_1 (1<<1)
+ #define INDEX_ADC1_100_25_2 (1<<2)
+ #define INDEX_ADC1_100_25_3 (1<<3)
+ #define FT_IT_3 (1<<4)
+ #define FT_IT_4 (1<<5)
+ #define FT_IT_5 (1<<6)
+ #define FT_IT_6 (1<<7)
+
+#define OTP1_OFFSET_E2 (OTP1_OFFSET_E1 + 1)
+ #define INDEX_ADC2_200_25_0 (1<<0)
+ #define INDEX_ADC2_200_25_1 (1<<1)
+ #define INDEX_ADC2_200_25_2 (1<<2)
+ #define INDEX_ADC2_200_25_3 (1<<3)
+ #define FT_IT_7 (1<<4)
+ #define FT_IT_8 (1<<5)
+ #define FT_IT_9 (1<<6)
+ #define FT_IT_10 (1<<7)
+
+#define OTP1_OFFSET_E3 (OTP1_OFFSET_E2 + 1)
+ #define INDEX_ADC2_100_25_0 (1<<0)
+ #define INDEX_ADC2_100_25_1 (1<<1)
+ #define INDEX_ADC2_100_25_2 (1<<2)
+ #define INDEX_ADC2_100_25_3 (1<<3)
+ #define FT_IT_11 (1<<4)
+ #define FT_IT_12 (1<<5)
+ #define FT_IT_13 (1<<6)
+ #define FT_IT_14 (1<<7)
+
+#define OTP2_OFFSET_F0 (0)
+ #define OTP2_OFFSET_F0_RSVD_0 (1<<0)
+ #define OTP2_OFFSET_F0_RSVD_1 (1<<1)
+ #define OTP2_OFFSET_F0_RSVD_2 (1<<2)
+ #define PRODUCT_TYPE_0 (1<<3)
+ #define PRODUCT_TYPE_1 (1<<4)
+ #define DELTA_ET_0 (1<<5)
+ #define INDEX_ADC2_100_25_4 (1<<6)
+ #define DELTA_ET_1 (1<<7)
+
+#define OTP2_OFFSET_F1 (OTP2_OFFSET_F0 + 1)
+ #define OTP2_OFFSET_F1_RSVD_0 (1<<0)
+ #define OTP2_OFFSET_F1_RSVD_1 (1<<1)
+ #define OTP2_OFFSET_F1_RSVD_2 (1<<2)
+ #define OTP2_OFFSET_F1_RSVD_3 (1<<3)
+ #define OTP2_OFFSET_F1_RSVD_4 (1<<4)
+ #define OTP2_OFFSET_F1_RSVD_5 (1<<5)
+ #define OTP2_OFFSET_F1_RSVD_6 (1<<6)
+ #define OTP2_OFFSET_F1_RSVD_7 (1<<7)
+
+#define OTP2_OFFSET_F2 (OTP2_OFFSET_F1 + 1)
+ #define OTP2_OFFSET_F2_RSVD_0 (1<<0)
+ #define OTP2_OFFSET_F2_RSVD_1 (1<<1)
+ #define OTP2_OFFSET_F2_RSVD_2 (1<<2)
+ #define OTP_CELL_EN_0 (1<<3)
+ #define OTP_CELL_EN_1 (1<<4)
+ #define OTP_CELL_EN_2 (1<<5)
+ #define OTP_CELL_EN_3 (1<<6)
+ #define OTP_CELL_EN_4 (1<<7)
+
+#define OTP2_OFFSET_F3 (OTP2_OFFSET_F2 + 1)
+ #define OTP2_OFFSET_F3_RSVD_0 (1<<0)
+ #define OTP2_OFFSET_F3_RSVD_1 (1<<1)
+ #define OTP2_OFFSET_F3_RSVD_2 (1<<2)
+ #define OTP2_OFFSET_F3_RSVD_3 (1<<3)
+ #define OTP2_OFFSET_F3_RSVD_4 (1<<4)
+ #define OTP2_OFFSET_F3_RSVD_5 (1<<5)
+ #define OTP2_OFFSET_F3_RSVD_6 (1<<6)
+ #define OTP2_OFFSET_F3_RSVD_7 (1<<7)
+
+#define OTP2_OFFSET_F4 (OTP2_OFFSET_F3 + 1)
+ #define ADC1_DELTA_CODE_25_200MV_8 (1<<0)
+ #define ADC1_DELTA_CODE_25_200MV_9 (1<<1)
+ #define DEV_ADDR_0 (1<<2)
+ #define DEV_ADDR_1 (1<<3)
+ #define DEV_ADDR_2 (1<<4)
+ #define DEV_ADDR_7 (1<<5)
+ #define DEV_ADDR_8 (1<<6)
+ #define DEV_ADDR_9 (1<<7)
+
+#define OTP2_OFFSET_F5 (OTP2_OFFSET_F4 + 1)
+ #define OTP2_OFFSET_F5_RSVD_0 (1<<0)
+ #define OTP2_OFFSET_F5_RSVD_1 (1<<1)
+ #define BGR_TUNE_0 (1<<2)
+ #define BGR_TUNE_1 (1<<3)
+ #define BGR_TUNE_2 (1<<4)
+ #define BGR_TUNE_3 (1<<5)
+ #define BGR_TUNE_4 (1<<6)
+ #define BGR_TUNE_5 (1<<7)
+
+#define OTP2_OFFSET_F6 (OTP2_OFFSET_F5 + 1)
+ #define OSC_DELTA_CODE_25_0 (1<<0)
+ #define OSC_DELTA_CODE_25_1 (1<<1)
+ #define OSC_DELTA_CODE_25_2 (1<<2)
+ #define OSC_DELTA_CODE_25_3 (1<<3)
+ #define OSC_DELTA_CODE_25_4 (1<<4)
+ #define OSC_DELTA_CODE_25_5 (1<<5)
+ #define OSC_DELTA_CODE_25_6 (1<<6)
+ #define OSC_DELTA_CODE_25_7 (1<<7)
+
+#define OTP2_OFFSET_F7 (OTP2_OFFSET_F6 + 1)
+ #define OSC_DELTA_CODE_80_0 (1<<0)
+ #define OSC_DELTA_CODE_80_1 (1<<1)
+ #define OSC_DELTA_CODE_80_2 (1<<2)
+ #define OSC_DELTA_CODE_80_3 (1<<3)
+ #define OSC_DELTA_CODE_80_4 (1<<4)
+ #define OSC_DELTA_CODE_80_5 (1<<5)
+ #define OSC_DELTA_CODE_80_6 (1<<6)
+ #define OSC_DELTA_CODE_80_7 (1<<7)
+
+#define OTP2_OFFSET_F8 (OTP2_OFFSET_F7 + 1)
+ #define ADC1_DELTA_CODE_25_200MV_0 (1<<0)
+ #define ADC1_DELTA_CODE_25_200MV_1 (1<<1)
+ #define ADC1_DELTA_CODE_25_200MV_2 (1<<2)
+ #define ADC1_DELTA_CODE_25_200MV_3 (1<<3)
+ #define ADC1_DELTA_CODE_25_200MV_4 (1<<4)
+ #define ADC1_DELTA_CODE_25_200MV_5 (1<<5)
+ #define ADC1_DELTA_CODE_25_200MV_6 (1<<6)
+ #define ADC1_DELTA_CODE_25_200MV_7 (1<<7)
+
+#define OTP2_OFFSET_F9 (OTP2_OFFSET_F8 + 1)
+ #define OTP2_OFFSET_F9_RSVD_0 (1<<0)
+ #define OTP2_OFFSET_F9_RSVD_1 (1<<1)
+ #define OTP2_OFFSET_F9_RSVD_2 (1<<2)
+ #define OTP2_OFFSET_F9_RSVD_3 (1<<3)
+ #define OTP2_OFFSET_F9_RSVD_4 (1<<4)
+ #define OTP2_OFFSET_F9_RSVD_5 (1<<5)
+ #define OTP2_OFFSET_F9_RSVD_6 (1<<6)
+ #define OTP2_OFFSET_F9_RSVD_7 (1<<7)
+
+#define OTP2_OFFSET_FA (OTP2_OFFSET_F9 + 1)
+ #define ADC1_DELTA_CODE_25_100MV_0 (1<<0)
+ #define ADC1_DELTA_CODE_25_100MV_1 (1<<1)
+ #define ADC1_DELTA_CODE_25_100MV_2 (1<<2)
+ #define ADC1_DELTA_CODE_25_100MV_3 (1<<3)
+ #define ADC1_DELTA_CODE_25_100MV_4 (1<<4)
+ #define ADC1_DELTA_CODE_25_100MV_5 (1<<5)
+ #define ADC1_DELTA_CODE_25_100MV_6 (1<<6)
+ #define ADC1_DELTA_CODE_25_100MV_7 (1<<7)
+
+#define OTP2_OFFSET_FB (OTP2_OFFSET_FA + 1)
+ #define OTP2_OFFSET_FB_RSVD_0 (1<<0)
+ #define OTP2_OFFSET_FB_RSVD_1 (1<<1)
+ #define OTP2_OFFSET_FB_RSVD_2 (1<<2)
+ #define OTP2_OFFSET_FB_RSVD_3 (1<<3)
+ #define OTP2_OFFSET_FB_RSVD_4 (1<<4)
+ #define OTP2_OFFSET_FB_RSVD_5 (1<<5)
+ #define OTP2_OFFSET_FB_RSVD_6 (1<<6)
+ #define OTP2_OFFSET_FB_RSVD_7 (1<<7)
+
+#define OTP2_OFFSET_FC (OTP2_OFFSET_FB + 1)
+ #define ADC1_DELTA_CODE_25_100MV_8 (1<<0)
+ #define ADC2_DELTA_CODE_25_100MV_0 (1<<1)
+ #define ADC2_DELTA_CODE_25_100MV_1 (1<<2)
+ #define ADC2_DELTA_CODE_25_100MV_2 (1<<3)
+ #define ADC2_DELTA_CODE_25_100MV_3 (1<<4)
+ #define ADC2_DELTA_CODE_25_100MV_4 (1<<5)
+ #define ADC2_DELTA_CODE_25_100MV_5 (1<<6)
+ #define ADC2_DELTA_CODE_25_100MV_6 (1<<7)
+
+#define OTP2_OFFSET_FD (OTP2_OFFSET_FC + 1)
+ #define OTP2_OFFSET_FD_RSVD_0 (1<<0)
+ #define OTP2_OFFSET_FD_RSVD_1 (1<<1)
+ #define OTP2_OFFSET_FD_RSVD_2 (1<<2)
+ #define OTP2_OFFSET_FD_RSVD_3 (1<<3)
+ #define OTP2_OFFSET_FD_RSVD_4 (1<<4)
+ #define OTP2_OFFSET_FD_RSVD_5 (1<<5)
+ #define OTP2_OFFSET_FD_RSVD_6 (1<<6)
+ #define OTP2_OFFSET_FD_RSVD_7 (1<<7)
+
+#define OTP2_OFFSET_FE (OTP2_OFFSET_FD + 1)
+ #define ADC2_DELTA_CODE_25_200MV_0 (1<<0)
+ #define ADC2_DELTA_CODE_25_200MV_1 (1<<1)
+ #define ADC2_DELTA_CODE_25_200MV_2 (1<<2)
+ #define ADC2_DELTA_CODE_25_200MV_3 (1<<3)
+ #define ADC2_DELTA_CODE_25_200MV_4 (1<<4)
+ #define ADC2_DELTA_CODE_25_200MV_5 (1<<5)
+ #define ADC2_DELTA_CODE_25_200MV_6 (1<<6)
+ #define ADC2_DELTA_CODE_25_200MV_7 (1<<7)
+
+#define OTP2_OFFSET_FF (OTP2_OFFSET_FE + 1)
+ #define OTP2_OFFSET_FF_RSVD_0 (1<<0)
+ #define OTP2_OFFSET_FF_RSVD_1 (1<<1)
+ #define OTP2_OFFSET_FF_RSVD_2 (1<<2)
+ #define OTP2_OFFSET_FF_RSVD_3 (1<<3)
+ #define OTP2_OFFSET_FF_RSVD_4 (1<<4)
+ #define OTP2_OFFSET_FF_RSVD_5 (1<<5)
+ #define OTP2_OFFSET_FF_RSVD_6 (1<<6)
+ #define OTP2_OFFSET_FF_RSVD_7 (1<<7)
+
+
+#define OTP3_OFFSET_70 (0)
+ #define DELTA_VREF_4 (1<<0)
+ #define DELTA_ET_2 (1<<1)
+ #define DELTA_ET_3 (1<<2)
+ #define AVE_IT_25_3 (1<<3)
+ #define AVE_IT_25_4 (1<<4)
+ #define AVE_IT_25_5 (1<<5)
+ #define AVE_IT_25_6 (1<<6)
+ #define AVE_IT_25_7 (1<<7)
+
+#define OTP3_OFFSET_71 (OTP3_OFFSET_70 + 1)
+ #define AVE_IT_25_8 (1<<0)
+ #define AVE_IT_25_9 (1<<1)
+ #define AVE_IT_25_10 (1<<2)
+ #define AVE_IT_25_11 (1<<3)
+ #define AVE_IT_25_12 (1<<4)
+ #define AVE_IT_25_13 (1<<5)
+ #define AVE_IT_25_14 (1<<6)
+ #define AVE_IT_25_15 (1<<7)
+
+#define OTP3_OFFSET_72 (OTP3_OFFSET_71 + 1)
+ #define INDEX_ADC2_200_25_4 (1<<0)
+ #define INDEX_ADC1_100_25_4 (1<<1)
+ #define INDEX_ADC1_200_25_4 (1<<2)
+ #define AVE_IT_80_3 (1<<3)
+ #define AVE_IT_80_4 (1<<4)
+ #define AVE_IT_80_5 (1<<5)
+ #define AVE_IT_80_6 (1<<6)
+ #define AVE_IT_80_7 (1<<7)
+
+#define OTP3_OFFSET_73 (OTP3_OFFSET_72 + 1)
+ #define AVE_IT_80_8 (1<<0)
+ #define AVE_IT_80_9 (1<<1)
+ #define AVE_IT_80_10 (1<<2)
+ #define AVE_IT_80_11 (1<<3)
+ #define AVE_IT_80_12 (1<<4)
+ #define AVE_IT_80_13 (1<<5)
+ #define AVE_IT_80_14 (1<<6)
+ #define AVE_IT_80_15 (1<<7)
+
+/// =============================================
+/// [AT-PM] : OTP register conversion routine
+/// =============================================
+
+/**
+ * @brief ConvOtp1E0
+ *
+ * Convert OTP1 0xE0
+ *
+ * @para obj address of OtpDataType
+ * @return _UPI_NULL_
+ */
+void ConvOtp1E0(OtpDataType *obj)
+{
+ _otp_u8_ value;
+
+ value = obj->otp1[OTP1_OFFSET_E0];
+ #ifdef UPI_UBOOT_DEBUG_MSG
+ printf("[ConvOtp1E0] Initial value of indexAdc1V200T25 = %d\n");
+ #endif ///< end of UPI_UBOOT_DEBUG_MSG
+ obj->indexAdc1V200T25 = obj->indexAdc1V200T25 + (value & (INDEX_ADC1_200_25_0 |
+ INDEX_ADC1_200_25_1 |
+ INDEX_ADC1_200_25_2 |
+ INDEX_ADC1_200_25_3));
+
+ obj->deltaVref = obj->deltaVref + ((value & (DELTA_VREF_0| DELTA_VREF_1 | DELTA_VREF_2 | DELTA_VREF_3)) >> 4);
+}
+
+/**
+ * @brief ConvOtp1E1
+ *
+ * Convert OTP1 0xE1
+ *
+ * @para obj address of OtpDataType
+ * @return _UPI_NULL_
+ */
+void ConvOtp1E1(OtpDataType *obj)
+{
+ _otp_u8_ value;
+
+ value = obj->otp1[OTP1_OFFSET_E1];
+
+ #ifdef UPI_UBOOT_DEBUG_MSG
+ printf("[ConvOtp1E1] Initial value of indexAdc1V100T25 = %d\n", obj->indexAdc1V100T25);
+ #endif ///< end of UPI_UBOOT_DEBUG_MSG
+ obj->indexAdc1V100T25 = obj->indexAdc1V100T25 + (value & (INDEX_ADC1_100_25_0 |
+ INDEX_ADC1_100_25_1 |
+ INDEX_ADC1_100_25_2 |
+ INDEX_ADC1_100_25_3));
+
+ obj->ftIT = obj->ftIT + ((value & (FT_IT_3 | FT_IT_4 | FT_IT_5 | FT_IT_6)) >> 1);
+}
+
+/**
+ * @brief ConvOtp1E2
+ *
+ * Convert OTP1 0xE2
+ *
+ * @para obj address of OtpDataType
+ * @return _UPI_NULL_
+ */
+void ConvOtp1E2(OtpDataType *obj)
+{
+ _otp_u8_ value;
+ _otp_u16_ tmp;
+
+ value = obj->otp1[OTP1_OFFSET_E2];
+
+ #ifdef UiPI_UBOOT_DEBUG_MSG
+ printf("[ConvOtp1E2] Initial value of indexAdc2V200T25 = %d\n", obj->indexAdc2V200T25);
+ #endif ///< end of UiPI_UBOOT_DEBUG_MSG
+ obj->indexAdc2V200T25 = obj->indexAdc2V200T25 + (value & (INDEX_ADC2_200_25_0 |
+ INDEX_ADC2_200_25_1 |
+ INDEX_ADC2_200_25_2 |
+ INDEX_ADC2_200_25_3));
+
+ tmp = (value & (FT_IT_7 | FT_IT_8 | FT_IT_9 | FT_IT_10));
+ obj->ftIT = obj->ftIT + (tmp << 3);
+}
+
+/**
+ * @brief ConvOtp1E3
+ *
+ * Convert OTP1 0xE3
+ *
+ * @para obj address of OtpDataType
+ * @return _UPI_NULL_
+ */
+void ConvOtp1E3(OtpDataType *obj)
+{
+ _otp_u8_ value;
+ _otp_u16_ tmp;
+
+ value = obj->otp1[OTP1_OFFSET_E3];
+
+ #ifdef UPI_UBOOT_DEBUG_MSG
+ printf("[ConvOtp1E3] Initial value of indexAdc2V100T25 = %d\n", obj->indexAdc2V100T25);
+ #endif ///< end of UPI_UBOOT_DEBUG_MSG
+ obj->indexAdc2V100T25 = obj->indexAdc2V100T25 + (value & (INDEX_ADC2_100_25_0 |
+ INDEX_ADC2_100_25_1 |
+ INDEX_ADC2_100_25_2 |
+ INDEX_ADC2_100_25_3));
+
+ tmp = (value & (FT_IT_11 | FT_IT_12 | FT_IT_13 | FT_IT_14));
+ obj->ftIT = obj->ftIT + (tmp << 7);
+}
+
+/**
+ * @brief ConvOtp2F0
+ *
+ * Convert OTP2 0xF0
+ *
+ * @para obj address of OtpDataType
+ * @return _UPI_NULL_
+ */
+void ConvOtp2F0(OtpDataType *obj)
+{
+ _otp_u8_ value;
+
+ value = obj->otp2[OTP2_OFFSET_F0];
+
+ obj->productType = (value & (PRODUCT_TYPE_0 | PRODUCT_TYPE_1)) >> 3;
+
+ obj->deltaET = obj->deltaET + ((value & DELTA_ET_0) >> 5) + ((value & DELTA_ET_1) >> 6);
+
+ #ifdef UPI_UBOOT_DEBUG_MSG
+ printf("[ConvOtp2F0] Initial value of indexAdc2V100T25 = %d\n", obj->indexAdc2V100T25);
+ #endif ///< end of UPI_UBOOT_DEBUG_MSG
+ obj->indexAdc2V100T25 = obj->indexAdc2V100T25 + ((value & INDEX_ADC2_100_25_4) >> 2);
+}
+
+/**
+ * @brief ConvOtp2F1
+ *
+ * Convert OTP2 0xF1
+ *
+ * @para obj address of OtpDataType
+ * @return _UPI_NULL_
+ */
+void ConvOtp2F1(OtpDataType *obj)
+{
+}
+
+/**
+ * @brief ConvOtp2F2
+ *
+ * Convert OTP2 0xF2
+ *
+ * @para obj address of OtpDataType
+ * @return _UPI_NULL_
+ */
+void ConvOtp2F2(OtpDataType *obj)
+{
+ _otp_u8_ value;
+
+ value = obj->otp2[OTP2_OFFSET_F2];
+
+ obj->otpCellEN = obj->otpCellEN + ((value & (OTP_CELL_EN_0 |
+ OTP_CELL_EN_1 |
+ OTP_CELL_EN_2 |
+ OTP_CELL_EN_3 |
+ OTP_CELL_EN_4)) >> 3);
+}
+
+/**
+ * @brief ConvOtp2F3
+ *
+ * Convert OTP2 0xF3
+ *
+ * @para obj address of OtpDataType
+ * @return _UPI_NULL_
+ */
+void ConvOtp2F3(OtpDataType *obj)
+{
+}
+
+/**
+ * @brief ConvOtp2F4
+ *
+ * Convert OTP2 0xF4
+ *
+ * @para obj address of OtpDataType
+ * @return _UPI_NULL_
+ */
+void ConvOtp2F4(OtpDataType *obj)
+{
+ _otp_u8_ value;
+ _otp_u16_ tmp;
+
+ value = obj->otp2[OTP2_OFFSET_F4];
+
+ tmp = value & (ADC1_DELTA_CODE_25_200MV_8| ADC1_DELTA_CODE_25_200MV_9);
+ #ifdef UPI_UBOOT_DEBUG_MSG
+ printf("[ConvOtp2F4] Initial value of adc1DeltaCodeT25V200 = %d\n", obj->adc1DeltaCodeT25V200);
+ #endif ///< end of UPI_UBOOT_DEBUG_MSG
+ obj->adc1DeltaCodeT25V200 = obj->adc1DeltaCodeT25V200 + (tmp << 8);
+
+ tmp = value & (DEV_ADDR_7 | DEV_ADDR_8 | DEV_ADDR_9);
+ obj->devAddr = (tmp << 2) + ((value & (DEV_ADDR_0 | DEV_ADDR_1 | DEV_ADDR_2)) >> 2);
+}
+
+/**
+ * @brief ConvOtp2F5
+ *
+ * Convert OTP2 0xF5
+ *
+ * @para obj address of OtpDataType
+ * @return _UPI_NULL_
+ */
+void ConvOtp2F5(OtpDataType *obj)
+{
+ _otp_u8_ value;
+
+ value = obj->otp2[OTP2_OFFSET_F5];
+
+ obj->bgrTune = obj->bgrTune + ((value & (BGR_TUNE_0 |
+ BGR_TUNE_1 |
+ BGR_TUNE_2 |
+ BGR_TUNE_3 |
+ BGR_TUNE_4 |
+ BGR_TUNE_5)) >> 2);
+}
+
+/**
+ * @brief ConvOtp2F6
+ *
+ * Convert OTP2 0xF6
+ *
+ * @para obj address of OtpDataType
+ * @return _UPI_NULL_
+ */
+void ConvOtp2F6(OtpDataType *obj)
+{
+ _otp_u8_ value;
+
+ value = obj->otp2[OTP2_OFFSET_F6];
+
+ obj->oscDeltaCode25 = obj->oscDeltaCode25 + (value & (OSC_DELTA_CODE_25_0 |
+ OSC_DELTA_CODE_25_1 |
+ OSC_DELTA_CODE_25_2 |
+ OSC_DELTA_CODE_25_3 |
+ OSC_DELTA_CODE_25_4 |
+ OSC_DELTA_CODE_25_5 |
+ OSC_DELTA_CODE_25_6 |
+ OSC_DELTA_CODE_25_7));
+}
+
+/**
+ * @brief ConvOtp2F7
+ *
+ * Convert OTP2 0xF7
+ *
+ * @para obj address of OtpDataType
+ * @return _UPI_NULL_
+ */
+void ConvOtp2F7(OtpDataType *obj)
+{
+ _otp_u8_ value;
+
+ value = obj->otp2[OTP2_OFFSET_F7];
+
+ obj->oscDeltaCode80 = obj->oscDeltaCode80 + (value & (OSC_DELTA_CODE_80_0 |
+ OSC_DELTA_CODE_80_1 |
+ OSC_DELTA_CODE_80_2 |
+ OSC_DELTA_CODE_80_3 |
+ OSC_DELTA_CODE_80_4 |
+ OSC_DELTA_CODE_80_5 |
+ OSC_DELTA_CODE_80_6 |
+ OSC_DELTA_CODE_80_7));
+}
+
+/**
+ * @brief ConvOtp2F8
+ *
+ * Convert OTP2 0xF8
+ *
+ * @para obj address of OtpDataType
+ * @return _UPI_NULL_
+ */
+void ConvOtp2F8(OtpDataType *obj)
+{
+ _otp_u8_ value;
+
+ value = obj->otp2[OTP2_OFFSET_F8];
+
+ #ifdef UPI_UBOOT_DEBUG_MSG
+ printf("[ConvOtp2F8] Initial value of adc1DeltaCodeT25V200 = %d\n", obj->adc1DeltaCodeT25V200);
+ #endif ///< end of UPI_UBOOT_DEBUG_MSG
+ obj->adc1DeltaCodeT25V200 = obj->adc1DeltaCodeT25V200 + (value & (ADC1_DELTA_CODE_25_200MV_0 |
+ ADC1_DELTA_CODE_25_200MV_1 |
+ ADC1_DELTA_CODE_25_200MV_2 |
+ ADC1_DELTA_CODE_25_200MV_3 |
+ ADC1_DELTA_CODE_25_200MV_4 |
+ ADC1_DELTA_CODE_25_200MV_5 |
+ ADC1_DELTA_CODE_25_200MV_6 |
+ ADC1_DELTA_CODE_25_200MV_7));
+}
+
+/**
+ * @brief ConvOtp2F9
+ *
+ * Convert OTP2 0xF9
+ *
+ * @para obj address of OtpDataType
+ * @return _UPI_NULL_
+ */
+void ConvOtp2F9(OtpDataType *obj)
+{
+}
+
+/**
+ * @brief ConvOtp2FA
+ *
+ * Convert OTP2 0xFA
+ *
+ * @para obj address of OtpDataType
+ * @return _UPI_NULL_
+ */
+void ConvOtp2FA(OtpDataType *obj)
+{
+ _otp_u8_ value;
+
+ value = obj->otp2[OTP2_OFFSET_FA];
+
+ #ifdef UPI_UBOOT_DEBUG_MSG
+ printf("[ConvOtp2FA] Initial value of adc1DeltaCodeT25V100 = %d\n", obj->adc1DeltaCodeT25V100);
+ #endif ///< end of UPI_UBOOT_DEBUG_MSG
+ obj->adc1DeltaCodeT25V100 = obj->adc1DeltaCodeT25V100 + (value & (ADC1_DELTA_CODE_25_100MV_0 |
+ ADC1_DELTA_CODE_25_100MV_1 |
+ ADC1_DELTA_CODE_25_100MV_2 |
+ ADC1_DELTA_CODE_25_100MV_3 |
+ ADC1_DELTA_CODE_25_100MV_4 |
+ ADC1_DELTA_CODE_25_100MV_5 |
+ ADC1_DELTA_CODE_25_100MV_6 |
+ ADC1_DELTA_CODE_25_100MV_7));
+}
+
+/**
+ * @brief ConvOtp2FB
+ *
+ * Convert OTP2 0xFB
+ *
+ * @para obj address of OtpDataType
+ * @return _UPI_NULL_
+ */
+void ConvOtp2FB(OtpDataType *obj)
+{
+}
+
+/**
+ * @brief ConvOtp2FC
+ *
+ * Convert OTP2 0xFC
+ *
+ * @para obj address of OtpDataType
+ * @return _UPI_NULL_
+ */
+void ConvOtp2FC(OtpDataType *obj)
+{
+ _otp_u8_ value;
+ _otp_u16_ tmp;
+
+ value = obj->otp2[OTP2_OFFSET_FC];
+
+ tmp = value & ADC1_DELTA_CODE_25_100MV_8;
+ #ifdef UPI_UBOOT_DEBUG_MSG
+ printf("[ConvOtp2FC] Initial value of = %d\n", obj->adc1DeltaCodeT25V100);
+ #endif ///< end of UPI_UBOOT_DEBUG_MSG
+ obj->adc1DeltaCodeT25V100 = obj->adc1DeltaCodeT25V100 + (tmp << 8);
+
+ #ifdef UPI_UBOOT_DEBUG_MSG
+ printf("[ConvOtp2FC] Initial value of = %d\n", obj->adc2DeltaCodeT25V100);
+ #endif ///< end of UPI_UBOOT_DEBUG_MSG
+ obj->adc2DeltaCodeT25V100 = obj->adc2DeltaCodeT25V100 + ((value & (ADC2_DELTA_CODE_25_100MV_0 |
+ ADC2_DELTA_CODE_25_100MV_1 |
+ ADC2_DELTA_CODE_25_100MV_2 |
+ ADC2_DELTA_CODE_25_100MV_3 |
+ ADC2_DELTA_CODE_25_100MV_4 |
+ ADC2_DELTA_CODE_25_100MV_5 |
+ ADC2_DELTA_CODE_25_100MV_6)) >> 1);
+}
+
+/**
+ * @brief ConvOtp2FD
+ *
+ * Convert OTP2 0xFD
+ *
+ * @para obj address of OtpDataType
+ * @return _UPI_NULL_
+ */
+void ConvOtp2FD(OtpDataType *obj)
+{
+}
+
+/**
+ * @brief ConvOtp2FE
+ *
+ * Convert OTP2 0xFE
+ *
+ * @para obj address of OtpDataType
+ * @return _UPI_NULL_
+ */
+void ConvOtp2FE(OtpDataType *obj)
+{
+ _otp_u8_ value;
+
+ value = obj->otp2[OTP2_OFFSET_FE];
+
+ #ifdef UPI_UBOOT_DEBUG_MSG
+ printf("[ConvOtp2FE] Initial value of adc2DeltaCodeT25V200 = %d\n", obj->adc2DeltaCodeT25V200);
+ #endif ///< end of UPI_UBOOT_DEBUG_MSG
+ obj->adc2DeltaCodeT25V200 = obj->adc2DeltaCodeT25V200 + (value & (ADC2_DELTA_CODE_25_200MV_0 |
+ ADC2_DELTA_CODE_25_200MV_1 |
+ ADC2_DELTA_CODE_25_200MV_2 |
+ ADC2_DELTA_CODE_25_200MV_3 |
+ ADC2_DELTA_CODE_25_200MV_4 |
+ ADC2_DELTA_CODE_25_200MV_5 |
+ ADC2_DELTA_CODE_25_200MV_6 |
+ ADC2_DELTA_CODE_25_200MV_7));
+}
+
+/**
+ * @brief ConvOtp2FF
+ *
+ * Convert OTP2 0xFF
+ *
+ * @para obj address of OtpDataType
+ * @return _UPI_NULL_
+ */
+void ConvOtp2FF(OtpDataType *obj)
+{
+}
+
+/**
+ * @brief ConvOtp370
+ *
+ * Convert OTP3 0x70
+ *
+ * @para obj address of OtpDataType
+ * @return _UPI_NULL_
+ */
+void ConvOtp370(OtpDataType *obj)
+{
+ _otp_u8_ value;
+
+ value = obj->otp3[OTP3_OFFSET_70];
+
+ obj->deltaVref = obj->deltaVref + ((value & DELTA_VREF_4) << 4);
+
+ obj->deltaET = obj->deltaET + ((value & (DELTA_ET_2 | DELTA_ET_3)) << 1);
+
+ obj->aveIT25 = obj->aveIT25 + (value & (AVE_IT_25_3 | AVE_IT_25_4 | AVE_IT_25_5 | AVE_IT_25_6 | AVE_IT_25_7));
+}
+
+/**
+ * @brief ConvOtp371
+ *
+ * Convert OTP3 0x71
+ *
+ * @para obj address of OtpDataType
+ * @return _UPI_NULL_
+ */
+void ConvOtp371(OtpDataType *obj)
+{
+ _otp_u8_ value;
+ _otp_u16_ tmp;
+
+ value = obj->otp3[OTP3_OFFSET_71];
+
+ tmp = value & (AVE_IT_25_8 |
+ AVE_IT_25_9 |
+ AVE_IT_25_10 |
+ AVE_IT_25_11 |
+ AVE_IT_25_12 |
+ AVE_IT_25_13 |
+ AVE_IT_25_14 |
+ AVE_IT_25_15);
+ obj->aveIT25 = obj->aveIT25 + (tmp << 8);
+}
+
+/**
+ * @brief ConvOtp372
+ *
+ * Convert OTP3 0x72
+ *
+ * @para obj address of OtpDataType
+ * @return _UPI_NULL_
+ */
+void ConvOtp372(OtpDataType *obj)
+{
+ _otp_u8_ value;
+
+ value = obj->otp3[OTP3_OFFSET_72];
+
+ #ifdef UPI_UBOOT_DEBUG_MSG
+ printf("[ConvOtp372] Initial value of indexAdc2V200T25 = %d\n", obj->indexAdc2V200T25);
+ #endif ///< end of UPI_UBOOT_DEBUG_MSG
+ obj->indexAdc2V200T25 = obj->indexAdc2V200T25 + ((value & INDEX_ADC2_200_25_4) << 4);
+
+ #ifdef UPI_UBOOT_DEBUG_MSG
+ printf("[ConvOtp372] Initial value of indexAdc1V100T25 = %d\n", obj->indexAdc1V100T25);
+ #endif ///< end of UPI_UBOOT_DEBUG_MSG
+ obj->indexAdc1V100T25 = obj->indexAdc1V100T25 + ((value & INDEX_ADC1_100_25_4) << 3);
+
+ #ifdef UPI_UBOOT_DEBUG_MSG
+ printf("[ConvOtp372] Initial value of indexAdc1V200T25 = %d\n", obj->indexAdc1V200T25);
+ #endif ///< end of UPI_UBOOT_DEBUG_MSG
+ obj->indexAdc1V200T25 = obj->indexAdc1V200T25 + ((value & INDEX_ADC1_200_25_4) << 2);
+
+ obj->aveIT80 = obj->aveIT80 + (value & (AVE_IT_80_3 | AVE_IT_80_4 | AVE_IT_80_5 | AVE_IT_80_6 | AVE_IT_80_7));
+}
+
+/**
+ * @brief ConvOtp373
+ *
+ * Convert OTP3 0x73
+ *
+ * @para obj address of OtpDataType
+ * @return _UPI_NULL_
+ */
+void ConvOtp373(OtpDataType *obj)
+{
+ _otp_u8_ value;
+ _otp_u16_ tmp;
+
+ value = obj->otp3[OTP3_OFFSET_73];
+
+ tmp = value & (AVE_IT_80_8 |
+ AVE_IT_80_9 |
+ AVE_IT_80_10 |
+ AVE_IT_80_11 |
+ AVE_IT_80_12 |
+ AVE_IT_80_13 |
+ AVE_IT_80_14 |
+ AVE_IT_80_15);
+ obj->aveIT80 = obj->aveIT80 + (tmp << 8);
+}
+
+#define CONV_FUNC_PTR_NULL (0)
+
+typedef void (*ConvFuncPtr)(OtpDataType *obj);
+
+static ConvFuncPtr ConvFuncTable[] = {
+ ConvOtp1E0,
+ ConvOtp1E1,
+ ConvOtp1E2,
+ ConvOtp1E3,
+
+ ConvOtp2F0,
+ ConvOtp2F1,
+ ConvOtp2F2,
+ ConvOtp2F3,
+ ConvOtp2F4,
+ ConvOtp2F5,
+ ConvOtp2F6,
+ ConvOtp2F7,
+ ConvOtp2F8,
+ ConvOtp2F9,
+ ConvOtp2FA,
+ ConvOtp2FB,
+ ConvOtp2FC,
+ ConvOtp2FD,
+ ConvOtp2FE,
+ ConvOtp2FF,
+
+ ConvOtp370,
+ ConvOtp371,
+ ConvOtp372,
+ ConvOtp373,
+
+ CONV_FUNC_PTR_NULL,
+};
+
+/**
+ * @brief CheckOtpISEmpty
+ *
+ * Check OTP is empty or not
+ *
+ * @para data address of OtpDataType
+ * @return _UPI_NULL_
+ */
+void CheckOtpISEmpty(OtpDataType *data)
+{
+ _otp_u8_ idx;
+
+ /// [AT-PM] : Check OTP1 ; 01/25/2013
+ idx = 0;
+ while(idx < OTP1_SIZE)
+ {
+ if(data->otp1[idx] != 0)
+ {
+ data->empty = OTP_IS_NOT_EMPTY;
+ return;
+ }
+ }
+
+ /// [AT-PM] : Check OTP2 ; 01/25/2013
+ idx = 0;
+ while(idx < OTP2_SIZE)
+ {
+ if(data->otp2[idx] != 0)
+ {
+ data->empty = OTP_IS_NOT_EMPTY;
+ return;
+ }
+ }
+
+ /// [AT-PM] : Check OTP3 ; 01/25/2013
+ idx = 0;
+ while(idx < OTP3_SIZE)
+ {
+ if(data->otp3[idx] != 0)
+ {
+ data->empty = OTP_IS_NOT_EMPTY;
+ return;
+ }
+ }
+
+ /// [AT-PM] : Set OTP is empty ; 01/25/2013
+ data->empty = OTP_IS_EMPTY;
+}
+
+/// =============================================
+/// [AT-PM] : Extern function region
+/// =============================================
+
+/**
+ * @brief UpiConvertOtp
+ *
+ * Convert OTP register value to readable value
+ *
+ * @para data address of OtpDataType
+ * @return _UPI_NULL_
+ */
+void UpiConvertOtp(OtpDataType *data)
+{
+ _otp_u8_ idx;
+
+ UG31_LOGI("[%s]: OTP version : %d.%02x\n", __func__, UG31XX_OTP_VERSION_MAIN, UG31XX_OTP_VERSION_SUB);
+
+ /// [AT-PM] : Set version ; 01/25/2013
+ data->versionMain = UG31XX_OTP_VERSION_MAIN;
+ data->versionSub = UG31XX_OTP_VERSION_SUB;
+
+ /// [AT-PM] : Conversion ; 01/23/2013
+ idx = 0;
+ while(1)
+ {
+ (*ConvFuncTable[idx])(data);
+
+ idx = idx + 1;
+ if(ConvFuncTable[idx] == CONV_FUNC_PTR_NULL)
+ {
+ break;
+ }
+ }
+
+ /// [AT-PM] : Check OTP is empty ; 01/25/2013
+ CheckOtpISEmpty(data);
+}
+
diff --git a/board/wmt/wmt_battery/gauge/upi/uG31xx_API_Otp.h b/board/wmt/wmt_battery/gauge/upi/uG31xx_API_Otp.h
new file mode 100755
index 0000000..b80361f
--- /dev/null
+++ b/board/wmt/wmt_battery/gauge/upi/uG31xx_API_Otp.h
@@ -0,0 +1,84 @@
+/**
+ * @filename uG31xx_API_Otp.h
+ *
+ * Header of OTP conversion module
+ *
+ * @author AllenTeng <allen_teng@upi-semi.com>
+ */
+
+/// [AT-PM] : Product Type definition in OTP ; 01/23/2013
+enum UG31XX_PRODUCT_TYPE {
+ UG31XX_PRODUCT_TYPE_0 = 0,
+ UG31XX_PRODUCT_TYPE_1 = 1,
+ UG31XX_PRODUCT_TYPE_2 = 2,
+ UG31XX_PRODUCT_TYPE_3 = 3,
+};
+
+#define UG31XX_OTP_VERSION_MAIN (0x2013)
+#define UG31XX_OTP_VERSION_SUB (0x0110)
+
+#define OTP_IS_EMPTY (1)
+#define OTP_IS_NOT_EMPTY (0)
+
+#define OTP1_SIZE (4)
+#define OTP2_SIZE (16)
+#define OTP3_SIZE (4)
+
+typedef unsigned char _otp_u8_;
+typedef unsigned short _otp_u16_;
+
+typedef struct OtpDataST {
+
+ /// [AT-PM] : Version ; 01/23/2013
+ _otp_u16_ versionMain;
+ _otp_u16_ versionSub;
+ _otp_u8_ empty;
+
+ /// [AT-PM] : Raw data ; 01/23/2013
+ _otp_u8_ otp1[OTP1_SIZE];
+ _otp_u8_ otp2[OTP2_SIZE];
+ _otp_u8_ otp3[OTP3_SIZE];
+
+ /// [AT-PM] : Converted value ; 01/23/2013
+ _otp_u16_ adc1DeltaCodeT25V100;
+ _otp_u16_ adc1DeltaCodeT25V200;
+ _otp_u16_ adc2DeltaCodeT25V100;
+ _otp_u16_ adc2DeltaCodeT25V200;
+ _otp_u16_ aveIT25;
+ _otp_u16_ aveIT80;
+
+ _otp_u8_ bgrTune;
+
+ _otp_u8_ deltaET;
+ _otp_u8_ deltaVref;
+ _otp_u16_ devAddr;
+
+ _otp_u16_ ftIT;
+
+ _otp_u8_ indexAdc1V100T25;
+ _otp_u8_ indexAdc1V200T25;
+ _otp_u8_ indexAdc2V100T25;
+ _otp_u8_ indexAdc2V200T25;
+
+ _otp_u8_ oscDeltaCode25;
+ _otp_u8_ oscDeltaCode80;
+ _otp_u8_ otpCellEN;
+
+ _otp_u8_ productType;
+
+#if defined(uG31xx_OS_ANDROID)
+} __attribute__ ((aligned(4))) OtpDataType;
+#else ///< else of defined(uG31xx_OS_ANDROID)
+} OtpDataType;
+#endif ///< end of defined(uG31xx_OS_ANDROID)
+
+/**
+ * @brief UpiConvertOtp
+ *
+ * Convert OTP register value to readable value
+ *
+ * @para data address of OtpDataType
+ * @return _UPI_NULL_
+ */
+extern void UpiConvertOtp(OtpDataType *data);
+
diff --git a/board/wmt/wmt_battery/gauge/upi/uG31xx_API_System.c b/board/wmt/wmt_battery/gauge/upi/uG31xx_API_System.c
new file mode 100755
index 0000000..38dc9d1
--- /dev/null
+++ b/board/wmt/wmt_battery/gauge/upi/uG31xx_API_System.c
@@ -0,0 +1,1216 @@
+/**
+ * @filename uG31xx_API_System.cpp
+ *
+ * uG31xx system control
+ *
+ * @author AllenTeng <allen_teng@upi-semi.com>
+ */
+
+#include "stdafx.h" //windows need this??
+#include "uG31xx_API.h"
+
+#if defined(uG31xx_OS_ANDROID)
+
+_upi_bool_ ReadGGBXFileToCellDataAndInitSetting(SystemDataType *obj)
+{
+ _sys_u8_ *p_start = _UPI_NULL_;
+ _sys_u8_ *p_end = _UPI_NULL_;
+ _sys_u16_ sum16=0;
+ _sys_s32_ i=0;
+
+ /*
+ * check GGBX_FILE tag
+ */
+ if(obj->ggbXBuf->ggb_tag != GGBX_FILE_TAG)
+ {
+ UG31_LOGE("[%s] GGBX file tag not correct. tag: %08X\n", __func__, obj->ggbXBuf->ggb_tag);
+ return (_UPI_FALSE_);
+ }
+
+ /*
+ * check GGBX_FILE checksum
+ */
+ p_start = (_sys_u8_ *)obj->ggbXBuf + sizeof(GGBX_FILE_HEADER);
+ p_end = p_start + obj->ggbXBuf->length - 1;
+ for (; p_start <= p_end; p_start++)
+ {
+ sum16 += *p_start;
+ }
+
+ /* check done. prepare copy data */
+ memset(obj->ggbCellTable, 0x00, sizeof(CELL_TABLE));
+ memset(obj->ggbParameter, 0x00, sizeof(CELL_PARAMETER));
+
+ p_start = (_sys_u8_ *)obj->ggbXBuf + sizeof(GGBX_FILE_HEADER);
+ for (i=0; i<obj->ggbXBuf->num_ggb; i++)
+ {
+ /* TODO: boundary checking */
+ /* TODO: select right ggb content by sku */
+ memcpy(obj->ggbParameter, p_start, sizeof(CELL_PARAMETER));
+ memcpy(obj->ggbCellTable, p_start + sizeof(CELL_PARAMETER), sizeof(CELL_TABLE));
+ p_start += (sizeof(CELL_PARAMETER) + sizeof(CELL_TABLE));
+ }
+ return (_UPI_TRUE_);
+}
+
+#else ///< else of defined(uG31xx_OS_ANDROID)
+
+ _upi_bool_ ReadGGBFileToCellDataAndInitSetting(SystemDataType *obj)
+{
+ FILE* stream;
+ _wfopen_s(&stream, obj->ggbFilename, _T("rb, ccs=UTF-8"));
+
+ memset(obj->ggbCellTable, 0x00, sizeof(CELL_TABLE));
+ memset(obj->ggbParameter, 0x00, sizeof(CELL_PARAMETER));
+
+ if(!stream)
+ {
+ return (_UPI_FALSE_);
+ }
+ if(fread(obj->ggbParameter, sizeof(char), sizeof(CELL_PARAMETER), stream) != sizeof(CELL_PARAMETER))
+ {
+ fclose(stream);
+ return (_UPI_FALSE_);
+ }
+ if(fread(obj->ggbCellTable, sizeof(char), sizeof(CELL_TABLE), stream) != sizeof(CELL_TABLE))
+ {
+ fclose(stream);
+ return (_UPI_FALSE_);
+ }
+
+ fclose(stream);
+
+ return (_UPI_TRUE_);
+}
+
+#endif ///< end of defined(uG31xx_OS_ANDROID)
+
+/**
+ * @brief GetCellNum
+ *
+ * Get cell number from ggbParameter->ICType
+ *
+ * @para data address of SystemDataType
+ * @return _UPI_NULL_
+ */
+void GetCellNum(SystemDataType *data)
+{
+ _sys_u8_ cellNum[6] = {1, 1, 2, 0, 2, 3};
+
+ data->cellNum = cellNum[data->ggbParameter->ICType];
+}
+
+/**
+ * @brief SetupAdcChopFunction
+ *
+ * Setup ADC chop function
+ *
+ * @para data address of SystemDataType
+ * @return _UPI_NULL_
+ */
+void SetupAdcChopFunction(SystemDataType *data)
+{
+ API_I2C_SingleWrite(SECURITY,
+ UG31XX_I2C_HIGH_SPEED_MODE,
+ UG31XX_I2C_TEM_BITS_MODE,
+ REG_FW_CTRL,
+ data->ggbParameter->chopCtrl);
+}
+
+/**
+ * @brief SetupAdc1Queue
+ *
+ * Setup ADC1 conversion queue
+ *
+ * @para data address of SystemDataType
+ * @return _UPI_NULL_
+ */
+void SetupAdc1Queue(SystemDataType *data)
+{
+ _cap_u8_ adcQueue[4];
+
+ adcQueue[0] = SET_A_ET | SET_B_ET | SET_C_CURRENT | SET_D_CURRENT;
+ adcQueue[1] = SET_E_CURRENT | SET_F_CURRENT | SET_G_CURRENT | SET_H_CURRENT;
+ adcQueue[2] = SET_I_IT | SET_J_IT | SET_K_CURRENT | SET_L_CURRENT;
+ adcQueue[3] = SET_M_CURRENT | SET_N_CURRENT | SET_O_CURRENT | SET_P_CURRENT;
+
+ API_I2C_Write(SECURITY,
+ UG31XX_I2C_HIGH_SPEED_MODE,
+ UG31XX_I2C_TEM_BITS_MODE,
+ REG_ADC_CTR_A,
+ 4,
+ &adcQueue[0]);
+}
+
+/**
+ * @brief SetupAdc2Queue
+ *
+ * Set ADC2 conversion queue
+ *
+ * @para data address of SystemDataType
+ * @return _UPI_NULL_
+ */
+void SetupAdc2Quene(SystemDataType *data)
+{
+ _sys_u8_ adc2Queue[3];
+
+ /// [AT-PM] : Set sell type ; 01/31/2013
+ if(data->cellNum == 1)
+ {
+ adc2Queue[0] = SET_V1_VBAT1 | SET_V2_VBAT1 | SET_V3_VBAT1 | SET_V4_VBAT1;
+ adc2Queue[1] = SET_V5_VBAT1 | SET_V6_VBAT1 | SET_V7_VBAT1 | SET_V8_VBAT1;
+ adc2Queue[2] = SET_V9_VBAT1 | SET_V10_VBAT1 | SET_V11_VBAT1 | SET_V12_VBAT1;
+ }
+ else if(data->cellNum == 2)
+ {
+ adc2Queue[0] = SET_V1_VBAT1 | SET_V2_VBAT1 | SET_V3_VBAT2 | SET_V4_VBAT2;
+ adc2Queue[1] = SET_V5_VBAT1 | SET_V6_VBAT1 | SET_V7_VBAT2 | SET_V8_VBAT2;
+ adc2Queue[2] = SET_V9_VBAT1 | SET_V10_VBAT1 | SET_V11_VBAT2 | SET_V12_VBAT2;
+ }
+ else if(data->cellNum == 3)
+ {
+ adc2Queue[0] = SET_V1_VBAT1 | SET_V2_VBAT1 | SET_V3_VBAT2 | SET_V4_VBAT2;
+ adc2Queue[1] = SET_V5_VBAT3 | SET_V6_VBAT3 | SET_V7_VBAT1 | SET_V8_VBAT1;
+ adc2Queue[2] = SET_V9_VBAT2 | SET_V10_VBAT2 | SET_V11_VBAT3 | SET_V12_VBAT3;
+ }
+ else
+ {
+ /// [AT-PM] : 1-cell ; 01/31/2013
+ adc2Queue[0] = SET_V1_VBAT1 | SET_V2_VBAT1 | SET_V3_VBAT1 | SET_V4_VBAT1;
+ adc2Queue[1] = SET_V5_VBAT1 | SET_V6_VBAT1 | SET_V7_VBAT1 | SET_V8_VBAT1;
+ adc2Queue[2] = SET_V9_VBAT1 | SET_V10_VBAT1 | SET_V11_VBAT1 | SET_V12_VBAT1;
+ }
+ API_I2C_Write(SECURITY, UG31XX_I2C_HIGH_SPEED_MODE, UG31XX_I2C_TEM_BITS_MODE, REG_ADC_V1, 3, &adc2Queue[0]);
+}
+
+/**
+ * @brief EnableCbc
+ *
+ * Enable CBC function
+ *
+ * @para data address of SystemDataType
+ * @return _UPI_NULL_
+ */
+void EnableCbc(SystemDataType *data)
+{
+ _sys_u8_ tmp8;
+
+ API_I2C_SingleRead(SECURITY, UG31XX_I2C_HIGH_SPEED_MODE, UG31XX_I2C_TEM_BITS_MODE, REG_INTR_CTRL_B, &tmp8);
+ tmp8 = tmp8 & (~(INTR_CTRL_B_CBC_32_EN | INTR_CTRL_B_CBC_21_EN));
+ tmp8 = tmp8 | (INTR_CTRL_B_ET_EN | INTR_CTRL_B_IT_EN | INTR_CTRL_B_RID_EN);
+ tmp8 = tmp8 | (data->ggbParameter->cbcEnable << 4);
+ API_I2C_SingleWrite(SECURITY, UG31XX_I2C_HIGH_SPEED_MODE, UG31XX_I2C_TEM_BITS_MODE, REG_INTR_CTRL_B, tmp8);
+}
+
+/**
+ * @brief EnableICType
+ *
+ * Enable IC type
+ *
+ * @para data address of SystemDataType
+ * @return _UPI_NULL_
+ */
+void EnableICType(SystemDataType *data)
+{
+ _sys_u8_ tmp8;
+
+ API_I2C_SingleRead(SECURITY, UG31XX_I2C_HIGH_SPEED_MODE, UG31XX_I2C_TEM_BITS_MODE, REG_CELL_EN, &tmp8);
+ tmp8 = tmp8 & (~CELL_EN_APPLICATION);
+ tmp8 = tmp8 | (data->ggbParameter->ICType << 2);
+ API_I2C_SingleWrite(SECURITY, UG31XX_I2C_HIGH_SPEED_MODE, UG31XX_I2C_TEM_BITS_MODE, REG_CELL_EN, tmp8);
+}
+
+/**
+ * @brief ConfigGpioFunction
+ *
+ * Configure GPIO1/2 function
+ *
+ * @para setting GPIO1/2 setting
+ * @return register value
+ */
+_sys_u8_ ConfigGpioFunction(_sys_u8_ setting)
+{
+ _sys_u8_ gpioSelData = 0;
+
+ if(setting & FUN_GPIO)
+ {
+ gpioSelData = 0;
+ }
+ if(setting & FUN_ALARM) //select Alarm function
+ {
+ gpioSelData = 1;
+ }
+ if(setting & FUN_CBC_EN21) //cbc21 enable
+ {
+ gpioSelData = 2;
+ }if(setting & FUN_CBC_EN32) //cbc32 Enable
+ {
+ gpioSelData = 3;
+ }
+ if(setting & FUN_PWM) //PWM function, set PWM cycle
+ {
+ gpioSelData = 4;
+ }
+ return (gpioSelData);
+}
+
+/**
+ * @brief ConfigureGpio
+ *
+ * Configure GPIO function
+ *
+ * @para data SystemDataType
+ * @return _UPI_NULL_
+ */
+void ConfigureGpio(SystemDataType *data)
+{
+ _sys_u8_ tmp8;
+
+ API_I2C_SingleRead(SECURITY,
+ UG31XX_I2C_HIGH_SPEED_MODE,
+ UG31XX_I2C_TEM_BITS_MODE,
+ REG_INTR_CTRL_A,
+ &tmp8);
+ tmp8 = tmp8 | (ConfigGpioFunction(data->ggbParameter->gpio1) << 2);
+ tmp8 = tmp8 | (ConfigGpioFunction(data->ggbParameter->gpio2) << 5);
+ API_I2C_SingleWrite(SECURITY,
+ UG31XX_I2C_HIGH_SPEED_MODE,
+ UG31XX_I2C_TEM_BITS_MODE,
+ REG_INTR_CTRL_A,
+ tmp8);
+ API_I2C_SingleWrite(SECURITY,
+ UG31XX_I2C_HIGH_SPEED_MODE,
+ UG31XX_I2C_TEM_BITS_MODE,
+ REG_INTR_CTRL_D,
+ data->ggbParameter->gpio34);
+}
+
+#define ADC_FAIL_CRITERIA (10)
+
+/**
+ * @brief CheckAdcStatusFail
+ *
+ * Check ADC status is fail or not
+ *
+ * @para pUg31xx address of SystemDataType
+ * @return _UPI_TRUE_ if fail
+ */
+_upi_bool_ CheckAdcStatusFail(SystemDataType *data)
+{
+ API_I2C_Read(NORMAL,
+ UG31XX_I2C_HIGH_SPEED_MODE,
+ UG31XX_I2C_TEM_BITS_MODE,
+ REG_COUNTER_LOW,
+ REG_COUNTER_HIGH - REG_COUNTER_LOW + 1,
+ (unsigned char *)&data->adcCheckData.regCounter);
+
+ API_I2C_Read(NORMAL,
+ UG31XX_I2C_HIGH_SPEED_MODE,
+ UG31XX_I2C_TEM_BITS_MODE,
+ REG_AVE_VBAT1_LOW,
+ REG_AVE_VBAT1_HIGH - REG_AVE_VBAT1_LOW + 1,
+ (unsigned char *)&data->adcCheckData.regVbat1Ave);
+
+ /// [AT-PM] : Compare counter register ; 01/27/2013
+ if(data->adcCheckData.regCounter == data->adcCheckData.lastCounter)
+ {
+ data->adcCheckData.failCounterCurrent = data->adcCheckData.failCounterCurrent + 1;
+ UG31_LOGI("[%s]: Counter fixed (%d) ... %d\n", __func__,
+ data->adcCheckData.regCounter, data->adcCheckData.failCounterCurrent);
+ }
+ else
+ {
+ data->adcCheckData.failCounterCurrent = 0;
+ }
+ data->adcCheckData.lastCounter = data->adcCheckData.regCounter;
+
+ /// [AT-PM] : Compre VBat1 register ; 01/27/2013
+ if(data->adcCheckData.regVbat1Ave == data->adcCheckData.lastVBat1Ave)
+ {
+ data->adcCheckData.failCounterVoltage = data->adcCheckData.failCounterVoltage + 1;
+ UG31_LOGI("[%s]: VBat1 fixed (%d) ... %d\n", __func__,
+ data->adcCheckData.regVbat1Ave, data->adcCheckData.failCounterVoltage);
+ }
+ else
+ {
+ data->adcCheckData.failCounterVoltage = 0;
+ }
+ data->adcCheckData.lastVBat1Ave = data->adcCheckData.regVbat1Ave;
+
+ /// [AT-PM] : Check ADC fail criteria ; 01/27/2013
+ if(data->adcCheckData.failCounterCurrent > ADC_FAIL_CRITERIA)
+ {
+ data->adcCheckData.failCounterCurrent = 0;
+ return (_UPI_TRUE_);
+ }
+ if(data->adcCheckData.failCounterVoltage > ADC_FAIL_CRITERIA)
+ {
+ data->adcCheckData.failCounterVoltage = 0;
+ return (_UPI_TRUE_);
+ }
+ return (_UPI_FALSE_);
+}
+
+/**
+ * @brief DecimateRst
+ *
+ * Decimate reset filter of ADC
+ *
+ * @return _UPI_NULL_
+ */
+void DecimateRst(void)
+{
+ _sys_u8_ tmp8;
+
+ tmp8 = 0x00;
+ API_I2C_Read(NORMAL, UG31XX_I2C_HIGH_SPEED_MODE, UG31XX_I2C_TEM_BITS_MODE, REG_ALARM_EN, 1, &tmp8);
+ tmp8 = tmp8 & (~ALARM_EN_DECIMATE_RST);
+ API_I2C_Write(NORMAL, UG31XX_I2C_HIGH_SPEED_MODE, UG31XX_I2C_TEM_BITS_MODE, REG_ALARM_EN, 1, &tmp8);
+ tmp8 = tmp8 | ALARM_EN_DECIMATE_RST;
+ API_I2C_Write(NORMAL, UG31XX_I2C_HIGH_SPEED_MODE, UG31XX_I2C_TEM_BITS_MODE, REG_ALARM_EN, 1, &tmp8);
+ UG31_LOGI("[%s]: DECIMATE_RST\n", __func__);
+}
+
+/**
+ * @brief AlarmEnable
+ *
+ * Enable alarm
+ *
+ * @para alarm REG_ALARM_EN bits
+ * @return NULL
+ */
+void AlarmEnable(_sys_u8_ alarm)
+{
+ _sys_u8_ tmp8;
+
+ API_I2C_Read(NORMAL, UG31XX_I2C_HIGH_SPEED_MODE, UG31XX_I2C_TEM_BITS_MODE, REG_ALARM_EN, 1, &tmp8);
+ tmp8 = tmp8 | alarm;
+ API_I2C_Write(NORMAL, UG31XX_I2C_HIGH_SPEED_MODE, UG31XX_I2C_TEM_BITS_MODE, REG_ALARM_EN, 1, &tmp8);
+}
+
+/**
+ * @brief AlarmDisable
+ *
+ * Disable alarm
+ *
+ * @para alarm REG_ALARM_EN bits
+ * @return NULL
+ */
+void AlarmDisable(_sys_u8_ alarm)
+{
+ _sys_u8_ tmp8;
+
+ API_I2C_Read(NORMAL, UG31XX_I2C_HIGH_SPEED_MODE, UG31XX_I2C_TEM_BITS_MODE, REG_ALARM_EN, 1, &tmp8);
+ tmp8 = tmp8 & (~alarm);
+ API_I2C_Write(NORMAL, UG31XX_I2C_HIGH_SPEED_MODE, UG31XX_I2C_TEM_BITS_MODE, REG_ALARM_EN, 1, &tmp8);
+}
+
+#define SYS_ALARM_STS_UV1 (ALARM2_STATUS_UV1_ALARM)
+#define SYS_ALARM_STS_OV1 (ALARM2_STATUS_OV1_ALARM)
+#define SYS_ALARM_STS_UV2 (ALARM2_STATUS_UV2_ALARM)
+#define SYS_ALARM_STS_OV2 (ALARM2_STATUS_OV2_ALARM)
+#define SYS_ALARM_STS_UV3 (ALARM2_STATUS_UV3_ALARM)
+#define SYS_ALARM_STS_OV3 (ALARM2_STATUS_OV3_ALARM)
+#define SYS_ALARM_STS_UET (ALARM1_STATUS_UET_ALARM<<8)
+#define SYS_ALARM_STS_OET (ALARM1_STATUS_OET_ALARM<<8)
+#define SYS_ALARM_STS_UIT (ALARM1_STATUS_UIT_ALARM<<8)
+#define SYS_ALARM_STS_OIT (ALARM1_STATUS_OIT_ALARM<<8)
+#define SYS_ALARM_STS_DOC (ALARM1_STATUS_DOC_ALARM<<8)
+#define SYS_ALARM_STS_COC (ALARM1_STATUS_COC_ALARM<<8)
+
+/**
+ * @brief ProcUVAlarm
+ *
+ * UV alarm function
+ *
+ * @para data address of SystemDataType
+ * @return NULL
+ */
+void ProcUVAlarm(SystemDataType *data)
+{
+ _sys_u8_ tmp8[4];
+
+ /// [AT-PM] : Check alarm is enable or not ; 04/08/2013
+ if(!(data->ggbParameter->alarmEnable & CELL_PARAMETER_ALARM_EN_UV))
+ {
+ /// [AT-PM] : Disable UV and OV alarm ; 04/08/2013
+ AlarmDisable(ALARM_EN_V1_ALARM_EN);
+ return;
+ }
+
+ if(data->uvAlarm.state == _UPI_TRUE_)
+ {
+ /// [AT-PM] : UV alarm has been set -> Wait for OV alarm ; 04/08/2013
+ if(data->alarmSts & SYS_ALARM_STS_OV1)
+ {
+ data->uvAlarm.state = _UPI_FALSE_;
+
+ /// [AT-PM] : Release UV alarm by disable ; 04/08/2013
+ AlarmDisable(ALARM_EN_V1_ALARM_EN);
+
+ /// [AT-PM] : UV release threshold reached -> set alarm threshold ; 04/08/2013
+ tmp8[0] = 0xff;
+ tmp8[1] = 0x7f;
+ tmp8[2] = (_sys_u8_)(data->uvAlarm.alarmThrd & 0x00ff);
+ tmp8[3] = (_sys_u8_)(data->uvAlarm.alarmThrd >> 8);
+ }
+ else
+ {
+ /// [AT-PM] : UV state -> set release threshold ; 04/08/2013
+ tmp8[0] = (_sys_u8_)(data->uvAlarm.releaseThrd & 0x00ff);
+ tmp8[1] = (_sys_u8_)(data->uvAlarm.releaseThrd >> 8);
+ tmp8[2] = 0x00;
+ tmp8[3] = 0x00;
+ }
+ }
+ else
+ {
+ /// [AT-PM] : Normal state ; 04/08/2013
+ if(data->alarmSts & SYS_ALARM_STS_UV1)
+ {
+ data->uvAlarm.state = _UPI_TRUE_;
+
+ /// [AT-PM] : Release UV alarm by disable ; 04/08/2013
+ AlarmDisable(ALARM_EN_V1_ALARM_EN);
+
+ /// [AT-PM] : UV alarm reached -> set release threshold ; 04/08/2013
+ tmp8[0] = (_sys_u8_)(data->uvAlarm.releaseThrd & 0x00ff);
+ tmp8[1] = (_sys_u8_)(data->uvAlarm.releaseThrd >> 8);
+ tmp8[2] = 0x00;
+ tmp8[3] = 0x00;
+ }
+ else
+ {
+ /// [AT-PM] : Normal state -> set alarm threshold ; 04/08/2013
+ tmp8[0] = 0xff;
+ tmp8[1] = 0x7f;
+ tmp8[2] = (_sys_u8_)(data->uvAlarm.alarmThrd & 0x00ff);
+ tmp8[3] = (_sys_u8_)(data->uvAlarm.alarmThrd >> 8);
+ }
+ }
+
+ /// [AT-PM] : Set alarm threshold ; 04/08/2013
+ API_I2C_Write(SECURITY, UG31XX_I2C_HIGH_SPEED_MODE, UG31XX_I2C_TEM_BITS_MODE, REG_OV1_LOW, 4, &tmp8[0]);
+
+ /// [AT-PM] : Enable UV and OV alarm ; 04/08/2013
+ AlarmEnable(ALARM_EN_V1_ALARM_EN);
+}
+
+/**
+ * @brief ProcETAlarm
+ *
+ * UET and OET alarm function
+ *
+ * @para data address of SystemDataType
+ * @return NULL
+ */
+void ProcETAlarm(SystemDataType *data)
+{
+ _sys_u8_ tmp8[4];
+
+ /// [AT-PM] : Check alarm is enable or not ; 04/08/2013
+ if(!(data->ggbParameter->alarmEnable & (CELL_PARAMETER_ALARM_EN_UET | CELL_PARAMETER_ALARM_EN_OET)))
+ {
+ /// [AT-PM] : Disable UV and OV alarm ; 04/08/2013
+ AlarmDisable(ALARM_EN_ET_ALARM_EN);
+ return;
+ }
+
+ if(data->uetAlarm.state == _UPI_TRUE_)
+ {
+ /// [AT-PM] : UET alarm state -> wait for OET alarm ; 04/08/2013
+ if(data->alarmSts & SYS_ALARM_STS_OET)
+ {
+ data->uetAlarm.state = _UPI_FALSE_;
+
+ /// [AT-PM] : Release by disable ; 04/08/2013
+ AlarmDisable(ALARM_EN_ET_ALARM_EN);
+
+ /// [AT-PM] : UET release met -> set UET and OET alarm ; 04/08/2013
+ tmp8[0] = (_sys_u8_)(data->oetAlarm.alarmThrd & 0x00ff);
+ tmp8[1] = (_sys_u8_)(data->oetAlarm.alarmThrd >> 8);
+ tmp8[2] = (_sys_u8_)(data->uetAlarm.alarmThrd & 0x00ff);
+ tmp8[3] = (_sys_u8_)(data->uetAlarm.alarmThrd >> 8);
+ }
+ else
+ {
+ /// [AT-PM] : Wait OET alarm ; 04/08/2013
+ tmp8[0] = (_sys_u8_)(data->uetAlarm.releaseThrd & 0x00ff);
+ tmp8[1] = (_sys_u8_)(data->uetAlarm.releaseThrd >> 8);
+ tmp8[2] = 0x00;
+ tmp8[3] = 0x00;
+ }
+ }
+ else if(data->oetAlarm.state == _UPI_TRUE_)
+ {
+ /// [AT-PM] : OET alarm state -> wait for UET alarm ; 04/08/2013
+ if(data->alarmSts & SYS_ALARM_STS_UET)
+ {
+ data->oetAlarm.state = _UPI_FALSE_;
+
+ /// [AT-PM] : Release by disable ; 04/08/2013
+ AlarmDisable(ALARM_EN_ET_ALARM_EN);
+
+ /// [AT-PM] : OET release met -> set UET and OET alarm ; 04/08/2013
+ tmp8[0] = (_sys_u8_)(data->oetAlarm.alarmThrd & 0x00ff);
+ tmp8[1] = (_sys_u8_)(data->oetAlarm.alarmThrd >> 8);
+ tmp8[2] = (_sys_u8_)(data->uetAlarm.alarmThrd & 0x00ff);
+ tmp8[3] = (_sys_u8_)(data->uetAlarm.alarmThrd >> 8);
+ }
+ else
+ {
+ /// [AT-PM] : Wait UET alarm ; 04/08/2013
+ tmp8[0] = 0xff;
+ tmp8[1] = 0x7f;
+ tmp8[2] = (_sys_u8_)(data->oetAlarm.releaseThrd & 0x00ff);
+ tmp8[3] = (_sys_u8_)(data->oetAlarm.releaseThrd >> 8);
+ }
+ }
+ else
+ {
+ /// [AT-PM] : Normal state ; 04/08/2013
+ if((data->alarmSts & SYS_ALARM_STS_UET) &&
+ (data->ggbParameter->alarmEnable & CELL_PARAMETER_ALARM_EN_UET))
+ {
+ data->uetAlarm.state = _UPI_TRUE_;
+
+ /// [AT-PM] : Release by disable ; 04/08/2013
+ AlarmDisable(ALARM_EN_ET_ALARM_EN);
+
+ /// [AT-PM] : UET is set -> set UET release threshold ; 04/08/2013
+ tmp8[0] = (_sys_u8_)(data->uetAlarm.releaseThrd & 0x00ff);
+ tmp8[1] = (_sys_u8_)(data->uetAlarm.releaseThrd >> 8);
+ tmp8[2] = 0x00;
+ tmp8[3] = 0x00;
+ }
+ else if((data->alarmSts & SYS_ALARM_STS_OET) &&
+ (data->ggbParameter->alarmEnable & CELL_PARAMETER_ALARM_EN_OET))
+ {
+ data->oetAlarm.state = _UPI_TRUE_;
+
+ /// [AT-PM] : Release by disable ; 04/08/2013
+ AlarmDisable(ALARM_EN_ET_ALARM_EN);
+
+ /// [AT-PM] : OET is set -> set OET release threshold ; 04/08/2013
+ tmp8[0] = 0xff;
+ tmp8[1] = 0x7f;
+ tmp8[2] = (_sys_u8_)(data->oetAlarm.releaseThrd & 0x00ff);
+ tmp8[3] = (_sys_u8_)(data->oetAlarm.releaseThrd >> 8);
+ }
+ else
+ {
+ /// [AT-PM] : Set OET alarm threshold ; 04/08/2013
+ if(data->ggbParameter->alarmEnable & CELL_PARAMETER_ALARM_EN_OET)
+ {
+ tmp8[0] = (_sys_u8_)(data->oetAlarm.alarmThrd & 0x00ff);
+ tmp8[1] = (_sys_u8_)(data->oetAlarm.alarmThrd >> 8);
+ }
+ else
+ {
+ tmp8[0] = 0xff;
+ tmp8[1] = 0x7f;
+ }
+ /// [AT-PM] : Set UET alarm threshold ; 04/11/2013
+ if(data->ggbParameter->alarmEnable & CELL_PARAMETER_ALARM_EN_UET)
+ {
+ tmp8[2] = (_sys_u8_)(data->uetAlarm.alarmThrd & 0x00ff);
+ tmp8[3] = (_sys_u8_)(data->uetAlarm.alarmThrd >> 8);
+ }
+ else
+ {
+ tmp8[2] = 0x00;
+ tmp8[3] = 0x00;
+ }
+ }
+ }
+
+ /// [AT-PM] : Set alarm threshold ; 04/08/2013
+ API_I2C_Write(SECURITY, UG31XX_I2C_HIGH_SPEED_MODE, UG31XX_I2C_TEM_BITS_MODE, REG_EXTR_OVER_TEMP_LOW, 4, &tmp8[0]);
+
+ /// [AT-PM] : Enable UV and OV alarm ; 04/08/2013
+ AlarmEnable(ALARM_EN_ET_ALARM_EN);
+}
+
+/**
+ * @brief EnableAlarm
+ *
+ * Set UV, UET, and OET alarm functions
+ *
+ * @para data address of SystemDataType
+ * @return NULL
+ */
+void EnableAlarm(SystemDataType *data)
+{
+ /// [AT-PM] : UV alarm ; 04/08/2013
+ ProcUVAlarm(data);
+
+ /// [AT-PM] : UET and OET alarm ; 04/08/2013
+ ProcETAlarm(data);
+}
+
+/// =============================================
+/// [AT-PM] : Extern function region
+/// =============================================
+
+/**
+ * @brief UpiInitSystemData
+ *
+ * Initialize system variables
+ *
+ * @para data address of SystemDataType
+ * @return SYSTEM_RTN_CODE
+ */
+SYSTEM_RTN_CODE UpiInitSystemData(SystemDataType *data)
+{
+ /// [AT-PM] : Initialize variables ; 01/30/2013
+ data->preITAve = 0;
+ data->cellNum = 0;
+
+ /// [AT-PM] : Load GGB file ; 01/30/2013
+ UG31_LOGI("[%s]: Read GGB\n", __func__);
+ #if defined(uG31xx_OS_ANDROID)
+ if(!ReadGGBXFileToCellDataAndInitSetting(data))
+ #else
+ if(!ReadGGBFileToCellDataAndInitSetting(data))
+ #endif
+ {
+ return (SYSTEM_RTN_READ_GGB_FAIL);
+ }
+
+ /// [AT-PM] : Set cell number ; 01/31/2013
+ GetCellNum(data);
+ return (SYSTEM_RTN_PASS);
+}
+
+/**
+ * @brief UpiCheckICActive
+ *
+ * Check IC is actived or not
+ *
+ * @return _UPI_TRUE_ if uG31xx is not actived
+ */
+_upi_bool_ UpiCheckICActive(void)
+{
+ _upi_u8_ tmp;
+
+ if(!API_I2C_Read(NORMAL, UG31XX_I2C_HIGH_SPEED_MODE, UG31XX_I2C_TEM_BITS_MODE, REG_MODE, 1, &tmp))
+ {
+ UG31_LOGI("[%s]: Get GG_RUN fail.\n", __func__);
+ return (_UPI_TRUE_);
+ }
+
+ if((tmp & MODE_GG_RUN) == GG_RUN_OPERATION_MODE)
+ {
+ UG31_LOGI("[%s]: uG31xx is actived.\n", __func__);
+ return (_UPI_FALSE_);
+ }
+ UG31_LOGI("[%s]: uG31xx is NOT actived.\n", __func__);
+ return (_UPI_TRUE_);
+}
+
+/**
+ * @brief UpiActiveUg31xx
+ *
+ * Active uG31xx
+ *
+ * @return SYSTEM_RTN_CODE
+ */
+SYSTEM_RTN_CODE UpiActiveUg31xx(void)
+{
+ _sys_u8_ tmp8;
+
+ /// [AT-PM] : Reset uG31xx ; 01/31/2013
+ tmp8 = PORDET_W_SOFTRESET | IO1DATA_W_HIGH;
+ if(!API_I2C_Write(NORMAL, UG31XX_I2C_HIGH_SPEED_MODE, UG31XX_I2C_TEM_BITS_MODE, REG_CTRL1, 1, &tmp8))
+ {
+ return (SYSTEM_RTN_I2C_FAIL);
+ }
+ tmp8 = IO1DATA_W_HIGH;
+ if(!API_I2C_Write(NORMAL, UG31XX_I2C_HIGH_SPEED_MODE, UG31XX_I2C_TEM_BITS_MODE, REG_CTRL1, 1, &tmp8))
+ {
+ return (SYSTEM_RTN_I2C_FAIL);
+ }
+
+ /// [AT-PM] : Active uG31xx ; 01/31/2013
+ tmp8 = CTRL1_GG_RST | IO1DATA_W_HIGH;
+ if(!API_I2C_Write(NORMAL, UG31XX_I2C_HIGH_SPEED_MODE, UG31XX_I2C_TEM_BITS_MODE, REG_CTRL1, 1, &tmp8))
+ {
+ return (SYSTEM_RTN_I2C_FAIL);
+ }
+ tmp8 = GG_RUN_OPERATION_MODE;
+ if(!API_I2C_Write(NORMAL, UG31XX_I2C_HIGH_SPEED_MODE, UG31XX_I2C_TEM_BITS_MODE, REG_MODE, 1, &tmp8))
+ {
+ return (SYSTEM_RTN_I2C_FAIL);
+ }
+
+ /// [AT-PM] : Delay 255mS for system stable ; 01/31/2013
+ SleepMiniSecond(255); //2012/08/29/Jacky, need wait 255 ms
+ return (SYSTEM_RTN_PASS);
+}
+
+/**
+ * @brief UpiSetupAdc
+ *
+ * Setup ADC configurations
+ *
+ * @para data address of SystemDataType
+ * @return _UPI_NULL_
+ */
+void UpiSetupAdc(SystemDataType *data)
+{
+ _sys_u8_ tmp8;
+
+ /// [AT-PM] : Set ADC chop function ; 01/31/2013
+ SetupAdcChopFunction(data);
+
+ /// [AT-PM] : Set ADC1 queue ; 01/31/2013
+ SetupAdc1Queue(data);
+
+ /// [AT-PM] : Set ADC2 queue ; 01/31/2013
+ SetupAdc2Quene(data);
+
+ /// [AT-PM] : Enable ADC ; 01/31/2013
+ API_I2C_SingleRead(SECURITY, UG31XX_I2C_HIGH_SPEED_MODE, UG31XX_I2C_TEM_BITS_MODE, REG_INTR_CTRL_A, &tmp8);
+ tmp8 = tmp8 | (INTR_CTRL_A_ADC2_EN | INTR_CTRL_A_ADC1_EN);
+ API_I2C_SingleWrite(SECURITY, UG31XX_I2C_HIGH_SPEED_MODE, UG31XX_I2C_TEM_BITS_MODE, REG_INTR_CTRL_A, tmp8);
+
+ /// [AT-PM] : Decimate reset ; 01/31/2013
+ DecimateRst();
+
+ /// [AT-PM] : Enable CBC function ; 01/31/2013
+ EnableCbc(data);
+}
+
+/**
+ * @brief UpiSetupSystem
+ *
+ * Setup uG31xx system
+ *
+ * @para data address of SystemDataType
+ * @return _UPI_NULL_
+ */
+void UpiSetupSystem(SystemDataType *data)
+{
+ _sys_u8_ tmp8;
+
+ /// [AT-PM] : Enable IC type ; 01/31/2013
+ EnableICType(data);
+
+ /// [AT-PM] : Configure GPIO ; 01/31/2013
+ ConfigureGpio(data);
+
+ /// [AT-PM] : Enable cell ; 01/31/2013
+ API_I2C_SingleRead(SECURITY, UG31XX_I2C_HIGH_SPEED_MODE, UG31XX_I2C_TEM_BITS_MODE, REG_CELL_EN, &tmp8);
+ tmp8 = tmp8 | (CELL_EN1 | CELL_EN0);
+ API_I2C_SingleWrite(SECURITY, UG31XX_I2C_HIGH_SPEED_MODE, UG31XX_I2C_TEM_BITS_MODE, REG_CELL_EN, tmp8);
+}
+
+#define OSC_CNT_TARG 512 //oscCntTarg[9:0]
+
+/**
+ * @brief UpiCalibrationOsc
+ *
+ * OSC calibration
+ * oscCnt25[9:0] = oscCntTarg[9:0] + oscDeltaCode25[7:0]
+ * oscCnt80[9:0] = oscCntTarg[9:0] + oscDeltaCode80[7:0]
+ * oscCnt[9:0] = m*ITcode[15:8] + C[9:0]
+ * m = (oscCnt80[9:0]-oscCnt25[9:0])/(iTcode80[7:0]-iTcode25[7:0])
+ * c = oscCnt25[9:0] - m*ITcode25[7:0]
+ * write oscCnt[9:0] to register 0x97-98
+ *
+ * @para data address of SystemDataType
+ * @return _UPI_NULL_
+ */
+void UpiCalibrationOsc(SystemDataType *data)
+{
+ _sys_u16_ u16Temp;
+
+ _sys_u16_ oscCnt25;
+ _sys_u16_ oscCnt80; //10 bits
+ _sys_u16_ oscDeltaCode25;
+ _sys_u16_ oscDeltaCode80; //
+ _sys_u16_ targetOscCnt; //target osc
+
+ _sys_u16_ varM;
+ _sys_u16_ varC;
+
+ _sys_u16_ aveIT;
+
+ /// [AT-PM] : Calculate m & C ; 01/25/2013
+ oscDeltaCode25 = (_sys_u16_)data->otpData->oscDeltaCode25;
+ oscDeltaCode80 = (_sys_u16_)data->otpData->oscDeltaCode80;
+
+ oscCnt25 = OSC_CNT_TARG + oscDeltaCode25;
+ oscCnt80 = OSC_CNT_TARG + oscDeltaCode80;
+
+ varM = (oscCnt80 - oscCnt25)/(data->otpData->aveIT80 - data->otpData->aveIT25);
+ varC = oscCnt25 - varM*(data->otpData->aveIT25);
+
+ /// [AT-PM] : Read ITAve ; 01/27/2013
+ API_I2C_Read(NORMAL,
+ UG31XX_I2C_HIGH_SPEED_MODE,
+ UG31XX_I2C_TEM_BITS_MODE,
+ REG_AVE_IT_LOW,
+ REG_AVE_IT_HIGH - REG_AVE_IT_LOW + 1,
+ (_sys_u8_ *)&aveIT);
+
+ /// [AT-PM] : Calculate target OSC cnt ; 01/25/2013
+ targetOscCnt = varM*(aveIT/256) + varC;
+ if(targetOscCnt & 0x8000) //check +/-
+ {
+ u16Temp = (_sys_u16_)(targetOscCnt & 0x1fff);
+ u16Temp |= 0x0200; // minus
+ } else{
+ u16Temp = (_sys_u16_)targetOscCnt; //positive data
+ }
+
+ /// [AT-PM] : Write to register 0x97-98 ; 01/25/2013
+ API_I2C_SingleWrite(SECURITY,
+ UG31XX_I2C_HIGH_SPEED_MODE,
+ UG31XX_I2C_TEM_BITS_MODE,
+ OSCTUNE_CNTB,
+ (_sys_u8_)(u16Temp >> 8));
+ API_I2C_SingleWrite(SECURITY,
+ UG31XX_I2C_HIGH_SPEED_MODE,
+ UG31XX_I2C_TEM_BITS_MODE,
+ OSCTUNE_CNTA,
+ (_sys_u8_)u16Temp );
+}
+
+/**
+ * @brief UpiAdcStatus
+ *
+ * Check ADC status
+ *
+ * @para data address of SystemDataType
+ * @return _UPI_NULL_
+ */
+void UpiAdcStatus(SystemDataType *data)
+{
+ if(CheckAdcStatusFail(data) == _UPI_TRUE_) //check ADC Code frozen
+ {
+ DecimateRst();
+ }
+}
+
+#define BACKUP_TIME_BYTE3 (REG_COC_LOW)
+#define BACKUP_TIME_BYTE2 (REG_OTP_CTRL)
+#define BACKUP_NAC_HIGH (REG_CBC21_LOW)
+#define BACKUP_NAC_LOW (REG_CBC21_HIGH)
+#define BACKUP_LMD_HIGH (REG_CBC32_LOW)
+#define BACKUP_LMD_LOW (REG_CBC32_HIGH)
+#define BACKUP_TABLE_UPDATE_IDX (REG_COC_HIGH)
+#define BACKUP_DELTA_CAP_HIGH (REG_DOC_LOW)
+#define BACKUP_DELTA_CAP_LOW (REG_DOC_HIGH)
+#define BACKUP_ADC1_CONV_TIME (REG_COC_HIGH)
+
+/**
+ * @brief UpiLoadBatInfoFromIC
+ *
+ * Load battery information from uG31xx
+ *
+ * @para data address of SystemDataType
+ * @return _UPI_NULL_
+ */
+void UpiLoadBatInfoFromIC(SystemDataType *data)
+{
+ _sys_u8_ *u8Ptr;
+ _sys_u8_ u8Temp;
+ _sys_u8_ u8TempHigh;
+ _sys_u32_ u32Temp;
+ _sys_u16_ u16Temp;
+
+ //Load the time tag
+ u8Ptr = (_sys_u8_ *)&data->timeTagFromIC;
+ *u8Ptr = 0;
+ *(u8Ptr + 1) = 0;
+ API_I2C_SingleRead(SECURITY, UG31XX_I2C_HIGH_SPEED_MODE, UG31XX_I2C_TEM_BITS_MODE, BACKUP_TIME_BYTE2, &u8Temp);
+ *(u8Ptr + 2) = u8Temp;
+ API_I2C_SingleRead(SECURITY, UG31XX_I2C_HIGH_SPEED_MODE, UG31XX_I2C_TEM_BITS_MODE, BACKUP_TIME_BYTE3, &u8Temp);
+ *(u8Ptr + 3) = u8Temp;
+
+ //Load the NAC
+ API_I2C_SingleRead(SECURITY, UG31XX_I2C_HIGH_SPEED_MODE, UG31XX_I2C_TEM_BITS_MODE, BACKUP_NAC_HIGH, &u8TempHigh);
+ API_I2C_SingleRead(SECURITY, UG31XX_I2C_HIGH_SPEED_MODE, UG31XX_I2C_TEM_BITS_MODE, BACKUP_NAC_LOW, &u8Temp);
+ data->rmFromIC = (_sys_u16_)u8TempHigh;
+ data->rmFromIC = data->rmFromIC*256 + u8Temp;
+
+ // Load LMD
+ API_I2C_SingleRead(SECURITY, UG31XX_I2C_HIGH_SPEED_MODE, UG31XX_I2C_TEM_BITS_MODE, BACKUP_LMD_HIGH, &u8TempHigh);
+ API_I2C_SingleRead(SECURITY, UG31XX_I2C_HIGH_SPEED_MODE, UG31XX_I2C_TEM_BITS_MODE, BACKUP_LMD_LOW, &u8Temp);
+ data->fccFromIC = (_sys_u16_)u8TempHigh;
+ data->fccFromIC = data->fccFromIC*256 + u8Temp;
+ UG31_LOGE("[%s]:timeTag =%u/%x ms,NAC = %d mAh,LMD = %dmAh\n",
+ __func__,
+ data->timeTagFromIC,
+ data->timeTagFromIC,
+ data->rmFromIC,
+ data->fccFromIC);
+
+ /// [AT-PM] : Load table update index ; 02/10/2013
+ API_I2C_SingleRead(NORMAL, UG31XX_I2C_HIGH_SPEED_MODE, UG31XX_I2C_TEM_BITS_MODE, BACKUP_TABLE_UPDATE_IDX, &u8Temp);
+ data->tableUpdateIdxFromIC = u8Temp & 0x07;
+ UG31_LOGI("[%s]: Table Update Index From IC = %d (0x%02x)\n", __func__, data->tableUpdateIdxFromIC, u8Temp);
+
+ /// [AT-PM] : Load delta capacity ; 02/10/2013
+ API_I2C_SingleRead(SECURITY, UG31XX_I2C_HIGH_SPEED_MODE, UG31XX_I2C_TEM_BITS_MODE, BACKUP_DELTA_CAP_HIGH, &u8TempHigh);
+ API_I2C_SingleRead(NORMAL, UG31XX_I2C_HIGH_SPEED_MODE, UG31XX_I2C_TEM_BITS_MODE, BACKUP_DELTA_CAP_LOW, &u8Temp);
+ data->deltaCapFromIC = (_sys_u16_)u8TempHigh;
+ data->deltaCapFromIC = data->deltaCapFromIC*256 + u8Temp;
+ UG31_LOGI("[%s]: Delta Capacity From IC = %d (0x%02x%02x)\n", __func__, data->deltaCapFromIC, u8TempHigh, u8Temp);
+
+ /// [AT-PM] : Load ADC1 conversion time ; 02/10/2013
+ API_I2C_SingleRead(SECURITY, UG31XX_I2C_HIGH_SPEED_MODE, UG31XX_I2C_TEM_BITS_MODE, BACKUP_ADC1_CONV_TIME, &u8Temp);
+ u16Temp = (_sys_u16_)(u8Temp & 0xf8);
+ data->adc1ConvTime = u16Temp*TIME_CONVERT_TIME_TO_MSEC;
+ UG31_LOGI("[%s]: ADC1 Conversion Time From IC = %d (0x%02x)\n", __func__, data->adc1ConvTime, u8Temp);
+
+ /// [AT-PM] : Get RSOC ; 01/31/2013
+ if(data->fccFromIC == 0)
+ {
+ data->rsocFromIC = 0;
+ }
+ else
+ {
+ u32Temp = (_sys_u32_)data->rmFromIC;
+ u32Temp = u32Temp*100 + 50;
+ u32Temp = u32Temp/data->fccFromIC;
+ data->rsocFromIC = (_sys_u8_)u32Temp;
+ }
+
+ data->rmFromICBackup = data->rmFromIC;
+ data->fccFromICBackup = data->fccFromIC;
+ data->rsocFromICBackup = data->rsocFromIC;
+}
+
+/**
+ * @brief UpiUpdateBatInfoFromIC
+ *
+ * Update battery information from uG31xx
+ *
+ * @para data address of SystemDataType
+ * @para deltaQ delta capacity from coulomb counter
+ * @return _UPI_NULL_
+ */
+void UpiUpdateBatInfoFromIC(SystemDataType *data, _sys_s16_ deltaQ)
+{
+ _sys_s32_ tmp32;
+ _sys_u16_ oldRM;
+
+ oldRM = data->rmFromIC;
+
+ tmp32 = (_sys_s32_)data->rmFromIC;
+ tmp32 = tmp32 + deltaQ;
+ #ifdef UPI_UBOOT_DEBUG_MSG
+ printf("[UpiUpdateBatInfoFromIC] RM = %d + %d = %d\n", data->rmFromIC, deltaQ, tmp32);
+ #endif ///< end of UPI_UBOOT_DEBUG_MSG
+ if(tmp32 < 0)
+ {
+ tmp32 = 0;
+ }
+ if(tmp32 > data->fccFromIC)
+ {
+ tmp32 = (_sys_s32_)data->fccFromIC;
+ }
+ UG31_LOGI("[%s]: RM = %d + %d = %d\n", __func__,
+ data->rmFromIC, deltaQ, tmp32);
+ data->rmFromIC = (_sys_u16_)tmp32;
+
+ #ifdef UPI_UBOOT_DEBUG_MSG
+ printf("[UpiUpdateBatInfoFromIC] fccFromIC = %d, rsocFromIC = %d\n", data->fccFromIC, data->rsocFromIC);
+ #endif ///< end of UPI_UBOOT_DEBUG_MSG
+ if(data->fccFromIC == 0)
+ {
+ data->rsocFromIC = 0;
+ }
+ else
+ {
+ tmp32 = tmp32*100 + 50;
+ tmp32 = tmp32/data->fccFromIC;
+ data->rsocFromIC = (_sys_u8_)tmp32;
+
+ if(oldRM != 0)
+ {
+ /// [AT-PM] : EDVF is not reached in last log data ; 02/13/2013
+ if(data->rsocFromIC == 0)
+ {
+ /// [AT-PM] : Check EDVF threshold ; 02/13/2013
+ if(data->voltage < data->ggbParameter->edv1Voltage)
+ {
+ /// [AT-PM] : Set capacity to 0 when EDVF reached ; 02/13/2013
+ data->rmFromIC = 0;
+ data->rsocFromIC = 0;
+ }
+ else
+ {
+ /// [AT-PM] : Capacity should not be 0 before EDVF ; 02/13/2013
+ tmp32 = (_sys_s32_)data->fccFromIC;
+ tmp32 = tmp32/CONST_PERCENTAGE;
+ data->rmFromIC = (_sys_u16_)tmp32;
+ data->rsocFromIC = 1;
+ }
+ #ifdef UPI_UBOOT_DEBUG_MSG
+ printf("[UpiUpdateBatInfoFromIC] Voltage = %d, EDVF = %d\n", data->voltage, data->ggbParameter->edv1Voltage);
+ printf("[UpiUpdateBatInfoFromIC] rmFromIC = %d, rsocFromIC = %d\n", data->rmFromIC, data->rsocFromIC);
+ #endif ///< end of UPI_UBOOT_DEBUG_MSG
+ }
+ else
+ {
+ /// [AT-PM] : Check EDVF threshold ; 02/13/2013
+ if(data->voltage < data->ggbParameter->edv1Voltage)
+ {
+ /// [AT-PM] : Set capacity to 1% when EDVF reached in initialization ; 02/13/2013
+ tmp32 = (_sys_s32_)data->fccFromIC;
+ tmp32 = tmp32/CONST_PERCENTAGE;
+ data->rmFromIC = (_sys_u16_)tmp32;
+ data->rsocFromIC = 1;
+ }
+ #ifdef UPI_UBOOT_DEBUG_MSG
+ printf("[UpiUpdateBatInfoFromIC] Voltage = %d, EDVF = %d\n", data->voltage, data->ggbParameter->edv1Voltage);
+ printf("[UpiUpdateBatInfoFromIC] rmFromIC = %d, rsocFromIC = %d\n", data->rmFromIC, data->rsocFromIC);
+ #endif ///< end of UPI_UBOOT_DEBUG_MSG
+ }
+ }
+ }
+}
+
+/**
+ * @brief UpiSaveBatInfoTOIC
+ *
+ * Save battery information from uG31xx
+ *
+ * @para data address of SystemDataType
+ * @return _UPI_NULL_
+ */
+void UpiSaveBatInfoTOIC(SystemDataType *data)
+{
+ _sys_u8_ *u8Ptr;
+ _sys_u8_ u8Temp;
+ _sys_u8_ u8Temp1;
+ _sys_u16_ u16Temp;
+
+ #if defined(uG31xx_OS_ANDROID)
+ data->timeTagFromIC = GetSysTickCount();
+ #else ///< else of defined(uG31xx_OS_ANDROID)
+ data->timeTagFromIC = GetTickCount();
+ #endif ///< end of defined(uG31xx_OS_ANDROID)
+ UG31_LOGE("[%s]:timeTag =%u/%x ms,NAC = %d maH,LMD = %d maH\n",
+ __func__,
+ data->timeTagFromIC,
+ data->timeTagFromIC,
+ data->rmFromIC,
+ data->fccFromIC);
+
+ //save the time tag
+ u8Ptr = (_sys_u8_ *)&data->timeTagFromIC;
+ u8Temp = (*(u8Ptr + 2)) & 0xf8;
+ API_I2C_SingleWrite(SECURITY, UG31XX_I2C_HIGH_SPEED_MODE, UG31XX_I2C_TEM_BITS_MODE, BACKUP_TIME_BYTE2, u8Temp);
+ API_I2C_SingleWrite(SECURITY, UG31XX_I2C_HIGH_SPEED_MODE, UG31XX_I2C_TEM_BITS_MODE, BACKUP_TIME_BYTE3, *(u8Ptr + 3));
+
+ //save the NAC
+ u8Temp = (_sys_u8_)((data->rmFromIC & 0xff00)/256);
+ API_I2C_SingleWrite(SECURITY, UG31XX_I2C_HIGH_SPEED_MODE, UG31XX_I2C_TEM_BITS_MODE, BACKUP_NAC_HIGH, u8Temp);
+ u8Temp = (_sys_u8_)(data->rmFromIC & 0x00ff);
+ API_I2C_SingleWrite(SECURITY, UG31XX_I2C_HIGH_SPEED_MODE, UG31XX_I2C_TEM_BITS_MODE, BACKUP_NAC_LOW, u8Temp);
+
+ // save LMD
+ u8Temp = (_sys_u8_)((data->fccFromIC & 0xff00)/256);
+ API_I2C_SingleWrite(SECURITY, UG31XX_I2C_HIGH_SPEED_MODE, UG31XX_I2C_TEM_BITS_MODE, BACKUP_LMD_HIGH, u8Temp);
+ u8Temp = (_sys_u8_)(data->fccFromIC & 0x00ff);
+ API_I2C_SingleWrite(SECURITY, UG31XX_I2C_HIGH_SPEED_MODE, UG31XX_I2C_TEM_BITS_MODE, BACKUP_LMD_LOW, u8Temp);
+
+ /// [AT-PM] : Save table update index ; 02/10/2013
+ API_I2C_SingleRead(NORMAL, UG31XX_I2C_HIGH_SPEED_MODE, UG31XX_I2C_TEM_BITS_MODE, BACKUP_TABLE_UPDATE_IDX, &u8Temp);
+ u8Temp = u8Temp & 0xf8;
+ u8Temp = u8Temp | (data->tableUpdateIdxFromIC & 0x07);
+ API_I2C_SingleWrite(NORMAL, UG31XX_I2C_HIGH_SPEED_MODE, UG31XX_I2C_TEM_BITS_MODE, BACKUP_TABLE_UPDATE_IDX, u8Temp);
+ UG31_LOGI("[%s]: Save Table Update Index = %d - 0x%02x\n", __func__, data->tableUpdateIdxFromIC, u8Temp);
+
+ /// [AT-PM] : Save delta capacity ; 02/10/2013
+ u16Temp = (_sys_u16_)data->deltaCapFromIC;
+ u8Temp = (_sys_u8_)(u16Temp >> 8);
+ API_I2C_SingleWrite(SECURITY, UG31XX_I2C_HIGH_SPEED_MODE, UG31XX_I2C_TEM_BITS_MODE, BACKUP_DELTA_CAP_HIGH, u8Temp);
+ u8Temp1 = (_sys_u8_)(u16Temp & 0x00ff);
+ API_I2C_SingleWrite(NORMAL, UG31XX_I2C_HIGH_SPEED_MODE, UG31XX_I2C_TEM_BITS_MODE, BACKUP_DELTA_CAP_LOW, u8Temp1);
+ UG31_LOGI("[%s]: Save Delta Capacity = %d - 0x%02x%02x\n", __func__, data->deltaCapFromIC, u8Temp, u8Temp1);
+
+ /// [AT-PM] : Save adc1 conversion time ; 02/10/2013
+ u16Temp = data->adc1ConvTime/TIME_CONVERT_TIME_TO_MSEC;
+ API_I2C_SingleRead(NORMAL, UG31XX_I2C_HIGH_SPEED_MODE, UG31XX_I2C_TEM_BITS_MODE, BACKUP_ADC1_CONV_TIME, &u8Temp);
+ u8Temp = u8Temp & 0x07;
+ u8Temp = u8Temp | (u16Temp & 0xf8);
+ API_I2C_SingleWrite(NORMAL, UG31XX_I2C_HIGH_SPEED_MODE, UG31XX_I2C_TEM_BITS_MODE, BACKUP_ADC1_CONV_TIME, u8Temp);
+ UG31_LOGI("[%s]: Save ADC1 Conversion Time = %d - 0x%02x\n", __func__, data->adc1ConvTime, u8Temp);
+}
+
+/**
+ * @brief UpiInitAlarm
+ *
+ * Initialize alarm function of uG3105
+ *
+ * @para data address of SystemDataType
+ * @return NULL
+ */
+void UpiInitAlarm(SystemDataType *data)
+{
+ /// [AT-PM] : Set GPIO as alarm pin ; 04/08/2013
+ ConfigureGpio(data);
+
+ /// [AT-PM] : Set delay time ; 04/08/2013
+ API_I2C_SingleWrite(SECURITY,
+ UG31XX_I2C_HIGH_SPEED_MODE,
+ UG31XX_I2C_TEM_BITS_MODE,
+ REG_TIMER,
+ data->ggbParameter->alarm_timer);
+ API_I2C_SingleWrite(SECURITY,
+ UG31XX_I2C_HIGH_SPEED_MODE,
+ UG31XX_I2C_TEM_BITS_MODE,
+ REG_CLK_DIVA,
+ data->ggbParameter->clkDivA);
+ API_I2C_SingleWrite(SECURITY,
+ UG31XX_I2C_HIGH_SPEED_MODE,
+ UG31XX_I2C_TEM_BITS_MODE,
+ REG_CLK_DIVB,
+ data->ggbParameter->clkDivB);
+
+ /// [AT-PM] : Enable alarm ; 04/08/2013
+ data->alarmSts = 0;
+ data->uvAlarm.state = _UPI_FALSE_;
+ data->uetAlarm.state = _UPI_FALSE_;
+ data->oetAlarm.state = _UPI_FALSE_;
+ EnableAlarm(data);
+}
+
+/**
+ * @brief UpiAlarmStatus
+ *
+ * Get alarm status
+ *
+ * @para data address of SystemDataType
+ * @return NULL
+ */
+_sys_u8_ UpiAlarmStatus(SystemDataType *data)
+{
+ _sys_u8_ sts;
+ _sys_u8_ tmp8[2];
+
+ sts = 0;
+
+ /// [AT-PM] : Read alarm status from uG3105 ; 04/08/2013
+ API_I2C_Read(NORMAL, UG31XX_I2C_HIGH_SPEED_MODE, UG31XX_I2C_TEM_BITS_MODE, REG_ALARM1_STATUS, 2, &tmp8[0]);
+ data->alarmSts = (_sys_u16_)tmp8[0];
+ data->alarmSts = data->alarmSts*256 + tmp8[1];
+
+ /// [AT-PM] : Enable alarm ; 04/08/2013
+ EnableAlarm(data);
+
+ /// [AT-PM] : Update current alarm status ; 04/08/2013
+ tmp8[0] = data->uvAlarm.state == _UPI_TRUE_ ? ALARM_STATUS_UV : 0;
+ sts = sts | tmp8[0];
+ tmp8[0] = data->uetAlarm.state == _UPI_TRUE_ ? ALARM_STATUS_UET : 0;
+ sts = sts | tmp8[0];
+ tmp8[0] = data->oetAlarm.state == _UPI_TRUE_ ? ALARM_STATUS_OET : 0;
+ sts = sts | tmp8[0];
+ return (sts);
+}
+
diff --git a/board/wmt/wmt_battery/gauge/upi/uG31xx_API_System.h b/board/wmt/wmt_battery/gauge/upi/uG31xx_API_System.h
new file mode 100755
index 0000000..f1579dc
--- /dev/null
+++ b/board/wmt/wmt_battery/gauge/upi/uG31xx_API_System.h
@@ -0,0 +1,211 @@
+/**
+ * @filename uG31xx_API_System.h
+ *
+ * Interface of ug31xx system control
+ *
+ * @author AllenTeng <allen_teng@upi-semi.com>
+ */
+
+#define UG31XX_SYSTEM_VERSION (6)
+
+typedef unsigned char _sys_u8_;
+typedef signed char _sys_s8_;
+typedef unsigned short _sys_u16_;
+typedef signed short _sys_s16_;
+typedef unsigned long _sys_u32_;
+typedef signed long _sys_s32_;
+typedef char _sys_bool_;
+
+typedef enum _SYSTEM_RTN_CODE {
+ SYSTEM_RTN_PASS = 0,
+ SYSTEM_RTN_READ_GGB_FAIL,
+ SYSTEM_RTN_I2C_FAIL,
+} SYSTEM_RTN_CODE;
+
+typedef struct AlarmDataST {
+ _sys_u16_ alarmThrd;
+ _sys_u16_ releaseThrd;
+ _sys_bool_ state;
+#if defined(uG31xx_OS_ANDROID)
+ } __attribute__ ((aligned(4))) AlarmDataType;
+#else ///< else of defined(uG31xx_OS_ANDROID)
+ } AlarmDataType;
+#endif ///< end of defined(uG31xx_OS_ANDROID)
+
+typedef struct SystemDataST {
+
+ #if defined (uG31xx_OS_WINDOWS)
+ const wchar_t* ggbFilename;
+ const wchar_t* otpFileName;
+ const wchar_t* backupFileName;
+ #elif defined(uG31xx_OS_ANDROID)
+ GGBX_FILE_HEADER *ggbXBuf;
+ #endif
+
+ CELL_PARAMETER *ggbParameter;
+ CELL_TABLE *ggbCellTable;
+ OtpDataType *otpData;
+
+ ADC_CHECK adcCheckData; //add for adc error check 20121025/jacky
+
+ _sys_u16_ voltage;
+
+ _sys_u16_ preITAve;
+ _sys_u8_ cellNum;
+
+ _sys_u16_ rmFromIC;
+ _sys_u16_ fccFromIC;
+ _sys_u8_ rsocFromIC;
+ _sys_u32_ timeTagFromIC;
+ _sys_u8_ tableUpdateIdxFromIC;
+ _sys_s16_ deltaCapFromIC;
+ _sys_u16_ adc1ConvTime;
+
+ _sys_u16_ rmFromICBackup;
+ _sys_u16_ fccFromICBackup;
+ _sys_u8_ rsocFromICBackup;
+
+ AlarmDataType uvAlarm;
+ AlarmDataType oetAlarm;
+ AlarmDataType uetAlarm;
+ _sys_u16_ alarmSts;
+#if defined(uG31xx_OS_ANDROID)
+ } __attribute__ ((aligned(4))) SystemDataType;
+#else ///< else of defined(uG31xx_OS_ANDROID)
+ } SystemDataType;
+#endif ///< end of defined(uG31xx_OS_ANDROID)
+
+/**
+ * @brief UpiInitSystemData
+ *
+ * Initialize system data
+ *
+ * @para data address of BootDataType
+ * @return _UPI_NULL_
+ */
+extern SYSTEM_RTN_CODE UpiInitSystemData(SystemDataType *data);
+
+/**
+ * @brief UpiCheckICActive
+ *
+ * Check IC is actived or not
+ *
+ * @return _UPI_TRUE_ if uG31xx is not actived
+ */
+extern _upi_bool_ UpiCheckICActive(void);
+
+/**
+ * @brief UpiActiveUg31xx
+ *
+ * Active uG31xx
+ *
+ * @return SYSTEM_RTN_CODE
+ */
+extern SYSTEM_RTN_CODE UpiActiveUg31xx(void);
+
+/**
+ * @brief UpiSetupAdc
+ *
+ * Setup ADC configurations
+ *
+ * @para data address of SystemDataType
+ * @return _UPI_NULL_
+ */
+extern void UpiSetupAdc(SystemDataType *data);
+
+/**
+ * @brief UpiDecimateRst
+ *
+ * Decimate reset filter of ADC
+ *
+ * @return _UPI_NULL_
+ */
+extern void UpiDecimateRst(void);
+
+/**
+ * @brief UpiSetupSystem
+ *
+ * Setup uG31xx system
+ *
+ * @para data address of SystemDataType
+ * @return _UPI_NULL_
+ */
+extern void UpiSetupSystem(SystemDataType *data);
+
+/**
+ * @brief UpiCalibrationOsc
+ *
+ * OSC calibration
+ * oscCnt25[9:0] = oscCntTarg[9:0] + oscDeltaCode25[7:0]
+ * oscCnt80[9:0] = oscCntTarg[9:0] + oscDeltaCode80[7:0]
+ * oscCnt[9:0] = m*ITcode[15:8] + C[9:0]
+ * m = (oscCnt80[9:0]-oscCnt25[9:0])/(iTcode80[7:0]-iTcode25[7:0])
+ * c = oscCnt25[9:0] - m*ITcode25[7:0]
+ * write oscCnt[9:0] to register 0x97-98
+ *
+ * @para data address of SystemDataType
+ * @return _UPI_NULL_
+ */
+extern void UpiCalibrationOsc(SystemDataType *data);
+
+/**
+ * @brief UpiAdcStatus
+ *
+ * Check ADC status
+ *
+ * @para data address of SystemDataType
+ * @return _UPI_NULL_
+ */
+extern void UpiAdcStatus(SystemDataType *data);
+
+/**
+ * @brief UpiLoadBatInfoFromIC
+ *
+ * Load battery information from uG31xx
+ *
+ * @para data address of SystemDataType
+ * @return _UPI_NULL_
+ */
+extern void UpiLoadBatInfoFromIC(SystemDataType *data);
+
+/**
+ * @brief UpiUpdateBatInfoFromIC
+ *
+ * Update battery information from uG31xx
+ *
+ * @para data address of SystemDataType
+ * @para deltaQ delta capacity from coulomb counter
+ * @return _UPI_NULL_
+ */
+extern void UpiUpdateBatInfoFromIC(SystemDataType *data, _sys_s16_ deltaQ);
+
+/**
+ * @brief UpiSaveBatInfoTOIC
+ *
+ * Save battery information from uG31xx
+ *
+ * @para data address of SystemDataType
+ * @return _UPI_NULL_
+ */
+extern void UpiSaveBatInfoTOIC(SystemDataType *data);
+
+/**
+ * @brief UpiInitAlarm
+ *
+ * Initialize alarm function of uG3105
+ *
+ * @para data address of SystemDataType
+ * @return NULL
+ */
+extern void UpiInitAlarm(SystemDataType *data);
+
+/**
+ * @brief UpiAlarmStatus
+ *
+ * Get alarm status
+ *
+ * @para data address of SystemDataType
+ * @return NULL
+ */
+extern _sys_u8_ UpiAlarmStatus(SystemDataType *data);
+
diff --git a/board/wmt/wmt_battery/gauge/upi/uG31xx_Platform.h b/board/wmt/wmt_battery/gauge/upi/uG31xx_Platform.h
new file mode 100755
index 0000000..f97ee4e
--- /dev/null
+++ b/board/wmt/wmt_battery/gauge/upi/uG31xx_Platform.h
@@ -0,0 +1,21 @@
+/**
+ * @filename uG31xx_Platform.h
+ *
+ * Define the platform for uG31xx driver
+ *
+ * @author AllenTeng <allen_teng@upi-semi.com>
+ */
+
+#ifndef _UG31XX_PLATFORM_H_
+#define _UG31XX_PLATFORM_H_
+
+//#define uG31xx_OS_WINDOWS
+#define uG31xx_OS_ANDROID
+
+#ifdef uG31xx_OS_ANDROID
+
+ #define uG31xx_BOOT_LOADER
+
+#endif ///< end of uG31xx_OS_ANDROID
+
+#endif ///< end of _UG31XX_PLATFORM_H_
diff --git a/board/wmt/wmt_battery/gauge/upi/uG31xx_Reg_Def.h b/board/wmt/wmt_battery/gauge/upi/uG31xx_Reg_Def.h
new file mode 100755
index 0000000..4de941a
--- /dev/null
+++ b/board/wmt/wmt_battery/gauge/upi/uG31xx_Reg_Def.h
@@ -0,0 +1,667 @@
+/**
+ * @filename RegDef.h
+ *
+ * uG31xx register definition
+ *
+ * @author AllenTeng <allen.kuoliang.teng@gmail.com>
+ * @note register table release date 2012/11/05
+ */
+
+#define INTERNAL_REGISTER_GROUP_A (0x00)
+ #define REG_MODE (INTERNAL_REGISTER_GROUP_A + 0) ///< 0x00
+ #define MODE_GG_RUN (1<<4)
+ #define GG_RUN_STANDBY_MODE (0<<4)
+ #define GG_RUN_OPERATION_MODE (1<<4)
+ #define REG_CTRL1 (INTERNAL_REGISTER_GROUP_A + 1) ///< 0x01
+ #define CTRL1_PORDET (1<<4)
+ #define PORDET_R_NO_POR (0<<4)
+ #define PORDET_R_POR (1<<4)
+ #define PORDET_W_RELEASE (0<<4)
+ #define PORDET_W_SOFTRESET (1<<4)
+ #define CTRL1_VTM_EOC (1<<3)
+ #define CTRL1_GG_EOC (1<<2)
+ #define CTRL1_GG_RST (1<<1)
+ #define CTRL1_IO1DATA (1<<0)
+ #define IO1DATA_R_LOW (0<<0)
+ #define IO1DATA_R_HIGH (1<<0)
+ #define IO1DATA_W_LOW (0<<0)
+ #define IO1DATA_W_HIGH (1<<0)
+
+#define INTERNAL_REGISTER_GROUP_B (0x02)
+ #define REG_CHARGE_LOW (INTERNAL_REGISTER_GROUP_B + 0) ///< 0x02
+ #define REG_CHARGE_HIGH (INTERNAL_REGISTER_GROUP_B + 1) ///< 0x03
+ #define REG_COUNTER_LOW (INTERNAL_REGISTER_GROUP_B + 2) ///< 0x04
+ #define REG_COUNTER_HIGH (INTERNAL_REGISTER_GROUP_B + 3) ///< 0x05
+ #define REG_AVE_CURRENT_LOW (INTERNAL_REGISTER_GROUP_B + 4) ///< 0x06
+ #define REG_AVE_CURRENT_HIGH (INTERNAL_REGISTER_GROUP_B + 5) ///< 0x07
+ #define REG_AVE_VBAT1_LOW (INTERNAL_REGISTER_GROUP_B + 6) ///< 0x08
+ #define REG_AVE_VBAT1_HIGH (INTERNAL_REGISTER_GROUP_B + 7) ///< 0x09
+ #define REG_AVE_IT_LOW (INTERNAL_REGISTER_GROUP_B + 8) ///< 0x0A
+ #define REG_AVE_IT_HIGH (INTERNAL_REGISTER_GROUP_B + 9) ///< 0x0B
+ #define REG_AVE_OFFSET_CURRENT_LOW (INTERNAL_REGISTER_GROUP_B + 10) ///< 0x0C
+ #define REG_AVE_OFFSET_CURRENT_HIGH (INTERNAL_REGISTER_GROUP_B + 11) ///< 0x0D
+ #define REG_AVE_ET_LOW (INTERNAL_REGISTER_GROUP_B + 12) ///< 0x0E
+ #define REG_AVE_ET_HIGH (INTERNAL_REGISTER_GROUP_B + 13) ///< 0x0F
+ #define REG_AVE_RID_LOW (INTERNAL_REGISTER_GROUP_B + 14) ///< 0x10
+ #define REG_AVE_RID_HIGH (INTERNAL_REGISTER_GROUP_B + 15) ///< 0x11
+ #define REG_ALARM1_STATUS (INTERNAL_REGISTER_GROUP_B + 16) ///< 0x12
+ #define ALARM1_STATUS_COC_ALARM (1<<5)
+ #define ALARM1_STATUS_DOC_ALARM (1<<4)
+ #define ALARM1_STATUS_OIT_ALARM (1<<3)
+ #define ALARM1_STATUS_UIT_ALARM (1<<2)
+ #define ALARM1_STATUS_OET_ALARM (1<<1)
+ #define ALARM1_STATUS_UET_ALARM (1<<0)
+ #define REG_ALARM2_STATUS (INTERNAL_REGISTER_GROUP_B + 17) ///< 0x13
+ #define ALARM2_STATUS_OV3_ALARM (1<<5)
+ #define ALARM2_STATUS_UV3_ALARM (1<<4)
+ #define ALARM2_STATUS_OV2_ALARM (1<<3)
+ #define ALARM2_STATUS_UV2_ALARM (1<<2)
+ #define ALARM2_STATUS_OV1_ALARM (1<<1)
+ #define ALARM2_STATUS_UV1_ALARM (1<<0)
+ #define REG_INTR_STATUS (INTERNAL_REGISTER_GROUP_B + 18) ///< 0x14
+ #define INTR_STATUS_CBC_STS32 (1<<7)
+ #define CBC_STS32_ENABLE (0<<7)
+ #define CBC_STS32_DISABLE (1<<7)
+ #define INTR_STATUS_CBC_STS21 (1<<6)
+ #define CBC_STS21_ENABLE (0<<6)
+ #define CBC_STS21_DISABLE (1<<6)
+ #define INTR_STATUS_STB_STS (1<<5)
+ #define INTR_STATUS_ET_STS (1<<4)
+ #define INTR_STATUS_IT_STS (1<<3)
+ #define INTR_STATUS_RID_STS (1<<2)
+ #define INTR_STATUS_LVD_STS (1<<1)
+ #define INTR_STATUS_AL_STS (1<<0)
+ #define REG_ALARM_EN (INTERNAL_REGISTER_GROUP_B + 19) ///< 0x15
+ #define ALARM_EN_COC_ALARM_EN (1<<7)
+ #define ALARM_EN_DOC_ALARM_EN (1<<6)
+ #define ALARM_EN_IT_ALARM_EN (1<<5)
+ #define ALARM_EN_ET_ALARM_EN (1<<4)
+ #define ALARM_EN_DECIMATE_RST (1<<3)
+ #define ALARM_EN_V3_ALARM_EN (1<<2)
+ #define ALARM_EN_V2_ALARM_EN (1<<1)
+ #define ALARM_EN_V1_ALARM_EN (1<<0)
+ #define REG_CTRL2 (INTERNAL_REGISTER_GROUP_B + 20) ///< 0x16
+ #define CTRL2_IO4DATA (1<<2)
+ #define IO4DATA_R_LOW (0<<2)
+ #define IO4DATA_R_HIGH (1<<2)
+ #define IO4DATA_W_LOW (0<<2)
+ #define IO4DATA_W_HIGH (1<<2)
+ #define CTRL2_IO3DATA (1<<1)
+ #define IO3DATA_R_LOW (0<<1)
+ #define IO3DATA_R_HIGH (1<<1)
+ #define IO3DATA_W_LOW (0<<1)
+ #define IO3DATA_W_HIGH (1<<1)
+ #define CTRL2_IO2DATA (1<<0)
+ #define IO2DATA_R_LOW (0<<0)
+ #define IO2DATA_R_HIGH (1<<0)
+ #define IO2DATA_W_LOW (0<<0)
+ #define IO2DATA_W_HIGH (1<<0)
+
+#define INTERNAL_REGISTER_GROUP_C (0x20)
+ #define REG_RAM0 (INTERNAL_REGISTER_GROUP_C + 0) ///< 0x20
+ #define REG_RAM1 (INTERNAL_REGISTER_GROUP_C + 1) ///< 0x21
+ #define REG_RAM2 (INTERNAL_REGISTER_GROUP_C + 2) ///< 0x22
+ #define REG_RAM3 (INTERNAL_REGISTER_GROUP_C + 3) ///< 0x23
+ #define REG_RAM4 (INTERNAL_REGISTER_GROUP_C + 4) ///< 0x24
+ #define REG_RAM5 (INTERNAL_REGISTER_GROUP_C + 5) ///< 0x25
+ #define REG_RAM6 (INTERNAL_REGISTER_GROUP_C + 6) ///< 0x26
+ #define REG_RAM7 (INTERNAL_REGISTER_GROUP_C + 7) ///< 0x27
+ #define REG_RAM8 (INTERNAL_REGISTER_GROUP_C + 8) ///< 0x28
+ #define REG_RAM9 (INTERNAL_REGISTER_GROUP_C + 9) ///< 0x29
+ #define REG_RAM10 (INTERNAL_REGISTER_GROUP_C + 10) ///< 0x2A
+ #define REG_RAM11 (INTERNAL_REGISTER_GROUP_C + 11) ///< 0x2B
+ #define REG_RAM12 (INTERNAL_REGISTER_GROUP_C + 12) ///< 0x2C
+ #define REG_RAM13 (INTERNAL_REGISTER_GROUP_C + 13) ///< 0x2D
+ #define REG_RAM14 (INTERNAL_REGISTER_GROUP_C + 14) ///< 0x2E
+ #define REG_RAM15 (INTERNAL_REGISTER_GROUP_C + 15) ///< 0x2F
+ #define REG_RAM16 (INTERNAL_REGISTER_GROUP_C + 16) ///< 0x30
+ #define REG_RAM17 (INTERNAL_REGISTER_GROUP_C + 17) ///< 0x31
+ #define REG_RAM18 (INTERNAL_REGISTER_GROUP_C + 18) ///< 0x32
+ #define REG_RAM19 (INTERNAL_REGISTER_GROUP_C + 19) ///< 0x33
+ #define REG_RAM20 (INTERNAL_REGISTER_GROUP_C + 20) ///< 0x34
+ #define REG_RAM21 (INTERNAL_REGISTER_GROUP_C + 21) ///< 0x35
+ #define REG_RAM22 (INTERNAL_REGISTER_GROUP_C + 22) ///< 0x36
+ #define REG_RAM23 (INTERNAL_REGISTER_GROUP_C + 23) ///< 0x37
+ #define REG_RAM24 (INTERNAL_REGISTER_GROUP_C + 24) ///< 0x38
+ #define REG_RAM25 (INTERNAL_REGISTER_GROUP_C + 25) ///< 0x39
+ #define REG_RAM26 (INTERNAL_REGISTER_GROUP_C + 26) ///< 0x3A
+ #define REG_RAM27 (INTERNAL_REGISTER_GROUP_C + 27) ///< 0x3B
+ #define REG_RAM28 (INTERNAL_REGISTER_GROUP_C + 28) ///< 0x3C
+ #define REG_RAM29 (INTERNAL_REGISTER_GROUP_C + 29) ///< 0x3D
+ #define REG_RAM30 (INTERNAL_REGISTER_GROUP_C + 30) ///< 0x3E
+ #define REG_RAM31 (INTERNAL_REGISTER_GROUP_C + 31) ///< 0x3F
+
+#define INTERNAL_REGISTER_GROUP_D (0x40)
+ #define REG_VBAT2_LOW (INTERNAL_REGISTER_GROUP_D + 0) ///< 0x40
+ #define REG_VBAT2_HIGH (INTERNAL_REGISTER_GROUP_D + 1) ///< 0x41
+ #define REG_VBAT3_LOW (INTERNAL_REGISTER_GROUP_D + 2) ///< 0x42
+ #define REG_VBAT3_HIGH (INTERNAL_REGISTER_GROUP_D + 3) ///< 0x43
+ #define REG_VBAT1_LOW (INTERNAL_REGISTER_GROUP_D + 4) ///< 0x44
+ #define REG_VBAT1_HIGH (INTERNAL_REGISTER_GROUP_D + 5) ///< 0x45
+ #define REG_VBAT2_AVE_LOW (INTERNAL_REGISTER_GROUP_D + 6) ///< 0x46
+ #define REG_VBAT2_AVE_HIGH (INTERNAL_REGISTER_GROUP_D + 7) ///< 0x47
+ #define REG_VBAT3_AVE_LOW (INTERNAL_REGISTER_GROUP_D + 8) ///< 0x48
+ #define REG_VBAT3_AVE_HIGH (INTERNAL_REGISTER_GROUP_D + 9) ///< 0x49
+ #define REG_V1_LOW (INTERNAL_REGISTER_GROUP_D + 10) ///< 0x4A
+ #define REG_V1_HIGH (INTERNAL_REGISTER_GROUP_D + 11) ///< 0x4B
+ #define REG_V2_LOW (INTERNAL_REGISTER_GROUP_D + 12) ///< 0x4C
+ #define REG_V2_HIGH (INTERNAL_REGISTER_GROUP_D + 13) ///< 0x4D
+ #define REG_V3_LOW (INTERNAL_REGISTER_GROUP_D + 14) ///< 0x4E
+ #define REG_V3_HIGH (INTERNAL_REGISTER_GROUP_D + 15) ///< 0x4F
+ #define REG_INTR_TEMPER_LOW (INTERNAL_REGISTER_GROUP_D + 16) ///< 0x50
+ #define REG_INTR_TEMPER_HIGH (INTERNAL_REGISTER_GROUP_D + 17) ///< 0x51
+ #define REG_EXTR_TEMPER_LOW (INTERNAL_REGISTER_GROUP_D + 18) ///< 0x52
+ #define REG_EXTR_TEMPER_HIGH (INTERNAL_REGISTER_GROUP_D + 19) ///< 0x53
+ #define REG_RID_LOW (INTERNAL_REGISTER_GROUP_D + 20) ///< 0x54
+ #define REG_RID_HIGH (INTERNAL_REGISTER_GROUP_D + 21) ///< 0x55
+ #define REG_CURRENT_LOW (INTERNAL_REGISTER_GROUP_D + 22) ///< 0x56
+ #define REG_CURRENT_HIGH (INTERNAL_REGISTER_GROUP_D + 23) ///< 0x57
+ #define REG_ADC1_OFFSET_LOW (INTERNAL_REGISTER_GROUP_D + 24) ///< 0x58
+ #define REG_ADC1_OFFSET_HIGH (INTERNAL_REGISTER_GROUP_D + 25) ///< 0x59
+
+ #define OTP6_BYTE1 (INTERNAL_REGISTER_GROUP_D + 48) ///< 0x70
+ #define AVE_IT25_7_3 (63<<3)
+ #define DELTA_ET_3_2 (3<<1)
+ #define DELTA_VREF_4 (1<<0)
+ #define OTP6_BYTE2 (INTERNAL_REGISTER_GROUP_D + 49) ///< 0x71
+ #define AVE_IT25_15_8 (255<<0)
+ #define OTP6_BYTE3 (INTERNAL_REGISTER_GROUP_D + 50) ///< 0x72
+ #define AVE_IT80_7_3 (63<<3)
+ #define INDEX_ADC1_200_25_4 (1<<2)
+ #define INDEX_ADC1_100_25_4 (1<<1)
+ #define INDEX_ADC2_200_25_4 (1<<0)
+ #define OTP6_BYTE4 (INTERNAL_REGISTER_GROUP_D + 51) ///< 0x73
+ #define AVE_IT80_15_8 (255<<0)
+
+#define INTERNAL_REGISTER_GROUP_E (0x8F)
+ #define REG_TIMER (INTERNAL_REGISTER_GROUP_E + 0) ///< 0x8F
+ #define TIMER_TIMER_ITSET (3<<6)
+ #define TIMER_ITSET_4 (0<<6)
+ #define TIMER_ITSET_9 (1<<6)
+ #define TIMER_ITSET_14 (2<<6)
+ #define TIMER_ITSET_19 (3<<6)
+ #define TIMER_TIMER_ETSET (3<<4)
+ #define TIMER_ETSET_4 (0<<4)
+ #define TIMER_ETSET_9 (1<<4)
+ #define TIMER_ETSET_14 (2<<4)
+ #define TIMER_ETSET_19 (3<<4)
+ #define TIMER_TIMER_VSET (3<<2)
+ #define TIMER_VSET_4 (0<<2)
+ #define TIMER_VSET_9 (1<<2)
+ #define TIMER_VSET_14 (2<<2)
+ #define TIMER_VSET_19 (3<<2)
+ #define TIMER_TIMER_CSET (3<<0)
+ #define TIMER_CSET_4 (0<<0)
+ #define TIMER_CSET_9 (1<<0)
+ #define TIMER_CSET_14 (2<<0)
+ #define TIMER_CSET_19 (3<<0)
+ #define REG_CLK_DIVA (INTERNAL_REGISTER_GROUP_E + 1) ///< 0x90
+ #define CLK_DIVA_FW_CLK_CDIV (15<<4)
+ #define FW_CLK_CDIV_31US (0<<4)
+ #define FW_CLK_CDIV_61US (1<<4)
+ #define FW_CLK_CDIV_122US (2<<4)
+ #define FW_CLK_CDIV_244US (3<<4)
+ #define FW_CLK_CDIV_488US (4<<4)
+ #define FW_CLK_CDIV_977US (5<<4)
+ #define FW_CLK_CDIV_2MS (6<<4)
+ #define FW_CLK_CDIV_4MS (7<<4)
+ #define FW_CLK_CDIV_8MS (8<<4)
+ #define FW_CLK_CDIV_16MS (9<<4)
+ #define FW_CLK_CDIV_31MS (10<<4)
+ #define FW_CLK_CDIV_62MS (11<<4)
+ #define FW_CLK_CDIV_125MS (12<<4)
+ #define FW_CLK_CDIV_250MS (13<<4)
+ #define FW_CLK_CDIV_500MS (14<<4)
+ #define FW_CLK_CDIV_1S (15<<4)
+ #define CLK_DIVA_FW_CLK_VDIV (15<<0)
+ #define FW_CLK_VDIV_31US (0<<0)
+ #define FW_CLK_VDIV_61US (1<<0)
+ #define FW_CLK_VDIV_122US (2<<0)
+ #define FW_CLK_VDIV_244US (3<<0)
+ #define FW_CLK_VDIV_488US (4<<0)
+ #define FW_CLK_VDIV_977US (5<<0)
+ #define FW_CLK_VDIV_2MS (6<<0)
+ #define FW_CLK_VDIV_4MS (7<<0)
+ #define FW_CLK_VDIV_8MS (8<<0)
+ #define FW_CLK_VDIV_16MS (9<<0)
+ #define FW_CLK_VDIV_31MS (10<<0)
+ #define FW_CLK_VDIV_62MS (11<<0)
+ #define FW_CLK_VDIV_125MS (12<<0)
+ #define FW_CLK_VDIV_250MS (13<<0)
+ #define FW_CLK_VDIV_500MS (14<<0)
+ #define FW_CLK_VDIV_1S (15<<0)
+ #define REG_CLK_DIVB (INTERNAL_REGISTER_GROUP_E + 2) ///< 0x91
+ #define CLK_DIVB_FW_CLK_ETDIV (15<<4)
+ #define FW_CLK_ETDIV_31US (0<<4)
+ #define FW_CLK_ETDIV_61US (1<<4)
+ #define FW_CLK_ETDIV_122US (2<<4)
+ #define FW_CLK_ETDIV_244US (3<<4)
+ #define FW_CLK_ETDIV_488US (4<<4)
+ #define FW_CLK_ETDIV_977US (5<<4)
+ #define FW_CLK_ETDIV_2MS (6<<4)
+ #define FW_CLK_ETDIV_4MS (7<<4)
+ #define FW_CLK_ETDIV_8MS (8<<4)
+ #define FW_CLK_ETDIV_16MS (9<<4)
+ #define FW_CLK_ETDIV_31MS (10<<4)
+ #define FW_CLK_ETDIV_62MS (11<<4)
+ #define FW_CLK_ETDIV_125MS (12<<4)
+ #define FW_CLK_ETDIV_250MS (13<<4)
+ #define FW_CLK_ETDIV_500MS (14<<4)
+ #define FW_CLK_ETDIV_1S (15<<4)
+ #define CLK_DIVB_FW_CLK_ITDIV (15<<0)
+ #define FW_CLK_ITDIV_31US (0<<0)
+ #define FW_CLK_ITDIV_61US (1<<0)
+ #define FW_CLK_ITDIV_122US (2<<0)
+ #define FW_CLK_ITDIV_244US (3<<0)
+ #define FW_CLK_ITDIV_488US (4<<0)
+ #define FW_CLK_ITDIV_977US (5<<0)
+ #define FW_CLK_ITDIV_2MS (6<<0)
+ #define FW_CLK_ITDIV_4MS (7<<0)
+ #define FW_CLK_ITDIV_8MS (8<<0)
+ #define FW_CLK_ITDIV_16MS (9<<0)
+ #define FW_CLK_ITDIV_31MS (10<<0)
+ #define FW_CLK_ITDIV_62MS (11<<0)
+ #define FW_CLK_ITDIV_125MS (12<<0)
+ #define FW_CLK_ITDIV_250MS (13<<0)
+ #define FW_CLK_ITDIV_500MS (14<<0)
+ #define FW_CLK_ITDIV_1S (15<<0)
+ #define REG_INTR_CTRL_D (INTERNAL_REGISTER_GROUP_E + 3) ///< 0x92
+ #define INTR_CTRL_D_GPIO4_SEL (7<<3)
+ #define GPIO4_SEL_GPIO1 (0<<3)
+ #define GPIO4_SEL_ALARM (1<<3)
+ #define GPIO4_SEL_CBC_EN21 (2<<3)
+ #define GPIO4_SEL_CBC_EN32 (3<<3)
+ #define GPIO4_SEL_PWM (4<<3)
+ #define GPIO4_SEL_ADC1_D (6<<3)
+ #define GPIO4_SEL_ADC2_D (7<<3)
+ #define INTR_CTRL_D_GPIO3_SEL (7<<0)
+ #define GPIO3_SEL_GPIO1 (0<<0)
+ #define GPIO3_SEL_ALARM (1<<0)
+ #define GPIO3_SEL_CBC_EN21 (2<<0)
+ #define GPIO3_SEL_CBC_EN32 (3<<0)
+ #define GPIO3_SEL_PWM (4<<0)
+ #define GPIO3_SEL_ADC1_D (6<<0)
+ #define GPIO3_SEL_ADC2_D (7<<0)
+ #define OSCTUNE_J1 (INTERNAL_REGISTER_GROUP_E + 4) ///< 0x93
+ #define OSCTUNE_J_LOW (255<<0)
+ #define OSCTUNE_J2 (INTERNAL_REGISTER_GROUP_E + 5) ///< 0x94
+ #define OSCTUNE_J_HIGH (3<<0)
+ #define OSCTUNE_K1 (INTERNAL_REGISTER_GROUP_E + 6) ///< 0x95
+ #define OSCTUNE_K_LOW (255<<0)
+ #define OSCTUNE_K2 (INTERNAL_REGISTER_GROUP_E + 7) ///< 0x96
+ #define OSCTUNE_K_HIGH (3<<0)
+ #define OSCTUNE_CNTA (INTERNAL_REGISTER_GROUP_E + 8) ///< 0x97
+ #define OSCTUNE_CNT_LOW (255<<0)
+ #define OSCTUNE_CNTB (INTERNAL_REGISTER_GROUP_E + 9) ///< 0x98
+ #define OSCTUNE_CNT_HIGH (3<<0)
+ #define ADC1_TARGET_A (INTERNAL_REGISTER_GROUP_E + 10) ///< 0x99
+ #define TARGET_A_LOW (255<<0)
+ #define ADC1_TARGET_B (INTERNAL_REGISTER_GROUP_E + 11) ///< 0x9A
+ #define TARGET_A_HIGH (3<<0)
+ #define REG_INTR_CTRL_A (INTERNAL_REGISTER_GROUP_E + 12) ///< 0x9B
+ #define INTR_CTRL_A_GPIO2_SEL (7<<5)
+ #define GPIO2_SEL_GPIO1 (0<<5)
+ #define GPIO2_SEL_ALARM (1<<5)
+ #define GPIO2_SEL_CBC_EN21 (2<<5)
+ #define GPIO2_SEL_CBC_EN32 (3<<5)
+ #define GPIO2_SEL_PWM (4<<5)
+ #define INTR_CTRL_A_GPIO1_SEL (7<<2)
+ #define GPIO1_SEL_GPIO1 (0<<2)
+ #define GPIO1_SEL_ALARM (1<<2)
+ #define GPIO1_SEL_CBC_EN21 (2<<2)
+ #define GPIO1_SEL_CBC_EN32 (3<<2)
+ #define GPIO1_SEL_PWM (4<<2)
+ #define GPIO1_SEL_OSCOUT (7<<2)
+ #define INTR_CTRL_A_ADC2_EN (1<<1)
+ #define INTR_CTRL_A_ADC1_EN (1<<0)
+ #define REG_INTR_CTRL_B (INTERNAL_REGISTER_GROUP_E + 13) ///< 0x9C
+ #define INTR_CTRL_B_OSC_CNT_EN (1<<7)
+ #define INTR_CTRL_B_PWM_EN (1<<6)
+ #define INTR_CTRL_B_CBC_32_EN (1<<5)
+ #define INTR_CTRL_B_CBC_21_EN (1<<4)
+ #define INTR_CTRL_B_STB_EN (1<<3)
+ #define INTR_CTRL_B_ET_EN (1<<2)
+ #define INTR_CTRL_B_IT_EN (1<<1)
+ #define INTR_CTRL_B_RID_EN (1<<0)
+ #define REG_ITNR_CTRL_C (INTERNAL_REGISTER_GROUP_E + 14) ///< 0x9D
+ #define INTR_CTRL_C_BGRCAL_FINISH (1<<7)
+ #define INTR_CTRL_C_FW_V_DIVIDE (1<<6)
+ #define INTR_CTRL_C_BGRCAL_START (1<<5)
+ #define INTR_CTRL_C_BGR_CALEN (1<<4)
+ #define INTR_CTRL_C_PWM_SET (3<<2)
+ #define PWM_SET_32K (0<<2)
+ #define PWM_SET_16K (1<<2)
+ #define PWM_SET_8K (2<<2)
+ #define PWM_SET_4K (3<<2)
+ #define INTR_CTRL_C_TIMER_SET (3<<0)
+ #define TIMER_SET_OV_UV (0<<0)
+ #define TIMER_SET_OC_UC (1<<0)
+ #define TIMER_SET_OIT_UIT (2<<0)
+ #define TIMER_SET_OET_UET (3<<0)
+ #define REG_CELL_EN (INTERNAL_REGISTER_GROUP_E + 15) ///< 0x9E
+ #define CELL_EN_APPLICATION (7<<2)
+ #define APPLICATION_UG3100 (0<<2)
+ #define APPLICATION_UG3101 (1<<2)
+ #define APPLICATION_UG3102 (2<<2)
+ #define APPLICATION_UG3103_2 (4<<2)
+ #define APPLICATION_UG3103_3 (5<<2)
+ #define CELL_EN1 (1<<1)
+ #define CELL_EN0 (1<<0)
+
+#define INTERNAL_REGISTER_GROUP_F (0x9F)
+ #define REG_COC_LOW (INTERNAL_REGISTER_GROUP_F + 0) ///< 0x9F
+ #define REG_COC_HIGH (INTERNAL_REGISTER_GROUP_F + 1) ///< 0xA0
+ #define REG_DOC_LOW (INTERNAL_REGISTER_GROUP_F + 2) ///< 0xA1
+ #define REG_DOC_HIGH (INTERNAL_REGISTER_GROUP_F + 3) ///< 0xA2
+ #define REG_UC_LOW (INTERNAL_REGISTER_GROUP_F + 4) ///< 0xA3
+ #define REG_UC_HIGH (INTERNAL_REGISTER_GROUP_F + 5) ///< 0xA4
+ #define REG_OV1_LOW (INTERNAL_REGISTER_GROUP_F + 6) ///< 0xA5
+ #define REG_OV1_HIGH (INTERNAL_REGISTER_GROUP_F + 7) ///< 0xA6
+ #define REG_UV1_LOW (INTERNAL_REGISTER_GROUP_F + 8) ///< 0xA7
+ #define REG_UV1_HIGH (INTERNAL_REGISTER_GROUP_F + 9) ///< 0xA8
+ #define REG_OV2_LOW (INTERNAL_REGISTER_GROUP_F + 10) ///< 0xA9
+ #define REG_OV2_HIGH (INTERNAL_REGISTER_GROUP_F + 11) ///< 0xAA
+ #define REG_UV2_LOW (INTERNAL_REGISTER_GROUP_F + 12) ///< 0xAB
+ #define REG_UV2_HIGH (INTERNAL_REGISTER_GROUP_F + 13) ///< 0xAC
+ #define REG_OV3_LOW (INTERNAL_REGISTER_GROUP_F + 14) ///< 0xAD
+ #define REG_OV3_HIGH (INTERNAL_REGISTER_GROUP_F + 15) ///< 0xAE
+ #define REG_UV3_LOW (INTERNAL_REGISTER_GROUP_F + 16) ///< 0xAF
+ #define REG_UV3_HIGH (INTERNAL_REGISTER_GROUP_F + 17) ///< 0xB0
+ #define REG_OVP_LOW (INTERNAL_REGISTER_GROUP_F + 18) ///< 0xB1
+ #define REG_OVP_HIGH (INTERNAL_REGISTER_GROUP_F + 19) ///< 0xB2
+ #define REG_UVP_LOW (INTERNAL_REGISTER_GROUP_F + 20) ///< 0xB3
+ #define REG_UVP_HIGH (INTERNAL_REGISTER_GROUP_F + 21) ///< 0xB4
+ #define REG_INTR_OVER_TEMP_LOW (INTERNAL_REGISTER_GROUP_F + 22) ///< 0xB5
+ #define REG_INTR_OVER_TEMP_HIGH (INTERNAL_REGISTER_GROUP_F + 23) ///< 0xB6
+ #define REG_INTR_UNDER_TEMP_LOW (INTERNAL_REGISTER_GROUP_F + 24) ///< 0xB7
+ #define REG_INTR_UNDER_TEMP_HIGH (INTERNAL_REGISTER_GROUP_F + 25) ///< 0xB8
+ #define REG_EXTR_OVER_TEMP_LOW (INTERNAL_REGISTER_GROUP_F + 26) ///< 0xB9
+ #define REG_EXTR_OVER_TEMP_HIGH (INTERNAL_REGISTER_GROUP_F + 27) ///< 0xBA
+ #define REG_EXTR_UNDER_TEMP_LOW (INTERNAL_REGISTER_GROUP_F + 28) ///< 0xBB
+ #define REG_EXTR_UNDER_TEMP_HIGH (INTERNAL_REGISTER_GROUP_F + 29) ///< 0xBC
+ #define REG_CBC21_LOW (INTERNAL_REGISTER_GROUP_F + 30) ///< 0xBD
+ #define REG_CBC21_HIGH (INTERNAL_REGISTER_GROUP_F + 31) ///< 0xBE
+ #define REG_CBC32_LOW (INTERNAL_REGISTER_GROUP_F + 32) ///< 0xBF
+ #define REG_CBC32_HIGH (INTERNAL_REGISTER_GROUP_F + 33) ///< 0xC0
+
+#define INTERNAL_REGISTER_GROUP_G (0xC1)
+ #define REG_FW_CTRL (INTERNAL_REGISTER_GROUP_G + 0) ///< 0xC1
+ #define FW_CTRL_CHOP2_EN (1<<3)
+ #define FW_CTRL_CHOPPING2 (1<<2)
+ #define FW_CTRL_CHOP1_EN (1<<1)
+ #define FW_CTRL_CHOPPING1 (1<<0)
+ #define REG_OTP_CTRL (INTERNAL_REGISTER_GROUP_G + 1) ///< 0xC2
+ #define OTP_CTRL_IT_CAL80 (1<<7)
+ #define OTP_CTRL_IT_CAL25 (1<<6)
+ #define OTP_CTRL_ADC2_200MV (1<<5)
+ #define OTP_CTRL_ADC2_100MV (1<<4)
+ #define OTP_CTRL_ADC1_200MV (1<<3)
+ #define OTP_CTRL_ADC1_100MV (1<<2)
+ #define OTP_CTRL_OTP_PTM (3<<0)
+ #define REG_OTP_PPROG_ON (INTERNAL_REGISTER_GROUP_G + 2) ///< 0xC3
+ #define OTP_PPROG_ON_VALUE (0xDD)
+ #define REG_OTP_PPROG_OFF (INTERNAL_REGISTER_GROUP_G + 3) ///< 0xC4
+ #define OTP_PPROG_OFF_VALUE (0xDE)
+
+#define INTERNAL_REGISTER_GROUP_H (0xC5)
+ #define REG_ADC_CTR_A (INTERNAL_REGISTER_GROUP_H + 0) ///< 0xC5
+ #define ADC_CTR_A_SET_A (3<<6)
+ #define SET_A_CURRENT (0<<6)
+ #define SET_A_ET (1<<6)
+ #define SET_A_RID_IN (2<<6)
+ #define SET_A_IT (3<<6)
+ #define ADC_CTR_A_SET_B (3<<4)
+ #define SET_B_CURRENT (0<<4)
+ #define SET_B_ET (1<<4)
+ #define SET_B_RID_IN (2<<4)
+ #define SET_B_IT (3<<4)
+ #define ADC_CTR_A_SET_C (3<<2)
+ #define SET_C_CURRENT (0<<2)
+ #define SET_C_ET (1<<2)
+ #define SET_C_RID_IN (2<<2)
+ #define SET_C_IT (3<<2)
+ #define ADC_CTR_A_SET_D (3<<0)
+ #define SET_D_CURRENT (0<<0)
+ #define SET_D_ET (1<<0)
+ #define SET_D_RID_IN (2<<0)
+ #define SET_D_IT (3<<0)
+ #define REG_ADC_CTR_B (INTERNAL_REGISTER_GROUP_H + 1) ///< 0xC6
+ #define ADC_CTR_B_SET_E (3<<6)
+ #define SET_E_CURRENT (0<<6)
+ #define SET_E_ET (1<<6)
+ #define SET_E_RID_IN (2<<6)
+ #define SET_E_IT (3<<6)
+ #define ADC_CTR_B_SET_F (3<<4)
+ #define SET_F_CURRENT (0<<4)
+ #define SET_F_ET (1<<4)
+ #define SET_F_RID_IN (2<<4)
+ #define SET_F_IT (3<<4)
+ #define ADC_CTR_B_SET_G (3<<2)
+ #define SET_G_CURRENT (0<<2)
+ #define SET_G_ET (1<<2)
+ #define SET_G_RID_IN (2<<2)
+ #define SET_G_IT (3<<2)
+ #define ADC_CTR_B_SET_H (3<<0)
+ #define SET_H_CURRENT (0<<0)
+ #define SET_H_ET (1<<0)
+ #define SET_H_RID_IN (2<<0)
+ #define SET_H_IT (3<<0)
+ #define REG_ADC_CTR_C (INTERNAL_REGISTER_GROUP_H + 2) ///< 0xC7
+ #define ADC_CTR_C_SET_I (3<<6)
+ #define SET_I_CURRENT (0<<6)
+ #define SET_I_ET (1<<6)
+ #define SET_I_RID_IN (2<<6)
+ #define SET_I_IT (3<<6)
+ #define ADC_CTR_C_SET_J (3<<4)
+ #define SET_J_CURRENT (0<<4)
+ #define SET_J_ET (1<<4)
+ #define SET_J_RID_IN (2<<4)
+ #define SET_J_IT (3<<4)
+ #define ADC_CTR_C_SET_K (3<<2)
+ #define SET_K_CURRENT (0<<2)
+ #define SET_K_ET (1<<2)
+ #define SET_K_RID_IN (2<<2)
+ #define SET_K_IT (3<<2)
+ #define ADC_CTR_C_SET_L (3<<0)
+ #define SET_L_CURRENT (0<<0)
+ #define SET_L_ET (1<<0)
+ #define SET_L_RID_IN (2<<0)
+ #define SET_L_IT (3<<0)
+ #define REG_ADC_CTR_D (INTERNAL_REGISTER_GROUP_H + 3) ///< 0xC8
+ #define ADC_CTR_D_SET_M (3<<6)
+ #define SET_M_CURRENT (0<<6)
+ #define SET_M_ET (1<<6)
+ #define SET_M_RID_IN (2<<6)
+ #define SET_M_IT (3<<6)
+ #define ADC_CTR_D_SET_N (3<<4)
+ #define SET_N_CURRENT (0<<4)
+ #define SET_N_ET (1<<4)
+ #define SET_N_RID_IN (2<<4)
+ #define SET_N_IT (3<<4)
+ #define ADC_CTR_D_SET_O (3<<2)
+ #define SET_O_CURRENT (0<<2)
+ #define SET_O_ET (1<<2)
+ #define SET_O_RID_IN (2<<2)
+ #define SET_O_IT (3<<2)
+ #define ADC_CTR_D_SET_P (3<<0)
+ #define SET_P_CURRENT (0<<0)
+ #define SET_P_ET (1<<0)
+ #define SET_P_RID_IN (2<<0)
+ #define SET_P_IT (3<<0)
+ #define REG_ADC_V1 (INTERNAL_REGISTER_GROUP_H + 4) ///< 0xC9
+ #define ADC_CTR_V1_SET_V1 (3<<6)
+ #define SET_V1_GND (0<<6)
+ #define SET_V1_VBAT1 (1<<6)
+ #define SET_V1_VBAT2 (2<<6)
+ #define SET_V1_VBAT3 (3<<6)
+ #define ADC_CTR_V1_SET_V2 (3<<4)
+ #define SET_V2_GND (0<<4)
+ #define SET_V2_VBAT1 (1<<4)
+ #define SET_V2_VBAT2 (2<<4)
+ #define SET_V2_VBAT3 (3<<4)
+ #define ADC_CTR_V1_SET_V3 (3<<2)
+ #define SET_V3_GND (0<<2)
+ #define SET_V3_VBAT1 (1<<2)
+ #define SET_V3_VBAT2 (2<<2)
+ #define SET_V3_VBAT3 (3<<2)
+ #define ADC_CTR_V1_SET_V4 (3<<0)
+ #define SET_V4_GND (0<<0)
+ #define SET_V4_VBAT1 (1<<0)
+ #define SET_V4_VBAT2 (2<<0)
+ #define SET_V4_VBAT3 (3<<0)
+ #define REG_ADC_V2 (INTERNAL_REGISTER_GROUP_H + 5) ///< 0xCA
+ #define ADC_CTR_V2_SET_V5 (3<<6)
+ #define SET_V5_GND (0<<6)
+ #define SET_V5_VBAT1 (1<<6)
+ #define SET_V5_VBAT2 (2<<6)
+ #define SET_V5_VBAT3 (3<<6)
+ #define ADC_CTR_V2_SET_V6 (3<<4)
+ #define SET_V6_GND (0<<4)
+ #define SET_V6_VBAT1 (1<<4)
+ #define SET_V6_VBAT2 (2<<4)
+ #define SET_V6_VBAT3 (3<<4)
+ #define ADC_CTR_V2_SET_V7 (3<<2)
+ #define SET_V7_GND (0<<2)
+ #define SET_V7_VBAT1 (1<<2)
+ #define SET_V7_VBAT2 (2<<2)
+ #define SET_V7_VBAT3 (3<<2)
+ #define ADC_CTR_V2_SET_V8 (3<<0)
+ #define SET_V8_GND (0<<0)
+ #define SET_V8_VBAT1 (1<<0)
+ #define SET_V8_VBAT2 (2<<0)
+ #define SET_V8_VBAT3 (3<<0)
+ #define REG_ADC_V3 (INTERNAL_REGISTER_GROUP_H + 6) ///< 0xCB
+ #define ADC_CTR_V3_SET_V9 (3<<6)
+ #define SET_V9_GND (0<<6)
+ #define SET_V9_VBAT1 (1<<6)
+ #define SET_V9_VBAT2 (2<<6)
+ #define SET_V9_VBAT3 (3<<6)
+ #define ADC_CTR_V3_SET_V10 (3<<4)
+ #define SET_V10_GND (0<<4)
+ #define SET_V10_VBAT1 (1<<4)
+ #define SET_V10_VBAT2 (2<<4)
+ #define SET_V10_VBAT3 (3<<4)
+ #define ADC_CTR_V3_SET_V11 (3<<2)
+ #define SET_V11_GND (0<<2)
+ #define SET_V11_VBAT1 (1<<2)
+ #define SET_V11_VBAT2 (2<<2)
+ #define SET_V11_VBAT3 (3<<2)
+ #define ADC_CTR_V3_SET_V12 (3<<0)
+ #define SET_V12_GND (0<<0)
+ #define SET_V12_VBAT1 (1<<0)
+ #define SET_V12_VBAT2 (2<<0)
+ #define SET_V12_VBAT3 (3<<0)
+
+#define INTERNAL_REGISTER_GROUP_I (0xCC)
+ #define KCONFIG_D1 (INTERNAL_REGISTER_GROUP_I + 0) ///< 0xCC
+ #define KCONFIG_D_LOW (255<<0)
+ #define KCONFIG_D2 (INTERNAL_REGISTER_GROUP_I + 1) ///< 0xCD
+ #define KCONFIG_D_HIGH (255<<0)
+
+#define INTERNAL_REGISTER_GROUP_J (0xCE)
+ #define KCONFIG_A1 (INTERNAL_REGISTER_GROUP_J + 0) ///< 0xCE
+ #define KCONFIG_A1_KGG1_OSC (255<<0)
+ #define KCONFIG_A2 (INTERNAL_REGISTER_GROUP_J + 1) ///< 0xCF
+ #define KCONFIG_A2_KGG1_DSM2_L (255<<0)
+ #define KCONFIG_A3 (INTERNAL_REGISTER_GROUP_J + 2) ///< 0xD0
+ #define KCONFIG_A3_KGG1_DSM2_M (255<<0)
+ #define KCONFIG_A4 (INTERNAL_REGISTER_GROUP_J + 3) ///< 0xD1
+ #define KCONFIG_A4_KGG1_DSM2_H (255<<0)
+ #define KCONFIG_A5 (INTERNAL_REGISTER_GROUP_J + 4) ///< 0xD2
+ #define KCONFIG_A5_KGG1_DSM1_L (255<<0)
+ #define KCONFIG_A6 (INTERNAL_REGISTER_GROUP_J + 5) ///< 0xD3
+ #define KCONFIG_A6_KGG1_DSM1_M (255<<0)
+ #define KCONFIG_A7 (INTERNAL_REGISTER_GROUP_J + 6) ///< 0xD4
+ #define KCONFIG_A7_KGG1_DSM1_H (255<<0)
+ #define KCONFIG_A8 (INTERNAL_REGISTER_GROUP_J + 7) ///< 0xD5
+ #define KCONFIG_A8_KGG1_MBIAS_L (255<<0)
+ #define KCONFIG_A9 (INTERNAL_REGISTER_GROUP_J + 8) ///< 0xD6
+ #define KCONFIG_A9_KGG1_MBIAS_H (3<<0)
+
+ #define KCONFIG_H1 (INTERNAL_REGISTER_GROUP_J + 9) ///< 0xD7
+ #define KCONFIG_H1_KGG1_IDO_LOW (15<<4)
+ #define KCONFIG_H1_KGG1_MBIAS (3<<2)
+ #define KCONFIG_H1_KGG1_OSC (3<<2)
+ #define KCONFIG_H2 (INTERNAL_REGISTER_GROUP_J + 10) ///< 0xD8
+ #define KCONFIG_H2_KGG1_IDO_HIGH (255<<0)
+ #define KCONFIG_H3 (INTERNAL_REGISTER_GROUP_J + 11) ///< 0xD9
+ #define KCONFIG_H3_KGG1_BGAP_LOW (63<<2)
+ #define KCONFIG_H3_KGG1_DSM2 (3<<0)
+ #define KCONFIG_H4 (INTERNAL_REGISTER_GROUP_J + 12) ///< 0xDA
+ #define KCONFIG_H3_KGG1_BGAP_HIGH (127<<0)
+ #define KCONFIG_H5 (INTERNAL_REGISTER_GROUP_J + 13) ///< 0xDB
+ #define KCONFIG_H5_WIRE_V_DIVIDE (1<<6)
+ #define KCONFIG_H5_KGG1_BGAP_CAL (63<<0)
+
+#define INTERNAL_REGISTER_GROUP_K (0xDC)
+ #define KCONFIG_CAL1 (INTERNAL_REGISTER_GROUP_K + 0) ///< 0xDC
+ #define KCONFIG_CAL1_KGG1_OSC_L (255<<0)
+ #define KCONFIG_CAL2 (INTERNAL_REGISTER_GROUP_K + 1) ///< 0xDD
+ #define KCONFIG_CAL2_KGG1_OSC_H (255<<0)
+ #define KCONFIG_CAL3 (INTERNAL_REGISTER_GROUP_K + 2) ///< 0xDE
+ #define KCONFIG_CAL3_KGG1_DSM2 (255<<0)
+ #define KCONFIG_CAL4 (INTERNAL_REGISTER_GROUP_K + 3) ///< 0xDF
+ #define KCONFIG_CAL4_KGG1_DSM1 (255<<0)
+
+#define INTERNAL_REGISTER_GROUP_L (0xE0)
+ #define OTP1_BYTE1 (INTERNAL_REGISTER_GROUP_L + 0) ///< 0xE0
+ #define DELTA_VREF_3_0 (15<<4)
+ #define INDEX_ADC1_200_25_3_0 (15<<0)
+ #define OTP1_BYTE2 (INTERNAL_REGISTER_GROUP_L + 1) ///< 0xE1
+ #define FT_IT_6_3 (15<<4)
+ #define INDEX_ADC1_100_25_3_0 (15<<0)
+ #define OTP1_BYTE3 (INTERNAL_REGISTER_GROUP_L + 2) ///< 0xE2
+ #define FT_IT_10_7 (15<<4)
+ #define INDEX_ADC2_200_25_3_0 (15<<0)
+ #define OTP1_BYTE4 (INTERNAL_REGISTER_GROUP_L + 3) ///< 0xE3
+ #define FT_IT_14_11 (15<<4)
+ #define INDEX_ADC2_100_25_3_0 (15<<0)
+
+ #define OTP2_BYTE1 (INTERNAL_REGISTER_GROUP_L + 16) ///< 0xF0
+ #define DELTA_ET_1 (1<<7)
+ #define INDEX_ADC2_100_25_4 (1<<6)
+ #define DELTA_ET_0 (1<<5)
+ #define PRODUCT_TYPE (3<<3)
+ #define ITDELTACODE25_10_8 (7<<0)
+ #define OTP2_BYTE2 (INTERNAL_REGISTER_GROUP_L + 17) ///< 0xF1
+ #define ITDELTACODE25_7_0 (255<<0)
+ #define OTP2_BYTE3 (INTERNAL_REGISTER_GROUP_L + 18) ///< 0xF2
+ #define OTP_CELL_EN (31<<3)
+ #define ITDELTACODE80_10_8 (7<<0)
+ #define OTP2_BYTE4 (INTERNAL_REGISTER_GROUP_L + 19) ///< 0xF3
+ #define ITDELTACODE80_7_0 (255<<0)
+
+ #define OTP3_BYTE1 (INTERNAL_REGISTER_GROUP_L + 20) ///< 0xF4
+ #define DEVADDR_9_0 (63<<2)
+ #define ADC1DELTACODE25_200_9 (1<<1)
+ #define ADC1DELTACODE25_200_8 (1<<0)
+ #define OTP3_BYTE2 (INTERNAL_REGISTER_GROUP_L + 21) ///< 0xF5
+ #define BGRTUNE_5_0 (63<<2)
+ #define ADC1DELTACODE80_200_9_8 (3<<0)
+ #define OTP3_BYTE3 (INTERNAL_REGISTER_GROUP_L + 22) ///< 0xF6
+ #define OSCDELTACODE25 (255<<0)
+ #define OTP3_BYTE4 (INTERNAL_REGISTER_GROUP_L + 23) ///< 0xF7
+ #define OSCDELTACODE80 (255<<0)
+
+ #define OTP4_BYTE1 (INTERNAL_REGISTER_GROUP_L + 24) ///< 0xF8
+ #define ADC1DELTACODE25_200_7_0 (255<<0)
+ #define OTP4_BYTE2 (INTERNAL_REGISTER_GROUP_L + 25) ///< 0xF9
+ #define ADC1DELTACODE80_200_7_0 (255<<0)
+ #define OTP4_BYTE3 (INTERNAL_REGISTER_GROUP_L + 26) ///< 0xFA
+ #define ADC1DELTACODE25_100_7_0 (255<<0)
+ #define OTP4_BYTE4 (INTERNAL_REGISTER_GROUP_L + 27) ///< 0xFB
+ #define ADC1DELTACODE80_100_7_0 (255<<0)
+
+ #define OTP5_BYTE1 (INTERNAL_REGISTER_GROUP_L + 28) ///< 0xFC
+ #define ADC2DELTACODE25_100_6 (1<<7)
+ #define ADC2DELTACODE25_100_5_0 (63<<1)
+ #define ADC1DELTACODE25_100_8 (1<<0)
+ #define OTP5_BYTE2 (INTERNAL_REGISTER_GROUP_L + 29) ///< 0xFD
+ #define ADC2DELTACODE80_100_6_0 (127<<1)
+ #define ADC1DELTACODE80_100_8 (1<<0)
+ #define OTP5_BYTE3 (INTERNAL_REGISTER_GROUP_L + 30) ///< 0xFE
+ #define ADC2DELTACODE25_200_7 (1<<7)
+ #define ADC2DELTACODE25_200_6_0 (127<<0)
+ #define OTP5_BYTE4 (INTERNAL_REGISTER_GROUP_L + 31) ///< 0xFF
+ #define ADC2DELTACODE80_200_7_0 (255<<0)
+
diff --git a/board/wmt/wmt_battery/gauge/upi/ug31xx_boot.c b/board/wmt/wmt_battery/gauge/upi/ug31xx_boot.c
new file mode 100755
index 0000000..b92ea75
--- /dev/null
+++ b/board/wmt/wmt_battery/gauge/upi/ug31xx_boot.c
@@ -0,0 +1,804 @@
+/**
+ * @filename ug31xx_boot.c
+ *
+ * uG31xx operation in bootloader
+ *
+ * @author AllenTeng <allen_teng@upi-semi.com>
+ */
+
+#include <common.h>
+#ifdef CONFIG_BATT_UPI
+#include <asm/errno.h>
+//#include <app.h>
+//#include <debug.h>
+//#include <arch/arm.h>
+//#include <dev/udc.h>
+//#include <linux/string.h>
+//#include <kernel/thread.h>
+//#include <arch/ops.h>
+//#include <malloc.h>
+
+//#include <stdarg.h>
+
+#include "../../wmt_battery.h"
+
+#include "ug31xx_boot_i2c.h"
+#include "ug31xx_boot.h"
+#include "uG31xx_API.h"
+
+#define UG31XX_BOOT_VERSION (12)
+
+#define UG31XX_BOOT_STATUS_FCC_IS_0 (1<<0)
+#define UG31XX_BOOT_STATUS_IC_IS_NOT_ACTIVE (1<<1)
+#define UG31XX_BOOT_STATUS_WRONG_PRODUCT_TYPE (1<<2)
+#define DPRINTF(x,args...) printf("UG31xx " x , ##args)
+
+extern void ug31xx_init_i2c(int i2c_dev);
+
+UG31xxDataType ug31_data;
+
+typedef struct UG31xxDataInternalST {
+ UG31xxDataType *info;
+
+ CELL_PARAMETER ggbParameter;
+ CELL_TABLE ggbCellTable;
+
+ OtpDataType otpData;
+ MeasDataType measData;
+ SystemDataType sysData;
+
+ int tpTime;
+ int status;
+} UG31xxDataInternalType;
+
+#undef bool
+typedef enum _bool {false, true} bool;
+
+#include "ggb/ug31xx_ggb_data_uboot_wms8309_wm8_20130820_110949.h"
+#include "ggb/ug31xx_ggb_data_uboot_wms8309_c7_20130725_164935.h"
+#include "ggb/ug31xx_ggb_data_uboot_wms8309_c7_20130910_130553.h"
+#include "ggb/ug31xx_ggb_data_uboot_wms7320_20130718_200031.h"
+#include "ggb/ug31xx_ggb_data_uboot_cw500_20130801_103638.h"
+#include "ggb/ug31xx_ggb_data_uboot_mp718_20131004_070110.h"
+#include "ggb/ug31xx_ggb_data_uboot_t73v_20131120_001204.h"
+
+enum {
+ UG31XX_ID_3105,
+ UG31XX_ID_3102,
+};
+
+static int g_ug31xx_id;
+
+struct ggb_info {
+ char *name;
+ char *data;
+};
+
+/* Extern Function */
+static struct ggb_info ggb_arrays[] = {
+ {
+ .name = "wms8309wm8",
+ .data = FactoryGGBXFile_wms8309_wm8,
+ }, {
+ .name = "wms7320",
+ .data = FactoryGGBXFile_wms7320,
+ }, {
+ .name = "wms8309c7_3900mAh",
+ .data = FactoryGGBXFile_wms8309_c7_3900mAh,
+ }, {
+ .name = "wms8309c7_3000mAh",
+ .data = FactoryGGBXFile_wms8309_c7_3000mAh,
+ }, {
+ .name = "cw500",
+ .data = FactoryGGBXFile_cw500,
+ }, {
+ .name = "mp718",
+ .data = FactoryGGBXFile_mp718,
+ }, {
+ .name = "t73v",
+ .data = FactoryGGBXFile_t73v,
+ },
+};
+
+struct ug31xx_param {
+ int i2c_adapter;
+ int external_temperature;
+ int charge_temperature_range[2];
+ struct ggb_info *ggb;
+};
+
+static struct ug31xx_param ug31xx_param = {
+ .i2c_adapter = 1,
+ .external_temperature = 1,
+ .charge_temperature_range = { -150, 600 },
+ .ggb = &ggb_arrays[0],
+};
+
+static int parse_battery_param(void)
+{
+ enum {
+ idx_i2c,
+ idx_et,
+ idx_temp0,
+ idx_temp1,
+ idx_max
+ };
+ long ps[idx_max] = { 0, };
+ char *p, *env;
+ char *endp;
+ int i = 0;
+
+ env = p = getenv("wmt.battery.param");
+ if (!p)
+ return -EINVAL;
+
+ if (!prefixcmp(p, "ug3105"))
+ g_ug31xx_id = UG31XX_ID_3105;
+ else if (!prefixcmp(p, "ug3102"))
+ g_ug31xx_id = UG31XX_ID_3102;
+ else
+ return -EINVAL;
+
+ p += 7; // skip "ug3105:"
+
+ while (i < idx_max) {
+ ps[i++] = simple_strtol(p, &endp, 10);
+ if (*endp == '\0')
+ break;
+ p = endp + 1;
+
+ if (*p == '\0')
+ break;
+ }
+
+ ug31xx_param.i2c_adapter = ps[idx_i2c];
+ ug31xx_param.external_temperature = ps[idx_et];
+ if (ps[idx_temp1] > ps[idx_temp0]) {
+ ug31xx_param.charge_temperature_range[0] = ps[idx_temp0];
+ ug31xx_param.charge_temperature_range[1] = ps[idx_temp1];
+ }
+
+ for (i = 0; i < ARRAY_SIZE(ggb_arrays); i++) {
+ if (strstr(env, ggb_arrays[i].name)) {
+ ug31xx_param.ggb = &ggb_arrays[i];
+ break;
+ }
+ }
+
+ printf("%s i2c%d, ggb %s, %s, charge temperature range [%d, %d]\n",
+ (g_ug31xx_id == UG31XX_ID_3105) ? "ug3105" : "ug3102",
+ ug31xx_param.i2c_adapter,
+ ug31xx_param.ggb->name,
+ ug31xx_param.external_temperature ? "ET" : "IT",
+ ug31xx_param.charge_temperature_range[0],
+ ug31xx_param.charge_temperature_range[1]);
+ return 0;
+}
+
+/**
+ * @brief GetTickCount
+ *
+ * Get tick count in milli-second
+ *
+ * @return tick count
+ */
+_upi_u32_ GetTickCount(void)
+{
+ return (0);
+}
+
+/**
+ * @brief GetSysTickCount
+ *
+ * Get system tick count in milli-second
+ *
+ * @return tick count
+ */
+_upi_u32_ GetSysTickCount(void)
+{
+ return (0);
+}
+
+/**
+ * @brief ug31_dprintk
+ *
+ * print debug message
+ *
+ * @para level debug message level
+ * @para fmt debug message
+ * @return message length
+ */
+#if 0
+int ug31_dprintk(int level, const char *fmt, ...)
+{
+ va_list args;
+ int r;
+
+ va_start(args, fmt);
+ //r = dprintk(level, fmt, args);
+ r = NULL;
+ va_end(args);
+ return (r);
+}
+#endif
+
+
+#define TP_REACH_SOC (100)
+
+void CheckRsocBeforeTP(UG31xxDataInternalType *obj)
+{
+ int rm;
+
+ if(obj->sysData.rsocFromIC >= TP_REACH_SOC)
+ {
+ obj->sysData.rsocFromIC = TP_REACH_SOC - 1;
+
+ rm = (int)obj->sysData.rsocFromIC;
+ rm = rm*obj->sysData.fccFromIC/100;
+ obj->sysData.rmFromIC = (_sys_u16_)rm;
+ return;
+ }
+
+ if(obj->sysData.rmFromIC > obj->sysData.fccFromIC)
+ {
+ obj->sysData.rmFromIC = obj->sysData.fccFromIC;
+ }
+}
+
+/**
+ * @brief ResetFullCharge
+ *
+ * Reset full charge checking module
+ *
+ * @para obj address of UG31xxDataInternalType
+ * @return NULL
+ */
+void ResetFullCharge(UG31xxDataInternalType *obj)
+{
+ obj->tpTime = 0;
+
+ CheckRsocBeforeTP(obj);
+}
+
+#define TP_COUNT_INTERVAL (5)
+
+/**
+ * @brief FullChargeCheck
+ *
+ * Check full charge condition
+ *
+ * @para obj address of UG31xxDataInternalType
+ * @return NULL
+ */
+void FullChargeCheck(UG31xxDataInternalType *obj)
+{
+ if(obj->tpTime >= obj->ggbParameter.TPTime)
+ {
+ return;
+ }
+
+ /// [AT-PM] : Check taper voltage ; 02/01/2013
+ if(obj->measData.bat1Voltage < obj->ggbParameter.TPVoltage)
+ {
+ ResetFullCharge(obj);
+ return;
+ }
+
+ /// [AT-PM] : Check taper current ; 02/01/2013
+ if((obj->measData.curr < obj->ggbParameter.standbyCurrent) ||
+ (obj->measData.curr > obj->ggbParameter.TPCurrent))
+ {
+ ResetFullCharge(obj);
+ return;
+ }
+
+ /// [AT-PM] : Check taper time ; 02/01/2013
+ obj->tpTime = obj->tpTime + TP_COUNT_INTERVAL;
+ if(obj->tpTime < obj->ggbParameter.TPTime)
+ {
+ CheckRsocBeforeTP(obj);
+ return;
+ }
+
+ /// [AT-PM] : Set full charge condition ; 02/01/2013
+ obj->sysData.rsocFromIC = TP_REACH_SOC;
+ obj->sysData.rmFromIC = obj->sysData.fccFromIC;
+}
+
+/**
+ * @brief SetMemoryMapping
+ *
+ * Set memory mapping
+ *
+ * @para data address of UG31xxDataType
+ * @para obj address of UG31xxDataInternalType pointer
+ * @return NULL
+ */
+void SetMemoryMapping(UG31xxDataType *data, UG31xxDataInternalType **obj)
+{
+ (*obj) = (UG31xxDataInternalType *)data->buf;
+ (*obj)->info = data;
+ (*obj)->measData.sysData = &((*obj)->sysData);
+ (*obj)->measData.otp = &((*obj)->otpData);
+ (*obj)->sysData.ggbXBuf = (GGBX_FILE_HEADER *)(ug31xx_param.ggb->data);
+ (*obj)->sysData.ggbParameter = &((*obj)->ggbParameter);
+ (*obj)->sysData.ggbCellTable = &((*obj)->ggbCellTable);
+ (*obj)->sysData.otpData = &((*obj)->otpData);
+ //printf("[SetMemoryMapping] ggb_tag (%d) = %d\n", sizeof((*obj)->sysData.ggbXBuf->ggb_tag), (*obj)->sysData.ggbXBuf->ggb_tag);
+ //printf("[SetMemoryMapping] sum16 (%d) = %d\n", sizeof((*obj)->sysData.ggbXBuf->sum16), (*obj)->sysData.ggbXBuf->sum16);
+ //printf("[SetMemoryMapping] time_stamp (%d) = %d\n", sizeof((*obj)->sysData.ggbXBuf->time_stamp), (*obj)->sysData.ggbXBuf->time_stamp);
+ //printf("[SetMemoryMapping] length (%d) = %d\n", sizeof((*obj)->sysData.ggbXBuf->length), (*obj)->sysData.ggbXBuf->length);
+ //printf("[SetMemoryMapping] num_ggb (%d) = %d\n", sizeof((*obj)->sysData.ggbXBuf->num_ggb), (*obj)->sysData.ggbXBuf->num_ggb);
+}
+
+#define CURRENT_MAGIC_NUMBER (4)
+#define OCV_TABLE_INDEX (1)
+
+static int OcvTableSoc[] = {
+ 100,
+ 95,
+ 90,
+ 85,
+ 80,
+ 75,
+ 70,
+ 65,
+ 60,
+ 55,
+ 50,
+ 45,
+ 40,
+ 35,
+ 30,
+ 25,
+ 20,
+ 15,
+ 10,
+ 5,
+ 0,
+};
+
+/**
+ * @brief InitCharge
+ *
+ * Look up initial charge from table
+ *
+ * @para obj address of UG31xxDataInternalType
+ * @return NULL
+ */
+void InitCharge(UG31xxDataInternalType *obj)
+{
+ int volt;
+ int tmp;
+ int idxTemp;
+ int idxSoc;
+ int ocv;
+
+ /// [AT-PM] : FCC is equal to ILMD ; 02/24/2013
+ obj->info->fcc = (int)obj->ggbParameter.ILMD;
+
+ /// [AT-PM] : Real battery voltage ; 02/24/2013
+ volt = (int)obj->measData.bat1Voltage;
+ tmp = (int)obj->measData.curr;
+ tmp = tmp/CURRENT_MAGIC_NUMBER;
+ if(tmp > 0)
+ {
+ volt = volt - tmp;
+ }
+
+ /// [AT-PM] : Look up table ; 02/24/2013
+ idxSoc = 0;
+ while(idxSoc < OCV_NUMS)
+ {
+ idxTemp = 0;
+ ocv = 0;
+ while(idxTemp < TEMPERATURE_NUMS)
+ {
+ ocv = ocv + obj->ggbCellTable.INIT_OCV[idxTemp][OCV_TABLE_INDEX][idxSoc];
+ idxTemp = idxTemp + 1;
+ }
+ ocv = ocv/TEMPERATURE_NUMS;
+
+ if(volt >= ocv)
+ {
+ break;
+ }
+
+ idxSoc = idxSoc + 1;
+ }
+ if(idxSoc < OCV_NUMS)
+ {
+ obj->info->rsoc = OcvTableSoc[idxSoc];
+ }
+ else
+ {
+ obj->info->rsoc = 0;
+ }
+
+ /// [AT-PM] : Calculate RM ; 02/24/2013
+ tmp = obj->info->rsoc;
+ tmp = tmp*obj->info->fcc/CONST_PERCENTAGE;
+ obj->info->rm = tmp;
+}
+
+/// ===========================================================================
+/// Extern region
+/// ===========================================================================
+
+#define DEFAULT_ADC1_CONV_TIME (1250)
+#define DEFAULT_TIME_TICK (0xFFFFFFFF)
+
+/**
+ * @brief UpiBootInitial
+ *
+ * Initialize uG31xx
+ *
+ * @para data address of UG31xxDataType
+ * @return UPI_BOOT_RTN
+ */
+int UpiBootInitial(UG31xxDataType *data)
+{
+ UG31xxDataInternalType *obj;
+
+ //dprintf(INFO, "[UpiBootInitial] Version = %d\n", UG31XX_BOOT_VERSION);
+ printf("[UpiBootInitial] Version = %d\n", UG31XX_BOOT_VERSION);
+
+ /// [AT-PM] : Create memory buffer ; 02/01/2013
+ data->buf = (char *)malloc(sizeof(UG31xxDataInternalType));
+ memset(data->buf, 0, sizeof(UG31xxDataInternalType));
+ obj = _UPI_NULL_;
+ SetMemoryMapping(data, &obj);
+
+ data->version = UG31XX_BOOT_VERSION;
+ obj->status = 0;
+
+ //dprintf(INFO, "[UpiBootInitial] data->ug31xx_i2c_dev = %d\n",data->ug31xx_i2c_dev);
+ /// [AT-PM] : Initial I2C device ; 02/04/2013
+ //ug31xx_init_i2c(data->ug31xx_i2c_dev);
+
+ /// [AT-PM] : Load GGB data ; 02/24/2013
+ UpiInitSystemData(&obj->sysData);
+ printf("[UPI Boot GGB]: %d (0x%04x)\n", obj->ggbCellTable.INIT_OCV[0][0][0], obj->ggbCellTable.INIT_OCV[0][0][0]);
+ printf("[UPI Boot GGB]: %d (0x%04x)\n", obj->ggbParameter.adc1_pgain, obj->ggbParameter.adc1_pgain);
+ printf("[UPI Boot GGB]: %d (0x%04x)\n", obj->ggbParameter.adc1_ngain, obj->ggbParameter.adc1_ngain);
+ printf("[UPI Boot GGB]: %d (0x%04x)\n", obj->ggbParameter.adc1_pos_offset, obj->ggbParameter.adc1_pos_offset);
+ printf("[UPI Boot GGB]: %d (0x%04x)\n", obj->ggbParameter.adc2_gain, obj->ggbParameter.adc2_gain);
+ printf("[UPI Boot GGB]: %d (0x%04x)\n", obj->ggbParameter.adc2_offset, obj->ggbParameter.adc2_offset);
+
+ /// [AT-PM] : Get capacity information from IC ; 02/24/2013
+ UpiLoadBatInfoFromIC(&obj->sysData);
+ if(obj->sysData.fccFromIC == 0)
+ {
+ //dprintf(CRITICAL, "[UpiBootInitial] Capacity in uG31xx is invalid.\n");
+ printf("[UpiBootInitial] Capacity in uG31xx is invalid.\n");
+ obj->status = obj->status | UG31XX_BOOT_STATUS_FCC_IS_0;
+ }
+
+ /// [AT-PM] : Check IC is active or not ; 02/24/2013
+ if(UpiCheckICActive() == _UPI_TRUE_)
+ {
+ //dprintf(CRITICAL, "[UpiBootInitial] uG31xx is not actived.\n");
+ printf("[UpiBootInitial] uG31xx is not actived.\n");
+ obj->status = obj->status | UG31XX_BOOT_STATUS_IC_IS_NOT_ACTIVE;
+
+ /// [AT-PM] : Active uG31xx ; 02/24/2013
+ if(UpiActiveUg31xx() != SYSTEM_RTN_PASS)
+ {
+ return (UPI_BOOT_RTN_UG31XX_NOT_ACTIVE);
+ }
+
+ /// [AT-PM] : Initialize ADC ; 02/24/2013
+ UpiSetupAdc(&obj->sysData);
+
+ /// [AT-PM] : Initialize system ; 02/24/2013
+ UpiSetupSystem(&obj->sysData);
+ }
+
+ /// [AT-PM] : Get OTP data ; 02/24/2013
+ API_I2C_Read(SECURITY, UG31XX_I2C_HIGH_SPEED_MODE, UG31XX_I2C_TEM_BITS_MODE, OTP1_BYTE1, OTP1_SIZE, obj->otpData.otp1);
+ API_I2C_Read(SECURITY, UG31XX_I2C_HIGH_SPEED_MODE, UG31XX_I2C_TEM_BITS_MODE, OTP2_BYTE1, OTP2_SIZE, obj->otpData.otp2);
+ API_I2C_Read(NORMAL, UG31XX_I2C_HIGH_SPEED_MODE, UG31XX_I2C_TEM_BITS_MODE, OTP6_BYTE1, OTP3_SIZE, obj->otpData.otp3);
+ #ifdef UPI_UBOOT_DEBUG_MSG
+ printf("[UpiBootInitial] %02x %02x %02x %02x\n",
+ obj->otpData.otp1[0], obj->otpData.otp1[1], obj->otpData.otp1[2], obj->otpData.otp1[3]);
+ printf("[UpiBootInitial] %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x\n",
+ obj->otpData.otp2[0], obj->otpData.otp2[1], obj->otpData.otp2[2], obj->otpData.otp2[3],
+ obj->otpData.otp2[4], obj->otpData.otp2[5], obj->otpData.otp2[6], obj->otpData.otp2[7],
+ obj->otpData.otp2[8], obj->otpData.otp2[9], obj->otpData.otp2[10], obj->otpData.otp2[11],
+ obj->otpData.otp2[12], obj->otpData.otp2[13], obj->otpData.otp2[14], obj->otpData.otp2[15]);
+ printf("[UpiBootInitial] %02x %02x %02x %02x\n",
+ obj->otpData.otp3[0], obj->otpData.otp3[1], obj->otpData.otp3[2], obj->otpData.otp3[3]);
+ #endif ///< end of UPI_UBOOT_DEBUG_MSG
+ UpiConvertOtp(&obj->otpData);
+ if(obj->otpData.productType != UG31XX_PRODUCT_TYPE_0)
+ {
+ //dprintf(CRITICAL, "[UpiBootInitial] uG31xx product type is not %d (%d)\n", UG31XX_PRODUCT_TYPE_0, obj->otpData.productType);
+ printf("[UpiBootInitial] uG31xx product type is not %d (%d)\n", UG31XX_PRODUCT_TYPE_0, obj->otpData.productType);
+ obj->status = obj->status | UG31XX_BOOT_STATUS_WRONG_PRODUCT_TYPE;
+ return (UPI_BOOT_RTN_INVALID_PRODUCT_TYPE);
+ }
+
+ /// [AT-PM] : Initialize UG31xxInternalDataType ; 02/24/2013
+ if(obj->status & (UG31XX_BOOT_STATUS_FCC_IS_0 | UG31XX_BOOT_STATUS_IC_IS_NOT_ACTIVE))
+ {
+ /// [AT-PM] : Data for IC not active ; 02/24/2013
+ obj->measData.lastDeltaCap = 0;
+ obj->measData.adc1ConvertTime = DEFAULT_ADC1_CONV_TIME;
+ /// [AT-PM] : Do measurement ; 02/24/2013
+ obj->measData.lastTimeTick = DEFAULT_TIME_TICK;
+ UpiMeasurement(&obj->measData);
+ data->volt = (int)obj->measData.bat1Voltage;
+ data->curr = (int)obj->measData.curr;
+ data->intTemp = (int)obj->measData.intTemperature;
+ data->extTemp = (int)obj->measData.extTemperature;
+ /// [AT-PM] : Look up initial capacity from table ; 02/24/2013
+ InitCharge(obj);
+ obj->sysData.rmFromIC = (_sys_u16_)obj->info->rm;
+ obj->sysData.fccFromIC = (_sys_u16_)obj->info->fcc;
+ obj->sysData.rsocFromIC = (_sys_u8_)obj->info->rsoc;
+ //dprintf(INFO, "[UpiBootInitial] (Lookup Table) %d / %d / %d - %d / %d = %d\n", data->volt, data->curr, data->intTemp, data->rm, data->fcc, data->rsoc);
+ printf("[UpiBootInitial] (Lookup Table) %d / %d / %d - %d / %d = %d\n", data->volt, data->curr, data->intTemp, data->rm, data->fcc, data->rsoc);
+ }
+ else
+ {
+ /// [AT-PM] : Data for IC active ; 02/24/2013
+ obj->measData.lastDeltaCap = obj->sysData.deltaCapFromIC;
+ obj->measData.adc1ConvertTime = obj->sysData.adc1ConvTime;
+ /// [AT-PM] : Do measurement ; 02/24/2013
+ obj->measData.lastTimeTick = DEFAULT_TIME_TICK;
+ UpiMeasurement(&obj->measData);
+ data->volt = (int)obj->measData.bat1Voltage;
+ data->curr = (int)obj->measData.curr;
+ data->intTemp = (int)obj->measData.intTemperature;
+ data->extTemp = (int)obj->measData.extTemperature;
+ /// [AT-PM] : Set capacity information ; 02/24/2013
+ obj->info->rm = (int)obj->sysData.rmFromIC;
+ obj->info->fcc = (int)obj->sysData.fccFromIC;
+ obj->info->rsoc = (int)obj->sysData.rsocFromIC;
+ //dprintf(INFO, "[UpiBootInitial] (Load From IC) %d / %d / %d - %d / %d = %d\n", data->volt, data->curr, data->intTemp, data->rm, data->fcc, data->rsoc);
+ printf("[UpiBootInitial] (Load From IC) %d / %d / %d - %d / %d = %d\n", data->volt, data->curr, data->intTemp, data->rm, data->fcc, data->rsoc);
+ }
+ return (UPI_BOOT_RTN_PASS);
+}
+
+/**
+ * @brief UpiBootMain
+ *
+ * Main function of uG31xx
+ *
+ * @para data address of UG31xxDataType
+ * @return UPI_BOOT_RTN
+ */
+int UpiBootMain(UG31xxDataType *data)
+{
+ UG31xxDataInternalType *obj;
+ MEAS_RTN_CODE rtn;
+
+ //dprintf(INFO, "[UpiBootMain]\n");
+ //printf("[UpiBootMain]\n");
+ obj = _UPI_NULL_;
+ SetMemoryMapping(data, &obj);
+
+ /// [AT-PM] : Do measurement ; 02/24/2013
+ obj->measData.lastTimeTick = DEFAULT_TIME_TICK;
+ rtn = UpiMeasurement(&obj->measData);
+ if(rtn != MEAS_RTN_PASS)
+ {
+ //dprintf(INFO, "[UpiBootMain] uG31xx measurement routine fail 0x%02x\n", rtn);
+ printf("[UpiBootMain] uG31xx measurement routine fail 0x%02x\n", rtn);
+
+ data->rm = 0;
+ data->fcc = 0;
+ data->rsoc = 0;
+ return (rtn);
+ }
+
+ /// [AT-PM] : Update capacity ; 02/13/2013
+ obj->sysData.voltage = obj->measData.bat1Voltage;
+ if((obj->measData.curr < 0) && (obj->measData.stepCap > 0))
+ {
+ obj->measData.stepCap = 0;
+ }
+ else if((obj->measData.curr > 0) && (obj->measData.stepCap < 0))
+ {
+ obj->measData.stepCap = 0;
+ }
+ UpiUpdateBatInfoFromIC(&obj->sysData, obj->measData.stepCap);
+
+ /// [AT-PM] : Reset coulomb counter ; 02/24/2013
+ obj->measData.lastTimeTick = DEFAULT_TIME_TICK;
+ if(obj->measData.deltaCap > 10)
+ {
+ UpiResetCoulombCounter(&obj->measData);
+ }
+
+ //dprintf(INFO, "[UpiBootMain] %d / %d / %d\n", obj->measData.codeBat1, obj->measData.codeCurrent, obj->measData.codeIntTemperature);
+ //dprintf(INFO, "[UpiBootMain] %d - %d / %d - %d\n", obj->measData.adc1Gain, obj->measData.adc1Offset, obj->measData.adc2Gain, obj->measData.adc2Offset);
+ //dprintf(INFO, "[UpiBootMain] Voltage : %d - %d\n", obj->ggbParameter.adc2_gain, obj->ggbParameter.adc2_offset);
+ //dprintf(INFO, "[UpiBootMain] Current : %d - %d - %d\n", obj->ggbParameter.adc1_pgain, obj->ggbParameter.adc1_ngain, obj->ggbParameter.adc1_pos_offset);
+ //dprintf(INFO, "[UpiBootMain] Int. T : %d\n", obj->ggbParameter.adc_d3);
+
+ //printf("[UpiBootMain] %d / %d / %d\n", obj->measData.codeBat1, obj->measData.codeCurrent, obj->measData.codeIntTemperature);
+ //printf("[UpiBootMain] %d - %d / %d - %d\n", obj->measData.adc1Gain, obj->measData.adc1Offset, obj->measData.adc2Gain, obj->measData.adc2Offset);
+ //printf("[UpiBootMain] Voltage : %d - %d\n", obj->ggbParameter.adc2_gain, obj->ggbParameter.adc2_offset);
+ //printf("[UpiBootMain] Current : %d - %d - %d\n", obj->ggbParameter.adc1_pgain, obj->ggbParameter.adc1_ngain, obj->ggbParameter.adc1_pos_offset);
+ //printf("[UpiBootMain] Int. T : %d\n", obj->ggbParameter.adc_d3);
+
+ data->volt = (int)obj->measData.bat1Voltage;
+ data->curr = (int)obj->measData.curr;
+ data->intTemp = (int)obj->measData.intTemperature;
+ data->extTemp = (int)obj->measData.extTemperature;
+
+ /// [AT-PM] : Full charge determination ; 02/01/2013
+ FullChargeCheck(obj);
+
+ /// [AT-PM] : Refresh capacity information ; 02/24/2013
+ data->rm = (int)obj->sysData.rmFromIC;
+ data->fcc = (int)obj->sysData.fccFromIC;
+ data->rsoc = (int)obj->sysData.rsocFromIC;
+ //dprintf(INFO, "[UpiBootMain] %d / %d / %d - %d / %d = %d\n", data->volt, data->curr, data->intTemp, data->rm, data->fcc, data->rsoc);
+ //printf("[UpiBootMain] %d / %d / %d - %d / %d = %d\n", data->volt, data->curr, data->intTemp, data->rm, data->fcc, data->rsoc);
+
+ /// [AT-PM] : Save battery information back to IC ; 02/24/2013
+ if(obj->status & (UG31XX_BOOT_STATUS_FCC_IS_0 | UG31XX_BOOT_STATUS_IC_IS_NOT_ACTIVE))
+ {
+ obj->sysData.fccFromIC = 0;
+ }
+ UpiSaveBatInfoTOIC(&obj->sysData);
+ obj->sysData.fccFromIC = (_sys_u16_)data->fcc;
+#if 0
+ printf("battery volt = %d\n", data->volt);
+ printf("battery curr = %d\n", data->curr);
+ printf("battery intTemp = %d\n", data->intTemp);
+ printf("battery extTemp = %d\n", data->extTemp);
+ printf("battery rm = %d\n", data->rm);
+ printf("battery fcc = %d\n", data->fcc);
+ printf("battery rsoc = %d\n", data->rsoc);
+#endif
+ return (UPI_BOOT_RTN_PASS);
+}
+
+/**
+ * @brief UpiBootUnInitial
+ *
+ * Un-initialize uG31xx
+ *
+ * @para data address of UG31xxDataType
+ * @return UPI_BOOT_RTN
+ */
+int UpiBootUnInitial(UG31xxDataType *data)
+{
+ printf("[UpiBootUninitial]\n");
+
+ free(data->buf);
+ return (UPI_BOOT_RTN_PASS);
+}
+
+/*
+ * WMT MCE: Use gpio3 on ug31xx as a switch to control charger.
+ */
+static void hw_charging_set(bool enable)
+{
+ if (g_ug31xx_id == UG31XX_ID_3105) {
+ API_I2C_SingleWrite(0, 0, 0, 0x16, enable ? 0x2 : 0x0);
+ } else if (g_ug31xx_id == UG31XX_ID_3102) {
+ u8 data = 0;
+ API_I2C_SingleRead(0, 0, 0 ,REG_CTRL1, &data);
+ if (enable)
+ data |= CTRL1_IO1DATA;
+ else
+ data &= ~CTRL1_IO1DATA;
+ API_I2C_SingleWrite(0, 0, 0, REG_CTRL1, data);
+ }
+}
+
+static void inline hw_charging_disable(void)
+{
+ hw_charging_set(false);
+}
+
+static void inline hw_charging_enable(void)
+{
+ hw_charging_set(true);
+}
+
+static unsigned short percentage = -1;
+
+int upi_read_percentage(void)
+{
+ UpiBootMain(&ug31_data);
+ percentage = ug31_data.rsoc;
+
+ if (g_ug31xx_id == UG31XX_ID_3105) {
+ printf("%s: percentage = %d, temperature %d\n",
+ __FUNCTION__, percentage, ug31_data.extTemp);
+ if (ug31xx_param.external_temperature) {
+ if (ug31_data.extTemp < ug31xx_param.charge_temperature_range[0] ||
+ ug31_data.extTemp > ug31xx_param.charge_temperature_range[1]) {
+ hw_charging_disable();
+ } else {
+ hw_charging_enable();
+ }
+ printf("%s: percentage = %d, temperature %d\n",
+ __FUNCTION__, percentage, ug31_data.extTemp);
+ }
+ } else if (g_ug31xx_id == UG31XX_ID_3102) {
+ hw_charging_enable();
+ }
+
+ return percentage;
+}
+
+int upi_read_voltage(void)
+{
+ int volt_mV;
+
+ UpiBootMain(&ug31_data);
+ volt_mV = ug31_data.volt;
+ printf("voltage = %d mV\n", volt_mV);
+
+ return volt_mV;
+}
+
+int upi_read_current(void)
+{
+ int current;
+
+ UpiBootMain(&ug31_data);
+ current = ug31_data.curr;
+ printf("current = %d mA\n", current);
+
+ return current;
+}
+
+int upi_boot_init(void)
+{
+ int ret;
+
+ if (parse_battery_param())
+ return -EINVAL;
+
+ ug31xx_init_i2c(ug31xx_param.i2c_adapter);
+
+ ret = UpiBootInitial(&ug31_data);
+
+ hw_charging_enable();
+
+ return (ret == UPI_BOOT_RTN_PASS) ? 0 : -1;
+}
+
+static int upi_check_bl(void)
+{
+ int ret;
+
+ if (percentage < 0) {
+ upi_read_percentage();
+ }
+
+ ret = (percentage < 3);
+ printf("%s: percentage = %d, temperature %d, ret %d\n",
+ __FUNCTION__, ug31_data.rsoc, ug31_data.extTemp, ret);
+
+ return ret;
+}
+
+struct battery_dev ug31xx_battery_dev = {
+ .name = "ug3105",
+ .is_gauge = 1,
+ .init = upi_boot_init,
+ .get_capacity = upi_read_percentage,
+ .get_voltage = upi_read_voltage,
+ .get_current = upi_read_current,
+ .check_batlow = upi_check_bl,
+};
+
+struct battery_dev ug3102_battery_dev = {
+ .name = "ug3102",
+ .is_gauge = 1,
+ .init = upi_boot_init,
+ .get_capacity = upi_read_percentage,
+ .get_voltage = upi_read_voltage,
+ .get_current = upi_read_current,
+ .check_batlow = upi_check_bl,
+};
+#endif
diff --git a/board/wmt/wmt_battery/gauge/upi/ug31xx_boot.h b/board/wmt/wmt_battery/gauge/upi/ug31xx_boot.h
new file mode 100755
index 0000000..730a4bf
--- /dev/null
+++ b/board/wmt/wmt_battery/gauge/upi/ug31xx_boot.h
@@ -0,0 +1,71 @@
+/**
+ * @filename ug31xx_boot.h
+ *
+ * uG31xx API for bootloader
+ *
+ * @author AllenTeng <allen_teng@upi-semi.com>
+ */
+
+#ifndef _UG31XX_BOOT_H_
+#define _UG31XX_BOOT_H_
+
+enum UPI_BOOT_RTN {
+ UPI_BOOT_RTN_PASS = 0,
+ UPI_BOOT_RTN_UG31XX_NOT_ACTIVE,
+ UPI_BOOT_RTN_INVALID_CAPACITY,
+ UPI_BOOT_RTN_INVALID_PRODUCT_TYPE,
+};
+
+typedef struct UG31xxDataST {
+ //struct qup_i2c_dev *ug31xx_i2c_dev;
+
+ int version;
+
+ int rm; ///< [AT-PM] : in unit mAh ; 02/01/2013
+ int fcc; ///< [AT-PM] : in unit mAh ; 02/01/2013
+ int rsoc; ///< [AT-PM] : in unit % ; 02/01/2013
+
+ int volt; ///< [AT-PM] : in unit mV ; 02/01/2013
+ int curr; ///< [AT-PM] : in unit mA ; 02/01/2013
+ int intTemp; ///< [AT-PM] : in unit 0.1oC ; 02/01/2013
+ int extTemp; ///< [AT-PM] : in unit 0.1oC ; 02/01/2013
+
+ char *buf;
+} UG31xxDataType;
+
+/**
+ * @brief UpiBootInitial
+ *
+ * Initialize uG31xx
+ *
+ * @para data address of UG31xxDataType
+ * @return UPI_BOOT_RTN_PASS
+ */
+extern int UpiBootInitial(UG31xxDataType *data);
+
+/**
+ * @brief UpiBootMain
+ *
+ * Main function of uG31xx
+ *
+ * @para data address of UG31xxDataType
+ * @return UPI_BOOT_RTN_PASS
+ */
+extern int UpiBootMain(UG31xxDataType *data);
+
+/**
+ * @brief UpiBootUnInitial
+ *
+ * Un-initialize uG31xx
+ *
+ * @para data address of UG31xxDataType
+ * @return UPI_BOOT_RTN_PASS
+ */
+extern int UpiBootUnInitial(UG31xxDataType *data);
+
+extern int upi_read_percentage(void);
+
+extern int upi_boot_init(void);
+
+#endif ///< end of _UG31XX_BOOT_H_
+
diff --git a/board/wmt/wmt_battery/gauge/upi/ug31xx_boot_i2c.c b/board/wmt/wmt_battery/gauge/upi/ug31xx_boot_i2c.c
new file mode 100755
index 0000000..800656a
--- /dev/null
+++ b/board/wmt/wmt_battery/gauge/upi/ug31xx_boot_i2c.c
@@ -0,0 +1,212 @@
+/*
+ * Copyright (c) 2012, ASUSTek, Inc. All Rights Reserved.
+ */
+
+#include <common.h>
+#ifdef CONFIG_BATT_UPI
+//#include <debug.h>
+//#include <gsbi.h>
+//#include <platform/timer.h>
+#include "ug31xx_boot_i2c.h"
+extern int wmt_i2c_transfer(struct i2c_msg_s msgs[], int num, int adap_id);
+
+//typedef unsigned char u8;
+//typedef unsigned short u16;
+
+#define UG31XX_I2C_SLAVE_ADDRESS (0x70)
+
+//static struct qup_i2c_dev *ug31xx_i2c_dev = NULL;
+static int ug31xx_i2c_dev;
+
+/**
+ * @brief ug31xx_init_i2c
+ *
+ * Initialize I2C for uG31xx
+ *
+ * @para ug31xx_i2c_dev address of qup_i2c_dev
+ * @return NULL
+ */
+//void ug31xx_init_i2c(struct qup_i2c_dev *i2c_dev)
+void ug31xx_init_i2c(int i2c_dev)
+{
+ ug31xx_i2c_dev = i2c_dev;
+}
+
+/**
+ * @brief ug31xx_read_i2c
+ *
+ * I2C read from uG31xx
+ *
+ * @para ug31xx_i2c_dev address of qup_i2c_dev
+ * @para reg register address
+ * @para rt_value address of returned value
+ * @return 0 if pass
+ */
+int ug31xx_read_i2c(u8 reg, int *rt_value)
+{
+ int status;
+ unsigned char ret;
+ unsigned char data[2] =
+ {
+ reg,
+ SECURITY_KEY,
+ };
+ struct i2c_msg_s msg_buf1[2] =
+ {
+ //{UG31XX_I2C_SLAVE_ADDRESS, I2C_M_WR | I2C_M_NOSTART, 1, &data[0], },
+ { UG31XX_I2C_SLAVE_ADDRESS, I2C_M_WR, 1, &data[0], },
+ { UG31XX_I2C_SLAVE_ADDRESS, I2C_M_RD, 1, &ret, },
+ };
+ struct i2c_msg_s msg_buf2[2] =
+ {
+ //{UG31XX_I2C_SLAVE_ADDRESS, I2C_M_WR | I2C_M_NOSTART, 2, &data[0], },
+ { UG31XX_I2C_SLAVE_ADDRESS, I2C_M_WR, 2, &data[0], },
+ { UG31XX_I2C_SLAVE_ADDRESS, I2C_M_RD, 1, &ret, },
+ };
+
+ if(reg < 0x80)
+ {
+ //status = qup_i2c_xfer(ug31xx_i2c_dev, msg_buf1, 2);
+ status = wmt_i2c_transfer(msg_buf1, 2, ug31xx_i2c_dev);
+ }
+ else
+ {
+ //status = qup_i2c_xfer(ug31xx_i2c_dev, msg_buf2, 2);
+ status = wmt_i2c_transfer(msg_buf2, 2, ug31xx_i2c_dev);
+ }
+
+ if(status > 0)
+ {
+ *rt_value = ret;
+ return (0);
+ }
+ //dprintf(CRITICAL, "[ug31xx_read_i2c][reg=%02x] failed\n", reg);
+ printf("[ug31xx_read_i2c][reg=%02x] failed\n", reg);
+ return (-1);
+}
+
+/**
+ * @brief ug31xx_write_i2c
+ *
+ * I2C write to uG31xx
+ *
+ * @para ug31xx_i2c_dev address of qup_i2c_dev
+ * @para reg register address
+ * @para rt_value value to be written
+ * @return 0 if pass
+ */
+int ug31xx_write_i2c(u8 reg, int rt_value)
+{
+ int status;
+ unsigned char data1[2] =
+ {
+ reg,
+ rt_value,
+ };
+ unsigned char data2[3] =
+ {
+ reg,
+ SECURITY_KEY,
+ rt_value,
+ };
+ struct i2c_msg_s msg_buf[2] =
+ {
+ //{UG31XX_I2C_SLAVE_ADDRESS,I2C_M_WR | I2C_M_NOSTART, 2, &data1[0], },
+ //{UG31XX_I2C_SLAVE_ADDRESS,I2C_M_WR | I2C_M_NOSTART, 3, &data2[0], }
+ { UG31XX_I2C_SLAVE_ADDRESS, I2C_M_WR, 2, &data1[0], },
+ { UG31XX_I2C_SLAVE_ADDRESS, I2C_M_WR, 3, &data2[0], }
+ };
+
+ if(reg < 0x80)
+ {
+ //status = qup_i2c_xfer(ug31xx_i2c_dev, &msg_buf[0], 1);
+ status = wmt_i2c_transfer(&msg_buf[0], 1,ug31xx_i2c_dev);
+ }
+ else
+ {
+ //status = qup_i2c_xfer(ug31xx_i2c_dev, &msg_buf[1], 1);
+ status = wmt_i2c_transfer(&msg_buf[1], 1,ug31xx_i2c_dev);
+ }
+
+ if(status > 0)
+ {
+ return (0);
+ }
+ //dprintf(CRITICAL, "[ug31xx_write_i2c][reg=%02x] failed.\n", reg);
+ return (-1);
+}
+
+/**
+ * @brief _API_I2C_Write
+ *
+ * I2C write protocol for uG31xx
+ *
+ * @para writeAddress register address to be written
+ * @para writeLength data length
+ * @para PWriteData address of data buffer
+ * @return true if pass
+ */
+_i2c_bool _API_I2C_Write(u16 writeAddress, u8 writeLength, u8 *PWriteData)
+{
+ int i, ret;
+ int tmp_buf;
+
+ if (!PWriteData)
+ {
+ // dprintf(CRITICAL, "[_API_I2C_Write]Write buffer pointer error.\n");
+ printf("[_API_I2C_Write]Write buffer pointer error.\n");
+ return (_i2c_false);
+ }
+
+ for (i=0; i<writeLength; i++) {
+ tmp_buf = PWriteData[i];
+
+ ret = ug31xx_write_i2c(writeAddress+i, tmp_buf);
+ if (ret)
+ {
+ //dprintf(CRITICAL, "[_API_I2C_Write]Write data (%02x) to address (%02x) fail.\n", tmp_buf, writeAddress + i);
+ printf("[_API_I2C_Write]Write data (%02x) to address (%02x) fail.\n", tmp_buf, writeAddress + i);
+ return (_i2c_false);
+ }
+ }
+
+ return (_i2c_true);
+}
+
+/**
+ * @brief _API_I2C_Read
+ *
+ * I2C read protocol for uG31xx
+ *
+ * @para readAddress register address to be read
+ * @para readLength data length
+ * @para pReadDataBuffer address of data buffer
+ * @return true if pass
+ */
+_i2c_bool _API_I2C_Read(u16 readAddress, u8 readLength, u8 *pReadDataBuffer)
+{
+ int i, ret;
+
+ if (!pReadDataBuffer)
+ {
+ //dprintf(CRITICAL, "[_API_I2C_Read]Read buffer pointer error.\n");
+ printf("[_API_I2C_Read]Read buffer pointer error.\n");
+ return (_i2c_false);
+ }
+
+ for (i=0; i<readLength; i++) {
+ int tmp_buf=0;
+
+ ret = ug31xx_read_i2c(readAddress+i, &tmp_buf);
+ if (ret)
+ {
+ //dprintf(CRITICAL, "[_API_I2C_Read]Read data from address (%02x) fail.\n", readAddress + i);
+ printf("[_API_I2C_Read]Read data from address (%02x) fail.\n", readAddress + i);
+ return (_i2c_false);
+ }
+ pReadDataBuffer[i] = tmp_buf;
+ }
+
+ return (_i2c_true);
+}
+#endif
diff --git a/board/wmt/wmt_battery/gauge/upi/ug31xx_boot_i2c.h b/board/wmt/wmt_battery/gauge/upi/ug31xx_boot_i2c.h
new file mode 100755
index 0000000..c96c640
--- /dev/null
+++ b/board/wmt/wmt_battery/gauge/upi/ug31xx_boot_i2c.h
@@ -0,0 +1,75 @@
+/**
+ * @filename ug31xx_boot_i2c.h
+ *
+ * Interface of I2C in bootloader
+ *
+ * @author AllenTeng <allen_teng@upi-semi.com>
+ */
+
+#ifndef _UG31XX_BOOT_I2C_H_
+#define _UG31XX_BOOT_I2C_H_
+
+//#include <i2c_qup.h>
+/* I2C Message - used for pure i2c transaction*/
+/**/
+/* flags*/
+#define I2C_M_RD 0x01
+#define I2C_M_WR 0x00
+unsigned short bq_battery_read_percentage(void);
+
+struct i2c_msg_s {
+ unsigned short addr; /* slave address*/
+ unsigned short flags; /* flags*/
+ unsigned short len; /* msg length*/
+ unsigned char *buf; /* pointer to msg data*/
+} ;
+
+
+#define SECURITY_KEY 0x5A //i2c read/write
+#define ONE_BYTE 0x1
+#define TWO_BYTE 0x0
+
+#define _i2c_bool unsigned char
+#define _i2c_true (1)
+#define _i2c_false (0)
+
+//void ug31xx_init_i2c(struct qup_i2c_dev *i2c_dev);
+//void ug31xx_init_i2c(void);
+
+int ug31xx_read_i2c(unsigned char reg, int *rt_value);
+int ug31xx_write_i2c(unsigned char reg, int rt_value);
+
+_i2c_bool _API_I2C_Write(unsigned short writeAddress, unsigned char writeLength, unsigned char *PWriteData);
+_i2c_bool _API_I2C_Read(unsigned short readAddress, unsigned char readLength, unsigned char *pReadDataBuffer);
+
+static inline _i2c_bool API_I2C_Read(_i2c_bool bSecurityMode, _i2c_bool bHighSpeedMode,
+ _i2c_bool bTenBitMode ,unsigned short readAddress, unsigned char readLength, unsigned char *pReadDataBuffer)
+{
+ return _API_I2C_Read(readAddress, readLength, pReadDataBuffer);
+}
+
+static inline _i2c_bool API_I2C_Write(_i2c_bool bSecurityMode, _i2c_bool bHighSpeedMode, _i2c_bool bTenBitMode,
+ unsigned short writeAddress, unsigned char writeLength, unsigned char *PWriteData)
+{
+ return _API_I2C_Write(writeAddress, writeLength, PWriteData);
+}
+
+static inline _i2c_bool API_I2C_SingleRead(_i2c_bool bSecurityMode,_i2c_bool bHighSpeedMode, _i2c_bool bTenBitMode ,
+ unsigned short readAddress, unsigned char *ReadData)
+{
+ return API_I2C_Read(bSecurityMode, bHighSpeedMode, bTenBitMode, readAddress, 1, ReadData);
+}
+
+static inline _i2c_bool API_I2C_SingleWrite(_i2c_bool bSecurityMode, _i2c_bool bHighSpeedMode, _i2c_bool bTenBitMode ,
+ unsigned short writeAddress, unsigned char WriteData)
+{
+ return API_I2C_Write(bSecurityMode, bHighSpeedMode, bTenBitMode, writeAddress, 1, &WriteData);
+}
+
+static inline _i2c_bool API_I2C_Init(unsigned long clockRate, unsigned short slaveAddr)
+{
+ return _i2c_true;
+}
+
+#endif ///< end of _UG31XX_BOOT_I2C_H_
+
diff --git a/board/wmt/wmt_battery/gauge/vt1603/vt1603.h b/board/wmt/wmt_battery/gauge/vt1603/vt1603.h
new file mode 100755
index 0000000..de1dd89
--- /dev/null
+++ b/board/wmt/wmt_battery/gauge/vt1603/vt1603.h
@@ -0,0 +1,132 @@
+/*++
+ * linux/sound/soc/codecs/vt1603.h
+ * WonderMedia audio driver for ALSA
+ *
+ * Copyright c 2010 WonderMedia Technologies, Inc.
+ *
+ * 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, see <http://www.gnu.org/licenses/>.
+ *
+ * WonderMedia Technologies, Inc.
+ * 4F, 533, Chung-Cheng Road, Hsin-Tien, Taipei 231, R.O.C
+--*/
+
+#ifndef _VT1603_H
+#define _VT1603_H
+
+/* VT1603 register space */
+
+///////////vt1603//////////////////
+#define BIT0 0x00000001
+#define BIT1 0x00000002
+#define BIT2 0x00000004
+#define BIT3 0x00000008
+#define BIT4 0x00000010
+#define BIT5 0x00000020
+#define BIT6 0x00000040
+#define BIT7 0x00000080
+#define BIT8 0x00000100
+
+#define VT1603_RESET 0x15
+
+#define VT1603_R00 0x00
+#define VT1603_R01 0x01
+#define VT1603_R02 0x02
+#define VT1603_R03 0x03
+#define VT1603_R04 0x04
+#define VT1603_R05 0x05
+#define VT1603_R06 0x06
+#define VT1603_R07 0x07
+#define VT1603_R08 0x08
+#define VT1603_R09 0x09
+#define VT1603_R0a 0x0a
+#define VT1603_R0b 0x0b
+#define VT1603_R0c 0x0c
+#define VT1603_R0d 0x0d
+#define VT1603_R0e 0x0e
+#define VT1603_R0f 0x0f
+#define VT1603_R10 0x10
+#define VT1603_R11 0x11
+#define VT1603_R12 0x12
+#define VT1603_R13 0x13
+#define VT1603_R15 0x15
+#define VT1603_R19 0x19
+#define VT1603_R1b 0x1b
+#define VT1603_R1c 0x1c
+#define VT1603_R1d 0x1d
+#define VT1603_R20 0x20
+#define VT1603_R21 0x21
+#define VT1603_R23 0x23
+#define VT1603_R24 0x24
+#define VT1603_R25 0x25
+#define VT1603_R28 0x28
+#define VT1603_R29 0x29
+#define VT1603_R2a 0x2a
+#define VT1603_R2b 0x2b
+#define VT1603_R2c 0x2c
+#define VT1603_R2d 0x2d
+#define VT1603_R40 0x40
+#define VT1603_R41 0x41
+#define VT1603_R42 0x42
+#define VT1603_R47 0x47
+#define VT1603_R51 0x51
+#define VT1603_R52 0x52
+#define VT1603_R53 0x53
+#define VT1603_R5f 0x5f
+#define VT1603_R60 0x60
+#define VT1603_R61 0x61
+#define VT1603_R62 0x62
+#define VT1603_R63 0x63
+#define VT1603_R64 0x64
+#define VT1603_R65 0x65
+#define VT1603_R66 0x66
+#define VT1603_R67 0x67
+#define VT1603_R68 0x68
+#define VT1603_R69 0x69
+#define VT1603_R6a 0x6a
+#define VT1603_R6b 0x6b
+#define VT1603_R6d 0x6d
+#define VT1603_R6e 0x6e
+#define VT1603_R70 0x70
+#define VT1603_R71 0x71
+#define VT1603_R72 0x72
+#define VT1603_R73 0x73
+#define VT1603_R77 0x77
+#define VT1603_R79 0x79
+#define VT1603_R7a 0x7a
+#define VT1603_R7b 0x7b
+#define VT1603_R7c 0x7c
+#define VT1603_R82 0x82
+#define VT1603_R87 0x87
+#define VT1603_R88 0x88
+#define VT1603_R8a 0x8a
+#define VT1603_R8e 0x8e
+#define VT1603_R90 0x90
+#define VT1603_R91 0x91
+#define VT1603_R92 0x92
+#define VT1603_R93 0x93
+#define VT1603_R95 0x95
+#define VT1603_R96 0x96
+#define VT1603_R97 0x97
+
+#define VT1603_IRQ IRQ_GPIO
+
+struct vt1603_setup_data {
+ int i2c_bus;
+ unsigned short i2c_address;
+};
+
+//extern struct snd_soc_dai vt1603_dai;
+//extern struct snd_soc_codec_device soc_codec_dev_vt1603;
+
+#endif
diff --git a/board/wmt/wmt_battery/gauge/vt1603/vt1603_battery.c b/board/wmt/wmt_battery/gauge/vt1603/vt1603_battery.c
new file mode 100755
index 0000000..0c107c9
--- /dev/null
+++ b/board/wmt/wmt_battery/gauge/vt1603/vt1603_battery.c
@@ -0,0 +1,639 @@
+/*
+ * Copyright (C) 2013 WonderMedia Technologies, Inc.
+ *
+ * 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.
+ *
+ * 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.,
+ * 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <common.h>
+#include <command.h>
+#include <linux/ctype.h>
+#include <asm/arch/common_def.h>
+#include <asm/errno.h>
+
+#include "../../../include/wmt_pmc.h"
+#include "../../../include/wmt_spi.h"
+#include "../../../include/wmt_clk.h"
+#include "../../../include/wmt_gpio.h"
+
+#include "../../wmt_battery.h"
+
+#include "vt1603_battery.h"
+#include "vt1603.h"
+
+#define CONFIG_VT1603_BATTERY
+
+//#define BAT_DEBUG
+
+#undef dbg
+#undef dbg_err
+#ifdef BAT_DEBUG
+#define dbg(fmt, args...) printf("[%s]_%d: " fmt, __func__ , __LINE__, ## args)
+#else
+#define dbg(fmt, args...)
+#endif
+
+#define dbg_err(fmt, args...) printf("## VT1603A/VT1609 BAT##: " fmt, ## args)
+
+extern int auto_pll_divisor(enum dev_id dev, enum clk_cmd cmd, int unit, int freq);
+
+static int vt1603_spi_write(u8 addr, const u8 data)
+{
+ u8 wbuf[3], rbuf[3];
+
+ wbuf[0] = ((addr & 0xFF) | BIT7);
+ wbuf[1] = ((addr & 0xFF) >> 7);
+ wbuf[2] = data;
+
+ spi_write_then_read_data(wbuf, rbuf, sizeof(wbuf),
+ SPI_MODE_3, 0);
+
+ udelay(10);
+ return 0;
+}
+
+static int vt1603_spi_read(u8 addr, u8 *data)
+{
+ u8 wbuf[5] = {0};
+ u8 rbuf[5] = {0};
+
+ memset(wbuf,0,sizeof(wbuf));
+ memset(rbuf,0,sizeof(rbuf));
+
+ wbuf[0] = ((addr & 0xFF) & (~BIT7));
+ wbuf[1] = ((addr & 0xFF) >> 7);
+
+ spi_write_then_read_data(wbuf, rbuf, sizeof(wbuf),
+ SPI_MODE_3, 0);
+
+ if (0) {
+ int i;
+ for (i = 0; i < sizeof(rbuf); i++)
+ printf("0x%02x ", rbuf[i]);
+ printf("\n");
+ }
+ data[0] = rbuf[4];
+ return 0;
+}
+
+/*
+ * vt1603_set_reg8 - set register value of vt1603
+ * @bat_drv: vt1603 driver data
+ * @reg: vt1603 register address
+ * @val: value register will be set
+ */
+static int vt1603_set_reg8(u8 reg, u8 val)
+{
+ int ret =0;
+
+ ret = vt1603_spi_write(reg,val);
+ if(ret < 0){
+ dbg_err("vt1603 battery write error, errno%d\n", ret);
+ return ret;
+ }
+
+ return 0;
+}
+
+/*
+ * vt1603_get_reg8 - get register value of vt1603
+ * @bat_drv: vt1603 driver data
+ * @reg: vt1603 register address
+ */
+static u8 vt1603_get_reg8(u8 reg)
+{
+ u8 val = 0;
+ int ret = 0;
+
+ ret = vt1603_spi_read(reg,&val);
+ if (ret < 0){
+ dbg_err("vt1603 battery read error, errno%d\n", ret);
+ return 0;
+ }
+
+ return val;
+}
+
+
+static int vt1603_read8(u8 reg,u8* data)
+{
+ int ret = 0;
+
+ ret = vt1603_spi_read(reg,data);
+ if (ret < 0){
+ dbg_err("vt1603 battery read error, errno%d\n", ret);
+ return ret;
+ }
+
+ return 0;
+}
+
+/*
+ * vt1603_setbits - write bit1 to related register's bit
+ * @bat_drv: vt1603 battery driver data
+ * @reg: vt1603 register address
+ * @mask: bit setting mask
+ */
+static void vt1603_setbits(u8 reg, u8 mask)
+{
+ u8 tmp = vt1603_get_reg8(reg) | mask;
+ vt1603_set_reg8(reg, tmp);
+}
+
+/*
+ * vt1603_clrbits - write bit0 to related register's bit
+ * @bat_drv: vt1603 battery driver data
+ * @reg: vt1603 register address
+ * @mask:bit setting mask
+ */
+static void vt1603_clrbits(u8 reg, u8 mask)
+{
+ u8 tmp = vt1603_get_reg8(reg) & (~mask);
+ vt1603_set_reg8(reg, tmp);
+}
+
+/*
+ * vt1603_reg_dump - dubug function, for dump vt1603 related registers
+ * @bat_drv: vt1603 battery driver data
+ */
+static void __attribute__((unused)) vt1603_reg_dump(u8 addr, int len)
+{
+ u8 i;
+ for (i = addr; i < addr + len; i += 2)
+ printf("reg[%d]:0x%02X, reg[%d]:0x%02X\n",
+ i, vt1603_get_reg8(i),
+ i + 1, vt1603_get_reg8(i + 1));
+}
+
+/*
+ * vt1603_get_bat_convert_data - get battery converted data
+ * @bat_drv: vt1603 battery driver data
+ */
+static int vt1603_get_bat_data(int *data)
+{
+ u8 data_l, data_h;
+
+ if (vt1603_read8(VT1603_DATL_REG, &data_l)) {
+ dbg("read VT1603_DATL_REG error!\n");
+ return -1;
+ }
+
+ if (vt1603_read8(VT1603_DATH_REG, &data_h)) {
+ dbg("red VT1603_DATH_REG error!\n");
+ return -1;
+ }
+
+ *data = ADC_DATA(data_l, data_h);
+ return 0;
+}
+
+/*
+ * vt1603_work_mode_switch - switch VT1603 to battery mode
+ * @bat_drv: vt1603 battery driver data
+ */
+static void vt1603_switch_to_bat_mode(void)
+{
+ dbg("Enter\n");
+ vt1603_set_reg8(VT1603_CR_REG, 0x00);
+ vt1603_set_reg8(VT1603_AMCR_REG, BIT0);
+ dbg("Exit\n");
+}
+
+/*
+ * vt1603_get_pen_state - get touch panel pen state from vt1603
+ * interrup status register
+ * @bat_drv: vt1603 battery driver data
+ */
+static inline int vt1603_get_pen_state(void)
+{
+ u8 state = vt1603_get_reg8(VT1603_INTS_REG);
+ return (((state & BIT4) == 0) ? TS_PENDOWN_STATE : TS_PENUP_STATE);
+}
+
+static inline void vt1603_bat_pen_manual(void)
+{
+ vt1603_setbits(VT1603_INTCR_REG, BIT7);
+}
+
+static void vt1603_bat_power_up(void)
+{
+ if (vt1603_get_reg8(VT1603_PWC_REG) != 0x08)
+ vt1603_set_reg8(VT1603_PWC_REG, 0x08);
+
+ return ;
+}
+
+static int vt1603_bat_avg(int *data, int num)
+{
+ int i = 0;
+ int avg = 0;
+
+ if(num == 0)
+ return 0;
+
+ for (i = 0; i < num; i++)
+ avg += data[i];
+
+ return (avg / num);
+}
+
+static int vt1603_read_adc(int *value)
+{
+ int timeout, i = 0;
+ int bat_arrary[DFLT_BAT_VAL_AVG]={0};
+ int ret = 0;
+
+ dbg("Enter\n");
+
+ // enable sar-adc power and clock
+ vt1603_bat_power_up();
+ // enable pen down/up to avoid miss irq
+ vt1603_bat_pen_manual();
+ // switch vt1603 to battery detect mode
+ vt1603_switch_to_bat_mode();
+ // do conversion use battery manual mode
+ vt1603_setbits(VT1603_INTS_REG, BIT0);
+ vt1603_set_reg8(VT1603_CR_REG, BIT4);
+
+ dbg("before VT1603_INTS_REG=%x\n", vt1603_get_reg8(VT1603_INTS_REG));
+
+ for (i=0; i<DFLT_BAT_VAL_AVG; i++) {
+ timeout = 2000;
+ while(--timeout && (vt1603_get_reg8(VT1603_INTS_REG) & BIT0)==0)
+ /* wait for irq */;
+
+ if(timeout){
+ ret = vt1603_get_bat_data(&bat_arrary[i]);
+ if(ret < 0) {
+ dbg_err("vt1603 get bat adc data Failed!\n");
+ goto out;
+ }
+
+ vt1603_setbits(VT1603_INTS_REG, BIT0);
+ vt1603_set_reg8(VT1603_CR_REG, BIT4);//start manual ADC mode
+ } else {
+ dbg_err("wait adc end timeout ?!\n");
+ ret = -1;
+ goto out;
+ }
+ }
+
+ *value = vt1603_bat_avg(bat_arrary, DFLT_BAT_VAL_AVG);
+
+out:
+ vt1603_clrbits(VT1603_INTCR_REG, BIT7);
+ vt1603_setbits(VT1603_INTS_REG, BIT0 | BIT3);
+ vt1603_set_reg8(VT1603_CR_REG, BIT1);
+ dbg("Exit\n\n\n");
+ return ret;
+}
+
+/*
+ * vt1603_get_bat_info - get battery status, API for wmt_battery.c
+ */
+int vt1603_read_voltage(void)
+{
+ int volt_mV;
+ int rc;
+
+ rc = vt1603_read_adc(&volt_mV);
+ if (rc < 0) {
+ printf("vt1603 read voltage failed\n");
+ return -1;
+ }
+
+ printf("vt1603 read voltage: %d mV\n", volt_mV);
+ return volt_mV;
+}
+
+/*
+ * vt1603_ts_reset - reset vt1603, auto postition conversion mode,
+ * do self calibration if enable
+ */
+static void vt1603_ts_reset(void)
+{
+ /* power control enable */
+ vt1603_set_reg8(VT1603_PWC_REG, 0x18);
+
+ /* clock divider */
+ vt1603_set_reg8(VT1603_CDPR_REG, 0x08);
+
+ /* clean debug register,for some 2 layer PCB machine enter debug mode unexpected */
+ vt1603_set_reg8(VT1603_DCR_REG, 0x00);
+
+
+ vt1603_set_reg8(VT1603_INTEN_REG, BIT1);//Just Enable pendown IRQ
+
+ // auto position conversion mode and panel type config
+ /*if (ts_pdata->panel_type== PANEL_TYPE_4WIRED)
+ vt1603_set_reg8(ts_drv, VT1603_CR_REG, BIT1);
+ else*/
+ vt1603_set_reg8(VT1603_CR_REG, BIT1 | BIT0);
+
+ // interrupt control, pen up/down detection enable
+ vt1603_set_reg8(VT1603_INTCR_REG, 0xff);
+
+ // mask other module interrupts
+ vt1603_set_reg8(VT1603_IMASK_REG27, 0xff);
+ vt1603_set_reg8(VT1603_IMASK_REG28, 0xFF);
+ vt1603_set_reg8(VT1603_IMASK_REG29, 0xFF);
+ /* reset headphone detect irq */
+ vt1603_set_reg8(VT1603_IMASK_REG27, 0xfd);
+
+ vt1603_setbits(VT1603_IPOL_REG33, BIT5);
+
+ vt1603_set_reg8(VT1603_ISEL_REG36, 0x04);/* vt1603 gpio1 as IRQ output */
+ // clear irq
+ //vt1603_clr_ts_irq(0x0F);
+ vt1603_setbits(VT1603_INTS_REG, 0x0F);
+ dbg("ok...\n");
+
+ return;
+}
+
+static inline void i2s_pin_config(void)
+{
+ /* disable GPIO and Pull Down mode */
+ GPIO_CTRL_GP10_I2S_BYTE_VAL &= ~0xFF;
+ GPIO_CTRL_GP11_I2S_BYTE_VAL &= ~(BIT0 | BIT1 | BIT2);
+
+ PULL_EN_GP10_I2S_BYTE_VAL &= ~0xFF;
+ PULL_EN_GP11_I2S_BYTE_VAL &= ~(BIT0 | BIT1 | BIT2);
+
+ /* set to 2ch input, 2ch output */
+ PIN_SHARING_SEL_4BYTE_VAL &= ~(BIT13 | BIT14 | BIT15 | BIT17 | BIT19 | BIT20 | BIT22);
+ PIN_SHARING_SEL_4BYTE_VAL |= (BIT1 | BIT16 | BIT18 | BIT21);
+}
+
+static inline void i2s_clk_config(void)
+{
+ /* set to 11.288MHz */
+ auto_pll_divisor(DEV_I2S, CLK_ENABLE , 0, 0);
+ auto_pll_divisor(DEV_I2S, SET_PLLDIV, 1, 11288);
+
+ /* Enable BIT4:ARFP clock, BIT3:ARF clock */
+ PMCEU_VAL |= (BIT4 | BIT3);
+
+ /* Enable BIT2:AUD clock */
+ PMCE3_VAL |= BIT2;
+}
+
+static int vt1603_bat_probe(void)
+{
+ i2s_pin_config();
+ i2s_clk_config();
+
+ vt1603_ts_reset();
+
+ //vt1603_reg_dump(0xc0, 12);
+
+ return 0;
+}
+
+struct bias_data {
+ int normal;
+ int max;
+};
+
+static struct bias_data bias_adapter[10];
+
+static int parse_bias_data(void)
+{
+ char *s;
+ char *endp;
+ int i;
+
+ struct bias_data *bias = bias_adapter;
+
+ s = getenv("wmt.io.bateff.adapter");
+ if (!s) {
+ printf("no wmt.io.bateff.adapter param!\n");
+ return -EINVAL;
+ }
+
+ // parse from the valid val
+ for (i = 9; i >= 0 ; i--) {
+ bias[i].normal = simple_strtoul(s, &endp, 16);
+ if (*endp == '\0')
+ break;
+ s = endp + 1;
+ if (*s == '\0')
+ break;
+
+ bias[i].max = simple_strtoul(s, &endp, 16);
+ if (*endp == '\0')
+ break;
+ s = endp + 1;
+ if (*s == '\0')
+ break;
+ }
+
+ if ((i != 0) && (i != 5)) {
+ printf("Error to get charging u-boot argument.! i = %d\n", i);
+ return -1;
+ }
+
+ return 0;
+}
+
+static int getEffect(int adc, int usage, struct bias_data *bias, int size)
+{
+ int effect, i;
+
+ for (i = 0; i < size; i++) {
+ if (adc <= bias[i].max) {
+ effect = (bias[i].max - bias[i].normal) * usage / 100;
+ return effect;
+ }
+ }
+
+ effect = bias[size-1].max - bias[size-1].normal;
+
+ if (size > 0)
+ return effect * usage / 100;
+
+ return 0;
+}
+
+static int adc_repair(int adc_val)
+{
+ int adc_add = adc_val;
+
+ if (wmt_is_dc_plugin()) {
+ adc_add -= getEffect(adc_val, 100, bias_adapter, ARRAY_SIZE(bias_adapter));
+ }
+
+ return adc_add;
+}
+
+static int volt_grade[11];
+
+static int parse_bat_level(void)
+{
+ char *s;
+ char *endp;
+ int i = 0;
+
+ s = getenv("wmt.io.bat");
+ if (!s) {
+ printf("no wmt.io.bat param!\n");
+ return -EINVAL;
+ }
+
+ // skip 5 val
+ while ((i < 5) && (*s != '\0')) {
+ if (*s==':') {
+ i++;
+ }
+ s++;
+ }
+
+ if ((i != 5) || (!s) || (*s == '\0')) {
+ printf("wmt.io.bat param format error!\n");
+ return -1;
+ }
+
+ // parse from the valid val
+ for (i = 10; i >= 0; i--) {
+ volt_grade[i] = simple_strtoul(s, &endp, 16);
+ if (*endp == '\0')
+ break;
+ s = endp + 1;
+
+ if (*s == '\0')
+ break;
+ }
+
+ if (i) {
+ printf("parse wmt.io.bat failed!\n");
+ return -EINVAL;
+ }
+
+ return 0;
+}
+
+static int adc_to_capacity(int adc_val)
+{
+ int capacity = 0;
+
+ if (adc_val <= volt_grade[0]) {
+ capacity = 0;
+ } else if (adc_val >= volt_grade[10]) {
+ capacity = 100;
+ } else {
+ int i;
+ for (i = 10; i >= 1 ; i--) {
+ if ((adc_val<=volt_grade[i])&&(adc_val>volt_grade[i-1])) {
+ capacity = ((adc_val-volt_grade[i-1]) * 10) /
+ (volt_grade[i]-volt_grade[i-1]) + (i-1)*10;
+ }
+ }
+ }
+
+ return capacity;
+}
+
+int vt1603_read_capacity(void)
+{
+ int adc0, adc1;
+ int cap0;
+ static int max_capacity = -1;
+
+ adc0 = vt1603_read_voltage();
+ if (adc0 < 0) {
+ printf("read raw adc failed\n");
+ return adc0;
+ }
+ printf("adc0 %dmV\n",adc0);
+
+ adc1 = adc_repair(adc0);
+ printf("adc1 %dmV\n",adc1);
+
+ cap0 = adc_to_capacity(adc1);
+ printf("cap0 %d\n", cap0);
+
+ // use the max capacity while charging.
+ if (!wmt_is_dc_plugin() ||
+ max_capacity < cap0 || max_capacity > cap0 + 5)
+ max_capacity = cap0;
+
+ printf("max_capacity %d\n", max_capacity);
+ return max_capacity;
+}
+
+int vt1603_batt_init(void)
+{
+ if (parse_bias_data())
+ return -EINVAL;
+
+ if (parse_bat_level())
+ return -EINVAL;
+
+ return vt1603_bat_probe();
+}
+
+int vt1603_check_bl(void)
+{
+ int rc;
+ int volt_mV;
+ int low_mV;
+
+ rc = vt1603_read_adc(&volt_mV);
+ if (rc < 0) {
+ printf("vt1603 read voltage failed\n");
+ return -EIO;
+ }
+
+ if (wmt_is_dc_plugin())
+ low_mV = adc_repair(volt_grade[0]);
+ else {
+ /* FIXME Work around for the situation that android poweroff by
+ * capcity 0, but uboot do not report low battery. */
+ low_mV = (volt_grade[0] + volt_grade[1]) / 2;
+ }
+
+ printf("current voltage %d, low bat %d, capacity %d\n",
+ volt_mV, low_mV, vt1603_read_capacity());
+ return volt_mV < low_mV;
+}
+
+static int do_adc(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
+{
+ int i;
+
+ parse_bias_data();
+ parse_bat_level();
+
+ for (i = 0; i < ARRAY_SIZE(bias_adapter); i++) {
+ printf("bias adapater [%2d]: %d -> %d (%d) mV\n",
+ i, bias_adapter[i].normal, bias_adapter[i].max,
+ bias_adapter[i].max - bias_adapter[i].normal);
+ }
+
+ for (i = 0; i < ARRAY_SIZE(volt_grade); i++) {
+ printf("voltage[%2d] - %d(%dmV)\n", i, volt_grade[i], (volt_grade[i] * 1047) / 1000);
+ }
+
+ return 0;
+}
+
+U_BOOT_CMD(
+ adc, 4, 1, do_adc, \
+ "adc: display battery capacity\n", \
+ "" \
+);
+
+struct battery_dev vt1603_battery_dev = {
+ .name = "vt1603",
+ .is_gauge = 0,
+ .init = vt1603_batt_init,
+ .get_capacity = vt1603_read_capacity,
+ .get_voltage = vt1603_read_voltage,
+ .check_batlow = vt1603_check_bl,
+};
diff --git a/board/wmt/wmt_battery/gauge/vt1603/vt1603_battery.h b/board/wmt/wmt_battery/gauge/vt1603/vt1603_battery.h
new file mode 100755
index 0000000..0c4600f
--- /dev/null
+++ b/board/wmt/wmt_battery/gauge/vt1603/vt1603_battery.h
@@ -0,0 +1,119 @@
+/*++
+ Copyright (c) 2008 WonderMedia Technologies, Inc.
+
+ 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, see <http://www.gnu.org/licenses/>.
+
+ WonderMedia Technologies, Inc.
+ 10F, 529, Chung-Cheng Road, Hsin-Tien, Taipei 231, R.O.C.
+--*/
+
+#ifndef __VT1603_BAT_H__
+#define __VT1603_BAT_H__
+
+#define POLL_TOUT 100
+#define DFLT_POLLING_BAT_INTERVAL 10
+#define VT1603_BAT_DRIVER "vt1603_bat"
+#define ADC_DATA(low, high) ((((high) & 0x0F) << 8) + (low))
+
+/* VT1603 touch panel state */
+#define TS_PENDOWN_STATE 0x00
+#define TS_PENUP_STATE 0x01
+
+/* vt1603 bus type config */
+#define VT1603_MAX_SPI_CLK (20*1000*1000)
+#define SPI_DEFAULT_CLK (12*1000*1000)
+#define IDLE_DATA_NUM 5
+#define VT1603_SPI_FIX_CS 0x00
+#define VT1603_SPI_FAKE_CS 3 //(0x7F - 1)
+#define VT1603_SPI_BUS_0 0x00
+#define VT1603_SPI_BUS_1 0x01
+#define VT1603_REG_OP_R 0x00
+#define VT1603_REG_OP_W 0x01
+
+
+#define VT1603_I2C_FIX_ADDR 0x1A
+#define VT1603_I2C_FAKE_ADDR 0xEE
+#define VT1603_I2C_WCMD 0x00
+#define VT1603_I2C_RCMD 0x01
+#define VT1603_I2C_RWCMD 0x02
+#define VT1603_I2C_BUS_0 0x00
+#define VT1603_I2C_BUS_1 0x01
+
+
+#define BA_WAKEUP_SRC_0 BIT0
+#define BA_WAKEUP_SRC_1 BIT1
+#define BA_WAKEUP_SRC_2 BIT2
+#define BA_WAKEUP_SRC_3 BIT3
+
+#define I2C_BUS 0
+#define SPI_BUS 1
+#define DFLT_BAT_VAL_AVG 10
+#define VT1603_FIFO_LEN 3
+
+/* VT1603 Register address */
+#define VT1603_BTHD_REG 0x78
+#define VT1603_BCLK_REG 0x88
+#define VT1603_BAEN_REG 0x04
+
+#define VT1603_PWC_REG 0xC0
+#define VT1603_CR_REG 0xC1
+#define VT1603_CCCR_REG 0xC2
+#define VT1603_CDPR_REG 0xC3
+#define VT1603_TSPC_REG 0xC4
+#define VT1603_AMCR_REG 0xC7
+#define VT1603_INTCR_REG 0xC8
+#define VT1603_INTEN_REG 0xC9
+#define VT1603_INTS_REG 0xCA
+#define VT1603_DCR_REG 0xCB
+
+#define VT1603_TODCL_REG 0xCC
+#define VT1603_TODCH_REG 0xCD
+
+#define VT1603_DATL_REG 0xCE
+#define VT1603_DATH_REG 0xCF
+
+#define VT1603_XPL_REG 0xD0
+#define VT1603_XPH_REG 0xD1
+#define VT1603_YPL_REG 0xD2
+#define VT1603_YPH_REG 0xD3
+
+#define VT1603_BATL_REG 0xD4
+#define VT1603_BATH_REG 0xD5
+
+#define VT1603_TEMPL_REG 0xD6
+#define VT1603_TEMPH_REG 0xD7
+
+#define VT1603_ERR8_REG 0xD8
+#define VT1603_ERR7_REG 0xD9
+#define VT1603_ERR6_REG 0xDA
+#define VT1603_ERR5_REG 0xDB
+#define VT1603_ERR4_REG 0xDC
+#define VT1603_ERR3_REG 0xDD
+#define VT1603_ERR2_REG 0xDE
+#define VT1603_ERR1_REG 0xDF
+
+#define VT1603_DBG8_REG 0xE0
+#define VT1603_DBG7_REG 0xE1
+#define VT1603_DBG6_REG 0xE2
+#define VT1603_DBG5_REG 0xE3
+#define VT1603_DBG4_REG 0xE4
+#define VT1603_DBG3_REG 0xE5
+#define VT1603_DBG2_REG 0xE6
+#define VT1603_DBG1_REG 0xE7
+
+/* for VT1603 GPIO1 interrupt setting */
+#define VT1603_IMASK_REG27 27
+#define VT1603_IMASK_REG28 28
+#define VT1603_IMASK_REG29 29
+#define VT1603_IPOL_REG33 33
+#define VT1603_ISEL_REG36 36
+
+#endif /* __VT1603_TS_H__ */