static void tps65200_shutdown(struct i2c_client *client) { u8 regh; pr_info("TPS65200 shutdown\n"); tps65200_i2c_read_byte(®h, 0x00); /* disable shunt monitor to decrease 0.035mA of current */ regh &= 0xDF; tps65200_i2c_write_byte(regh, 0x00); }
int tps_set_charger_ctrl(u32 ctl) { int result = 0; u8 status; u8 regh; if (tps65200_initial < 0) return 0; switch (ctl) { case DISABLE: pr_info("Switch charger OFF\n"); tps65200_i2c_write_byte(0x29, 0x01); tps65200_i2c_write_byte(0x28, 0x00); break; case ENABLE_SLOW_CHG: case ENABLE_WIRELESS_CHG: pr_info("Switch charger ON (SLOW)\n"); tps65200_i2c_write_byte(0x29, 0x01); tps65200_i2c_write_byte(0x2A, 0x00); if (tps65200_low_chg) tps65200_i2c_write_byte(0x8B, 0x03); else tps65200_i2c_write_byte(0x83, 0x03); tps65200_i2c_read_byte(®h, 0x03); pr_info("batt: Switch charger ON (SLOW): regh 0x03=%x\n", regh); tps65200_i2c_write_byte(0x63, 0x02); break; case ENABLE_FAST_CHG: pr_info("Switch charger ON (FAST)\n"); tps65200_i2c_write_byte(0x29, 0x01); tps65200_i2c_write_byte(0x2A, 0x00); if (tps65200_low_chg) tps65200_i2c_write_byte(0x8B, 0x03); else tps65200_i2c_write_byte(0x83, 0x03); tps65200_i2c_write_byte(0xA3, 0x02); tps65200_i2c_read_byte(®h, 0x01); pr_info("batt: Switch charger ON (FAST): regh 0x01=%x\n", regh); tps65200_i2c_read_byte(®h, 0x00); pr_info("batt: Switch charger ON (FAST): regh 0x00=%x\n", regh); tps65200_i2c_read_byte(®h, 0x03); pr_info("batt: Switch charger ON (FAST): regh 0x03=%x\n", regh); tps65200_i2c_read_byte(®h, 0x02); pr_info("batt: Switch charger ON (FAST): regh 0x02=%x\n", regh); break; case ENABLE_LIMITED_CHG: pr_info("Switch charger on (LIMITED)\n"); tps65200_i2c_write_byte(0x8B, 0x03); tps65200_low_chg = 1; tps65200_i2c_read_byte(®h, 0x03); pr_info("batt: Switch charger ON (LIMITED): regh 0x03=%x\n", regh); break; case CLEAR_LIMITED_CHG: pr_info("Switch charger off (LIMITED)\n"); tps65200_i2c_write_byte(0x83, 0x03); tps65200_low_chg = 0; tps65200_i2c_read_byte(®h, 0x03); pr_info("batt: Switch charger ON (LIMITED): regh 0x03=%x\n", regh); break; case CHECK_CHG: pr_info("Switch charger CHECK \n"); tps65200_i2c_read_byte(&status, 0x06); pr_info("TPS65200 STATUS_A%x\n", status); break; case SET_ICL500: pr_info("Switch charger SET_ICL500 \n"); tps65200_i2c_write_byte(0xA3, 0x02); break; case SET_ICL100: pr_info("Switch charger SET_ICL100 \n"); tps65200_i2c_write_byte(0x23, 0x02); break; case CHECK_INT1: pr_info("Switch charger CHECK_INT1 \n"); tps65200_i2c_read_byte(&status, 0x08); pr_info("Switch charger CHECK_INT1: regh 0x08h=%x\n", status); result = (int)status; break; case CHECK_INT2: pr_info("Switch charger CHECK_INT2 \n"); tps65200_i2c_read_byte(&status, 0x09); pr_info("TPS65200 INT2 %x\n", status); result = (int)status; break; case CHECK_CONTROL: pr_info("Switch charger CHECK_CONTROL \n"); tps65200_i2c_read_byte(&status, 0x00); pr_info("TPS65200 status 0x00=%x\n", status); break; case OVERTEMP_VREG_4060: pr_info("Switch charger OVERTEMP_VREG_4060 \n"); tps65200_i2c_read_byte(®h, 0x02); regh = (regh & 0xC0) | 0x1C; tps65200_i2c_write_byte(regh, 0x02); tps65200_i2c_read_byte(®h, 0x02); pr_info("Switch charger OVERTEMP_VREG_4060: regh 0x02=%x\n", regh); break; case NORMALTEMP_VREG_4200: pr_info("Switch charger NORMALTEMP_VREG_4200 \n"); tps65200_i2c_read_byte(®h, 0x02); regh = (regh & 0xC0) | 0X23; tps65200_i2c_write_byte(regh, 0x02); tps65200_i2c_read_byte(®h, 0x02); pr_info("Switch charger NORMALTEMP_VREG_4200: regh 0x02=%x\n", regh); break; default: pr_info("%s: Not supported battery ctr called.!", __func__); result = -EINVAL; break; } return result; }
int tps_set_charger_ctrl(u32 ctl) { int result = 0; u8 status; u8 regh; if (tps65200_initial < 0) return 0; switch (ctl) { case POWER_SUPPLY_DISABLE_CHARGE: pr_info("Switch charger OFF\n"); tps65200_i2c_write_byte(0x29, 0x01); tps65200_i2c_write_byte(0x28, 0x00); if (tps65200_chager_check) /* cancel CHECK_CHG alarm */ alarm_cancel(&tps65200_check_alarm); break; case POWER_SUPPLY_ENABLE_SLOW_CHARGE: pr_info("Switch charger ON (SLOW)\n"); tps65200_i2c_write_byte(0x29, 0x01); tps65200_i2c_write_byte(0x2A, 0x00); if (tps65200_low_chg) tps65200_i2c_write_byte(0x8B, 0x03); else tps65200_i2c_write_byte(0x83, 0x03); tps65200_i2c_read_byte(®h, 0x03); pr_info("batt: Switch charger ON (SLOW): regh 0x03=%x\n", regh); tps65200_i2c_write_byte(0x63, 0x02); if (tps65200_chager_check) /* set alarm for CHECK_CHG */ tps65200_set_check_alarm(); break; case POWER_SUPPLY_ENABLE_FAST_CHARGE: pr_info("Switch charger ON (FAST)\n"); tps65200_i2c_write_byte(0x29, 0x01); tps65200_i2c_write_byte(0x2A, 0x00); if (tps65200_low_chg) tps65200_i2c_write_byte(0x8B, 0x03); else tps65200_i2c_write_byte(0x83, 0x03); tps65200_i2c_write_byte(0xA3, 0x02); tps65200_i2c_read_byte(®h, 0x01); pr_info("batt: Switch charger ON (FAST): regh 0x01=%x\n", regh); tps65200_i2c_read_byte(®h, 0x00); pr_info("batt: Switch charger ON (FAST): regh 0x00=%x\n", regh); tps65200_i2c_read_byte(®h, 0x03); pr_info("batt: Switch charger ON (FAST): regh 0x03=%x\n", regh); tps65200_i2c_read_byte(®h, 0x02); pr_info("batt: Switch charger ON (FAST): regh 0x02=%x\n", regh); if (tps65200_chager_check) /* set alarm for CHECK_CHG */ tps65200_set_check_alarm(); break; case POWER_SUPPLY_ENABLE_SLOW_HV_CHARGE: pr_info("Switch charger ON (SLOW_HV)\n"); tps65200_i2c_write_byte(0x29, 0x01); tps65200_i2c_write_byte(0x2A, 0x00); if (tps65200_low_chg) tps65200_i2c_write_byte(0x8D, 0x03); else tps65200_i2c_write_byte(0x85, 0x03); tps65200_i2c_read_byte(®h, 0x03); pr_info("batt: Switch charger ON (SLOW_HV): regh 0x03=%x\n", regh); tps65200_i2c_write_byte(0x6A, 0x02); tps65200_i2c_read_byte(®h, 0x02); pr_info("batt: Switch charger ON (SLOW_HV): regh 0x02=%x\n", regh); if (tps65200_chager_check) /* set alarm for CHECK_CHG */ tps65200_set_check_alarm(); break; case POWER_SUPPLY_ENABLE_FAST_HV_CHARGE: pr_info("Switch charger ON (FAST_HV)\n"); tps65200_i2c_write_byte(0x29, 0x01); tps65200_i2c_write_byte(0x2A, 0x00); if (tps65200_low_chg) tps65200_i2c_write_byte(0x8D, 0x03); else tps65200_i2c_write_byte(0x85, 0x03); tps65200_i2c_write_byte(0xAA, 0x02); tps65200_i2c_read_byte(®h, 0x01); pr_info("batt: Switch charger ON (FAST_HV): regh 0x01=%x\n", regh); tps65200_i2c_read_byte(®h, 0x00); pr_info("batt: Switch charger ON (FAST_HV): regh 0x00=%x\n", regh); tps65200_i2c_read_byte(®h, 0x03); pr_info("batt: Switch charger ON (FAST_HV): regh 0x03=%x\n", regh); tps65200_i2c_read_byte(®h, 0x02); pr_info("batt: Switch charger ON (FAST_HV): regh 0x02=%x\n", regh); if (tps65200_chager_check) /* set alarm for CHECK_CHG */ tps65200_set_check_alarm(); break; case ENABLE_LIMITED_CHG: pr_info("Switch charger on (LIMITED)\n"); tps65200_i2c_write_byte(0x8B, 0x03); tps65200_low_chg = 1; tps65200_i2c_read_byte(®h, 0x03); pr_info("batt: Switch charger ON (LIMITED): regh 0x03=%x\n", regh); break; case CLEAR_LIMITED_CHG: pr_info("Switch charger off (LIMITED)\n"); tps65200_i2c_write_byte(0x83, 0x03); tps65200_low_chg = 0; tps65200_i2c_read_byte(®h, 0x03); pr_info("batt: Switch charger OFF (LIMITED): regh 0x03=%x\n", regh); break; case CHECK_CHG: pr_info("Switch charger CHECK \n"); tps65200_i2c_read_byte(&status, 0x06); pr_info("TPS65200 STATUS_A%x\n", status); break; case SET_ICL500: pr_info("Switch charger SET_ICL500 \n"); tps65200_i2c_write_byte(0xA3, 0x02); break; case SET_ICL100: pr_info("Switch charger SET_ICL100 \n"); tps65200_i2c_write_byte(0x23, 0x02); break; case CHECK_INT1: pr_info("Switch charger CHECK_INT1 \n"); tps65200_i2c_read_byte(&status, 0x08); pr_info("Switch charger CHECK_INT1: regh 0x08h=%x\n", status); result = (int)status; break; case CHECK_INT2: pr_info("Switch charger CHECK_INT2 \n"); tps65200_i2c_read_byte(&status, 0x09); pr_info("TPS65200 INT2 %x\n", status); result = (int)status; break; case CHECK_CONTROL: pr_info("Switch charger CHECK_CONTROL \n"); tps65200_i2c_read_byte(&status, 0x00); pr_info("TPS65200 status 0x00=%x\n", status); break; case OVERTEMP_VREG: #ifdef CONFIG_SUPPORT_DQ_BATTERY tps65200_i2c_read_byte(®h, 0x04); pr_info("Switch charger CONFIG_D: regh 0x04=%x\n", regh); if (htc_is_dq_pass()) { pr_info("Switch charger OVERTEMP_VREG_4240\n"); tps65200_i2c_read_byte(®h, 0x02); regh = (regh & 0xC0) | 0x25; tps65200_i2c_write_byte(regh, 0x02); tps65200_i2c_read_byte(®h, 0x02); pr_info("Switch charger OVERTEMP_VREG_4240: regh 0x02=%x\n", regh); break; } #endif pr_info("Switch charger OVERTEMP_VREG_4060 \n"); tps65200_i2c_read_byte(®h, 0x02); regh = (regh & 0xC0) | 0x1C; tps65200_i2c_write_byte(regh, 0x02); tps65200_i2c_read_byte(®h, 0x02); pr_info("Switch charger OVERTEMP_VREG_4060: regh 0x02=%x\n", regh); break; case NORMALTEMP_VREG: #ifdef CONFIG_SUPPORT_DQ_BATTERY tps65200_i2c_read_byte(®h, 0x04); pr_info("Switch charger CONFIG_D: regh 0x04=%x\n", regh); if (htc_is_dq_pass()) { pr_info("Switch charger NORMALTEMP_VREG_4340\n"); tps65200_i2c_read_byte(®h, 0x02); regh = (regh & 0xC0) | 0X2A; tps65200_i2c_write_byte(regh, 0x02); tps65200_i2c_read_byte(®h, 0x02); pr_info("Switch charger NORMALTEMP_VREG_4340: regh 0x02=%x\n", regh); break; } #endif pr_info("Switch charger NORMALTEMP_VREG_4200 \n"); tps65200_i2c_read_byte(®h, 0x02); regh = (regh & 0xC0) | 0X23; tps65200_i2c_write_byte(regh, 0x02); tps65200_i2c_read_byte(®h, 0x02); pr_info("Switch charger NORMALTEMP_VREG_4200: regh 0x02=%x\n", regh); break; default: pr_info("%s: Not supported battery ctr called.!", __func__); result = -EINVAL; break; } return result; }