summaryrefslogtreecommitdiff
path: root/drivers/power
AgeCommit message (Collapse)Author
2019-05-15Merge tag 'for-v5.2' of ↵Linus Torvalds
git://git.kernel.org/pub/scm/linux/kernel/git/sre/linux-power-supply Pull power supply and reset updates from Sebastian Reichel: "Core: - Add over-current health state - Add standard, adaptive and custom charge types - Add new properties for start/end charge threshold New Drivers / Hardware: - UCS1002 Programmable USB Port Power Controller - Ingenic JZ47xx Battery Fuel Gauge - AXP20x USB Power: Add AXP813 support - AT91 poweroff: Add SAM9X60 support - OLPC battery: Add XO-1.5 and XO-1.75 support Misc Changes: - syscon-reboot: support mask property - AXP288 fuel gauge: Blacklist ACEPC T8/T11. Looks like some vendor thought it's a good idea to build a desktop system with a fuel gauge, that slowly "discharges"... - cpcap-battery: Fix calculation errors - misc fixes" * tag 'for-v5.2' of git://git.kernel.org/pub/scm/linux/kernel/git/sre/linux-power-supply: (54 commits) power: supply: olpc_battery: force the le/be casts power: supply: ucs1002: Fix build error without CONFIG_REGULATOR power: supply: ucs1002: Fix wrong return value checking power: supply: Add driver for Microchip UCS1002 dt-bindings: power: supply: Add bindings for Microchip UCS1002 power: supply: core: Add POWER_SUPPLY_HEALTH_OVERCURRENT constant power: supply: core: fix clang -Wunsequenced power: supply: core: Add missing documentation for CHARGE_CONTROL_* properties power: supply: core: Add CHARGE_CONTROL_{START_THRESHOLD,END_THRESHOLD} properties power: supply: core: Add Standard, Adaptive, and Custom charge types power: supply: axp288_fuel_gauge: Add ACEPC T8 and T11 mini PCs to the blacklist power: supply: bq27xxx_battery: Notify also about status changes power: supply: olpc_battery: Have the framework register sysfs files for us power: supply: olpc_battery: Add OLPC XO 1.75 support power: supply: olpc_battery: Avoid using platform_info power: supply: olpc_battery: Use devm_power_supply_register() power: supply: olpc_battery: Move priv data to a struct power: supply: olpc_battery: Use DT to get battery version x86/platform/olpc: Use a correct version when making up a battery node x86/platform/olpc: Trivial code move in DT fixup ...
2019-05-14power: supply: olpc_battery: force the le/be castsLubomir Rintel
The endianness of data returned from the EC depends on the particular EC version determined at run time. Cast from little/big endian explicitey in the routine that flips endianness to the native one to make sparse happy. Signed-off-by: Lubomir Rintel <lkundrak@v3.sk> Reported-by: kbuild test robot <lkp@intel.com> Fixes: 76311b9a3295 ("power: supply: olpc_battery: Add OLPC XO 1.75 support") Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-05-10power: supply: ucs1002: Fix build error without CONFIG_REGULATORYueHaibing
Fix gcc build error while CONFIG_REGULATOR is not set drivers/power/supply/ucs1002_power.o: In function `ucs1002_probe': drivers/power/supply/ucs1002_power.c:593: undefined reference to `devm_regulator_register' drivers/power/supply/ucs1002_power.o:(.rodata+0x3b8): undefined reference to `regulator_enable_regmap' drivers/power/supply/ucs1002_power.o:(.rodata+0x3c0): undefined reference to `regulator_disable_regmap' drivers/power/supply/ucs1002_power.o:(.rodata+0x3c8): undefined reference to `regulator_is_enabled_regmap' Add Kconfig dependency to CONFIG_REGULATOR. Reported-by: Hulk Robot <hulkci@huawei.com> Fixes: 9a2688e42638 ("power: supply: Add driver for Microchip UCS1002") Signed-off-by: YueHaibing <yuehaibing@huawei.com> Reviewed-by: Guenter Roeck <linux@roeck-us.net> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-05-09power: supply: ucs1002: Fix wrong return value checkingAxel Lin
Fix wrong return value checking for devm_regulator_register and devm_regmap_init_i2c. This looks like a copy-n-paste mistake. Fixes: 9a2688e42638 ("power: supply: Add driver for Microchip UCS1002") Signed-off-by: Axel Lin <axel.lin@ingics.com> Reviewed-by: Enric Balletbo i Serra <enric.balletbo@collabora.com> Reviewed-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-05-08power: supply: max77650: Add support for battery chargerBartosz Golaszewski
Add basic support for the battery charger for max77650 PMIC. Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com> Reviewed-by: Linus Walleij <linus.walleij@linaro.org> Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.com> Signed-off-by: Lee Jones <lee.jones@linaro.org>
2019-05-03power: supply: Add driver for Microchip UCS1002Andrey Smirnov
Add driver for Microchip UCS1002 Programmable USB Port Power Controller with Charger Emulation. The driver exposed a power supply device to control/monitor various parameter of the device as well as a regulator to allow controlling VBUS line. Signed-off-by: Enric Balletbo Serra <enric.balletbo@collabora.com> Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Reviewed-by: Guenter Roeck <linux@roeck-us.net> Cc: Chris Healy <cphealy@gmail.com> Cc: Lucas Stach <l.stach@pengutronix.de> Cc: Fabio Estevam <festevam@gmail.com> Cc: Guenter Roeck <linux@roeck-us.net> Cc: linux-kernel@vger.kernel.org Cc: linux-pm@vger.kernel.org Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-05-03power: supply: core: Add POWER_SUPPLY_HEALTH_OVERCURRENT constantAndrey Smirnov
Add POWER_SUPPLY_HEALTH_OVERCURRENT constant in order to allow singalling overcurrent condition via power supply health information. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Reviewed-by: Guenter Roeck <linux@roeck-us.net> Cc: Enric Balletbo Serra <enric.balletbo@collabora.com> Cc: Chris Healy <cphealy@gmail.com> Cc: Lucas Stach <l.stach@pengutronix.de> Cc: Fabio Estevam <festevam@gmail.com> Cc: Guenter Roeck <linux@roeck-us.net> Cc: linux-kernel@vger.kernel.org Cc: linux-pm@vger.kernel.org Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-05-02power: supply: core: fix clang -WunsequencedPhong Tran
The increment operator of pointer in be32_to_cpu() is not explicitly. It made the warning from clang: drivers/power/supply/power_supply_core.c:674:36: error: multiple unsequenced modifications to 'list' [-Werror,-Wunsequenced] drivers/power/supply/power_supply_core.c:675:41: error: multiple unsequenced modifications to 'list' [-Werror,-Wunsequenced] Link: https://github.com/ClangBuiltLinux/linux/issues/460 Signed-off-by: Phong Tran <tranmanphong@gmail.com> Reviewed-by: Nick Desaulniers <ndesaulniers@google.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-05-02power: supply: core: Add CHARGE_CONTROL_{START_THRESHOLD,END_THRESHOLD} ↵Nick Crews
properties Add POWER_SUPPLY_PROP_CHARGE_CONTROL_START_THRESHOLD and POWER_SUPPLY_PROP_CHARGE_CONTROL_END_THRESHOLD properties, to expand the existing CHARGE_CONTROL_* properties. I am adding them in order to support a new Chrome OS device, but these properties should be general enough that they can be used on other devices. When the charge_type is "Custom", the charge controller uses the POWER_SUPPLY_PROP_CHARGE_CONTROL_* properties as configuration for some other algorithm. For example, in the use case that I am supporting, this means the battery begins charging when the percentage level drops below POWER_SUPPLY_PROP_CHARGE_CONTROL_START_THRESHOLD and charging ceases when the percentage level goes above POWER_SUPPLY_PROP_CHARGE_CONTROL_END_THRESHOLD. v5 changes: - Add the other missing CHARGE_CONTROL_* properties documentation in a separate commit - Split up adding the charge types and adding the POWER_SUPPLY_PROP_CHARGE_CONTROL_START_THRESHOLD and POWER_SUPPLY_PROP_CHARGE_CONTROL_END_THRESHOLD properties into two different commits. v4 changes: - Add documentation for the new properties, and add documentation for the the previously missing charge_control_limit and charge_control_limit_max properties. Signed-off-by: Nick Crews <ncrews@chromium.org> Reviewed-by: Enric Balletbo i Serra <enric.balletbo@collabora.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-05-02power: supply: core: Add Standard, Adaptive, and Custom charge typesNick Crews
Add "Standard", "Adaptive", and "Custom" modes to the charge_type property, to expand the existing "Trickle" and "Fast" modes. I am adding them in order to support a new Chrome OS device, but these properties should be general enough that they can be used on other devices. The meaning of "Standard" is obvious, but "Adaptive" and "Custom" are more tricky: "Adaptive" means that the charge controller uses some custom algorithm to change the charge type automatically, with no configuration needed. "Custom" means that the charge controller uses the POWER_SUPPLY_PROP_CHARGE_CONTROL_* properties as configuration for some other algorithm. v5 changes: - Split up adding the charge types and adding the POWER_SUPPLY_PROP_CHARGE_CONTROL_START_THRESHOLD and POWER_SUPPLY_PROP_CHARGE_CONTROL_END_THRESHOLD properties into two different commits. v4 changes: - Add documentation for the new properties, and add documentation for the the previously missing charge_control_limit and charge_control_limit_max properties. Signed-off-by: Nick Crews <ncrews@chromium.org> Reviewed-by: Enric Balletbo i Serra <enric.balletbo@collabora.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-05-02power: supply: axp288_fuel_gauge: Add ACEPC T8 and T11 mini PCs to the blacklistHans de Goede
The ACEPC T8 and T11 Cherry Trail Z8350 mini PCs use an AXP288 and as PCs, rather then portables, they does not have a battery. Still for some reason the AXP288 not only thinks there is a battery, it actually thinks it is discharging while the PC is running, slowly going to 0% full, causing userspace to shutdown the system due to the battery being critically low after a while. This commit adds the ACEPC T8 and T11 to the axp288 fuel-gauge driver blacklist, so that we stop reporting bogus battery readings on this device. BugLink: https://bugzilla.redhat.com/show_bug.cgi?id=1690852 Cc: stable@vger.kernel.org Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-05-02power: supply: bq27xxx_battery: Notify also about status changesKrzysztof Kozlowski
User-space might be interested in receiving uevents when the charging starts/stops or if conditions of battery changes (e.g. over-temperature). Notify about changes in battery also when the flags change, not only SoC. Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org> Reviewed-by: Pali Rohár <pali.rohar@gmail.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-05-01Merge tag 'for-v5.1-rc' of ↵Linus Torvalds
git://git.kernel.org/pub/scm/linux/kernel/git/sre/linux-power-supply Pull power supply fixes from Sebastian Reichel: "Two more fixes for the 5.1 cycle. One division by zero fix in a specific driver and one core workaround for bad userspace behaviour from systemd regarding uevents. IMHO this can be considered to be a userspace bug, but the debug messages are useless anyways - cpcap-battery: fix a division by zero - core: fix systemd issue due to log messages produced by uevent" * tag 'for-v5.1-rc' of git://git.kernel.org/pub/scm/linux/kernel/git/sre/linux-power-supply: power: supply: sysfs: prevent endless uevent loop with CONFIG_POWER_SUPPLY_DEBUG power: supply: cpcap-battery: Fix division by zero
2019-04-26power: supply: sysfs: prevent endless uevent loop with CONFIG_POWER_SUPPLY_DEBUGAndrey Smirnov
Fix a similar endless event loop as was done in commit 8dcf32175b4e ("i2c: prevent endless uevent loop with CONFIG_I2C_DEBUG_CORE"): The culprit is the dev_dbg printk in the i2c uevent handler. If this is activated (for instance by CONFIG_I2C_DEBUG_CORE) it results in an endless loop with systemd-journald. This happens if user-space scans the system log and reads the uevent file to get information about a newly created device, which seems fair use to me. Unfortunately reading the "uevent" file uses the same function that runs for creating the uevent for a new device, generating the next syslog entry Both CONFIG_I2C_DEBUG_CORE and CONFIG_POWER_SUPPLY_DEBUG were reported in https://bugs.freedesktop.org/show_bug.cgi?id=76886 but only former seems to have been fixed. Drop debug prints as it was done in I2C subsystem to resolve the issue. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Cc: Chris Healy <cphealy@gmail.com> Cc: linux-pm@vger.kernel.org Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-04-18Merge tag 'psy-olpc-1.75-battery-signed' into psy-nextSebastian Reichel
This immutable branch contains the changes required for OLPC 1.75 battery, which touches x86 and power-supply and is based on v5.1-rc1. Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-04-18power: supply: olpc_battery: Have the framework register sysfs files for usLubomir Rintel
The power framework gained ability to register groups of sysfs attributes in commit cef8fe6a382c ("power: supply: core: add support for custom sysfs attributes"). Signed-off-by: Lubomir Rintel <lkundrak@v3.sk> Suggested-by: Sebastian Reichel <sre@kernel.org> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-04-18power: supply: olpc_battery: Add OLPC XO 1.75 supportLubomir Rintel
The battery and the protocol are essentially the same as OLPC XO 1.5, but the responses from the EC are LSB first. Signed-off-by: Lubomir Rintel <lkundrak@v3.sk> Acked-by: Pavel Machek <pavel@ucw.cz> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-04-18power: supply: olpc_battery: Avoid using platform_infoLubomir Rintel
This wouldn't work on the DT-based ARM platform. Let's read the EC version directly from the EC driver instead. This removes x86 specific bits that would prevent this driver from being used with the EC of ARM-based OLPC XO 1.75. Signed-off-by: Lubomir Rintel <lkundrak@v3.sk> Acked-by: Pavel Machek <pavel@ucw.cz> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-04-18power: supply: olpc_battery: Use devm_power_supply_register()Lubomir Rintel
This simplifies the error handling. Signed-off-by: Lubomir Rintel <lkundrak@v3.sk> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-04-18power: supply: olpc_battery: Move priv data to a structLubomir Rintel
The global variables for private data are not too nice. I'd like some more, and that would clutter the global name space even further. Signed-off-by: Lubomir Rintel <lkundrak@v3.sk> Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-04-18power: supply: olpc_battery: Use DT to get battery versionLubomir Rintel
Avoid using the x86 OLPC platform specific call to get the board version. That wouldn't work on FDT-based ARM MMP2 platform. Add the XO 1.5 compatible string too. This is actually not completely necessary as the battery nodes on XO 1.5 claim to be compatible with "olpc,xo1-battery", but there are, in fact, differencies. Signed-off-by: Lubomir Rintel <lkundrak@v3.sk> Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com> Acked-by: Pavel Machek <pavel@ucw.cz> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-04-18power: supply: add Ingenic JZ47xx battery driver.Artur Rojek
Add a driver for battery present on Ingenic JZ47xx SoCs. Signed-off-by: Artur Rojek <contact@artur-rojek.eu> Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-04-17power: supply: axp20x_usb_power: add support for AXP813Quentin Schulz
This adds support for AXP813 PMIC. It is almost the same as AXP22X but has a different current limit. Signed-off-by: Quentin Schulz <quentin.schulz@bootlin.com> Signed-off-by: Chen-Yu Tsai <wens@csie.org> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-04-17power: supply: axp20x_usb_power: add function to get max currentQuentin Schulz
To prepare for a new PMIC, factor out the code responsible of returning the maximum current to axp20x_get_current_max. Signed-off-by: Quentin Schulz <quentin.schulz@bootlin.com> Signed-off-by: Chen-Yu Tsai <wens@csie.org> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-04-17power: supply: axp20x_usb_power: use polling to detect vbus status changeChen-Yu Tsai
On AXP221 and later AXP PMICs that have the N_VBUSEN pin, when this pin is high, either due to the PMIC driving it high or as an input, the VBUS detection related interrupt mechanisms are disabled. Previously this was worked around in the phy-sun4i-usb driver, which needed to sense VBUS changes and report them to the musb driver in a timely matter. However this workaround was only for the A31 and A33 type USB PHYs. To support newer platforms we would have to enable it for almost all the post-A31 SoCs. However, since this is actually the result of the PMIC's behavior, the workaround would be better if done in the PMIC driver, in this case the VBUS power supply driver. Add the same workqueue-based polling to the VBUS power supply driver. The polling interval is chosen to be the debounce interval from the USB PHY driver, as this short interval is needed in some cases, but the power supply driver would not know when. Signed-off-by: Chen-Yu Tsai <wens@csie.org> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-04-17power: supply: axp20x_usb_power: Fix typo in VBUS current limit macrosChen-Yu Tsai
The VBUS current limit value macros have VBUS typed as VBUC, while the bitmask macro is named correctly. Fix it. Fixes: 69fb4dcada77 ("power: Add an axp20x-usb-power driver") Signed-off-by: Chen-Yu Tsai <wens@csie.org> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-04-17power: supply: core: fix leaked of_node refs in power_supply_get_battery_infoWen Yang
The call to of_parse_phandle returns a node pointer with refcount incremented thus it must be explicitly decremented after the last usage. Detected by coccinelle with the following warnings: ./drivers/power/supply/power_supply_core.c:601:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 595, but without a corresponding object release within this function. ./drivers/power/supply/power_supply_core.c:604:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 595, but without a corresponding object release within this function. ./drivers/power/supply/power_supply_core.c:632:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 595, but without a corresponding object release within this function. ./drivers/power/supply/power_supply_core.c:635:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 595, but without a corresponding object release within this function. ./drivers/power/supply/power_supply_core.c:653:3-9: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 595, but without a corresponding object release within this function. ./drivers/power/supply/power_supply_core.c:664:3-9: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 595, but without a corresponding object release within this function. ./drivers/power/supply/power_supply_core.c:673:1-7: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 595, but without a corresponding object release within this function. Signed-off-by: Wen Yang <wen.yang99@zte.com.cn> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-04-17power: supply: ab8500: fix leaked of_node refs in ab8500_bm_of_probeWen Yang
The call to of_parse_phandle returns a node pointer with refcount incremented thus it must be explicitly decremented after the last usage. 492 int ab8500_bm_of_probe(struct device *dev, 493 struct device_node *np, 494 struct abx500_bm_data *bm) 495 { 496 const struct batres_vs_temp *tmp_batres_tbl; 497 struct device_node *battery_node; ... 501 /* get phandle to 'battery-info' node */ 502 battery_node = of_parse_phandle(np, "battery", 0); ... 509 if (!btech) { 510 dev_warn(dev, "missing property battery-name/type\n"); 511 return -EINVAL; ---> leaked here 512 } ... 540 of_node_put(battery_node); ---> released here 541 542 return 0; 543 } Detected by coccinelle with the following warnings: ./drivers/power/supply/ab8500_bmdata.c:511:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 502, but without a corresponding object release within this function. Signed-off-by: Wen Yang <wen.yang99@zte.com.cn> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-04-15power: supply: cpcap-charger: Fix pointless EPROBE_DEFER warningsTony Lindgren
With loadable modules we may get the following during init: could not initialize VBUS or ID IIO: -517 Let's not print any pointless error messages for deferred probe. 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-15power: supply: cpcap-battery: Fix pointless EPROBE_DEFER warningsTony Lindgren
With loadable modules we may get the following during init: could not initialize VBUS or ID IIO: -517 Let's not print any pointless error messages for deferred probe. 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-15power: supply: cpcap-battery: Use accumulator for current and power averageTony Lindgren
We should not use measured current value for average since we have proper coulomb counter values available. Using measured current value should be only used when the value is queried at a higher rate than the 250 ms rate the coulomb counter is configured to run at. 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-15power: supply: cpcap-battery: Fix coulomb counter calibration register useTony Lindgren
The coulomb counter calibration is not CCO, it's CCM. And the CCM is nine bits wide signed register, so let's use sign_extend32() for it. 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-15power: supply: cpcap-battery: Fix signed counter sample registerTony Lindgren
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-15power: supply: cpcap-battery: Fix low battery checkTony Lindgren
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-15Merge branch 'psy-fixes' into psy-nextSebastian Reichel
Merge fixes branch into next branch for cpcap-battery patches. Signed-off-by: Sebastian Reichel <sre@collabora.com>
2019-04-15power: supply: gpio-charger: Add support for charger status.Artur Rojek
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-15power: supply: core: fix typo in function to get current charge control limitEnric Balletbo i Serra
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-15drivers: power: supply: goldfish_battery: Fix bogus SPDX identifierThomas Gleixner
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: e75e3a125b40 ("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-10power: supply: cpcap-battery: Fix division by zeroTony Lindgren
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: 874b2adbed12 ("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-10power: supply: ltc3651-charger: Fix device name (rename files)Michael Hennerich
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-10power: supply: ltc3651-charger: Fix device nameMichael Hennerich
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-05power: supply: max14656: fix potential use-after-freeSven Van Asbroeck
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-05power: supply: max14656: fix potential use-before-allocSven Van Asbroeck
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-05power: reset: at91-poweroff: add support for SAM9X60Claudiu Beznea
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-05power: reset: at91-poweroff: add RTT wakeup capabilityClaudiu Beznea
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-05power: supply: axp288_charger: Fix unchecked return valueGustavo A. R. Silva
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: 843735b788a4 ("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-05power: supply: Fix the simple battery property namesMaxime Ripard
Commit c08b1f45d7d1 ("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: c08b1f45d7d1 ("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-05power: charger-manager: fix a potential NULL pointer dereferenceKangjie Lu
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-05power: reset: syscon-reboot: add a mask propertyMartin Schiller
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 f2c199db477e ("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-02-20power: reset: at91-reset: add support for sam9x60 SoCNicolas Ferre
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>