pda_power: Complain if regulator operations fail

Rather than silently ignoring errors from the regulator enable and disable
add a WARN_ON() - it's probably pretty important if we're not getting
power, though it should be vanishingly unlikely in production.

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: Anton Vorontsov <cbouatmailru@gmail.com>
ds2781_battery: w1_ds2781_read() should be static

This patch fixes the following sparse warning:

  CHECK   drivers/power/ds2781_battery.c
drivers/power/ds2781_battery.c:72:5: warning: symbol 'w1_ds2781_read' was not declared. Should it be static?

Signed-off-by: Anton Vorontsov <cbouatmailru@gmail.com>
power_supply: Register battery as a thermal zone

Battery and charger contribute to Thermals in most of the embedded
devices. So, it makes sense to identify them as Thermal zones in a
particular platform.

This patch registers a thermal zone if the power supply is reporting
a temperature property. The thermal zone will be used by platform's
thermal management solution.

Signed-off-by: Jenny TC <jenny.tc@intel.com>
Signed-off-by: Anton Vorontsov <cbouatmailru@gmail.com>
power_supply: Add constant charge_current and charge_voltage properties

Constant Charge Current(CC) is charging parameter which limit the
maximum current which can be pumped into the battery during charge cycle.

Constant Charge Voltage(CV) is also charging parameter which limit the
maximum voltage that battery can reach during charge cycle.

It is very common practice that at low or high temperatures we
do not charge the batteries upto it's fullest charge voltage
to avoid battery and user safety issues.

These sysfs properties will be useful for debug and to implement
certain user space policies like "Charging limited due to OverTemp".

Signed-off-by: Ramakrishna Pallala <ramakrishna.pallala@intel.com>
Signed-off-by: Anton Vorontsov <cbouatmailru@gmail.com>
smb347-charger: Add constant charge and current properties

This patch makes use of the two new properties in smb347 charger driver.

Signed-off-by: Ramakrishna Pallala <ramakrishna.pallala@intel.com>
Signed-off-by: Anton Vorontsov <cbouatmailru@gmail.com>
max17042_battery: Support CHARGE_COUNTER power supply attribute

This patch adds the support for CHARGE_COUNTER power supply attribute
to max17042/47 driver.

Note:QH(Charge Counter) register is not documented in max17042 the Spec.

Signed-off-by: Ramakrishna Pallala <ramakrishna.pallala@intel.com>
Signed-off-by: Anton Vorontsov <cbouatmailru@gmail.com>
twl4030_charger: Fix some typos

Signed-off-by: NeilBrown <neilb@suse.de>
Signed-off-by: Anton Vorontsov <cbouatmailru@gmail.com>
twl4030_charger: Add backup-battery charging

This allows a voltage and current (bb_uvolts and bb_uamps) to be
specified in the platform_data, and charging of the backup battery will
be enabled with those specification.

As it is not possible to monitor the backup battery at all there is no
new device created to represent it.

Signed-off-by: NeilBrown <neilb@suse.de>
Signed-off-by: Anton Vorontsov <cbouatmailru@gmail.com>
twl4030_charger: Allow charger to control the regulator that feeds it

The charger needs usb3v1 to be running, so add a new consumer to
keep it running.

This allows the charger to draw current even when the USB driver has
powered down.

Signed-off-by: NeilBrown <neilb@suse.de>
Acked-by: Tero Kristo <t-kristo@ti.com>
Acked-by: Samuel Ortiz <sameo@linux.intel.com>
Signed-off-by: Anton Vorontsov <cbouatmailru@gmail.com>
sbs-battery: Don't trigger false supply_changed event

power_supply_changed() events are triggerd based on the return value
of a get_property() call. However the property TECHNOLOGY is
hard-coded to LION in this driver, thus always succeeds.

So, with the battery removed, this triggers a false battery present
uevent. This uevent triggers a new query via power_supply_uevent()
which again starts to query all known properties and thus leads to
an infinite loop of battery present/not-present uevents.

This patch skips the battery presence detection for the hard-coded
property TECHNOLOGY.

