Commit Graph

2400 Commits

Author SHA1 Message Date
Linus Torvalds 5a69e9bce9 power supply and reset changes for the v5.13 series
battery/charger driver changes:
  * core: provide function stubs if CONFIG_POWER_SUPPLY=n
  * core: reduce loglevel for probe defer info
  * surface-battery: new battery driver for Surface
  * surface-charger: new charger driver for Surface
  * bq27xxx: add bq78z100 support
  * bq27xxx: fix current_now/power_avg for newer chips
  * cw2015: add CHARGE_NOW support
  * ab8500: drop pdata support
  * convert most DT bindings to YAML
  * lot's of minor fixes and cleanups
 
 reset drivers:
  * ltc2952-poweroff: make trigger delay configurable from DT
  * minor fixes and cleanups
 -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCgAdFiEE72YNB0Y/i3JqeVQT2O7X88g7+poFAmCHIvEACgkQ2O7X88g7
 +poldw/9E3n0HK/SZR/kdpXCt8oLQ6Ey7SSKi1a+i1Qe2VgAdDPVceI7T5yRvMeo
 CVhTQ5nCl2HdZMhbNWgN1xY37eybX3cUGCYieXoWA/ALSdLRNVFcz5aOexJcWyYg
 nxcg+qJ5CYOHIJBjA+0H0t9GRTz5PkYyzgilajkhN0EJIxMzjF1hnv9YLReibN4g
 WD+EZNnpPO1FcxGsmKwhyEmO1xEAqe9LMj/qffiHNHgN+kX2GVW9t+TCLwPtCbnZ
 6SwT7seT2Lk9nKhhZNWk5R+W1uhXicYsvkXlqVM6TOjbn3hDqGhC0D2OXz+A0ykW
 R7WQB4gWyy9coU8gTerRBWd8BTjsc2oAvy8fYuAmEkqpiecZD5AwZO8mNwKX0y7d
 DRloYsFVs1FJrW+6eA+2S+PPwMI4sfVGWpp2DNti8STxeBPFkQDUyVVwhR3xbm79
 5DBj8V8VKekqteUOhnB5ZpyqkbIUMS2zYPgWq7p5g9GnYSffeQI7sOZrNna0pUDg
 9pNYaRzNHWVONftxQP4SY1pMbsZFXV3znYwdXZjO8eiRCSi8hbpo9y+I2fFp/7fW
 9vr//cDWLcgSpqt5z0yhgVjGtXXwcvkd3X2BgX8BY0hhH9NrOEFD6o2DXDPZAC+q
 djcW3nl5QpUUzXp07xxSFAxNTmo8jlegkZenNkYLVLEahvG0jjs=
 =9IUN
 -----END PGP SIGNATURE-----

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

Pull power supply and reset updates from Sebastian Reichel:
 "battery/charger driver changes:
   - core:
      - provide function stubs if CONFIG_POWER_SUPPLY=n
      - reduce loglevel for probe defer info
   - surface:
      - new battery and charger drivers for Surface
   - bq27xxx:
      - add bq78z100 support
      - fix current_now/power_avg for newer chips
   - cw2015:
      - add CHARGE_NOW support
   - ab8500:
      - drop pdata support
   - convert most DT bindings to YAML
   - lots of minor fixes and cleanups

  reset drivers:
   - ltc2952-poweroff:
      - make trigger delay configurable from DT
   - minor fixes and cleanups"

