Commit Graph

2221 Commits

Author SHA1 Message Date
Iskren Chernev
6455a8a84b power: supply: max17040: Use regmap i2c
Rewrite i2c operations from i2c client read/write to regmap i2c. As
a result, most private functions now accept the private driver data
instead of an i2c client pointer.

Signed-off-by: Iskren Chernev <iskren.chernev@gmail.com>
Tested-by: Jonathan Bakker <xc-racer2@live.ca>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2020-10-03 13:04:28 +02:00
Iskren Chernev
e55a50613d power: supply: max17040: Use devm_ to automate remove
Two actions were performed during remove - power supply dereg and
delayed work cleanup. Power supply dereg can be handled by using the
devm_ version of the registration function. Work cleanup can be added as
a devm_action.

If probe fails after psy registration it will now be cleaned up
properly.

Signed-off-by: Iskren Chernev <iskren.chernev@gmail.com>
Tested-by: Jonathan Bakker <xc-racer2@live.ca>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2020-10-03 12:57:12 +02:00
Krzysztof Kozlowski
41a7431dba power: supply: bq27xxx: add support for TI bq34z100
Add support for new device: the TI bq34z100-G1, a Wide Range Fuel Gauge
for Li-Ion, PbA, NiMH, and NiCd batteries.  The device shares a lot with
other models, although it has its own differences requiring new quirks.

This patch was tested on a system equipped with NiMH batteries.

Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2020-10-02 00:01:42 +02:00
Krzysztof Kozlowski
7be64ae0bf power: supply: bq27xxx: add separate flag for capacity inaccurate
bq27000, bq27010 and upcoming bq34z100 have a Capacity Inaccurate flag.
However except this similarity, bq34z100 is quite different than
bq27000/bq27010, so flag BQ27XXX_O_ZERO cannot be reused here.  Add
a new bit flag describing this capability.

No functional change for bq27000 and bq27010.

Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2020-10-02 00:01:42 +02:00
Krzysztof Kozlowski
c02ca20198 power: supply: bq27xxx: add separate flag for single SoC register
bq27000, bq27010 and upcoming bq34z100 have a single byte SoC
register.  However except this similarity, bq34z100 is quite different
than bq27000/bq27010, so flag BQ27XXX_O_ZERO cannot be reused here.  Add
a new bit flag describing that SoC is a single byte register.

