Commit graph

1883 commits

Author SHA1 Message Date
Tony Lindgren c68b901ac4 power: supply: cpcap-battery: Fix signed counter sample register
The accumulator sample register is signed 32-bits wide register on
droid 4. And only the earlier version of cpcap has a signed 24-bits
wide register. We're currently passing it around as unsigned, so
let's fix that and use sign_extend32() for the earlier revision.

Signed-off-by: Tony Lindgren <tony@atomide.com>
Acked-by: Pavel Machek <pavel@ucw.cz>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-04-15 22:52:14 +02:00
Tony Lindgren 1a9aadc86a power: supply: cpcap-battery: Fix low battery check
We need to check current instead of the charge counter to see if
a charger is connected. The charge counter shows the cumulated value
instead of the current charge current and can be negative or positive.

Cc: Pavel Machek <pavel@ucw.cz>
Signed-off-by: Tony Lindgren <tony@atomide.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-04-15 22:51:44 +02:00
Sebastian Reichel 6f76aa94e1 Merge branch 'psy-fixes' into psy-next
Merge fixes branch into next branch for cpcap-battery
patches.

Signed-off-by: Sebastian Reichel <sre@collabora.com>
2019-04-15 22:40:29 +02:00
Artur Rojek df68c44c72 power: supply: gpio-charger: Add support for charger status.
Introduce optional support of POWER_SUPPLY_PROP_STATUS for chargers
which provide charging status GPIO.

Signed-off-by: Artur Rojek <contact@artur-rojek.eu>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-04-15 22:07:18 +02:00
Enric Balletbo i Serra 5ec87ecde2 power: supply: core: fix typo in function to get current charge control limit
There is a spelling mistake in ps_get_cur_charge_cntl_limit function so
replace 'chrage' for 'charge'.

Signed-off-by: Enric Balletbo i Serra <enric.balletbo@collabora.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-04-15 21:40:00 +02:00
Thomas Gleixner 2aae471d66 drivers: power: supply: goldfish_battery: Fix bogus SPDX identifier
spdxcheck.py complains:

 drivers/power/supply/goldfish_battery.c: 1:28 Invalid License ID: GPL

which is correct because GPL is not a valid identifier. Of course this
could have been caught by checkpatch.pl _before_ submitting or merging the
patch.

 WARNING: 'SPDX-License-Identifier: GPL' is not supported in LICENSES/...
 #19: FILE: drivers/power/supply/goldfish_battery.c:1:
 +// SPDX-License-Identifier: GPL

Which is absolutely hillarious as the commit introducing this wreckage says
in the changelog:

  There was a checkpatch complain:

    "Missing or malformed SPDX-License-Identifier tag".

Oh well. Replacing a checkpatch warning by a different checkpatch warning
is a really useful exercise.

Use the proper GPL-2.0 identifier which is what the boiler plate in the
file had originally.

Fixes: e75e3a125b ("drivers: power: supply: goldfish_battery: Put an SPDX tag")
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-04-15 11:16:31 +02:00
Tony Lindgren dbe7208c6c power: supply: cpcap-battery: Fix division by zero
If called fast enough so samples do not increment, we can get
division by zero in kernel:

__div0
cpcap_battery_cc_raw_div
cpcap_battery_get_property
power_supply_get_property.part.1
power_supply_get_property
power_supply_show_property
power_supply_uevent

Fixes: 874b2adbed ("power: supply: cpcap-battery: Add a battery driver")
Signed-off-by: Tony Lindgren <tony@atomide.com>
Acked-by: Pavel Machek <pavel@ucw.cz>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-04-10 00:53:20 +02:00
Michael Hennerich d7830ce3c5 power: supply: ltc3651-charger: Fix device name (rename files)
rename only - no functional changes

Signed-off-by: Michael Hennerich <michael.hennerich@analog.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-04-10 00:39:01 +02:00
Michael Hennerich 2e220e6eb3 power: supply: ltc3651-charger: Fix device name
There never was a device called LTC3651, it always was just LT3651.
This circumstance makes it pretty difficult to identify what this
driver is meant to control.channges since

Signed-off-by: Michael Hennerich <michael.hennerich@analog.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-04-10 00:39:01 +02:00
Sven Van Asbroeck 252fbeb86c power: supply: max14656: fix potential use-after-free
Explicitly cancel/sync the irq_work delayed work, otherwise
there's a chance that it will run after the device is removed,
which would result in a use-after-free.

Note that cancel/sync should happen:
- after irq's have been disabled, as the isr re-schedules the work
- before the power supply is unregistered, because the work func
    uses the power supply handle.

Cc: Alexander Kurz <akurz@blala.de>
Signed-off-by: Sven Van Asbroeck <TheSven73@gmail.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-04-05 18:01:38 +02:00
Sven Van Asbroeck 0cd0e49711 power: supply: max14656: fix potential use-before-alloc
Call order on probe():
- max14656_hw_init() enables interrupts on the chip
- devm_request_irq() starts processing interrupts, isr
  could be called immediately
-    isr: schedules delayed work (irq_work)
-    irq_work: calls power_supply_changed()
- devm_power_supply_register() registers the power supply

Depending on timing, it's possible that power_supply_changed()
is called on an unregistered power supply structure.

Fix by registering the power supply before requesting the irq.

Cc: Alexander Kurz <akurz@blala.de>
Signed-off-by: Sven Van Asbroeck <TheSven73@gmail.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-04-05 18:01:38 +02:00
Claudiu Beznea 17d2e876b4 power: reset: at91-poweroff: add support for SAM9X60
Add support for SAM9X60 shutdown controller.

Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com>
Acked-by: Nicolas Ferre <nicolas.ferre@microchip.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-04-05 17:50:55 +02:00
Claudiu Beznea 5c6c513ddb power: reset: at91-poweroff: add RTT wakeup capability
Add RTT wakeup capability.

Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com>
Acked-by: Nicolas Ferre <nicolas.ferre@microchip.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-04-05 17:50:45 +02:00
Gustavo A. R. Silva c3422ad5f8 power: supply: axp288_charger: Fix unchecked return value
Currently there is no check on platform_get_irq() return value
in case it fails, hence never actually reporting any errors and
causing unexpected behavior when using such value as argument
for function regmap_irq_get_virq().

Fix this by adding a proper check, a message reporting any errors
and returning *pirq*

