summaryrefslogtreecommitdiffstats
path: root/drivers/power/supply
Commit message (Collapse)AuthorAgeFilesLines
* Merge tag 'for-v4.13' of ↵Linus Torvalds2017-07-0414-189/+1994
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | git://git.kernel.org/pub/scm/linux/kernel/git/sre/linux-power-supply Pull power supply and reset updates from Sebastian Reichel: "New drivers: - Linear ltc3651 charger driver - Motorola CPCAP battery fuel-gauge driver New chip/feature support: - bq27xxx: prepare for chip data setup - axp20x_battery: support max charge current setup New core features: - add Apple Brick ID type - support "supplied-from" device property for generic ACPI/pdata support - support strings for sysfs properties representing enums - introduce battery-info (backend is DT only for now) - provide reboot-mode header globally .. and misc fixes" * tag 'for-v4.13' of git://git.kernel.org/pub/scm/linux/kernel/git/sre/linux-power-supply: (39 commits) power: supply: sbs-battery: Don't needlessly set CAPACITY_MODE power: supply: sbs-battery: Prevent CAPACITY_MODE races power: supply: bq24735: remove incorrect le16_to_cpu calls power: supply: sbs-battery: remove incorrect le16_to_cpu calls power: supply: cpcap-charger: Add missing power_supply_config power: supply: twl4030-charger: move allocation of iio channel to the beginning power: supply: twl4030-charger: allocate iio by devm_iio_channel_get() and fix error path power: supply: core: constify psy_tcd_ops. dt-bindings: power: supply: cpcap-battery: Add power-supplies property dt-bindings: power: supply: move max8903-charger.txt to proper location dt-bindings: power: supply: move maxim,max14656.txt to proper location power: supply: twl4030_charger: Use sysfs_match_string() helper power: reset: reboot-mode: Make include file global power: supply: axp20x_battery: add DT support for battery max constant charge current power: supply: axp20x_battery: add support for DT battery power: supply: bq27xxx: Add power_supply_battery_info support power: supply: bq27xxx: Add chip data memory read/write support power: supply: bq27xxx: Add bulk transfer bus methods dt-bindings: power: supply: bq27xxx: Add monitored-battery documentation power: supply: core: Add power_supply_prop_precharge ...
| * power: supply: sbs-battery: Don't needlessly set CAPACITY_MODEShawn Nematbakhsh2017-06-151-7/+7
| | | | | | | | | | | | | | | | | | | | | | | | According to the smart battery spec (1), the CAPACITY_MODE bit does not influence the value read from RelativeStateOfCharge(), so don't bother changing CAPACITY_MODE when doing such a read. (1) - Smart Battery Data Specification, Rev 1.1, Dec. 11, 1998 Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org> Reviewed-by: Guenter Roeck <groeck@chromium.org> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
| * power: supply: sbs-battery: Prevent CAPACITY_MODE racesShawn Nematbakhsh2017-06-151-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | A subset of smart battery commands return charge or energy depending on the CAPACITY_MODE bit setting of BatteryMode(). In order to unambiguously read a charge or energy value, it is necessary to ensure that CAPACITY_MODE is set as desired, and not changed for the duration of the attribute read. Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org> Reviewed-by: Guenter Roeck <groeck@chromium.org> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
| * power: supply: bq24735: remove incorrect le16_to_cpu callsPhil Reid2017-06-151-4/+2Star
| | | | | | | | | | | | | | | | | | i2c_smbus commands handle the correct byte order for smbus transactions internally. This will currently result in incorrect operation on big endian systems. Signed-off-by: Phil Reid <preid@electromag.com.au> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
| * power: supply: sbs-battery: remove incorrect le16_to_cpu callsPhil Reid2017-06-151-4/+3Star
| | | | | | | | | | | | | | | | | | i2c_smbus commands handle the correct byte order for smbus transactions internally. This will currently result in incorrect operation on big endian systems. Signed-off-by: Phil Reid <preid@electromag.com.au> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
| * power: supply: cpcap-charger: Add missing power_supply_configTony Lindgren2017-06-151-1/+5
| | | | | | | | | | | | | | | | | | | | | | Otherwise cpcap-battery won't probe properly with the power-supplies property configured but will fail with "Not all required supplies found, defer probe". Cc: Marcel Partap <mpartap@gmx.net> Cc: Michael Scott <michael.scott@linaro.org> Signed-off-by: Tony Lindgren <tony@atomide.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
| * power: supply: twl4030-charger: move allocation of iio channel to the beginningH. Nikolaus Schaller2017-06-141-6/+6
| | | | | | | | | | | | | | | | | | This is in prepraration for EPROBE_DEFER handling because it is quite likely that geting the (madc) iio channel is deferred more often than later steps. Signed-off-by: H. Nikolaus Schaller <hns@goldelico.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
| * power: supply: twl4030-charger: allocate iio by devm_iio_channel_get() and ↵H. Nikolaus Schaller2017-06-141-8/+2Star
| | | | | | | | | | | | | | | | fix error path Suggested-by: Sebastian Reichel <sre@kernel.org> Signed-off-by: H. Nikolaus Schaller <hns@goldelico.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
| * power: supply: core: constify psy_tcd_ops.Arvind Yadav2017-06-141-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | File size before: text data bss dec hex filename 4240 200 80 4520 11a8 drivers/power/supply/power_supply_core.o File size After adding 'const': text data bss dec hex filename 4296 136 80 4512 11a0 drivers/power/supply/power_supply_core.o Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
| * power: supply: twl4030_charger: Use sysfs_match_string() helperAndy Shevchenko2017-06-121-9/+5Star
| | | | | | | | | | | | | | | | Use sysfs_match_string() helper instead of open coded variant. Cc: Sebastian Reichel <sre@kernel.org> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: Sebastian Reichel <sre@kernel.org>
| * power: supply: axp20x_battery: add DT support for battery max constant ↵Quentin Schulz2017-06-081-8/+70
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | charge current This adds the ability to set the maximum constant charge current, supported by the battery, delivered by this battery power supply to the battery. The maximum constant charge current set in DT will also set the default constant charge current supplied by this supply. The actual user can modify the constant charge current within the range of 0 to maximum constant charge current via sysfs. The user can also modify the maximum constant charge current to widen the range of possible constant charge current. While this seems quite risky, a message is printed on the console to warn the user this might damage the battery. The reason for letting the user change the maximum constant charge current is for letting users change the battery and thus, let them adjust the maximum constant charge current according to what the battery can support. Signed-off-by: Quentin Schulz <quentin.schulz@free-electrons.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
| * power: supply: axp20x_battery: add support for DT batteryQuentin Schulz2017-06-081-0/+10
| | | | | | | | | | | | | | | | | | | | | | | | This adds support in X-Powers AXP20X and AXP22X battery driver for a fixed battery in DT. It will take the minimum supported voltage by the battery as defined in the battery DT node and set the V_OFF register to this value, telling the system to shut down if the supplied power is below this value. Signed-off-by: Quentin Schulz <quentin.schulz@free-electrons.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
| * power: supply: bq27xxx: Add power_supply_battery_info supportLiam Breck2017-06-082-1/+214
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
| * power: supply: bq27xxx: Add chip data memory read/write supportLiam Breck2017-06-081-0/+265
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
| * power: supply: bq27xxx: Add bulk transfer bus methodsMatt Ranostay2017-06-082-3/+146
| | | | | | | | | | | | | | | | | | | | | | 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>
| * power: supply: core: Add power_supply_prop_prechargeLiam Breck2017-06-081-0/+1
| | | | | | | | | | | | | | | | Battery chargers use POWER_SUPPLY_PROP_PRECHARGE_CURRENT Clarify related item POWER_SUPPLY_PROP_CHARGE_TERM_CURRENT Signed-off-by: Liam Breck <kernel@networkimprov.net> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
| * power: supply: core: Add power_supply_battery_info and APILiam Breck2017-06-081-0/+57
| | | | | | | | | | | | | | | | | | | | | | | | power_supply_get_battery_info() reads battery data from devicetree. struct power_supply_battery_info provides battery data to drivers. Its fields correspond to elements in enum power_supply_property. Drivers may surface battery data in sysfs via corresponding POWER_SUPPLY_PROP_* fields. 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>
| * power: supply: cpcap-battery: Add a battery driverTony Lindgren2017-06-083-0/+817
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | On the CPCAP PMIC we can use the ADCs for monitoring the battery, and there is also a coulomb counter. So let's add basic support for the battery driver. I did not add any capacity prediction as that should probably be done in the user space. Or at least user space should tell the kernel some battery statistics and then the kernel driver could display the capacity based on that. Cc: devicetree@vger.kernel.org Cc: Marcel Partap <mpartap@gmx.net> Cc: Michael Scott <michael.scott@linaro.org> Cc: Rob Herring <robh@kernel.org> Signed-off-by: Tony Lindgren <tony@atomide.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
| * power: supply: twl4030-charger: remove nonstandard max_current sysfs attributeH. Nikolaus Schaller2017-06-081-63/+0Star
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Since we now support the standard 'input_current_limit' property by commit 3fb319c2cdcd ("power: supply: twl4030-charger: add writable INPUT_CURRENT_LIMIT property") we can now remove the nonstandard 'max_current' sysfs attribute. See Documentation/power/power_supply_class.txt line 125 Both are functionally equivalent. From ABI point of view it is just a rename of the property. This also removes the entry in Documentation/ABI/testing/sysfs-class-power-twl4030 Signed-off-by: H. Nikolaus Schaller <hns@goldelico.com> Signed-off-by: Sebastian Reichel <sre@kernel.org>
| * power: supply: ltc3651-charger: fix some error codes in probeDan Carpenter2017-06-081-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | There are several cut and past bugs here. ltc3651_charger->charger is NULL at this point, so we return success instead of the intended error codes. Fixes: c94d4ed017ae ("power: supply: Add ltc3651-charger driver") Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> [Wei Yongjun found the same issue independently] Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com> Acked-by: Mike Looijmans <mike.looijmans@topic.nl> Signed-off-by: Sebastian Reichel <sre@kernel.org>
| * power: supply: sysfs: parse string as enum when writing propertyDavid Lechner2017-06-081-39/+85
| | | | | | | | | | | | | | | | | | | | | | | | | | This fixes the TODO to parse strings and convert them to enum values when writing to a power_supply class property sysfs attribute. There is at least one driver that has a writable enum property that previously could only be written as an integer, so a fallback to writing enums as integers instead of strings is provided so we don't break existing userspace programs. Signed-off-by: David Lechner <david@lechnology.com> Signed-off-by: Sebastian Reichel <sre@kernel.org>
| * power: supply: Add Apple Brick ID power supply typeBenson Leung2017-06-081-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Apple currently supports three very common USB chargers: https://www.apple.com/power-adapters/ These chargers implement a proprietary Apple method for advertising 1A, 2.1A, and 2.4A at 5V called "Brick ID". In addition, 3rd parties implement the same charging method in many charging accessories that work with iOS devices. Devices that have charger detection chips such as the Pericom PI3USB9281, eg. Google Chromebook Pixel 2015, are capable of detecting these chargers, so let's add a type to facilicate passing that info up to userspace. This adds a separate power supply type for Apple's proprietary "Brick ID" charging method. Signed-off-by: Benson Leung <bleung@chromium.org> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
| * power: supply: core: Add support for supplied-from device-propertyHans de Goede2017-05-151-1/+23
| | | | | | | | | | | | | | | | | | | | | | | | On devicetree using platforms the devicetree can provide info on which power-supplies supply another power-supply through phandles. This commit adds support for providing this info on non devicetree platforms through the platform code setting a supplied-from device-property on the power-supplies parent device. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
| * power: supply: axp20x_usb_power: Drop unnecessary staticJulia Lawall2017-05-151-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Drop static on a local variable, when the variable is either first initialized or never used, on every possible execution path through the function. The static has no benefit, and dropping it reduces the code size. The semantic patch that fixes this problem is as follows: (http://coccinelle.lip6.fr/) // <smpl> @bad exists@ position p; identifier x; type T; @@ static T x@p; ... x = <+...x...+> @@ identifier x; expression e; type T; position p != bad.p; @@ -static T x@p; ... when != x when strict ?x = e; // </smpl> The change in code size is indicates by the following output from the size command. before: text data bss dec hex filename 2865 252 8 3125 c35 drivers/power/supply/axp20x_usb_power.o after: text data bss dec hex filename 2822 252 0 3074 c02 drivers/power/supply/axp20x_usb_power.o Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
| * power: supply: Add ltc3651-charger driverMike Looijmans2017-05-153-0/+218
| | | | | | | | | | | | | | | | | | The LTC3651 reports its status via GPIO lines. This driver translates the GPIO levels to battery charger status information via sysfs. It relies on devicetree to supply the IO configuration. Signed-off-by: Mike Looijmans <mike.looijmans@topic.nl> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
| * power: supply: cpcap-charger: Fix charger voltages based on ADC valuesTony Lindgren2017-05-141-10/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | With the ADC driver working, we can now fix the voltage table based on the values read from the ADC. Note that unlike the ICHRG registers, the VCHRG register bits don't match the MC13783UG.pdf. Cc: Marcel Partap <mpartap@gmx.net> Cc: Michael Scott <michael.scott@linaro.org> Signed-off-by: Tony Lindgren <tony@atomide.com> Signed-off-by: Sebastian Reichel <sre@kernel.org>
| * power: supply: cpcap-charger: Update charge current table and add commentsTony Lindgren2017-05-141-24/+35
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Turns out a similar battery charger hardware is documented for NXP MC13783 PMIC in "MC13783 Power Management and Audio Circuit Users's Guide" named MC13783UG.pdf. Looks like the CPCAP charge current table matches that, so let's start using the nominal values from it. While at it, let's also add comments to some of the mystery CPCAP charger registers based on the MC13783UG.pdf documentation. Note that this patch does not contain any functional changes, the register values being used stay the same. Cc: Marcel Partap <mpartap@gmx.net> Cc: Michael Scott <michael.scott@linaro.org> Signed-off-by: Tony Lindgren <tony@atomide.com> Signed-off-by: Sebastian Reichel <sre@kernel.org>
* | w1: Add subsystem kernel public interfaceAndrew F. Davis2017-06-093-3/+3
|/ | | | | | | | | | | | | | | | | | | | Like other subsystems we should be able to define slave devices outside of the w1 directory. To do this we move public facing interface definitions to include/linux/w1.h and rename the internal definition file to w1_internal.h. As w1_family.h and w1_int.h contained almost entirely public driver interface definitions we simply removed these files and moved the remaining definitions into w1_internal.h. With this we can now start to move slave devices out of w1/slaves and into the subsystem based on the function they implement, again like other drivers. Signed-off-by: Andrew F. Davis <afd@ti.com> Reviewed-by: Sebastian Reichel <sre@kernel.org> Acked-by: Evgeniy Polyakov <zbr@ioremap.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* Merge tag 'for-v4.12-2' of ↵Linus Torvalds2017-05-1215-172/+945
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | git://git.kernel.org/pub/scm/linux/kernel/git/sre/linux-power-supply Pull more power-supply updates from Sebastian Reichel: "The power-supply subsystem has a few more changes for the v4.12 merge window: - New battery driver for AXP20X and AXP22X PMICs - Improve max17042_battery for usage on x86 - Misc small cleanups & fixes" * tag 'for-v4.12-2' of git://git.kernel.org/pub/scm/linux/kernel/git/sre/linux-power-supply: (34 commits) power: supply: cpcap-charger: Keep trickle charger bits disabled power: supply: cpcap-charger: Fix enable for 3.8V charge setting power: supply: cpcap-charger: Fix charge voltage configuration power: supply: cpcap-charger: Fix charger name power: supply: twl4030-charger: make twl4030_bci_property_is_writeable static power: supply: sbs-battery: Add alert callback mailmap: add Sebastian Reichel power: supply: avoid unused twl4030-madc.h power: supply: sbs-battery: Correct supply status with current draw power: supply: sbs-battery: Don't ignore the first external power change power: supply: pda_power: move from timer to delayed_work power: supply: max17042_battery: Add support for the SCOPE property power: supply: max17042_battery: Add support for the CHARGE_NOW property power: supply: max17042_battery: Add support for the CHARGE_FULL_DESIGN property power: supply: max17042_battery: mAh readings depend on r_sns value power: supply: max17042_battery: Add support for the VOLT_MIN property power: supply: max17042_battery: Add support for the TECHNOLOGY attribute power: supply: max17042_battery: Add external_power_changed callback power: supply: max17042_battery: Add support for the STATUS property power: supply: max17042_battery: Add default platform_data fallback data ...
| * power: supply: cpcap-charger: Keep trickle charger bits disabledTony Lindgren2017-05-041-2/+1Star
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Android does not seem to set the trickle charger bits, and these seem to be only used by the bootloader when bringing up a completely discharged battery. So let's keep the trickle charging bits disabled and avoid misconfiguring the hardware. Fixes: 0c9888e3c192 ("power: supply: cpcap-charger: Add minimal CPCAP PMIC battery charger") Cc: Marcel Partap <mpartap@gmx.net> Cc: Michael Scott <michael.scott@linaro.org> Signed-off-by: Tony Lindgren <tony@atomide.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
| * power: supply: cpcap-charger: Fix enable for 3.8V charge settingTony Lindgren2017-05-041-1/+1
| | | | | | | | | | | | | | | | | | | | | | Zero is a valid register value for for 3.8V charging. Fixes: 0c9888e3c192 ("power: supply: cpcap-charger: Add minimal CPCAP PMIC battery charger") Cc: Marcel Partap <mpartap@gmx.net> Cc: Michael Scott <michael.scott@linaro.org> Signed-off-by: Tony Lindgren <tony@atomide.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
| * power: supply: cpcap-charger: Fix charge voltage configurationTony Lindgren2017-05-041-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We have the charge voltage wrong, it should be 4.35V instead of 4.2V. This will cause the battery to never get fully charged. I noticed this when looking at the Andoid kernel battery and charger status for a fully charged battery: POWER_SUPPLY_VOLTAGE_NOW=4351000 Also the battery on droid 4 says "4.35, 1735/1785mAh (min/typ), 6.6/6.8 Wh (min/typ)". Presumably the 4.35 on the battery is the charge voltage. And finally, on Android the CPCAP CRM register is set to 0x03b5 where the b is the charge voltage. Let's fix the charge voltage define and update the charge configuration to use the 4.35V setting. Fixes: 0c9888e3c192 ("power: supply: cpcap-charger: Add minimal CPCAP PMIC battery charger") Cc: Marcel Partap <mpartap@gmx.net> Cc: Michael Scott <michael.scott@linaro.org> Signed-off-by: Tony Lindgren <tony@atomide.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
| * power: supply: cpcap-charger: Fix charger nameTony Lindgren2017-05-041-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | I noticed we have a different name from what Android is using. Let's not break the /sys/class/power user space interface here and use the same naming as Android has. On Android we have the following for droid 4: $ ls /sys/class/power_supply/ ac battery usb So let's use the usb naming here for charger too. Fixes: 0c9888e3c192 ("power: supply: cpcap-charger: Add minimal CPCAP PMIC battery charger") Cc: Marcel Partap <mpartap@gmx.net> Cc: Michael Scott <michael.scott@linaro.org> Signed-off-by: Tony Lindgren <tony@atomide.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
| * power: supply: twl4030-charger: make twl4030_bci_property_is_writeable staticSebastian Reichel2017-05-041-1/+1
| | | | | | | | | | | | | | | | | | The function twl4030_bci_property_is_writeable can be made static as it does not need to be in global scope. Signed-off-by: Colin Ian King <colin.king@canonical.com> Tested-by: "H. Nikolaus Schaller" <hns@goldelico.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
| * power: supply: sbs-battery: Add alert callbackPhil Reid2017-05-011-3/+13
| | | | | | | | | | | | | | | | | | To simplify the sbs-manager code and notification of battery removal use the i2c alert callback to notify the sbs-battery driver that an event has occurred. Signed-off-by: Phil Reid <preid@electromag.com.au> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
| * power: supply: avoid unused twl4030-madc.hSebastian Reichel2017-05-012-2/+0Star
| | | | | | | | | | | | | | | | Avoid inclusion of unused twl4030-madc.h. This will allow twl4030-madc.h to be merged into the iio driver. Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
| * power: supply: sbs-battery: Correct supply status with current drawPaul Kocialkowski2017-05-011-0/+29
| | | | | | | | | | | | | | | | | | | | | | The status reported directly by the battery controller is not always reliable and should be corrected based on the current draw information. This implements such a correction with a dedicated function, called where the supply status is retrieved. Signed-off-by: Paul Kocialkowski <contact@paulk.fr> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
| * power: supply: sbs-battery: Don't ignore the first external power changePaul Kocialkowski2017-05-011-10/+0Star
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | A mechanism to ignore the first external power change notification was put in place years ago to ignore the power_supply_register notification. However, this doesn't apply to the current situation anymore, as the first notification is always the result of a legitimate power change. This removes this deprecated mechanism, which puts back the driver's state machine to a sane state (an ignored first notification previously caused a charging/discharging status inversion). Signed-off-by: Paul Kocialkowski <contact@paulk.fr> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
| * power: supply: pda_power: move from timer to delayed_workMichael Trimarchi2017-05-011-22/+27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This changed is needed to avoid locking problem during boot as shown: <5>[ 8.824096] Registering SWP/SWPB emulation handler <6>[ 8.977294] clock: disabling unused clocks to save power <3>[ 9.108154] BUG: sleeping function called from invalid context at kernel_albert/kernel/mutex.c:269 <3>[ 9.122894] in_atomic(): 1, irqs_disabled(): 0, pid: 1, name: swapper/0 <4>[ 9.130249] 3 locks held by swapper/0/1: <4>[ 9.134613] #0: (&__lockdep_no_validate__){......}, at: [<c0342430>] __driver_attach+0x58/0xa8 <4>[ 9.144500] #1: (&__lockdep_no_validate__){......}, at: [<c0342440>] __driver_attach+0x68/0xa8 <4>[ 9.154357] #2: (&polling_timer){......}, at: [<c0053770>] run_timer_softirq+0x108/0x3ec <4>[ 9.163726] Backtrace: <4>[ 9.166473] [<c001269c>] (dump_backtrace+0x0/0x114) from [<c067e5f0>] (dump_stack+0x20/0x24) <4>[ 9.175811] r6:00203230 r5:0000010d r4:d782e000 r3:60000113 <4>[ 9.182250] [<c067e5d0>] (dump_stack+0x0/0x24) from [<c007441c>] (__might_sleep+0x10c/0x128) <4>[ 9.191650] [<c0074310>] (__might_sleep+0x0/0x128) from [<c0688f60>] (mutex_lock_nested+0x34/0x36c) <4>[ 9.201660] r5:c02d5350 r4:d79a0c64 <4>[ 9.205688] [<c0688f2c>] (mutex_lock_nested+0x0/0x36c) from [<c02d5350>] (regulator_set_current_limit+0x30/0x118) <4>[ 9.217071] [<c02d5320>] (regulator_set_current_limit+0x0/0x118) from [<c0435ce0>] (update_charger+0x84/0xc4) <4>[ 9.228027] r7:d782fb20 r6:00000101 r5:c1767e94 r4:00000000 <4>[ 9.234436] [<c0435c5c>] (update_charger+0x0/0xc4) from [<c0435d40>] (psy_changed+0x20/0x48) <4>[ 9.243804] r5:d782e000 r4:c1767e94 <4>[ 9.247802] [<c0435d20>] (psy_changed+0x0/0x48) from [<c0435dec>] (polling_timer_func+0x84/0xb8) <4>[ 9.257537] r4:c1767e94 r3:00000002 <4>[ 9.261566] [<c0435d68>] (polling_timer_func+0x0/0xb8) from [<c00537e4>] (run_timer_softirq+0x17c/0x3ec) <4>[ 9.272033] r4:c1767eb0 r3:00000000 <4>[ 9.276062] [<c0053668>] (run_timer_softirq+0x0/0x3ec) from [<c004b000>] (__do_softirq+0xf0/0x298) <4>[ 9.286010] [<c004af10>] (__do_softirq+0x0/0x298) from [<c004b650>] (irq_exit+0x98/0xa0) <4>[ 9.295013] [<c004b5b8>] (irq_exit+0x0/0xa0) from [<c000edbc>] (handle_IRQ+0x60/0xc0) <4>[ 9.303680] r4:c1194e98 r3:c00bc778 <4>[ 9.307708] [<c000ed5c>] (handle_IRQ+0x0/0xc0) from [<c0008504>] (gic_handle_irq+0x34/0x68) <4>[ 9.316955] r8:000ac383 r7:d782fc3c r6:d782fc08 r5:c11936c4 r4:e0802100 <4>[ 9.324310] r3:c026ba48 <4>[ 9.327301] [<c00084d0>] (gic_handle_irq+0x0/0x68) from [<c068c2c0>] (__irq_svc+0x40/0x74) <4>[ 9.336456] Exception stack(0xd782fc08 to 0xd782fc50) <4>[ 9.342041] fc00: d6e30e6c ac383627 00000000 ac383417 ea19c000 ea200000 <4>[ 9.351104] fc20: beffffff 00000667 000ac383 d6e30670 d6e3066c d782fc94 d782fbe8 d782fc50 <4>[ 9.360168] fc40: c026ba48 c001d1f0 00000113 ffffffff Fixes: b2998049cfae ("[BATTERY] pda_power platform driver") Signed-off-by: Michael Trimarchi <michael@amarulasolutions.com> Signed-off-by: Anthony Brandon <anthony@amarulasolutions.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
| * power: supply: max17042_battery: Add support for the SCOPE propertyHans de Goede2017-05-011-0/+4
| | | | | | | | | | | | | | | | | | | | Add support for the SCOPE property, always return SCOPE_SYSTEM, as the max170xx is used for the main battery on all known systems with a max170xx. 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>
| * power: supply: max17042_battery: Add support for the CHARGE_NOW propertyHans de Goede2017-05-011-0/+10
| | | | | | | | | | | | | | | | | | At least upower prefers the more precise charge_now sysfs value over capacity and the max17042 has the info, so lets export it. 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>
| * power: supply: max17042_battery: Add support for the CHARGE_FULL_DESIGN propertyHans de Goede2017-05-011-0/+10
| | | | | | | | | | | | | | | | 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>
| * power: supply: max17042_battery: mAh readings depend on r_sns valueHans de Goede2017-05-011-1/+4
| | | | | | | | | | | | | | | | | | | | 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>
| * power: supply: max17042_battery: Add support for the VOLT_MIN propertyHans de Goede2017-05-011-0/+8
| | | | | | | | | | | | | | | | 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>
| * power: supply: max17042_battery: Add support for the TECHNOLOGY attributeHans de Goede2017-05-011-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
| * power: supply: max17042_battery: Add external_power_changed callbackHans de Goede2017-05-011-0/+6
| | | | | | | | | | | | | | | | | | 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>
| * power: supply: max17042_battery: Add support for the STATUS propertyHans de Goede2017-05-011-0/+46
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
| * power: supply: max17042_battery: Add default platform_data fallback dataHans de Goede2017-05-011-7/+53
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
| * power: supply: max17047_battery: The temp alert values are 8-bit 2's complementHans de Goede2017-05-011-2/+2
| | | | | | | | | | | | | | | | | | 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>
| * power: supply: max17042_battery: Use sign_extend32 instead of DIY codeHans de Goede2017-05-011-21/+3Star
| | | | | | | | | | | | | | | | | | 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>