* tag 'for-v5.13' of git://git.kernel.org/pub/scm/linux/kernel/git/sre/linux-power-supply: (97 commits)
  power: supply: cpcap-battery: fix invalid usage of list cursor
  power: supply: bq256xx: add kerneldoc for structure members
  power: supply: act8945a: correct kerneldoc
  power: supply: max17040: remove unneeded double cast
  power: supply: max17040: handle device_property_read_u8_array() failure
  power: supply: max14577: remove unneeded variable initialization
  power: supply: surface-charger: Make symbol 'surface_ac_pm_ops' static
  power: supply: surface-battery: Make some symbols static
  power: reset: restart-poweroff: Add missing MODULE_DEVICE_TABLE
  power: reset: hisi-reboot: add missing MODULE_DEVICE_TABLE
  power: supply: s3c_adc_battery: fix possible use-after-free in s3c_adc_bat_remove()
  power: supply: generic-adc-battery: fix possible use-after-free in gab_remove()
  power: supply: Add AC driver for Surface Aggregator Module
  power: supply: Add battery driver for Surface Aggregator Module
  power: supply: bq25980: Move props from battery node
  power: supply: core: Use true and false for bool variable
  power: supply: goldfish: Remove the GOLDFISH dependency
  power: reset: ltc2952: make trigger delay configurable
  power: supply: cpcap-charger: Simplify bool conversion
  power: supply: cpcap-charger: Add usleep to cpcap charger to avoid usb plug bounce
  ...
2021-04-28 15:43:58 -07:00
Guangqing Zhu d0a43c12ee power: supply: cpcap-battery: fix invalid usage of list cursor
Fix invalid usage of a list_for_each_entry in cpcap_battery_irq_thread().
Empty list or fully traversed list points to list head, which is not
NULL (and before the first element containing real data).

Signed-off-by: Guangqing Zhu <zhuguangqing83@gmail.com>
Reviewed-by: Tony Lindgren <tony@atomide.com>
Reviewed-by: Carl Philipp Klemm <philipp@uvos.xyz>
Tested-by: Carl Philipp Klemm <philipp@uvos.xyz>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2021-04-21 23:06:14 +02: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
Krzysztof Kozlowski 4667d52fad power: supply: act8945a: correct kerneldoc
Remove incorrect kerneldoc marker to fix W=1 warning:

  drivers/power/supply/act8945a_charger.c:22: warning:
    This comment starts with '/**', but isn't a kernel-doc comment. Refer Documentation/doc-guide/kernel-doc.rst

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
Krzysztof Kozlowski 6dfbb2cece power: supply: max17040: remove unneeded double cast
There is no need for double explicit cast from of_device_get_match_data()
(uintptr_t and then to target enum) because implicit conversion from
uintptr_t to enum is straightforward (uintptr_t is a integer type).

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
Krzysztof Kozlowski a837f35c5a power: supply: max17040: handle device_property_read_u8_array() failure
The device_property_read_u8_array() call should not fail because it is
preceded with device_property_count_u8() and check for number of
readable u8 values.  However the code is more obvious and easier to read
if the return value of device_property_read_u8_array() is checked.
Otherwise reader needs to investigate whether really there is no risk of
using random stack values of 'rcomp' variable.

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
Krzysztof Kozlowski 01dcfe7849 power: supply: max14577: remove unneeded variable initialization
The local 'current_bits' variable does not have to be initialized
because all cases in following switch() either return or initialize it.

Addresses-Coverity: Unused value
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
Qiheng Lin a4d5ed3b54 power: supply: surface-charger: Make symbol 'surface_ac_pm_ops' static
The sparse tool complains as follows:

drivers/power/supply/surface_charger.c:229:1: warning:
 symbol 'surface_ac_pm_ops' was not declared. Should it be static?

This symbol is not used outside of surface_charger.c, so this
commit marks it static.

Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Qiheng Lin <linqiheng@huawei.com>
Acked-by: Maximilian Luz <luzmaximilian@gmail.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2021-04-12 21:20:25 +02:00
Qiheng Lin 5ea2edd67a power: supply: surface-battery: Make some symbols static
The sparse tool complains as follows:

drivers/power/supply/surface_battery.c:700:1: warning:
 symbol 'dev_attr_alarm' was not declared. Should it be static?
drivers/power/supply/surface_battery.c:805:1: warning:
 symbol 'surface_battery_pm_ops' was not declared. Should it be static?

