Commit graph

1579 commits

Author SHA1 Message Date
Hans de Goede 2e015412a3 power: supply: max17042_battery: Add support for the CHARGE_FULL_DESIGN property
The info is there, lets export it as a property.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Krzysztof Kozlowski <krzk@kernel.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2017-05-01 12:37:49 +02:00
Hans de Goede d7d15fc677 power: supply: max17042_battery: mAh readings depend on r_sns value
The PROP_CHARGE_FULL code was hardcoded for the default sense
resistor of 0.010 Ohm, make it use r_sns which contains the
actual sense resistor value in micro-Ohms instead.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Krzysztof Kozlowski <krzk@kernel.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2017-05-01 12:37:45 +02:00
Hans de Goede 7bfc9397ff power: supply: max17042_battery: Add support for the VOLT_MIN property
The info is there, so lets export it, like we already do for VOLT_MAX.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Krzysztof Kozlowski <krzk@kernel.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2017-05-01 12:37:42 +02:00
Hans de Goede ef7fcdaebf power: supply: max17042_battery: Add support for the TECHNOLOGY attribute
The max17042 is intended for Li-Ion or Li-Po batteries, add a TECHNOLOGY
attribute to reflect this. Note this is hardcoded to Li-Ion as there is
no way to tell the difference, and Lithium-Ion Polymer batteries are
a sub-family of Lithium-Ion so Li-Ion technically is correct for both.

Using Li-Ion for both is already done by many drivers and is much
better then not providing any technology info at all.

Suggested-by: Wolfgang Wiedmeyer <wolfgit@wiedmeyer.de>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Krzysztof Kozlowski <krzk@kernel.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2017-05-01 12:37:37 +02:00
Hans de Goede dcdddda8fd power: supply: max17042_battery: Add external_power_changed callback
If our supplier changes status, chances are we've changed status too,
let any listeners know about this.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Krzysztof Kozlowski <krzk@kernel.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2017-05-01 12:37:32 +02:00
Hans de Goede a9df22c00d power: supply: max17042_battery: Add support for the STATUS property
Userspace prefers the driver having a status property over having to guess
itself. Specifically this will properly make the GNOME3 UI (and likely
others) properly show discharging / charging / full status, instead
of always showing discharging as status.

Note that in the case there is no charger driver supplying the max17042,
then a status of unknown will get returned. At least upower treats
this the same as not having a status attribute, so in this case nothing
changes from a userspace pov.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Krzysztof Kozlowski <krzk@kernel.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2017-05-01 12:37:29 +02:00
Hans de Goede 917362135b power: supply: max17042_battery: Add default platform_data fallback data
Some x86 machines use a max17047 fuel-gauge and x86 might be missing
platform_data if not provided by SFI.

This commit adds default platform_data as fallback option so that the
driver can work on boards where no platform_data is provided.

Since not all boards have a thermistor hooked up, set temp_min to 0 and
change the health checks from temp <= temp_min to temp < temp_min to
not trigger on such boards (where temp reads 0).

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Krzysztof Kozlowski <krzk@kernel.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2017-05-01 12:37:25 +02:00
Hans de Goede 2814913c31 power: supply: max17047_battery: The temp alert values are 8-bit 2's complement
The temp alert values are 8-bit 2's complement, so sign-extend them
before reporting them back to the caller.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Krzysztof Kozlowski <krzk@kernel.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2017-05-01 12:37:21 +02:00
Hans de Goede c67c06939e power: supply: max17042_battery: Use sign_extend32 instead of DIY code
Use sign_extend32 to sign-extend variables where necessary instead of
DIY code.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Krzysztof Kozlowski <krzk@kernel.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2017-05-01 12:37:16 +02:00
Colin Ian King 7f232af356 power: supply: ab8500_charger: spelling: "prechage" -> "precharge"
trivial fix to spelling mistake in dev_error message.

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2017-05-01 12:37:01 +02:00
Arnd Bergmann 6254a6a944 power: supply: axp20x_usb_power: add IIO dependency
When CONFIG_IIO=m and the axp20x_usb_power driver is built-in, we get
a link time error:

