aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/power/supply/bq27xxx_battery.c
AgeCommit message (Collapse)Author
2020-06-01power: supply: bq27xxx_battery: Silence deferred-probe errorDmitry Osipenko
commit 583b53ece0b0268c542a1eafadb62e3d4b0aab8c upstream. The driver fails to probe with -EPROBE_DEFER if battery's power supply (charger driver) isn't ready yet and this results in a bit noisy error message in KMSG during kernel's boot up. Let's silence the harmless error message. Signed-off-by: Dmitry Osipenko <digetx@gmail.com> Reviewed-by: Andrew F. Davis <afd@ti.com> Reviewed-by: Pali Rohár <pali@kernel.org> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com> Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
2019-05-02power: supply: bq27xxx_battery: Notify also about status changesKrzysztof Kozlowski
User-space might be interested in receiving uevents when the charging starts/stops or if conditions of battery changes (e.g. over-temperature). Notify about changes in battery also when the flags change, not only SoC. Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org> Reviewed-by: Pali Rohár <pali.rohar@gmail.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-02-20bq27x00: use cached flagsArthur Demchenkov
The flags were just read by bq27xxx_battery_update(), no need to read them again. Signed-off-by: Arthur Demchenkov <spinal.by@gmail.com> Reviewed-by: Andrew F. Davis <afd@ti.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2018-09-20power: supply: bq27xxx: Add support for BQ27411Liu Xiang
According to the datasheet, bq27411 is similar to bq27421. Signed-off-by: Liu Xiang <liu.xiang6@zte.com.cn> Reviewed-by: Andrew F. Davis <afd@ti.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2018-07-24power: supply: bq27xxx: Update commentsLiu Xiang
The URL of bq27441-g1 and bq27426 are missing and bq27520-g4 is duplicated. Signed-off-by: Liu Xiang <liu.xiang6@zte.com.cn> Reviewed-by: Pali Rohár <pali.rohar@gmail.com> Acked-by: Andrew F. Davis <afd@ti.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2018-04-25power: supply: bq27xxx: Add support for BQ27426Andrew F. Davis
This device is software similar to the BQ27426 except it has different data memory offsets. Add support here. Signed-off-by: Andrew F. Davis <afd@ti.com> Acked-by: Pali Rohár <pali.rohar@gmail.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2018-03-12power: supply: bq27xxx: support missing supplier deviceSebastian Reichel
power_supply_am_i_supplied() can return negative error codes. In this case we should assume, that no charger is connected and the battery should be marked as DISCHARGING instead of NOT_CHARGING. Reported-by: Merlijn Wajer <merlijn@wizzup.org> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2017-12-08Add support for bq27521 battery monitorPavel Machek
This adds basic support for BQ27521 battery monitor, used in Nokia N9 and N950. In particular, battery voltage is important to be able to tell when the battery is almost empty. Emptying battery on N950 is pretty painful, as flasher needs to be used to recover phone in such case. Signed-off-by: Pavel Machek <pavel@ucw.cz> Acked-by: Andrew F. Davis <afd@ti.com> Acked-by: Rob Herring <robh@kernel.org> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2017-08-31power: supply: bq27xxx: enable writing capacity values for bq27421H. Nikolaus Schaller
Tested on Pyra prototype with bq27421. Signed-off-by: H. Nikolaus Schaller <hns@goldelico.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2017-08-29power: supply: bq27xxx: Remove duplicate chip data arraysLiam Breck
BQ2751X & BQ27510G3 have identical regs & props. BQ2750X & BQ27510G3 have identical props. BQ27500 & BQ27510G1 & BQ27510G2 have identical regs & props. BQ27500 & BQ27520G2 have identical props. Remove the duplicate arrays. No functional changes to the driver. Signed-off-by: Liam Breck <kernel@networkimprov.net> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2017-08-29power: supply: bq27xxx: Enable data memory update for certain chipsLiam Breck
Support data memory update on BQ27425. Parameters from TI datasheets are also provided for BQ27500, 545, 421, 441, 621; however these are commented out, as they are not tested. Add BQ27XXX_O_CFGUP & _O_RAM for use in bq27xxx_chip_data[n].opts and by data memory update functions. Signed-off-by: Liam Breck <kernel@networkimprov.net> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2017-08-29power: supply: bq27xxx: Add chip IDs for previously shadowed chipsLiam Breck
For the existing features, these chips act like others already ID'd, so they had false but functional IDs. We will be adding features which require correct IDs, so the following IDs are added: BQ2752X, 531, 542, 546, 742, 425, 441, 621 Chip-specific features are now tracked by BQ27XXX_O_* flags in di->opts. No functional changes to the driver. Signed-off-by: Liam Breck <kernel@networkimprov.net> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2017-08-29power: supply: bq27xxx: Create single chip data tableLiam Breck
To support new features which require different data for each chip, we unify the bq27xxx_regs and bq27xxx_battery_props tables into a single one. No functional changes to the driver. Signed-off-by: Liam Breck <kernel@networkimprov.net> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2017-07-25power: supply: bq27xxx: move platform driver code into bq27xxx_battery_hdq.cAndrew F. Davis
When the BQ27xxx driver was originally written the w1 subsystem only allowed device drivers for w1 attached devices to live in the w1 subsystem. Kernel driver subsystems expect that the driver for a device live in the directory of the subsystem for which it implements functionality, not in the directory of the bus that it is attached. To work around this, the BQ27xxx driver was implemented as a platform device driver and the interface driver would instantiate this device from within the w1 directory, then pass a w1 read callback as platform data. As we can now have the w1 interface driver in the power/supply directory (like we do already with the i2c interface driver) we can remove this middle-layer platform driver. Signed-off-by: Andrew F. Davis <afd@ti.com> Acked-by: Pali Rohár <pali.rohar@gmail.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2017-06-08power: supply: bq27xxx: Add power_supply_battery_info supportLiam Breck
Previously there was no way to configure these chips in the event that the defaults didn't match the battery in question. For chips with RAM data memory (and also those with flash/NVM data memory if CONFIG_BATTERY_BQ27XXX_DT_UPDATES_NVM is defined and the user has not set module param dt_monitored_battery_updates_nvm=0) we now call power_supply_get_battery_info(), check its values, and write battery properties to chip data memory if there is a dm_regs table for the chip. Signed-off-by: Matt Ranostay <matt@ranostay.consulting> Signed-off-by: Liam Breck <kernel@networkimprov.net> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2017-06-08power: supply: bq27xxx: Add chip data memory read/write supportLiam Breck
Add these to enable read/write of chip data memory RAM/NVM/flash: bq27xxx_battery_seal() bq27xxx_battery_unseal() bq27xxx_battery_set_cfgupdate() bq27xxx_battery_soft_reset() bq27xxx_battery_read_dm_block() bq27xxx_battery_write_dm_block() bq27xxx_battery_checksum_dm_block() Signed-off-by: Matt Ranostay <matt@ranostay.consulting> Signed-off-by: Liam Breck <kernel@networkimprov.net> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2017-06-08power: supply: bq27xxx: Add bulk transfer bus methodsMatt Ranostay
Declare bus.write/read_bulk/write_bulk(). Add I2C write/read_bulk/write_bulk() to implement the above. Add bq27xxx_write/read_block/write_block() helpers to call the above. Signed-off-by: Matt Ranostay <matt@ranostay.consulting> Signed-off-by: Liam Breck <kernel@networkimprov.net> Acked-by: "Andrew F. Davis" <afd@ti.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2017-01-12power: supply: bq27xxx: adds specific support for bq27520-g4 revision.Chris Lapa
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-12power: supply: bq27xxx: adds specific support for bq27520-g3 revision.Chris Lapa
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-12power: supply: bq27xxx: adds specific support for bq27520-g2 revision.Chris Lapa
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-12power: supply: bq27xxx: adds specific support for bq27520-g1 revision.Chris Lapa
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-12power: supply: bq27xxx: adds specific support for bq27510-g3 revision.Chris Lapa
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-12power: supply: bq27xxx: adds specific support for bq27510-g2 revision.Chris Lapa
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-12power: supply: bq27xxx: adds specific support for bq27510-g1 revision.Chris Lapa
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-12power: supply: bq27xxx: adds specific support for bq27500/1 revision.Chris Lapa
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-12power: supply: bq27xxx: rename BQ27510 allow for deprecation in future.Chris Lapa
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-12power: supply: bq27xxx: rename BQ27500 allow for deprecation in future.Chris Lapa
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-10power: supply: bq27xxx: move overtemp tests to a switch statement.Chris Lapa
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>
2016-11-23power: supply: bq27xxx_battery: Fix register map for BQ27510 and BQ27520Andrew F. Davis
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: d74534c27775 ("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-10-19power: supply: bq27xxx_battery: don't update poll_interval param if sameMatt Ranostay
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-09-21power: supply: bq27xxx_battery: allow kernel poll_interval parameter runtime ↵Matt Ranostay
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-08-15power:bq27xxx: 27000/10 read FLAGS register as singleH. Nikolaus Schaller
The bq27000 and bq27010 have a single byte FLAGS register. Other gauges have 16 bit FLAGS registers. For reading the FLAGS register it is sufficient to read the single register instead of reading RSOC at the next higher address as well and then ignore the high byte. This does not change functionality but optimizes i2c and hdq traffic. Signed-off-by: H. Nikolaus Schaller <hns@goldelico.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>
2016-08-11power: move power supply drivers to power/supplySebastian Reichel
This moves all power supply drivers from drivers/power/ to drivers/power/supply/. The intention is a cleaner source tree, since drivers/power/ also contains frameworks unrelated to power supply, like adaptive voltage scaling. Signed-off-by: Sebastian Reichel <sre@kernel.org>