This symbol is not used outside of surface_battery.c, so this
commit marks it static.

Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Qiheng Lin <linqiheng@huawei.com>
Acked-by: Maximilian Luz <luzmaximilian@gmail.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2021-04-12 21:19:42 +02:00
Bixuan Cui e318c3c2ae power: reset: restart-poweroff: Add missing MODULE_DEVICE_TABLE
This patch adds missing MODULE_DEVICE_TABLE definition which generates
correct modalias for automatic loading of this driver when it is built
as an external module.

Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Bixuan Cui <cuibixuan@huawei.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2021-04-12 21:18:52 +02:00
Chen Lifu 2d54a2222c power: reset: hisi-reboot: add missing MODULE_DEVICE_TABLE
This patch adds missing MODULE_DEVICE_TABLE definition which generates
correct modalias for automatic loading of this driver when it is built
as an external module.

Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Chen Lifu <chenlifu@huawei.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2021-04-09 13:50:01 +02:00
Yang Yingliang 68ae256945 power: supply: s3c_adc_battery: fix possible use-after-free in s3c_adc_bat_remove()
This driver's remove path calls cancel_delayed_work(). However, that
function does not wait until the work function finishes. This means
that the callback function may still be running after the driver's
remove function has finished, which would result in a use-after-free.

Fix by calling cancel_delayed_work_sync(), which ensures that
the work is properly cancelled, no longer running, and unable
to re-schedule itself.

Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2021-04-08 14:36:08 +02:00
Yang Yingliang b6cfa007b3 power: supply: generic-adc-battery: fix possible use-after-free in gab_remove()
This driver's remove path calls cancel_delayed_work(). However, that
function does not wait until the work function finishes. This means
that the callback function may still be running after the driver's
remove function has finished, which would result in a use-after-free.

Fix by calling cancel_delayed_work_sync(), which ensures that
the work is properly cancelled, no longer running, and unable
to re-schedule itself.

Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2021-04-08 14:35:19 +02:00
Maximilian Luz e61ffb3445 power: supply: Add AC driver for Surface Aggregator Module
On newer Microsoft Surface models (specifically 7th-generation, i.e.
Surface Pro 7, Surface Book 3, Surface Laptop 3, and Surface Laptop Go),
battery and AC status/information is no longer handled via standard ACPI
devices, but instead directly via the Surface System Aggregator Module
(SSAM), i.e. the embedded controller on those devices.

While on previous generation models, AC status is also handled via SSAM,
an ACPI shim was present to translate the standard ACPI AC interface to
SSAM requests. The SSAM interface itself, which is modeled closely after
the ACPI interface, has not changed.

This commit introduces a new SSAM client device driver to support AC
status/information via the aforementioned interface on said Surface
models.

Signed-off-by: Maximilian Luz <luzmaximilian@gmail.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2021-04-08 14:30:35 +02:00
Maximilian Luz 167f77f7d0 power: supply: Add battery driver for Surface Aggregator Module
On newer Microsoft Surface models (specifically 7th-generation, i.e.
Surface Pro 7, Surface Book 3, Surface Laptop 3, and Surface Laptop Go),
battery and AC status/information is no longer handled via standard ACPI
devices, but instead directly via the Surface System Aggregator Module
(SSAM), i.e. the embedded controller on those devices.

While on previous generation models, battery status is also handled via
SSAM, an ACPI shim was present to translate the standard ACPI battery
interface to SSAM requests. The SSAM interface itself, which is modeled
closely after the ACPI interface, has not changed.

This commit introduces a new SSAM client device driver to support
battery status/information via the aforementioned interface on said
Surface models. It is in parts based on the standard ACPI battery
driver.

Signed-off-by: Maximilian Luz <luzmaximilian@gmail.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2021-04-08 14:30:28 +02:00
Ricardo Rivera-Matos 04722cec14 power: supply: bq25980: Move props from battery node
Currently POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT and
POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE are exposed on
the battery node and this is incorrect.

This patch exposes both of them on the charger node rather
than the battery node.