Addresses-Coverity-ID: 1443940 ("Improper use of negative value")
Fixes: 843735b788 ("power: axp288_charger: axp288 charger driver")
Cc: stable@vger.kernel.org
Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-04-05 16:03:44 +02:00
Maxime Ripard f0459fe147 power: supply: Fix the simple battery property names
Commit c08b1f45d7 ("power: supply: core: Add power_supply_battery_info
and API") introduced code to parse the simple-battery node and express
battery charging constraints. However, it parsed that node using the
properties constant_charge_current_max_microamp and
constant_charge_voltage_max_microvolt, while the device tree binding for
the simple-battery node uses dashes to separate the words in those
properties (constant-charge-current-max-microamp and
constant-charge-voltage-max-microvolt).

Let's make the code match the binding.

Fixes: c08b1f45d7 ("power: supply: core: Add power_supply_battery_info and API")
Signed-off-by: Maxime Ripard <maxime.ripard@bootlin.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-04-05 16:00:54 +02:00
Kangjie Lu 75cf4f5aa9 power: charger-manager: fix a potential NULL pointer dereference
In case create_freezable_workqueue fails, the fix return -ENOMEM
to avoid a potential NULL pointer dereference.

Signed-off-by: Kangjie Lu <kjlu@umn.edu>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-04-05 16:00:06 +02:00
Martin Schiller 077d9951f7 power: reset: syscon-reboot: add a mask property
Make the syscon-reboot driver accept value and mask instead of
just value.

Prior to this patch, the property name for the value was 'mask'. If
only the mask property is defined on a node, maintain compatibility
by using it as the value.

This patch is based on commit
f2c199db47 ("power: reset: syscon-poweroff: add a mask property")
and does the same change for the syscon-reboot driver.

Signed-off-by: Martin Schiller <ms@dev.tdt.de>
Acked-by: Rob Herring <robh@kernel.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-04-05 15:06:57 +02:00
Nicolas Ferre 655ab0bc46 power: reset: at91-reset: add support for sam9x60 SoC
Add support for additional reset causes and the proper compatibility
string for sam9x60 SoC. The restart function is the same as the samx7.

Signed-off-by: Nicolas Ferre <nicolas.ferre@microchip.com>
Reviewed-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-02-20 00:41:01 +01:00
Sven Van Asbroeck bf592c56b1 max17042_battery: fix potential use-after-free on device remove
The work which is scheduled on a POR boot is potentially left
pending or running until after the device module is removed,
which could result in a use-after-free.

Fix by registering a cancel/sync callback, which gets executed as
part of standard resource unwinding.

This issue was detected with the help of Coccinelle.

Signed-off-by: Sven Van Asbroeck <TheSven73@gmail.com>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-02-20 00:36:52 +01:00
Artur Rojek 04fb53101e power: supply: core: Add a field to support battery max voltage
Add a field for "voltage_max_design_uv" to present fully charged
battery voltage.

Signed-off-by: Artur Rojek <contact@artur-rojek.eu>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-02-20 00:33:08 +01:00
Arthur Demchenkov 9b2c945f9f bq27x00: use cached flags
The flags were just read by bq27xxx_battery_update(),
no need to read them again.

Signed-off-by: Arthur Demchenkov <spinal.by@gmail.com>
Reviewed-by: Andrew F. Davis <afd@ti.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-02-20 00:26:38 +01:00
Sven Van Asbroeck 74f0aaba7c power: supply: ds2782: fix possible use-after-free on remove
In remove(), use cancel_delayed_work_sync() to cancel the
delayed work. Otherwise there's a chance that this work
will continue to run until after the device has been removed.

While we're here, fix the deallocation order in remove(),
to correspond to the inverse of the probe() allocation
order. This guarantees that any remaining work can run
to completion with all driver structures still intact.

This issue was detected with the help of Coccinelle.

Signed-off-by: Sven Van Asbroeck <TheSven73@gmail.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-02-12 23:27:16 +01:00
Michał Mirosław f83a6ece69 power: supply: bq25890: show max charge current/voltage as configured
Use firmware-provided limits for POWER_SUPPLY_*_MAX properties instead
of chip max values. This will reflect the battery limits as those are
the important ones.

Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-01-23 22:29:45 +01:00
Yuanjiang Yu d3e67c94e8 power: supply: sc27xx: Fix capacity saving function
We found sometimes we can not get the saving capacity to initialize the
battery capacity, the reason is the user area registers are put on power
always-on region, so we need delay some time to wait until values are
updated successfully.

Moreover we also should clear the USER_AREA_CLEAR register after setting
the USER_AREA_SET register, otherwise we can not save the values in the
USER_AREA_SET register.

Signed-off-by: Yuanjiang Yu <yuanjiang.yu@unisoc.com>
Signed-off-by: Baolin Wang <baolin.wang@linaro.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-01-23 21:26:56 +01:00
Baolin Wang 3a28f203c5 power: supply: sc27xx: Fix the incorrect formula when converting capacity to coulomb counter
We should multiply the calibrated current data (cur_1000ma_adc) when
converting current capacity (mAh) to coulomb counter, which can get
an accurate coulomb counter from the fuel gauge controller.

Signed-off-by: Baolin Wang <baolin.wang@linaro.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-01-23 21:26:56 +01:00
Baolin Wang 0a4f97a171 power: supply: sc27xx: Add one property to read charge voltage
Add POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE property to get charge
voltage sampling by ADC controller, which is used to validate if the
charge voltage is in normal range or not in charger manager.

Signed-off-by: Baolin Wang <baolin.wang@linaro.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-01-23 21:26:56 +01:00
Roman Kiryanov 2a7b0a29b3 drivers: power: supply: goldfish_battery: Add support for reading more properties
To comply with tests we need to support more power supply properties:

POWER_SUPPLY_PROP_VOLTAGE_NOW
POWER_SUPPLY_PROP_TEMP
POWER_SUPPLY_PROP_CHARGE_COUNTER
POWER_SUPPLY_PROP_CURRENT_NOW
POWER_SUPPLY_PROP_CURRENT_AVG
POWER_SUPPLY_PROP_CHARGE_FULL
POWER_SUPPLY_PROP_CYCLE_COUNT
POWER_SUPPLY_PROP_VOLTAGE_MAX
POWER_SUPPLY_PROP_CURRENT_MAX

Signed-off-by: Roman Kiryanov <rkir@google.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-01-21 22:31:27 +01:00
Krzysztof Kozlowski 02276af2fc power: supply: charger-manager: Fix trivial language typos
Fix few trivial language typos.

Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-01-20 22:45:08 +01:00
Pavel Machek fd10606f93 cpcap-charger: generate events for userspace
The driver doesn't generate uevents on charger connect/disconnect.
This leads to UPower not detecting when AC is on or off... and that is
bad.

Reported by Arthur D. on github (
https://github.com/maemo-leste/bugtracker/issues/206 ), thanks to
Merlijn Wajer for suggesting a fix.

Cc: stable@kernel.org
Signed-off-by: Pavel Machek <pavel@ucw.cz>
Acked-by: Tony Lindgren <tony@atomide.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-01-20 22:40:27 +01:00
Yangtao Li 19836a1b8e power: supply: remove some duplicated includes
We include of.h twice. It's unnecessary,so
just remove them.

Signed-off-by: Yangtao Li <tiny.windzz@gmail.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-01-20 22:39:23 +01:00
Kangjie Lu 6f12e46eeb power: twl4030: fix a missing check of return value
If twl4030_bci_read() fails, the read data in "s" is incorrect,
which is however used in the following execution. The fix checks
the return value of twl4030_bci_read() and returns an error code
upstream upon the failure of twl4030_bci_read().

Signed-off-by: Kangjie Lu <kjlu@umn.edu>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-01-20 22:38:35 +01:00
Roman Kiryanov 3dcdb68925 drivers: power: supply: goldfish_battery: Use tabs for alignment
Tabs are preferred.

Signed-off-by: Roman Kiryanov <rkir@google.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-01-20 22:29:54 +01:00
Roman Kiryanov 617ee863ed drivers: power: supply: goldfish_battery: Fix alignment
Align two values as other values below.

Signed-off-by: Roman Kiryanov <rkir@google.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-01-20 22:29:36 +01:00
Roman Kiryanov 5fbde356cb drivers: power: supply: goldfish_battery: Retire a redundant variable
The battery_data static variable was not used.

Signed-off-by: Roman Kiryanov <rkir@google.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-01-20 22:29:22 +01:00
Roman Kiryanov 65ab18a1aa drivers: power: supply: goldfish_battery: Fix "line over 80 characters"
There was a line longer than 80 characters.

Signed-off-by: Roman Kiryanov <rkir@google.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-01-20 22:28:54 +01:00
Roman Kiryanov e75e3a125b drivers: power: supply: goldfish_battery: Put an SPDX tag
There was a checkpatch complain:

"Missing or malformed SPDX-License-Identifier tag".

Signed-off-by: Roman Kiryanov <rkir@google.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-01-20 22:28:10 +01:00
Yangtao Li 0367e23425 power: supply: axp288_fuel_gauge: Change to use DEFINE_SHOW_ATTRIBUTE macro
Use DEFINE_SHOW_ATTRIBUTE macro to simplify the code.

Signed-off-by: Yangtao Li <tiny.windzz@gmail.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-01-20 22:21:45 +01:00
Sebastian Reichel f5d782d46a power: supply: isp1704: switch to gpiod API
This migrates isp1704 driver from old GPIO API to new descriptor
based GPIO API and drops useless platform data as a side-effect.

Migration is simple, since all mainline users are DT based and
DT API does not change. Out of tree users of the platform data
need to migrate to gpiod_lookup_table as described here:

Documentation/driver-api/gpio/board.rst

Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Acked-by: Pavel Machek <pavel@ucw.cz>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-01-20 21:57:43 +01:00
Linus Torvalds 579a700359 power supply and reset changes for the v4.21 series
* New core support
  - battery internal resistance
  - battery OCV capacity lookup table
  - support for custom sysfs attributes
 * Convert all drivers to use power-supply core support for custom sysfs attributes
 * bq24190-charger: bq24196 support
 * axp20x-charger: AXP813 support
 * sc27xx-battery: new fuel gauge driver
 * gpio-poweroff: support for specific active and inactive delays
 * Misc fixes
 -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCgAdFiEE72YNB0Y/i3JqeVQT2O7X88g7+poFAlwlThQACgkQ2O7X88g7
 +pqmHg/+PPPeJVIfAAdxFe4KPvP/sAUnAGxqgJc7yeaKOq03eIWnm0JFbEsQLazM
 XDyk+8N7PQ254n2hU/DQln/OKrkVMo/QaOsn3HbbxaDbUiM5Mj8WjKOzgjWtgUy0
 OZOEk6n4SQNx6Ib7Wp/e+H6b/K+EglO5CVZDXmTBJfFKiKp5g4A3ZaUe8bCa1xuG
 4AB3QWQPomtI8o/nD37c4lpegojabUGN8hHI6r9TFT1PaYEzAmOQsb0NnGqEKAUw
 ECPBeH4jVoLN9Bie4u5Fgdr0lqukG+EAEHlHhPRea92oDLFfXEjPOI9JDM4XWBg/
 P47KNuvsVrIAUQ3rnCHUP4aC2ElL0G9bcEyADiLOuw9FIjMMjBm65pyRDORwkH+L
 TAu/28fL2Rzwenk+N8OLZ5lpvYlrqpDFISJkwO7gSGq4wyNW8I62GXJPFAYuSZsf
 dvlEOTgUCwNUnnF2ehx1AkvOBE+eh1CHvtcbKUMLwtBgWOhVi664Gm2znaLy6PwN
 XPkcRCNFIr/FZRuAo1x9GyxYv483Nk+27LcKfwz+HtmHHMRRDHDWtJ/K0KqK/y7a
 7HE7tBhCMpWikIXT1pAz7A0XYlMqfaMsyHlOqmeFgsNUBuDvJAArDz3Gff935PL3
 KGIr4lp+YeTHv6nJT/EMtGIG2dsJZUHh/NAtWZ07usI2fOgE3J4=
 =59iw
 -----END PGP SIGNATURE-----

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

Pull power supply and reset updates from Sebastian Reichel:

 - New core support:
    - battery internal resistance
    - battery OCV capacity lookup table
    - support for custom sysfs attributes

 - Convert all drivers to use power-supply core support for custom sysfs
   attributes

 - bq24190-charger: bq24196 support

 - axp20x-charger: AXP813 support

 - sc27xx-battery: new fuel gauge driver

 - gpio-poweroff: support for specific active and inactive delays

 - Misc fixes

* tag 'for-v4.21' of git://git.kernel.org/pub/scm/linux/kernel/git/sre/linux-power-supply: (53 commits)
  power: supply: bq25890: fix BAT_COMP field definition
  power: supply: gpio-charger: Do not use deprecated POWER_SUPPLY_TYPE_USB_*
  power: supply: ds2781: switch to devm_power_supply_register
  power: supply: ds2780: switch to devm_power_supply_register
  power: supply: ds2781: fix race-condition in bin attribute registration
  power: supply: ds2780: fix race-condition in bin attribute registration
  power: supply: pcf50633: fix race-condition in sysfs registration
  power: supply: charger-manager: fix race-condition in sysfs registration
  power: supply: charger-manager: simplify generation of sysfs attribute group name
  power: supply: bq24257: fix race-condition in sysfs registration
  power: supply: bq24190_charger: fix race-condition in sysfs registration
  power: supply: lp8788: fix race-condition in sysfs registration
  power: supply: ds2781: fix race-condition in sysfs registration
  power: supply: ds2780: fix race-condition in sysfs registration
  power: supply: bq2415x: fix race-condition in sysfs registration
  power: supply: core: add support for custom sysfs attributes
  power: supply: sc27xx: Save last battery capacity
  power: reset: at91-poweroff: move shdwc related data to one structure
  power: supply: sc27xx: Add suspend/resume interfaces
  power: supply: sc27xx: Add fuel gauge low voltage alarm
  ...
2018-12-28 20:22:45 -08:00
Linus Torvalds 030672aea8 Merge tag 'devicetree-for-4.21' of git://git.kernel.org/pub/scm/linux/kernel/git/robh/linux
Pull Devicetree updates from Rob Herring:
 "The biggest highlight here is the start of using json-schema for DT
  bindings. Being able to validate bindings has been discussed for years
  with little progress.

   - Initial support for DT bindings using json-schema language. This is
     the start of converting DT bindings from free-form text to a
     structured format.

   - Reworking of initrd address initialization. This moves to using the
     phys address instead of virt addr in the DT parsing code. This
     rework was motivated by CONFIG_DEV_BLK_INITRD causing unnecessary
     rebuilding of lots of files.

   - Fix stale phandle entries in phandle cache

   - DT overlay validation improvements. This exposed several memory
     leak bugs which have been fixed.

   - Use node name and device_type helper functions in DT code

   - Last remaining conversions to using %pOFn printk specifier instead
     of device_node.name directly

   - Create new common RTC binding doc and move all trivial RTC devices
     out of trivial-devices.txt.

   - New bindings for Freescale MAG3110 magnetometer, Cadence Sierra
     PHY, and Xen shared memory

   - Update dtc to upstream version v1.4.7-57-gf267e674d145"

* tag 'devicetree-for-4.21' of git://git.kernel.org/pub/scm/linux/kernel/git/robh/linux: (68 commits)
  of: __of_detach_node() - remove node from phandle cache
  of: of_node_get()/of_node_put() nodes held in phandle cache
  gpio-omap.txt: add reg and interrupts properties
  dt-bindings: mrvl,intc: fix a trivial typo
  dt-bindings: iio: magnetometer: add dt-bindings for freescale mag3110
  dt-bindings: Convert trivial-devices.txt to json-schema
  dt-bindings: arm: mrvl: amend Browstone compatible string
  dt-bindings: arm: Convert Tegra board/soc bindings to json-schema
  dt-bindings: arm: Convert ZTE board/soc bindings to json-schema
  dt-bindings: arm: Add missing Xilinx boards
  dt-bindings: arm: Convert Xilinx board/soc bindings to json-schema
  dt-bindings: arm: Convert VIA board/soc bindings to json-schema
  dt-bindings: arm: Convert ST STi board/soc bindings to json-schema
  dt-bindings: arm: Convert SPEAr board/soc bindings to json-schema
  dt-bindings: arm: Convert CSR SiRF board/soc bindings to json-schema
  dt-bindings: arm: Convert QCom board/soc bindings to json-schema
  dt-bindings: arm: Convert TI nspire board/soc bindings to json-schema
  dt-bindings: arm: Convert TI davinci board/soc bindings to json-schema
  dt-bindings: arm: Convert Calxeda board/soc bindings to json-schema
  dt-bindings: arm: Convert Altera board/soc bindings to json-schema
  ...
2018-12-28 20:08:34 -08:00
Michał Mirosław 9580913966 power: supply: bq25890: fix BAT_COMP field definition
According to datasheet, BAT_COMP field spans bits 5-7. The rest of the
code seems to assume this already.

Fixes: 4aeae9cb0d ("power_supply: Add support for TI BQ25890 charger chip")
Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2018-12-18 00:21:16 +01:00
Sebastian Reichel fb4d494480 power: supply: gpio-charger: Do not use deprecated POWER_SUPPLY_TYPE_USB_*
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2018-12-13 00:17:01 +01:00
Sebastian Reichel fbd17e58d4 power: supply: ds2781: switch to devm_power_supply_register
Simplify/Cleanup the driver by switching to devm_power_supply_register
and dropping the driver's remove function.

Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2018-12-13 00:16:56 +01:00
Sebastian Reichel 63fac6cb63 power: supply: ds2780: switch to devm_power_supply_register
Simplify/Cleanup the driver by switching to devm_power_supply_register
and dropping the driver's remove function.

Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2018-12-13 00:16:47 +01:00
Sebastian Reichel 711aebcfe3 power: supply: ds2781: fix race-condition in bin attribute registration
This is a follow-up patch to the previous one, which fixed a
race-condition during registration of the attribute group.
This fixes the same issue for the binary attributes by adding
them to the properly registered group. As a side effect the
code is further cleaned up.

Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2018-12-13 00:16:39 +01:00
Sebastian Reichel 88635b6da8 power: supply: ds2780: fix race-condition in bin attribute registration
This is a follow-up patch to the previous one, which fixed a
race-condition during registration of the attribute group.
This fixes the same issue for the binary attributes by adding
them to the properly registered group. As a side effect the
code is further cleaned up.

Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2018-12-13 00:16:31 +01:00
Sebastian Reichel 451ba0e436 power: supply: pcf50633: fix race-condition in sysfs registration
This registers custom sysfs properties using the native functionality
of the power-supply framework, which cleans up the code a bit and
fixes a race-condition. Before this patch the sysfs attributes were
not properly registered to udev.

Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2018-12-13 00:16:24 +01:00
Sebastian Reichel 157ba1bb5f power: supply: charger-manager: fix race-condition in sysfs registration
This registers custom sysfs properties using the native functionality
of the power-supply framework, which cleans up the code a bit and
fixes a race-condition. Before this patch the sysfs attributes were
not properly registered to udev.

Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2018-12-13 00:16:20 +01:00
Sebastian Reichel efcca6bdfb power: supply: charger-manager: simplify generation of sysfs attribute group name
This is a simple cleanup and there should be no functional changes.

Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2018-12-13 00:16:16 +01:00
Sebastian Reichel 750688c7cd power: supply: bq24257: fix race-condition in sysfs registration
This registers custom sysfs properties using the native functionality
of the power-supply framework, which cleans up the code a bit and
fixes a race-condition. Before this patch the sysfs attributes were
not properly registered to udev.

Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2018-12-13 00:16:12 +01:00
Sebastian Reichel 348a3c079b power: supply: bq24190_charger: fix race-condition in sysfs registration
This registers custom sysfs properties using the native functionality
of the power-supply framework, which cleans up the code a bit and
fixes a race-condition. Before this patch the sysfs attributes were
not properly registered to udev.

Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2018-12-13 00:16:08 +01:00
Sebastian Reichel b1f7ee898b power: supply: lp8788: fix race-condition in sysfs registration
This registers custom sysfs properties using the native functionality
of the power-supply framework, which cleans up the code a bit and
fixes a race-condition. Before this patch the sysfs attributes were
not properly registered to udev.

Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2018-12-13 00:16:02 +01:00
Sebastian Reichel a45cefb0ca power: supply: ds2781: fix race-condition in sysfs registration
This registers custom sysfs properties using the native functionality
of the power-supply framework, which cleans up the code a bit and
fixes a race-condition. Before this patch the sysfs attributes were
not properly registered to udev.

Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2018-12-13 00:15:47 +01:00
Sebastian Reichel b10474aafe power: supply: ds2780: fix race-condition in sysfs registration
This registers custom sysfs properties using the native functionality
of the power-supply framework, which cleans up the code a bit and
fixes a race-condition. Before this patch the sysfs attributes were
not properly registered to udev.

Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2018-12-13 00:15:42 +01:00
Sebastian Reichel 06215ce999 power: supply: bq2415x: fix race-condition in sysfs registration
This registers custom sysfs properties using the native functionality
of the power-supply framework, which cleans up the code a bit and
fixes a race-condition. Before this patch the sysfs attributes were
not properly registered to udev.

Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2018-12-13 00:15:21 +01:00
Sebastian Reichel cef8fe6a38 power: supply: core: add support for custom sysfs attributes
Add functionality to setup device specific sysfs attributes
in a race condition free manner

Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2018-12-13 00:15:06 +01:00
Nishanth Menon f9dca0f067 PM / AVS: SmartReflex: Switch to SPDX Licence ID
Fix up licensing to be inline with Linux conventions.

Signed-off-by: Nishanth Menon <nm@ti.com>
Acked-by: Kevin Hilman <khilman@baylibre.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2018-12-12 13:54:28 +01:00
Thomas Meyer 14d338a857 PM / AVS: SmartReflex: NULL check before some freeing functions is not needed
NULL check before some freeing functions is not needed.

Signed-off-by: Thomas Meyer <thomas@m3y3r.de>
Reviewed-by: Kevin Hilman <khilman@baylibre.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2018-12-12 13:54:05 +01:00
Rafael J. Wysocki c76aa32207 Merge back staging AVS changes for v4.21. 2018-12-11 12:02:46 +01:00
Yuanjiang Yu 4a040e7c72 power: supply: sc27xx: Save last battery capacity
Our charger manager can optimize the battery capacity periodically, so
we can save last battery capacity into registers. Then next system
power-on, we can read the last saved battery capacity as the initial
battery capacity, which can make the battery capacity more accurate.

Signed-off-by: Yuanjiang Yu <yuanjiang.yu@unisoc.com>
Signed-off-by: Baolin Wang <baolin.wang@linaro.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2018-12-06 22:24:39 +01:00
Claudiu Beznea caa6e150f8 power: reset: at91-poweroff: move shdwc related data to one structure
Move SHDWC realted data to only one structure to have them grouped.
Inspired from commit 9be74f0d39 ("power: reset: at91-poweroff: make
mpddrc_base part of struct shdwc").

Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2018-12-06 21:56:37 +01:00
Yuanjiang Yu e2fb615b69 power: supply: sc27xx: Add suspend/resume interfaces
Add fuel gauge platform suspend and resume interfaces. In suspend state,
we should enable the low voltage and coulomb counter threshold interrupts
to wake up system to calibrate the battery capacity in lower voltage stage.

Signed-off-by: Yuanjiang Yu <yuanjiang.yu@unisoc.com>
Signed-off-by: Baolin Wang <baolin.wang@linaro.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2018-12-06 01:04:30 +01:00
Yuanjiang Yu edcb1c0a3f power: supply: sc27xx: Add fuel gauge low voltage alarm
Add low voltage alarm support to make sure the battery capacity
more accurate in lower voltage stage.

Signed-off-by: Yuanjiang Yu <yuanjiang.yu@unisoc.com>
Signed-off-by: Baolin Wang <baolin.wang@linaro.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2018-12-06 01:04:30 +01:00
Baolin Wang 65c9fab7bc power: supply: sc27xx: Add fuel gauge calibration
This patch adds support to read calibration values from the eFuse controller
to calibrate the ADC values corresponding to current and voltage, which can
make the current and voltage data more accurate.

Signed-off-by: Baolin Wang <baolin.wang@linaro.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2018-12-06 00:54:22 +01:00
Baolin Wang 872bcf83ec power: supply: sc2731_charger: Free battery information
Free battery information in case of adding battery OCV tables.

Signed-off-by: Baolin Wang <baolin.wang@linaro.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2018-12-05 23:54:01 +01:00
Baolin Wang a8aaff6be0 power: supply: sc2731_charger: Avoid repeated charge/discharge
Add info->charging validation to avoid repeated charge or discharge
operation.

Signed-off-by: Baolin Wang <baolin.wang@linaro.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2018-12-05 23:53:14 +01:00
Baolin Wang 18c807dbf9 power: supply: sc2731_charger: Add charger status detection
The USB charger status can be notified before the charger driver registers
the USB phy notifier, so we should check the charger status in probe() in
case we missed the USB charger notification.

Signed-off-by: Baolin Wang <baolin.wang@linaro.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2018-12-05 23:51:58 +01:00
Baolin Wang 8ac1091ed1 power: supply: sc2731_charger: Add one work to charge/discharge
Since the USB notifier context is atomic, we can not start or stop charging
in atomic context. Thus this patch adds one work to help to charge or
discharge.

Signed-off-by: Baolin Wang <baolin.wang@linaro.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2018-12-05 23:48:17 +01:00
Claudiu.Beznea@microchip.com e6ae9a05a4 power: reset: at91-poweroff: remove at91_ramc_of_match
Remove at91_ramc_of_match[] since it is not used anywhere in this code.

Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2018-12-05 23:29:57 +01:00
Claudiu.Beznea@microchip.com 996463fdb8 power: reset: at91-poweroff: use one poweroff function for at91-poweroff
Use only one poweroff function and adapt it to work for both scenarios
(with LPDDR or not). The assignement of pm_power_off was moved at the
end of probe after all initializations are OK. This patch adapt the idea
from commit 4e018c1e9b ("power: reset: at91-poweroff: use only one
poweroff function").

Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2018-12-05 23:18:30 +01:00
Heiko Stuebner d0717d73be power: supply: bq24190_charger: add support for bq24196 variant
The bq24196 is another variant of the bq24190 charger ic.
Its register set is identical to the bq24192 and it even reuses
the same part number (0x5).

Signed-off-by: Heiko Stuebner <heiko.stuebner@bq.com>
Reviewed-by: Rob Herring <robh@kernel.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2018-12-05 22:57:56 +01:00
Brian Masney 161a2135e0 power: supply: bq24190_charger: add extcon support for USB OTG
Add extcon support so that we can notify USB drivers of cable state
changes. Based on work from Jonathan Marek. USB OTG was tested on a LG
Nexus 5 (hammerhead) phone.

Signed-off-by: Brian Masney <masneyb@onstation.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2018-12-05 22:53:32 +01:00
Jonathan Marek 74d09c927c power: supply: bq24190_charger: add of_match for usb-otg-vbus regulator
This patch adds an of_match for the usb-otg-vbus regulator to
bq24190_charger.

Signed-off-by: Jonathan Marek <jonathan@marek.ca>
Signed-off-by: Brian Masney <masneyb@onstation.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2018-12-05 22:52:05 +01:00
Jonathan Marek 5ea67bb0b0 power: supply: bq24190_charger: add support for bq24192 variant
This patch adds support for the bq24192 variant to bq24190_charger.

Signed-off-by: Jonathan Marek <jonathan@marek.ca>
[masneyb@onstation.org: Changed if statement to a switch based on
feedback from Sebastian Reichel.]
Signed-off-by: Brian Masney <masneyb@onstation.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2018-12-05 22:51:58 +01:00
Alexandre Belloni 9afe62509b power: reset: ocelot: switch the SI to boot mode
Switch the SI to boot mode so on a warm reboot, the SI is able to access
the flash.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2018-12-05 22:40:25 +01:00
Heiko Stuebner 76ee875c2f power: reset: gpio-poweroff: add ability to specific active and inactive delays
Similar to gpio-reset allow to specify active and inactive delays
while keeping the 100ms defaults that were used previously all the time.

The dt-properties are named the same as in gpio-reset but get an "-ms"
suffix as properties should contain such a suffix specifying its unit.

Signed-off-by: Heiko Stuebner <heiko.stuebner@bq.com>
Reviewed-by: Rob Herring <robh@kernel.org>
Reviewed-by: Moritz Fischer <mdf@kernel.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2018-12-05 22:38:29 +01:00
Baolin Wang a53a68cee8 power: supply: charger-manager: Make code more readable
Make code more readable.

Signed-off-by: Baolin Wang <baolin.wang@linaro.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2018-12-05 21:25:44 +01:00
Baolin Wang f25a646fbe power: supply: charger-manager: Fix incorrect return value
Fix incorrect return value.

Signed-off-by: Baolin Wang <baolin.wang@linaro.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2018-12-05 21:25:01 +01:00
Baolin Wang 8c13b6f18a power: supply: charger-manager: Fix some misspelled words
Fix some misspelled words.

Signed-off-by: Baolin Wang <baolin.wang@linaro.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2018-12-05 21:24:37 +01:00
Baolin Wang 1dd3509929 power: supply: charger-manager: Remove unused index counting
Remove unused index counting.

Signed-off-by: Baolin Wang <baolin.wang@linaro.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2018-12-05 21:24:21 +01:00
Colin Ian King 80fca773bf power: supply: cpcap-charger: clean an indentation issue, remove tab
Trivial fix to clean up indentation issue, remove an extraneous tab

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2018-12-05 19:02:11 +01:00
Sebastian Reichel 8f01c45a0f Immutable branch between mfd and power-supply for driver
changes related to axp813.
 
 Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
 -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCgAdFiEE72YNB0Y/i3JqeVQT2O7X88g7+poFAlwIEC4ACgkQ2O7X88g7
 +pr0FQ//YwW7NxbxgNsYH2z7tLUct5LgElj3HGVFO++OJGe+cEh4jDdNUqfjGhyb
 ww5NkRZuUBZSqKoGukAARAbTH/gYQloNQV2C6EEk/AULYPkIG84tBRtDv2INBHxM
 InoHLEvNZ4n4lDzmNzwjaUxxfUoRwFj1Rz1+dAYzuoC6ImFYqzwEuggwI9cRLd6h
 hCVIh7lasGLQ9aCX04agE53ki4t52PGn8klRNUhdRS5T944g/8a1pdMoHT7faCFA
 hbIMrC9LdEgUCdOkWwYGa87wfz1+DNfwTY7DC+/2P3ItGh8cV/w1Hi3IK6XRPVDY
 1Gp6RYNtmB+EX2j0lSOvf6uUFx/YKbDkyJZlZY75ZLK/hb8Rl+RDIX8WQKA1tdAY
 ie/8+DOSdnT+pQH1xGg+615fTnGWAK0W0rUaZdAmCwlBEfusBt2mtjOhuRuGXpSS
 hua3KIZqX7FIKtcnPZ6dZ6oYKABgcEkUjap74F2Vc0sUFsrHv5BTR1/tiwmrNvnA
 mD05Y9ApcEAA9TK9SAUOHRkvfS7fogBXjZqtKWB0BLHDZZQKZtItvzjx6R1tQaQs
 5Vl19AIdeIjcnHPUKj8B7KtZk5LbdlvEiarxMbEVrijjh49K6gPr1PrvGTD74zuN
 yafd7sRA2d8T1fSBkeNUTaJcEjRX7Q4IBmacVnFks/teynz6jhg=
 =FoKv
 -----END PGP SIGNATURE-----

Merge tag 'psy-mfd-axp813-immutable-for-v4.21-signed' into psy-next

Immutable branch between mfd and power-supply for driver
changes related to axp813.

Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2018-12-05 18:52:09 +01:00
Oskari Lemmela 7693b5643f power: supply: add AC power supply driver for AXP813
AXP813 and AXP803 PMICs can control input current and minimum voltage.

Both of these values are configurable.

Signed-off-by: Oskari Lemmela <oskari@lemmela.net>
Reviewed-by: Quentin Schulz <quentin.schulz@bootlin.com>
Reviewed-by: Chen-Yu Tsai <wens@csie.org>
Acked-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2018-12-05 18:49:32 +01:00
Olliver Schinagl a95761d6d2 power: supply: axp288: use the BIT() macro
Make use of the recommended BIT() macro for bit defines.

Signed-off-by: Olliver Schinagl <oliver@schinagl.nl>
Signed-off-by: Priit Laes <plaes@plaes.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2018-12-05 18:39:56 +01:00
Olliver Schinagl 57428f6f8a power: supply: axp20x: add missing include bitops.h
The axp20x_usb_power driver uses BIT() operations but lacks the include
for it. Include the bitops.h header file.

Signed-off-by: Olliver Schinagl <oliver@schinagl.nl>
Signed-off-by: Priit Laes <plaes@plaes.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2018-12-05 18:39:00 +01:00
Colin Ian King bd82ef0838 power: supply: cpcap-battery: make array cpcap_battery_irqs static, shrinks object size
Don't populate the array cpcap_battery_irqs  on the stack but instead
make it static. Makes the object code smaller by 99 bytes:

Before:
   text	   data	    bss	    dec	    hex	filename
  13673	   2448	      0	  16121	   3ef9	cpcap-battery.o

After:
   text	   data	    bss	    dec	    hex	filename
  13510	   2512	      0	  16022	   3e96	cpcap-battery.o

(gcc version 8.2.0 x86_64)

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2018-12-05 00:24:36 +01:00
Rob Herring e31d0fc6fd power: reset: Convert to using %pOFn instead of device_node.name
In preparation to remove the node name pointer from struct device_node,
convert printf users to use the %pOFn format specifier.

Cc: Sebastian Reichel <sre@kernel.org>
Cc: linux-pm@vger.kernel.org
Signed-off-by: Rob Herring <robh@kernel.org>
2018-11-27 10:55:38 -06:00
Lubomir Rintel ed54ffbe55 power: supply: olpc_battery: correct the temperature units
According to [1] and [2], the temperature values are in tenths of degree
Celsius. Exposing the Celsius value makes the battery appear on fire:

  $ upower -i /org/freedesktop/UPower/devices/battery_olpc_battery
  ...
      temperature:         236.9 degrees C

Tested on OLPC XO-1 and OLPC XO-1.75 laptops.

[1] include/linux/power_supply.h
[2] Documentation/power/power_supply_class.txt

Fixes: fb972873a7 ("[BATTERY] One Laptop Per Child power/battery driver")
Cc: stable@vger.kernel.org
Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
Acked-by: Pavel Machek <pavel@ucw.cz>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2018-11-19 14:14:46 +01:00
Randy Dunlap ed60f43d01 power/supply: fix sc27xx_fuel_gauge build errors
Fix build errors when FUEL_GUAGE_SC27XX is enabled but IIO is either
not enabled or IIO=m and FUEL_GUAGE_SC27XX=y.

ld: drivers/power/supply/sc27xx_fuel_gauge.o: in function `sc27xx_fgu_get_temp':
sc27xx_fuel_gauge.c:(.text+0x1d2): undefined reference to `iio_read_channel_processed'
ld: drivers/power/supply/sc27xx_fuel_gauge.o: in function `sc27xx_fgu_probe':
sc27xx_fuel_gauge.c:(.text+0x97f): undefined reference to `devm_iio_channel_get'

Signed-off-by: Randy Dunlap <rdunlap@infradead.org>
Cc: linux-pm@vger.kernel.org
Acked-by: Baolin Wang <baolin.wang@linaro.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2018-11-13 03:03:21 +01:00
Baolin Wang 195ca17037 power: supply: Add Spreadtrum SC27XX fuel gauge unit driver
This patch adds the Spreadtrum SC27XX serial PMICs fuel gauge support,
which is used to calculate the battery capacity.

Original-by: Yuanjiang Yu <yuanjiang.yu@unisoc.com>
Signed-off-by: Baolin Wang <baolin.wang@linaro.org>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2018-11-09 22:55:46 +01:00
Baolin Wang 3afb50d712 power: supply: core: Add some helpers to use the battery OCV capacity table
We have introduced some battery properties to present the OCV table
temperatures and OCV capacity table values. Thus this patch add OCV
temperature and OCV table for battery information, as well as providing
some helper functions to use the OCV capacity table for users.

Signed-off-by: Baolin Wang <baolin.wang@linaro.org>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2018-11-09 22:55:46 +01:00
Baolin Wang 86131d933f power: supply: core: Add one field to present the battery internal resistance
Add one field for 'struct power_supply_battery_info' to present the battery
factory internal resistance.

Signed-off-by: Baolin Wang <baolin.wang@linaro.org>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2018-11-09 22:55:46 +01:00
Linus Torvalds b27186abb3 Devicetree updates for 4.20:
- Sync dtc with upstream version v1.4.7-14-gc86da84d30e4
 
 - Work to get rid of direct accesses to struct device_node name and
   type pointers in preparation for removing them. New helpers for
   parsing DT cpu nodes and conversions to use the helpers. printk
   conversions to %pOFn for printing DT node names. Most went thru
   subystem trees, so this is the remainder.
 
 - Fixes to DT child node lookups to actually be restricted to child
   nodes instead of treewide.
 
 - Refactoring of dtb targets out of arch code. This makes the support
   more uniform and enables building all dtbs on c6x, microblaze, and
   powerpc.
 
 - Various DT binding updates for Renesas r8a7744 SoC
 
 - Vendor prefixes for Facebook, OLPC
 
 - Restructuring of some ARM binding docs moving some peripheral bindings
   out of board/SoC binding files
 
 - New "secure-chosen" binding for secure world settings on ARM
 
 - Dual licensing of 2 DT IRQ binding headers
 -----BEGIN PGP SIGNATURE-----
 
 iQJEBAABCgAuFiEEktVUI4SxYhzZyEuo+vtdtY28YcMFAlvTKWYQHHJvYmhAa2Vy
 bmVsLm9yZwAKCRD6+121jbxhw8J5EACMAnrTxWQmXfQXOZEVxztcFavH6LP8mh2e
 7FZIZ38jzHXXvl81tAg1nBhzFUU/qtvqW8NDCZ9OBxKvp6PFDNhWu241ZodSB1Kw
 MZWy2A9QC+qbHYCC+SB5gOT0+Py3v7LNCBa5/TxhbFd35THJM8X0FP7gmcCGX593
 9Ml1rqawT4mK5XmCpczT0cXxyC4TgVtpfDWZH2KgJTR/kwXVQlOQOGZ8a1y/wrt7
 8TLIe7Qy4SFRzjhwbSta1PUehyYfe4uTSsXIJ84kMvNMxinLXQtvd7t9TfsK8p/R
 WjYUneJskVjtxVrMQfdV4MxyFL1YEt2mYcr0PMKIWxMCgGDAZsHPoUZmjyh/PrCI
 uiZtEHn3fXpUZAV/xEHHNirJxYyQfHGiksAT+lPrUXYYLCcZ3ZmqiTEYhGoQAfH5
 CQPMuxA6yXxp6bov6zJwZSTZtkXciju8aQRhUhlxIfHTqezmGYeql/bnWd+InNuR
 upANLZBh6D2jTWzDyobconkCCLlVkSqDoqOx725mMl6hIcdH9d2jVX7hwRf077VI
 5i3CyPSJOkSOLSdB8bAPYfBoaDtH2bthxieUrkkSbIjbwHO1H6a2lxPeG/zah0a3
 ePMGhi7J84UM4VpJEi000cP+bhPumJtJrG7zxP7ldXdfAF436sQ6KRptlcpLpj5i
 IwMhUQNH+g==
 =335v
 -----END PGP SIGNATURE-----

Merge tag 'devicetree-for-4.20' of git://git.kernel.org/pub/scm/linux/kernel/git/robh/linux

Pull Devicetree updates from Rob Herring:
 "A bit bigger than normal as I've been busy this cycle.

  There's a few things with dependencies and a few things subsystem
  maintainers didn't pick up, so I'm taking them thru my tree.

  The fixes from Johan didn't get into linux-next, but they've been
  waiting for some time now and they are what's left of what subsystem
  maintainers didn't pick up.

  Summary:

   - Sync dtc with upstream version v1.4.7-14-gc86da84d30e4

   - Work to get rid of direct accesses to struct device_node name and
     type pointers in preparation for removing them. New helpers for
     parsing DT cpu nodes and conversions to use the helpers. printk
     conversions to %pOFn for printing DT node names. Most went thru
     subystem trees, so this is the remainder.

   - Fixes to DT child node lookups to actually be restricted to child
     nodes instead of treewide.

   - Refactoring of dtb targets out of arch code. This makes the support
     more uniform and enables building all dtbs on c6x, microblaze, and
     powerpc.

   - Various DT binding updates for Renesas r8a7744 SoC

   - Vendor prefixes for Facebook, OLPC

   - Restructuring of some ARM binding docs moving some peripheral
     bindings out of board/SoC binding files

   - New "secure-chosen" binding for secure world settings on ARM

   - Dual licensing of 2 DT IRQ binding headers"

* tag 'devicetree-for-4.20' of git://git.kernel.org/pub/scm/linux/kernel/git/robh/linux: (78 commits)
  ARM: dt: relicense two DT binding IRQ headers
  power: supply: twl4030-charger: fix OF sibling-node lookup
  NFC: nfcmrvl_uart: fix OF child-node lookup
  net: stmmac: dwmac-sun8i: fix OF child-node lookup
  net: bcmgenet: fix OF child-node lookup
  drm/msm: fix OF child-node lookup
  drm/mediatek: fix OF sibling-node lookup
  of: Add missing exports of node name compare functions
  dt-bindings: Add OLPC vendor prefix
  dt-bindings: misc: bk4: Add device tree binding for Liebherr's BK4 SPI bus
  dt-bindings: thermal: samsung: Add SPDX license identifier
  dt-bindings: clock: samsung: Add SPDX license identifiers
  dt-bindings: timer: ostm: Add R7S9210 support
  dt-bindings: phy: rcar-gen2: Add r8a7744 support
  dt-bindings: can: rcar_can: Add r8a7744 support
  dt-bindings: timer: renesas, cmt: Document r8a7744 CMT support
  dt-bindings: watchdog: renesas-wdt: Document r8a7744 support
  dt-bindings: thermal: rcar: Add device tree support for r8a7744
  Documentation: dt: Add binding for /secure-chosen/stdout-path
  dt-bindings: arm: zte: Move sysctrl bindings to their own doc
  ...
2018-10-26 12:09:58 -07:00
Johan Hovold 9844fb2e35 power: supply: twl4030-charger: fix OF sibling-node lookup
Use the new of_get_compatible_child() helper to lookup the usb sibling
node instead of using of_find_compatible_node(), which searches the
entire tree from a given start node and thus can return an unrelated
(non-sibling) node.

This also addresses a potential use-after-free (e.g. after probe
deferral) as the tree-wide helper drops a reference to its first
argument (i.e. the parent device node).

While at it, also fix the related phy-node reference leak.

Fixes: f5e4edb8c8 ("power: twl4030_charger: find associated phy by more reliable means.")
Cc: stable <stable@vger.kernel.org>     # 4.2
Cc: NeilBrown <neilb@suse.de>
Cc: Felipe Balbi <felipe.balbi@linux.intel.com>
Cc: Sebastian Reichel <sre@kernel.org>
Reviewed-by: Sebastian Reichel <sre@kernel.org>
Signed-off-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Rob Herring <robh@kernel.org>
2018-10-23 13:28:53 -05:00
Gustavo A. R. Silva cfb347979e power: max8925: mark expected switch fall-through
In preparation to enabling -Wimplicit-fallthrough, mark switch cases
where we are expecting to fall through.

Addresses-Coverity-ID: 201510 ("Missing break in switch")
Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2018-10-21 21:33:35 +02:00
Colin Ian King 415d602b22 power: supply: fix spelling mistake "Gauage" -> "Gauge"
Trivial fix to spelling mistake in MODULE_DESCRIPTION text

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2018-10-21 21:32:44 +02:00
Uwe Kleine-König 2d12df47ea PM / AVS: SmartReflex: remove unused function
omap_sr_register_pmic() was introduced in 2010 in commit

	984aa6dbf4 ("OMAP3: PM: Adding smartreflex driver support.")

. There was never any caller of this function in mainline resulting in a
warning

	sr_init: No PMIC hook to init smartreflex

for each machine where this driver is enabled. So remove the unused
function and the pr_warn.

Signed-off-by: Uwe Kleine-König <uwe@kleine-koenig.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2018-10-09 09:50:19 +02:00
Vinod Koul a4ac1f5ced power: reset: qcom-pon: Add pms405 pon support
Update the binding and driver for pms405 pon.

Signed-off-by: Vinod Koul <vkoul@kernel.org>
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2018-09-20 11:40:00 +02:00
Liu Xiang 457b42f0aa power: supply: bq27xxx: Add support for BQ27411
According to the datasheet, bq27411 is similar to bq27421.

Signed-off-by: Liu Xiang <liu.xiang6@zte.com.cn>
Reviewed-by: Andrew F. Davis <afd@ti.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2018-09-20 11:35:40 +02:00
Baolin Wang 1c3d7b0364 power: supply: Add Spreadtrum SC2731 charger support
This patch adds the SC2731 PMIC switch charger support.

Signed-off-by: Baolin Wang <baolin.wang@linaro.org>
Reviewed-by: Krzysztof Kozlowski <krzk@kernel.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2018-09-20 02:58:08 +02:00