Commit graph

314 commits

Author SHA1 Message Date
Linus Torvalds 3ac684b881 power supply and reset changes for the v4.17 series
* Microsemi Ocelot reset support
 * Spreadtrum SC27xx reset support
 * generic gpio charger: lot's of cleanups
 * axp20x fuel gauge: add AXP813 support
 * misc. fixes
 -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCgAdFiEE72YNB0Y/i3JqeVQT2O7X88g7+poFAlrCZVQACgkQ2O7X88g7
 +ppKgQ/8Cmgfta6nX5N8U3jAbBmduFkxmV+WaVE2yMned7ABL5ZAXBOBIDXW0Cvk
 yFNhu4fgpb2tDW/NEsYiyu61ES7F4W+q0AlvTNaPcM4oh+j8+E3B8C26qUaojw7E
 rB5FrRJA7/1RQeBl8RrWplT3bmYyL8qPrEca3hPPrrVPYsvf7TqJlgJRqOEu5bIG
 GBcU+aPZsd6T0u3SloErm0LL9Q4S6YpuW/gqR69azcQUacfalA7kjZ5gpiN9YXYq
 xSsm3zoJl77x4HTAnKN+7Kzyl3gugKJXIN8kN19F9iYwpc3ccii9FROrx7T3trps
 nUojvRorlZHawwAOYxp/6C21u6N7SXZ+TyVnPWgjP24Fr7DI5OxqWEZ8fZqaN7M4
 nNjhZYpquJDwgg63E1WoA3aPOUCQp7ZLz2xKUWuwX6n1zXr/R3qVeguFPORvhp9Q
 uu9nfoZXo5ThVz5JK5eGP7pE1OU/qpnzF2ZLHyeNULjAJcnxQjNzN2nTG35IxiO0
 BKlYmy31GcMwooRqarJrKavzMU1xGKZtIGxOm6uIluqA1cGfH+8ahk84tzLgYAZ4
 4MYnPjDyR31gzt9AB3eb7wGo+TP7djnIzeooeyz8Q71oNcCx263QgrmaKcPZjQtm
 QcLA+/jyGNg0T5t6l2Kj7mLKNdiGb6bHMqMs5KrezTruJcDhlRg=
 =VY8H
 -----END PGP SIGNATURE-----

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

Pull power supply and reset updates from Sebastian Reichel:

 - Microsemi Ocelot reset support

 - Spreadtrum SC27xx reset support

 - generic gpio charger: lot's of cleanups

 - axp20x fuel gauge: add AXP813 support

 - misc fixes, including one devicetree change for the Nokia N900, that
   has been Acked-by Tony Lindgren

* tag 'for-v4.17' of git://git.kernel.org/pub/scm/linux/kernel/git/sre/linux-power-supply: (27 commits)
  power: reset: at91-reset: Switch from the pr_*() to the dev_*() logging functions
  power: reset: at91-poweroff: Remove redundant dev_err call in at91_poweroff_probe()
  power: reset: at91-poweroff: Switch from the pr_*() to the dev_*() logging functions
  power: reset: make function sc27xx_poweroff_shutdown static
  power: supply: da9150-fg: remove VLA usage
  ARM: dts: omap3-n900: Add link between battery and charger
  power: supply: bq2415x: add DT referencing support
  power: supply: bq27xxx: support missing supplier device
  max17042: propagate of_node to power supply device
  power: supply: axp288_fuel_gauge: Fix full status reporting
  power: supply: axp288_fuel_gauge: Do not register FG on ECS EF20EA
  power: reset: gpio-poweroff: Support for timeout from device property
  dt-bindings: power: reset: gpio-poweroff: Add 'timeout-ms' property
  power: reset: Add Spreadtrum SC27xx PMIC power off support
  power: supply: axp20x_battery: add support for AXP813
  dt-bindings: power: supply: axp20x: add AXP813 battery DT binding
  power: supply: axp20x_battery: use data struct for variant specific code
  power: supply: gpio-charger: Remove pdata from gpio_charger
  power: supply: gpio-charger: Use GPIOF_ACTIVE_LOW for legacy setup
  power: supply: gpio-charger: Remove redundant dev_err call in probe function
  ...
