Lines Matching +full:ilim +full:- +full:ma
1 // SPDX-License-Identifier: GPL-2.0+
30 * weighting of the registers is given in mA/hrs.
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()
147 * B0: 0.01084 mA/h rounded to 11 uA/h in ucs1002_get_charge()
148 * B1: 0.02169 mA/h rounded to 22 uA/h in ucs1002_get_charge()
149 * B2: 0.04340 mA/h rounded to 43 uA/h in ucs1002_get_charge()
150 * B3: 0.08676 mA/h rounded to 87 uA/h in ucs1002_get_charge()
151 * B4: 0.17350 mA/h rounded to 173 uÁ/h in ucs1002_get_charge()
156 * B6: 0.00271 mA/h rounded to 3 uA/h in ucs1002_get_charge()
157 * B7: 0.005422 mA/h rounded to 5 uA/h in ucs1002_get_charge()
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()
206 * is from 9.76 mA to 2.5 A. 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()
230 * port switch. The range is from 500mA to 2.5 A.
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()
279 * Any current limit setting exceeding the one set via ILIM 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()
323 return -EINVAL; in ucs1002_set_usb_type()
326 return regmap_update_bits(info->regmap, UCS1002_REG_SWITCH_CFG, in ucs1002_set_usb_type()
337 ret = regmap_read(info->regmap, UCS1002_REG_PIN_STATUS, ®); in ucs1002_get_usb_type()
359 val->intval = type; in ucs1002_get_usb_type()
382 val->intval = info->health; in ucs1002_get_property()
385 val->intval = info->present; in ucs1002_get_property()
388 val->strval = UCS1002_MANUFACTURER; in ucs1002_get_property()
391 return -EINVAL; in ucs1002_get_property()
403 return ucs1002_set_max_current(info, val->intval); in ucs1002_set_property()
405 return ucs1002_set_usb_type(info, val->intval); in ucs1002_set_property()
407 return -EINVAL; in ucs1002_set_property()
445 ret = regmap_read(info->regmap, UCS1002_REG_INTERRUPT_STATUS, ®); in ucs1002_health_poll()
450 if ((reg & F_ERR) && info->health != POWER_SUPPLY_HEALTH_GOOD) { in ucs1002_health_poll()
451 schedule_delayed_work(&info->health_poll, in ucs1002_health_poll()
457 info->health = POWER_SUPPLY_HEALTH_OVERHEAT; in ucs1002_health_poll()
459 info->health = POWER_SUPPLY_HEALTH_OVERVOLTAGE; in ucs1002_health_poll()
461 info->health = POWER_SUPPLY_HEALTH_OVERCURRENT; in ucs1002_health_poll()
463 info->health = POWER_SUPPLY_HEALTH_UNSPEC_FAILURE; in ucs1002_health_poll()
465 info->health = POWER_SUPPLY_HEALTH_GOOD; in ucs1002_health_poll()
467 sysfs_notify(&info->charger->dev.kobj, NULL, "health"); in ucs1002_health_poll()
476 present = info->present; in ucs1002_charger_irq()
478 ret = regmap_read(info->regmap, UCS1002_REG_OTHER_STATUS, ®val); in ucs1002_charger_irq()
483 info->present = regval & F_ADET_PIN; in ucs1002_charger_irq()
486 if (present != info->present) in ucs1002_charger_irq()
487 power_supply_changed(info->charger); in ucs1002_charger_irq()
496 mod_delayed_work(system_wq, &info->health_poll, 0); in ucs1002_alert_irq()
508 * a non-zero maximum current budget. in ucs1002_regulator_enable()
510 if (info->output_disable) in ucs1002_regulator_enable()
523 .name = "ucs1002-vbus",
536 struct device *dev = &client->dev; in ucs1002_probe()
549 return -ENOMEM; in ucs1002_probe()
551 info->regmap = devm_regmap_init_i2c(client, ®map_config); in ucs1002_probe()
552 ret = PTR_ERR_OR_ZERO(info->regmap); in ucs1002_probe()
558 info->client = client; in ucs1002_probe()
560 irq_a_det = of_irq_get_byname(dev->of_node, "a_det"); in ucs1002_probe()
561 irq_alert = of_irq_get_byname(dev->of_node, "alert"); in ucs1002_probe()
563 charger_config.of_node = dev->of_node; in ucs1002_probe()
566 ret = regmap_read(info->regmap, UCS1002_REG_PRODUCT_ID, ®val); in ucs1002_probe()
576 return -ENODEV; in ucs1002_probe()
580 ret = regmap_update_bits(info->regmap, UCS1002_REG_GENERAL_CFG, in ucs1002_probe()
591 ret = regmap_update_bits(info->regmap, UCS1002_REG_SWITCH_CFG, in ucs1002_probe()
599 * Be safe and set initial current limit to 500mA in ucs1002_probe()
607 info->charger = devm_power_supply_register(dev, &ucs1002_charger_desc, in ucs1002_probe()
609 ret = PTR_ERR_OR_ZERO(info->charger); in ucs1002_probe()
615 ret = regmap_read(info->regmap, UCS1002_REG_PIN_STATUS, ®val); in ucs1002_probe()
621 info->regulator_descriptor = in ucs1002_probe()
625 if (!info->regulator_descriptor) in ucs1002_probe()
626 return -ENOMEM; in ucs1002_probe()
628 info->regulator_descriptor->enable_is_inverted = !(regval & F_SEL_PIN); in ucs1002_probe()
631 regulator_config.of_node = dev->of_node; in ucs1002_probe()
632 regulator_config.regmap = info->regmap; in ucs1002_probe()
635 info->rdev = devm_regulator_register(dev, info->regulator_descriptor, in ucs1002_probe()
637 ret = PTR_ERR_OR_ZERO(info->rdev); in ucs1002_probe()
643 info->health = POWER_SUPPLY_HEALTH_GOOD; in ucs1002_probe()
644 INIT_DELAYED_WORK(&info->health_poll, ucs1002_health_poll); in ucs1002_probe()
650 "ucs1002-a_det", info); in ucs1002_probe()
660 0,"ucs1002-alert", info); in ucs1002_probe()