drivers/power/built-in.o: In function `axp20x_usb_power_get_property':
undefined reference to `iio_read_channel_processed'
drivers/power/built-in.o: In function `axp20x_usb_power_probe':
undefined reference to `devm_iio_channel_get'
undefined reference to `devm_iio_channel_get'

This adds the same dependency that we already have for the AC power driver
to the USB power driver. For consistency, I'm also moving the two closer
together in the Kconfig file.

Fixes: 33863c938c ("power: supply: axp20x_usb_power: use IIO channels when available")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2017-05-01 11:56:49 +02:00
Pan Bian 8b20839988 power: supply: isp1704: Fix unchecked return value of devm_kzalloc
Function devm_kzalloc() will return a NULL pointer. However, in function
isp1704_charger_probe(), the return value of devm_kzalloc() is directly
used without validation. This may result in a bad memory access bug.

Fixes: 34a109610e ("isp1704_charger: Add DT support")
Signed-off-by: Pan Bian <bianpan2016@163.com>
Reviewed-by: Pali Rohár <pali.rohar@gmail.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2017-05-01 11:52:25 +02:00
Rahul Bedarkar 756e142a4b power: supply: generic-adc-battery: use SIMPLE_DEV_PM_OPS helper macro
Replace ifdefs with SIMPLE_DEV_PM_OPS helper macro.

Signed-off-by: Rahul Bedarkar <rahulbedarkar89@gmail.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2017-05-01 11:52:24 +02:00
Ryosuke Saito bb8fe8ea00 power: supply: sbs-battery: fix the sbs interrupt request
Since we use the default primary handler for the irq, IRQF_ONESHOT must
be set. Otherwise the request fails and the following errors are
displayed:

genirq: Threaded irq requested with handler=NULL and !ONESHOT for irq 129
sbs-battery 0-000b: Failed to request irq: -22

Signed-off-by: Ryosuke Saito <raitosyo@gmail.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2017-05-01 11:52:24 +02:00
Quentin Schulz 46c202b5f2 power: supply: add battery driver for AXP20X and AXP22X PMICs
The X-Powers AXP20X and AXP22X PMICs can have a battery as power supply.

This patch adds the battery power supply driver to get various data from
the PMIC, such as the battery status (charging, discharging, full,
dead), current max limit, current current, battery capacity (in
percentage), voltage max and min limits, current voltage and battery
capacity (in Ah).

This battery driver uses the AXP20X/AXP22X ADC driver as PMIC data
provider.

Signed-off-by: Quentin Schulz <quentin.schulz@free-electrons.com>
Acked-by: Jonathan Cameron <jic23@kernel.org>
Acked-by: Maxime Ripard <maxime.ripard@free-electrons.com>
Acked-by: Chen-Yu Tsai <wens@csie.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2017-05-01 11:52:23 +02:00
Liam Breck 1eb2869b3c power: supply: bq24190_charger: Deprecate battery class and replicate its features in charger
The driver was registering two classes, bq24190-battery & -charger.
Because the power supply framework cannot surface features from multiple
drivers in a single class, a fuel gauge driver would create a third class,
which some power management utilities cannot see.

Deprecate the -battery class for future removal and replicate its features
in -charger. Set /sys/class...-charger/online = pg_stat && !batfet_disable.
If device_property "omit-battery-class" is set, don't register -battery.

Cc: Tony Lindgren <tony@atomide.com>
Cc: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Liam Breck <kernel@networkimprov.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2017-05-01 11:52:15 +02:00
Hans de Goede 2848e039c5 power: supply: Make power_supply_am_i_supplied return -ENODEV if there are no suppliers
It is sensible to assume that the hardware actually always has a
way of charging the battery so when power_supply_am_i_supplied does not
find any suppliers, that does not mean that there are none, but simply
that no power_supply-drivers are registered / bound for any suppliers for
the supply calling power_supply_am_i_supplied.

At which point a fuel-gauge driver calling power_supply_am_i_supplied()
cannot determine whether the battery is being charged or not.

Allow a caller of power_supply_am_i_supplied to differentiate between
there not being any suppliers, vs no suppliers being online by returning
-ENODEV if there are no suppliers matching supplied_to / supplied_from,
which allows fuel-gauge drivers to return POWER_SUPPLY_STATUS_UNKNOWN
rather then POWER_SUPPLY_STATUS_DISCHARGING if there are no suppliers.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Krzysztof Kozlowski <krzk@kernel.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2017-05-01 11:51:20 +02:00
H. Nikolaus Schaller 19a2ee69c2 power: supply: twl4030-charger: don't check if battery is present
We can't assume that the battery is or stays present after probing
on devices with replaceable battery.

On some devices (e.g. GTA04 or OpenPanodra) it can be removed
and even be hot swapped by the user while device continues to operate
through external AC or USB power (as long as system power consumption
remains below ca. 500mA as provided by USB). Under certain conditions
it is possible to boot without battery.

So it makes no sense to check for this situation during probe and make
the charger driver (and its status reports) completely non-operational if
the battery can be inserted later.

Tested on: GTA04 and OpenPandora.

Signed-off-by: H. Nikolaus Schaller <hns@goldelico.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2017-05-01 11:41:37 +02:00
H. Nikolaus Schaller 3fb319c2cd power: supply: twl4030-charger: add writable INPUT_CURRENT_LIMIT property
Currently, the twl4030 charger defines its own max_current by directly
creating sysfs nodes. It should use the input_current_limit property
which is e.g. used by the bq24257 driver.

This patch adds the input_current_property with the same semantics as
the max_current property. The code to manage the max_current property
is removed by a separate patch.

Signed-off-by: H. Nikolaus Schaller <hns@goldelico.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2017-05-01 11:37:11 +02:00
Hans de Goede 6cf62a3b97 power: supply: bq24190_charger: Add disable-reset device-property
Allow platform-code to disable the reset on probe and suspend/resume
by setting a "disable-reset" boolean device property on the device.

There are several reasons why the platform-code may want to disable
the reset on probe and suspend/resume:

1) Resetting the charger should never be necessary it should always have
sane values programmed. If it is running with invalid values while we
are not running (system turned off or suspended) there is a big problem
as that may lead to overcharging the battery.

2) The reset in suspend() is meant to put the charger back into default
mode, but this is not necessary and not a good idea. If the charger has
been programmed with a higher max charge_current / charge_voltage then
putting it back in default-mode will reset those to the safe power-on
defaults, leading to slower charging, or charging to a lower voltage
(and thus not using the full capacity) while suspended which is
undesirable. Reprogramming the max charge_current / charge_voltage
after the reset will not help here as that will put the charger back
in host mode and start the i2c watchdog if the host then does not do
anything for 40s (iow if we're suspended for more then 40s) the watchdog
expires resetting the device to default-mode, including resetting all
the registers to there safe power-on defaults. So the only way to keep
using custom charge settings while suspending is to keep the charger in
its normal running state with the i2c watchdog disabled. This is fine
as the charger will still automatically switch from constant current
to constant voltage and stop charging when the battery is full.

3) Besides never being necessary resetting the charger also causes
problems on systems where the charge voltage limit is set higher then the
reset value, if this is the case and the charger is reset while charging
and the battery voltage is between the 2 voltages, then about half the
time the charger gets confused and claims to be charging (REG08 contains
0x64) but in reality the charger has decoupled itself from VBUS (Q1 off)
and is drawing 0A from VBUS, leaving the system running from the battery.

This last problem is happening on a GPD-win mini PC with a bq24292i
charger chip combined with a max17047 fuel-gauge and a LiHV battery.
I've checked and TI does not list any errata for the bq24292i which
could explain this (there are no errata at all).

Cc: Liam Breck <kernel@networkimprov.net>
Cc: Tony Lindgren <tony@atomide.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Acked-by: Liam Breck <kernel@networkimprov.net>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2017-05-01 11:34:20 +02:00
Hans de Goede 6c4c9a9a4a power: supply: axp288_charger: Only wait for INT3496 device if present
On some devices with an axp288 pmic setting vbus path based on the
id-pin is handled by an ACPI _AIE interrupt on the gpio and the
INT3496 device is disabled.

Instead of returning -EPROBE_DEFER on these devices waiting for the
never to show up INT3496 device, check for its presence and only
request and monitor the matching extcon if the device is there,
otherwise let the firmware handle the vbus path control.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Acked-by: Sebastian Reichel <sre@kernel.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2017-04-19 22:53:35 +02:00
Hans de Goede 6c381663bb power: supply: bq24190_charger: Use new extcon_register_notifier_all()
When I submitted the extcon handling I had a patch pending for the
extcon sub-system for extcon_register_notifier to take -1 as cable id
for listening for all type cable events on an extcon with a single
notifier.

In the end it was decided to instead add a new
extcon_register_notifier_all function for this, switch to using this.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Acked-by: Liam Breck <kernel@networkimprov.net>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2017-04-14 01:45:06 +02:00
Liam Breck 61489b0f9f power: supply: bq24190_charger: Longer delay while polling reset flag
On chip reset, polling loop used udelay(10) which is too short
to be useful. Instead, use usleep_range(100, 200).

Signed-off-by: Liam Breck <kernel@networkimprov.net>
Acked-by: Tony Lindgren <tony@atomide.com>
Acked-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2017-04-14 01:41:35 +02:00
Liam Breck e3ebc381a9 power: supply: bq24190_charger: Uniform pm_runtime_get() failure handling
On pm_runtime_get() failure, always emit an error message.
Prevent unbalanced pm_runtime_get by calling:
  pm_runtime_put_noidle() in irq handler
  pm_runtime_put_sync() on any probe() failure
Rename probe() out labels instead of renumbering them.

Fixes: 13d6fa8447fa ("power: bq24190_charger: Use PM runtime autosuspend")
Signed-off-by: Liam Breck <kernel@networkimprov.net>
Acked-by: Tony Lindgren <tony@atomide.com>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Acked-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2017-04-14 01:41:35 +02:00
Liam Breck 03add17fe3 power: supply: bq24190_charger: Clean up extcon code
Polishing and fixes for initial extcon patch.

Fixes: 4db249b6f3b4 ("power: supply: bq24190_charger: Use extcon to determine ilimit, 5v boost")
Cc: Tony Lindgren <tony@atomide.com>
Signed-off-by: Liam Breck <kernel@networkimprov.net>
Acked-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2017-04-14 01:41:35 +02:00
Liam Breck d63d07c6fc power: supply: bq24190_charger: Limit over/under voltage fault logging
If the charger is unplugged before the battery is full we may
see an over/under voltage fault. Ignore this rather then emitting
a message or uevent.

This fixes messages like these getting logged on charger unplug + replug:
bq24190-charger 15-006b: Fault: boost 0, charge 1, battery 0, ntc 0
bq24190-charger 15-006b: Fault: boost 0, charge 0, battery 0, ntc 0

Cc: Tony Lindgren <tony@atomide.com>
Cc: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Liam Breck <kernel@networkimprov.net>
Acked-by: Tony Lindgren <tony@atomide.com>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2017-04-14 01:41:35 +02:00
David Lechner 53db88586a power: supply: New driver for LEGO MINDSTORMS EV3 battery
This adds a new driver for the LEGO MINDSTORMS EV3 battery. The EV3 is
an embedded ARM device that can use 6 AA batteries or a special rechargeable
Li-ion battery pack. The rechargeable battery pack presses a special key
switch in the battery compartment to indicate that it is present.

The EV3 is only capable of monitoring battery voltage and current. The
charging circuit is built into the rechargeable battery pack and there is
no way to communicate with is, so we can't provide any information about
charging status.

When not using the rechargeable battery pack, it is most common to use
alkaline batteries to power the device, but it is also common for people to
use rechargeable NiMH batteries. Since there is not a way to automatically
differentiate between these, the technology property is made writable.

Signed-off-by: David Lechner <david@lechnology.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2017-04-14 01:41:35 +02:00
Enric Balletbo i Serra 53a022d0c1 power: supply: tps65217: remove debug messages for function calls
Equivalent information can be nowadays obtained using function tracer.

Signed-off-by: Enric Balletbo i Serra <enric.balletbo@collabora.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2017-04-14 01:41:35 +02:00
Javier Martinez Canillas 9697277ed5 power: supply: ltc2941-battery-gauge: Add OF device ID table
The driver doesn't have a struct of_device_id table but supported devices
are registered via Device Trees. This is working on the assumption that a
I2C device registered via OF will always match a legacy I2C device ID and
that the MODALIAS reported will always be of the form i2c:<device>.

But this could change in the future so the correct approach is to have an
OF device ID table if the devices are registered via OF.

Signed-off-by: Javier Martinez Canillas <javier@osg.samsung.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2017-04-14 01:41:34 +02:00
Andi Shyti dc6ea7d4cd power: supply: charger-manager: simplify return statements
Some trivial improvements on the returning value of the
functions:

 - remove unnecessary goto labels that just return, return
   immediately, instead.

 - do not initialize when not needed.

 - return the value from the calling function that fails instead
   of politically choosing -EINVAL.

Signed-off-by: Andi Shyti <andi@etezian.org>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2017-04-14 01:41:34 +02:00
Giedrius Statkevičius bdd9968d35 power: supply: lp8788: prevent out of bounds array access
val might become 7 in which case stime[7] (array of length 7) would be
accessed during the scnprintf call later and that will cause issues.
Obviously, string concatenation is not intended here so just a comma needs
to be added to fix the issue.

Fixes: 98a2766493 ("power_supply: Add new lp8788 charger driver")
Signed-off-by: Giedrius Statkevičius <giedrius.statkevicius@gmail.com>
Acked-by: Milo Kim <milo.kim@ti.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2017-04-14 01:41:34 +02:00
Tony Lindgren 0c9888e3c1 power: supply: cpcap-charger: Add minimal CPCAP PMIC battery charger
The custom CPCAP PMIC used on Motorola phones such as Droid 4 has a
USB battery charger. It can optionally also have a companion chip that
is used for wireless charging.

The charger on CPCAP also can feed VBUS for the USB host mode. This
can be handled by the existing kernel phy_companion interface.

Cc: devicetree@vger.kernel.org
Cc: Marcel Partap <mpartap@gmx.net>
Cc: Michael Scott <michael.scott@linaro.org>
Signed-off-by: Tony Lindgren <tony@atomide.com>
Acked-by: Rob Herring <robh@kernel.org>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2017-04-14 01:41:34 +02:00
Hans de Goede da26580f4e power: supply: bq24190_charger: Use extcon to determine ilimit, 5v boost
Add support for monitoring an extcon device with USB SDP/CDP/DCP and HOST
cables and adjust ilimit and enable/disable the 5V boost converter
accordingly. This is necessary on systems where the PSEL pin is hardwired
high and ILIM needs to be set by software based on the detected charger
type, as well as on systems where the 5V boost converter is used, as
that always needs to be enabled from software.

Cc: Liam Breck <kernel@networkimprov.net>
Cc: Tony Lindgren <tony@atomide.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2017-04-14 01:41:34 +02:00
Hans de Goede 99c88eb244 power: supply: bq24190_charger: Add support for bq24192i
The bq24192 and bq24192i are mostly identical to the bq24190, TI even
published a single datasheet for all 3 of them. The difference
between the bq24190 and bq24192[i] is the way charger-type detection
is done, the bq24190 is to be directly connected to the USB a/b lines,
where as the the bq24192[i] has a gpio which should be driven high/low
externally depending on the type of charger connected, from a register
level access pov there is no difference.

The differences between the bq24192 and bq24192i are:
1) Lower default charge rate on the bq24192i
2) Pre-charge-current can be max 640 mA on the bq24192i

On x86/ACPI systems the code which instantiates the i2c client may not
know the exact variant being used, so instead of coding the model-id
in the i2c_id struct and bailing if it does not match, check the reported
model-id matches one of the supported variants.

This commit only adds support for the bq24192i as I don't
have a bq24192 to test with, adding support for the bq24192 should
be as simple as also accepting its model-id in the model-id test.

Cc: Liam Breck <kernel@networkimprov.net>
Cc: Tony Lindgren <tony@atomide.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2017-04-14 01:41:34 +02:00
Hans de Goede 01c0e0a28d power: supply: bq24190_charger: Use i2c-core irq-mapping code
The i2c-core already maps of irqs before calling the driver's probe
function and there are no in tree users of
bq24190_platform_data->gpio_int.

Remove the redundant custom irq-mapping code and just use client->irq.

Cc: Liam Breck <kernel@networkimprov.net>
Cc: Tony Lindgren <tony@atomide.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Acked-by: Tony Lindgren <tony@atomide.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2017-04-14 01:41:34 +02:00
Arnd Bergmann b98074e2ad power: bq24190_charger: mark PM functions as __maybe_unused
Without CONFIG_PM, we get a harmless warning:

drivers/power/supply/bq24190_charger.c:1514:12: error: 'bq24190_runtime_resume' defined but not used [-Werror=unused-function]
drivers/power/supply/bq24190_charger.c:1501:12: error: 'bq24190_runtime_suspend' defined but not used [-Werror=unused-function]

To avoid the warning, we can mark all four PM functions as __maybe_unused,
which also lets us remove the incorrect #ifdef.

Fixes: 3d8090cba638 ("power: bq24190_charger: Check the interrupt status on resume")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Acked-by: Tony Lindgren <tony@atomide.com>
Acked-by: Liam Breck <kernel@networkimprov.net>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2017-04-14 01:41:34 +02:00
Daniel Perez dba8347696 power: supply: sbs-charger: simplified bool function
Signed-off-by: Daniel Perez <danielperezdeandres@gmail.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2017-04-14 01:41:34 +02:00
Munir Contractor d71472465a power: supply: ab8500: Replaced spaces with tabs in indent
This patch fixes 4 checkpatch.pl errors on lines 433 to 436:
ERROR: code indent should use tabs where possible

Signed-off-by: Munir Contractor <munircontractor@gmail.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2017-04-14 01:41:34 +02:00
Andy Shevchenko 867758793a power: supply: bq25890: Use gpiod_get()
Since index is always 0, replace gpiod_get_index() by gpiod_get().

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2017-04-14 01:41:34 +02:00
Dmitry Torokhov 420b2d443b power: supply: twl4030_charger: remove incorrect __exit markups
Even if bus is not hot-pluggable, the devices can be unbound from the
driver via sysfs, so we should not be using __exit annotations on
remove() methods. The only exception is drivers registered with
platform_driver_probe() which specifically disables sysfs bind/unbind
attributes.

Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2017-04-14 01:41:33 +02:00
Linus Walleij f7a388d6cd power: reset: Add a driver for the Gemini poweroff
The Gemini (SL3516) SoC has a special power controller block
that only deal with shutting down the system.

If you do not register a driver and activate the block, the
power button on the systems utilizing this SoC will do an
uncontrolled power cut, which is why it is important to have
a special poweroff driver.

The most basic functionality is to just shut down the system
by writing a special bit in the control register after the
system has reached pm_poweroff.

It also handles the poweroff from a button or other sources:

When the poweroff button is pressed, or a signal is sent to
poweroff from an infrared remote control, or when the RTC
fires a special alarm (!) the system emits an interrupt.
At this point, Linux must acknowledge the interrupt and
proceed to do an orderly shutdown of the system.

After adding this driver, pressing the poweroff button gives
this dmesg:

root@gemini:/
root@gemini:/ gemini-poweroff 4b000000.power-controller:
poweroff button pressed

calling shutdown scripts..
setting /dev/rtc0 from system time
unmounting file systems...
umount: tmpfs busy - remounted read-only
umount: can't unmount /: Invalid argument
The system is going down NOW!
Sent SIGTERM to all processes
Sent SIGKILL to all processes
Requesting system poweroff
uhci_hcd 0000:00:09.1: HCRESET not completed yet!
uhci_hcd 0000:00:09.0: HCRESET not completed yet!
reboot: Power down
gemini-poweroff 4b000000.power-controller: Gemini power off

Cc: Janos Laube <janos.dev@gmail.com>
Cc: Paulius Zaleckas <paulius.zaleckas@gmail.com>
Cc: Hans Ulli Kroll <ulli.kroll@googlemail.com>
Cc: Florian Fainelli <f.fainelli@gmail.com>
Cc: linux-pm@vger.kernel.org
Cc: Sebastian Reichel <sre@kernel.org>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2017-04-14 01:41:33 +02:00
Javier Martinez Canillas da28122c82 power: supply: max17040: Add OF device ID table
The driver doesn't have a struct of_device_id table but supported devices
are registered via Device Trees. This is working on the assumption that a
I2C device registered via OF will always match a legacy I2C device ID and
that the MODALIAS reported will always be of the form i2c:<device>.

But this could change in the future so the correct approach is to have an
OF device ID table if the devices are registered via OF.

Signed-off-by: Javier Martinez Canillas <javier@osg.samsung.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2017-04-14 01:41:33 +02:00
Guy Shapiro f2c199db47 power: reset: syscon-poweroff: add a mask property
Make the syscon-poweroff 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.

Signed-off-by: Guy Shapiro <guy.shapiro@mobi-wize.com>
Acked-by: Rob Herring <robh@kernel.org>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2017-04-14 01:41:33 +02:00
Tony Lindgren f385e6e2a1 power: bq24190_charger: Use PM runtime autosuspend
We can get quite a few interrupts when the battery is trickle charging.
Let's enable PM runtime autosuspend to avoid constantly toggling device
driver PM runtime state.

Let's use a 600 ms timeout as that's how long the USB chager detection
might take.

Acked-by: Mark Greer <mgreer@animalcreek.com>
Acked-by: Liam Breck <kernel@networkimprov.net>
Signed-off-by: Tony Lindgren <tony@atomide.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2017-04-14 01:41:33 +02:00
Tony Lindgren 35c3c196d3 power: bq24190_charger: Check the interrupt status on resume
Some SoCs like omap3 can configure GPIO irqs to use Linux generic
dedicated wakeirq support. If the dedicated wakeirq is configured,
the SoC will use a always-on interrupt controller to produce wake-up
events.

If bq24190 is configured for dedicated wakeirq, we need to check the
interrupt status on PM runtime resume. This is because the Linux
generic wakeirq will call pm_runtime_resume() on the device on a
wakeirq. And as the bq24190 interrupt is falling edge sensitive
and only active for 250 us, there will be no device interrupt seen
by the runtime SoC IRQ controller.

Note that this can cause spurious interrupts on omap3 devices with
bq24190 connected to gpio banks 2 - 5 as there's a glitch on those
pins waking from off mode as listed in "Advisory 1.45". Devices
with this issue should not configure the optional wakeirq interrupt
in the dts file.

Acked-by: Mark Greer <mgreer@animalcreek.com>
Acked-by: Liam Breck <kernel@networkimprov.net>
Signed-off-by: Tony Lindgren <tony@atomide.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2017-04-14 01:41:33 +02:00
David Wu 7db36b1c3c PM / AVS: rockchip-io: add io selectors and supplies for rk3328
This adds the necessary data for handling io voltage domains on the rk3328.
As interesting tidbit, the rk3328 only contains one iodomain area in the
regular General Register Files (GRF).

Signed-off-by: David Wu <david.wu@rock-chips.com>
Reviewed-by: Heiko Stuebner <heiko@sntech.de>
Reviewed-by: Kevin Hilman <khilman@baylibre.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2017-03-12 23:09:10 +01:00
Masahiro Yamada 183b8021fc scripts/spelling.txt: add "intialization" pattern and fix typo instances
Fix typos and add the following to the scripts/spelling.txt:

  intialization||initialization

The "inintialization" in drivers/acpi/spcr.c is a different pattern but
I fixed it as well in this commit.

Link: http://lkml.kernel.org/r/1481573103-11329-16-git-send-email-yamada.masahiro@socionext.com
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2017-02-27 18:43:47 -08:00
Quentin Schulz 744cc304a1 power: supply: add AC power supply driver for AXP20X and AXP22X PMICs
The X-Powers AXP20X and AXP22X PMICs expose the status of AC power
supply.

Moreover, the AXP20X can also expose the current current and voltage
values of the AC power supply.

This adds the driver which exposes the status of the AC power supply of
the AXP20X and AXP22X PMICs.

Signed-off-by: Quentin Schulz <quentin.schulz@free-electrons.com>
Acked-by: Jonathan Cameron <jic23@kernel.org>
Acked-by: Maxime Ripard <maxime.ripard@free-electrons.com>
[removed unused elements from struct axp20x_ac_power]
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2017-01-29 23:15:18 +01:00
Quentin Schulz 33863c938c power: supply: axp20x_usb_power: use IIO channels when available
The X-Powers AXP20X PMIC exposes the current current and voltage
measures via an internal ADC.

This adds the possibility to read IIO channels directly for processed
values rather than reading the registers and computing the value.

For backward compatibility purpose, if the IIO driver is not compiled,
this driver will fall back on previous behaviour which is direct
register readings.

Signed-off-by: Quentin Schulz <quentin.schulz@free-electrons.com>
Acked-by: Maxime Ripard <maxime.ripard@free-electrons.com>
Acked-by: Jonathan Cameron <jic23@kernel.org>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2017-01-29 23:15:17 +01:00
Javier Martinez Canillas 166e8dbd63 power: supply: max14656: Export I2C and OF device ID as module aliases
If the driver is built as a module, I2C module alias information is not
filled so the module won't be autoloaded. Export the I2C and OF devices
ID to the module by using the MODULE_DEVICE_TABLE() macro.

Before this patch:

$ modinfo drivers/power/supply/max14656_charger_detector.ko | grep alias
$

After this patch:

$ modinfo drivers/power/supply/max14656_charger_detector.ko | grep alias
alias:          i2c:max14656
alias:          of:N*T*Cmaxim,max14656C*
alias:          of:N*T*Cmaxim,max14656

Signed-off-by: Javier Martinez Canillas <javier@osg.samsung.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2017-01-29 23:15:17 +01:00
Colin Ian King a1b94355ea power: supply: bq2415x: check for NULL acpi_id to avoid null pointer dereference
acpi_match_device can potentially return NULL, so it is prudent to
check if acpi_id is null before it is dereferenced.  Add a check
and an error message to indicate the failure.

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Reviewed-by: Pali Rohár <pali.rohar@gmail.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2017-01-21 03:35:07 +01:00
Liam Breck cb190af290 power: supply: bq24190_charger: Adjust formatting
Add breathing room in probe() out* section.

Signed-off-by: Liam Breck <kernel@networkimprov.net>
Acked-by: Tony Lindgren <tony@atomide.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2017-01-20 12:45:53 +01:00
Liam Breck ba52e75718 power: supply: bq24190_charger: Handle fault before status on interrupt
Reading both fault and status registers and logging any fault should
take priority over handling status register update.

Fix by moving the status handling to later in interrupt routine.

Fixes: d7bf353fd0 ("bq24190_charger: Add support for TI BQ24190 Battery Charger")
Signed-off-by: Liam Breck <kernel@networkimprov.net>
Acked-by: Mark Greer <mgreer@animalcreek.com>
Acked-by: Tony Lindgren <tony@atomide.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2017-01-20 12:43:11 +01:00
Liam Breck 68abfb8015 power: supply: bq24190_charger: Don't read fault register outside irq_handle_thread()
Caching the fault register after a single I2C read may not keep an accurate
value.

Fix by doing two reads in irq_handle_thread() and using the cached value
elsewhere. If a safety timer fault later clears itself, we apparently don't get
an interrupt (INT), however other interrupts would refresh the register cache.

From the data sheet: "When a fault occurs, the charger device sends out INT
 and keeps the fault state in REG09 until the host reads the fault register.
 Before the host reads REG09 and all the faults are cleared, the charger
 device would not send any INT upon new faults. In order to read the
 current fault status, the host has to read REG09 two times consecutively.
 The 1st reads fault register status from the last read [1] and the 2nd reads
 the current fault register status."

[1] presumably a typo; should be "last fault"

Fixes: d7bf353fd0 ("bq24190_charger: Add support for TI BQ24190 Battery Charger")
Signed-off-by: Liam Breck <kernel@networkimprov.net>
Acked-by: Mark Greer <mgreer@animalcreek.com>
Acked-by: Tony Lindgren <tony@atomide.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2017-01-20 12:43:07 +01:00
Liam Breck 2d9fee6a42 power: supply: bq24190_charger: Call power_supply_changed() for relevant component
We wrongly get uevents for bq24190-charger and bq24190-battery on every
register change.

Fix by checking the association with charger and battery before
emitting uevent(s).

Fixes: d7bf353fd0 ("bq24190_charger: Add support for TI BQ24190 Battery Charger")
Signed-off-by: Liam Breck <kernel@networkimprov.net>
Acked-by: Mark Greer <mgreer@animalcreek.com>
Acked-by: Tony Lindgren <tony@atomide.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2017-01-20 12:43:03 +01:00
Liam Breck d62acc5ef0 power: supply: bq24190_charger: Install irq_handler_thread() at end of probe()
The device specific data is not fully initialized on
request_threaded_irq(). This may cause a crash when the IRQ handler
tries to reference them.

Fix the issue by installing IRQ handler at the end of the probe.

Fixes: d7bf353fd0 ("bq24190_charger: Add support for TI BQ24190 Battery Charger")
Signed-off-by: Liam Breck <kernel@networkimprov.net>
Acked-by: Mark Greer <mgreer@animalcreek.com>
Acked-by: Tony Lindgren <tony@atomide.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2017-01-20 12:42:59 +01:00
Liam Breck e05ad7e074 power: supply: bq24190_charger: Call set_mode_host() on pm_resume()
pm_resume() does a register_reset() which clears charger host mode.

Fix by calling set_mode_host() after the reset.

Fixes: d7bf353fd0 ("bq24190_charger: Add support for TI BQ24190 Battery Charger")
Signed-off-by: Liam Breck <kernel@networkimprov.net>
Acked-by: Mark Greer <mgreer@animalcreek.com>
Acked-by: Tony Lindgren <tony@atomide.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2017-01-20 12:42:55 +01:00
Liam Breck 767eee362f power: supply: bq24190_charger: Fix irq trigger to IRQF_TRIGGER_FALLING
The interrupt signal is TRIGGER_FALLING. This is is specified in the
data sheet PIN FUNCTIONS: "The INT pin sends active low, 256us
pulse to host to report charger device status and fault."

Also the direction can be seen in the data sheet Figure 37 "BQ24190
with D+/D- Detection and USB On-The-Go (OTG)" which shows a 10k
pull-up resistor installed for the sample configurations.

Fixes: d7bf353fd0 ("bq24190_charger: Add support for TI BQ24190 Battery Charger")
Signed-off-by: Liam Breck <kernel@networkimprov.net>
Acked-by: Mark Greer <mgreer@animalcreek.com>
Acked-by: Tony Lindgren <tony@atomide.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2017-01-20 12:42:37 +01:00
Arnd Bergmann 51962a359c power: supply: qcom_smbb: add regulator dependency
The added regulator dependency in the smbb driver causes build errors
when regulators are disabled, e.g. in randconfig build testing:

drivers/power/supply/qcom_smbb.o: In function `smbb_chg_otg_is_enabled':
qcom_smbb.c:(.text.smbb_chg_otg_is_enabled+0x18): undefined reference to `rdev_get_drvdata'
drivers/power/supply/qcom_smbb.o: In function `smbb_charger_probe':
qcom_smbb.c:(.text.smbb_charger_probe+0x410): undefined reference to `devm_regulator_register'

This adds a Kconfig dependency to avoid the link error.

Fixes: 61274eff0d ("power: supply: qcom_smbb: Add otg regulator for control of vbus")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2017-01-18 17:05:49 +01:00
Alexandre Belloni b6d30432e0 power: reset: at91-reset: remove leftover platform_device_id
commit eacd8d09db ("power/reset: at91-reset: remove useless
at91_reset_platform_probe()") removed non DT probe support but forgot to
remove the now useless id_table. Do that now.

Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2017-01-18 17:05:46 +01:00
Szemző András f22dfd86f0 power: reset: at91-reset: add samx7 support
Add samx7 support. It is lacking a few bits and needs a new reset function.

Signed-off-by: Szemző András <sza@esh.hu>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2017-01-18 17:05:38 +01:00
kbuild test robot d04ba0a2cb power: supply: max14656: fix platform_no_drv_owner.cocci warnings
drivers/power/supply/max14656_charger_detector.c:317:3-8:
No need to set .owner here. The core will do it.

Remove .owner field if calls are used which set it automatically

Generated by: scripts/coccinelle/api/platform_no_drv_owner.cocci

CC: Alexander Kurz <akurz@blala.de>
Signed-off-by: Fengguang Wu <fengguang.wu@intel.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2017-01-17 01:10:41 +01:00
Gustavo A. R. Silva e448e2d149 power: supply: pcf50633-charger: Compress return logic into one line.
Simplify return logic to avoid unnecessary variable assignments.
These issues were detected using Coccinelle and the following semantic patch:

@@
local idexpression ret;
expression e;
@@

-ret =
+return
     e;
-return ret;

Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2017-01-17 00:29:16 +01:00
Gustavo A. R. Silva 33237fb8f0 power: supply: ab8500_btemp: Compress return logic into one line.
Simplify return logic to avoid unnecessary variable assignments.
These issues were detected using Coccinelle and the following semantic patch:

@@
local idexpression ret;
expression e;
@@

-ret =
+return
     e;
-return ret;

Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2017-01-17 00:28:38 +01:00
Sebastian Reichel c0d21f73ae Merge branch 'psy-arm-at91-immutable' into psy-next 2017-01-16 23:22:53 +01:00
Alexandre Belloni 0b0408745e power: reset: at91-poweroff: timely shutdown LPDDR memories
LPDDR memories can only handle up to 400 uncontrolled power off. Ensure the
proper power off sequence is used before shutting down the platform.

Cc: <stable@vger.kernel.org> # 4.4+
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2017-01-16 23:21:33 +01:00
Alexander Kurz 9d60595a06 power: supply: Add support for MAX14656 USB charger detector
The MAX14656 USB charger detector, also known as "AL32" is used to detect
the presence and capabilities of attached USB chargers. The device is
attached via I2C plus one interrupt line to signalize events.

The device can be found in LG smartphones like LS665 and LS770, compatible
devices are present in 4th/5th generation Amazon Kindle readers referenced
in source code packages as "Maxim AL32".

The initial version of this driver has been extracted from LG source code
package LGLS665_Android_Lollipop_LS665ZV3, enriched with information from
the Kindle_src_4.1.3 source code package and adapted to the current power
class sysfs interface. Non-Standard Apple chargers which the device may
detect are mapped to the USB Battery Charging Specification Revision 1.2
class USB_DCP.

Signed-off-by: Alexander Kurz <akurz@blala.de>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2017-01-16 23:03:11 +01:00
Bird, Tim 61274eff0d power: supply: qcom_smbb: Add otg regulator for control of vbus
Add a regulator to control the OTG chargepath switch.  This
is used by USB code to control VBUS direction - out for host mode
on the OTG port, and in for charging mode.

Signed-off-by: Tim Bird <tim.bird@sonymobile.com>
Acked-by: Bjorn Andersson <bjorn.andersson@sonymobile.com>
Reviewed-by: Andy Gross <andy.gross@linaro.org>
[stephen.boyd@linaro.org: Fix supply name, constify ops, drop
machine.h and of_regulator.h includes]
Signed-off-by: Stephen Boyd <stephen.boyd@linaro.org>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2017-01-16 23:02:46 +01:00
Chris Lapa 8835cae5f2 power: supply: bq27xxx: adds specific support for bq27520-g4 revision.
This commit adds the BQ27520G4 chip definition to specifically match the
bq27520-G4 functionality as described in the datasheet.

Signed-off-by: Chris Lapa <chris@lapa.com.au>
Acked-by: Pali Rohár <pali.rohar@gmail.com>
Reviewed-by: Andrew F. Davis <afd@ti.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2017-01-12 02:30:13 +01:00
Chris Lapa 825e915ba2 power: supply: bq27xxx: adds specific support for bq27520-g3 revision.
This commit adds the BQ27520G3 chip definition to specifically match the
bq27520-G3 functionality as described in the datasheet.

Signed-off-by: Chris Lapa <chris@lapa.com.au>
Acked-by: Pali Rohár <pali.rohar@gmail.com>
Reviewed-by: Andrew F. Davis <afd@ti.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2017-01-12 02:30:13 +01:00
Chris Lapa a5deb9a930 power: supply: bq27xxx: adds specific support for bq27520-g2 revision.
This commit adds the BQ27520G2 chip definition to specifically match the
bq27520-G2 functionality as described in the datasheet.

Signed-off-by: Chris Lapa <chris@lapa.com.au>
Acked-by: Pali Rohár <pali.rohar@gmail.com>
Reviewed-by: Andrew F. Davis <afd@ti.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2017-01-12 02:30:13 +01:00
Chris Lapa 68f2a813eb power: supply: bq27xxx: adds specific support for bq27520-g1 revision.
This commit adds the BQ27520G1 chip definition to specifically match the
bq27520-G1 functionality as described in the datasheet.

Signed-off-by: Chris Lapa <chris@lapa.com.au>
Acked-by: Pali Rohár <pali.rohar@gmail.com>
Reviewed-by: Andrew F. Davis <afd@ti.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2017-01-12 02:30:13 +01:00
Chris Lapa 71375aa7d6 power: supply: bq27xxx: adds specific support for bq27510-g3 revision.
This commit adds the BQ27510G3 chip definition to specifically match the
bq27510-G3 functionality as described in the datasheet.

Signed-off-by: Chris Lapa <chris@lapa.com.au>
Acked-by: Pali Rohár <pali.rohar@gmail.com>
Reviewed-by: Andrew F. Davis <afd@ti.com>
Tested-by: Chris Lapa <chris@lapa.com.au>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2017-01-12 02:30:13 +01:00
Chris Lapa 698a2bf5fc power: supply: bq27xxx: adds specific support for bq27510-g2 revision.
This commit adds the BQ27510G2 chip definition to specifically match the
bq27510-G2 functionality as described in the datasheet.

Signed-off-by: Chris Lapa <chris@lapa.com.au>
Acked-by: Pali Rohár <pali.rohar@gmail.com>
Reviewed-by: Andrew F. Davis <afd@ti.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2017-01-12 02:30:13 +01:00
Chris Lapa bd28177f3e power: supply: bq27xxx: adds specific support for bq27510-g1 revision.
This commit adds the BQ27510G1 chip definition to specifically match the
bq27510-G1 functionality as described in the datasheet.

Signed-off-by: Chris Lapa <chris@lapa.com.au>
Acked-by: Pali Rohár <pali.rohar@gmail.com>
Reviewed-by: Andrew F. Davis <afd@ti.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2017-01-12 02:30:13 +01:00
Chris Lapa 32833635b0 power: supply: bq27xxx: adds specific support for bq27500/1 revision.
This commit adds the BQ27500 chip definition to specifically match the
bq27500/1 functionality as described in the datasheet.

Signed-off-by: Chris Lapa <chris@lapa.com.au>
Acked-by: Pali Rohár <pali.rohar@gmail.com>
Reviewed-by: Andrew F. Davis <afd@ti.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2017-01-12 02:30:13 +01:00
Chris Lapa 6da6e4bdd3 power: supply: bq27xxx: rename BQ27510 allow for deprecation in future.
The BQ2751X definition exists only to satisfy backwards compatibility.

Signed-off-by: Chris Lapa <chris@lapa.com.au>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2017-01-12 02:30:13 +01:00
Chris Lapa 818e3012c2 power: supply: bq27xxx: rename BQ27500 allow for deprecation in future.
The BQ2750X definition exists only to satisfy backwards compatibility.

Signed-off-by: Chris Lapa <chris@lapa.com.au>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2017-01-12 02:30:13 +01:00
Michal Suchanek 15df6d98ec power: supply: axp20x_usb_power: fix warning on 64bit
Casting of_device_get_match_data return value to int causes warning on 64bit
architectures.

../drivers/power/supply/axp20x_usb_power.c: In function
'axp20x_usb_power_probe':
../drivers/power/supply/axp20x_usb_power.c:297:21: warning: cast from
pointer to integer of different size [-Wpointer-to-int-cast]

Fixes: 0dcc70ca86 ("power: supply: axp20x_usb_power: use of_device_id
    data field instead of device_is_compatible")
Signed-off-by: Michal Suchanek <msuchanek@suse.de>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2017-01-12 01:03:53 +01:00
Chris Lapa e839a44881 power: supply: bq27xxx: move overtemp tests to a switch statement.
This is done for readability as the upcoming commits will add a lot of
cases.

tested: no

Signed-off-by: Chris Lapa <chris@lapa.com.au>
Acked-by: Pali Rohár <pali.rohar@gmail.com>
Reviewed-by: Andrew F. Davis <afd@ti.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2017-01-10 03:45:38 +01:00
Andy Shevchenko af5179a405 power: supply: remove Intel Moorestown battery support
The Moorestown support was removed by commit 1a8359e411 ("x86/mid: Remove
Intel Moorestown").

Remove this leftover.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2017-01-06 00:45:02 +01:00
Linus Walleij fb9a33ae6b power: supply: gpio_charger: switch to using GPIO descriptors
The GPIO charger is using a mix of the legacy GPIO interface
and <linux/of_gpio.h> which is not the modern way to use GPIOs.

Refactor like this:

- Use a GPIO descriptor for the GPIO line used to monitor the
  charger.
- Fetch the descriptor with devm_gpiod_get() as the first
  method.
- If this fails and we are *not* using device tree, then
  start looking to see if we can use platform data instead.
- After looking up and requesting a GPIO number with the
  legacy API, convert it to a descriptor.

This way we can later isolate and drop the legacy code as
more platforms move over to using descriptors.

Cc: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
Cc: Heiko Stuebner <heiko@sntech.de>
Cc: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2017-01-04 22:04:50 +01:00
Colin Ian King c56ca24a01 power: supply: fix spelling mistake: supply: "Celcius" -> "Celsius"
trivial fix to spelling mistake in comments in the headers

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2017-01-04 22:04:46 +01:00
Colin Ian King e3e774186d power: supply: wm97xx_battery: remove redundant 2nd null check on pdata
pdata is being null checked twice, the 2nd check is redundant code
and can be removed.

Fixes CoverityScan CID 1392340 "Logically dead code"

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2017-01-04 22:04:20 +01:00
Hans de Goede 1169735dc2 power: supply: axp288_fuel_gauge: Remove unnecessary irq?_en register writes
Setting the irq_enable bits is taken care of by the irq chip when we
request the irqs and the driver should not be meddling with the
irq?_en registers itself.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2017-01-04 22:03:44 +01:00
Peter Rosin de4fb05142 power: supply: bq24735: bring down the noise level
If there is no ti,ac-detect-gpios configured, it is normal to
have failed reads of the options register. So, hold back on the
log spamming.

Signed-off-by: Peter Rosin <peda@axentia.se>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2017-01-04 22:03:33 +01:00
Peter Rosin dbff4c8eaa power: supply: bq24735: allow polling even if there is no ac-detect gpio
It is possible to verify AC adapter presence via a register read, without
any physical connection to the ACOK pin on the charger. Allow this.

Signed-off-by: Peter Rosin <peda@axentia.se>
Acked-by: Rob Herring <robh@kernel.org>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2017-01-04 22:03:28 +01:00
Hans de Goede 577b1f06e2 power: supply: axp288_charger: Use one notifier_block per extcon cable
Prior to this commit the code was using 1 notifier_block for all
types of charger cable, this is incorrect as the notifier_block
becomes part of a linked-list and now the same notifier_block
is part of 3 linked lists.

This commit fixes this by using a separate nb per extcon cable.

Note this happened to work fine sofar because axp288_charger was the only
listener, so when added to each of the 3 notifier chains, the next pointer
in the nb would be set to 0, so we've 3 heads pointing to the same nb,
with its next pointing to NULL. But as soon as we mix in a second extcon
consumer things will go boom.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2017-01-04 22:03:20 +01:00
Hans de Goede 7def63ca9c power: supply: axp288_charger: Fix the module not auto-loading
Add a MODULE_DEVICE_TABLE to fix the module not auto-loading.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2017-01-04 22:03:16 +01:00
Hans de Goede 620874c2df power: supply: axp288_charger: Remove unnecessary irq?_en register writes
Setting the irq_enable bits is taken care of by the irq chip when we
request the irqs and the driver should not be meddling with the
irq?_en registers itself.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2017-01-04 22:03:12 +01:00
Hans de Goede 8cffbe47e5 power: supply: axp288_charger: Fix wrong regmap_update_bits
To set a bit to 1 one needs to pass the mask for the bit to set
as second argument into regmap_update_bits, not "1".

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2017-01-04 22:03:08 +01:00
Hans de Goede 5c5bcb8c57 power: supply: axp288_charger: Get and process initial hardware-state
Do not wait for an extcon notification before processing the cable
states, instead queue the otg / cable work on probe to make sure we
immediately process the initial hardware state.

Note this also requiree moving the getting of the USB_HOST cable state
from the extcon notifier to the workqueue function.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2017-01-04 22:03:04 +01:00
Hans de Goede bcd39ba732 power: supply: axp288_charger: Some minor cleanups
Remove info->health, info->present and info->online caching, as no code
is reading the cached values.

Remove if (changed) check before calling power_supply_changed(), we
return early from axp288_charger_extcon_evt_worker if nothing has
changed, so the check is not needed.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2017-01-04 22:03:00 +01:00
Hans de Goede 71851a63af power: supply: axp288_charger: Handle charger type changing without disconnect
Deal with the charger type changing without a vbus-disconnect being
reported in between the 2 charger type states:

-Do not return from axp288_charger_extcon_evt_worker early in this case
 (track old_chg_type)
-Make calling axp288_charger_enable_charger with the same value as before
 a nop, to avoid the need for the caller to check this
-Do no do a dev_err when axp288_charger_enable_charger returns an error,
 axp288_charger_enable_charger already returns an error itself
-Disable the charger before changing the charge-current setting (nop if
 vbus was seen as disconnected before the change)

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2017-01-04 22:02:56 +01:00
Hans de Goede 7508f44129 power: supply: axp288_charger: Actually get and use the USB_HOST extcon device
Nothing was setting info->otg.cable, so the extcon_get_cable_state_
calls on it would always return -EINVAL.

This commit fixes this by actually setting info->otg.cable using the new
extcon_get_extcon_dev_by_cable_id function.

This commit also makes failing to register the extcon notifier for the
USB_HOST cable an error rather then a warning, because we MUST have this
notfier to properly disable the VBUS path when in host mode so that we're
not drawing current from the 5V boost converter which is supplying power
to the otg port when in host mode.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2017-01-04 22:02:52 +01:00
Hans de Goede d96e07350a power: supply: axp288_charger: Move init_hw_regs call before supply registration
Move the charger_init_hw_regs() above the power_supply_register call,
the axp288_charger_usb_set_property() uses axp288_chrg_info.max_cv and
.max_cc which get set by charger_init_hw_regs().

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2017-01-04 22:02:47 +01:00
Hans de Goede 42e2008a66 power: supply: axp288_charger: Register extcon notifers after power_supply
The extcon notifier work calls power_supply_changed on the power_supply
we register, so the extcon notifiers should be registered after we
register the power_supply.

While touching this code anyways, refactor the code for the 3 cable types
into a loop to avoid code repetition.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2017-01-04 22:02:39 +01:00
Hans de Goede e3668e37f9 power: supply: axp288_charger: Use devm_power_supply_register
Use devm_power_supply_register instead of power_supply_register,
this avoids the need to do manual cleanup and results in quite
a nice code cleanup.

Note it may seem excessive to add a "struct device *dev" helper local
variable for the 1 time it is used in this patch, but future patches
in this series also use it.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2017-01-04 22:02:31 +01:00
Sebastian Reichel 8bb17b6c83 Merge branch 'psy-mfd-axp288-immutable' into psy-next 2017-01-04 22:01:42 +01:00
Nicolas Saenz Julienne feb583e37f power: supply: add sbs-charger driver
This adds support for sbs-charger compilant chips as defined here:
http://sbs-forum.org/specs/sbc110.pdf

This was tested on a arm board connected to an LTC4100 battery charger
chip.

Signed-off-by: Nicolas Saenz Julienne <nicolas.saenz@prodys.net>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2017-01-04 22:01:00 +01:00
Peter Rosin a7d143d42b power: supply: bq24735: always check for AC adapter presence in probe
So what if there is a status_gpio specified? bq24735_charger_is_present()
do have a working fallback for the case of no status_gpio.

Simplify this by not special casing setups w/o status_gpio, folding
two consecutive if-blocks in the process.

Signed-off-by: Peter Rosin <peda@axentia.se>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2017-01-04 22:00:52 +01:00
Peter Rosin a07bea32c6 power: supply: bq24735: configure the charger as part of enabling it
During probe, it makes no sense to take care to first not issue any
i2c commands to verify if the connected part really is a bq24735, to
later simply fail the probe in the next step when trying to configure
the charger. So, delay configuration of the charging parameters until
the charger is accessible (i.e. when the AC adapter is present) as
part of enabling the charging.

This also fixes the rather serious issue that the charging parameters
are lost when the AC adapter is disconnected.

Signed-off-by: Peter Rosin <peda@axentia.se>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2017-01-04 22:00:48 +01:00
Peter Rosin 2e66585ca2 power: supply: bq24735: move down bq24735_{en,dis}able_charging
bq24735_enable_charging() needs to call bq24735_config_charging(),
which is something to change later, this is just a preparatory patch.

Signed-off-by: Peter Rosin <peda@axentia.se>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2017-01-04 22:00:41 +01:00
Milo Kim 5b903a1555 power: supply: tps65217: Use generic charger name
"tps65217-charger" is more appropriate name because the driver supports
not only AC but also USB charger.

Signed-off-by: Milo Kim <woogyom.kim@gmail.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2017-01-04 22:00:37 +01:00
Milo Kim 757620c4e4 power: supply: tps65217: Use generic name for get_property()
Rename it as tps65217_charger_get_property().

Signed-off-by: Milo Kim <woogyom.kim@gmail.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2017-01-04 22:00:33 +01:00
Milo Kim da50b3a584 power: supply: tps65217: Use generic name for power supply property
Replace 'ac_props' with 'charger_props'.

Signed-off-by: Milo Kim <woogyom.kim@gmail.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2017-01-04 22:00:29 +01:00
Milo Kim 3967d1f91c power: supply: tps65217: Use generic name for power supply structure
Replace 'ac' of tps65217_charger structure with 'psy'.

Signed-off-by: Milo Kim <woogyom.kim@gmail.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2017-01-04 22:00:25 +01:00
Milo Kim 3c2e58a6d7 power: supply: tps65217: Use generic name for charger online
This driver supports AC and USB chargers. Generic name is preferred.
Replace 'ac_online' with 'online'.

Signed-off-by: Milo Kim <woogyom.kim@gmail.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2017-01-04 22:00:21 +01:00
Milo Kim 20a7e173c2 power: supply: tps65217: Support USB charger interrupt
TPS65217 has two charger interrupts - AC and USB power status change.

Interrupt number in the TPS65217 driver data:
  IRQ number is only used on requesting the interrupt, so no need to keep
  it inside the driver data.

Interrupt handler:
  Check not only AC but also USB charger status.
  In both cases, enable charging operation.

Interrupt request:
  If an interrupt number is invalid, then use legacy polling thread.
  Otherwise, create IRQ threads to handle AC and USB charger event.

Signed-off-by: Milo Kim <woogyom.kim@gmail.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2017-01-04 22:00:18 +01:00
Milo Kim 9ef0bf1184 power: supply: tps65217: Use 'poll_task' on unloading the module
Use the task_struct variable for running polling thread. If polling task
is activated, then use it to stop running thread.
This is a preceding step of supporting two interrupts of TPS65217 charger,
so checking single IRQ number is not appropriate when the module is removed.

Signed-off-by: Milo Kim <woogyom.kim@gmail.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2017-01-04 22:00:14 +01:00
Chanwoo Choi bdca5d9e6b power: supply: qcom_smbb: Replace the deprecated extcon API
This patch replaces the deprecated extcon API as following:
- extcon_set_cable_state_() -> extcon_set_state_sync()

Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2017-01-04 22:00:07 +01:00
Chanwoo Choi c31480348f power: supply: axp288_charger: Replace the extcon API
This patch uses the resource-managed extcon API for extcon_register_notifier()
and replaces the deprecated extcon API as following:
- extcon_get_cable_state_() -> extcon_get_state()

Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2017-01-04 22:00:02 +01:00
Srikant Ritolia a50b0dbbaf power: supply: max8997_charger: Using device managed API and remove OOM print
Use managed resource function devm_power_supply_register instead of
power_supply_register to simplify the error path by allowing unregistering
to happen automatically on error and remove.
Removing max8997_battery_remove function also as it is now redundant.

Also removing out of memory printk message after kzalloc as there is
already enough information on failure.

Signed-off-by: Srikant Ritolia <s.ritolia@samsung.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2017-01-04 21:59:56 +01:00
Quentin Schulz 50111d3f88 power: supply: axp20x_usb_power: add 100mA max current limit for AXP223
The X-Powers AXP223 shares most of its behaviour with the AXP221 PMIC
but allows the VBUS power supply max current to be set to 100mA (like
the AXP209 PMIC).

This basically adds a new compatible to the VBUS power supply driver and
adds a check on the compatible when setting current max limit.

Signed-off-by: Quentin Schulz <quentin.schulz@free-electrons.com>
Acked-by: Chen-Yu Tsai <wens@csie.org>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2017-01-04 21:59:46 +01:00
Quentin Schulz 5c3ff59b4e power: supply: axp20x_usb_power: set min voltage and max current from sysfs
AXP20X and AXP22X PMICs allow setting the min voltage and max current of
VBUS power supply. This adds entries in sysfs to allow to do so.

Signed-off-by: Quentin Schulz <quentin.schulz@free-electrons.com>
Acked-by: Chen-Yu Tsai <wens@csie.org>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2017-01-04 21:59:34 +01:00
Quentin Schulz 0dcc70ca86 power: supply: axp20x_usb_power: use of_device_id data field instead of device_is_compatible
This replaces calls to of_device_is_compatible to check data field of
of_device_id matched when probing the driver.

Signed-off-by: Quentin Schulz <quentin.schulz@free-electrons.com>
Acked-by: Chen-Yu Tsai <wens@csie.org>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2017-01-04 21:59:30 +01:00
Peter Rosin bf383fea1f power: supply: bq24735-charger: optionally poll the ac-detect gpio
If the ac-detect gpio does not support interrupts, provide a fallback
to poll the gpio at a configurable interval.

Signed-off-by: Peter Rosin <peda@axentia.se>
Acked-by: Rob Herring <robh@kernel.org>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2017-01-04 21:59:23 +01:00
Hans de Goede 248efcf006 power: supply: axp288_fuel_gauge: Read 12 bit values 2 registers at a time
In order for the MSB -> LSB latching to work correctly we must read the
2 8 bit registers of a 12 bit value in one consecutive read.

This fixes voltage_ocv reporting inconsistent values on my tablet.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2017-01-04 21:59:17 +01:00
Hans de Goede 4949fc5e07 power: supply: axp288_fuel_gauge: Read 15 bit values 2 registers at a time
In order for the MSB -> LSB latching to work correctly we must read the
2 8 bit registers of a 15 bit value in one consecutive read.

This fixes charge_full reporting 3498768 on some reads and 3354624 one
other reads on my tablet (for the 3354624 value the raw LSB is 0x00).

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2017-01-04 21:59:13 +01:00
Hans de Goede 6f074bc878 power: supply: axp288_fuel_gauge: Fix fuel_gauge_reg_readb return on error
If reading the register fails, return the actual error code, instead
of the uninitialized val variable;

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2017-01-04 21:59:08 +01:00
Peter Rosin d0ddcba9e9 power: supply: bq24735-charger: simplify register update to stop charging
Providing value bits outside of the mask is pointless.

Signed-off-by: Peter Rosin <peda@axentia.se>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2017-01-04 21:58:42 +01:00
Hans de Goede 888f97435a power: supply: axp288_fuel_gauge: Drop platform_data dependency
When the axp288_faul_gauge driver was originally merged, it was
merged with a dependency on some other driver providing platform
data for it.

However the battery-data-framework which should provide that data
never got merged, resulting in x86 tablets / laptops with an axp288
having no working battery monitor, as before this commit the driver
would simply return -ENODEV if there is no platform data.

This commit removes the dependency on the platform_data instead
checking that the firmware has initialized the fuel-gauge and
reading the info back from the pmic.

What is missing from the read-back info is the table to map raw adc
values to temperature, so this commit drops the temperature and
temperature limits properties. The min voltage, charge design and
model name info is also missing. Note that none of these are really
important for userspace to have.

All other functionality is preserved and actually made available
by this commit.

BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=88471
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2017-01-04 21:56:10 +01:00
Hans de Goede eac53b3664 power: supply: axp288_charger: Drop platform_data dependency
When the axp288_charger driver was originally merged, it was merged with
a dependency on some other driver providing platform data for it.

However the battery-data-framework which should provide that data never
got merged, so the axp288_charger as merged upstream has never worked,
its probe method simply always returns -ENODEV.

This commit removes the dependency on the platform_data instead reading
back the charging current and charging voltage that the firmware has set
and using those values as the maximum values the user may set.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2017-01-04 21:54:58 +01:00
Hans de Goede d556f21cb0 power: supply: axp288_charger: Make charger_init_hw_regs propagate i2c errors
Make charger_init_hw_regs propagate i2c errors, instead of only warning
about them and then ignoring them.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2017-01-04 21:54:53 +01:00
Thomas Gleixner 8b0e195314 ktime: Cleanup ktime_set() usage
ktime_set(S,N) was required for the timespec storage type and is still
useful for situations where a Seconds and Nanoseconds part of a time value
needs to be converted. For anything where the Seconds argument is 0, this
is pointless and can be replaced with a simple assignment.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Peter Zijlstra <peterz@infradead.org>
2016-12-25 17:21:22 +01:00
Linus Torvalds bbcd9c53c7 power supply and reset changes for the v4.10 series
* New driver for Intel PIIX4
 * lots of module autoload fixes
 * misc. fixes
 -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCgAdFiEE72YNB0Y/i3JqeVQT2O7X88g7+poFAlhRSwwACgkQ2O7X88g7
 +ppsxQ/7BMBtkVlr2lLFfognswP87r6cqeEhKICpxbgk1KfcTG7xJ/AEyPUDflET
 htPTurpcetlJLB1057ikSt9QTMtyIBUgpbnM+oJt0EVj/UYV6mXw6rqkNX/ROfVY
 JcIN1/nQljv3W//tR83x04TJv+8V65lV/Jrh3XkNS2arRXCD/JktRNljvgUpn2iw
 Tp9MM8eyv9J4VN5BCPudyBOU0Y6ztC9VVDj/p+I7giUOm3udAvgYvcOTqBdCcuZH
 ThDnf8dLNWmTkLTWqPBCnmfe2TyS8IbWMYMtYec3E5NzymzuYA1r0U1wBRVLm4BA
 LFeEXLtmRx3pXt6YY2MqPF9jQGhMsiDdKhHmF0GhpofEk1Ctu0xzCyvA1wxtLq/I
 bt006d5tu1Y+yFu1t0iPCEtGP5H2dt1p9Rq4EM7rgEodIsolIdD5h/Fdc3g7IdRK
 1HgkKhzEOT4+WrIyT3HoI8k8lgFmYs8BumbLTYIR6j/XD8ZBO8Dk4pljyL3B4lur
 qszI73U1yp5iEq4/Mcam1LHwfOxt7liYPrqDiZgUDuK3QAy4Z2lQTjXbaEaTCgN9
 Z5YUSh9RrCTYhAcy5zNEeoixfnDxB7G09v7+5Cfh4RJnZZ2tBL5sQSbMZMgTjbRT
 Trbupf9z7ItYNRerEm+2vSgOTkQpj2V6SaP+jrEl/il0/UDLVoo=
 =s+mK
 -----END PGP SIGNATURE-----

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

Pull power supply and reset updates from Sebastian Reichel:

 - new driver for Intel PIIX4

 - lots of module autoload fixes

 - misc fixes

* tag 'for-v4.10' of git://git.kernel.org/pub/scm/linux/kernel/git/sre/linux-power-supply:
  power_supply: wm97xx_battery: use power_supply_get_drvdata
  wm8350_power: use permission-specific DEVICE_ATTR variants
  power: ipaq_micro_battery: fix alias
  power: supply: bq27xxx_battery: Fix register map for BQ27510 and BQ27520
  bq24190_charger: Fix PM runtime use for bq24190_battery_set_property
  power: supply: lp8788: remove an unneeded NULL check
  power: reset: zx-reboot: Fix module autoload
  power: reset: syscon-reboot-mode: Fix module autoload
  power: reset: at91-poweroff: Fix module autoload
  power: reset: at91-reset: Fix module autoload
  power: supply: axp288_fuel_gauge: Fix module autoload
  power: supply: max8997_charger: Fix module autoload
  power: supply: max17040: Change register transaction length from 8 bits to 16 bits
  power: supply: bq27xxx_battery: don't update poll_interval param if same
  power: supply: improve function-level documentation
  power: reset: Add Intel PIIX4 poweroff driver
2016-12-14 11:18:51 -08:00
Robert Jarzmik 6480af4915 power_supply: wm97xx_battery: use power_supply_get_drvdata
As the power supply framework provides a way to store and retrieve
private supply data, use it.

In the process, change the platform data for wm97xx_battery from a
container of a single struct wm97xx_batt_pdata to the direct point to wm97xx_batt_pdata.

Signed-off-by: Robert Jarzmik <robert.jarzmik@free.fr>
Acked-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2016-11-23 23:48:12 +01:00
Julia Lawall 8d4124cb94 wm8350_power: use permission-specific DEVICE_ATTR variants
Use DEVICE_ATTR_RO for read only attributes.  This simplifies the source
code, improves readbility, and reduces the chance of inconsistencies.

The semantic patch that makes this change is as follows:
(http://coccinelle.lip6.fr/)

// <smpl>
@ro@
declarer name DEVICE_ATTR;
identifier x,x_show;
@@

DEVICE_ATTR(x, \(0444\|S_IRUGO\), x_show, NULL);

@script:ocaml@
x << ro.x;
x_show << ro.x_show;
@@

if not (x^"_show" = x_show) then Coccilib.include_match false

@@
declarer name DEVICE_ATTR_RO;
identifier ro.x,ro.x_show;
@@

- DEVICE_ATTR(x, \(0444\|S_IRUGO\), x_show, NULL);
+ DEVICE_ATTR_RO(x);
// </smpl>

Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
Acked-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2016-11-23 23:46:20 +01:00
Russell King 5ee1d39e1c power: ipaq_micro_battery: fix alias
The alias for the ipaq_micro_battery driver is incorrect, fix it so the
module can be auto-loaded.

Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2016-11-23 23:44:40 +01:00
Andrew F. Davis 3bee9ea1de power: supply: bq27xxx_battery: Fix register map for BQ27510 and BQ27520
The BQ27510 and BQ27520 use a slightly different register map than the
BQ27500, add a new type enum and add these gauges to it.

Fixes: d74534c277 ("power: bq27xxx_battery: Add support for additional bq27xxx family devices")
Based-on-patch-by: Kenneth R. Crudup <kenny@panix.com>
Signed-off-by: Andrew F. Davis <afd@ti.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2016-11-23 23:37:27 +01:00
Tony Lindgren 075eb5719d bq24190_charger: Fix PM runtime use for bq24190_battery_set_property
There's a typo, it should do pm_runtime_get_sync, not put.

Fixes: d7bf353fd0 ("bq24190_charger: Add support for TI BQ24190 Battery Charger")
Cc: Mark A. Greer <mgreer@animalcreek.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>
Reviewed-by: Mark Greer <mgreer@animalcreek.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2016-11-23 23:27:41 +01:00
Shawn Lin f526140249 PM / AVS: rockchip-io: make the log more consistent
When testing SD hotplug automatically, I got bunch of
useless log like this:

[  588.357838] mmc0: card 0007 removed
[  589.492664] rockchip-iodomain ff770000.syscon:io-domains: Setting to 3300000 done
[  589.500698] vccio_sd: ramp_delay not set
[  589.504817] rockchip-iodomain ff770000.syscon:io-domains: Setting to 3300000 done
[  589.669705] rockchip-iodomain ff770000.syscon:io-domains: Setting to 3300000 done
[  589.677593] vccio_sd: ramp_delay not set
[  589.681581] rockchip-iodomain ff770000.syscon:io-domains: Setting to 1800000 done
[  590.032820] dwmmc_rockchip ff0c0000.dwmmc: Successfully tuned phase to 140
[  590.039725] mmc0: new ultra high speed SDR50 SDHC card at address 0007
[  590.046641] mmcblk0: mmc0:0007 SD32G 29.3 GiB
[  590.052163]  mmcblk0: p1

Moreover the code is intent to print the 'uV' for debug but
later print it using dev_info. It looks more like to me that
it should be the real intention of the code. Anyway, let's
mark this verbose log as debug message.

Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
Reviewed-by: Heiko Stuebner <heiko@sntech.de>
Acked-by: Kevin Hilman <khilman@baylibre.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2016-10-21 14:51:03 +02:00
Dan Carpenter 44fccac4ff power: supply: lp8788: remove an unneeded NULL check
We checked that "pdata->chg_params" is non-NULL earlier in this function
so when we add "i" to it, it's still non-NULL.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Acked-by: Milo Kim <milo.kim@ti.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2016-10-19 05:36:09 +02:00
Javier Martinez Canillas 93f7c27b4d power: reset: zx-reboot: Fix module autoload
If the driver is built as a module, autoload won't work because the module
alias information is not filled. So user-space can't match the registered
device with the corresponding module.

Export the module alias information using the MODULE_DEVICE_TABLE() macro.

Before this patch:

$ modinfo drivers/power/reset/zx-reboot.ko | grep alias
$

After this patch:

$ modinfo drivers/power/reset/zx-reboot.ko | grep alias
alias:          of:N*T*Czte,sysctrlC*
alias:          of:N*T*Czte,sysctrl

Signed-off-by: Javier Martinez Canillas <javier@osg.samsung.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2016-10-19 05:16:09 +02:00
Javier Martinez Canillas 0a27aa9c31 power: reset: syscon-reboot-mode: Fix module autoload
If the driver is built as a module, autoload won't work because the module
alias information is not filled. So user-space can't match the registered
device with the corresponding module.

Export the module alias information using the MODULE_DEVICE_TABLE() macro.

Before this patch:

$ modinfo drivers/power/reset/syscon-reboot-mode.ko | grep alias
$

After this patch:

$ modinfo drivers/power/reset/syscon-reboot-mode.ko | grep alias
alias:          of:N*T*Csyscon-reboot-modeC*
alias:          of:N*T*Csyscon-reboot-mode

Signed-off-by: Javier Martinez Canillas <javier@osg.samsung.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2016-10-19 05:16:09 +02:00
Javier Martinez Canillas c9ba9b7763 power: reset: at91-poweroff: Fix module autoload
If the driver is built as a module, autoload won't work because the module
alias information is not filled. So user-space can't match the registered
device with the corresponding module.

Export the module alias information using the MODULE_DEVICE_TABLE() macro.

Before this patch:

$ modinfo drivers/power/reset/at91-poweroff.ko | grep alias
$

After this patch:

$ modinfo drivers/power/reset/at91-poweroff.ko | grep alias
alias:          of:N*T*Catmel,at91sam9x5-shdwcC*
alias:          of:N*T*Catmel,at91sam9x5-shdwc
alias:          of:N*T*Catmel,at91sam9rl-shdwcC*
alias:          of:N*T*Catmel,at91sam9rl-shdwc
alias:          of:N*T*Catmel,at91sam9260-shdwcC*
alias:          of:N*T*Catmel,at91sam9260-shdwc

Signed-off-by: Javier Martinez Canillas <javier@osg.samsung.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2016-10-19 05:16:09 +02:00
Javier Martinez Canillas 991de44036 power: reset: at91-reset: Fix module autoload
If the driver is built as a module, autoload won't work because the module
alias information is not filled. So user-space can't match the registered
device with the corresponding module.

Export the module alias information using the MODULE_DEVICE_TABLE() macro.

Before this patch:

$ modinfo drivers/power/reset/at91-reset.ko | grep alias
$

After this patch:

$ modinfo drivers/power/reset/at91-reset.ko | grep alias
alias:          of:N*T*Catmel,sama5d3-rstcC*
alias:          of:N*T*Catmel,sama5d3-rstc
alias:          of:N*T*Catmel,at91sam9g45-rstcC*
alias:          of:N*T*Catmel,at91sam9g45-rstc
alias:          of:N*T*Catmel,at91sam9260-rstcC*
alias:          of:N*T*Catmel,at91sam9260-rstc
alias:          platform:at91-sam9g45-reset
alias:          platform:at91-sam9260-reset

Signed-off-by: Javier Martinez Canillas <javier@osg.samsung.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2016-10-19 05:16:09 +02:00
Javier Martinez Canillas 99e33fbdff power: supply: axp288_fuel_gauge: Fix module autoload
If the driver is built as a module, autoload won't work because the module
alias information is not filled. So user-space can't match the registered
device with the corresponding module.

Export the module alias information using the MODULE_DEVICE_TABLE() macro.

Before this patch:

$ modinfo drivers/power/supply/axp288_fuel_gauge.ko | grep alias
$

After this patch:

$ modinfo drivers/power/supply/axp288_fuel_gauge.ko | grep alias
alias:          platform:axp288_fuel_gauge

Signed-off-by: Javier Martinez Canillas <javier@osg.samsung.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2016-10-19 05:15:07 +02:00
Javier Martinez Canillas a5a8539927 power: supply: max8997_charger: Fix module autoload
If the driver is built as a module, autoload won't work because the module
alias information is not filled. So user-space can't match the registered
device with the corresponding module.

Export the module alias information using the MODULE_DEVICE_TABLE() macro.

Before this patch:

$ modinfo drivers/power/supply/max8997_charger.ko | grep alias
$

After this patch:

$ modinfo drivers/power/supply/max8997_charger.ko | grep alias
alias:          platform:max8997-battery

Signed-off-by: Javier Martinez Canillas <javier@osg.samsung.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2016-10-19 05:15:07 +02:00
Liu Xiang 14d60bdd1e power: supply: max17040: Change register transaction length from 8 bits to 16 bits
According to the datasheet, MAX17040 has six 16-bit registers.
Register reads and writes are only valid if all 16 bits are transferred.
Any write command that is terminated early is ignored.
So it's better to change register transacton length from 8 bits to 16 bits.

Signed-off-by: Liu Xiang <liu.xiang6@zte.com.cn>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2016-10-19 05:06:32 +02:00
Matt Ranostay 950b6c2d11 power: supply: bq27xxx_battery: don't update poll_interval param if same
To avoid canceling the delayed workqueue needlessly, and scheduling an
immediate polling. Check if the new poll_interval value is different
than the previous setting.

Cc: Tony Lindgren <tony@atomide.com>
Cc: Sebastian Reichel <sre@kernel.org>
Signed-off-by: Matt Ranostay <matt@ranostay.consulting>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2016-10-19 05:06:28 +02:00
Julia Lawall 32c52eff6a power: supply: improve function-level documentation
In drivers/power/supply/ab8500_fg.c, fix two typos and adjust the function
name in two cases to correspond to the names of the defined functions.

In drivers/power/supply/power_supply_core.c, change two variable names to
the names of the corresponding parameters.

Issue detected using Coccinelle (http://coccinelle.lip6.fr/)

Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2016-10-19 05:06:22 +02:00
Paul Burton 29676833df power: reset: Add Intel PIIX4 poweroff driver
Add a driver which allows powering off the system via an Intel PIIX4
southbridge, by entering the PIIX4 SOff state. This is useful on the
MIPS Malta development board, where it will power down the FPGA based
board until its ON/NMI button is pressed, or the QEMU implementation of
the MIPS Malta board where it will cause QEMU to exit.

Signed-off-by: Paul Burton <paul.burton@imgtec.com>
Cc: Sebastian Reichel <sre@kernel.org>
Cc: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
Cc: David Woodhouse <dwmw2@infradead.org>
Cc: linux-pm@vger.kernel.org
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2016-10-18 05:13:37 +02:00
Linus Torvalds 021723e6c5 power supply and reset changes for the v4.9 series
* move power supply drivers to drivers/power/supply
  * unify location of power supply DT documentation
  * tps65217-charger: IRQ support
  * act8945a-charger: misc. cleanups & improvements
  * sbs-battery cleanup
  * fix users of deprecated create_singlethread_workqueue()
  * misc fixes.
 -----BEGIN PGP SIGNATURE-----
 
 iQIcBAABCgAGBQJX8j3bAAoJENju1/PIO/qavlcP/Rq5LeMol2KYQfYOLrVKmS9N
 sqJpOM1wnQS25Dw+KQf+bNOLuBY/w44SnINFYswV2Vw5DQ2ODt1IzvqoaPBwznpq
 BeLN/NLvYY2vIAPxmHxvdB0mnPEhRJOgZkHXUkonIqX98qnzbIorQtHBhAZ3h2v6
 nz5ltO3GXiAyzPE6Zhx9OWWTZRLi1YKCuPZstRU6SY6uGwEMyEVMcu6Rv3XFizBj
 kng9nOCWRE3723UaGQx3LumI2EIsJ1m7RDHIx0ZPOIRlUEd5bawhxdhfT1pQAEZS
 y7GSs4FE86QuGN4M+zcxr4u1vSmYsK2c7FGFRnBcwG4Hkmy4O4h1yBjmrMby8eWo
 V0JxsGkkN+R/6/cAKqXRL0T5gU4rKf4LAj84kSOHGZDiQk0D29wGNZuBtlQw/2sB
 CLABJvpn11aQ3NIkNttr1ur8S15C9tAEMKmjrK7bbvtzBUp2BoVguYQtkP909s0U
 19exP0yslM95t0cRT6lCpZUPFUvoEDs7iIDwv7QBFJSB2ZDMUFfGy6ouM6gHnfKL
 ZkiCi2gmhTqHCpGvD/yi8FhuDFBZ7Ujcotzn3bE07GSTeG7FmzhR+6khedq9DIYQ
 xJbDdPwmwhbrOe99O0wk/qFCBcvgmkXaE4O23fBPS10oCs70FFseYFfb15qAljsE
 4ydoaCMwFUgH49SpDQC6
 =HpLI
 -----END PGP SIGNATURE-----

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

Pull power supply and reset updates from Sebastian Reichel:
 - move power supply drivers to drivers/power/supply
 - unify location of power supply DT documentation
 - tps65217-charger: IRQ support
 - act8945a-charger: misc. cleanups & improvements
 - sbs-battery cleanup
 - fix users of deprecated create_singlethread_workqueue()
 - misc fixes.

* tag 'for-v4.9' of git://git.kernel.org/pub/scm/linux/kernel/git/sre/linux-power-supply: (46 commits)
  power: supply: bq27xxx_battery: allow kernel poll_interval parameter runtime update
  power: supply: sbs-battery: Cleanup removal of chip->pdata
  power: reset: st: Remove obsolete platforms from dt doc
  power: reset: st-poweroff: Remove obsolete platforms.
  power: reset: zx-reboot: Unmap region obtained by of_iomap
  power: reset: xgene-reboot: Unmap region obtained by of_iomap
  power: supply: ab8500: cleanup with list_first_entry_or_null()
  power: reset: add in missing white space in error message text
  sbs-battery: make writes to ManufacturerAccess optional
  power: bq24257: Fix use of uninitialized pointer bq->charger
  power: supply: sbs-battery: simplify DT parsing
  power: supply: bq24735-charger: Request status GPIO with initial input setup
  power: supply: sbs-battery: Use gpio_desc and sleeping calls for battery detect
  power: supply: act8945a_charger: Add max current property
  power: supply: act8945a_charger: Add capacity level property
  doc: bindings: power: act8945a-charger: Update properties.
  power: supply: act8945a_charger: Fix the power supply type
  power: supply: act8945a_charger: Add status change update support
  power: supply: act8945a_charger: Improve state handling
  power: supply: act8945a_charger: Remove "battery_temperature"
  ...
2016-10-06 18:21:15 -07:00
Matt Ranostay 1d72706f04 power: supply: bq27xxx_battery: allow kernel poll_interval parameter runtime update
Fix issue with poll_interval being not updated till the previous
interval expired.

Cc: Tony Lindgren <tony@atomide.com>
Cc: Liam Breck <liam@networkimprov.net>
Signed-off-by: Matt Ranostay <matt@ranostay.consulting>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2016-09-21 02:08:04 +02:00
Phil Reid 389958bb6b power: supply: sbs-battery: Cleanup removal of chip->pdata
There where still a few lingering references to pdata after commit
power: supply: sbs-battery: simplify DT parsing.

Remove pdata from struct·sbs_info and conditional checks to ser if this
was set from the i2c read / write functions.
Instead of call max in each function for incrementing poll_retry_count
do it once in the probe function.
Fixup null pointer dereference in to pdata in sbs_external_power_changed.
Change retry counts to u32 to avoid need for max.

Signed-off-by: Phil Reid <preid@electromag.com.au>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2016-09-21 02:04:47 +02:00
Peter Griffin 8ad5d85efd power: reset: st-poweroff: Remove obsolete platforms.
This patch removes support for STiH415/6 SoC's from the
st-poweroff driver, as support for these platforms is
being removed from the kernel.

Signed-off-by: Peter Griffin <peter.griffin@linaro.org>
Cc: <linux-pm@vger.kernel.org>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2016-09-19 21:32:22 +02:00
Arvind Yadav 7531be5cdf power: reset: zx-reboot: Unmap region obtained by of_iomap
Free memory mapping, if probe is not successful.

Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2016-09-19 21:25:41 +02:00
Arvind Yadav 896af83ef6 power: reset: xgene-reboot: Unmap region obtained by of_iomap
Free memory mapping, if probe is not successful.

Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2016-09-19 21:24:06 +02:00
Masahiro Yamada f04f7aef7f power: supply: ab8500: cleanup with list_first_entry_or_null()
The combo of list_empty() check and return list_first_entry()
can be replaced with list_first_entry_or_null().

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2016-09-19 21:22:10 +02:00