2018-04-03 12:10:01 -07:00
Sebastian Reichel 75dd56c0cd Merge branch 'fixes' into for-next
Merge for-stable fixes branch into for-next development branch.

Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2018-03-12 14:35:10 +01:00
Gustavo A. R. Silva fc5a7f0339 power: supply: da9150-fg: remove VLA usage
In preparation to enabling -Wvla, remove VLA usage and replace it
with fixed-length arrays.

DA9150_QIF_LONG_SIZE (4 bytes) is the biggest size of an attribute which can
be accessed [1].

Fixed as part of the directive to remove all VLAs from
the kernel: https://lkml.org/lkml/2018/3/7/621

[1] https://marc.info/?l=kernel-hardening&m=152059600524753&w=2

Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
Acked-by: Adam Thomson <Adam.Thomson.Opensource@diasemi.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2018-03-12 14:34:52 +01:00
Sebastian Reichel 90ad4cc203 power: supply: bq2415x: add DT referencing support
Add support for using bq2415x together with power_supply_am_i_supplied().

Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2018-03-12 14:34:51 +01:00
Sebastian Reichel f72c14ad8c power: supply: bq27xxx: support missing supplier device
power_supply_am_i_supplied() can return negative error
codes. In this case we should assume, that no charger
is connected and the battery should be marked as
DISCHARGING instead of NOT_CHARGING.

Reported-by: Merlijn Wajer <merlijn@wizzup.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2018-03-12 14:30:09 +01:00
Pierre Bourdon 66ec32fc7c max17042: propagate of_node to power supply device
max17042_get_status uses the core power_supply_am_i_supplied. That
function relies on DT properties to figure out the power supply
topology, and will error out without DT.

Fixes max17042 battery status being reported as "unknown".