Fixes: 5069185fc1 ("power: supply: bq25980: Add support for the BQ259xx family")
Signed-off-by: Ricardo Rivera-Matos <r-rivera-matos@ti.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2021-04-05 17:51:21 +02:00
Sebastian Reichel 2509555070 Immutable branch between MFD and Power due for the v5.13 merge window
-----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCgAdFiEEdrbJNaO+IJqU8IdIUa+KL4f8d2EFAmBZrSsACgkQUa+KL4f8
 d2EyiA/9GRBj8piXoHnlqA4lkExInTddmts2r7aDtmPa1iCUT5XeyIoiSWdnFz++
 fr9ion87/T89zVJWLMGHi5HRlOEQwR0eG8VUF7rAp8qV9ANOOB8sYi0KC4k1ADet
 +SNTqUYIbA3xrlH+DSPBRmyWMJ6EHkrtmzBCO4PUyxEexFFGSGz3BuEkCdhKMsUb
 /t/AqxLEs9v8dHOIWHTlKK9M1divTdBkqN8mwUfGMDqvtCpFXIuSZ3koTnK9wJyd
 Pqw+5XAoL8cMfSkQrwIpZGRdzyCa9f0iOJz8gdYYKxq1575zGxUTM53z3MYb+ujX
 ei3oO99bCNLezcWozBNEJIlk4LK2FdzWFrlimsxE+2IStH9p1TE3voWFUJh+tL3f
 mbYHNJr35pBNRXA07iQccA9V2zCFAeN4GaeRrY59blcfw8fvOGcWwni8YDbWmmGz
 E/xYv7WeNtrzrELNDMpGJ4w909EItfXEsWyzItJBhI5ThsRPOpET7uBolkEfbd5M
 jjGM2pGeLq++Zd1c2kBzc3a2gW60iGNI6dMBpZWCwCCPe1Vz7okiu1hVULMYYXgZ
 B7F8xzM60phdlMUrFu/tFyYPOs8/0w8tk5QjGiD7/FkLsFhD6UdJsD0r02PCtqN+
 4BRGwOmZWED83XVDTkwVR61GWPP7mWl5AUywe2XdPBo6/jhWTBY=
 =+5eM
 -----END PGP SIGNATURE-----

Merge tag 'ib-mfd-power-v5.13' into psy-next

Immutable branch between MFD and Power due for the v5.13 merge window.

Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2021-04-05 12:38:08 +02:00
Roman Kiryanov 570b7c0ea2 power: supply: goldfish: Remove the GOLDFISH dependency
This will allow to use the BATTERY_GOLDFISH driver
without enabling GOLDFISH.

Signed-off-by: Roman Kiryanov <rkir@google.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2021-04-05 12:10:11 +02:00
Marek Czerski 52473b0740 power: reset: ltc2952: make trigger delay configurable
Make trigger delay configurable through device tree with
trigger-delay-ms property.

Trigger delay is the time to wait before starting shutdown
sequence after trigger line assertion.
Trigger delay must take into account the OFFT time configured
with the capacitor connected to OFFT pin of the LTC2952 chip.
Basically, the higher the capacitance connected to OFFT pin,
the larger trigger delay must be.

Signed-off-by: Marek Czerski <ma.czerski@gmail.com>
Acked-by: Rob Herring <robh@kernel.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2021-04-05 12:05:51 +02:00
Yang Li 816aacd541 power: supply: cpcap-charger: Simplify bool conversion
Fix the following coccicheck warning:
./drivers/power/supply/cpcap-charger.c:416:31-36: WARNING: conversion to
bool not needed here

Reported-by: Abaci Robot <abaci@linux.alibaba.com>
Signed-off-by: Yang Li <yang.lee@linux.alibaba.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2021-04-05 11:37:06 +02:00
Carl Philipp Klemm 751faedf06 power: supply: cpcap-charger: Add usleep to cpcap charger to avoid usb plug bounce
Adds 80000 us sleep when the usb cable is plugged in to hopefully avoid
bouncing contacts.

