Lines Matching +full:milli +full:- +full:ohm

1 // SPDX-License-Identifier: GPL-2.0-only
3 * I2C client/driver for the Maxim/Dallas DS2782 Stand-Alone Fuel Gauge IC
35 /* Current unit measurement in uA for a 1 milli-ohm sense resistor */
73 ret = i2c_smbus_read_byte_data(info->client, reg); in ds278x_read_reg()
75 dev_err(&info->client->dev, "register read failed\n"); in ds278x_read_reg()
88 ret = i2c_smbus_read_word_data(info->client, reg_msb); in ds278x_read_reg16()
90 dev_err(&info->client->dev, "register read failed\n"); in ds278x_read_reg16()
131 dev_err(&info->client->dev, "sense resistor value is 0\n"); in ds2782_get_current()
132 return -ENXIO; in ds2782_get_current()
136 dev_dbg(&info->client->dev, "sense resistor = %d milli-ohms\n", in ds2782_get_current()
152 * a 10-bit number plus sign, in the upper bits of a 16-bit register in ds2782_get_voltage()
181 *current_uA = (raw / 16) * (DS2786_CURRENT_UNITS / info->rsns); in ds2786_get_current()
192 * a 12-bit number plus sign, in the upper bits of a 16-bit register in ds2786_get_voltage()
220 err = info->ops->get_battery_current(info, &current_uA); in ds278x_get_status()
224 err = info->ops->get_battery_capacity(info, &capacity); in ds278x_get_status()
228 info->capacity = capacity; in ds278x_get_status()
251 ret = ds278x_get_status(info, &val->intval); in ds278x_battery_get_property()
255 ret = info->ops->get_battery_capacity(info, &val->intval); in ds278x_battery_get_property()
259 ret = info->ops->get_battery_voltage(info, &val->intval); in ds278x_battery_get_property()
263 ret = info->ops->get_battery_current(info, &val->intval); in ds278x_battery_get_property()
267 ret = ds278x_get_temp(info, &val->intval); in ds278x_battery_get_property()
271 ret = -EINVAL; in ds278x_battery_get_property()
279 int old_status = info->status; in ds278x_bat_update()
280 int old_capacity = info->capacity; in ds278x_bat_update()
282 ds278x_get_status(info, &info->status); in ds278x_bat_update()
284 if ((old_status != info->status) || (old_capacity != info->capacity)) in ds278x_bat_update()
285 power_supply_changed(info->battery); in ds278x_bat_update()
295 schedule_delayed_work(&info->bat_work, DS278x_DELAY); in ds278x_bat_work()
308 battery->type = POWER_SUPPLY_TYPE_BATTERY; in ds278x_power_supply_init()
309 battery->properties = ds278x_battery_props; in ds278x_power_supply_init()
310 battery->num_properties = ARRAY_SIZE(ds278x_battery_props); in ds278x_power_supply_init()
311 battery->get_property = ds278x_battery_get_property; in ds278x_power_supply_init()
312 battery->external_power_changed = NULL; in ds278x_power_supply_init()
318 int id = info->id; in ds278x_battery_remove()
320 power_supply_unregister(info->battery); in ds278x_battery_remove()
321 cancel_delayed_work_sync(&info->bat_work); in ds278x_battery_remove()
322 kfree(info->battery_desc.name); in ds278x_battery_remove()
337 cancel_delayed_work(&info->bat_work); in ds278x_suspend()
346 schedule_delayed_work(&info->bat_work, DS278x_DELAY); in ds278x_resume()
374 struct ds278x_platform_data *pdata = client->dev.platform_data; in ds278x_battery_probe()
384 if (id->driver_data == DS2786 && !pdata) { in ds278x_battery_probe()
385 dev_err(&client->dev, "missing platform data for ds2786\n"); in ds278x_battery_probe()
386 return -EINVAL; in ds278x_battery_probe()
399 ret = -ENOMEM; in ds278x_battery_probe()
403 info->battery_desc.name = kasprintf(GFP_KERNEL, "%s-%d", in ds278x_battery_probe()
404 client->name, num); in ds278x_battery_probe()
405 if (!info->battery_desc.name) { in ds278x_battery_probe()
406 ret = -ENOMEM; in ds278x_battery_probe()
410 if (id->driver_data == DS2786) in ds278x_battery_probe()
411 info->rsns = pdata->rsns; in ds278x_battery_probe()
414 info->client = client; in ds278x_battery_probe()
415 info->id = num; in ds278x_battery_probe()
416 info->ops = &ds278x_ops[id->driver_data]; in ds278x_battery_probe()
417 ds278x_power_supply_init(&info->battery_desc); in ds278x_battery_probe()
420 info->capacity = 100; in ds278x_battery_probe()
421 info->status = POWER_SUPPLY_STATUS_FULL; in ds278x_battery_probe()
423 INIT_DELAYED_WORK(&info->bat_work, ds278x_bat_work); in ds278x_battery_probe()
425 info->battery = power_supply_register(&client->dev, in ds278x_battery_probe()
426 &info->battery_desc, &psy_cfg); in ds278x_battery_probe()
427 if (IS_ERR(info->battery)) { in ds278x_battery_probe()
428 dev_err(&client->dev, "failed to register battery\n"); in ds278x_battery_probe()
429 ret = PTR_ERR(info->battery); in ds278x_battery_probe()
432 schedule_delayed_work(&info->bat_work, DS278x_DELAY); in ds278x_battery_probe()
438 kfree(info->battery_desc.name); in ds278x_battery_probe()
458 .name = "ds2782-battery",
468 MODULE_DESCRIPTION("Maxim/Dallas DS2782 Stand-Alone Fuel Gauge IC driver");