Signed-off-by: Nikolaus Voss <n.voss@weinmann.de>
Acked-by Rhyland Klein <rklein@nvidia.com>
Signed-off-by: Anton Vorontsov <cbouatmailru@gmail.com>
bq27x00_battery: Add support for power average and health properties

Addition of power average and health properties.

Signed-off-by: Syed Rafiuddin <srafiuddin@nvidia.com>
Signed-off-by: Anton Vorontsov <cbouatmailru@gmail.com>
gpio-charger: Use cansleep version of gpio_set_value

Context of gpio_charger_get_property is sleepable so we should
use gpio_set_value_cansleep instead of gpio_set_value.

It will remove WARN_ON incase of using gpio from i2c-to-gpio
expander like pca953x.

Signed-off-by: Pritesh Raithatha <praithatha@nvidia.com>
Acked-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Anton Vorontsov <cbouatmailru@gmail.com>
test_power: Add support for USB AC source

Usually a device has both AC plug and UDC plug usable for charging.
Provide both AC sources.

Signed-off-by: Dmitry Eremin-Solenikov <dmitry_eremin@mentor.com>
Signed-off-by: Anton Vorontsov <cbouatmailru@gmail.com>
test_power: Add VOLTAGE_NOW and BATTERY_TEMP properties

Emulate battery temperature (fixed to 26) and battery voltage (variable)
properties.

Signed-off-by: Dmitry Eremin-Solenikov <dmitry_eremin@mentor.com>
Signed-off-by: Anton Vorontsov <cbouatmailru@gmail.com>
random: fix up sparse warnings

Add extern and static declarations to suppress sparse warnings

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
charger-manager: Use EXTCON Subsystem to detect charger cables for charging

This patch support that charger-manager use EXTCON(External Connector)
Subsystem to detect the state of charger cables for enabling or disabling
charger(regulator) and select the charger cable for charging among
a number of external cable according to policy of H/W board.

Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
Signed-off-by: Myungjoo Ham <myungjoo.ham@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Anton Vorontsov <anton.vorontsov@linaro.org>
charger-manager: Set current limit of regulator for over current protection

This patch support the protection of host device from over current.
The Charger-manager set proper current limit of charger(regulator) for
charging according to type of charger cable when external connector
is attached.

Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
Signed-off-by: Myungjoo Ham <myungjoo.ham@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Anton Vorontsov <anton.vorontsov@linaro.org>
bq27x00_battery: Add support for BQ27425 chip

This patch adds support for BQ27425 (TI) chip. This chip is same as
BQ27500 with few registers removed and register address map changed.
The data sheet for this chip is publicly available at
 http://www.ti.com/product/bq27425-g1

Signed-off-by: Saranya Gopal <saranya.gopal@intel.com>
Reviewed-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Anton Vorontsov <anton.vorontsov@linaro.org>
power_supply: Add min/max alert properties for CAPACITY, TEMP, TEMP_AMBIENT

Minimum and maximum alerts on power supply properties will help or allow
the user space to "proactively" create policies like connect/disconnect
charger or stop/start the user apps based on capacity or temperature
parameters.

These parameters can be used to avoid unnecessary polling from user space
and even from kernel space if the underlying HW can support INT triggers
(ex: max17042/47).

This patch adds the following power supply alert type properties:

 CAPACITY_ALERT_MIN
 CAPACITY_ALERT_MAX
 TEMP_ALERT_MIN
 TEMP_ALERT_MAX
 TEMP_AMBIENT_ALERT_MIN
 TEMP_AMBIENT_ALERT_MAX

Signed-off-by: Ramakrishna Pallala <ramakrishna.pallala@intel.com>
Signed-off-by: Anton Vorontsov <anton.vorontsov@linaro.org>
lp8727_charger: Move header file into platform_data directory

The lp8727 header can be used only in the platform side, so it can be
moved to the platform_data directory.

Signed-off-by: Milo(Woogyom) Kim <milo.kim@ti.com>
Signed-off-by: Anton Vorontsov <anton.vorontsov@linaro.org>