Upon pluging in the usb cable vbus will bounce for some time, causing cpcap to
dissconnect charging due to detecting an undervoltage condition. This is a
scope of vbus on xt894 while quickly inserting the usb cable with firm force,
probed at the far side of the usb socket and vbus loaded with approx 1k:
http://uvos.xyz/maserati/usbplug.jpg.

As can clearly be seen, vbus is all over the place for the first 15 ms or so
with a small blip at ~40 ms this causes the cpcap to trip up and disable
charging again.

The delay helps cpcap_usb_detect avoid the worst of this. It is, however, still
not ideal as strong vibrations can cause the issue to reapear any time during
charging. I have however not been able to cause the device to stop charging due
to this in practice as it is hard to vibrate the device such that the vbus pins
start bouncing again but cpcap_usb_detect is not called again due to a detected
disconnect/reconnect event.

Signed-off-by: Carl Philipp Klemm <philipp@uvos.xyz>
Tested-by: Tony Lindgren <tony@atomide.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2021-04-05 10:22:18 +02:00
Carl Philipp Klemm 8a5a0cc13a power: supply: cpcap-charger: fix small mistake in current to register conversion
Signed-off-by: Carl Philipp Klemm <philipp@uvos.xyz>
Acked-by: Tony Lindgren <tony@atomide.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2021-04-05 10:21:12 +02:00
Sebastian Reichel 3af26e2ad5 power: supply: core: reduce loglevel for probe defer info
Avoid logging probe defer information for default loglevel
configurations. This is only required for debugging probe
defer issues, which requires enabling debug messages for
other subsystems.

This dev_info() message predates having deferred devices
information available in /sys/kernel/debug/devices_deferred,
which is generally more useful.

Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2021-04-02 14:19:26 +02:00
Sebastian Reichel 17948f5899 power: supply: sbs-manager: update gpio include
sbs-manager implements a GPIO chip, so include the proper
gpio driver include instead of the legacy gpio.h.

Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2021-04-02 14:19:26 +02:00
Sebastian Reichel 436ff8c928 power: supply: sbs-manager: use dev_err_probe
Introduce usage of dev_err_probe in probe routine, which
makes the code slightly more readable and removes some
lines of code. It also removes PROBE_DEFER errors being
logged by default.

Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2021-04-02 14:19:25 +02:00
Sebastian Reichel 814ddbd9ec power: supply: sbs-manager: use managed i2c_mux_adapter
Simplify code by using devm_add_action_or_reset to unregister
the i2c_mux_adapter.

Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2021-04-02 14:19:25 +02:00
Sebastian Reichel 310162f6dd power: supply: sbs-charger: drop unused gpio includes
sbs-charger does not use any GPIOs, so no need to include
gpio.h and of_gpio.h.

Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2021-04-02 14:19:25 +02:00
Sebastian Reichel e319f4e25a power: supply: sbs-charger: use dev_err_probe
Introduce usage of dev_err_probe in probe routine, which
makes the code slightly more readable and removes some
lines of code. It also removes PROBE_DEFER errors being
logged by default.

Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2021-04-02 14:19:25 +02:00
Sebastian Reichel 166767ab91 power: supply: sbs-battery: use dev_err_probe
Introduce usage of dev_err_probe in probe routine, which
makes the code slightly more readable and removes some
lines of code. It also removes PROBE_DEFER errors being
logged by default, which are common when the battery is
waiting for the charger driver to be registered.

This also cleans up a useless goto and instead returns
directly.

Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2021-04-02 14:19:25 +02:00
Milan Djurovic 33ae8b0346 power: supply: 88pm860x_battery: Remove unnecessary int for long long
Change 'long long int' to 'long long' because the int is unnecessary,
as suggested by checkpatch.pl.

Signed-off-by: Milan Djurovic <mdjurovic@zohomail.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2021-04-02 14:14:58 +02:00
Timon Baetz 416682f27a power: supply: max8997_charger: Switch to new binding
Get regulator from parent device's node and extcon by name.

