int debug_finish_temp_soc;
};
-struct battery_info *data;
struct battery_info *g_battery;
u32 support_uboot_chrg;
extern int rk818_set_bits(struct rk818 *rk818, u8 reg, u8 mask, u8 val);
extern unsigned int irq_create_mapping(struct irq_domain *domain,
irq_hw_number_t hwirq);
-
+extern void rk_send_wakeup_key(void);
static void update_battery_info(struct battery_info *di);
#define SUPPORT_USB_CHARGE
#endif
-#define BATT_NUM 11
-
-static int batt_table[22];
-
-static ssize_t bat_param_read(struct device *dev, struct device_attribute *attr, char *buf)
-{
- int i;
-
- for (i = 0; i < BATT_NUM; i++)
- printk(KERN_INFO"i = %d batt_table = %d\n", i, batt_table[i]);
-
- for (i = 0; i < BATT_NUM; i++)
- printk(KERN_INFO"i = %d batt_table = %d\n", i + BATT_NUM , batt_table[i+BATT_NUM]);
- return 0;
-}
-
-static ssize_t bat_param_write(struct device *dev,
- struct device_attribute *attr, const char *buf, size_t size)
-{
- return size;
-}
-
-
-DEVICE_ATTR(rk818batparam, 0664, bat_param_read, bat_param_write);
static uint16_t get_relax_voltage(struct battery_info *di);
static ssize_t show_state_attrs(struct device *dev,
struct device_attribute *attr, char *buf)
{
- printk(KERN_INFO"get_relax_voltage relax voltage = %d\n", get_relax_voltage(data));
+ struct battery_info *data = g_battery;
if (0 == get_relax_voltage(data)) {
return sprintf(buf,
return ret;
}
-#if 1
-/*calc battery resister*/
-static void res_mode_init(struct battery_info *di)
-{
- u8 ggcon;/* chrg_ctrl_reg2; */
- u8 ggsts;
-
- battery_read(di->rk818, GGCON, &ggcon, 1);
- battery_read(di->rk818, GGSTS, &ggsts, 1);
-
- ggcon |= 0x01;
- ggsts &= ~0x01;
- ggsts |= 0x60;
- battery_write(di->rk818, GGCON, &ggcon, 1);
- battery_write(di->rk818, GGSTS, &ggsts, 1);
-}
-#endif
-
static void _capacity_init(struct battery_info *di, u32 capacity)
{
u8 buf;
DBG("old usb_ctrl_reg = 0x%2x, CHRG_CTRL_REG1 = 0x%2x\n ", usb_ctrl_reg, chrg_ctrl_reg1);
usb_ctrl_reg &= (~0x0f);
#ifdef SUPPORT_USB_CHARGE
- usb_ctrl_reg |= (VLIM_4400MV | ILIM_45MA | CHRG_CT_EN);
+ usb_ctrl_reg |= (ILIM_450MA | CHRG_CT_EN);
#else
- usb_ctrl_reg |= (VLIM_4400MV | ILIM_3000MA) | CHRG_CT_EN);
+ usb_ctrl_reg |= (ILIM_3000MA | CHRG_CT_EN);
#endif
chrg_ctrl_reg1 &= (0x00);
chrg_ctrl_reg1 |= (CHRG_EN) | (CHRG_VOL4200 | CHRG_CUR1400mA);
_set_cal_offset(di, di->current_offset+42);
_rsoc_init(di);
_capacity_init(di, di->nac);
- res_mode_init(di);
+
di->remain_capacity = _get_realtime_capacity(di);
di->current_avg = _get_average_current(di);
voltage = di->voltage;
now_current = di->current_avg;
+ if (now_current == 0)
+ now_current = 1;
soc_time = di->fcc*3600/100/(abs_int(now_current));
_voltage_to_capacity(di, 3800);
volt_to_soc = di->temp_soc;
int now_current, soc_time;
now_current = _get_average_current(di);
+ if (now_current == 0)
+ now_current = 1;
soc_time = di->fcc*3600/100/(abs_int(now_current)); /* 1% time; */
di->temp_soc = _get_soc(di);
if (delta_time >= 20) {/*20s*/
/*first sample*/
- set_charge_current(di, ILIM_45MA);/*450mA*/
+ set_charge_current(di, ILIM_450MA);/*450mA*/
msleep(1000);
for (i = 0; i < 10 ; i++) {
msleep(100);
if (di->ac_online == 1)
set_charge_current(di, ILIM_3000MA);
else
- set_charge_current(di, ILIM_45MA);
+ set_charge_current(di, ILIM_450MA);
return otg_status;
}
if (otg_status == 1) {
di->usb_online = 1;
di->ac_online = 0;
- set_charge_current(di, ILIM_45MA);
+ set_charge_current(di, ILIM_450MA);
di->status = POWER_SUPPLY_STATUS_CHARGING;
- DBG("++++++++ILIM_45MA++++++\n");
+ DBG("++++++++ILIM_450MA++++++\n");
} else if (otg_status == 2) {
di->usb_online = 0;
int i;
struct kobject *rk818_fg_kobj;
- ret = device_create_file(dev, &dev_attr_rk818batparam);
- if (ret) {
- ret = -EINVAL;
- dev_err(dev, "failed to create bat param file\n");
- goto err_sysfs;
- }
-
ret = create_sysfs_interfaces(dev);
if (ret < 0) {
ret = -EINVAL;
dev_err(dev, "kzalloc for battery_platform_data failed!\n");
return -ENOMEM;
}
- memset(data, 0, sizeof(*data));
cell_cfg = devm_kzalloc(rk818->dev, sizeof(*cell_cfg), GFP_KERNEL);
if (!cell_cfg) {
queue_delayed_work(di->wq, &di->battery_monitor_work,
msecs_to_jiffies(TIMER_MS_COUNTS/2));
- if (di->sleep_status == POWER_SUPPLY_STATUS_CHARGING || di->real_soc <= 5)
+ if (di->sleep_status == POWER_SUPPLY_STATUS_CHARGING ||
+ di->real_soc <= 5)
wake_lock_timeout(&di->resume_wake_lock, 5*HZ);
return 0;
/* auto sleep mode 0:disable 1:enable*/
#define FRAME_SMP_INTERV_TIME 0x1F
+/*VB_MOD_REG*/
#define PLUG_IN_STS (1<<6)
/*SUP_STS_REG*/
/*USB_CTRL_REG*/
#define CHRG_CT_EN (1<<7)
/* USB_VLIM_SEL*/
+/*
#define VLIM_4000MV (0x00<<4)
#define VLIM_4100MV (0x01<<4)
#define VLIM_4200MV (0x02<<4)
#define VLIM_4500MV (0x05<<4)
#define VLIM_4600MV (0x06<<4)
#define VLIM_4700MV (0x07<<4)
+*/
+
/*USB_ILIM_SEL*/
-#define ILIM_45MA (0x00)
-#define ILIM_300MA (0x01)
-#define ILIM_80MA (0x02)
-#define ILIM_820MA (0x03)
-#define ILIM_1000MA (0x04)
-#define ILIM_1200MA (0x05)
-#define ILIM_1400MA (0x06)
-#define ILIM_1600MA (0x07)
-#define ILIM_1800MA (0x08)
-#define ILIM_2000MA (0x09)
-#define ILIM_2200MA (0x0A)
-#define ILIM_2400MA (0x0B)
-#define ILIM_2600MA (0x0C)
-#define ILIM_2800MA (0x0D)
-#define ILIM_3000MA (0x0E)
+#define ILIM_450MA (0x00)
+#define ILIM_800MA (0x01)
+#define ILIM_850MA (0x02)
+#define ILIM_1000MA (0x03)
+#define ILIM_1250MA (0x04)
+#define ILIM_1500MA (0x05)
+#define ILIM_1750MA (0x06)
+#define ILIM_2000MA (0x07)
+#define ILIM_2250MA (0x08)
+#define ILIM_2500MA (0x09)
+#define ILIM_2750MA (0x0A)
+#define ILIM_3000MA (0x0B)
+
/*CHRG_CTRL_REG*/
#define CHRG_EN (0x01<<7)
#define CHRG_CUR3000mA (0x0A)
/*CHRG_CTRL_REG2*/
-#define FINISH_100MA (0X00 << 6)
-#define FINISH_150MA (0X01 << 6)
-#define FINISH_200MA (0X10 << 6)
-#define FINISH_250MA (0X11 << 6)
+#define FINISH_100MA (0x00<<6)
+#define FINISH_150MA (0x01<<6)
+#define FINISH_200MA (0x02<<6)
+#define FINISH_250MA (0x03<<6)
/* CHRG_CTRL_REG2*/
#define CHRG_TERM_ANA_SIGNAL (0 << 5)
struct cell_config *cell_cfg;
};
-extern void rk_send_wakeup_key(void);
+
#endif