No functional change for bq27000 and bq27010.

Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2020-10-02 00:01:42 +02:00
Krzysztof Kozlowski
bffa569fc9 power: supply: bq27xxx: adjust whitespace and use BIT() for bitflags
BIT() is a preferred way to toggle bit-like flags: no problems with 32/64
bit systems, less chances for mistakes.  Remove also unneeded
whitespace.

Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2020-10-02 00:01:42 +02:00
Krzysztof Kozlowski
7bf738ba11 power: supply: bq27xxx: report "not charging" on all types
Commit 6f24ff97e3 ("power: supply: bq27xxx_battery: Add the
BQ27Z561 Battery monitor") and commit d74534c277 ("power:
bq27xxx_battery: Add support for additional bq27xxx family devices")
added support for new device types by copying most of the code and
adding necessary quirks.

However they did not copy the code in bq27xxx_battery_status()
responsible for returning POWER_SUPPLY_STATUS_NOT_CHARGING.

Unify the bq27xxx_battery_status() so for all types when charger is
supplied, it will return "not charging" status.

Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2020-10-02 00:01:42 +02:00
Lucas Stach
81196e2e57 power: supply: ucs1002: fix some health status issues
Some fault events like the over-current condition will get resolved
by the hardware, by e.g. disabling the port. As the status in the
interrupt status register is cleared on read when the fault is resolved,
the sysfs health property will only contain the correct health status
for the first time it is read after such an event, even if the actual
fault condition (like a VBUS short) still persists. To reflect this
properly in the property we cache the last health status and only update
the cache when a actual change happens, i.e. the ERR bit in the status
register flips, as this one properly reflects a continued fault condition.

The ALERT pin however, is not driven by the ERR status, but by the actual
fault status, so the pin will change back to it's default state when the
hardware has automatically resolved the fault by cutting the power. Thus
we never get an IRQ when the actual fault condition has been resolved and
the ERR status bit has been cleared in auto-recovery mode. To get this
information we need to poll the interrupt status register after some time
to see if the fault is gone and update our cache in that case.

To avoid any additional locking, we handle both paths (IRQ firing and
delayed polling) through the same single-threaded delayed work.

Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2020-10-01 00:18:05 +02:00
Wang Qing
ec3af53aa4 power: supply: ab8500-fg: fix spelling typo
Modify the comment typo: "compliment" -> "complement".

Signed-off-by: Wang Qing <wangqing@vivo.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2020-09-30 01:12:22 +02:00
Michał Mirosław
724083293e power: supply: bq25890: support IBAT compensation
Add configuration for compensation of IBAT measuring resistor in series
with the battery.

Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2020-09-30 01:12:22 +02:00
Wang Qing
3f41e742ee power: supply: ds278x: fix spelling typo
Modify the comment typo: "compliment" -> "complement".

Signed-off-by: Wang Qing <wangqing@vivo.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2020-09-30 01:12:04 +02:00
Jonathan Bakker
683aa86eb1 power: supply: charger-manager: Count cm-chargers property directly
Rather than having a cm-chargers and a separate cm-num-chargers
property, simply count the entries in cm-chargers.

Signed-off-by: Jonathan Bakker <xc-racer2@live.ca>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2020-08-28 19:27:45 +02:00
Jonathan Bakker
c1f73028f7 power: supply: charger-manager: Update extcon functions
In commit 830ae44220 ("extcon: Remove the deprecated extcon functions")
the function extcon_register_interest became a no-op returning an error,
leading to non-functional behaviour in charger-manager.

Additionally, a translation table is needed between the text representation
of the extcon cable names and their IDs is needed.  In order to retain DT
compatibility, TA and CHARGE-DOWNSTREAM are added as they were present up
until commit 11eecf910b ("extcon: Modify the id and name of external
connector")

Signed-off-by: Jonathan Bakker <xc-racer2@live.ca>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2020-08-28 19:27:45 +02:00
Jonghwa Lee
9434e4530d power: supply: charger-manager: Don't start charging in cable nofitication
Prevents direct charging control in cable notification and only set the
input current limit according to cable type.  Leave the enabling of
charing to cm_monitor() where charging management proceeds.  We may lose
a few ms to enable charging compared to before, but it's more important
that charging is enabled always in safe context.

Signed-off-by: Jonghwa Lee <jonghwa3.lee@samsung.com>
Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
Signed-off-by: Jonathan Bakker <xc-racer2@live.ca>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2020-08-28 19:27:45 +02:00
Jonghwa Lee
e132fc6bb8 power: supply: charger-manager: Make decisions focussed on battery status
cm_monitor(), where charging management starts, checks various charging
condition sequentially to decide next charging operation. However, as it
follows sequential process, cascaded if statements, it does some
jobs which have already done in the previous stage. This results in a
delay in decision making. Moreover, starting point of charging is spread
all around which makes maintain code and debugging difficult.

Both of the problems mentioned above become clean if it manages battery
charging focusing on battery status not following sequential condition
checking.  Now, cm_monitor() moves battery state diagram and does the
optimal operation for current state. As a result, it reduces whole
monitoring time almost in half.

Signed-off-by: Jonghwa Lee <jonghwa3.lee@samsung.com>
Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
Signed-off-by: Jonathan Bakker <xc-racer2@live.ca>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2020-08-28 19:27:45 +02:00
Jonghwa Lee
dfc63825aa power: supply: charger-manager: Collect all power_supply_changed() calls
Current charger-manager calls power_supply_changed() whenever charging
status is changed. Remove the separated power_supply_changed() calls
and let it be called at end of try_charger_enable() function which
is called to set charging/discharging.

Signed-off-by: Jonghwa Lee <jonghwa3.lee@samsung.com>
Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
Signed-off-by: Jonathan Bakker <xc-racer2@live.ca>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2020-08-28 19:27:41 +02:00
Jonghwa Lee
0a9e0f94bf power: supply: charger-manager: Correct usage of CHARGE_NOW/FULL
The POWER_SUPPLY_CHARGE_NOW/FULL property reflects battery's charges
in uAh unit, but charger-manager has been used it wrongly as a
status field.

Signed-off-by: Jonghwa Lee <jonghwa3.lee@samsung.com>
Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
Signed-off-by: Jonathan Bakker <xc-racer2@live.ca>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2020-08-28 19:07:42 +02:00
Jonathan Bakker
cdaeb15157 power: supply: charger-manager: Always use POWER_SUPPLY_PROP_TEMP
We were using POWER_SUPPLY_PROP_TEMP if the temperature was coming
via the fuel gauge and POWER_SUPPLY_PROP_TEMP_AMBIENT if it was
coming via the thermal framework.  Since they're mutually
exclusive in the driver and we don't know if the thermal framework
 is ambient or not, unify them both to use POWER_SUPPLY_PROP_TEMP.

Signed-off-by: Jonathan Bakker <xc-racer2@live.ca>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2020-08-28 19:05:57 +02:00
Jonghwa Lee
9584051f3c power: supply: charger-manager: Remove cm_notify_event function
cm_notify_event() was introduced to get an event associated with the
battery status externally (ie in board files), but no one ever used it.
Moreover it makes charger manager driver more complicated. Drop the
function and all data related to it to simplify the driver.

Signed-off-by: Jonghwa Lee <jonghwa3.lee@samsung.com>
Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
Signed-off-by: Jonathan Bakker <xc-racer2@live.ca>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2020-08-28 19:03:24 +02:00
Jonghwa Lee
033dea165c power: supply: charger-manager: Swap private uevent for power_supply_changed
Whenever the battery status is changed, charger manager triggers a uevent
through a private interface. Modify it to use power_supply_changed()
since it belongs to the power supply subsystem.

Signed-off-by: Jonghwa Lee <jonghwa3.lee@samsung.com>
Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
Signed-off-by: Jonathan Bakker <xc-racer2@live.ca>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2020-08-28 18:59:15 +02:00
Andreas Kemnade
1426dffad0 power: supply: Add support for RN5T618/RC5T619 charger and fuel gauge
Both chips have charger and a fuel gauge.

This adds basic support for displaying the state of the battery and the
input power, settings are not modified. There are some defaults set via
OTP.

Charging also starts after plugging USB.

Known issues of the fuel gauge: There are drivers in the wild which disable
the fuel gauge at shutdown. If a kernel is booted without fuel gauge
support, after such a driver has been used, the fuel gauge will stay off
and decalibrate.
If this driver is used after that, it might display wrong values for charge
level.

Signed-off-by: Andreas Kemnade <andreas@kemnade.info>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2020-08-28 17:34:38 +02:00
Ikjoon Jang
395a7251dc power: supply: sbs-battery: don't assume i2c errors as battery disconnect
Current sbs-battery considers all smbus errors as disconnection events
when battery-detect pin isn't supplied, and restored to present state back
when any successful transaction is made.

This can lead to unwanted state changes between present and !present
when there's one i2c error and other following commands were successful.

This patch provides a unified way of checking presence by calling
sbs_get_battery_presence_and_health() when detect pin is not used.

Signed-off-by: Ikjoon Jang <ikjn@chromium.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2020-08-28 17:25:54 +02:00
Sebastian Reichel
f385e2fcc5 power: supply: smb347-charger: Use generic property framework
Simplify the driver and remove the DT specific code by
using the generic device property framework.

Reviewed-by: Dmitry Osipenko <digetx@gmail.com>
Tested-by: Dmitry Osipenko <digetx@gmail.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2020-08-28 15:34:36 +02:00
Sebastian Reichel
b6f3e21b92 power: supply: smb347-charger: Drop pdata support
There are no platforms using the pdata support, so let's
drop it to simplify the driver.

Reviewed-by: Dmitry Osipenko <digetx@gmail.com>
Tested-by: Dmitry Osipenko <digetx@gmail.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2020-08-28 15:33:10 +02:00
Dan Murphy
44ff56c022 power: bq27xxx: Update to SPDX licensing
Update the license to the SPDX licensing format.

Signed-off-by: Dan Murphy <dmurphy@ti.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2020-08-28 00:04:44 +02:00
Colin Ian King
c24b9a741b power: supply: pm2301_charger: fix spelling mistake "chargind" -> "charging"
There is a spelling mistake in a dev_dbg message. Fix it.

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2020-08-28 00:02:29 +02:00
Ikjoon Jang
2c4bf69834 power: supply: sbs-battery: combine get_presence_and_health
This patch enables calling sbs_get_battery_presence_and_health()
without checking its chip type. No functional changes.

Signed-off-by: Ikjoon Jang <ikjn@chromium.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2020-08-27 23:56:37 +02:00
Ikjoon Jang
52bef41f60 power: supply: sbs-battery: remove unused enable_detection flags
Remove unused enable_detection flag which is always true after
the device is proved.

Signed-off-by: Ikjoon Jang <ikjn@chromium.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2020-08-27 23:54:58 +02:00
Sebastian Reichel
be2919d835 power: supply: gpio-charger: add charge-current-limit feature
Add new charge-current-limit feature to gpio-charger.

Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2020-08-27 21:13:23 +02:00
Sebastian Reichel
39e95bbbac Immutable branch between arm and power-supply for gpio-charger for 5.10
This immutable branch drops legacy gpio API from
 gpio-charger and updates the remaining users to
 the new gpiod API instead.
 
 Signed-off-by: Sebastian Reichel <sre@kernel.org>
 -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCgAdFiEE72YNB0Y/i3JqeVQT2O7X88g7+poFAl9H0T8ACgkQ2O7X88g7
 +poL9A//X+8A8rX4wsZt1SQCwWVjRnikaluhJpbo24lq4GGolsiTJtV+efk5u3wT
 SoNOZboUBF7Fr9EoNCh203eGr3Z1vG8q+a7DFa41wSb8N5SQSjDECzbwFwMudXMo
 uPwQ21ETQHIyOk6J/fuoQnjpZ9h2ytPgX7gAh6DyDNiz0cdFlLezkewQEmHPq7Ni
 GBPzHuFE3+jGu28Od3FevhP5WnRnAq5sbP6I0KGq1Bbt7FB5N9MKa9j+ZBVcAvHj
 VIH1SVeNjYY7fw3Zr6Qtn0FwDh+p0bzMGCmwtnFvsDzh2mWaMF4imKoGctSIkopl
 5559885mwCDEtTeGO3s38cBNyMKBxNEX+hUN3O82UWf0VcVP97IaFsv0s2TyVg/z
 N3punW6fEBfyQFs+otefQ/AONL6PfxK2bqfu+zJigVXuWaOTS8k3svYGbo5e4oKV
 1Eaj6yH5LWqWdbTg6FZG7zSJJUjEDHXIb+wMaQJHoZXErrqRvdJz89rp0gw7pX3/
 oL0Qj1LKMDYya5YSYF+1k5ykQ9SZYy1aDCex7PYY8Nz5X3phwVqTXcG9SRgduG+U
 m+1DDzw0pn7zG3LRAhXKRxj+9Yy+0DgTMRZ3AbYToS/7+r6o77FrFgud7JUBgHcW
 ZXah7mWdb3uadv6Rb98aNtDmsWtZnwrcY+T2Q86b8Nw3ApLFnT8=
 =RhVS
 -----END PGP SIGNATURE-----

Merge tag 'psy-arm-gpio-charger-immutable-for-5.10-signed' into psy-next

Immutable branch between arm and power-supply for gpio-charger for 5.10

This immutable branch drops legacy gpio API from
gpio-charger and updates the remaining users to
the new gpiod API instead.

Signed-off-by: Sebastian Reichel <sre@kernel.org>
2020-08-27 17:34:01 +02:00
Linus Walleij
17529bcf0a power: supply: gpio-charger: Convert to GPIO descriptors
This converts the GPIO charger to use exclusively GPIO
descriptors, moving the two remaining platforms passing
global GPIO numbers over to using a GPIO descriptor table.

Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Cc: Robert Jarzmik <robert.jarzmik@free.fr>
Cc: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2020-08-27 16:47:14 +02:00
Krzysztof Kozlowski
e03e3601fb power: supply: lego_ev3: Simplify with dev_err_probe()
Common pattern of handling deferred probe can be simplified with
dev_err_probe().  Less code and also it prints the error value.

Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
Reviewed-by: David Lechner <david@lechnology.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2020-08-26 17:25:45 +02:00
Krzysztof Kozlowski
31873dc23c power: supply: ingenic: Simplify with dev_err_probe()
Common pattern of handling deferred probe can be simplified with
dev_err_probe().  Less code and also it prints the error value.

Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2020-08-26 17:25:42 +02:00
Krzysztof Kozlowski
52a023a14e power: supply: gpio-charger: Simplify with dev_err_probe()
Common pattern of handling deferred probe can be simplified with
dev_err_probe().  Less code and also it prints the error value.

Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2020-08-26 17:25:42 +02:00
Krzysztof Kozlowski
ec744270c9 power: supply: cpcap: Simplify with dev_err_probe()
Common pattern of handling deferred probe can be simplified with
dev_err_probe().  Less code and also it prints the error value.

Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2020-08-26 17:25:42 +02:00
Krzysztof Kozlowski
4024810c5a power: supply: bq27xxx: Simplify with dev_err_probe()
Common pattern of handling deferred probe can be simplified with
dev_err_probe().  Less code and also it prints the error value.

Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2020-08-26 17:25:42 +02:00
Subbaraman Narayanamurthy
5ca937fb5d power: supply: add wireless type
Currently, power_supply framework supports only Battery, UPS,
Mains and USB power_supply_type. Add wireless power_supply_type
so that the drivers which supports wireless can register a power
supply class device with POWER_SUPPLY_TYPE_WIRELESS.

Signed-off-by: Subbaraman Narayanamurthy <subbaram@codeaurora.org>
Signed-off-by: Guru Das Srinagesh <gurus@codeaurora.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2020-08-26 16:53:26 +02:00
Dmitry Osipenko
99298de5df power: supply: smb347-charger: Replace mutex with IRQ disable/enable
Let's simply disable/enable IRQ rather than use a mutex that protects from
racing with the interrupt handler. The result of this patch is that it's a
bit easier now to follow the driver's code.

Tested-by: David Heidelberg <david@ixit.cz>
Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2020-08-26 14:41:32 +02:00
David Heidelberg
db14d3b45b power: supply: smb347-charger: Remove virtual smb347-battery
SMB347 is a charger and not a battery driver. Secondly, power-supply core
now supports monitored-battery. So the 'fake' battery doesn't do anything
useful for us, and thus, it should be removed.

Transfer smb347-battery functionality into smb347-mains and smb347-usb.

Reviewed-by: Dmitry Osipenko <digetx@gmail.com>
Signed-off-by: David Heidelberg <david@ixit.cz>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2020-08-26 14:37:05 +02:00
David Heidelberg
de76fd29a7 power: supply: smb347-charger: Support SMB345 and SMB358
SMB345 tested on Nexus 7 2013.

Based on:
- https://patchwork.kernel.org/patch/4922431/
- https://patchwork.ozlabs.org/patch/666877/

Signed-off-by: David Heidelberg <david@ixit.cz>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2020-08-25 19:54:08 +02:00
David Heidelberg
364bec7557 power: supply: smb347-charger: Implement device-tree support
This patch adds device-tree support to the SMB347 charger driver. All
legacy platform data now can be parsed from DT. Because of that and since
SMB347 is an I2C client driver, the IRQ number can be passed automatically
through client's IRQ variable if it's defined in DT. There is no need to
map GPIO to IRQ manually in the case of DT.

This patch is based on the original work made by:
Jonghwa Lee <jonghwa3.lee@samsung.com>
Link: https://patchwork.kernel.org/patch/4284731/

Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
Signed-off-by: David Heidelberg <david@ixit.cz>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2020-08-25 19:29:18 +02:00
Dmitry Osipenko
00cda13e33 power: supply: Support battery temperature device-tree properties
The generic battery temperature properties are already supported by the
power-supply core. Let's support parsing of the common battery temperature
properties from a device-tree.

Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2020-08-25 19:24:37 +02:00
David Heidelberg
2d52f7102b power: supply: smb347-charger: Use resource-managed API
Simplify code, more convenient to use with Device Tree.

Reviewed-by: Dmitry Osipenko <digetx@gmail.com>
Signed-off-by: David Heidelberg <david@ixit.cz>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2020-08-25 19:04:24 +02:00
Rikard Falkeborn
93d660de3f power: supply: bq2515x: Constify static variables
Constify a number of static variables that are not modified to allow the
compiler to put them in read-only memory.

Signed-off-by: Rikard Falkeborn <rikard.falkeborn@gmail.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2020-08-25 17:55:29 +02:00
Alex Dewar
8fada2d4c2 power: supply: Add dependency to lego-ev3-battery Kconfig options
This battery appears only to be used by a single board (DA850), so it
makes sense to add this to the Kconfig file so that users don't build
the module unnecessarily. It currently seems to be built for the x86
Arch Linux kernel where it's probably not doing much good.

Signed-off-by: Alex Dewar <alex.dewar90@gmail.com>
Acked-by: David Lechner <david@lechnology.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2020-08-25 15:48:44 +02:00
Linus Torvalds
449dc8c970 power supply and reset changes for the v5.9 series
power-supply core:
  * add COOL/WARM/HOT state from JEITA JISC8712:2015 specification
  * convert simple-battery DT binding to YAML
  * add long-life charging mode
 
 battery/charger drivers:
  * bq25150: new charger driver
  * bq27xxx: add support for BQ27z561 and BQ28z610
  * max17040: support CAPACITY_ALERT_MIN
  * sbs-battery: add PEC support
  * wilco-ec: support long-life charging mode
  * bq25890: fix DT binding
  * misc. fixes and cleanups
 
 reset drivers:
  * linkstation: new reset driver
 -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCgAdFiEE72YNB0Y/i3JqeVQT2O7X88g7+poFAl8rMawACgkQ2O7X88g7
 +prspw/8CkZiTCl+tnaVdWNvzSQjalKjKeYegKlEolwfZjSQIokeLfz8KSqN2R8q
 t+TTEJLuO+Y7ZRlpR+inD3UbeAI4XUL9PE8ZwrKycpwUbwIsjICZT5XEbDCjkyIo
 tXBsB4ainkGy4SD2Yn1/tMQB+S4blqiz7ryhii1OWI8+MMLfR25m0cQQDMm1VlAn
 WgWza/wRTX+7NpCPSoHkMN4lk2hZz4Ai7X+z8W7TtId91gk+1vQBGOllinG9yd5F
 bik6Q2qBgHP8ICB6p+9YUenozvvFfEK79euMW99YnZM91DCb0v0YSDm56wIpV58r
 JGDXN2pHeYxjuDM6pXMbQV31u/NbMKSHMolBYdAtPbxPMS7iHefgoPYUOZDamRte
 ovjW+pXhEyKkFORp61rwwza3EDBBdKsF2C8OVGywAK8kOZ2y0a6wPEre62Dq2r3U
 A6eYT+UD+EYV9eunX6Nvx45hi/Vl3R35vJGhU+M77N5YcpW1jSJxWVZJ5AlbwDQK
 +6Di8GUYrZLZ17+z0bkF8RKnJlfHPVcrvbKty/ePtyYW/DgDpwH9/QQWPIF7BbMG
 f5csOE5A/MWIENeOWClYtKGMjxzTrKZ5BbjPWYzSo+Gw36fM5pCB1rG6/s+kmGM3
 HeGyWMr5fe4eoRBTcM/LFqyM8C1wYXGIMd8u65/RsYh592fgfgw=
 =SWyv
 -----END PGP SIGNATURE-----

Merge tag 'for-v5.9' of git://git.kernel.org/pub/scm/linux/kernel/git/sre/linux-power-supply

Pull power supply and reset updates from Sebastian Reichel:
 "Power-supply core:
   - add COOL/WARM/HOT state from JEITA JISC8712:2015 specification
   - convert simple-battery DT binding to YAML
   - add long-life charging mode

 Battery/charger drivers:
   - bq25150: new charger driver
   - bq27xxx: add support for BQ27z561 and BQ28z610
   - max17040: support CAPACITY_ALERT_MIN
   - sbs-battery: add PEC support
   - wilco-ec: support long-life charging mode
   - bq25890: fix DT binding
   - misc. fixes and cleanups

 Reset drivers:
   - linkstation: new reset driver"

* tag 'for-v5.9' of git://git.kernel.org/pub/scm/linux/kernel/git/sre/linux-power-supply: (32 commits)
  power: supply: wilco_ec: Add long life charging mode
  power: supply: bq27xxx_battery: Add the BQ28z610 Battery monitor
  dt-bindings: power: Add BQ28z610 compatible
  power: supply: bq27xxx_battery: Add the BQ27Z561 Battery monitor
  dt-bindings: power: Add BQ27Z561 compatible
  power: supply: test_power: Fix battery_current initial value
  power: supply: Fix kerneldoc of power_supply_temp2resist_simple()
  power: supply: cpcap-battery: Fix kerneldoc of cpcap_battery_read_accumulated()
  dt-bindings: power: Convert battery.txt to battery.yaml
  power: supply: rt5033_battery: Fix error code in rt5033_battery_probe()
  power: supply: max17040: Add POWER_SUPPLY_PROP_CAPACITY_ALERT_MIN
  power: supply: check if calc_soc succeeded in pm860x_init_battery
  power: supply: bq2xxxx: Replace HTTP links with HTTPS ones
  power: reset: add driver for LinkStation power off
  power: supply: sc27xx: prevent adc * 1000 from overflow
  math64: New DIV_S64_ROUND_CLOSEST helper
  power: fix duplicated words in bq2415x_charger.h
  power: Convert to DEFINE_SHOW_ATTRIBUTE
  power: reset: keystone-reset: Replace HTTP links with HTTPS ones
  power: supply: bq25150 introduce the bq25150
  ...
2020-08-07 21:27:37 -07:00
Crag Wang
46cbd0b057 power: supply: wilco_ec: Add long life charging mode
This is a long life mode set in the factory for extended warranty
battery, the power charging rate is customized so that battery at
work last longer.

Presently switching to a different battery charging mode is through
EC PID 0x0710 to configure the battery firmware, this operation will
be blocked by EC with failure code 0x01 when PLL mode is already
in use.

Signed-off-by: Crag Wang <crag.wang@dell.com>
Reviewed-by: Mario Limonciello <mario.limonciello@dell.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2020-07-31 14:33:56 +02:00
Dan Murphy
707d678a5c power: supply: bq27xxx_battery: Add the BQ28z610 Battery monitor
Add the Texas Instruments BQ28z610 battery monitor.
The register address map is laid out the same as compared to other
devices within the file.

The battery status register bits are similar to the bq27z561 but they
are different compared to other fuel gauge devices within this file.

Signed-off-by: Dan Murphy <dmurphy@ti.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2020-07-29 22:33:10 +02:00
Dan Murphy
6f24ff97e3 power: supply: bq27xxx_battery: Add the BQ27Z561 Battery monitor
Add the Texas Instruments BQ27Z561 battery monitor.  The register address
map is laid out the same as compared to other devices within the file.
The battery status register has differing bits to determine if the
battery is full, discharging or dead.

Signed-off-by: Dan Murphy <dmurphy@ti.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2020-07-29 22:33:10 +02:00
LH Lin
c365ee561e power: supply: test_power: Fix battery_current initial value
Since default battery_status is POWER_SUPPLY_STATUS_DISCHARGING,
we should change default battery_current to a negative value.

Signed-off-by: LH Lin <lh.lin@mediatek.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2020-07-29 19:43:49 +02:00