Signed-off-by: Timon Baetz <timon.baetz@protonmail.com>
Reviewed-by: Krzysztof Kozlowski <krzk@kernel.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2021-04-02 14:12:52 +02:00
Hao Fang 9f45275a34 power: reset: hisi-reboot: use the correct HiSilicon copyright
s/Hisilicon/HiSilicon/g.
It should use capital S, according to
https://www.hisilicon.com/en/terms-of-use.

Signed-off-by: Hao Fang <fanghao11@huawei.com>
Acked-by: Haojian Zhuang <haojian.zhuang@linaro.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2021-04-02 13:58:34 +02:00
Claudiu Beznea bd3127733f power: reset: at91-reset: use devm_of_iomap
Use devm_of_iomap() to map resources. This will avoid the necessity to
track the mapped resources and free them on failure path or on remove.

Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Suggested-by: Nicolas Ferre <nicolas.ferre@microchip.com>
Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2021-04-02 13:11:45 +02:00
Matti Vaittinen ecdc996baf power: supply: axp20x_usb_power: fix work-queue init
The commit 6d0c5de2fd
("power: supply: Clean-up few drivers by using managed work init")
Re-introduced wrong order of initializing work-queue and requesting
the IRQs which was originally fixed by the commit b5e8642ed9
("power: supply: axp20x_usb_power: Init work before enabling IRQs")

In addition this caused the work queue to be initialized twice.

Fix it again.

Fixes: 6d0c5de2fd ("power: supply: Clean-up few drivers by using managed work init")
Signed-off-by: Matti Vaittinen <matti.vaittinen@fi.rohmeurope.com>
Reported-by: Chen-Yu Tsai <wens@csie.org>
Acked-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Link: https://lore.kernel.org/r/a774ca25010b7c932c07f22ce8a548466705c023.1616574973.git.matti.vaittinen@fi.rohmeurope.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-03-26 15:45:33 +01:00
Daniel Golle 3aeaf50938 power: reset: replace curly brackets in Makefile
Normal parentheses should be used when referring to config variables
in Makefile. Replace the accidentally introduced curly brackets by
regular parentheses.

Fixes: a7f79f9954 ("power: reset: add driver for LinkStation power off")
Acked-by: Daniel González Cabanelas <dgcbueu@gmail.com>
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2021-03-23 16:25:56 +01:00
Matti Vaittinen 6d0c5de2fd power: supply: Clean-up few drivers by using managed work init
Few drivers implement remove call-back only for ensuring a delayed
work gets cancelled prior driver removal. Clean-up these by switching
to use devm_delayed_work_autocancel() instead.

This change is compile-tested only. All testing is appreciated.

Acked-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Signed-off-by: Matti Vaittinen <matti.vaittinen@fi.rohmeurope.com>
Link: https://lore.kernel.org/r/e5b1b0380cdd1aa066c9ac6d7a8b1a86ba1ddbbe.1616506559.git.matti.vaittinen@fi.rohmeurope.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-03-23 15:22:40 +01:00
Bhaskar Chowdhury 37ad56aa82 power: supply: max17042: Trivial spelling fixes
Few trivial spelling fixes.

Signed-off-by: Bhaskar Chowdhury <unixbhaskar@gmail.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2021-03-23 14:27:11 +01:00
Linus Walleij ee0975c308 mfd/power: ab8500: Push data to power supply code
There is a slew of defines, structs and enums and even a
function call only relevant for the charging code that
still lives in <linux/mfd/abx500.h>. Push it down to the
"ab8500-bm.h" header in the power supply subsystem where
it is actually used.

Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Acked-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
2021-03-22 14:56:02 +00:00
Linus Walleij a65aa0ce23 mfd/power: ab8500: Push algorithm to power supply code
The charging algorithm header is only used locally in the
power supply subsystem so push this down into
drivers/power/supply and rename from the confusing
"ux500_chargalg.h" to "ab8500-chargalg.h" for clarity:
it is only used with the AB8500.

