static int smb328a_watchdog_control(struct i2c_client *client, bool enable) { int val, reg; u8 data; dev_info(&client->dev, "%s : (%d)\n", __func__, enable); smb328a_allow_volatile_writes(client); reg = SMB328A_FUNCTION_CONTROL_A2; val = smb328a_read_reg(client, reg); if (val >= 0) { data = (u8)val; dev_info(&client->dev, "%s : reg (0x%x) = 0x%x\n", __func__, reg, data); if (enable) data |= (0x1 << 1); else data &= ~(0x1 << 1); if (smb328a_write_reg(client, reg, data) < 0) pr_err("%s : error!\n", __func__); val = smb328a_read_reg(client, reg); if (val >= 0) { data = (u8)val; dev_info(&client->dev, "%s : => reg (0x%x) = 0x%x\n", __func__, reg, data); } } return 0; }
static void smb328a_set_command_reg(struct i2c_client *client) { struct smb328a_chip *chip = i2c_get_clientdata(client); int val, reg; u8 data; reg = SMB328A_COMMAND; val = smb328a_read_reg(client, reg); if (val >= 0) { data = (u8)val; dev_info(&client->dev, "%s : reg (0x%x) = 0x%x\n", __func__, reg, data); if (chip->chg_mode == CHG_MODE_AC || chip->chg_mode == CHG_MODE_MISC || chip->chg_mode == CHG_MODE_UNKNOWN) data = 0xad; else data = 0xa9; /* usb */ if (smb328a_write_reg(client, reg, data) < 0) pr_err("%s : error!\n", __func__); val = smb328a_read_reg(client, reg); if (val >= 0) { data = (u8)data; pr_info("%s : => reg (0x%x) = 0x%x\n", __func__, reg, data); } } }
static void smb328a_clear_irqs(struct i2c_client *client) { struct smb328a_chip *chip = i2c_get_clientdata(client); int reg; reg = SMB328A_CLEAR_IRQ; if (smb328a_write_reg(chip->client, reg, 0xff) < 0) pr_err("%s : irq clear error!\n", __func__); }
static void smb328a_allow_volatile_writes(struct i2c_client *client) { int val; u8 data; val = smb328a_read_reg(client, SMB328A_COMMAND); if ((val >= 0) && !(val&0x80)) { data = (u8)val; dev_info(&client->dev, "%s : reg (0x%x) = 0x%x\n", __func__, SMB328A_COMMAND, data); data |= (0x1 << 7); if (smb328a_write_reg(client, SMB328A_COMMAND, data) < 0) pr_err("%s : error!\n", __func__); val = smb328a_read_reg(client, SMB328A_COMMAND); if (val >= 0) { data = (u8)data; pr_info("%s : => reg (0x%x) = 0x%x\n", __func__, SMB328A_COMMAND, data); } } }
static void smb328a_set_command_reg(struct i2c_client *client) { struct smb328a_chip *chip = i2c_get_clientdata(client); int val; u8 data; val = smb328a_read_reg(client, SMB328A_COMMAND); if (val >= 0) { data = (u8)val; dev_info(&client->dev, "%s : reg (0x%x) = 0x%x\n", __func__, SMB328A_COMMAND, data); if (chip->chg_mode == CHG_MODE_AC) // data = 0xad; data = 0x8C; else data = 0x88; /* usb or misc or unknown */ if (smb328a_write_reg(client, SMB328A_COMMAND, data) < 0) pr_err("%s : error!\n", __func__); val = smb328a_read_reg(client, SMB328A_COMMAND); if (val >= 0) { data = (u8)data; pr_info("%s : => reg (0x%x) = 0x%x\n", __func__, SMB328A_COMMAND, data); } } }
static void smb328a_charger_function_conrol(struct i2c_client *client) { struct smb328a_chip *chip = i2c_get_clientdata(client); int val, reg; u8 data, set_data; smb328a_allow_volatile_writes(client); reg = SMB328A_INPUT_AND_CHARGE_CURRENTS; val = smb328a_read_reg(client, reg); if (val >= 0) { data = (u8)val; dev_info(&client->dev, "%s : reg (0x%x) = 0x%x\n", __func__, reg, data); #ifdef CONFIG_FORCE_FAST_CHARGE if (force_fast_charge != 0) { set_data = 0x97; } else if(chip->chg_mode == CHG_MODE_AC) { #else if (chip->chg_mode == CHG_MODE_AC) { #endif #if defined (CONFIG_USA_MODEL_SGH_I717) set_data = 0xB7; /* fast 1A */ #else set_data = 0x97; /* fast 900mA */ #endif } else if (chip->chg_mode == CHG_MODE_MISC) { set_data = 0x57; /* fast 700mA */ } else set_data = 0x17; /* fast 500mA */ if (data != set_data) { /* this can be changed with top-off setting */ data = set_data; if (smb328a_write_reg(client, reg, data) < 0) pr_err("%s : error!\n", __func__); val = smb328a_read_reg(client, reg); if (val >= 0) { data = (u8)val; dev_info(&client->dev, "%s : => reg (0x%x) = 0x%x\n", __func__, reg, data); } } } reg = SMB328A_CURRENT_TERMINATION; val = smb328a_read_reg(client, reg); if (val >= 0) { data = (u8)val; dev_info(&client->dev, "%s : reg (0x%x) = 0x%x\n", __func__, reg, data); #ifdef CONFIG_FORCE_FAST_CHARGE if (force_fast_charge != 0) { set_data = 0xb0; } else if(chip->chg_mode == CHG_MODE_AC) { #else if (chip->chg_mode == CHG_MODE_AC) { #endif set_data = 0xb0; /* input 1A */ } else if (chip->chg_mode == CHG_MODE_MISC) { set_data = 0x50; /* input 700mA */ } else set_data = 0x10; /* input 450mA */ if (data != set_data) { /* AICL enable */ data = set_data; if (smb328a_write_reg(client, reg, data) < 0) pr_err("%s : error!\n", __func__); val = smb328a_read_reg(client, reg); if (val >= 0) { data = (u8)val; dev_info(&client->dev, "%s : => reg (0x%x) = 0x%x\n", __func__, reg, data); } } } reg = SMB328A_FLOAT_VOLTAGE; val = smb328a_read_reg(client, reg); if (val >= 0) { data = (u8)val; dev_info(&client->dev, "%s : reg (0x%x) = 0x%x\n", __func__, reg, data); if (data != 0xca) { data = 0xca; /* 4.2V float voltage */ //data = 0xcc; /* 4.22V float voltage */ if (smb328a_write_reg(client, reg, data) < 0) pr_err("%s : error!\n", __func__); val = smb328a_read_reg(client, reg); if (val >= 0) { data = (u8)val; dev_info(&client->dev, "%s : => reg (0x%x) = 0x%x\n", __func__, reg, data); } } } reg = SMB328A_FUNCTION_CONTROL_A1; val = smb328a_read_reg(client, reg); if (val >= 0) { data = (u8)val; dev_info(&client->dev, "%s : reg (0x%x) = 0x%x\n", __func__, reg, data); if (data != 0xda) { data = 0xda; if (smb328a_write_reg(client, reg, data) < 0) pr_err("%s : error!\n", __func__); val = smb328a_read_reg(client, reg); if (val >= 0) { data = (u8)val; dev_info(&client->dev, "%s : => reg (0x%x) = 0x%x\n", __func__, reg, data); } } } reg = SMB328A_FUNCTION_CONTROL_A2; val = smb328a_read_reg(client, reg); if (val >= 0) { data = (u8)val; dev_info(&client->dev, "%s : reg (0x%x) = 0x%x\n", __func__, reg, data); if (data != 0x4d) { data = 0x4d; if (smb328a_write_reg(client, reg, data) < 0) pr_err("%s : error!\n", __func__); val = smb328a_read_reg(client, reg); if (val >= 0) { data = (u8)val; dev_info(&client->dev, "%s : => reg (0x%x) = 0x%x\n", __func__, reg, data); } } } reg = SMB328A_FUNCTION_CONTROL_B; val = smb328a_read_reg(client, reg); if (val >= 0) { data = (u8)val; dev_info(&client->dev, "%s : reg (0x%x) = 0x%x\n", __func__, reg, data); if (data != 0x0) { data = 0x0; if (smb328a_write_reg(client, reg, data) < 0) pr_err("%s : error!\n", __func__); val = smb328a_read_reg(client, reg); if (val >= 0) { data = (u8)val; dev_info(&client->dev, "%s : => reg (0x%x) = 0x%x\n", __func__, reg, data); } } } reg = SMB328A_OTG_PWR_AND_LDO_CONTROL; val = smb328a_read_reg(client, reg); if (val >= 0) { data = (u8)val; dev_info(&client->dev, "%s : reg (0x%x) = 0x%x\n", __func__, reg, data); #if defined (CONFIG_TARGET_LOCALE_USA) set_data = 0x55; #else set_data = 0xd5; #endif if (data != set_data) { data = set_data; if (smb328a_write_reg(client, reg, data) < 0) pr_err("%s : error!\n", __func__); val = smb328a_read_reg(client, reg); if (val >= 0) { data = (u8)val; dev_info(&client->dev, "%s : => reg (0x%x) = 0x%x\n", __func__, reg, data); } } } reg = SMB328A_VARIOUS_CONTROL_FUNCTION_A; val = smb328a_read_reg(client, reg); if (val >= 0) { data = (u8)val; dev_info(&client->dev, "%s : reg (0x%x) = 0x%x\n", __func__, reg, data); if (data != 0xf6) { /* this can be changed with top-off setting */ data = 0xf6; if (smb328a_write_reg(client, reg, data) < 0) pr_err("%s : error!\n", __func__); val = smb328a_read_reg(client, reg); if (val >= 0) { data = (u8)val; dev_info(&client->dev, "%s : => reg (0x%x) = 0x%x\n", __func__, reg, data); } } } reg = SMB328A_CELL_TEMPERATURE_MONITOR; val = smb328a_read_reg(client, reg); if (val >= 0) { data = (u8)val; dev_info(&client->dev, "%s : reg (0x%x) = 0x%x\n", __func__, reg, data); if (data != 0x0) { data = 0x0; if (smb328a_write_reg(client, reg, data) < 0) pr_err("%s : error!\n", __func__); val = smb328a_read_reg(client, reg); if (val >= 0) { data = (u8)val; dev_info(&client->dev, "%s : => reg (0x%x) = 0x%x\n", __func__, reg, data); } } } reg = SMB328A_INTERRUPT_SIGNAL_SELECTION; val = smb328a_read_reg(client, reg); if (val >= 0) { data = (u8)val; dev_info(&client->dev, "%s : reg (0x%x) = 0x%x\n", __func__, reg, data); if (data != 0x1) { data = 0x1; if (smb328a_write_reg(client, reg, data) < 0) pr_err("%s : error!\n", __func__); val = smb328a_read_reg(client, reg); if (val >= 0) { data = (u8)val; dev_info(&client->dev, "%s : => reg (0x%x) = 0x%x\n", __func__, reg, data); } } } } static int smb328a_watchdog_control(struct i2c_client *client, bool enable) { int val, reg; u8 data; dev_info(&client->dev, "%s : (%d)\n", __func__, enable); smb328a_allow_volatile_writes(client); reg = SMB328A_FUNCTION_CONTROL_A2; val = smb328a_read_reg(client, reg); if (val >= 0) { data = (u8)val; dev_info(&client->dev, "%s : reg (0x%x) = 0x%x\n", __func__, reg, data); if (enable) data |= (0x1 << 1); else data &= ~(0x1 << 1); if (smb328a_write_reg(client, reg, data) < 0) pr_err("%s : error!\n", __func__); val = smb328a_read_reg(client, reg); if (val >= 0) { data = (u8)val; dev_info(&client->dev, "%s : => reg (0x%x) = 0x%x\n", __func__, reg, data); } } return 0; }
static void smb328a_charger_function_conrol(struct i2c_client *client) { struct smb328a_chip *chip = i2c_get_clientdata(client); int val, reg; u8 data, set_data; smb328a_allow_volatile_writes(client); reg = SMB328A_INPUT_AND_CHARGE_CURRENTS; val = smb328a_read_reg(client, reg); if (val >= 0) { data = (u8)val; dev_info(&client->dev, "%s : reg (0x%x) = 0x%x\n", __func__, reg, data); if (chip->chg_mode == CHG_MODE_AC) { set_data = 0xbf; } else set_data = 0x1f; if (data != set_data) { /* this can be changed with top-off setting */ data = set_data; if (smb328a_write_reg(client, reg, data) < 0) pr_err("%s : error!\n", __func__); val = smb328a_read_reg(client, reg); if (val >= 0) { data = (u8)val; dev_info(&client->dev, "%s : => reg (0x%x) = 0x%x\n", __func__, reg, data); } } } reg = SMB328A_CURRENT_TERMINATION; val = smb328a_read_reg(client, reg); if (val >= 0) { data = (u8)val; dev_info(&client->dev, "%s : reg (0x%x) = 0x%x\n", __func__, reg, data); if (chip->chg_mode == CHG_MODE_AC) { set_data = 0xd0; } else set_data = 0x10; if (data != set_data) { /* AICL enable */ data = set_data; if (smb328a_write_reg(client, reg, data) < 0) pr_err("%s : error!\n", __func__); val = smb328a_read_reg(client, reg); if (val >= 0) { data = (u8)val; dev_info(&client->dev, "%s : => reg (0x%x) = 0x%x\n", __func__, reg, data); } } } reg = SMB328A_FLOAT_VOLTAGE; val = smb328a_read_reg(client, reg); if (val >= 0) { data = (u8)val; dev_info(&client->dev, "%s : reg (0x%x) = 0x%x\n", __func__, reg, data); if (data != 0xca) { data = 0xca; /* 4.2V float voltage */ if (smb328a_write_reg(client, reg, data) < 0) pr_err("%s : error!\n", __func__); val = smb328a_read_reg(client, reg); if (val >= 0) { data = (u8)val; dev_info(&client->dev, "%s : => reg (0x%x) = 0x%x\n", __func__, reg, data); } } } reg = SMB328A_FUNCTION_CONTROL_A1; val = smb328a_read_reg(client, reg); if (val >= 0) { data = (u8)val; dev_info(&client->dev, "%s : reg (0x%x) = 0x%x\n", __func__, reg, data); if (data != 0xda) { data = 0xda; if (smb328a_write_reg(client, reg, data) < 0) pr_err("%s : error!\n", __func__); val = smb328a_read_reg(client, reg); if (val >= 0) { data = (u8)val; dev_info(&client->dev, "%s : => reg (0x%x) = 0x%x\n", __func__, reg, data); } } } reg = SMB328A_FUNCTION_CONTROL_A2; val = smb328a_read_reg(client, reg); if (val >= 0) { data = (u8)val; dev_info(&client->dev, "%s : reg (0x%x) = 0x%x\n", __func__, reg, data); if (data != 0x4d) { data = 0x4d; if (smb328a_write_reg(client, reg, data) < 0) pr_err("%s : error!\n", __func__); val = smb328a_read_reg(client, reg); if (val >= 0) { data = (u8)val; dev_info(&client->dev, "%s : => reg (0x%x) = 0x%x\n", __func__, reg, data); } } } reg = SMB328A_FUNCTION_CONTROL_B; val = smb328a_read_reg(client, reg); if (val >= 0) { data = (u8)val; dev_info(&client->dev, "%s : reg (0x%x) = 0x%x\n", __func__, reg, data); if (data != 0x0) { data = 0x0; if (smb328a_write_reg(client, reg, data) < 0) pr_err("%s : error!\n", __func__); val = smb328a_read_reg(client, reg); if (val >= 0) { data = (u8)val; dev_info(&client->dev, "%s : => reg (0x%x) = 0x%x\n", __func__, reg, data); } } } reg = SMB328A_OTG_PWR_AND_LDO_CONTROL; val = smb328a_read_reg(client, reg); if (val >= 0) { data = (u8)val; dev_info(&client->dev, "%s : reg (0x%x) = 0x%x\n", __func__, reg, data); #if defined (CONFIG_TARGET_LOCALE_USA) set_data = 0x4d; #else set_data = 0xd5; #endif if (data != set_data) { data = set_data; if (smb328a_write_reg(client, reg, data) < 0) pr_err("%s : error!\n", __func__); val = smb328a_read_reg(client, reg); if (val >= 0) { data = (u8)val; dev_info(&client->dev, "%s : => reg (0x%x) = 0x%x\n", __func__, reg, data); } } } reg = SMB328A_VARIOUS_CONTROL_FUNCTION_A; val = smb328a_read_reg(client, reg); if (val >= 0) { data = (u8)val; dev_info(&client->dev, "%s : reg (0x%x) = 0x%x\n", __func__, reg, data); if (data != 0xf6) { /* this can be changed with top-off setting */ data = 0xf6; if (smb328a_write_reg(client, reg, data) < 0) pr_err("%s : error!\n", __func__); val = smb328a_read_reg(client, reg); if (val >= 0) { data = (u8)val; dev_info(&client->dev, "%s : => reg (0x%x) = 0x%x\n", __func__, reg, data); } } } reg = SMB328A_CELL_TEMPERATURE_MONITOR; val = smb328a_read_reg(client, reg); if (val >= 0) { data = (u8)val; dev_info(&client->dev, "%s : reg (0x%x) = 0x%x\n", __func__, reg, data); if (data != 0x0) { data = 0x0; if (smb328a_write_reg(client, reg, data) < 0) pr_err("%s : error!\n", __func__); val = smb328a_read_reg(client, reg); if (val >= 0) { data = (u8)val; dev_info(&client->dev, "%s : => reg (0x%x) = 0x%x\n", __func__, reg, data); } } } reg = SMB328A_INTERRUPT_SIGNAL_SELECTION; val = smb328a_read_reg(client, reg); if (val >= 0) { data = (u8)val; dev_info(&client->dev, "%s : reg (0x%x) = 0x%x\n", __func__, reg, data); if (data != 0x1) { data = 0x1; if (smb328a_write_reg(client, reg, data) < 0) pr_err("%s : error!\n", __func__); val = smb328a_read_reg(client, reg); if (val >= 0) { data = (u8)val; dev_info(&client->dev, "%s : => reg (0x%x) = 0x%x\n", __func__, reg, data); } } } }
static void smb328a_charger_function_conrol(struct i2c_client *client) { struct smb328a_chip *chip = i2c_get_clientdata(client); int val; u8 data, set_data; smb328a_allow_volatile_writes(client); /* Clear IRQ register*/ set_data = 0xAA; if (smb328a_write_reg(client, SMB328A_CLEAR_IRQ, set_data) < 0) pr_err("%s : write error!\n", __func__); else printk("%s : Clear IRQ register.\n", __func__); val = smb328a_read_reg(client, SMB328A_INPUT_AND_CHARGE_CURRENTS); if (val >= 0) { data = (u8)val; dev_info(&client->dev, "%s : reg (0x%x) = 0x%x\n", __func__, SMB328A_INPUT_AND_CHARGE_CURRENTS, data); #if 0 if (chip->chg_mode == CHG_MODE_AC) { set_data = 0x97; } else set_data = 0x17; #endif set_data = 0x75; if (data != set_data) { /* this can be changed with top-off setting */ data = set_data; if (smb328a_write_reg(client, SMB328A_INPUT_AND_CHARGE_CURRENTS, data) < 0) pr_err("%s : error!\n", __func__); val = smb328a_read_reg(client, SMB328A_INPUT_AND_CHARGE_CURRENTS); if (val >= 0) { data = (u8)val; dev_info(&client->dev, "%s : => reg (0x%x) = 0x%x\n", __func__, SMB328A_INPUT_AND_CHARGE_CURRENTS, data); } } } val = smb328a_read_reg(client, SMB328A_CURRENT_TERMINATION); if (val >= 0) { data = (u8)val; dev_info(&client->dev, "%s : reg (0x%x) = 0x%x\n", __func__, SMB328A_CURRENT_TERMINATION, data); #if 0 if (chip->chg_mode == CHG_MODE_AC) { set_data = 0x90; } else set_data = 0x10; #endif #if CONFIG_MACH_APACHE set_data = 0x54;/* HW req : chg current 600mA -> 700 mA */ #else set_data = 0x34; #endif if (data != set_data) { /* AICL enable */ data = set_data; if (smb328a_write_reg(client, SMB328A_CURRENT_TERMINATION, data) < 0) pr_err("%s : error!\n", __func__); val = smb328a_read_reg(client, SMB328A_CURRENT_TERMINATION); if (val >= 0) { data = (u8)val; dev_info(&client->dev, "%s : => reg (0x%x) = 0x%x\n", __func__, SMB328A_CURRENT_TERMINATION, data); } } } val = smb328a_read_reg(client, SMB328A_FLOAT_VOLTAGE); if (val >= 0) { data = (u8)val; dev_info(&client->dev, "%s : reg (0x%x) = 0x%x\n", __func__, SMB328A_FLOAT_VOLTAGE, data); #if CONFIG_MACH_ANCORA if (data != 0xCC) { data = 0xCC; /* 4.22V float voltage *//* hw requirements '*****@*****.**'*/ #else if (data != 0xCA) { data = 0xCA; /* 4.2V float voltage */ #endif if (smb328a_write_reg(client, SMB328A_FLOAT_VOLTAGE, data) < 0) pr_err("%s : error!\n", __func__); val = smb328a_read_reg(client, SMB328A_FLOAT_VOLTAGE); if (val >= 0) { data = (u8)val; dev_info(&client->dev, "%s : => reg (0x%x) = 0x%x\n", __func__, SMB328A_FLOAT_VOLTAGE, data); } } } val = smb328a_read_reg(client, SMB328A_FUNCTION_CONTROL_A1); if (val >= 0) { data = (u8)val; dev_info(&client->dev, "%s : reg (0x%x) = 0x%x\n", __func__, SMB328A_FUNCTION_CONTROL_A1, data); if (data != 0xDA) { data = 0xDA; if (smb328a_write_reg(client, SMB328A_FUNCTION_CONTROL_A1, data) < 0) pr_err("%s : error!\n", __func__); val = smb328a_read_reg(client, SMB328A_FUNCTION_CONTROL_A1); if (val >= 0) { data = (u8)val; dev_info(&client->dev, "%s : => reg (0x%x) = 0x%x\n", __func__, SMB328A_FUNCTION_CONTROL_A1, data); } } } val = smb328a_read_reg(client, SMB328A_FUNCTION_CONTROL_A2); if (val >= 0) { data = (u8)val; dev_info(&client->dev, "%s : reg (0x%x) = 0x%x\n", __func__, SMB328A_FUNCTION_CONTROL_A2, data); if (data != 0x4F) { data = 0x4F; if (smb328a_write_reg(client, SMB328A_FUNCTION_CONTROL_A2, data) < 0) pr_err("%s : error!\n", __func__); val = smb328a_read_reg(client, SMB328A_FUNCTION_CONTROL_A2); if (val >= 0) { data = (u8)val; dev_info(&client->dev, "%s : => reg (0x%x) = 0x%x\n", __func__, SMB328A_FUNCTION_CONTROL_A2, data); } } } val = smb328a_read_reg(client, SMB328A_FUNCTION_CONTROL_B); if (val >= 0) { data = (u8)val; dev_info(&client->dev, "%s : reg (0x%x) = 0x%x\n", __func__, SMB328A_FUNCTION_CONTROL_B, data); if (data != 0x00) { data = 0x00; if (smb328a_write_reg(client, SMB328A_FUNCTION_CONTROL_B, data) < 0) pr_err("%s : error!\n", __func__); val = smb328a_read_reg(client, SMB328A_FUNCTION_CONTROL_B); if (val >= 0) { data = (u8)val; dev_info(&client->dev, "%s : => reg (0x%x) = 0x%x\n", __func__, SMB328A_FUNCTION_CONTROL_B, data); } } } val = smb328a_read_reg(client, SMB328A_OTG_PWR_AND_LDO_CONTROL); if (val >= 0) { data = (u8)val; dev_info(&client->dev, "%s : reg (0x%x) = 0x%x\n", __func__, SMB328A_OTG_PWR_AND_LDO_CONTROL, data); #if defined (CONFIG_TARGET_LOCALE_USA) set_data = 0x4d; #else set_data = 0xC5; #endif if (data != set_data) { data = set_data; if (smb328a_write_reg(client, SMB328A_OTG_PWR_AND_LDO_CONTROL, data) < 0) pr_err("%s : error!\n", __func__); val = smb328a_read_reg(client, SMB328A_OTG_PWR_AND_LDO_CONTROL); if (val >= 0) { data = (u8)val; dev_info(&client->dev, "%s : => reg (0x%x) = 0x%x\n", __func__, SMB328A_OTG_PWR_AND_LDO_CONTROL, data); } } } val = smb328a_read_reg(client, SMB328A_VARIOUS_CONTROL_FUNCTION_A); if (val >= 0) { data = (u8)val; dev_info(&client->dev, "%s : reg (0x%x) = 0x%x\n", __func__, SMB328A_VARIOUS_CONTROL_FUNCTION_A, data); if (data != 0xF6) { /* this can be changed with top-off setting */ data = 0xF6; if (smb328a_write_reg(client, SMB328A_VARIOUS_CONTROL_FUNCTION_A, data) < 0) pr_err("%s : error!\n", __func__); val = smb328a_read_reg(client, SMB328A_VARIOUS_CONTROL_FUNCTION_A); if (val >= 0) { data = (u8)val; dev_info(&client->dev, "%s : => reg (0x%x) = 0x%x\n", __func__, SMB328A_VARIOUS_CONTROL_FUNCTION_A, data); } } } val = smb328a_read_reg(client, SMB328A_CELL_TEMPERATURE_MONITOR); if (val >= 0) { data = (u8)val; dev_info(&client->dev, "%s : reg (0x%x) = 0x%x\n", __func__, SMB328A_CELL_TEMPERATURE_MONITOR, data); if (data != 0x00) { data = 0x00; if (smb328a_write_reg(client, SMB328A_CELL_TEMPERATURE_MONITOR, data) < 0) pr_err("%s : error!\n", __func__); val = smb328a_read_reg(client, SMB328A_CELL_TEMPERATURE_MONITOR); if (val >= 0) { data = (u8)val; dev_info(&client->dev, "%s : => reg (0x%x) = 0x%x\n", __func__, SMB328A_CELL_TEMPERATURE_MONITOR, data); } } } val = smb328a_read_reg(client, SMB328A_INTERRUPT_SIGNAL_SELECTION); if (val >= 0) { data = (u8)val; dev_info(&client->dev, "%s : reg (0x%x) = 0x%x\n", __func__, SMB328A_INTERRUPT_SIGNAL_SELECTION, data); if (data != 0x00) { data = 0x20; if (smb328a_write_reg(client, SMB328A_INTERRUPT_SIGNAL_SELECTION, data) < 0) pr_err("%s : error!\n", __func__); val = smb328a_read_reg(client, SMB328A_INTERRUPT_SIGNAL_SELECTION); if (val >= 0) { data = (u8)val; dev_info(&client->dev, "%s : => reg (0x%x) = 0x%x\n", __func__, SMB328A_INTERRUPT_SIGNAL_SELECTION, data); } } } } static int smb328a_check_charging_status(struct i2c_client *client) { int val; u8 data = 0; int ret = -1; //printk("%s : \n", __func__); val = smb328a_read_reg(client, SMB328A_BATTERY_CHARGING_STATUS_C); if (val >= 0) { data = (u8)val; dev_info(&client->dev, "%s : reg (0x%x) = 0x%x\n", __func__, SMB328A_BATTERY_CHARGING_STATUS_C, data); ret = (data&(0x3<<1))>>1; dev_info(&client->dev, "%s : status = 0x%x\n", __func__, data); }