Commit Graph

1224 Commits

Author SHA1 Message Date
Ivaylo Dimitrov 9aafabc7fe power: bq27xxx_battery: Restore device name
Patch <703df6c09795> ("power: bq27xxx_battery: Reorganize I2C
into a module") has removed the device name numbering from
bq27xxx_battery_i2c_probe. Fix that by restoring the code.

Fixes: 703df6c097
Signed-off-by: Ivaylo Dimitrov <ivo.g.dimitrov.75@gmail.com>
Reviewed-by: Pali Rohár <pali.rohar@gmail.com>
Tested-by: Pali Rohár <pali.rohar@gmail.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2016-02-21 20:49:34 +01:00
Liu Xiang 265b60497a power: bq27xxx_battery: Fix bq27541 AveragePower register address
Currently in bq27541 driver, the average power register address is
incorrectly set to 0x76, which would result in an error:
bq27xxx-battery 2-0055: error reading average power register  10: -11
According to the bq27541 datasheet, fix this problem by setting
the average power register address to 0x24.

Fixes: d74534c277 ("power: bq27xxx_battery: Add support for additional bq27xxx family devices")
Signed-off-by: Liu Xiang <liu.xiang6@zte.com.cn>
Acked-by: Andrew F. Davis <afd@ti.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2016-01-14 01:03:18 +01:00
Sasha Levin 6b9140f39c power: test_power: correctly handle empty writes
Writing 0 length data into test_power makes it access an invalid array
location and kill the system.

Fixes: f17ef9b2d ("power: Make test_power driver more dynamic.")
Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2016-01-07 18:39:34 +01:00
Geliang Tang 127d286848 power: generic-adc-battery: use to_delayed_work
Use to_delayed_work() instead of open-coding it.

Signed-off-by: Geliang Tang <geliangtang@163.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2016-01-07 16:38:31 +01:00
Ivaylo Dimitrov 8802563251 power: isp1704_charger: Fix isp1704_write() definition
All calls to isp1704_write() are using parameter sequence of
isp1704_write(isp, reg, val) but the function is defined as
isp1704_write(isp, val, reg). Fix isp1704_write function definition so
that the driver to be functional.

Signed-off-by: Ivaylo Dimitrov <ivo.g.dimitrov.75@gmail.com>
Reviewed-by: Pali Rohár <pali.rohar@gmail.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2016-01-07 16:38:30 +01:00
H. Nikolaus Schaller 099867a16a power: bq27xxx: fix register numbers of bq27500
bug: according to data sheet some register numbers are wrong.

tested: no

Fixes: d74534c277 ("power: bq27xxx_battery: Add support for additional bq27xxx family devices")
Signed-off-by: H. Nikolaus Schaller <hns@goldelico.com>
Acked-by: Andrew F. Davis <afd@ti.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2016-01-07 16:38:27 +01:00
H. Nikolaus Schaller 549d7b317c power: bq27xxx: fix reading for bq27000 and bq27010
bug: the driver reports funny capacity values:

root@letux:/sys/class/power_supply/bq27000-battery# cat uevent
POWER_SUPPLY_NAME=bq27000-battery
POWER_SUPPLY_STATUS=Charging
POWER_SUPPLY_PRESENT=1
POWER_SUPPLY_VOLTAGE_NOW=3702000
POWER_SUPPLY_CURRENT_NOW=-464635
POWER_SUPPLY_CAPACITY=1536			<- over 100% is magic
POWER_SUPPLY_CAPACITY_LEVEL=Normal
POWER_SUPPLY_TEMP=311
POWER_SUPPLY_TIME_TO_FULL_NOW=10440
POWER_SUPPLY_TECHNOLOGY=Li-ion
POWER_SUPPLY_CHARGE_FULL=805450
POWER_SUPPLY_CHARGE_NOW=1068
POWER_SUPPLY_CHARGE_FULL_DESIGN=8844998	<- battery has just 1200 mAh
POWER_SUPPLY_CYCLE_COUNT=21
POWER_SUPPLY_ENERGY_NOW=0
POWER_SUPPLY_POWER_AVG=0
POWER_SUPPLY_HEALTH=Good
POWER_SUPPLY_MANUFACTURER=Texas Instruments

reason: the state of charge and the design capacity register are single
byte only. The design capacity returns the higer order byte.

tested: GTA04 with Openmoko/FIC HF08x battery (using hdq)

Fixes: d74534c277 ("power: bq27xxx_battery: Add support for additional bq27xxx family devices")
Signed-off-by: H. Nikolaus Schaller <hns@goldelico.com>
Acked-by: Andrew F. Davis <afd@ti.com>
Reviewed-by: Pali Rohár <pali.rohar@gmail.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2016-01-07 16:38:24 +01:00
Krzysztof Kozlowski f96576bd63 power: Fix unmet dependency on POWER_SUPPLY by POWER_RESET by uncoupling them
Currently the reset/power off handlers (POWER_RESET) and Adaptive Voltage
Scaling class (POWER_AVS) are not built when POWER_SUPPLY is disabled.
The POWER_RESET is also not visible in drivers main section of config.

However they do not really depend on power supply so they can be built
always. The objects for power supply drivers already depend on
particular Kconfig symbols so there is no need for any changes in
drivers/power/Makefile.

This allows selecting POWER_RESET from main drivers config section and
fixes following build warning (encountered on ARM exynos defconfig when
POWER_SUPPLY is disabled manually):

warning: (ARCH_HISI && ARCH_INTEGRATOR && ARCH_EXYNOS && ARCH_VEXPRESS && REALVIEW_DT) selects POWER_RESET which has unmet direct dependencies (POWER_SUPPLY)
warning: (ARCH_EXYNOS) selects POWER_RESET_SYSCON which has unmet direct dependencies (POWER_SUPPLY && POWER_RESET && OF)
warning: (ARCH_EXYNOS) selects POWER_RESET_SYSCON_POWEROFF which has unmet direct dependencies (POWER_SUPPLY && POWER_RESET && OF)

Reported-by: Pavel Fedin <p.fedin@samsung.com>
Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2015-12-08 04:26:05 +01:00
Andrew F. Davis 703df6c097 power: bq27xxx_battery: Reorganize I2C into a module
Separate out I2C functionality into a module. This fixes several small
issues and simplifies the driver initialization.

Signed-off-by: Andrew F. Davis <afd@ti.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2015-12-05 02:06:51 +01:00
NeilBrown 1f94b2563a power: bq27xxx: don't fill system log by missing battery
Print message that battery is not calibrated only once
to avoid spamming the log.

Suggested-By: H. Nikolaus Schaller <hns@goldelico.com>
Suggested-By: Pali Rohár <pali.rohar@gmail.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2015-12-05 02:06:50 +01:00
Saurabh Sengar d5fdfedc0e power: max8903_charger: set IRQF_ONESHOT if no primary handler is specified
If no primary handler is specified for threaded_irq then a
default one is assigned which always returns IRQ_WAKE_THREAD.
This handler requires the IRQF_ONESHOT, because the source of
interrupt is not disabled.

Signed-off-by: Saurabh Sengar <saurabh.truth@gmail.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2015-12-05 02:06:50 +01:00
Julia Lawall c4c0edfbf8 power/reset: at91-reset: add missing of_node_put
for_each_matching_node performs an of_node_get on each iteration, so
a break out of the loop requires an of_node_put.

A simplified version of the semantic patch that fixes this problem is as
follows (http://coccinelle.lip6.fr):

// <smpl>
@@
expression e,e1;
local idexpression np;
@@

 for_each_matching_node(np, e1) {
   ... when != of_node_put(np)
       when != e = np
(
   return np;
|
+  of_node_put(np);
?  return ...;
)
   ...
 }
// </smpl>

Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2015-12-05 02:06:49 +01:00
Julia Lawall 79fbdb66cf power: ds2782_battery: constify ds278x_battery_ops structure
The ds278x_battery_ops structure is never modified, so declare it as const.

Done with the help of Coccinelle.

Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2015-12-05 02:06:49 +01:00
Markus Elfring b7e16ec6e3 power: bq2415x_charger: Delete unnecessary checks before the function call "of_node_put"
The of_node_put() function tests whether its argument is NULL and then
returns immediately. Thus the test around the calls is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
Acked-by: Pali Rohár <pali.rohar@gmail.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2015-12-05 02:04:03 +01:00
Linus Torvalds bc914532a0 - New Device Support
- Add support for 88pm860; 88pm80x
    - Add support for 24c08 EEPROM; at24
    - Add support for Broxton Whiskey Cove; intel*
    - Add support for RTS522A; rts5227
    - Add support for I2C devices; intel_quark_i2c_gpio
  - New Functionality
    - Add microphone support; arizona
    - Add general purpose switch support; arizona
    - Add fuel-gauge support; da9150-core
    - Add shutdown support; sec-core
    - Add charger support; tps65217
    - Add flexible serial communication unit support; atmel-flexcom
    - Add power button support; axp20x
    - Add led-flash support; rt5033
  - Core Frameworks
    - Supply a generic macro for defining Regmap IRQs
    - Rework ACPI child device matching
  - Fix-ups
    - Use Regmap to access registers; tps6105x
    - Use DEFINE_RES_IRQ_NAMED() macro; da9150
    - Re-arrange device registration order; intel_quark_i2c_gpio
    - Allow OF matching; cros_ec_i2c, atmel-hlcdc, hi6421-pmic, max8997, sm501
    - Handle deferred probe; twl6040
    - Improve accuracy of headphone detect; arizona
    - Unnecessary MODULE_ALIAS() removal; bcm590xx, rt5033
    - Remove unused code; htc-i2cpld, arizona, pcf50633-irq, sec-core
    - Simplify code; kempld, rts5209, da903x, lm3533, da9052, arizona
    - Remove #iffery; arizona
    - DT binding adaptions; many
  - Bug Fixes
    - Fix possible NULL pointer dereference; wm831x, tps6105x
    - Fix 64bit bug; intel_soc_pmic_bxtwc
    - Fix signedness issue; arizona
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1
 
 iQIcBAABAgAGBQJWOzEbAAoJEFGvii+H/HdhbUEQAIBHvNaunWp362L2D2lOOQMa
 cBlGiR2yXCpsFGAcvpr50zX5soFuNITGea1CidJmp/ZIHIG7hVUz5E8wQZ8HdiyG
 03UKsa6xkVx9i+PhV5agUjxi6MDgUvxsPwdbVw6LTw1wQejIrfxq7ObdcPo30OTI
 4r0tjLonQkGaFFdGqC4Jr7Grs7pvzmKzHu08AaknaoTyhUl/E9Wtq12HJFr8kUCw
 WNgEyiPzNk0h9EByCUiG7iFwyg1EJLsF1U973Th8Utvl7PFe8REQVZ46v9iYAM9J
 1OeSrsKhtyhQqAP/FJ5odZCXwTy9q6ifGfELyyS26/okCYWDzxDcF+hAp0VNbzb4
 zYvEnKue101Y+WEsF9bNaya3avf45obJuRaRukoGMZ/brW6+d1ub0kwUKMD8MqOn
 UFL3oZwfPQ8mWB5ddELl97dzJDwHbEIhWe7yKQVpTaJ2pCm6JSS5Vb0TU+A1Zywp
 Hie1Yr0y36npnCbml4W74O9H/rblpNpgFlaupfB6mHRWZyTsyQNeKJ6FWTirncgQ
 xy8Ti+ZsXlMTvWCzzS3GcjP9rAK0e5dKurOE8t+krZmTul96+OYsnvxRC0nyo7XC
 1PKomkWO+3if2DsnurFX/QKfE55PCKermJRO5mDZbsWp6aJAhKW5UwxAgkHpUHsJ
 hHaT+npBczXbq8jvEMTt
 =99/D
 -----END PGP SIGNATURE-----

Merge tag 'mfd-for-linus-4.4' of git://git.kernel.org/pub/scm/linux/kernel/git/lee/mfd

Pull MFD updates from Lee Jones:
 "New Device Support:
   - Add support for 88pm860; 88pm80x
   - Add support for 24c08 EEPROM; at24
   - Add support for Broxton Whiskey Cove; intel*
   - Add support for RTS522A; rts5227
   - Add support for I2C devices; intel_quark_i2c_gpio

  New Functionality:
   - Add microphone support; arizona
   - Add general purpose switch support; arizona
   - Add fuel-gauge support; da9150-core
   - Add shutdown support; sec-core
   - Add charger support; tps65217
   - Add flexible serial communication unit support; atmel-flexcom
   - Add power button support; axp20x
   - Add led-flash support; rt5033

  Core Frameworks:
   - Supply a generic macro for defining Regmap IRQs
   - Rework ACPI child device matching

  Fix-ups:
   - Use Regmap to access registers; tps6105x
   - Use DEFINE_RES_IRQ_NAMED() macro; da9150
   - Re-arrange device registration order; intel_quark_i2c_gpio
   - Allow OF matching; cros_ec_i2c, atmel-hlcdc, hi6421-pmic, max8997, sm501
   - Handle deferred probe; twl6040
   - Improve accuracy of headphone detect; arizona
   - Unnecessary MODULE_ALIAS() removal; bcm590xx, rt5033
   - Remove unused code; htc-i2cpld, arizona, pcf50633-irq, sec-core
   - Simplify code; kempld, rts5209, da903x, lm3533, da9052, arizona
   - Remove #iffery; arizona
   - DT binding adaptions; many

  Bug Fixes:
   - Fix possible NULL pointer dereference; wm831x, tps6105x
   - Fix 64bit bug; intel_soc_pmic_bxtwc
   - Fix signedness issue; arizona"

* tag 'mfd-for-linus-4.4' of git://git.kernel.org/pub/scm/linux/kernel/git/lee/mfd: (73 commits)
  bindings: mfd: s2mps11: Add documentation for s2mps15 PMIC
  mfd: sec-core: Remove unused s2mpu02-rtc and s2mpu02-clk children
  extcon: arizona: Add extcon specific device tree binding document
  MAINTAINERS: Add binding docs for Cirrus Logic/Wolfson Arizona devices
  mfd: arizona: Remove bindings covered in new subsystem specific docs
  mfd: rt5033: Add RT5033 Flash led sub device
  mfd: lpss: Add Intel Broxton PCI IDs
  mfd: lpss: Add Broxton ACPI IDs
  mfd: arizona: Signedness bug in arizona_runtime_suspend()
  mfd: axp20x: Add a cell for the power button part of the, axp288 PMICs
  mfd: dt-bindings: Document pulled down WRSTBI pin on S2MPS1X
  mfd: sec-core: Disable buck voltage reset on watchdog falling edge
  mfd: sec-core: Dump PMIC revision to find out the HW
  mfd: arizona: Use correct type ID for device tree config
  mfd: arizona: Remove use of codec build config #ifdefs
  mfd: arizona: Simplify adding subdevices
  mfd: arizona: Downgrade type mismatch messages to dev_warn
  mfd: arizona: Factor out checking of jack detection state
  mfd: arizona: Factor out DCVDD isolation control
  mfd: Make TPS6105X select REGMAP_I2C
  ...
2015-11-06 10:23:50 -08:00
Linus Torvalds 400c5bd5a5 power supply and reset changes for the v4.4 series
* new AXP20X USB Power driver
  * new Qualcomm SMBB driver
  * new TPS65217 Charger driver
  * BQ24257: add BQ24250/BQ24251 support
  * overhaul bq27x00 battery driver, rename to bq27xxx
  * misc. fixes and cleanups
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1
 
 iQIcBAABCgAGBQJWOn8oAAoJENju1/PIO/qahrEP/RPHXvTxtYv8YvhaFbqcr07x
 11gRB8RRthKK5woC3s70QKlMtcHijFeCwKuacut+7tfgK2oZDIm+Bd43Pl93aypU
 Yk4oTwop5OyrLsGIGiTIPPV9HTwr4q69Or2Q91mqUAUe2wGB5uCuJiJmCowUwfZs
 piv+ISLSOcH+i1bTx3hQ7h7axsdAlaSz2o1JprZaxm3rM67M8zF1ZHSK7wlpAeBa
 DiDrtUvEDCeLL8dmCA9xkFV4yFB9T+KNh0730N2RY+zlZS6WjSpzryqwsUWWyQ6h
 U9gFgcs+DjVaGHuMsIX2zm7xXfXHgUBtXdSQoCBhpSrZsdufMsT/8VQqVZ0yqpXL
 pQ2EXy63k6tXnXEyAKTA0tAOX/WZNfmmNblkea4JiyZULn7b/WH09waMZUBJqe84
 Yn3SatVdGDN4nawsivzdiM3zR9/WTE9R3DmEeAE+g1RRsSraNwWlkzpDXcmnWmbc
 DoprnjLsDJfqL3/1ysF2V2I4B26Bws73qq6UUjJ4KEGWf8Y1fVawxrbcYmnrvg1K
 zW/saEgtl70FYqtee/0lIqTpjOZRX/O6QH5i8p7VC8cUzftX0Twc8MvfvpamDywX
 Cr1Y7pIMEhc6TFUP5lOzx9xJelA5PHJMpAT+02fh6YXMAzCcBUzL113rY5zBrVVl
 gce0iHDKAybmvww77z1r
 =0be4
 -----END PGP SIGNATURE-----

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

Pull power supply and reset updates from Sebastian Reichel:
 - new AXP20X USB Power driver
 - new Qualcomm SMBB driver
 - new TPS65217 Charger driver
 - BQ24257: add BQ24250/BQ24251 support
 - overhaul bq27x00 battery driver, rename to bq27xxx
 - misc fixes and cleanups

* tag 'for-v4.4' of git://git.kernel.org/pub/scm/linux/kernel/git/sre/linux-power-supply: (54 commits)
  power: bq27xxx_battery: Remove unneeded dependency in Kconfig
  power: bq27xxx_battery: move irq handler to i2c section
  power: bq27xxx_battery: fix platform probe
  twl4030_charger: add missing iio dependency
  power_supply: charger-manager: add missing of_node_put
  Documentation: power: bq24257: Document exported sysfs entries
  power: bq24257: Add various device-specific sysfs properties
  power: bq24257: Allow input current limit sysfs access
  power: bq24257: Add input DPM voltage threshold setting support
  power: bq24257: Add over voltage protection setting support
  power: bq24257: Add SW-based approach for Power Good determination
  power: bq24257: Allow manual setting of input current limit
  power: bq24257: Add bit definition for temp sense enable
  power: bq24257: Add basic support for bq24250/bq24251
  dt: power: bq24257-charger: Cover additional devices
  power: bq24257: Simplify bq24257_power_supply_init()
  power: bq24257: Use managed power supply register
  power: bq24257: Streamline input current limit setup
  power: bq24257: Remove IRQ config through stat-gpios
  power: bq27xxx_battery: fix signedness bug in bq27xxx_battery_read_health()
  ...
2015-11-05 12:28:15 -08:00
Andrew F. Davis 6bd03ce3c1 power: bq27xxx_battery: Remove unneeded dependency in Kconfig
I2C is only required when using the config item BATTERY_BQ27XXX_I2C which
already depends on the I2C subsystem, remove the unneeded dependency from
BATTERY_BQ27XXX.

Signed-off-by: Andrew F. Davis <afd@ti.com>
Acked-by: Pali Rohár <pali.rohar@gmail.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2015-10-19 10:38:50 +02:00
Sebastian Reichel 41a90db8fd power: bq27xxx_battery: move irq handler to i2c section
The IRQ handler is not used by the platform based
code resulting in a 'defined but not used' warning,
if CONFIG_BQ27XXX_I2C is not enabled.

Signed-off-by: Sebastian Reichel <sre@kernel.org>
Acked-by: Pali Rohár <pali.rohar@gmail.com>
Acked-by: Andrew F. Davis <afd@ti.com>
2015-10-19 10:38:03 +02:00
Sebastian Reichel 0077ae7e99 power: bq27xxx_battery: fix platform probe
Add missing initialization of register mapping table to
platform probe function.

Signed-off-by: Sebastian Reichel <sre@kernel.org>
Acked-by: Pali Rohár <pali.rohar@gmail.com>
Acked-by: Andrew F. Davis <afd@ti.com>
2015-10-19 10:37:25 +02:00
Sebastian Reichel 0f4998cbb2 twl4030_charger: add missing iio dependency
This driver fails to link without CONFIG_IIO, since
there are no stubs for the iio_channels functions.

Signed-off-by: Sebastian Reichel <sre@kernel.org>
Acked-by: Marek Belisko <marek@goldelico.com>
Acked-by: Nikolaus Schaller <hns@goldelico.com>
2015-10-16 14:12:38 +02:00
Julia Lawall 8e5cfb74bc power_supply: charger-manager: add missing of_node_put
for_each_child_of_node performs an of_node_get on each iteration, so
a break out of the loop requires an of_node_put.

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

// <smpl>
@@
expression root,e;
local idexpression child;
@@

 for_each_child_of_node(root, child) {
   ... when != of_node_put(child)
       when != e = child
(
   return child;
|
+  of_node_put(child);
?  return ...;
)
   ...
 }
// </smpl>

Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
Reviewed-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2015-10-15 10:55:44 +02:00
Luis de Bethencourt fa743d96e7 PM / AVS: rockchip-io: Fix module autoload for OF platform driver
This platform driver has a OF device ID table but the OF module
alias information is not created so module autoloading won't work.

Signed-off-by: Luis de Bethencourt <luisbg@osg.samsung.com>
Reviewed-by: Heiko Stuebner <heiko@sntech.de>
Acked-by: Kevin Hilman <khilman@linaro.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2015-10-14 02:38:53 +02:00
Adam Thomson a419b4fd91 power: Add support for DA9150 Fuel-Gauge
This adds power supply driver support for the Fuel-Gauge part of
the DA9150 combined Charger and Fuel-Gauge device.

Signed-off-by: Adam Thomson <Adam.Thomson.Opensource@diasemi.com>
Acked-by: Sebastian Reichel <sre@kernel.org>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
2015-10-13 11:28:07 +01:00
Andreas Dannenberg 007ee5f656 power: bq24257: Add various device-specific sysfs properties
This patch adds support for enabling/disabling optional device specific
features through sysfs properties at runtime.

* High-impedance mode enable/disable
* Sysoff enable/disable

Refer to the respective device datasheets for more information:

http://www.ti.com/product/bq24250
http://www.ti.com/product/bq24251
http://www.ti.com/product/bq24257

Signed-off-by: Andreas Dannenberg <dannenberg@ti.com>
Reviewed-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2015-09-29 16:55:03 +02:00
Andreas Dannenberg 0cfbfde65a power: bq24257: Allow input current limit sysfs access
This patch allows reading and writing of the input current limit through
the power supply's input_current_limit sysfs property. This allows
userspace to see what charger was detected (if the D+/D- USB signal-
based charger type detection is enabled) and to re-configure the maximum
current drawn from the external supply at runtime based on system-level
knowledge or user input. Note that upon charger disconnection and
re-connection the limit configured through firmware becomes active again
(or the D+/D- USB signal-based charger detection will be run again).

Signed-off-by: Andreas Dannenberg <dannenberg@ti.com>
Reviewed-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2015-09-29 16:54:52 +02:00
Andreas Dannenberg 138606ffe4 power: bq24257: Add input DPM voltage threshold setting support
A new optional device property called "ti,in-dpm-voltage" is introduced
to allow configuring the input voltage threshold for the devices'
dynamic power path management (DPM) feature. In short, it can be used to
prevent the input voltage from dropping below a certain value as current
is drawn to charge the battery or supply the system.

Signed-off-by: Andreas Dannenberg <dannenberg@ti.com>
Reviewed-by: Laurentiu Palcu <laurentiu.palcu@intel.com>
Reviewed-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2015-09-29 16:54:44 +02:00
Andreas Dannenberg bb2956e8e1 power: bq24257: Add over voltage protection setting support
A new optional device property called "ti,ovp-voltage" is introduced to
allow configuring the input over voltage protection setting.

This commit also adds the basic sysfs support for custom properties
which is being used to allow userspace to read the current ovp-voltage
setting.

Signed-off-by: Andreas Dannenberg <dannenberg@ti.com>
Reviewed-by: Laurentiu Palcu <laurentiu.palcu@intel.com>
Reviewed-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2015-09-29 16:54:22 +02:00
Andreas Dannenberg 7c071a0a08 power: bq24257: Add SW-based approach for Power Good determination
A software-based approach for determining the charger's input voltage
"Power Good" state is introduced for devices like the bq24250 which
don't have a dedicated hardware pin for that purpose. This SW-based
approach is also used for other devices (with dedicated PG pin) as a
fall back solution if that pin is not configured to be used through
"pg-gpios".

Signed-off-by: Andreas Dannenberg <dannenberg@ti.com>
Reviewed-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2015-09-29 16:53:37 +02:00
Andreas Dannenberg eb9fbcc669 power: bq24257: Allow manual setting of input current limit
A new optional device property called "ti,current-limit" is introduced
to allow disabling the D+/D- USB signal-based charger type auto-
detection algorithm used to set the input current limit and instead to
use a fixed input current limit.

Signed-off-by: Andreas Dannenberg <dannenberg@ti.com>
Reviewed-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2015-09-29 16:52:56 +02:00
Andreas Dannenberg 7ef62365c6 power: bq24257: Add bit definition for temp sense enable
Adding a missing bit definition for the sake of consistency device model
vs. bit field representation. No change in functionality.

Signed-off-by: Andreas Dannenberg <dannenberg@ti.com>
Reviewed-by: Laurentiu Palcu <laurentiu.palcu@intel.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2015-09-29 16:49:58 +02:00
Andreas Dannenberg bf02dca9ee power: bq24257: Add basic support for bq24250/bq24251
This patch adds basic support for bq24250 and bq24251 which are very
similar to the bq24257 the driver was originally written for. Basic
support means the ability to select a device through Kconfig, DT and
ACPI, an instance variable allowing to check which chip is active, and
the reporting back of the selected device through the model_name power
supply sysfs property.

This patch by itself is not sufficient to actually use those two added
devices in a real-world setting due to some feature differences which
are addressed by other patches in this series.

Signed-off-by: Andreas Dannenberg <dannenberg@ti.com>
Reviewed-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2015-09-29 16:49:58 +02:00
Andreas Dannenberg 3b84b8efef power: bq24257: Simplify bq24257_power_supply_init()
Eliminate a few lines of code by using the PTR_ERR_OR_ZERO() macro.

Signed-off-by: Andreas Dannenberg <dannenberg@ti.com>
Reviewed-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2015-09-29 16:48:28 +02:00
Andreas Dannenberg dfc602524b power: bq24257: Use managed power supply register
Use the devm_* managed version of the function to register the power
supply and remove the associated unregister function. This will simplify
error handling moving forward as it allows the unregister to happen
automatically. It also saves a few lines of code.

As this changes the order of putting the bq24257 into reset vs.
unregistering the power-supply during driver remove re-tested various
driver unload scenario to make sure that this doesn't cause any
unintended side effects such as erroneous interrupts.

Signed-off-by: Andreas Dannenberg <dannenberg@ti.com>
Reviewed-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2015-09-29 16:48:07 +02:00
Andreas Dannenberg 9b1cf1e44d power: bq24257: Streamline input current limit setup
The maximum amount of input current the charger should draw is dependent
on the power supply and should only be (re-)configured when the power
supply gets connected and disconnected. However the driver was also
lowering the bq24257's input current limit setting to 500mA when the
battery was removed and restored the previous setting according to the
power supply capabilities when the battery was reconnected although
these events are not impacting the amount of power that can be drawn
from the supply. Furthermore, a re-configuration of the input current
limit to 500mA when the battery gets disconnected is actually dangerous
if the limit was set higher previously and the system draws more than
500mA in which case the system voltage would be reduced in order to
maintain 500mA which could result in the system getting too low of a
supply to maintain operation. Last but not least the mechanism itself
used for battery re-connection detection did not work in corner cases
such as when the device's input current loop becomes active and the
bq24257 device clears its battery fault error resulting in incorrectly
reporting that the battery got reconnected.

This patches removes the impact the battery removal/insertion has on the
input current limit configured for the bq24257 and simplifies the
associated handler routine.

Signed-off-by: Andreas Dannenberg <dannenberg@ti.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2015-09-28 18:47:50 +02:00
Andreas Dannenberg 5ff8c89d11 power: bq24257: Remove IRQ config through stat-gpios
At the time the driver was written GpioInt resources in ACPI were not
passed to the driver in client->irq, as opposed to DT enumeration. To
accommodate this use case, a "stat-gpios" property was introduced to
allow configuring the IRQ.

However this issue with ACPI was fixed in commit "845c877 i2c / ACPI:
Assign IRQ for devices that have GpioInt automatically" and makes this
workaround no longer necessary, hence we can remove the support for the
"stat-gpios" property and the associated code from the bq24257 driver.

Signed-off-by: Andreas Dannenberg <dannenberg@ti.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2015-09-28 18:36:35 +02:00
Andrzej Hajda 2edd69a81d power: bq27xxx_battery: fix signedness bug in bq27xxx_battery_read_health()
We need flags to be signed for the error handling to work.

The problem has been detected using proposed semantic patch
scripts/coccinelle/tests/unsigned_lesser_than_zero.cocci [1].

[1]: http://permalink.gmane.org/gmane.linux.kernel/2038576

Fixes: 74aab849f3 ('power: bq27xxx_battery: Cleanup health checking')
Signed-off-by: Andrzej Hajda <a.hajda@samsung.com>
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Acked-By: Pali Rohár <pali.rohar@gmail.com>
Acked-by: Andrew F. Davis <afd@ti.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2015-09-28 18:07:48 +02:00
Marek Belisko 2202e1fc5a drivers: power: twl4030_charger: fix link problems when building as module
If either twl4030_charger or twl4030_madc is configured as MODULE,
we get build (link) errors.

To solve, the direct call of twl4030_get_madc_conversion() is replaced
by a call to iio_read_channel_processed().

Signed-off-by: H. Nikolaus Schaller <hns@goldelico.com>
Signed-off-by: Marek Belisko <marek@goldelico.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2015-09-26 19:10:09 +02:00
Valentin Rothberg 90adf98d95 wm831x_power: Use IRQF_ONESHOT to request threaded IRQs
Since commit 1c6c69525b ("genirq: Reject bogus threaded irq requests")
threaded IRQs without a primary handler need to be requested with
IRQF_ONESHOT, otherwise the request will fail.

scripts/coccinelle/misc/irqf_oneshot.cocci detected this issue.

Fixes: b5874f33bb ("wm831x_power: Use genirq")
Signed-off-by: Valentin Rothberg <valentinrothberg@gmail.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2015-09-26 18:55:09 +02:00
Enric Balletbo i Serra 3636859b28 power_supply: Add support for tps65217-charger.
This patch adds support for the tps65217 charger driver. This driver is
responsible for controlling the charger aspect of the tps65217 mfd.
Currently, this mainly consists of turning on and off the charger, but
some other features of the charger can be supported through this driver.

Signed-off-by: Enric Balletbo i Serra <enric.balletbo@collabora.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2015-09-24 22:43:13 +02:00
Dan Carpenter 0bc58e9381 power: qcom_smbb: test the correct variable
"state" is a bool so it's never less than zero.  The intent was to test
"ret" instead.

Fixes: 56d7df8716 ('power: Add Qualcomm SMBB driver')
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2015-09-24 22:35:24 +02:00
Pali Rohár 28153a31b8 bq2415x_charger: Fix null pointer dereference
Commit b68c316143 (bq2415x_charger: Allow to load and use driver even if
notify device is not registered yet) introduced null pointer dereference in
case bq is NULL. This patch fixes it.

Fixes: b68c316143 ("bq2415x_charger: Allow to load and use driver even if notify device is not registered yet")
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Pali Rohár <pali.rohar@gmail.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2015-09-23 18:59:19 +02:00
Andrew F. Davis 8807feb91b power: bq27xxx_battery: Add interrupt handling support
Some devices have a pin that can generate an interrupt when
the battery's status changes. Add an interrupt handler to
read the new battery status.

Signed-off-by: Andrew F. Davis <afd@ti.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2015-09-23 17:36:18 +02:00
Andrew F. Davis 74aab849f3 power: bq27xxx_battery: Cleanup health checking
Reorganize the logic checking battery health and add under temperature
condition checking.

Signed-off-by: Andrew F. Davis <afd@ti.com>
Acked-by: Pali Rohár <pali.rohar@gmail.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2015-09-23 17:36:18 +02:00
Andrew F. Davis d74534c277 power: bq27xxx_battery: Add support for additional bq27xxx family devices
Add support for additional devices and register equivalent family devices
including the bq27010, bq27210, bq27500, bq27510, bq27520, bq27530,
bq27531, bq27541, bq27542, bq27546, bq27545, bq27441, bq27421, and the
bq27641.

To facilitate this process the register mapings have been moved to tables
and other small cleanups have been made.

Signed-off-by: Andrew F. Davis <afd@ti.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2015-09-23 17:15:27 +02:00
Andrew F. Davis c570903290 power: bq27xxx_battery: Fix typos and change naming for state of charge functions
Fix typos and change "relative state of charge" to "state of charge" as not
all supported devices use relative state of charge.

Signed-off-by: Andrew F. Davis <afd@ti.com>
Acked-by: Pali Rohár <pali.rohar@gmail.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2015-09-23 16:23:59 +02:00
Andrew F. Davis 424cfde49a power: bq27xxx_battery: Platform initialization must declare a device
When initialized as a platform device the initializer must now specify
a device. An empty device name is no longer valid.

Signed-off-by: Andrew F. Davis <afd@ti.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2015-09-23 16:23:12 +02:00
Andrew F. Davis 081bab217d power: bq27x00_battery: Renaming for consistency
Rename functions that are used by multiple devices. New devices
have been added and the function names and driver name are no longer
general enough for the functionality they provide.

Signed-off-by: Andrew F. Davis <afd@ti.com>
Acked-by: Tony Lindgren <tony@atomide.com>
Acked-by: GUAN Xuetao <gxt@mprc.pku.edu.cn>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2015-09-23 16:16:22 +02:00
Andrew F. Davis 95b8aff2a6 power: bq27x00_battery: Remove unneeded i2c MODULE_ALIAS
The MODULE_DEVICE_TABLE macro automatically adds all needed
i2c MODULE_ALIASes so remove the extra MODULE_ALIAS.

Signed-off-by: Andrew F. Davis <afd@ti.com>
Acked-by: Pali Rohár <pali.rohar@gmail.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2015-09-22 16:20:10 +02:00
Vaishali Thakkar 5e5822f670 power_supply: max8998: Use devm_power_supply_register
Use managed resource function devm_power_supply_register instead
of power_supply_register to simplify the error path by allowing
unregister to happen automatically on error. To be compatible with
the change, replace various gotos by direct returns and remove
unneeded label err.

Also, remove max8998_battery_remove as it is now redundant.

Signed-off-by: Vaishali Thakkar <vthakkar1994@gmail.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2015-09-22 16:20:10 +02:00
Luis de Bethencourt c72b7bf82c tps65090-charger: Fix module autoload for OF platform driver
This platform driver has a OF device ID table but the OF module
alias information is not created so module autoloading won't work.

Signed-off-by: Luis de Bethencourt <luisbg@osg.samsung.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2015-09-22 16:03:37 +02:00