This is another remnant of non-DT code needing to pass
data from boardfiles, which we don't do anymore.

Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Acked-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
2021-03-22 14:55:51 +00:00
Linus Walleij 417c0fc24d mfd/power: ab8500: Push data to power supply code
The global definition of platform data for the battery
management code has no utility after the OF conversion,
move the <linux/mfd/abx500/ab8500-bm.h> to be a local
file in drivers/power/supply and stop defining the
platform data in drivers/power/supply/ab8500_bmdata.c
and broadcast to the kernel only to have it assigned
as platform data to the MFD cells and then picked back
into the same subsystem that defined it in the first
place. This kills off a layer of indirection.

Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Acked-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
2021-03-22 14:55:38 +00:00
Linus Walleij 53207aa1a7 power: ab8500: Require device tree
The core AB8500 driver and the whole platform is completely
dependent on being probed from device tree so remove the
non-DT probe paths.

Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Acked-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
2021-03-22 14:55:06 +00:00
Xiaofeng Cao bd3689a64e power: supply: max1721x: Correct spelling
Change  'stanalone'      to  'standalone'
Change  'mesaurement'    to  'measurement'
Change  'nonvilatile'    to  'nonvolatile'
Change  'unical'         to  'unique'
Change  'unaccesable'    to  'unaccessible'
Change  'correcpondent'  to  'correspond'

Signed-off-by: Xiaofeng Cao <caoxiaofeng@yulong.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2021-03-22 15:11:22 +01:00
dongjian c77b26e327 power: supply: ds2781: use kobj_to_dev()
Use kobj_to_dev() instead of open-coding it

Signed-off-by: dongjian <dongjian@yulong.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2021-03-22 15:05:41 +01:00
Bhaskar Chowdhury 31ba6fadc3 power: supply: charger-manager: Fix a typo
s/systme/system/

Signed-off-by: Bhaskar Chowdhury <unixbhaskar@gmail.com>
Acked-by: Randy Dunlap <rdunlap@infradead.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2021-03-22 14:59:48 +01:00
dongjian 091d0a3a48 power: reset: remove unneeded semicolon
Fixes coccicheck warning:
drivers/power/reset/vexpress-poweroff.c:136:2-3: Unneeded semicolon

Signed-off-by: dongjian <dongjian@yulong.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2021-03-22 14:55:50 +01:00
dongjian 2469b836fa power: supply: Use IRQF_ONESHOT
Fixes coccicheck error:

drivers/power/supply/pm2301_charger.c:1089:7-27: ERROR:
drivers/power/supply/lp8788-charger.c:502:8-28: ERROR:
drivers/power/supply/tps65217_charger.c:239:8-33: ERROR:
drivers/power/supply/tps65090-charger.c:303:8-33: ERROR:

Threaded IRQ with no primary handler requested without IRQF_ONESHOT

Signed-off-by: dongjian <dongjian@yulong.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2021-03-22 14:54:24 +01:00
LI Qingwu 4eed7f5a83 power: supply: bq27xxx: Add support for BQ78Z100
Add support for TI BQ78Z100, I2C interface gas gauge.
It provides a fully integrated safety protection
and authentication for 1 to 2-series cell Li-Ion and
Li-Polymer battery packs.

The patch was tested with BQ78Z100 equipment.

CASE I:  Discharging:
	POWER_SUPPLY_NAME=bq78z100-0
	POWER_SUPPLY_STATUS=Discharging
	POWER_SUPPLY_PRESENT=1
	POWER_SUPPLY_VOLTAGE_NOW=3386000
	POWER_SUPPLY_CURRENT_NOW=-5000
	POWER_SUPPLY_CAPACITY=27
	POWER_SUPPLY_CAPACITY_LEVEL=Normal
	POWER_SUPPLY_TEMP=269
	POWER_SUPPLY_TIME_TO_EMPTY_NOW=1249920
	POWER_SUPPLY_TECHNOLOGY=Li-ion
	POWER_SUPPLY_CHARGE_FULL=6494000
	POWER_SUPPLY_CHARGE_NOW=1736000
	POWER_SUPPLY_CHARGE_FULL_DESIGN=6000000
	POWER_SUPPLY_CYCLE_COUNT=1
	POWER_SUPPLY_POWER_AVG=-20000
	POWER_SUPPLY_HEALTH=Good
	POWER_SUPPLY_MANUFACTURER=Texas Instruments

