aboutsummaryrefslogtreecommitdiff
path: root/drivers/power/supply
AgeCommit message (Collapse)AuthorFilesLines
2024-05-20Merge tag 'i2c-for-6.10-rc1' of ↵Gravatar Linus Torvalds 1-1/+1
git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux Pull i2c updates from Wolfram Sang: "i2c core removes an argument from the i2c_mux_add_adapter() call to further deprecate class based I2C device instantiation. All users are converted, too. Other that that, Andi collected a number if I2C host driver patches. Those merges have their own description" * tag 'i2c-for-6.10-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux: (72 commits) power: supply: sbs-manager: Remove class argument from i2c_mux_add_adapter() i2c: mux: Remove class argument from i2c_mux_add_adapter() i2c: synquacer: Fix an error handling path in synquacer_i2c_probe() i2c: acpi: Unbind mux adapters before delete i2c: designware: Replace MODULE_ALIAS() with MODULE_DEVICE_TABLE() i2c: pxa: use 'time_left' variable with wait_event_timeout() i2c: s3c2410: use 'time_left' variable with wait_event_timeout() i2c: rk3x: use 'time_left' variable with wait_event_timeout() i2c: qcom-geni: use 'time_left' variable with wait_for_completion_timeout() i2c: jz4780: use 'time_left' variable with wait_for_completion_timeout() i2c: synquacer: use 'time_left' variable with wait_for_completion_timeout() i2c: stm32f7: use 'time_left' variable with wait_for_completion_timeout() i2c: stm32f4: use 'time_left' variable with wait_for_completion_timeout() i2c: st: use 'time_left' variable with wait_for_completion_timeout() i2c: omap: use 'time_left' variable with wait_for_completion_timeout() i2c: imx-lpi2c: use 'time_left' variable with wait_for_completion_timeout() i2c: hix5hd2: use 'time_left' variable with wait_for_completion_timeout() i2c: exynos5: use 'time_left' variable with wait_for_completion_timeout() i2c: digicolor: use 'time_left' variable with wait_for_completion_timeout() i2c: amd-mp2-plat: use 'time_left' variable with wait_for_completion_timeout() ...
2024-05-18Merge tag 'for-v6.10' of ↵Gravatar Linus Torvalds 5-75/+121
git://git.kernel.org/pub/scm/linux/kernel/git/sre/linux-power-supply Pull power supply and reset updates from Sebastian Reichel: - core: simplify POWER_SUPPLY_PROP_CHARGE_BEHAVIOUR handling - test-power: add POWER_SUPPLY_PROP_CHARGE_BEHAVIOUR support - chrome EC drivers: add ID based probing - bq27xxx: simplify update loop to reduce I2C traffic - max8903 binding: fix GPIO polarity description * tag 'for-v6.10' of git://git.kernel.org/pub/scm/linux/kernel/git/sre/linux-power-supply: dt-bindings: power: supply: max8903: specify flt-gpios as input power: supply: bq27xxx: Move health reading out of update loop power: supply: bq27xxx: Move cycle count reading out of update loop power: supply: bq27xxx: Move energy reading out of update loop power: supply: bq27xxx: Move charge reading out of update loop power: supply: bq27xxx: Move time reading out of update loop power: supply: bq27xxx: Move temperature reading out of update loop power: supply: cros_pchg: provide ID table for avoiding fallback match power: supply: cros_usbpd: provide ID table for avoiding fallback match power: supply: core: simplify charge_behaviour formatting power: supply: test-power: implement charge_behaviour property
2024-05-14power: supply: sbs-manager: Remove class argument from i2c_mux_add_adapter()Gravatar Wolfram Sang 1-1/+1
Commit 99a741aa7a2d ("i2c: mux: gpio: remove support for class-based device instantiation") removed the last call to i2c_mux_add_adapter() with a non-null class argument. Therefore the class argument can be removed. Note: Class-based device instantiation is a legacy mechanism which shouldn't be used in new code, so we can rule out that this argument may be needed again in the future. This driver was forgotten by the patch in the Fixes tag. Fixes: fec1982d7072 ("i2c: mux: Remove class argument from i2c_mux_add_adapter()") Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com> Acked-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2024-04-15power: supply: mt6360_charger: Fix of_match for usb-otg-vbus regulatorGravatar AngeloGioacchino Del Regno 1-1/+1
The of_match shall correspond to the name of the regulator subnode, or the deprecated `regulator-compatible` property must be used: failing to do so, the regulator won't probe (and the driver will as well not probe). Since the devicetree binding for this driver is actually correct and wants DTs to use the "usb-otg-vbus-regulator" subnode name, fix this driver by aligning the `of_match` string to what the DT binding wants. Fixes: 0402e8ebb8b8 ("power: supply: mt6360_charger: add MT6360 charger support") Signed-off-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> Reviewed-by: Chen-Yu Tsai <wenst@chromium.org> Link: https://lore.kernel.org/r/20240410084405.1389378-1-angelogioacchino.delregno@collabora.com Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2024-04-10power: rt9455: hide unused rt9455_boost_voltage_valuesGravatar Arnd Bergmann 1-0/+2
The rt9455_boost_voltage_values[] array is only used when USB PHY support is enabled, causing a W=1 warning otherwise: drivers/power/supply/rt9455_charger.c:200:18: error: 'rt9455_boost_voltage_values' defined but not used [-Werror=unused-const-variable=] Enclose the definition in the same #ifdef as the references to it. Fixes: e86d69dd786e ("power_supply: Add support for Richtek RT9455 battery charger") Signed-off-by: Arnd Bergmann <arnd@arndb.de> Link: https://lore.kernel.org/r/20240403080702.3509288-10-arnd@kernel.org Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2024-04-01power: supply: bq27xxx: Move health reading out of update loopGravatar Andrew Davis 1-12/+18
Most of the functions that read values return a status and put the value itself in an a function parameter. Update health reading to match. As health is not checked for changes as part of the update loop, remove the read of this from the periodic update loop. This saves I2C/1W bandwidth. It also means we do not have to cache it, fresh values are read when requested. Signed-off-by: Andrew Davis <afd@ti.com> Link: https://lore.kernel.org/r/20240325203129.150030-6-afd@ti.com Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2024-04-01power: supply: bq27xxx: Move cycle count reading out of update loopGravatar Andrew Davis 1-5/+6
Most of the functions that read values return a status and put the value itself in an a function parameter. Update cycle count reading to match. As cycle count is not checked for changes as part of the update loop, remove the read of this from the periodic update loop. This saves I2C/1W bandwidth. It also means we do not have to cache it, fresh values are read when requested. Signed-off-by: Andrew Davis <afd@ti.com> Link: https://lore.kernel.org/r/20240325203129.150030-5-afd@ti.com Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2024-04-01power: supply: bq27xxx: Move energy reading out of update loopGravatar Andrew Davis 1-5/+6
Most of the functions that read values return a status and put the value itself in an a function parameter. Update energy reading to match. As energy is not checked for changes as part of the update loop, remove the read of this from the periodic update loop. This saves I2C/1W bandwidth. It also means we do not have to cache it, fresh values are read when requested. Signed-off-by: Andrew Davis <afd@ti.com> Link: https://lore.kernel.org/r/20240325203129.150030-4-afd@ti.com Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2024-04-01power: supply: bq27xxx: Move charge reading out of update loopGravatar Andrew Davis 1-12/+17
Most of the functions that read values return a status and put the value itself in an a function parameter. Update charge reading to match. As charge state is not checked for changes as part of the update loop, remove the read of this from the periodic update loop. This saves I2C/1W bandwidth. It also means we do not have to cache it, fresh values are read when requested. Signed-off-by: Andrew Davis <afd@ti.com> Link: https://lore.kernel.org/r/20240325203129.150030-3-afd@ti.com Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2024-04-01power: supply: bq27xxx: Move time reading out of update loopGravatar Andrew Davis 1-12/+8
Most of the functions that read values return a status and put the value itself in an a function parameter. Update time reading to match. As time is not checked for changes as part of the update loop, remove the read of the this from the periodic update loop. This saves I2C/1W bandwidth. It also means we do not have to cache it, fresh values are read when requested. Signed-off-by: Andrew Davis <afd@ti.com> Link: https://lore.kernel.org/r/20240325203129.150030-2-afd@ti.com Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2024-04-01power: supply: bq27xxx: Move temperature reading out of update loopGravatar Andrew Davis 1-7/+10
Most of the functions that read values return a status and put the value itself in an a function parameter. Update temperature reading to match. As temp is not checked for changes as part of the update loop, remove the read of the temperature from the periodic update loop. This saves I2C/1W bandwidth. It also means we do not have to cache it, fresh values are read when requested. Signed-off-by: Andrew Davis <afd@ti.com> Link: https://lore.kernel.org/r/20240325203129.150030-1-afd@ti.com Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2024-04-01power: supply: cros_pchg: provide ID table for avoiding fallback matchGravatar Tzung-Bi Shih 1-2/+9
Instead of using fallback driver name match, provide ID table[1] for the primary match. [1]: https://elixir.bootlin.com/linux/v6.8/source/drivers/base/platform.c#L1353 Reviewed-by: Benson Leung <bleung@chromium.org> Reviewed-by: Krzysztof Kozlowski <krzk@kernel.org> Signed-off-by: Tzung-Bi Shih <tzungbi@kernel.org> Link: https://lore.kernel.org/r/20240401030052.2887845-5-tzungbi@kernel.org Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2024-04-01power: supply: cros_usbpd: provide ID table for avoiding fallback matchGravatar Tzung-Bi Shih 1-2/+9
Instead of using fallback driver name match, provide ID table[1] for the primary match. [1]: https://elixir.bootlin.com/linux/v6.8/source/drivers/base/platform.c#L1353 Reviewed-by: Benson Leung <bleung@chromium.org> Reviewed-by: Prashant Malani <pmalani@chromium.org> Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org> Signed-off-by: Tzung-Bi Shih <tzungbi@kernel.org> Link: https://lore.kernel.org/r/20240401030052.2887845-4-tzungbi@kernel.org Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2024-03-29power: supply: core: simplify charge_behaviour formattingGravatar Thomas Weißschuh 1-18/+2
The function power_supply_show_charge_behaviour() is not needed and can be removed completely. Removing the function also saves a spurious read of the property from the driver on each call. The convulted logic was a leftover from an earlier patch revision. Some restructuring made this cleanup possible. Suggested-by: Hans de Goede <hdegoede@redhat.com> Link: https://lore.kernel.org/all/9e035ae4-cb07-4f84-8336-1a0050855bea@redhat.com/ Fixes: 4e61f1e9d58f ("power: supply: core: fix charge_behaviour formatting") Signed-off-by: Thomas Weißschuh <linux@weissschuh.net> Reviewed-by: Hans de Goede <hdegoede@redhat.com> Link: https://lore.kernel.org/r/20240329-power-supply-simplify-v1-1-416f1002739f@weissschuh.net Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2024-03-25power: supply: test-power: implement charge_behaviour propertyGravatar Thomas Weißschuh 1-0/+36
To validate the special formatting of the "charge_behaviour" sysfs property add it to the example driver. Signed-off-by: Thomas Weißschuh <linux@weissschuh.net> Link: https://lore.kernel.org/r/20240306-power_supply-charge_behaviour_prop-v3-1-d04cf1f5f0af@weissschuh.net Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2024-03-14Merge tag 'for-v6.9' of ↵Gravatar Linus Torvalds 32-473/+402
git://git.kernel.org/pub/scm/linux/kernel/git/sre/linux-power-supply Pull power supply and reset updates from Sebastian Reichel: "New features: - axp20x_usb_power: report USB type Cleanups: - convert lots of drivers to use devm_power_supply_register() - convert lots of reset drivers to use devm_register_sys_off_handler() - constify device_type and power_supply_class - axp20x_usb_power: use correct property to report input current limit - mm8013: correct handling of "not charging" status register - core: fix charge_behaviour formatting - minor fixes cleanups" * tag 'for-v6.9' of git://git.kernel.org/pub/scm/linux/kernel/git/sre/linux-power-supply: (66 commits) power: supply: core: fix charge_behaviour formatting power: supply: core: ease special formatting implementations power: supply: mm8013: fix "not charging" detection power: supply: move power_supply_attr_groups definition back to sysfs power: supply: core: simplify power_supply_class_init power: supply: core: add power_supply_for_each_device() power: supply: core: make power_supply_class constant power: supply: bq2415x_charger: report online status power: supply: core: move power_supply_attr_group into #ifdef block power: supply: core: Fix power_supply_init_attrs() stub power: supply: bq27xxx: Report charge full state correctly power: reset: rmobile-reset: Make sysc_base2 local power: supply: core: constify the struct device_type usage power: supply: axp288_fuel_gauge: Deny ROCK Pi X power: reset: rmobile-reset: Map correct MMIO resource power: reset: xgene-reboot: Fix a NULL vs IS_ERR() test power: supply: axp288_fuel_gauge: Add STCK1A* Intel Compute Sticks to the deny-list power: reset: syscon-poweroff: Use devm_register_sys_off_handler(POWER_OFF) power: reset: syscon-poweroff: Move device data into a struct power: reset: restart-poweroff: Use devm_register_sys_off_handler(POWER_OFF) ...
2024-03-06power: supply: core: fix charge_behaviour formattingGravatar Thomas Weißschuh 1-0/+20
This property is documented to have a special format which exposes all available behaviours and the currently active one at the same time. For this special format some helpers are provided. When the charge_behaviour property was added in 1b0b6cc8030d ("power: supply: add charge_behaviour attributes"), it did not update the default logic in in power_supply_sysfs.c to use the format helpers. Thus by default only the currently active behaviour is printed. This fixes the default logic to follow the documented format. There is currently only one in-tree drivers exposing charge behaviours - thinkpad_acpi, which is not affected by the change, as it directly uses the helpers and does not use the power_supply_sysfs.c logic. Signed-off-by: Thomas Weißschuh <linux@weissschuh.net> Link: https://lore.kernel.org/r/20240303-power_supply-charge_behaviour_prop-v2-3-8ebb0a7c2409@weissschuh.net Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2024-03-06power: supply: core: ease special formatting implementationsGravatar Thomas Weißschuh 1-6/+6
By moving the conditional into the default-branch of the switch new additions to the switch won't have to bypass the conditional. This makes it easier to implement those special cases like the upcoming change to the formatting of "charge_behaviour". Suggested-by: Hans de Goede <hdegoede@redhat.com> Link: https://lore.kernel.org/lkml/53082075-852f-4698-b354-ed30e7fd2683@redhat.com/ Signed-off-by: Thomas Weißschuh <linux@weissschuh.net> Link: https://lore.kernel.org/r/20240303-power_supply-charge_behaviour_prop-v2-2-8ebb0a7c2409@weissschuh.net Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2024-03-06power: supply: mm8013: fix "not charging" detectionGravatar Thomas Weißschuh 1-11/+2
The charge_behaviours property is meant as a control-knob that can be changed by the user. Page 23 of [0] which documents the flag CHG_INH as follows: CHG_INH : Charge Inhibit When the current is more than or equal to charge threshold current, charge inhibit temperature (upper/lower limit) :1 charge permission temperature or the current is less than charge threshold current :0 So this is pure read-only information which is better represented as POWER_SUPPLY_STATUS_NOT_CHARGING. [0] https://product.minebeamitsumi.com/en/product/category/ics/battery/fuel_gauge/parts/download/__icsFiles/afieldfile/2023/07/12/1_download_01_12.pdf Signed-off-by: Thomas Weißschuh <linux@weissschuh.net> Link: https://lore.kernel.org/r/20240303-power_supply-charge_behaviour_prop-v2-1-8ebb0a7c2409@weissschuh.net Fixes: e39257cde7e8 ("power: supply: mm8013: Add more properties") Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2024-03-06power: supply: move power_supply_attr_groups definition back to sysfsGravatar Ricardo B. Marliere 3-4/+8
As reported by the kernel test robot, 'power_supply_attr_group' is defined but not used when CONFIG_SYSFS is not set. Sebastian suggested that the correct fix implemented by this patch, instead of my attempt in commit ea4367c40c79 ("power: supply: core: move power_supply_attr_group into #ifdef block"), is to define power_supply_attr_groups in power_supply_sysfs.c and expose it in the power_supply.h header. For the case where CONFIG_SYSFS=n, define it as NULL. Suggested-by: Sebastian Reichel <sebastian.reichel@collabora.com> Fixes: ea4367c40c79 ("power: supply: core: move power_supply_attr_group into #ifdef block") Reported-by: kernel test robot <lkp@intel.com> Closes: https://lore.kernel.org/oe-kbuild-all/202403021518.SUQzk3oA-lkp@intel.com/ Signed-off-by: Ricardo B. Marliere <ricardo@marliere.net> Link: https://lore.kernel.org/r/20240303-class_cleanup-power-v2-1-e248b7128519@marliere.net Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2024-03-06power: supply: core: simplify power_supply_class_initGravatar Sebastian Reichel 1-8/+1
Technically the sysfs attributes should be initialized before the class is registered, since that will use them. As a nice side effect this nicely simplifies the code, since it allows dropping the helper variable. Reviewed-by: Ricardo B. Marliere <ricardo@marliere.net> Link: https://lore.kernel.org/r/20240301-psy-class-cleanup-v1-2-aebe8c4b6b08@collabora.com Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2024-03-06power: supply: core: add power_supply_for_each_device()Gravatar Sebastian Reichel 6-28/+21
Introduce power_supply_for_each_device(), which is a wrapper for class_for_each_device() using the power_supply_class and going through all devices. This allows making the power_supply_class itself a local variable, so that drivers cannot mess with it and simplifies the code slightly. Reviewed-by: Ricardo B. Marliere <ricardo@marliere.net> Link: https://lore.kernel.org/r/20240301-psy-class-cleanup-v1-1-aebe8c4b6b08@collabora.com Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2024-03-01power: supply: core: make power_supply_class constantGravatar Ricardo B. Marliere 6-23/+26
Since commit 43a7206b0963 ("driver core: class: make class_register() take a const *"), the driver core allows for struct class to be in read-only memory, so move the power_supply_class structure to be declared at build time placing it into read-only memory, instead of having to be dynamically allocated at boot time. Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Suggested-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Ricardo B. Marliere <ricardo@marliere.net> Reviewed-by: Linus Walleij <linus.walleij@linaro.org> Link: https://lore.kernel.org/r/20240301-class_cleanup-power-v1-1-97e0b7bf9c94@marliere.net Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2024-03-01power: supply: bq2415x_charger: report online statusGravatar Sicelo A. Mhlongo 1-0/+10
Provide the Online property. This chip does not have specific flags to indicate the presence of an input voltage, but this is implied by all valid charging states. Fault states also only occur when VBUS is present, so set Online true for those as well. Signed-off-by: Sicelo A. Mhlongo <absicsz@gmail.com> Link: https://lore.kernel.org/r/20240229063721.2592069-2-absicsz@gmail.com Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2024-02-28power: supply: core: move power_supply_attr_group into #ifdef blockGravatar Ricardo B. Marliere 1-2/+2
When building with CONFIG_SYSFS=n, the build error below is triggered: ld: drivers/power/supply/power_supply_core.o:(.data+0x0): undefined reference to `power_supply_attr_group' The problem is that power_supply_attr_group is needed in power_supply_core.c but defined in power_supply_sysfs.c, which is only targeted with CONFIG_SYSFS=y. Therefore, move the extern declaration into the #ifdef block that checks for CONFIG_SYSFS, and define an empty static const struct otherwise. This is safe because the macro __ATRIBUTE_GROUPS in power_supply_core.c will expand into an empty attribute_group array. Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Reported-by: Nathan Chancellor <nathan@kernel.org> Link: https://lore.kernel.org/all/20240227214916.GA3699076@dev-arch.thelio-3990X/ Fixes: 7b46b60944d7 ("power: supply: core: constify the struct device_type usage") Signed-off-by: Ricardo B. Marliere <ricardo@marliere.net> Tested-by: Nathan Chancellor <nathan@kernel.org> # build Link: https://lore.kernel.org/r/20240228-device_cleanup-power-v1-1-52c0321c48e1@marliere.net Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2024-02-28power: supply: core: Fix power_supply_init_attrs() stubGravatar Nathan Chancellor 1-1/+1
When building without CONFIG_SYSFS, there is an error because of a recent refactoring that failed to update the stub of power_supply_init_attrs(): drivers/power/supply/power_supply_core.c: In function 'power_supply_class_init': drivers/power/supply/power_supply_core.c:1630:9: error: too few arguments to function 'power_supply_init_attrs' 1630 | power_supply_init_attrs(); | ^~~~~~~~~~~~~~~~~~~~~~~ In file included from drivers/power/supply/power_supply_core.c:25: drivers/power/supply/power_supply.h:25:20: note: declared here 25 | static inline void power_supply_init_attrs(struct device_type *dev_type) {} | ^~~~~~~~~~~~~~~~~~~~~~~ Update the stub function to take no parameters like the rest of the refactoring, which resolves the build error. Fixes: 7b46b60944d7 ("power: supply: core: constify the struct device_type usage") Signed-off-by: Nathan Chancellor <nathan@kernel.org> Reviewed-by: Ricardo B. Marliere <ricardo@marliere.net> Link: https://lore.kernel.org/r/20240227-fix-power_supply_init_attrs-stub-v1-1-43365e68d4b3@kernel.org Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2024-02-27power: supply: bq27xxx: Report charge full state correctlyGravatar Sicelo A. Mhlongo 1-9/+6
When reporting the charging status, the existing code reports the battery as full only when the reported current flowing is exactly 0mA, which is unlikely in practice. Fix the reporting by giving priority to the battery's full state indication/flag. Tested on the Nokia N900 with bq27200 fuel gauge. Signed-off-by: Sicelo A. Mhlongo <absicsz@gmail.com> Link: https://lore.kernel.org/r/20240226193722.2173624-1-absicsz@gmail.com Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2024-02-25power: supply: core: constify the struct device_type usageGravatar Ricardo B. Marliere 3-12/+11
Since commit aed65af1cc2f ("drivers: make device_type const"), the driver core can properly handle constant struct device_type. Move the power_supply_dev_type variable to be a constant structure as well, placing it into read-only memory which can not be modified at runtime. In order to accomplish that, export power_supply_attr_group in power_supply.h and use it with the macro __ATTRIBUTE_GROUPS when defining power_supply_dev_type in power_supply_core.c. Therefore the attribute group is no longer static. Lastly, because power_supply_attr_groups is no longer dynamically associated to power_supply_dev_type in power_supply_init_attrs(), make the function receive zero arguments. Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Ricardo B. Marliere <ricardo@marliere.net> Link: https://lore.kernel.org/r/20240224-device_cleanup-power-v2-1-465ff94b896c@marliere.net Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2024-02-21power: supply: axp288_fuel_gauge: Deny ROCK Pi XGravatar Guoyi Zhang 1-0/+8
The ROCK Pi X is a single board computer without batteries using the AXP288 PMIC where the EFI code does not disable the charger part of the PMIC causing us to report a discharging battery with a continuously consumed battery charge to userspace. Add it to the deny-list to avoid the bogus battery status reporting. Signed-off-by: Guoyi Zhang <kuoi@bioarchlinux.org> Reviewed-by: Hans de Goede <hdegoede@redhat.com> Link: https://lore.kernel.org/r/20240221083425.440108-1-kuoi@bioarchlinux.org Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2024-02-17power: supply: axp288_fuel_gauge: Add STCK1A* Intel Compute Sticks to the ↵Gravatar Hans de Goede 1-4/+6
deny-list Besides the existing STK1A* Cherry Trail based Intel Compute Sticks already on the deny-list, Intel also made Bay Trail based Compute Sticks which have a product name of STCK1A* and wich also report a non existing battery with a random battery charge. Instead of adding 3 new deny-list entries for the 3 variants of the STCK1A* sticks consolidate the 2 Cherry Trail STK1AW32SC and STK1A32SC variants into a single entry with a partial match for STK1A* and add a single new STCK1A* match for the Bay Trail variants. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Link: https://lore.kernel.org/r/20240212090014.13719-1-hdegoede@redhat.com Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2024-02-16power: supply: bq27xxx-i2c: Do not free non existing IRQGravatar Hans de Goede 1-1/+3
The bq27xxx i2c-client may not have an IRQ, in which case client->irq will be 0. bq27xxx_battery_i2c_probe() already has an if (client->irq) check wrapping the request_threaded_irq(). But bq27xxx_battery_i2c_remove() unconditionally calls free_irq(client->irq) leading to: [ 190.310742] ------------[ cut here ]------------ [ 190.310843] Trying to free already-free IRQ 0 [ 190.310861] WARNING: CPU: 2 PID: 1304 at kernel/irq/manage.c:1893 free_irq+0x1b8/0x310 Followed by a backtrace when unbinding the driver. Add an if (client->irq) to bq27xxx_battery_i2c_remove() mirroring probe() to fix this. Fixes: 444ff00734f3 ("power: supply: bq27xxx: Fix I2C IRQ race on remove") Signed-off-by: Hans de Goede <hdegoede@redhat.com> Link: https://lore.kernel.org/r/20240215155133.70537-1-hdegoede@redhat.com Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2024-02-12power: supply: mm8013: select REGMAP_I2CGravatar Thomas Weißschuh 1-0/+1
The driver uses regmap APIs so it should make sure they are available. Fixes: c75f4bf6800b ("power: supply: Introduce MM8013 fuel gauge driver") Cc: <stable@vger.kernel.org> Signed-off-by: Thomas Weißschuh <linux@weissschuh.net> Reviewed-by: Konrad Dybcio <konrad.dybcio@linaro.org> Link: https://lore.kernel.org/r/20240204-mm8013-regmap-v1-1-7cc6b619b7d3@weissschuh.net Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2024-02-02power: supply: axp20x_usb_power: enable usb_type reportingGravatar Aren Moynihan 1-1/+72
The axp803 and axp813 chips can report the detected USB BC mode. SDP, CDP, and DCP are supported. Signed-off-by: Aren Moynihan <aren@peacevolution.org> Link: https://lore.kernel.org/r/20240130203714.3020464-5-aren@peacevolution.org Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2024-02-02power: supply: axp20x_usb_power: fix race condition with usb bcGravatar Aren Moynihan 1-0/+23
When input_current_limit is set while USB BC is in progress, the BC module will overwrite the value that was set when it finishes detection. Signed-off-by: Aren Moynihan <aren@peacevolution.org> Link: https://lore.kernel.org/r/20240130203714.3020464-4-aren@peacevolution.org Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2024-02-02power: supply: axp20x_usb_power: use correct register for input current limitGravatar Aren Moynihan 1-4/+18
On the axp803 and axp813 chips register 0x30 bits 0-1 is the default current limit that gets applied after the pmic detects a CDP or DCP port. The correct field to set is 0x35 bits 4-7. This field only has nine values (out of the 16 possible if it used all the bits), so introduce a field size variable to take that into account. Signed-off-by: Aren Moynihan <aren@peacevolution.org> Link: https://lore.kernel.org/r/20240130203714.3020464-3-aren@peacevolution.org Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2024-02-02power: supply: axp20x_usb_power: replace current_max with input_current_limitGravatar Aren Moynihan 1-11/+18
The current_max property is supposed to be read-only, and represent the maximum current the supply can provide. input_current_limit is the limit that is currently set, which is what we have here. When determining what value to write to the register, we need to pick a reasonable value if the requested limit doesn't exactly match one supported by the hardware. If the requested limit is less than the lowest value we can set, round up to the lowest value. Otherwise round down to the nearest value supported by hardware. Also add a dev field to the axp20x_usb_power struct, so we can use dev_dbg and dev_err in more places. Signed-off-by: Aren Moynihan <aren@peacevolution.org> Link: https://lore.kernel.org/r/20240130203714.3020464-2-aren@peacevolution.org Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2024-02-01power: supply: wm8350: Use devm_power_supply_register() helperGravatar Andrew Davis 1-23/+7
Use the device lifecycle managed register function. This helps prevent mistakes like unregistering out of order in cleanup functions and forgetting to unregister on error paths. Signed-off-by: Andrew Davis <afd@ti.com> Link: https://lore.kernel.org/r/20240129190246.73067-5-afd@ti.com Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2024-02-01power: supply: max8925: Use devm_power_supply_register() helperGravatar Andrew Davis 1-27/+10
Use the device lifecycle managed register function. This helps prevent mistakes like unregistering out of order in cleanup functions and forgetting to unregister on error paths. Signed-off-by: Andrew Davis <afd@ti.com> Link: https://lore.kernel.org/r/20240129190246.73067-4-afd@ti.com Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2024-02-01power: supply: max77693: Use devm_power_supply_register() helperGravatar Andrew Davis 1-7/+3
Use the device lifecycle managed register function. This helps prevent mistakes like unregistering out of order in cleanup functions and forgetting to unregister on error paths. Signed-off-by: Andrew Davis <afd@ti.com> Link: https://lore.kernel.org/r/20240129190246.73067-3-afd@ti.com Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2024-02-01power: supply: max14577: Use devm_power_supply_register() helperGravatar Andrew Davis 1-5/+3
Use the device lifecycle managed register function. This helps prevent mistakes like unregistering out of order in cleanup functions and forgetting to unregister on error paths. Signed-off-by: Andrew Davis <afd@ti.com> Link: https://lore.kernel.org/r/20240129190246.73067-2-afd@ti.com Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2024-01-27power: supply: twl4030_madc: Use devm_power_supply_register() helperGravatar Andrew Davis 1-12/+3
Use the device lifecycle managed register function. This helps prevent mistakes like unregistering out of order in cleanup functions and forgetting to unregister on error paths. Signed-off-by: Andrew Davis <afd@ti.com> Link: https://lore.kernel.org/r/20240123163653.384385-22-afd@ti.com Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2024-01-27power: supply: twl4030_madc: Use devm_iio_channel_get() helperGravatar Andrew Davis 1-33/+11
Use the device lifecycle managed get function. This helps prevent mistakes like releasing out of order in cleanup functions and forgetting to release on error paths. Signed-off-by: Andrew Davis <afd@ti.com> Link: https://lore.kernel.org/r/20240123163653.384385-21-afd@ti.com Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2024-01-27power: supply: rx51: Use devm_power_supply_register() helperGravatar Andrew Davis 1-11/+1
Use the device lifecycle managed register function. This helps prevent mistakes like unregistering out of order in cleanup functions and forgetting to unregister on error paths. Signed-off-by: Andrew Davis <afd@ti.com> Link: https://lore.kernel.org/r/20240123163653.384385-20-afd@ti.com Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2024-01-27power: supply: rx51: Use devm_iio_channel_get() helperGravatar Andrew Davis 1-34/+11
Use the device lifecycle managed get function. This helps prevent mistakes like releasing out of order in cleanup functions and forgetting to release on error paths. Signed-off-by: Andrew Davis <afd@ti.com> Link: https://lore.kernel.org/r/20240123163653.384385-19-afd@ti.com Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2024-01-27power: supply: da9150: Use devm_power_supply_register() helperGravatar Andrew Davis 1-11/+4
Use the device lifecycle managed register function. This helps prevent mistakes like unregistering out of order in cleanup functions and forgetting to unregister on error paths. Signed-off-by: Andrew Davis <afd@ti.com> Link: https://lore.kernel.org/r/20240123163653.384385-18-afd@ti.com Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2024-01-27power: supply: da9150: Use devm_iio_channel_get() helperGravatar Andrew Davis 1-43/+14
Use the device lifecycle managed get function. This helps prevent mistakes like releasing out of order in cleanup functions and forgetting to release on error paths. Signed-off-by: Andrew Davis <afd@ti.com> Link: https://lore.kernel.org/r/20240123163653.384385-17-afd@ti.com Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2024-01-27power: supply: wm831x: Use devm_power_supply_register() helperGravatar Andrew Davis 1-15/+9
Use the device lifecycle managed register function. This helps prevent mistakes like unregistering out of order in cleanup functions and forgetting to unregister on error paths. Signed-off-by: Andrew Davis <afd@ti.com> Link: https://lore.kernel.org/r/20240123163653.384385-15-afd@ti.com Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2024-01-27power: supply: wm831x: Use devm_power_supply_register() helperGravatar Andrew Davis 1-11/+2
Use the device lifecycle managed register function. This helps prevent mistakes like unregistering out of order in cleanup functions and forgetting to unregister on error paths. Signed-off-by: Andrew Davis <afd@ti.com> Link: https://lore.kernel.org/r/20240123163653.384385-14-afd@ti.com Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2024-01-27power: supply: tps65090: Use devm_power_supply_register() helperGravatar Andrew Davis 1-12/+6
Use the device lifecycle managed register function. This helps prevent mistakes like unregistering out of order in cleanup functions and forgetting to unregister on error paths. Signed-off-by: Andrew Davis <afd@ti.com> Link: https://lore.kernel.org/r/20240123163653.384385-13-afd@ti.com Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2024-01-27power: supply: rt5033: Use devm_power_supply_register() helperGravatar Andrew Davis 1-11/+3
Use the device lifecycle managed register function. This helps prevent mistakes like unregistering out of order in cleanup functions and forgetting to unregister on error paths. Signed-off-by: Andrew Davis <afd@ti.com> Link: https://lore.kernel.org/r/20240123163653.384385-12-afd@ti.com Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>