Lines Matching +full:6 +full:bd
21 * b) pre-charge with constant current (6)
43 *(3)` `.`."" ` ` ` `+-------- ` ` ` ` ` ` `.:` ` ` ` ` ` ` ` ` .` ` (6)
175 static int bd9995x_get_prop_batt_health(struct bd9995x_device *bd) in bd9995x_get_prop_batt_health() argument
179 ret = regmap_field_read(bd->rmap_fields[F_BATTEMP], &tmp); in bd9995x_get_prop_batt_health()
202 static int bd9995x_get_prop_charge_type(struct bd9995x_device *bd) in bd9995x_get_prop_charge_type() argument
206 ret = regmap_field_read(bd->rmap_fields[F_CHGSTM_STATE], &tmp); in bd9995x_get_prop_charge_type()
225 static bool bd9995x_get_prop_batt_present(struct bd9995x_device *bd) in bd9995x_get_prop_batt_present() argument
229 ret = regmap_field_read(bd->rmap_fields[F_BATTEMP], &tmp); in bd9995x_get_prop_batt_present()
236 static int bd9995x_get_prop_batt_voltage(struct bd9995x_device *bd) in bd9995x_get_prop_batt_voltage() argument
240 ret = regmap_field_read(bd->rmap_fields[F_VBAT_VAL], &tmp); in bd9995x_get_prop_batt_voltage()
249 static int bd9995x_get_prop_batt_current(struct bd9995x_device *bd) in bd9995x_get_prop_batt_current() argument
253 ret = regmap_field_read(bd->rmap_fields[F_IBATP_VAL], &tmp); in bd9995x_get_prop_batt_current()
262 static int bd9995x_get_prop_batt_temp(struct bd9995x_device *bd) in bd9995x_get_prop_batt_temp() argument
266 ret = regmap_field_read(bd->rmap_fields[F_THERM_VAL], &tmp); in bd9995x_get_prop_batt_temp()
278 struct bd9995x_device *bd = power_supply_get_drvdata(psy); in bd9995x_power_supply_get_property() local
281 mutex_lock(&bd->lock); in bd9995x_power_supply_get_property()
282 state = bd->state; in bd9995x_power_supply_get_property()
283 mutex_unlock(&bd->lock); in bd9995x_power_supply_get_property()
333 ret = regmap_field_read(bd->rmap_fields[F_IBATP_VAL], &tmp); in bd9995x_power_supply_get_property()
340 ret = regmap_field_read(bd->rmap_fields[F_IBATP_AVE_VAL], &tmp); in bd9995x_power_supply_get_property()
359 ret = regmap_field_read(bd->rmap_fields[F_SEL_ILIM_VAL], &tmp); in bd9995x_power_supply_get_property()
371 ret = regmap_field_read(bd->rmap_fields[F_VFASTCHG_REG_SET1], in bd9995x_power_supply_get_property()
385 ret = regmap_field_read(bd->rmap_fields[F_ITERM_SET], &tmp); in bd9995x_power_supply_get_property()
389 val->intval = tmp << 6; in bd9995x_power_supply_get_property()
397 val->intval = bd9995x_get_prop_batt_present(bd); in bd9995x_power_supply_get_property()
401 val->intval = bd9995x_get_prop_batt_voltage(bd); in bd9995x_power_supply_get_property()
405 val->intval = bd9995x_get_prop_batt_current(bd); in bd9995x_power_supply_get_property()
409 val->intval = bd9995x_get_prop_charge_type(bd); in bd9995x_power_supply_get_property()
413 val->intval = bd9995x_get_prop_batt_health(bd); in bd9995x_power_supply_get_property()
417 val->intval = bd9995x_get_prop_batt_temp(bd); in bd9995x_power_supply_get_property()
436 static int bd9995x_get_chip_state(struct bd9995x_device *bd, in bd9995x_get_chip_state() argument
445 bd->rmap_fields[F_CHGSTM_STATE], &state->chgstm_status, in bd9995x_get_chip_state()
447 bd->rmap_fields[F_VBAT_VSYS_STATUS], in bd9995x_get_chip_state()
450 bd->rmap_fields[F_VBUS_VCC_STATUS], in bd9995x_get_chip_state()
475 struct bd9995x_device *bd = private; in bd9995x_irq_handler_thread() local
496 ret = regmap_read(bd->rmap, INT0_STATUS, &status); in bd9995x_irq_handler_thread()
498 dev_err(bd->dev, "Failed to read IRQ status\n"); in bd9995x_irq_handler_thread()
502 ret = regmap_field_read(bd->rmap_fields[F_INT0_SET], &mask); in bd9995x_irq_handler_thread()
504 dev_err(bd->dev, "Failed to read IRQ mask\n"); in bd9995x_irq_handler_thread()
518 ret = regmap_field_write(bd->rmap_fields[F_INT0_SET], 0); in bd9995x_irq_handler_thread()
520 dev_err(bd->dev, "Failed to mask F_INT0\n"); in bd9995x_irq_handler_thread()
524 ret = regmap_write(bd->rmap, INT0_STATUS, status); in bd9995x_irq_handler_thread()
526 dev_err(bd->dev, "Failed to ack F_INT0\n"); in bd9995x_irq_handler_thread()
537 bd->rmap_fields[F_INT1_SET], in bd9995x_irq_handler_thread()
538 bd->rmap_fields[F_INT2_SET], in bd9995x_irq_handler_thread()
539 bd->rmap_fields[F_INT3_SET], in bd9995x_irq_handler_thread()
540 bd->rmap_fields[F_INT4_SET], in bd9995x_irq_handler_thread()
541 bd->rmap_fields[F_INT5_SET], in bd9995x_irq_handler_thread()
542 bd->rmap_fields[F_INT6_SET], in bd9995x_irq_handler_thread()
543 bd->rmap_fields[F_INT7_SET], in bd9995x_irq_handler_thread()
547 ret = regmap_read(bd->rmap, sub_status_reg[i], &sub_status); in bd9995x_irq_handler_thread()
549 dev_err(bd->dev, "Failed to read IRQ sub-status\n"); in bd9995x_irq_handler_thread()
555 dev_err(bd->dev, "Failed to read IRQ sub-mask\n"); in bd9995x_irq_handler_thread()
562 ret = regmap_write(bd->rmap, sub_status_reg[i], sub_status); in bd9995x_irq_handler_thread()
564 dev_err(bd->dev, "Failed to ack sub-IRQ\n"); in bd9995x_irq_handler_thread()
569 ret = regmap_field_write(bd->rmap_fields[F_INT0_SET], mask); in bd9995x_irq_handler_thread()
575 ret = bd9995x_get_chip_state(bd, &state); in bd9995x_irq_handler_thread()
577 dev_err(bd->dev, "Failed to read chip state\n"); in bd9995x_irq_handler_thread()
579 mutex_lock(&bd->lock); in bd9995x_irq_handler_thread()
580 bd->state = state; in bd9995x_irq_handler_thread()
581 mutex_unlock(&bd->lock); in bd9995x_irq_handler_thread()
583 power_supply_changed(bd->charger); in bd9995x_irq_handler_thread()
589 ret = regmap_field_write(bd->rmap_fields[F_INT0_SET], mask); in bd9995x_irq_handler_thread()
591 dev_err(bd->dev, in bd9995x_irq_handler_thread()
597 static int __bd9995x_chip_reset(struct bd9995x_device *bd) in __bd9995x_chip_reset() argument
603 ret = regmap_raw_write(bd->rmap, SYSTEM_CTRL_SET, &tmp, 2); in __bd9995x_chip_reset()
608 ret = regmap_field_read(bd->rmap_fields[F_OTPLD_STATE], &state); in __bd9995x_chip_reset()
616 dev_err(bd->dev, "chip reset not completed\n"); in __bd9995x_chip_reset()
621 ret = regmap_raw_write(bd->rmap, SYSTEM_CTRL_SET, &tmp, 2); in __bd9995x_chip_reset()
626 static int bd9995x_hw_init(struct bd9995x_device *bd) in bd9995x_hw_init() argument
631 struct bd9995x_init_data *id = &bd->init_data; in bd9995x_hw_init()
700 ret = __bd9995x_chip_reset(bd); in bd9995x_hw_init()
706 ret = regmap_field_write(bd->rmap_fields[init_data[i].id], in bd9995x_hw_init()
709 dev_err(bd->dev, "failed to initialize charger (%d)\n", in bd9995x_hw_init()
715 ret = bd9995x_get_chip_state(bd, &state); in bd9995x_hw_init()
719 mutex_lock(&bd->lock); in bd9995x_hw_init()
720 bd->state = state; in bd9995x_hw_init()
721 mutex_unlock(&bd->lock); in bd9995x_hw_init()
817 static int bd9995x_fw_probe(struct bd9995x_device *bd) in bd9995x_fw_probe() argument
825 struct bd9995x_init_data *init = &bd->init_data; in bd9995x_fw_probe()
892 ret = power_supply_get_battery_info(bd->charger, &info); in bd9995x_fw_probe()
903 battery_inits[6].info_data = &info->constant_charge_current_max_ua; in bd9995x_fw_probe()
917 dev_err(bd->dev, "Unsupported value for %s\n", in bd9995x_fw_probe()
920 power_supply_put_battery_info(bd->charger, info); in bd9995x_fw_probe()
924 dev_warn(bd->dev, in bd9995x_fw_probe()
931 power_supply_put_battery_info(bd->charger, info); in bd9995x_fw_probe()
934 ret = device_property_read_u32(bd->dev, props[i].prop, in bd9995x_fw_probe()
937 dev_err(bd->dev, "failed to read %s", props[i].prop); in bd9995x_fw_probe()
947 dev_err(bd->dev, "Unsupported value for '%s'\n", in bd9995x_fw_probe()
954 dev_warn(bd->dev, in bd9995x_fw_probe()
965 static void bd9995x_chip_reset(void *bd) in bd9995x_chip_reset() argument
967 __bd9995x_chip_reset(bd); in bd9995x_chip_reset()
973 struct bd9995x_device *bd; in bd9995x_probe() local
978 bd = devm_kzalloc(dev, sizeof(*bd), GFP_KERNEL); in bd9995x_probe()
979 if (!bd) in bd9995x_probe()
982 bd->client = client; in bd9995x_probe()
983 bd->dev = dev; in bd9995x_probe()
984 psy_cfg.drv_data = bd; in bd9995x_probe()
987 mutex_init(&bd->lock); in bd9995x_probe()
989 bd->rmap = devm_regmap_init_i2c(client, &bd9995x_regmap_config); in bd9995x_probe()
990 if (IS_ERR(bd->rmap)) { in bd9995x_probe()
992 return PTR_ERR(bd->rmap); in bd9995x_probe()
998 bd->rmap_fields[i] = devm_regmap_field_alloc(dev, bd->rmap, in bd9995x_probe()
1000 if (IS_ERR(bd->rmap_fields[i])) { in bd9995x_probe()
1002 return PTR_ERR(bd->rmap_fields[i]); in bd9995x_probe()
1006 i2c_set_clientdata(client, bd); in bd9995x_probe()
1008 ret = regmap_field_read(bd->rmap_fields[F_CHIP_ID], &bd->chip_id); in bd9995x_probe()
1014 if (bd->chip_id != BD99954_ID) { in bd9995x_probe()
1016 bd->chip_id); in bd9995x_probe()
1020 ret = regmap_field_read(bd->rmap_fields[F_CHIP_REV], &bd->chip_rev); in bd9995x_probe()
1026 dev_info(bd->dev, "Found BD99954 chip rev %d\n", bd->chip_rev); in bd9995x_probe()
1032 bd->charger = devm_power_supply_register(bd->dev, in bd9995x_probe()
1035 if (IS_ERR(bd->charger)) { in bd9995x_probe()
1037 return PTR_ERR(bd->charger); in bd9995x_probe()
1040 ret = bd9995x_fw_probe(bd); in bd9995x_probe()
1046 ret = bd9995x_hw_init(bd); in bd9995x_probe()
1052 ret = devm_add_action_or_reset(dev, bd9995x_chip_reset, bd); in bd9995x_probe()
1059 BD9995X_IRQ_PIN, bd); in bd9995x_probe()