CASE II : No discharging current:
	POWER_SUPPLY_NAME=bq78z100-0
	POWER_SUPPLY_STATUS=Not charging
	POWER_SUPPLY_PRESENT=1
	POWER_SUPPLY_VOLTAGE_NOW=3386000
	POWER_SUPPLY_CURRENT_NOW=0
	POWER_SUPPLY_CAPACITY=27
	POWER_SUPPLY_CAPACITY_LEVEL=Normal
	POWER_SUPPLY_TEMP=270
	POWER_SUPPLY_TECHNOLOGY=Li-ion
	POWER_SUPPLY_CHARGE_FULL=6494000
	POWER_SUPPLY_CHARGE_NOW=1734000
	POWER_SUPPLY_CHARGE_FULL_DESIGN=6000000
	POWER_SUPPLY_CYCLE_COUNT=1
	POWER_SUPPLY_POWER_AVG=0
	POWER_SUPPLY_HEALTH=Good
	POWER_SUPPLY_MANUFACTURER=Texas Instruments

Signed-off-by: LI Qingwu <Qing-wu.Li@leica-geosystems.com.cn>
Reviewed-by: Krzysztof Kozlowski <krzk@kernel.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2021-03-21 21:29:26 +01:00
Matthias Schiffer c3a6d6a1df power: supply: bq27xxx: make status more robust
There are multiple issues in bq27xxx_battery_status():

- On BQ28Q610 is was observed that the "full" flag may be set even while
  the battery is charging or discharging. With the current logic to make
  "full" override everything else, it look a very long time (>20min) for
  the status to change from "full" to "discharging" after unplugging the
  supply on a device with low power consumption
- The POWER_SUPPLY_STATUS_NOT_CHARGING check depends on
  power_supply_am_i_supplied(), which will not work when the supply
  doesn't exist as a separate device known to Linux

We can solve both issues by deriving the status from the current instead
of the flags field. The flags are now only used to distinguish "full"
from "not charging", and to determine the sign of the current on
BQ27XXX_O_ZERO devices.

Signed-off-by: Matthias Schiffer <matthias.schiffer@ew.tq-group.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2021-03-15 02:26:03 +01:00
Matthias Schiffer c4d57c22ac power: supply: bq27xxx: fix power_avg for newer ICs
On all newer bq27xxx ICs, the AveragePower register contains a signed
value; in addition to handling the raw value as unsigned, the driver
code also didn't convert it to µW as expected.

At least for the BQ28Z610, the reference manual incorrectly states that
the value is in units of 1mW and not 10mW. I have no way of knowing
whether the manuals of other supported ICs contain the same error, or if
there are models that actually use 1mW. At least, the new code shouldn't
be *less* correct than the old version for any device.

power_avg is removed from the cache structure, se we don't have to
extend it to store both a signed value and an error code. Always getting
an up-to-date value may be desirable anyways, as it avoids inconsistent
current and power readings when switching between charging and
discharging.

Signed-off-by: Matthias Schiffer <matthias.schiffer@ew.tq-group.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2021-03-15 02:26:03 +01:00
Matthias Schiffer b67fdcb709 power: supply: bq27xxx: fix sign of current_now for newer ICs
Commit cd060b4d08 ("power: supply: bq27xxx: fix polarity of current_now")
changed the sign of current_now for all bq27xxx variants, but on BQ28Z610
I'm now seeing negated values *with* that patch.

The GTA04/Openmoko device that was used for testing uses a BQ27000 or
BQ27010 IC, so I assume only the BQ27XXX_O_ZERO code path was incorrect.
Revert the behaviour for newer ICs.

Fixes: cd060b4d08 "power: supply: bq27xxx: fix polarity of current_now"
Signed-off-by: Matthias Schiffer <matthias.schiffer@ew.tq-group.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2021-03-15 02:26:03 +01:00