static void smb327_charger_otg_control(struct i2c_client *client, int enable) { u8 reg_data; smb327_i2c_read(client, SMB327_OTG_POWER_AND_LDO, ®_data); if (!enable) reg_data |= CFG_OTG_ENABLE; else reg_data &= ~CFG_OTG_ENABLE; smb327_set_writable(client, 1); smb327_i2c_write(client, SMB327_OTG_POWER_AND_LDO, ®_data); smb327_set_writable(client, 0); }
static void smb327_irq_disable(struct i2c_client *client) { u8 data; smb327_set_writable(client, 1); data = 0x6E; smb327_i2c_write(client, 0x04, &data); smb327_i2c_read(client, SMB327_INTERRUPT_SIGNAL_SELECTION, &data); data &= 0xfe; smb327_i2c_write(client, SMB327_INTERRUPT_SIGNAL_SELECTION, &data); smb327_set_writable(client, 0); }
static void smb327_irq_enable(struct i2c_client *client) { u8 data; smb327_set_writable(client, 1); if (system_rev < 10) data = 0x4D; else data = 0x6D; smb327_i2c_write(client, 0x04, &data); smb327_i2c_read(client, SMB327_INTERRUPT_SIGNAL_SELECTION, &data); data |= 0x1; smb327_i2c_write(client, SMB327_INTERRUPT_SIGNAL_SELECTION, &data); smb327_set_writable(client, 0); }
static void smb327_charger_function_control(struct i2c_client *client) { struct sec_charger_info *charger = i2c_get_clientdata(client); u8 reg_data, charge_mode; smb327_set_writable(client, 1); if (system_rev < 10) reg_data = 0x4E; else reg_data = 0x6E; smb327_i2c_write(client, SMB327_FUNCTION_CONTROL_B, ®_data); smb327_i2c_read(client, SMB327_INTERRUPT_SIGNAL_SELECTION, ®_data); reg_data |= 0x1; smb327_i2c_write(client, SMB327_INTERRUPT_SIGNAL_SELECTION, ®_data); if (charger->cable_type == POWER_SUPPLY_TYPE_BATTERY) { /* turn off charger */ smb327_set_charge_enable(client, 0); } else { pr_info("%s: Input : %d, Charge : %d\n", __func__, charger->pdata->charging_current[charger->cable_type].input_current_limit, charger->charging_current); /* AICL enable */ smb327_i2c_read(client, SMB327_INPUT_CURRENTLIMIT, ®_data); reg_data &= ~CFG_AICL_ENABLE; reg_data &= ~CFG_AICL_VOLTAGE; /* AICL enable voltage 4.25V */ smb327_i2c_write(client, SMB327_INPUT_CURRENTLIMIT, ®_data); /* Function control A */ reg_data = 0xDA; smb327_i2c_write(client, SMB327_FUNCTION_CONTROL_A, ®_data); /* 4.2V float voltage */ smb327_set_float_voltage(client, charger->pdata->chg_float_voltage); /* Set termination current */ smb327_set_termination_current_limit(client, charger->pdata->charging_current[charger-> cable_type].full_check_current_1st); smb327_set_input_current_limit(client, charger->pdata->charging_current [charger->cable_type].input_current_limit); smb327_set_fast_charging_current(client, charger->charging_current); /* SET USB5/1, AC/USB Mode */ charge_mode = (charger->cable_type == POWER_SUPPLY_TYPE_MAINS) || (charger->cable_type == POWER_SUPPLY_TYPE_UARTOFF) ? 0x3 : 0x2; smb327_i2c_read(client, SMB327_COMMAND, ®_data); reg_data &= ~0x0C; reg_data |= charge_mode << 2; smb327_i2c_write(client, SMB327_COMMAND, ®_data); smb327_set_charge_enable(client, 1); } smb327_test_read(client); smb327_set_writable(client, 0); }