Lines Matching +full:- +full:39000
1 // SPDX-License-Identifier: GPL-2.0+
129 ret = regmap_read(info->regmap, UCS1002_REG_OTHER_STATUS, ®); in ucs1002_get_online()
133 val->intval = !!(reg & F_CHG_ACT); in ucs1002_get_online()
186 ret = regmap_bulk_read(info->regmap, UCS1002_REG_TOTAL_ACC_CHARGE, in ucs1002_get_charge()
192 val->intval = 0; in ucs1002_get_charge()
195 val->intval += bit_weights_uAh[i]; in ucs1002_get_charge()
209 9760, 19500, 39000, 78100, 156200, 312300, 624600, 1249300, in ucs1002_get_current()
215 ret = regmap_read(info->regmap, UCS1002_REG_CURRENT_MEASUREMENT, ®); in ucs1002_get_current()
220 val->intval = 0; in ucs1002_get_current()
223 val->intval += bit_weights_uA[i]; in ucs1002_get_current()
242 if (info->output_disable) { in ucs1002_get_max_current()
243 val->intval = 0; in ucs1002_get_max_current()
247 ret = regmap_read(info->regmap, UCS1002_REG_ILIMIT, ®); in ucs1002_get_max_current()
251 val->intval = ucs1002_current_limit_uA[reg & UCS1002_ILIM_SW_MASK]; in ucs1002_get_max_current()
262 info->output_disable = true; in ucs1002_set_max_current()
263 regulator_disable_regmap(info->rdev); in ucs1002_set_max_current()
273 return -EINVAL; in ucs1002_set_max_current()
275 ret = regmap_write(info->regmap, UCS1002_REG_ILIMIT, idx); in ucs1002_set_max_current()
283 ret = regmap_read(info->regmap, UCS1002_REG_ILIMIT, ®); in ucs1002_set_max_current()
288 return -EINVAL; in ucs1002_set_max_current()
290 info->output_disable = false; in ucs1002_set_max_current()
292 if (info->rdev && info->rdev->use_count && in ucs1002_set_max_current()
293 !regulator_is_enabled_regmap(info->rdev)) in ucs1002_set_max_current()
294 regulator_enable_regmap(info->rdev); in ucs1002_set_max_current()
312 return -EINVAL; in ucs1002_set_usb_type()
328 return -EINVAL; in ucs1002_set_usb_type()
331 return regmap_update_bits(info->regmap, UCS1002_REG_SWITCH_CFG, in ucs1002_set_usb_type()
342 ret = regmap_read(info->regmap, UCS1002_REG_PIN_STATUS, ®); in ucs1002_get_usb_type()
364 val->intval = type; in ucs1002_get_usb_type()
387 val->intval = info->health; in ucs1002_get_property()
390 val->intval = info->present; in ucs1002_get_property()
393 val->strval = UCS1002_MANUFACTURER; in ucs1002_get_property()
396 return -EINVAL; in ucs1002_get_property()
408 return ucs1002_set_max_current(info, val->intval); in ucs1002_set_property()
410 return ucs1002_set_usb_type(info, val->intval); in ucs1002_set_property()
412 return -EINVAL; in ucs1002_set_property()
447 ret = regmap_read(info->regmap, UCS1002_REG_INTERRUPT_STATUS, ®); in ucs1002_health_poll()
452 if ((reg & F_ERR) && info->health != POWER_SUPPLY_HEALTH_GOOD) { in ucs1002_health_poll()
453 schedule_delayed_work(&info->health_poll, in ucs1002_health_poll()
459 info->health = POWER_SUPPLY_HEALTH_OVERHEAT; in ucs1002_health_poll()
461 info->health = POWER_SUPPLY_HEALTH_OVERVOLTAGE; in ucs1002_health_poll()
463 info->health = POWER_SUPPLY_HEALTH_OVERCURRENT; in ucs1002_health_poll()
465 info->health = POWER_SUPPLY_HEALTH_UNSPEC_FAILURE; in ucs1002_health_poll()
467 info->health = POWER_SUPPLY_HEALTH_GOOD; in ucs1002_health_poll()
469 sysfs_notify(&info->charger->dev.kobj, NULL, "health"); in ucs1002_health_poll()
478 present = info->present; in ucs1002_charger_irq()
480 ret = regmap_read(info->regmap, UCS1002_REG_OTHER_STATUS, ®val); in ucs1002_charger_irq()
485 info->present = regval & F_ADET_PIN; in ucs1002_charger_irq()
488 if (present != info->present) in ucs1002_charger_irq()
489 power_supply_changed(info->charger); in ucs1002_charger_irq()
498 mod_delayed_work(system_wq, &info->health_poll, 0); in ucs1002_alert_irq()
510 * a non-zero maximum current budget. in ucs1002_regulator_enable()
512 if (info->output_disable) in ucs1002_regulator_enable()
525 .name = "ucs1002-vbus",
538 struct device *dev = &client->dev; in ucs1002_probe()
551 return -ENOMEM; in ucs1002_probe()
553 info->regmap = devm_regmap_init_i2c(client, ®map_config); in ucs1002_probe()
554 ret = PTR_ERR_OR_ZERO(info->regmap); in ucs1002_probe()
560 info->client = client; in ucs1002_probe()
562 irq_a_det = of_irq_get_byname(dev->of_node, "a_det"); in ucs1002_probe()
563 irq_alert = of_irq_get_byname(dev->of_node, "alert"); in ucs1002_probe()
565 charger_config.of_node = dev->of_node; in ucs1002_probe()
568 ret = regmap_read(info->regmap, UCS1002_REG_PRODUCT_ID, ®val); in ucs1002_probe()
578 return -ENODEV; in ucs1002_probe()
582 ret = regmap_update_bits(info->regmap, UCS1002_REG_GENERAL_CFG, in ucs1002_probe()
593 ret = regmap_update_bits(info->regmap, UCS1002_REG_SWITCH_CFG, in ucs1002_probe()
609 info->charger = devm_power_supply_register(dev, &ucs1002_charger_desc, in ucs1002_probe()
611 ret = PTR_ERR_OR_ZERO(info->charger); in ucs1002_probe()
617 ret = regmap_read(info->regmap, UCS1002_REG_PIN_STATUS, ®val); in ucs1002_probe()
623 info->regulator_descriptor = in ucs1002_probe()
627 if (!info->regulator_descriptor) in ucs1002_probe()
628 return -ENOMEM; in ucs1002_probe()
630 info->regulator_descriptor->enable_is_inverted = !(regval & F_SEL_PIN); in ucs1002_probe()
633 regulator_config.of_node = dev->of_node; in ucs1002_probe()
634 regulator_config.regmap = info->regmap; in ucs1002_probe()
637 info->rdev = devm_regulator_register(dev, info->regulator_descriptor, in ucs1002_probe()
639 ret = PTR_ERR_OR_ZERO(info->rdev); in ucs1002_probe()
645 info->health = POWER_SUPPLY_HEALTH_GOOD; in ucs1002_probe()
646 INIT_DELAYED_WORK(&info->health_poll, ucs1002_health_poll); in ucs1002_probe()
652 "ucs1002-a_det", info); in ucs1002_probe()
662 0,"ucs1002-alert", info); in ucs1002_probe()