Signed-off-by: Pierre Bourdon <delroth@google.com>
Signed-off-by: Andre Heider <a.heider@gmail.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2018-03-12 14:29:52 +01:00
Hans de Goede f451655c72 power: supply: axp288_fuel_gauge: Fix full status reporting
Commit 2b5a4b4bf2 ("power: supply: axp288_fuel_gauge: Rework
get_status()"), switched from 0A current detection to using the capacity
register for full detection.

It turns out this fixes full reporting on some devices which keep trickle
charging long after the capacity register reach 100%, but breaks it on
some other devices where the charger stops charging before the capacity
register reaches 100%. This commit fixes this by also checking for
0A current when the reported capacity is above 90%.

Fixes: 2b5a4b4bf2 ("psy: axp288_fuel_gauge: Rework get_status()")
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2018-03-09 18:02:20 +01:00
Carlo Caione 7638eb5666 power: supply: axp288_fuel_gauge: Do not register FG on ECS EF20EA
The ECS EF20EA laptop ships an AXP288 but it is actually using a
different, separate FG chip for AC and battery monitoring. On this
laptop we need to keep using the regular ACPI driver and disable the
AXP288 FG to avoid reporting two batteries to userspace.

Signed-off-by: Carlo Caione <carlo@endlessm.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2018-03-09 17:21:11 +01:00
Quentin Schulz 6ff653e3e8 power: supply: axp20x_battery: add support for AXP813
The X-Powers AXP813 PMIC has got some slight differences from
AXP20X/AXP22X PMICs:
 - the maximum voltage supplied by the PMIC is 4.35 instead of 4.36/4.24
 for AXP20X/AXP22X,
 - the constant charge current formula is different,

It also has a bit to tell whether the battery percentage returned by the
PMIC is valid.

Signed-off-by: Quentin Schulz <quentin.schulz@bootlin.com>
Reviewed-by: Chen-Yu Tsai <wens@csie.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2018-03-09 16:52:33 +01:00
Quentin Schulz 648badd797 power: supply: axp20x_battery: use data struct for variant specific code
We used to use IDs to select a function or a feature depending on the
variant. It's easier to maintain the code by adding data structure
storing the few differences between variants so that we don't add a pile
of if conditions.

Let's use this data structure and update the code to use it.

Signed-off-by: Quentin Schulz <quentin.schulz@bootlin.com>
Reviewed-by: Chen-Yu Tsai <wens@csie.org>
[updated POWER_SUPPLY_PROP_VOLTAGE_MAX_DESIGN write property to use
the introduced set_max_voltage() callback]
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2018-03-09 16:51:06 +01:00
Ladislav Michl d47c1e4b2f power: supply: gpio-charger: Remove pdata from gpio_charger
Platform data are now used only during probe time, so remove
them from gpio_charger structure and consolidate probing
function accordingly.

Signed-off-by: Ladislav Michl <ladis@linux-mips.org>
[Replace of_property_read_string with dev_property_read_string]
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2018-03-09 16:50:28 +01:00
Ladislav Michl f5fec4cc29 power: supply: gpio-charger: Use GPIOF_ACTIVE_LOW for legacy setup
Setting GPIOF_ACTIVE_LOW flag based on platform data gpio_active_low
makes return value of gpiod_get_value_cansleep directly usable.

Signed-off-by: Ladislav Michl <ladis@linux-mips.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2018-03-09 16:16:34 +01:00
Ladislav Michl d433d04bb7 power: supply: gpio-charger: Remove redundant dev_err call in probe function
There is an error message within devm_kzalloc already.

Signed-off-by: Ladislav Michl <ladis@linux-mips.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2018-03-09 16:14:02 +01:00
Ladislav Michl dde5953f05 power: supply: ltc2941-battery-gauge: Fix temperature units
Temperature is measured in tenths of degree Celsius.

Fixes: 085bc24d15 ("Add LTC2941/LTC2943 Battery Gauge Driver")
Signed-off-by: Ladislav Michl <ladis@linux-mips.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2018-02-22 21:28:16 +01:00
Ognjen Galic 285995d15d power: add to_power_supply macro to the API
This patch adds the to_power_supply macro to upcast
a device to a power_supply struct.

This is needed because the same piece of code using
container_of is used in various other places, so we
abstract away such low-level operations via a macro.

Suggested-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Ognjen Galic <smclt30p@gmail.com>
Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2018-02-21 23:27:13 +01:00
Ladislav Michl 416a1ae673 power: supply: gpio-charger: use helper variable to access device info
Using explicit struct device variable makes code a bit more readable.

Signed-off-by: Ladislav Michl <ladis@linux-mips.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2018-02-13 13:48:24 +01:00
Ladislav Michl 419cac572b power: supply: gpio-charger: Drop driver remove function
Simplify error unwinding using devm_* allocators. This also
makes driver remove function empty, so remove it.

Signed-off-by: Ladislav Michl <ladis@linux-mips.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2018-02-13 13:48:23 +01:00
Ladislav Michl 3bf4e03d19 power: supply: ltc2941-battery-gauge: Add charge empty and full properties
Add properties for charge empty and charge full thresholds.

Signed-off-by: Ladislav Michl <ladis@linux-mips.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2018-02-12 11:23:46 +01:00
Hans de Goede 2d7e6a8376 power: supply: max17042_battery: Always fall back to default platform-data
It is possible to have CONFIG_OF enabled on x86 builds, where we have no
firmware provided max17042_platform_data. The CONFIG_OF implementation of
max17042_get_pdata would return NULL in this case, causing the probe to
fail.

Instead always fallback to the default platform-data, as used on x86 sofar,
when there is no firmware provided pdata, independent of CONFIG_OF.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2018-01-23 16:51:22 +01:00
Hans de Goede 6e5ab19d54 power: supply: max17042_battery: Check battery current for status when supplied
Even though the system is supplied, it may still be discharging if the
supply is e.g. only delivering 5V 0.5A. Check the avg battery current if
available for more accurate status reporting.

Cc: James <kernel@madingley.org>
Suggested-by: James <kernel@madingley.org>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2018-01-22 17:53:35 +01:00
Hans de Goede b60c75b6a5 power: supply: axp288_fuel_gauge: Do not register our psy on (some) HDMI sticks
The Intel Compute Stick (Cherry Trail version) and the Meegopad T08 HDMI
stick, both use an axp288 PMIC.  They also both have this wired up in such
a way that the detection logic in the PMIC claims that a valid battery is
present, resuling in GNOME and KDE showing a full-battery in their status
bar and power-settings, while these devices do not have a battery.

For lack of a better fix add a DMI blacklist and do not register the
axp288_fuel_gauge psy on devices on the blacklist.

Reviewed-by: Chen-Yu Tsai <wens@csie.org>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2018-01-09 17:50:05 +01:00
Hans de Goede ceb40831c9 power: supply: axp288_fuel_gauge: Optimize get_current()
First check the discharge current, and when that is non 0 use that without
also checking the charge current (which will be 0 then). This makes
get_current() do only 1 i2c read instead of 2 when on battery.

This is esp. important given the pmic i2c bus mutex stuff used on boards
with an axp288 because the SoC's own punit also may access the axp288,
which makes i2c accesses more expensive then normal.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Chen-Yu Tsai <wens@csie.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2018-01-09 17:45:08 +01:00
Hans de Goede 2b5a4b4bf2 power: supply: axp288_fuel_gauge: Rework get_status()
Relying on the (dis)charge current reporting for reporting FULL back to
userspace does not work really well and often leads to the reported status
getting stuck at e.g. 98/99% (the fuelgauge is not perfect) for hours.

What happens is that when the battery is full the axp288 keeps charging it
with a very low current. Until it is really really full and once really
really full, some inaccuracies in the adc lead to it then sometimes
reporting a small discharging rate, even though an external pwr source is
used. So we end up with a status of "charging" for hours after the battery
is actually already full and sometimes this then flip-flops to discharging.

This commit fixes this by first checking if a valid Vbus is present and if
it is present using the fuel-gauge's reported percentage to check for a
full battery.

This commit also changes how get_status() determines if the battery is
charging or discharging when not reporting it as full. We still use the
current direction for this, but instead of reading 4 extra registers for
this (2 16 bit regs), simplify things by using the current-direction bit
in the power-status register, which already gets read anyways.

This also reduces the amount of i2c reads to 1 when on battery and 2
when a valid Vbus is present.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Chen-Yu Tsai <wens@csie.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2018-01-09 17:41:39 +01:00
Julia Lawall a488ca6e70 power: supply: account for const type of of_device_id.data
This driver creates two const structures that it stores in the data
field of an of_device_id array.

The data field of an of_device_id structure has type const void *, so
there is no need for a const-discarding cast when putting const values
into such a structure.

Furthermore, adding const to the declaration of the location that
receives a const value from such a field ensures that the compiler
will continue to check that the value is not modified.  The
const-discarding cast on the extraction from the data field is thus
no longer needed.

Done using Coccinelle.

Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2018-01-08 18:40:46 +01:00
Pavel Machek 31381042a6 bq24190: Simplify code in property_is_writeable
Simplify function that should be trivial.

Signed-off-by: Pavel machek <pavel@ucw.cz>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2018-01-08 18:40:06 +01:00
Hans de Goede 331645e165 power: supply: axp288_fuel_gauge: Get iio-channels once during boot
Get iio-channels once during boot, delaying the probe if the axp288_adc
drivers has not loaded yet, instead of getting them on demand each time
we need them.

This fixes the following errors in dmesg:

axp288_fuel_gauge axp288_fuel_gauge: ADC charge current read failed:-19

Which were caused by the ondemand iio-channel read code not finding the
channel when the axp288_adc driver had not loaded yet.

Reviewed-by: Chen-Yu Tsai <wens@csie.org>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2018-01-08 18:38:57 +01:00
Hans de Goede 165c235774 power: supply: axp288_charger: Properly stop work on probe-error / remove
Properly stop any work we may have queued on probe-errors / remove.

Rather then adding a remove driver callback for this, and goto style
error handling to probe, use a devm_action for this.

The devm_action gets registered before we register any of the extcon
notifiers which may queue the work, devm does cleanup in reverse order,
so this ensures that the notifiers are removed before we cancel the work.

Reviewed-by: Chen-Yu Tsai <wens@csie.org>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2018-01-08 18:38:57 +01:00
Hans de Goede 8c0a0a2959 power: supply: axp288_charger: Simplify extcon cable handling
Simplify extcon cable handling using the new
devm_extcon_register_notifier_all function to listen to all cables
in one go.

Reviewed-by: Chen-Yu Tsai <wens@csie.org>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2018-01-08 18:38:57 +01:00
Hans de Goede 81d56dd3d5 power: supply: axp288_charger: Use the right property for the input current limit
Use the right property for the input current limit and make it writable.

Reviewed-by: Chen-Yu Tsai <wens@csie.org>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2018-01-08 18:38:57 +01:00
Hans de Goede 9563d05416 power: supply: axp288_charger: Pick lower input current limit not higher
The code before this commit would pick 900 mA when asking for an input
current limit of 600mA, rather then 500 mA, not good.

While touching almost all code using the silly xxxMA defines anyways,
also get rid of these simply typing out the numbers and switch the
unit to uA as that is the psy class standard unit for currents.

Reviewed-by: Chen-Yu Tsai <wens@csie.org>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2018-01-08 18:38:57 +01:00
Hans de Goede d1ce7e5853 power: supply: axp288_charger: Do not cache input current limit value
The hardware may change this underneath us.

Reviewed-by: Chen-Yu Tsai <wens@csie.org>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2018-01-08 18:38:57 +01:00
Hans de Goede c28185bd3a power: supply: axp288_charger: Remove no longer needed locking
Now that we use regmap to do read-modify-write ops everywhere, we can
rely on the regmap lock and no longer need our own lock.

Reviewed-by: Chen-Yu Tsai <wens@csie.org>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2018-01-08 18:38:57 +01:00
Hans de Goede bbafa111ca power: supply: axp288_charger: Use regmap_update_bits to set the input limits
Use regmap_update_bits in axp288_charger_set_vbus_inlmt, instead of DIY
code.

Reviewed-by: Chen-Yu Tsai <wens@csie.org>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2018-01-08 18:38:57 +01:00
Hans de Goede a9904aa828 power: supply: axp288_charger: Cleanup some double empty lines
While we are doing cleanups, also remove some double blank lines.

Reviewed-by: Chen-Yu Tsai <wens@csie.org>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2018-01-08 18:38:57 +01:00
Hans de Goede 672b4b0060 power: supply: axp288_charger: Remove charger-enabled state tracking
The extcon code is the only one to trigger our worker (outside of the
initial run) and we can rely on it to only call us if things have
changed, so there is no need to track the charger-enabled state.

Reviewed-by: Chen-Yu Tsai <wens@csie.org>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2018-01-08 18:38:57 +01:00
Hans de Goede a59943f8f6 power: supply: axp288_charger: Add missing newlines to some messages
Add missing (terminating) "\n"-s to some dev_dbg messages.

Reviewed-by: Chen-Yu Tsai <wens@csie.org>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2018-01-08 18:38:57 +01:00
Hans de Goede d8e6519535 power: supply: axp288_charger: Do not stop + restart charging at boot
Before this commit we were relying solely on the extcon interface for
cable detection, including to determine if a cable providing vbus is
connected at all. This caused us to turn off charging at boot, because
when we run the initial state processing the axp288-extcon driver is still
running charger-type detection most of the time, so all charger cable
types read as disconnected when we run the initial state processing.

This commit reworks the axp288_charger_extcon_evt_worker flow to use the
VBUS_VALID bit from the PWR_INPUT_STATUS register to determine if we
should turn charging on/off. Note this is the same bit as we use for the
online property.

If VBUS_VALID is set, but the extcon code has not completed the charger
type detection yet, we now simply bail leaving things as configured by
the BIOS (we will get a notifier call when the extcon code is done and
reschedule the axp288_charger_extcon_evt_worker).

The extcon code is the only one to trigger the worker (outside of the
initial run) and we can rely on it to only call us if things have changed,
so while we are completely refactoring axp288_charger_extcon_evt_worker,
also remove the code to check if the state has changed.

Reviewed-by: Chen-Yu Tsai <wens@csie.org>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2018-01-08 18:38:56 +01:00
Pavel Machek 70a39e1075 Add support for bq27521 battery monitor
This adds basic support for BQ27521 battery monitor, used in Nokia N9
and N950. In particular, battery voltage is important to be able to
tell when the battery is almost empty. Emptying battery on N950 is
pretty painful, as flasher needs to be used to recover phone in such case.

Signed-off-by: Pavel Machek <pavel@ucw.cz>
Acked-by: Andrew F. Davis <afd@ti.com>
Acked-by: Rob Herring <robh@kernel.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2017-12-08 18:02:15 +01:00
Hans de Goede d16002755d power: supply: bq24190_charger: Remove extcon handling
Now that drivers/i2c/busses/i2c-cht-wc.c uses
"input-current-limit-from-supplier" instead of "extcon-name" the last
user of the bq24190 extcon code is gone, remove it.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2017-12-01 16:43:21 +01:00
Mike Looijmans 5f2f0d6105 power: ltc2941-battery-gauge: Disable continuous monitoring on shutdown
The driver sets the fuel gauge to continuous monitoring on startup, for
the models that support this. When the board shuts down, the chip remains
in that mode, causing a few mA drain on the battery every 2 or 10 seconds.

This patch registers a shutdown handler that turns off the monitoring to
prevent this battery drain.

Signed-off-by: Mike Looijmans <mike.looijmans@topic.nl>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2017-12-01 16:41:05 +01:00
Arvind Yadav aac7990407 power: supply: cpcap-battery: Fix platform_get_irq_byname's error checking
The platform_get_irq_byname() function returns -1 if an error occurs.
zero or positive number on success. platform_get_irq_byname() error
checking for zero is not correct.

Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2017-12-01 16:22:10 +01:00
Christophe JAILLET 09edcb6475 power: supply: ab8500_charger: Bail out in case of error in 'ab8500_charger_init_hw_registers()'
If an error occurs when we enable the backup battery charging, we should
go through the error handling path directly.

Before commit db43e6c473 ("ab8500-bm: Add usb power path support") this
was the case, but this commit has added some code between the last test and
the 'out' label.
So, in case of error, this added code is executed and the error may be
silently ignored.

Fix it by adding the missing 'goto out', as done in all other error
handling paths.

Fixes: db43e6c473 ("ab8500-bm: Add usb power path support")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2017-12-01 16:21:18 +01:00
Christophe JAILLET bf59fddde1 power: supply: ab8500_charger: Fix an error handling path
'ret' is know to be 0 at this point, because it has not been updated by the
the previous call to 'abx500_mask_and_set_register_interruptible()'.

Fix it by updating 'ret' before checking if an error occurred.

Fixes: 84edbeeab6 ("ab8500-charger: AB8500 charger driver")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2017-12-01 16:21:18 +01:00
Ryosuke Saito f46b151ede power: supply: charger-manager: Fix typo in condition
Should be discharging_max_duration_ms, not charging_max_duration_ms.

Signed-off-by: Ryosuke Saito <raitosyo@gmail.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2017-12-01 16:14:06 +01:00
Dan Carpenter 7d54d0d38e power: supply: sbs-message: double left shift bug in sbsm_select()
The original code does this: "1 << (1 << 11)" which is undefined in C.

Fixes: dbc4deda03 ("power: Adds support for Smart Battery System Manager")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2017-12-01 16:08:00 +01:00
Linus Torvalds 19b9aaf8a5 power supply and reset changes for the v4.15 series
* Misc. minor fixes
 -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCgAdFiEE72YNB0Y/i3JqeVQT2O7X88g7+poFAloMMiIACgkQ2O7X88g7
 +po5Tg//cT+BUtyJuzHvBLt59OG7/qkMv5Kkazr6ZQIAD2gLp7aYQjLyqG82bnXI
 a/vEp0mXY6IWtmUmh0dk/sn8UUBFPyTxxAEKt1z/ygEf8/2Cozcji1QtEfqGpR2S
 5EDGneJ4aoLuBmNYEfOmw9ohr6uNhhhSZ46ev0k73pEPGZHU2BxRLDf8/hzuBRX/
 w8hMwF/5Mi5dREtjk0axauQwB7xCurxrHHPjaXDhPdYorLJ/xXcXUgc0fX6RvE9p
 ZIQEy5ESPsYdazSAW/Dtn0UgfFYuscWAh76lAxw3fQrlIbbVdy7rqrnUDJgh9qCP
 GW8vfK3IQi7oB4Y+H1Iyjl4e2tJKVPRugG8vfSQVWaVM2uVjD5dYTG/c9nPd968h
 7waPCpToPkP3Mv5MrXB049KNey06Jm8pMUmSzW2aMQhXHTwTBlubVpz2xCVbYYzM
 OJtOmv4D5i/qSO1cDvZUosF0yXnkCk0u9ZF9L0JAqznd7s0ZbJES6/Etjwo/TM2R
 RB5Ucu3nc8QXBhoH+AASPThkG7QmRDkzliaO9fIl18g4LiMAMYMmGB5bhTjc5Eog
 p7P3uVqMx8z9yqouX9+eJC6PbgiLm+oHesO6w4lxqFp/izeDvgQZrlRFqMAWxftU
 jLVSvkPjPD6JVdUG4cbkZfwyJ1doOS6djbmKC9Pi8kc01xV5nuY=
 =9LP+
 -----END PGP SIGNATURE-----

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

Pull power supply and reset updates from Sebastian Reichel:

 - misc minor fixes

* tag 'for-v4.15' of git://git.kernel.org/pub/scm/linux/kernel/git/sre/linux-power-supply:
  power: supply: cpcap-charger: fix incorrect return value check
  power: supply: replace pr_* with dev_*
  power: supply: pcf50633-charger: remove redundant variable charging_start
  power: supply: generic-adc-battery: remove redundant variable pdata
  power: supply: max8997: Improve a size determination in probe
2017-11-15 13:37:15 -08:00
Linus Torvalds 9682b3dea2 Merge branch 'for-linus' of ssh://gitolite.kernel.org/pub/scm/linux/kernel/git/jikos/trivial
Pull trivial tree updates from Jiri Kosina:
 "The usual rocket-science from trivial tree for 4.15"

* 'for-linus' of ssh://gitolite.kernel.org/pub/scm/linux/kernel/git/jikos/trivial:
  MAINTAINERS: relinquish kconfig
  MAINTAINERS: Update my email address
  treewide: Fix typos in Kconfig
  kfifo: Fix comments
  init/Kconfig: Fix module signing document location
  misc: ibmasm: Return error on error path
  HID: logitech-hidpp: fix mistake in printk, "feeback" -> "feedback"
  MAINTAINERS: Correct path to uDraw PS3 driver
  tracing: Fix doc mistakes in trace sample
  tracing: Kconfig text fixes for CONFIG_HWLAT_TRACER
  MIPS: Alchemy: Remove reverted CONFIG_NETLINK_MMAP from db1xxx_defconfig
  mm/huge_memory.c: fixup grammar in comment
  lib/xz: Add fall-through comments to a switch statement
2017-11-15 10:14:11 -08:00
Linus Torvalds 4008e6a9bc Merge branch 'i2c/for-4.15' of ssh://gitolite.kernel.org/pub/scm/linux/kernel/git/wsa/linux
Pull i2c updates from Wolfram Sang:
 "This contains two bigger than usual tree-wide changes this time. They
  all have proper acks, caused no merge conflicts in linux-next where
  they have been for a while. They are namely:

   - to-gpiod conversion of the i2c-gpio driver and its users (touching
     arch/* and drivers/mfd/*)

   - adding a sbs-manager based on I2C core updates to SMBus alerts
     (touching drivers/power/*)

  Other notable changes:

   - i2c_boardinfo can now carry a dev_name to be used when the device
     is created. This is because some devices in ACPI world need fixed
     names to find the regulators.

   - the designware driver got a long discussed overhaul of its PM
     handling. img-scb and davinci got PM support, too.

   - at24 driver has way better OF support. And it has a new maintainer.
     Thanks Bartosz for stepping up!

  The rest is regular driver updates and fixes"

* 'i2c/for-4.15' of ssh://gitolite.kernel.org/pub/scm/linux/kernel/git/wsa/linux: (55 commits)
  ARM: sa1100: simpad: Correct I2C GPIO offsets
  i2c: aspeed: Deassert reset in probe
  eeprom: at24: Add OF device ID table
  MAINTAINERS: new maintainer for AT24 driver
  i2c: nuc900: remove platform_data, too
  i2c: thunderx: Remove duplicate NULL check
  i2c: taos-evm: Remove duplicate NULL check
  i2c: Make i2c_unregister_device() NULL-aware
  i2c: xgene-slimpro: Support v2
  i2c: mpc: remove useless variable initialization
  i2c: omap: Trigger bus recovery in lockup case
  i2c: gpio: Add support for named gpios in DT
  dt-bindings: i2c: i2c-gpio: Add support for named gpios
  i2c: gpio: Local vars in probe
  i2c: gpio: Augment all boardfiles to use open drain
  i2c: gpio: Enforce open drain through gpiolib
  gpio: Make it possible for consumers to enforce open drain
  i2c: gpio: Convert to use descriptors
  power: supply: sbs-message: fix some code style issues
  power: supply: sbs-battery: remove unchecked return var
  ...
2017-11-14 17:52:21 -08:00
Linus Torvalds 894025f24b USB/PHY patches for 4.15-rc1
Here is the big set of USB and PHY driver updates for 4.15-rc1.
 
 There is the usual amount of gadget and xhci driver updates, along with
 phy and chipidea enhancements.  There's also a lot of SPDX tags and
 license boilerplate cleanups as well, which provide some churn in the
 diffstat.
 
 Other major thing is the typec code that moved out of staging and into
 the "real" part of the drivers/usb/ tree, which was nice to see happen.
 
 All of these have been in linux-next with no reported issues for a
 while.
 
 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
 -----BEGIN PGP SIGNATURE-----
 
 iG0EABECAC0WIQT0tgzFv3jCIUoxPcsxR9QN2y37KQUCWgm/Vw8cZ3JlZ0Brcm9h
 aC5jb20ACgkQMUfUDdst+yktXwCdGgpInfOEvOGFd83EPDL7a1ncyc4AoM5wI8yl
 1CeLipqVIN3IsMMJptvb
 =zvDI
 -----END PGP SIGNATURE-----

Merge tag 'usb-4.15-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb

Pull USB/PHY updates from Greg KH:
 "Here is the big set of USB and PHY driver updates for 4.15-rc1.

  There is the usual amount of gadget and xhci driver updates, along
  with phy and chipidea enhancements. There's also a lot of SPDX tags
  and license boilerplate cleanups as well, which provide some churn in
  the diffstat.

  Other major thing is the typec code that moved out of staging and into
  the "real" part of the drivers/usb/ tree, which was nice to see
  happen.

  All of these have been in linux-next with no reported issues for a
  while"

* tag 'usb-4.15-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb: (263 commits)
  usb: gadget: f_fs: Fix use-after-free in ffs_free_inst
  USB: usbfs: compute urb->actual_length for isochronous
  usb: core: message: remember to reset 'ret' to 0 when necessary
  USB: typec: Remove remaining redundant license text
  USB: typec: add SPDX identifiers to some files
  USB: renesas_usbhs: rcar?.h: add SPDX tags
  USB: chipidea: ci_hdrc_tegra.c: add SPDX line
  USB: host: xhci-debugfs: add SPDX lines
  USB: add SPDX identifiers to all remaining Makefiles
  usb: host: isp1362-hcd: remove a couple of redundant assignments
  USB: adutux: remove redundant variable minor
  usb: core: add a new usb_get_ptm_status() helper
  usb: core: add a 'type' parameter to usb_get_status()
  usb: core: introduce a new usb_get_std_status() helper
  usb: core: rename usb_get_status() 'type' argument to 'recip'
  usb: core: add Status Type definitions
  USB: gadget: Remove redundant license text
  USB: gadget: function: Remove redundant license text
  USB: gadget: udc: Remove redundant license text
  USB: gadget: legacy: Remove redundant license text
  ...
2017-11-13 21:14:07 -08:00
Pan Bian 838c8afa67 power: supply: cpcap-charger: fix incorrect return value check
Function platform_get_irq_byname() returns a negative error code on
failure, and a zero or positive number on success. However, in function
cpcap_usb_init_irq(), positive IRQ numbers are also taken as error
cases. Use "if (irq < 0)" instead of "if (!irq)" to validate the return
value of platform_get_irq_byname().

Signed-off-by: Pan Bian <bianpan2016@163.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2017-11-13 11:56:12 +01:00