• Home
  • Raw
  • Download

Lines Matching refs:info

157 static int fuel_gauge_reg_readb(struct axp288_fg_info *info, int reg)  in fuel_gauge_reg_readb()  argument
162 ret = regmap_read(info->regmap, reg, &val); in fuel_gauge_reg_readb()
164 dev_err(info->dev, "Error reading reg 0x%02x err: %d\n", reg, ret); in fuel_gauge_reg_readb()
171 static int fuel_gauge_reg_writeb(struct axp288_fg_info *info, int reg, u8 val) in fuel_gauge_reg_writeb() argument
175 ret = regmap_write(info->regmap, reg, (unsigned int)val); in fuel_gauge_reg_writeb()
178 dev_err(info->dev, "Error writing reg 0x%02x err: %d\n", reg, ret); in fuel_gauge_reg_writeb()
183 static int fuel_gauge_read_15bit_word(struct axp288_fg_info *info, int reg) in fuel_gauge_read_15bit_word() argument
188 ret = regmap_bulk_read(info->regmap, reg, buf, 2); in fuel_gauge_read_15bit_word()
190 dev_err(info->dev, "Error reading reg 0x%02x err: %d\n", reg, ret); in fuel_gauge_read_15bit_word()
196 dev_err(info->dev, "Error reg 0x%02x contents not valid\n", reg); in fuel_gauge_read_15bit_word()
203 static int fuel_gauge_read_12bit_word(struct axp288_fg_info *info, int reg) in fuel_gauge_read_12bit_word() argument
208 ret = regmap_bulk_read(info->regmap, reg, buf, 2); in fuel_gauge_read_12bit_word()
210 dev_err(info->dev, "Error reading reg 0x%02x err: %d\n", reg, ret); in fuel_gauge_read_12bit_word()
218 static int fuel_gauge_update_registers(struct axp288_fg_info *info) in fuel_gauge_update_registers() argument
222 if (info->valid && time_before(jiffies, info->last_updated + AXP288_REG_UPDATE_INTERVAL)) in fuel_gauge_update_registers()
225 dev_dbg(info->dev, "Fuel Gauge updating register values...\n"); in fuel_gauge_update_registers()
231 ret = fuel_gauge_reg_readb(info, AXP20X_PWR_INPUT_STATUS); in fuel_gauge_update_registers()
234 info->pwr_stat = ret; in fuel_gauge_update_registers()
237 ret = fuel_gauge_reg_readb(info, AXP288_FG_OCV_CAP_REG); in fuel_gauge_update_registers()
239 ret = fuel_gauge_reg_readb(info, AXP20X_FG_RES); in fuel_gauge_update_registers()
242 info->fg_res = ret; in fuel_gauge_update_registers()
244 ret = iio_read_channel_raw(info->iio_channel[BAT_VOLT], &info->bat_volt); in fuel_gauge_update_registers()
248 ret = fuel_gauge_read_12bit_word(info, AXP288_FG_OCVH_REG); in fuel_gauge_update_registers()
251 info->ocv = ret; in fuel_gauge_update_registers()
256 if (info->pwr_stat & PS_STAT_BAT_CHRG_DIR) { in fuel_gauge_update_registers()
257 info->d_curr = 0; in fuel_gauge_update_registers()
258 ret = iio_read_channel_raw(info->iio_channel[BAT_CHRG_CURR], &info->c_curr); in fuel_gauge_update_registers()
262 info->c_curr = 0; in fuel_gauge_update_registers()
263 ret = iio_read_channel_raw(info->iio_channel[BAT_D_CURR], &info->d_curr); in fuel_gauge_update_registers()
268 ret = fuel_gauge_read_15bit_word(info, AXP288_FG_CC_MTR1_REG); in fuel_gauge_update_registers()
271 info->fg_cc_mtr1 = ret; in fuel_gauge_update_registers()
273 ret = fuel_gauge_read_15bit_word(info, AXP288_FG_DES_CAP1_REG); in fuel_gauge_update_registers()
276 info->fg_des_cap1 = ret; in fuel_gauge_update_registers()
279 info->last_updated = jiffies; in fuel_gauge_update_registers()
280 info->valid = 1; in fuel_gauge_update_registers()
287 static void fuel_gauge_get_status(struct axp288_fg_info *info) in fuel_gauge_get_status() argument
289 int pwr_stat = info->pwr_stat; in fuel_gauge_get_status()
290 int fg_res = info->fg_res; in fuel_gauge_get_status()
291 int curr = info->d_curr; in fuel_gauge_get_status()
302 info->status = POWER_SUPPLY_STATUS_FULL; in fuel_gauge_get_status()
315 info->status = POWER_SUPPLY_STATUS_FULL; in fuel_gauge_get_status()
321 info->status = POWER_SUPPLY_STATUS_CHARGING; in fuel_gauge_get_status()
323 info->status = POWER_SUPPLY_STATUS_DISCHARGING; in fuel_gauge_get_status()
326 static int fuel_gauge_battery_health(struct axp288_fg_info *info) in fuel_gauge_battery_health() argument
328 int vocv = VOLTAGE_FROM_ADC(info->ocv); in fuel_gauge_battery_health()
331 if (vocv > info->max_volt) in fuel_gauge_battery_health()
343 struct axp288_fg_info *info = power_supply_get_drvdata(ps); in fuel_gauge_get_property() local
346 mutex_lock(&info->lock); in fuel_gauge_get_property()
348 ret = fuel_gauge_update_registers(info); in fuel_gauge_get_property()
354 fuel_gauge_get_status(info); in fuel_gauge_get_property()
355 val->intval = info->status; in fuel_gauge_get_property()
358 val->intval = fuel_gauge_battery_health(info); in fuel_gauge_get_property()
361 value = VOLTAGE_FROM_ADC(info->bat_volt); in fuel_gauge_get_property()
365 value = VOLTAGE_FROM_ADC(info->ocv); in fuel_gauge_get_property()
369 if (info->d_curr > 0) in fuel_gauge_get_property()
370 value = -1 * info->d_curr; in fuel_gauge_get_property()
372 value = info->c_curr; in fuel_gauge_get_property()
377 if (info->pwr_op & CHRG_STAT_BAT_PRESENT) in fuel_gauge_get_property()
383 if (!(info->fg_res & FG_REP_CAP_VALID)) in fuel_gauge_get_property()
384 dev_err(info->dev, "capacity measurement not valid\n"); in fuel_gauge_get_property()
385 val->intval = (info->fg_res & FG_REP_CAP_VAL_MASK); in fuel_gauge_get_property()
388 val->intval = (info->low_cap & 0x0f); in fuel_gauge_get_property()
394 val->intval = info->fg_cc_mtr1 * FG_DES_CAP_RES_LSB; in fuel_gauge_get_property()
397 val->intval = info->fg_des_cap1 * FG_DES_CAP_RES_LSB; in fuel_gauge_get_property()
400 val->intval = PROP_VOLT(info->max_volt); in fuel_gauge_get_property()
407 mutex_unlock(&info->lock); in fuel_gauge_get_property()
415 struct axp288_fg_info *info = power_supply_get_drvdata(ps); in fuel_gauge_set_property() local
418 mutex_lock(&info->lock); in fuel_gauge_set_property()
425 new_low_cap = info->low_cap; in fuel_gauge_set_property()
428 ret = fuel_gauge_reg_writeb(info, AXP288_FG_LOW_CAP_REG, new_low_cap); in fuel_gauge_set_property()
430 info->low_cap = new_low_cap; in fuel_gauge_set_property()
437 mutex_unlock(&info->lock); in fuel_gauge_set_property()
459 struct axp288_fg_info *info = dev; in fuel_gauge_thread_handler() local
463 if (info->irq[i] == irq) in fuel_gauge_thread_handler()
468 dev_warn(info->dev, "spurious interrupt!!\n"); in fuel_gauge_thread_handler()
474 dev_info(info->dev, "Quit Battery under temperature in work mode IRQ (QWBTU)\n"); in fuel_gauge_thread_handler()
477 dev_info(info->dev, "Battery under temperature in work mode IRQ (WBTU)\n"); in fuel_gauge_thread_handler()
480 dev_info(info->dev, "Quit Battery over temperature in work mode IRQ (QWBTO)\n"); in fuel_gauge_thread_handler()
483 dev_info(info->dev, "Battery over temperature in work mode IRQ (WBTO)\n"); in fuel_gauge_thread_handler()
486 dev_info(info->dev, "Low Batt Warning(2) INTR\n"); in fuel_gauge_thread_handler()
489 dev_info(info->dev, "Low Batt Warning(1) INTR\n"); in fuel_gauge_thread_handler()
492 dev_warn(info->dev, "Spurious Interrupt!!!\n"); in fuel_gauge_thread_handler()
495 mutex_lock(&info->lock); in fuel_gauge_thread_handler()
496 info->valid = 0; /* Force updating of the cached registers */ in fuel_gauge_thread_handler()
497 mutex_unlock(&info->lock); in fuel_gauge_thread_handler()
499 power_supply_changed(info->bat); in fuel_gauge_thread_handler()
505 struct axp288_fg_info *info = power_supply_get_drvdata(psy); in fuel_gauge_external_power_changed() local
507 mutex_lock(&info->lock); in fuel_gauge_external_power_changed()
508 info->valid = 0; /* Force updating of the cached registers */ in fuel_gauge_external_power_changed()
509 mutex_unlock(&info->lock); in fuel_gauge_external_power_changed()
618 static int axp288_fuel_gauge_read_initial_regs(struct axp288_fg_info *info) in axp288_fuel_gauge_read_initial_regs() argument
627 ret = regmap_read(info->regmap, AXP20X_CC_CTRL, &val); in axp288_fuel_gauge_read_initial_regs()
633 ret = fuel_gauge_reg_readb(info, AXP288_FG_DES_CAP1_REG); in axp288_fuel_gauge_read_initial_regs()
638 dev_err(info->dev, "axp288 not configured by firmware\n"); in axp288_fuel_gauge_read_initial_regs()
642 ret = fuel_gauge_reg_readb(info, AXP20X_CHRG_CTRL1); in axp288_fuel_gauge_read_initial_regs()
647 info->max_volt = 4100; in axp288_fuel_gauge_read_initial_regs()
650 info->max_volt = 4150; in axp288_fuel_gauge_read_initial_regs()
653 info->max_volt = 4200; in axp288_fuel_gauge_read_initial_regs()
656 info->max_volt = 4350; in axp288_fuel_gauge_read_initial_regs()
660 ret = fuel_gauge_reg_readb(info, AXP20X_PWR_OP_MODE); in axp288_fuel_gauge_read_initial_regs()
663 info->pwr_op = ret; in axp288_fuel_gauge_read_initial_regs()
665 ret = fuel_gauge_reg_readb(info, AXP288_FG_LOW_CAP_REG); in axp288_fuel_gauge_read_initial_regs()
668 info->low_cap = ret; in axp288_fuel_gauge_read_initial_regs()
675 struct axp288_fg_info *info = data; in axp288_fuel_gauge_release_iio_chans() local
679 if (!IS_ERR_OR_NULL(info->iio_channel[i])) in axp288_fuel_gauge_release_iio_chans()
680 iio_channel_release(info->iio_channel[i]); in axp288_fuel_gauge_release_iio_chans()
685 struct axp288_fg_info *info; in axp288_fuel_gauge_probe() local
712 info = devm_kzalloc(dev, sizeof(*info), GFP_KERNEL); in axp288_fuel_gauge_probe()
713 if (!info) in axp288_fuel_gauge_probe()
716 info->dev = dev; in axp288_fuel_gauge_probe()
717 info->regmap = axp20x->regmap; in axp288_fuel_gauge_probe()
718 info->status = POWER_SUPPLY_STATUS_UNKNOWN; in axp288_fuel_gauge_probe()
719 info->valid = 0; in axp288_fuel_gauge_probe()
721 platform_set_drvdata(pdev, info); in axp288_fuel_gauge_probe()
723 mutex_init(&info->lock); in axp288_fuel_gauge_probe()
733 info->irq[i] = ret; in axp288_fuel_gauge_probe()
742 info->iio_channel[i] = in axp288_fuel_gauge_probe()
744 if (IS_ERR(info->iio_channel[i])) { in axp288_fuel_gauge_probe()
745 ret = PTR_ERR(info->iio_channel[i]); in axp288_fuel_gauge_probe()
751 axp288_fuel_gauge_release_iio_chans(info); in axp288_fuel_gauge_probe()
756 ret = devm_add_action_or_reset(dev, axp288_fuel_gauge_release_iio_chans, info); in axp288_fuel_gauge_probe()
764 ret = axp288_fuel_gauge_read_initial_regs(info); in axp288_fuel_gauge_probe()
769 psy_cfg.drv_data = info; in axp288_fuel_gauge_probe()
772 info->bat = devm_power_supply_register(dev, &fuel_gauge_desc, &psy_cfg); in axp288_fuel_gauge_probe()
773 if (IS_ERR(info->bat)) { in axp288_fuel_gauge_probe()
774 ret = PTR_ERR(info->bat); in axp288_fuel_gauge_probe()
780 ret = devm_request_threaded_irq(dev, info->irq[i], NULL, in axp288_fuel_gauge_probe()
782 IRQF_ONESHOT, DEV_NAME, info); in axp288_fuel_gauge_probe()
784 return dev_err_probe(dev, ret, "requesting IRQ %d\n", info->irq[i]); in axp288_fuel_gauge_probe()