int set_charger_ctrl(u32 ctl) { int result = 0; u8 version; switch (ctl) { case DISABLE: pr_info("Switch charger OFF\n"); 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(0xD0, 0x01); 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; }
static int smb329_probe(struct i2c_client *client, const struct i2c_device_id *id) { if (i2c_check_functionality(client->adapter, I2C_FUNC_I2C) == 0) { dev_dbg(&client->dev, "[SMB329]:I2C fail\n"); return -EIO; } smb329.client = client; mutex_init(&smb329.state_lock); INIT_WORK(&smb329.work, smb329_work_func); smb329_i2c_read_byte(&smb329.version, 0x3B); pr_info("smb329 version: 0x%02x\n", smb329.version); return 0; }