Commit graph

10 commits

Author SHA1 Message Date
Uwe Kleine-König fe20b1dcd2 power: supply: Switch i2c drivers back to use .probe()
After commit b8a1a4cd5a ("i2c: Provide a temporary .probe_new()
call-back type"), all drivers being converted to .probe_new() and then
03c835f498 ("i2c: Switch .probe() to not take an id parameter") convert
back to (the new) .probe() to be able to eventually drop .probe_new() from
struct i2c_driver.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2023-06-04 22:33:22 +02:00
Hermes Zhang 131c0c7682 power: supply: bq256xx: Apply TS_IGNORE from devicetree
TS_IGNORE is default off in bq256xx chip. For some HW which doesn't have
the NTC, we need to set TS_IGNORE to 1 to make the charge work. The new
"ti,no-thermistor" is introduced to toggle it.

Signed-off-by: Hermes Zhang <chenhuiz@axis.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2023-05-08 14:14:07 +02:00
Hermes Zhang 5161ec200f power: supply: bq256xx: Support to disable charger
To be able to control the charging process flexible, we need to able to
disable the charger. This commit will allow to disable the charger by
"echo 1 > /sys/class/power_supply/bq256xx-charger/charge_type"
(1 = POWER_SUPPLY_CHARGE_TYPE_NONE) and enable the charger by set it to
2/3 (POWER_SUPPLY_CHARGE_TYPE_TRICKLE/POWER_SUPPLY_CHARGE_TYPE_FAST)

Signed-off-by: Hermes Zhang <chenhuiz@axis.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2023-03-12 23:47:54 +01:00
Hermes Zhang 4651b6b729 power: supply: bq256xx: Init ichg/vbat value with chip default value
Init the ichg/vbat reg with chip default value instead of the max value
used now. The max value set in driver will result an unsafe case (e.g.
battery is over charging when in a hot environment) if no user space
update the value later.

Signed-off-by: Hermes Zhang <chenhuiz@axis.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2023-02-03 13:32:01 +01:00
Uwe Kleine-König fb94ef2efa power: supply: bq256xx: Convert to i2c's .probe_new()
.probe_new() doesn't get the i2c_device_id * parameter, so determine
that explicitly in the probe function.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2022-11-20 20:12:16 +01:00
Linus Walleij f444578d72 power: supply: bq256xx: Handle OOM correctly
Since we now return a pointer to an allocated object we need
to account for memory allocation failure in a separate
error path.

Fixes: 25fd330370 ("power: supply_core: Pass pointer to battery info")
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2022-02-11 21:19:51 +01:00
Linus Walleij 25fd330370 power: supply_core: Pass pointer to battery info
The function to retrieve battery info (from the device tree) assumes
we have a static info struct that gets populated by calling into
power_supply_get_battery_info().

This is awkward since I want to support tables of static battery
info by just assigning a pointer to all info based on e.g. a
compatible value in the device tree.

We also have a mixture of static and dynamically allocated
variables here.

Bite the bullet and let power_supply_get_battery_info() allocate
also the memory used for the very top level
struct power_supply_battery_info container. Pass pointers
around and lifecycle this with the psy device just like the
stuff we allocate inside it.

Change all current users over.

As part of the change, initializers need to be added to some
previously uninitialized fields in struct
power_supply_battery_info.

Reviewed-By: Matti Vaittinen <matti.vaittinen@fi.rohmeurope.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2022-01-03 18:53:10 +01:00
Krzysztof Kozlowski 43d8766372 power: supply: bq256xx: add kerneldoc for structure members
Document members of structure to fix W=1 warnings like:

  drivers/power/supply/bq256xx_charger.c:240: warning:
    Function parameter or member 'charger' not described in 'bq256xx_device'

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2021-04-20 16:18:08 +02:00
Ricardo Rivera-Matos c3f1813516 power: supply: bq256xx: Fix BQ256XX_NUM_WD_VAL and bq256xx_watchdog_time[] overrun
Corrects BQ256XX_NUM_WD_VAL from value of "8" to "4" and fixes the issue when 'i'
is equal to array size then array index over runs the array

Fixes: 32e4978bb9 ("power: supply: bq256xx: Introduce the BQ256XX charger driver")
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Ricardo Rivera-Matos <r-rivera-matos@ti.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2021-01-14 23:38:56 +01:00
Ricardo Rivera-Matos 32e4978bb9 power: supply: bq256xx: Introduce the BQ256XX charger driver
The BQ256XX family of devices are highly integrated buck chargers
for single cell batteries.

Signed-off-by: Ricardo Rivera-Matos <r-rivera-matos@ti.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2021-01-06 21:25:05 +01:00