static void smb329_work_func(struct work_struct *work)
{
	mutex_lock(&smb329.state_lock);

	switch (smb329.chg_state) {
	case SMB329_ENABLE_FAST_CHG:
		pr_info("smb329: charger on (fast)\n");
		smb329_i2c_write_byte(0x84, 0x31);
		smb329_i2c_write_byte(0x08, 0x05);
		if ((smb329.version & 0x18) == 0x0)
			smb329_i2c_write_byte(0xA9, 0x00);
		break;

	case SMB329_DISABLE_CHG:
	case SMB329_ENABLE_SLOW_CHG:
		pr_info("smb329: charger off/slow\n");
		smb329_i2c_write_byte(0x88, 0x31);
		smb329_i2c_write_byte(0x08, 0x05);
		break;
	default:
		pr_err("smb329: unknown charger state %d\n",
			smb329.chg_state);
	}

	mutex_unlock(&smb329.state_lock);
}
Ejemplo n.º 2
0
int set_charger_ctrl(u32 ctl)
{
	int result = 0;
    u8 version;

	switch (ctl) {
	case DISABLE:
		pr_info("Switch charger OFF\n");
        if (machine_is_incrediblec()) {
		smb329_i2c_write_byte(0x80, 0x31);
		smb329_i2c_write_byte(0x20, 0x06);
        }
		break;
	case ENABLE_SLOW_CHG:
		pr_info("Switch charger ON (SLOW)\n");
		smb329_i2c_write_byte(0x88, 0x31);
		smb329_i2c_write_byte(0x08, 0x05);
		break;
	case ENABLE_FAST_CHG:
		pr_info("Switch charger ON (FAST)\n");
		smb329_i2c_write_byte(0x84, 0x31);
		smb329_i2c_write_byte(0x08, 0x05);
		smb329_i2c_read_byte(&version, 0x3B);
		pr_info("Switch charger version%x\n", version);
		if ((version & 0x18) == 0x0)
			smb329_i2c_write_byte(0xA9, 0x00);
		break;
	default:
		pr_info("%s: Not supported battery ctr called.!", __func__);
		result = -EINVAL;
		break;
	}

	return result;
}