Lines Matching refs:bdi
240 static int bq24190_read(struct bq24190_dev_info *bdi, u8 reg, u8 *data) in bq24190_read() argument
244 ret = i2c_smbus_read_byte_data(bdi->client, reg); in bq24190_read()
252 static int bq24190_write(struct bq24190_dev_info *bdi, u8 reg, u8 data) in bq24190_write() argument
254 return i2c_smbus_write_byte_data(bdi->client, reg, data); in bq24190_write()
257 static int bq24190_read_mask(struct bq24190_dev_info *bdi, u8 reg, in bq24190_read_mask() argument
263 ret = bq24190_read(bdi, reg, &v); in bq24190_read_mask()
274 static int bq24190_write_mask(struct bq24190_dev_info *bdi, u8 reg, in bq24190_write_mask() argument
280 ret = bq24190_read(bdi, reg, &v); in bq24190_write_mask()
287 return bq24190_write(bdi, reg, v); in bq24190_write_mask()
290 static int bq24190_get_field_val(struct bq24190_dev_info *bdi, in bq24190_get_field_val() argument
298 ret = bq24190_read_mask(bdi, reg, mask, shift, &v); in bq24190_get_field_val()
308 static int bq24190_set_field_val(struct bq24190_dev_info *bdi, in bq24190_set_field_val() argument
317 return bq24190_write_mask(bdi, reg, mask, shift, idx); in bq24190_set_field_val()
438 struct bq24190_dev_info *bdi = power_supply_get_drvdata(psy); in bq24190_sysfs_show() local
448 ret = pm_runtime_get_sync(bdi->dev); in bq24190_sysfs_show()
450 pm_runtime_put_noidle(bdi->dev); in bq24190_sysfs_show()
454 ret = bq24190_read_mask(bdi, info->reg, info->mask, info->shift, &v); in bq24190_sysfs_show()
460 pm_runtime_mark_last_busy(bdi->dev); in bq24190_sysfs_show()
461 pm_runtime_put_autosuspend(bdi->dev); in bq24190_sysfs_show()
470 struct bq24190_dev_info *bdi = power_supply_get_drvdata(psy); in bq24190_sysfs_store() local
483 ret = pm_runtime_get_sync(bdi->dev); in bq24190_sysfs_store()
485 pm_runtime_put_noidle(bdi->dev); in bq24190_sysfs_store()
489 ret = bq24190_write_mask(bdi, info->reg, info->mask, info->shift, v); in bq24190_sysfs_store()
493 pm_runtime_mark_last_busy(bdi->dev); in bq24190_sysfs_store()
494 pm_runtime_put_autosuspend(bdi->dev); in bq24190_sysfs_store()
503 struct bq24190_dev_info *bdi = rdev_get_drvdata(dev); in bq24190_set_charge_mode() local
506 ret = pm_runtime_get_sync(bdi->dev); in bq24190_set_charge_mode()
508 dev_warn(bdi->dev, "pm_runtime_get failed: %i\n", ret); in bq24190_set_charge_mode()
509 pm_runtime_put_noidle(bdi->dev); in bq24190_set_charge_mode()
513 ret = bq24190_write_mask(bdi, BQ24190_REG_POC, in bq24190_set_charge_mode()
517 pm_runtime_mark_last_busy(bdi->dev); in bq24190_set_charge_mode()
518 pm_runtime_put_autosuspend(bdi->dev); in bq24190_set_charge_mode()
535 struct bq24190_dev_info *bdi = rdev_get_drvdata(dev); in bq24190_vbus_is_enabled() local
539 ret = pm_runtime_get_sync(bdi->dev); in bq24190_vbus_is_enabled()
541 dev_warn(bdi->dev, "pm_runtime_get failed: %i\n", ret); in bq24190_vbus_is_enabled()
542 pm_runtime_put_noidle(bdi->dev); in bq24190_vbus_is_enabled()
546 ret = bq24190_read_mask(bdi, BQ24190_REG_POC, in bq24190_vbus_is_enabled()
550 pm_runtime_mark_last_busy(bdi->dev); in bq24190_vbus_is_enabled()
551 pm_runtime_put_autosuspend(bdi->dev); in bq24190_vbus_is_enabled()
578 static int bq24190_register_vbus_regulator(struct bq24190_dev_info *bdi) in bq24190_register_vbus_regulator() argument
580 struct bq24190_platform_data *pdata = bdi->dev->platform_data; in bq24190_register_vbus_regulator()
585 cfg.dev = bdi->dev; in bq24190_register_vbus_regulator()
590 cfg.driver_data = bdi; in bq24190_register_vbus_regulator()
591 reg = devm_regulator_register(bdi->dev, &bq24190_vbus_desc, &cfg); in bq24190_register_vbus_regulator()
594 dev_err(bdi->dev, "Can't register regulator: %d\n", ret); in bq24190_register_vbus_regulator()
600 static int bq24190_register_vbus_regulator(struct bq24190_dev_info *bdi) in bq24190_register_vbus_regulator() argument
606 static int bq24190_set_config(struct bq24190_dev_info *bdi) in bq24190_set_config() argument
611 ret = bq24190_read(bdi, BQ24190_REG_CTTC, &v); in bq24190_set_config()
615 bdi->watchdog = ((v & BQ24190_REG_CTTC_WATCHDOG_MASK) >> in bq24190_set_config()
628 ret = bq24190_write(bdi, BQ24190_REG_CTTC, v); in bq24190_set_config()
632 if (bdi->sys_min) { in bq24190_set_config()
633 v = bdi->sys_min / 100 - 30; // manual section 9.5.1.2, table 9 in bq24190_set_config()
634 ret = bq24190_write_mask(bdi, BQ24190_REG_POC, in bq24190_set_config()
642 if (bdi->iprechg) { in bq24190_set_config()
643 v = bdi->iprechg / 128 - 1; // manual section 9.5.1.4, table 11 in bq24190_set_config()
644 ret = bq24190_write_mask(bdi, BQ24190_REG_PCTCC, in bq24190_set_config()
652 if (bdi->iterm) { in bq24190_set_config()
653 v = bdi->iterm / 128 - 1; // manual section 9.5.1.4, table 11 in bq24190_set_config()
654 ret = bq24190_write_mask(bdi, BQ24190_REG_PCTCC, in bq24190_set_config()
665 static int bq24190_register_reset(struct bq24190_dev_info *bdi) in bq24190_register_reset() argument
680 if (device_property_read_bool(bdi->dev, "disable-reset")) in bq24190_register_reset()
684 ret = bq24190_write_mask(bdi, BQ24190_REG_POC, in bq24190_register_reset()
693 ret = bq24190_read_mask(bdi, BQ24190_REG_POC, in bq24190_register_reset()
711 static int bq24190_charger_get_charge_type(struct bq24190_dev_info *bdi, in bq24190_charger_get_charge_type() argument
717 ret = bq24190_read_mask(bdi, BQ24190_REG_POC, in bq24190_charger_get_charge_type()
728 ret = bq24190_read_mask(bdi, BQ24190_REG_CCC, in bq24190_charger_get_charge_type()
744 static int bq24190_charger_set_charge_type(struct bq24190_dev_info *bdi, in bq24190_charger_set_charge_type() argument
779 ret = bq24190_write_mask(bdi, BQ24190_REG_CCC, in bq24190_charger_set_charge_type()
786 ret = bq24190_write_mask(bdi, BQ24190_REG_CTTC, in bq24190_charger_set_charge_type()
794 return bq24190_write_mask(bdi, BQ24190_REG_POC, in bq24190_charger_set_charge_type()
799 static int bq24190_charger_get_health(struct bq24190_dev_info *bdi, in bq24190_charger_get_health() argument
805 mutex_lock(&bdi->f_reg_lock); in bq24190_charger_get_health()
806 v = bdi->f_reg; in bq24190_charger_get_health()
807 mutex_unlock(&bdi->f_reg_lock); in bq24190_charger_get_health()
864 static int bq24190_charger_get_online(struct bq24190_dev_info *bdi, in bq24190_charger_get_online() argument
870 ret = bq24190_read_mask(bdi, BQ24190_REG_SS, in bq24190_charger_get_online()
876 ret = bq24190_read_mask(bdi, BQ24190_REG_MOC, in bq24190_charger_get_online()
887 static int bq24190_battery_set_online(struct bq24190_dev_info *bdi,
889 static int bq24190_battery_get_status(struct bq24190_dev_info *bdi,
891 static int bq24190_battery_get_temp_alert_max(struct bq24190_dev_info *bdi,
893 static int bq24190_battery_set_temp_alert_max(struct bq24190_dev_info *bdi,
896 static int bq24190_charger_set_online(struct bq24190_dev_info *bdi, in bq24190_charger_set_online() argument
899 return bq24190_battery_set_online(bdi, val); in bq24190_charger_set_online()
902 static int bq24190_charger_get_status(struct bq24190_dev_info *bdi, in bq24190_charger_get_status() argument
905 return bq24190_battery_get_status(bdi, val); in bq24190_charger_get_status()
908 static int bq24190_charger_get_temp_alert_max(struct bq24190_dev_info *bdi, in bq24190_charger_get_temp_alert_max() argument
911 return bq24190_battery_get_temp_alert_max(bdi, val); in bq24190_charger_get_temp_alert_max()
914 static int bq24190_charger_set_temp_alert_max(struct bq24190_dev_info *bdi, in bq24190_charger_set_temp_alert_max() argument
917 return bq24190_battery_set_temp_alert_max(bdi, val); in bq24190_charger_set_temp_alert_max()
920 static int bq24190_charger_get_precharge(struct bq24190_dev_info *bdi, in bq24190_charger_get_precharge() argument
926 ret = bq24190_read_mask(bdi, BQ24190_REG_PCTCC, in bq24190_charger_get_precharge()
936 static int bq24190_charger_get_charge_term(struct bq24190_dev_info *bdi, in bq24190_charger_get_charge_term() argument
942 ret = bq24190_read_mask(bdi, BQ24190_REG_PCTCC, in bq24190_charger_get_charge_term()
952 static int bq24190_charger_get_current(struct bq24190_dev_info *bdi, in bq24190_charger_get_current() argument
958 ret = bq24190_get_field_val(bdi, BQ24190_REG_CCC, in bq24190_charger_get_current()
965 ret = bq24190_read_mask(bdi, BQ24190_REG_CCC, in bq24190_charger_get_current()
979 static int bq24190_charger_get_current_max(struct bq24190_dev_info *bdi, in bq24190_charger_get_current_max() argument
988 static int bq24190_charger_set_current(struct bq24190_dev_info *bdi, in bq24190_charger_set_current() argument
994 ret = bq24190_read_mask(bdi, BQ24190_REG_CCC, in bq24190_charger_set_current()
1004 return bq24190_set_field_val(bdi, BQ24190_REG_CCC, in bq24190_charger_set_current()
1010 static int bq24190_charger_get_voltage(struct bq24190_dev_info *bdi, in bq24190_charger_get_voltage() argument
1015 ret = bq24190_get_field_val(bdi, BQ24190_REG_CVC, in bq24190_charger_get_voltage()
1026 static int bq24190_charger_get_voltage_max(struct bq24190_dev_info *bdi, in bq24190_charger_get_voltage_max() argument
1035 static int bq24190_charger_set_voltage(struct bq24190_dev_info *bdi, in bq24190_charger_set_voltage() argument
1038 return bq24190_set_field_val(bdi, BQ24190_REG_CVC, in bq24190_charger_set_voltage()
1044 static int bq24190_charger_get_iinlimit(struct bq24190_dev_info *bdi, in bq24190_charger_get_iinlimit() argument
1049 ret = bq24190_get_field_val(bdi, BQ24190_REG_ISC, in bq24190_charger_get_iinlimit()
1061 static int bq24190_charger_set_iinlimit(struct bq24190_dev_info *bdi, in bq24190_charger_set_iinlimit() argument
1064 return bq24190_set_field_val(bdi, BQ24190_REG_ISC, in bq24190_charger_set_iinlimit()
1074 struct bq24190_dev_info *bdi = power_supply_get_drvdata(psy); in bq24190_charger_get_property() local
1077 dev_dbg(bdi->dev, "prop: %d\n", psp); in bq24190_charger_get_property()
1079 ret = pm_runtime_get_sync(bdi->dev); in bq24190_charger_get_property()
1081 pm_runtime_put_noidle(bdi->dev); in bq24190_charger_get_property()
1087 ret = bq24190_charger_get_charge_type(bdi, val); in bq24190_charger_get_property()
1090 ret = bq24190_charger_get_health(bdi, val); in bq24190_charger_get_property()
1093 ret = bq24190_charger_get_online(bdi, val); in bq24190_charger_get_property()
1096 ret = bq24190_charger_get_status(bdi, val); in bq24190_charger_get_property()
1099 ret = bq24190_charger_get_temp_alert_max(bdi, val); in bq24190_charger_get_property()
1102 ret = bq24190_charger_get_precharge(bdi, val); in bq24190_charger_get_property()
1105 ret = bq24190_charger_get_charge_term(bdi, val); in bq24190_charger_get_property()
1108 ret = bq24190_charger_get_current(bdi, val); in bq24190_charger_get_property()
1111 ret = bq24190_charger_get_current_max(bdi, val); in bq24190_charger_get_property()
1114 ret = bq24190_charger_get_voltage(bdi, val); in bq24190_charger_get_property()
1117 ret = bq24190_charger_get_voltage_max(bdi, val); in bq24190_charger_get_property()
1120 ret = bq24190_charger_get_iinlimit(bdi, val); in bq24190_charger_get_property()
1127 val->strval = bdi->model_name; in bq24190_charger_get_property()
1138 pm_runtime_mark_last_busy(bdi->dev); in bq24190_charger_get_property()
1139 pm_runtime_put_autosuspend(bdi->dev); in bq24190_charger_get_property()
1148 struct bq24190_dev_info *bdi = power_supply_get_drvdata(psy); in bq24190_charger_set_property() local
1151 dev_dbg(bdi->dev, "prop: %d\n", psp); in bq24190_charger_set_property()
1153 ret = pm_runtime_get_sync(bdi->dev); in bq24190_charger_set_property()
1155 pm_runtime_put_noidle(bdi->dev); in bq24190_charger_set_property()
1161 ret = bq24190_charger_set_online(bdi, val); in bq24190_charger_set_property()
1164 ret = bq24190_charger_set_temp_alert_max(bdi, val); in bq24190_charger_set_property()
1167 ret = bq24190_charger_set_charge_type(bdi, val); in bq24190_charger_set_property()
1170 ret = bq24190_charger_set_current(bdi, val); in bq24190_charger_set_property()
1173 ret = bq24190_charger_set_voltage(bdi, val); in bq24190_charger_set_property()
1176 ret = bq24190_charger_set_iinlimit(bdi, val); in bq24190_charger_set_property()
1182 pm_runtime_mark_last_busy(bdi->dev); in bq24190_charger_set_property()
1183 pm_runtime_put_autosuspend(bdi->dev); in bq24190_charger_set_property()
1206 struct bq24190_dev_info *bdi = in bq24190_input_current_limit_work() local
1210 power_supply_set_input_current_limit_from_supplier(bdi->charger); in bq24190_input_current_limit_work()
1216 struct bq24190_dev_info *bdi = power_supply_get_drvdata(psy); in bq24190_charger_external_power_changed() local
1226 queue_delayed_work(system_wq, &bdi->input_current_limit_work, in bq24190_charger_external_power_changed()
1265 static int bq24190_battery_get_status(struct bq24190_dev_info *bdi, in bq24190_battery_get_status() argument
1271 mutex_lock(&bdi->f_reg_lock); in bq24190_battery_get_status()
1272 chrg_fault = bdi->f_reg; in bq24190_battery_get_status()
1273 mutex_unlock(&bdi->f_reg_lock); in bq24190_battery_get_status()
1278 ret = bq24190_read(bdi, BQ24190_REG_SS, &ss_reg); in bq24190_battery_get_status()
1317 static int bq24190_battery_get_health(struct bq24190_dev_info *bdi, in bq24190_battery_get_health() argument
1323 mutex_lock(&bdi->f_reg_lock); in bq24190_battery_get_health()
1324 v = bdi->f_reg; in bq24190_battery_get_health()
1325 mutex_unlock(&bdi->f_reg_lock); in bq24190_battery_get_health()
1356 static int bq24190_battery_get_online(struct bq24190_dev_info *bdi, in bq24190_battery_get_online() argument
1362 ret = bq24190_read_mask(bdi, BQ24190_REG_MOC, in bq24190_battery_get_online()
1372 static int bq24190_battery_set_online(struct bq24190_dev_info *bdi, in bq24190_battery_set_online() argument
1375 return bq24190_write_mask(bdi, BQ24190_REG_MOC, in bq24190_battery_set_online()
1380 static int bq24190_battery_get_temp_alert_max(struct bq24190_dev_info *bdi, in bq24190_battery_get_temp_alert_max() argument
1385 ret = bq24190_get_field_val(bdi, BQ24190_REG_ICTRC, in bq24190_battery_get_temp_alert_max()
1397 static int bq24190_battery_set_temp_alert_max(struct bq24190_dev_info *bdi, in bq24190_battery_set_temp_alert_max() argument
1400 return bq24190_set_field_val(bdi, BQ24190_REG_ICTRC, in bq24190_battery_set_temp_alert_max()
1410 struct bq24190_dev_info *bdi = power_supply_get_drvdata(psy); in bq24190_battery_get_property() local
1413 dev_warn(bdi->dev, "warning: /sys/class/power_supply/bq24190-battery is deprecated\n"); in bq24190_battery_get_property()
1414 dev_dbg(bdi->dev, "prop: %d\n", psp); in bq24190_battery_get_property()
1416 ret = pm_runtime_get_sync(bdi->dev); in bq24190_battery_get_property()
1418 pm_runtime_put_noidle(bdi->dev); in bq24190_battery_get_property()
1424 ret = bq24190_battery_get_status(bdi, val); in bq24190_battery_get_property()
1427 ret = bq24190_battery_get_health(bdi, val); in bq24190_battery_get_property()
1430 ret = bq24190_battery_get_online(bdi, val); in bq24190_battery_get_property()
1438 ret = bq24190_battery_get_temp_alert_max(bdi, val); in bq24190_battery_get_property()
1448 pm_runtime_mark_last_busy(bdi->dev); in bq24190_battery_get_property()
1449 pm_runtime_put_autosuspend(bdi->dev); in bq24190_battery_get_property()
1458 struct bq24190_dev_info *bdi = power_supply_get_drvdata(psy); in bq24190_battery_set_property() local
1461 dev_warn(bdi->dev, "warning: /sys/class/power_supply/bq24190-battery is deprecated\n"); in bq24190_battery_set_property()
1462 dev_dbg(bdi->dev, "prop: %d\n", psp); in bq24190_battery_set_property()
1464 ret = pm_runtime_get_sync(bdi->dev); in bq24190_battery_set_property()
1466 pm_runtime_put_noidle(bdi->dev); in bq24190_battery_set_property()
1472 ret = bq24190_battery_set_online(bdi, val); in bq24190_battery_set_property()
1475 ret = bq24190_battery_set_temp_alert_max(bdi, val); in bq24190_battery_set_property()
1481 pm_runtime_mark_last_busy(bdi->dev); in bq24190_battery_set_property()
1482 pm_runtime_put_autosuspend(bdi->dev); in bq24190_battery_set_property()
1523 static int bq24190_configure_usb_otg(struct bq24190_dev_info *bdi, u8 ss_reg) in bq24190_configure_usb_otg() argument
1529 ret = extcon_set_state_sync(bdi->edev, EXTCON_USB, otg_enabled); in bq24190_configure_usb_otg()
1531 dev_err(bdi->dev, "Can't set extcon state to %d: %d\n", in bq24190_configure_usb_otg()
1537 static void bq24190_check_status(struct bq24190_dev_info *bdi) in bq24190_check_status() argument
1546 ret = bq24190_read(bdi, BQ24190_REG_SS, &ss_reg); in bq24190_check_status()
1548 dev_err(bdi->dev, "Can't read SS reg: %d\n", ret); in bq24190_check_status()
1554 ret = bq24190_read(bdi, BQ24190_REG_F, &f_reg); in bq24190_check_status()
1556 dev_err(bdi->dev, "Can't read F reg: %d\n", ret); in bq24190_check_status()
1566 if (f_reg != bdi->f_reg) { in bq24190_check_status()
1567 dev_warn(bdi->dev, in bq24190_check_status()
1574 mutex_lock(&bdi->f_reg_lock); in bq24190_check_status()
1575 if ((bdi->f_reg & battery_mask_f) != (f_reg & battery_mask_f)) in bq24190_check_status()
1577 if ((bdi->f_reg & ~battery_mask_f) != (f_reg & ~battery_mask_f)) in bq24190_check_status()
1579 bdi->f_reg = f_reg; in bq24190_check_status()
1580 mutex_unlock(&bdi->f_reg_lock); in bq24190_check_status()
1583 if (ss_reg != bdi->ss_reg) { in bq24190_check_status()
1588 if ((bdi->ss_reg & BQ24190_REG_SS_PG_STAT_MASK) && in bq24190_check_status()
1590 ret = bq24190_write_mask(bdi, BQ24190_REG_ISC, in bq24190_check_status()
1595 dev_err(bdi->dev, "Can't access ISC reg: %d\n", in bq24190_check_status()
1599 if ((bdi->ss_reg & battery_mask_ss) != (ss_reg & battery_mask_ss)) in bq24190_check_status()
1601 if ((bdi->ss_reg & ~battery_mask_ss) != (ss_reg & ~battery_mask_ss)) in bq24190_check_status()
1603 bdi->ss_reg = ss_reg; in bq24190_check_status()
1607 power_supply_changed(bdi->charger); in bq24190_check_status()
1608 bq24190_configure_usb_otg(bdi, ss_reg); in bq24190_check_status()
1610 if (alert_battery && bdi->battery) in bq24190_check_status()
1611 power_supply_changed(bdi->battery); in bq24190_check_status()
1613 dev_dbg(bdi->dev, "ss_reg: 0x%02x, f_reg: 0x%02x\n", ss_reg, f_reg); in bq24190_check_status()
1618 struct bq24190_dev_info *bdi = data; in bq24190_irq_handler_thread() local
1621 bdi->irq_event = true; in bq24190_irq_handler_thread()
1622 error = pm_runtime_get_sync(bdi->dev); in bq24190_irq_handler_thread()
1624 dev_warn(bdi->dev, "pm_runtime_get failed: %i\n", error); in bq24190_irq_handler_thread()
1625 pm_runtime_put_noidle(bdi->dev); in bq24190_irq_handler_thread()
1628 bq24190_check_status(bdi); in bq24190_irq_handler_thread()
1629 pm_runtime_mark_last_busy(bdi->dev); in bq24190_irq_handler_thread()
1630 pm_runtime_put_autosuspend(bdi->dev); in bq24190_irq_handler_thread()
1631 bdi->irq_event = false; in bq24190_irq_handler_thread()
1636 static int bq24190_hw_init(struct bq24190_dev_info *bdi) in bq24190_hw_init() argument
1642 ret = bq24190_read_mask(bdi, BQ24190_REG_VPRS, in bq24190_hw_init()
1655 dev_err(bdi->dev, "Error unknown model: 0x%02x\n", v); in bq24190_hw_init()
1659 ret = bq24190_register_reset(bdi); in bq24190_hw_init()
1663 ret = bq24190_set_config(bdi); in bq24190_hw_init()
1667 return bq24190_read(bdi, BQ24190_REG_SS, &bdi->ss_reg); in bq24190_hw_init()
1670 static int bq24190_get_config(struct bq24190_dev_info *bdi) in bq24190_get_config() argument
1676 if (device_property_read_u32(bdi->dev, s, &v) == 0) { in bq24190_get_config()
1680 bdi->sys_min = v; in bq24190_get_config()
1682 dev_warn(bdi->dev, "invalid value for %s: %u\n", s, v); in bq24190_get_config()
1685 if (bdi->dev->of_node && in bq24190_get_config()
1686 !power_supply_get_battery_info(bdi->charger, &info)) { in bq24190_get_config()
1690 bdi->iprechg = v; in bq24190_get_config()
1692 dev_warn(bdi->dev, "invalid value for battery:precharge-current-microamp: %d\n", in bq24190_get_config()
1698 bdi->iterm = v; in bq24190_get_config()
1700 dev_warn(bdi->dev, "invalid value for battery:charge-term-current-microamp: %d\n", in bq24190_get_config()
1713 struct bq24190_dev_info *bdi; in bq24190_probe() local
1721 bdi = devm_kzalloc(dev, sizeof(*bdi), GFP_KERNEL); in bq24190_probe()
1722 if (!bdi) { in bq24190_probe()
1727 bdi->client = client; in bq24190_probe()
1728 bdi->dev = dev; in bq24190_probe()
1729 strncpy(bdi->model_name, id->name, I2C_NAME_SIZE); in bq24190_probe()
1730 mutex_init(&bdi->f_reg_lock); in bq24190_probe()
1731 bdi->f_reg = 0; in bq24190_probe()
1732 bdi->ss_reg = BQ24190_REG_SS_VBUS_STAT_MASK; /* impossible state */ in bq24190_probe()
1733 INIT_DELAYED_WORK(&bdi->input_current_limit_work, in bq24190_probe()
1736 i2c_set_clientdata(client, bdi); in bq24190_probe()
1743 bdi->edev = devm_extcon_dev_allocate(dev, bq24190_usb_extcon_cable); in bq24190_probe()
1744 if (IS_ERR(bdi->edev)) in bq24190_probe()
1745 return PTR_ERR(bdi->edev); in bq24190_probe()
1747 ret = devm_extcon_dev_register(dev, bdi->edev); in bq24190_probe()
1765 charger_cfg.drv_data = bdi; in bq24190_probe()
1769 bdi->charger = power_supply_register(dev, &bq24190_charger_desc, in bq24190_probe()
1771 if (IS_ERR(bdi->charger)) { in bq24190_probe()
1773 ret = PTR_ERR(bdi->charger); in bq24190_probe()
1780 battery_cfg.drv_data = bdi; in bq24190_probe()
1781 bdi->battery = power_supply_register(dev, &bq24190_battery_desc, in bq24190_probe()
1783 if (IS_ERR(bdi->battery)) { in bq24190_probe()
1785 ret = PTR_ERR(bdi->battery); in bq24190_probe()
1790 ret = bq24190_get_config(bdi); in bq24190_probe()
1796 ret = bq24190_hw_init(bdi); in bq24190_probe()
1802 ret = bq24190_configure_usb_otg(bdi, bdi->ss_reg); in bq24190_probe()
1806 bdi->initialized = true; in bq24190_probe()
1811 "bq24190-charger", bdi); in bq24190_probe()
1817 ret = bq24190_register_vbus_regulator(bdi); in bq24190_probe()
1829 if (!IS_ERR_OR_NULL(bdi->battery)) in bq24190_probe()
1830 power_supply_unregister(bdi->battery); in bq24190_probe()
1831 power_supply_unregister(bdi->charger); in bq24190_probe()
1842 struct bq24190_dev_info *bdi = i2c_get_clientdata(client); in bq24190_remove() local
1845 error = pm_runtime_get_sync(bdi->dev); in bq24190_remove()
1847 dev_warn(bdi->dev, "pm_runtime_get failed: %i\n", error); in bq24190_remove()
1848 pm_runtime_put_noidle(bdi->dev); in bq24190_remove()
1851 bq24190_register_reset(bdi); in bq24190_remove()
1852 if (bdi->battery) in bq24190_remove()
1853 power_supply_unregister(bdi->battery); in bq24190_remove()
1854 power_supply_unregister(bdi->charger); in bq24190_remove()
1856 pm_runtime_put_sync(bdi->dev); in bq24190_remove()
1857 pm_runtime_dont_use_autosuspend(bdi->dev); in bq24190_remove()
1858 pm_runtime_disable(bdi->dev); in bq24190_remove()
1866 struct bq24190_dev_info *bdi = i2c_get_clientdata(client); in bq24190_runtime_suspend() local
1868 if (!bdi->initialized) in bq24190_runtime_suspend()
1871 dev_dbg(bdi->dev, "%s\n", __func__); in bq24190_runtime_suspend()
1879 struct bq24190_dev_info *bdi = i2c_get_clientdata(client); in bq24190_runtime_resume() local
1881 if (!bdi->initialized) in bq24190_runtime_resume()
1884 if (!bdi->irq_event) { in bq24190_runtime_resume()
1885 dev_dbg(bdi->dev, "checking events on possible wakeirq\n"); in bq24190_runtime_resume()
1886 bq24190_check_status(bdi); in bq24190_runtime_resume()
1895 struct bq24190_dev_info *bdi = i2c_get_clientdata(client); in bq24190_pm_suspend() local
1898 error = pm_runtime_get_sync(bdi->dev); in bq24190_pm_suspend()
1900 dev_warn(bdi->dev, "pm_runtime_get failed: %i\n", error); in bq24190_pm_suspend()
1901 pm_runtime_put_noidle(bdi->dev); in bq24190_pm_suspend()
1904 bq24190_register_reset(bdi); in bq24190_pm_suspend()
1907 pm_runtime_mark_last_busy(bdi->dev); in bq24190_pm_suspend()
1908 pm_runtime_put_autosuspend(bdi->dev); in bq24190_pm_suspend()
1917 struct bq24190_dev_info *bdi = i2c_get_clientdata(client); in bq24190_pm_resume() local
1920 bdi->f_reg = 0; in bq24190_pm_resume()
1921 bdi->ss_reg = BQ24190_REG_SS_VBUS_STAT_MASK; /* impossible state */ in bq24190_pm_resume()
1923 error = pm_runtime_get_sync(bdi->dev); in bq24190_pm_resume()
1925 dev_warn(bdi->dev, "pm_runtime_get failed: %i\n", error); in bq24190_pm_resume()
1926 pm_runtime_put_noidle(bdi->dev); in bq24190_pm_resume()
1929 bq24190_register_reset(bdi); in bq24190_pm_resume()
1930 bq24190_set_config(bdi); in bq24190_pm_resume()
1931 bq24190_read(bdi, BQ24190_REG_SS, &bdi->ss_reg); in bq24190_pm_resume()
1934 pm_runtime_mark_last_busy(bdi->dev); in bq24190_pm_resume()
1935 pm_runtime_put_autosuspend(bdi->dev); in bq24190_pm_resume()
1939 power_supply_changed(bdi->charger); in bq24190_pm_resume()
1940 if (bdi->battery) in bq24190_pm_resume()
1941 power_supply_changed(bdi->battery); in bq24190_pm_resume()