summaryrefslogtreecommitdiffstats
path: root/drivers/power
Commit message (Collapse)AuthorAgeFilesLines
...
| * | power: supply: ab8500: Drop BATCTRL thermal modeLinus Walleij2022-02-113-257/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The BATCTRL mode reads the temperature of the battery by enabling a certain probing current (7-20 mA) and then measure the voltage of the NTC mounted inside the battery. None of the AB8500 product or the reference designs use this mode. What we use is the so-called BATTEMP mode which enables an internal 230 kOhm pull-up to 1.8 V to the external NTC on pin BatTemp (N16) and then measures the voltage over the NTC using the ADC: 1.8V (VTVOUT) | [ ] 230 kOhm | BatTemp +---------------- ADC Pin N16 | _ |/ [/] NTC _/| | GND Cut out the BATCTRL code to clear the forest and stop maintaining code we can never test. The current inducing method is still used to probe for the battery type using the internal BTI (battery type indicator) on the BatCtrl (C3) pin in a separate code path. Signed-off-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
| * | power: supply: core: Use device_property_string_array_count()Andy Shevchenko2022-02-111-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | Use device_property_string_array_count() to get number of strings in a string array property. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
| * | power: supply: rt9455: Don't pass an error code in remove callbackUwe Kleine-König2022-02-111-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When ret is not zero there were already one or two error messages emitted about a problem (because rt9455_register_reset() emits a message in most cases then). Passing on that error code to the i2c core only results in another error message. Suppress that by returning zero unconditionally. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
| * | power: supply: core: Simplify hwmon memory allocationChristophe JAILLET2022-02-111-12/+3
| | | | | | | | | | | | | | | | | | | | | Use devm_bitmap_zalloc() instead of hand writing it. Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
| * | power: supply: ug3105_battery: Add driver for uPI uG3105 battery monitorHans de Goede2022-02-113-0/+502
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add a new battery driver for the uPI uG3105 battery monitor. Note the uG3105 is not a full-featured autonomous fuel-gauge. Instead it is expected to be use in combination with some always on microcontroller reading its coulomb-counter before it can wrap (must be read every 400 seconds!). Since Linux does not monitor coulomb-counter changes while the device is off or suspended, the coulomb counter is not used atm. So far this driver is only used on x86/ACPI (non devicetree) devs (also note there is no of_match table). Therefor there is no devicetree bindings documentation for this driver's "upisemi,rsns-microohm" property since this is not used in actual devicetree files and the dt bindings maintainers have requested properties with no actual dt users to _not_ be added to the dt bindings. The property's name has been chosen so that it should not need to be changed if/when devicetree enumeration support gets added later, as it mirrors "maxim,rsns-microohm" from the "maxim,max17042" bindings. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
| * | power: supply: bq24190_charger: Disallow ccc_ireg and cvc_vreg to be higher ↵Hans de Goede2022-02-111-2/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | then the fwnode values If the fwnode data as parsed by power_supply_get_battery_info() provides max values for ccc_ireg and cvc_vreg then do not allow the user to later set these to higher values then those specified by the firmware, otherwise the battery might get damaged. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
| * | power: supply: bq24190_charger: Program charger with fwnode supplied ↵Hans de Goede2022-02-111-2/+49
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ccc_ireg and cvc_vreg So far the bq24190_charger driver has been relying on either the chips default constant_charge_current_max_ua and constant_charge_voltage_max_uv values, or on the BIOS or bootloader to program these for us. This does not happen on all boards, causing e.g. the wrong (too low) values to be used on Lenovo Yoga Tablet 2 830F/L and 1050F/L tablets. If power_supply_get_battery_info() provides us with values for these settings, then program the charger accordingly. And if the user later overrides these values then save the user-values so that these will be restored after a suspend/resume. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
| * | power: supply: bq24190_charger: Store ichg-max and vreg-max in bq24190_dev_infoHans de Goede2022-02-111-21/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Store ichg-max and vreg-max in bq24190_dev_info once from bq24190_get_config() and drop the bq24190_charger_get_current_max() and bq24190_charger_get_voltage_max() helpers. This is a preparation patch for honoring the constant_charge_current_max_ua and constant_charge_voltage_max_uv values from power_supply_get_battery_info(). Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
| * | power: supply: bq24190_charger: Always call power_supply_get_battery_info()Hans de Goede2022-02-111-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | power_supply_get_battery_info() now also supports getting battery_info on boards not using dt/of. Remove the of_node check. If neither of nor other battery-info is present the function will fail making this change a no-op in that case. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
| * | power: supply: bq24190_charger: Turn off 5V boost regulator on shutdownHans de Goede2022-02-111-5/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Turn off the 5V boost regulator on shutdown, there are 3 reasons for doing this: 1. It drains he battery if left on 2. If left on the device will not charge when plugged into a charger 3. If left on and the powered peripheral attached to a Type-C port is removed before the next boot, then the Type-C port-controller will see VBus being present while nothing is attached confusing the TCPM state-machine. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
| * | power: supply: core: Add support for generic fwnodes to ↵Hans de Goede2022-02-111-10/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | power_supply_get_battery_info() Add support to power_supply_get_battery_info() to read the properties from other fwnode types such as swnodes added by platform code on x86 devices. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
| * | power: supply: core: Use fwnode_property_*() in power_supply_get_battery_info()Hans de Goede2022-02-111-27/+42
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Switch power_supply_get_battery_info() over to use the generic fwnode_property_*() property read functions. This is a preparation patch for adding support for reading properties from other fwnode types such as swnode properties added by platform code on x86 devices. Note the parsing of the 2d matrix "ocv-capacity-table-%d" and "resistance-temp-table" properties is not converted since this depends on the raw of_get_property() accessor function of which there is no fwnode_property_*() equivalent AFAICT. This means that these properties will not be supported in swnodes for now. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
| * | power: supply: axp288_fuel_gauge: Fix spelling mistake "resisitor" -> "resistor"Colin Ian King2022-02-021-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | There is a spelling mistake in a MODULE_PARM_DESC description. Fix it. Signed-off-by: Colin Ian King <colin.i.king@gmail.com> Acked-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
| * | Merge tag 'psy-extcon-i2c-mfd-for-v5.18-signed' into psy-nextSebastian Reichel2022-02-013-105/+360
| |\ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Immutable branch between power-supply, mfd, i2c and extcon for for 5.18 This immutable branch fixes the charger setup on Xiaomi Mi Pad 2 and Lenovo Yogabook, which requires updates to multiple drivers throughout the tree. Signed-off-by: Sebastian Reichel <sre@kernel.org>
| | * | power: supply: bq25890: Use the devm_regmap_field_bulk_alloc() helperHans de Goede2022-02-011-10/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Use the devm_regmap_field_bulk_alloc() helper function instead of open-coding this ourselves. Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
| | * | power: supply: bq25890: Support higher charging voltages through Pump ↵Yauhen Kharuzhy2022-02-011-8/+84
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Express+ protocol Add a "linux,pump-express-vbus-max" property which indicates if the Pump Express+ protocol should be used to increase the charging protocol. If this new property is set and a DCP charger is detected then request a higher charging voltage through the Pump Express+ protocol. So far this new property is only used on x86/ACPI (non devicetree) devs, IOW it is not used in actual devicetree files. The devicetree-bindings maintainers have requested properties like these to not be added to the devicetree-bindings, so the new property is deliberately not added to the existing devicetree-bindings. Changes by Hans de Goede: - Port to my bq25890 patch-series + various cleanups - Make behavior configurable through a new "linux,pump-express-vbus-max" device-property - Sleep 1 second before re-checking the Vbus voltage after requesting it to be raised, to ensure that the ADC has time to sampled the new Vbus - Add VBUSV bq25890_tables[] entry and use it in bq25890_get_vbus_voltage() - Tweak commit message Signed-off-by: Yauhen Kharuzhy <jekhor@gmail.com> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Co-developed-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
| | * | power: supply: bq25890: On the bq25892 set the IINLIM based on external ↵Hans de Goede2022-02-011-0/+33
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | charger detection The bq25892 does not have builtin charger-type detection like the bq25980, there might be some external charger detection capability, which will be modelled as a power_supply class-device supplying the bq25892. Use the usb_type property value from the supplier psy-device to set the input-current-limit (when available). Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
| | * | power: supply: bq25890: Add support for registering the Vbus boost converter ↵Hans de Goede2022-02-011-0/+80
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | as a regulator The bq25890_charger code supports enabling/disabling the boost converter based on usb-phy notifications. But the usb-phy framework is not used on all boards/platforms. At support for registering the Vbus boost converter as a standard regulator when there is no usb-phy on the board. Also add support for providing regulator_init_data through platform_data for use on boards where device-tree is not used and the platform code must thus provide the regulator_init_data. Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com> Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
| | * | power: supply: bq25890: Add bq25890_set_otg_cfg() helperHans de Goede2022-02-011-13/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add a bq25890_set_otg_cfg() helper function, this is a preparation patch for adding regulator support. Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
| | * | power: supply: bq25890: Drop dev->platform_data == NULL checkHans de Goede2022-02-011-10/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Drop the "if (!dev->platform_data)" check, this seems to be an attempt for allowing loading the driver on devices without devicetree stemming from the initial commit of the driver (with the presumed intention being the "return -ENODEV" else branch getting replaced with something else). With the new "linux,skip-init" and "linux,read-back-settings" properties the driver can actually supports devices without devicetree and this check no longer makes sense. While at it, also switch to dev_err_probe(), which is already used in various other places in the driver. Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com> Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
| | * | power: supply: bq25890: Enable charging on boards where we skip resetHans de Goede2022-02-011-0/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | On boards where the "linux,skip-reset" boolean property is set we don't reset the charger; and on some boards where the fw takes care of initalizition F_CHG_CFG is set to 0 before handing control over to the OS. Explicitly set F_CHG_CFG to 1 on boards where we don't reset the charger, so that charging is always enabled on these boards, like it is always enabled on boards where we do reset the charger. Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
| | * | power: supply: bq25890: Add support to read back the settings from the chipHans de Goede2022-02-011-1/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | On most x86/ACPI devices there is no devicetree to supply the necessary init-data. Instead the firmware already fully initializes the bq25890 charger at boot. To support this, add support for reading back the settings from the chip through a new "linux,read-back-settings" boolean. So far this new property is only used on x86/ACPI (non devicetree) devs, IOW it is not used in actual devicetree files. The devicetree-bindings maintainers have requested properties like these to not be added to the devicetree-bindings, so the new property is deliberately not added to the existing devicetree-bindings. Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
| | * | power: supply: bq25890: Add support to skip reset at probe() / remove()Hans de Goede2022-02-011-6/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | On most x86/ACPI devices the firmware already fully initializes the bq25890 charger at boot, in this case it is best to not reset it at probe() time. At support for a new "linux,skip-reset" boolean property to support this. So far this new property is only used on x86/ACPI (non devicetree) devs, IOW it is not used in actual devicetree files. The devicetree-bindings maintainers have requested properties like these to not be added to the devicetree-bindings, so the new property is deliberately not added to the existing devicetree-bindings. Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
| | * | power: supply: bq25890: Add a bq25890_rw_init_data() helperHans de Goede2022-02-011-22/+40
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | On most x86/ACPI devices there is no devicetree to supply the necessary init-data. Instead the firmware already fully initializes the bq25890 charger at boot. Factor out the current code to write all the init_data from devicetree into a new bq25890_rw_init_data() helper which can both write the data to the charger (the current behavior) as well as read it back from the charger into the init_data struct. This is a preparation patch for adding support for x86/ACPI device's where the init_data must be read back from the bq25890 charger. Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
| | * | power: supply: bq25890: Reduce reported CONSTANT_CHARGE_CURRENT_MAX for low ↵Yauhen Kharuzhy2022-02-011-3/+26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | temperatures Take into account possible current reduction due to low-temperature when reading POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT_MAX. As described in the datasheet in cool (0-20° Celcius) conditions the current limit is decreased to 20% or 50% of ICHG field value depended on JEITA_ISET field. Also add NTC_FAULT field value to the debug message in bq25890_get_chip_state(). Changed by Hans de Goede: - Fix reading F_CHG_FAULT instead of F_NTC_FIELD for state->ntc_fault - Only read JEITA_ISET field if necessary - Tweak commit message a bit Signed-off-by: Yauhen Kharuzhy <jekhor@gmail.com> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Co-developed-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
| | * | power: supply: bq25890: Rename IILIM field to IINLIMYauhen Kharuzhy2022-02-011-6/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Rename the Input Current Limit field in the REG00 from IILIM to IINLIM accordingly with the bq2589x datasheet. This is just cosmetical change to reduce confusion. Signed-off-by: Yauhen Kharuzhy <jekhor@gmail.com> Reviewed-by: Hans de Goede <hdegoede@redhat.com> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
| | * | power: supply: core: Refactor ↵Hans de Goede2022-02-012-28/+41
| | |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | power_supply_set_input_current_limit_from_supplier() Some (USB) charger ICs have variants with USB D+ and D- pins to do their own builtin charger-type detection, like e.g. the bq24190 and bq25890 and also variants which lack this functionality, e.g. the bq24192 and bq25892. In case the charger-type; and thus the input-current-limit detection is done outside the charger IC then we need some way to communicate this to the charger IC. In the past extcon was used for this, but if the external detection does e.g. full USB PD negotiation then the extcon cable-types do not convey enough information. For these setups it was decided to model the external charging "brick" and the parameters negotiated with it as a power_supply class-device itself; and power_supply_set_input_current_limit_from_supplier() was introduced to allow drivers to get the input-current-limit this way. But in some cases psy drivers may want to know other properties, e.g. the bq25892 can do "quick-charge" negotiation by pulsing its current draw, but this should only be done if the usb_type psy-property of its supplier is set to DCP (and device-properties indicate the board allows higher voltages). Instead of adding extra helper functions for each property which a psy-driver wants to query from its supplier, refactor power_supply_set_input_current_limit_from_supplier() into a more generic power_supply_get_property_from_supplier() function. Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
| * | power: supply: axp288_fuel_gauge: Add a no_current_sense_res module_paramHans de Goede2022-02-011-9/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Some boards with an AXP288 fuel-gauge appear to have a broken (approx. 2 milli-ohm instead of 10) current sense resistor. This makes the coulomb-counter part of the fuel-gauge useless, but the OCV based capacity reporting is still working. Add a no_current_sense_res module_param to disable use of the coulomb-counter using parts of the fuel-gauge to allow users to work around this. Note this is a module parameter and not done through DMI quirks, since this seems to be a defect on some boards, not something which all boards of the same model share. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
| * | power: supply: axp288_fuel_gauge: Take lock before updating the valid flagHans de Goede2022-02-011-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | The valid flag is protected by the mutex, so code clearing it should take the mutex before cleating the valid flag. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
| * | power: supply: axp288_fuel_gauge: Refactor IRQ initializationHans de Goede2022-02-011-49/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Refactor the IRQ initialization code: * Move the looking up of the vIRQs to the beginning of probe(), failing probe early if this fails * Do the actual requesting of IRQs inline in probe() and properly abort probe() on errors * Use devm_request_threaded_irq(), completing the conversion of probe() to only use devm managed resources and remove the remove() driver function. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
| * | power: supply: axp288_fuel_gauge: Use devm_power_supply_register()Hans de Goede2022-02-011-3/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Use devm_power_supply_register() instead of power_supply_register(). Note as a side-effect this changes the release order so that now first the IRQs get free-ed and then the psy gets unregistered. This is actually a bug-fix since this fixes the IRQ possibly trying to reference the unregistered psy. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
| * | power: supply: axp288_fuel_gauge: Use devm_add_action_or_reset() for iio ↵Hans de Goede2022-02-011-14/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | chan release An existing comment already mentions we: "cannot use devm_iio_channel_get because x86 systems lack the device<->channel maps which iio_channel_get will try to use when passed a non NULL device pointer". Work around this by registering a devm action to free the iio-channels. This is a step on the way to fully converting the probe() function to only use devm managed resources. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
| * | power: supply: axp288_fuel_gauge: Add axp288_fuel_gauge_read_initial_regs()Hans de Goede2022-02-011-53/+56
| | | | | | | | | | | | | | | | | | | | | | | | | | | Refactor probe a bit, introducing a new axp288_fuel_gauge_read_initial_regs() helper. This replaces a whole bunch of gotos and removes the unblock_punit_i2c_access label. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
| * | power: supply: axp288_fuel_gauge: Add dev helper var to probe()Hans de Goede2022-02-011-6/+6
| | | | | | | | | | | | | | | | | | | | | | | | Add a dev local variable to probe() as shortcut for &pdev->dev, this is a preparation change for making more use of devm managed resources. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
| * | power: supply: cpcap-battery: Add battery type auto detection for mapphone ↵Carl Philipp Klemm2022-02-011-26/+92
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | devices This allows cpcap-battery to detect whitch battery is inserted, HW4X or BW8X for xt875 and EB41 for xt894 by examining the battery nvmem. If no known battery is detected sane defaults are used. Signed-off-by: Carl Philipp Klemm <philipp@uvos.xyz> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
| * | power: supply: axp20x_battery: properly report current when dischargingEvgeny Boger2022-02-011-7/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | As stated in [1], negative current values are used for discharging batteries. AXP PMICs internally have two different ADC channels for shunt current measurement: one used during charging and one during discharging. The values reported by these ADCs are unsigned. While the driver properly selects ADC channel to get the data from, it doesn't apply negative sign when reporting discharging current. [1] Documentation/ABI/testing/sysfs-class-power Signed-off-by: Evgeny Boger <boger@wirenboard.com> Acked-by: Chen-Yu Tsai <wens@csie.org> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
| * | power: reset: gemini-poweroff: Fix IRQ check in gemini_poweroff_probeMiaoqian Lin2022-02-011-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | platform_get_irq() returns negative error number instead 0 on failure. And the doc of platform_get_irq() provides a usage example: int irq = platform_get_irq(pdev, 0); if (irq < 0) return irq; Fix the check of return value to catch errors correctly. Fixes: f7a388d6cd1c ("power: reset: Add a driver for the Gemini poweroff") Signed-off-by: Miaoqian Lin <linmq006@gmail.com> Reviewed-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
| * | power: supply: mp2629_charger: use platform_get_irq()Sergey Shtylyov2022-02-011-4/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | Calling platform_get_irq_optional() doesn't make sense if you then bail out on any error it returns. Switch to calling platform_get_irq() instead and remove dev_err() call as platform_get_irq() already curses loudly on error. Signed-off-by: Sergey Shtylyov <s.shtylyov@omp.ru> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
| * | power: supply: cros_usbpd: Use struct_size() helper in kzalloc()Gustavo A. R. Silva2022-01-311-1/+1
| |/ | | | | | | | | | | | | | | | | | | | | | | | | Make use of the struct_size() helper instead of an open-coded version, in order to avoid any potential type mistakes or integer overflows that, in the worst scenario, could lead to heap overflows. Also, address the following sparse warnings: drivers/power/supply/cros_usbpd-charger.c:107:23: warning: using sizeof on a flexible structure Link: https://github.com/KSPP/linux/issues/174 Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
* | power: supply: bq256xx: Handle OOM correctlyLinus Walleij2022-02-111-0/+3
| | | | | | | | | | | | | | | | | | | | | | Since we now return a pointer to an allocated object we need to account for memory allocation failure in a separate error path. Fixes: 25fd330370ac ("power: supply_core: Pass pointer to battery info") Reported-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
* | power: supply: core: fix application of sizeof to pointerYang Li2022-02-011-1/+1
|/ | | | | | | | | | | | The coccinelle check report: ./drivers/power/supply/cw2015_battery.c:692:12-18: ERROR: application of sizeof to pointer Reported-by: Abaci Robot <abaci@linux.alibaba.com> Fixes: 25fd330370ac ("power: supply_core: Pass pointer to battery info") Signed-off-by: Yang Li <yang.lee@linux.alibaba.com> Reviewed-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
* Merge tag 'platform-drivers-x86-v5.17-1' of ↵Linus Torvalds2022-01-111-0/+56
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | git://git.kernel.org/pub/scm/linux/kernel/git/pdx86/platform-drivers-x86 Pull x86 platform driver updates from Hans de Goede: "Highlights: New drivers: - asus-tf103c-dock - intel_crystal_cove_charger - lenovo-yogabook-wmi - simatic-ipc platform-code + led driver + watchdog driver - x86-android-tablets (kernel module to workaround DSDT bugs on these) amd-pmc: - bug-fixes - smar trace buffer support asus-wmi: - support for custom fan curves int3472 (camera info ACPI object for Intel IPU3/SkyCam cameras): - ACPI core + int3472 changes to delay enumeration of camera sensor I2C clients until the PMIC for the sensor has been fully probed - Add support for board data (DSDT info is incomplete) for setting up the tps68470 PMIC used on some boards with these cameras - Add board data for the Microsoft Surface Go (original, v2 and v3) thinkpad_acpi: - various cleanups - support for forced battery discharging (for battery calibration) - support to inhibit battery charging - this includes power_supply core changes to add new APIs for this think_lmi: - enhanced BIOS password support various other small fixes and hardware-id additions" * tag 'platform-drivers-x86-v5.17-1' of git://git.kernel.org/pub/scm/linux/kernel/git/pdx86/platform-drivers-x86: (78 commits) power: supply: Provide stubs for charge_behaviour helpers platform/x86: x86-android-tablets: Fix GPIO lookup leak on error-exit platform/x86: int3472: Add board data for Surface Go 3 platform/x86: Add Asus TF103C dock driver platform/x86: x86-android-tablets: Add TM800A550L data platform/x86: x86-android-tablets: Add Asus MeMO Pad 7 ME176C data platform/x86: x86-android-tablets: Add Asus TF103C data platform/x86: x86-android-tablets: Add support for preloading modules platform/x86: x86-android-tablets: Add support for registering GPIO lookup tables platform/x86: x86-android-tablets: Add support for instantiating serdevs platform/x86: x86-android-tablets: Add support for instantiating platform-devs platform/x86: x86-android-tablets: Add support for PMIC interrupts platform/x86: x86-android-tablets: Don't return -EPROBE_DEFER from a non probe() function platform/x86: touchscreen_dmi: Remove the Glavey TM800A550L entry platform/x86: touchscreen_dmi: Enable pen support on the Chuwi Hi10 Plus and Pro platform/x86: touchscreen_dmi: Correct min/max values for Chuwi Hi10 Pro (CWI529) tablet platform/x86: Add intel_crystal_cove_charger driver power: supply: fix charge_behaviour attribute initialization platform/x86: intel-uncore-frequency: use default_groups in kobj_type x86/platform/uv: use default_groups in kobj_type ...
| * power: supply: fix charge_behaviour attribute initializationThomas Weißschuh2022-01-051-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | All properties have to be added to power_supply_attrs which was missed before. Fixes: 1b0b6cc8030d ("power: supply: add charge_behaviour attributes") Reported-by: Heiner Kallweit <hkallweit1@gmail.com> Suggested-by: Heiner Kallweit <hkallweit1@gmail.com> Signed-off-by: Thomas Weißschuh <linux@weissschuh.net> Link: https://lore.kernel.org/r/20220105064239.2689-1-linux@weissschuh.net Signed-off-by: Hans de Goede <hdegoede@redhat.com>
| * power: supply: add helpers for charge_behaviour sysfsThomas Weißschuh2021-12-211-0/+55
| | | | | | | | | | | | | | | | | | | | | | | | These helper functions can be used by drivers to implement their own sysfs-attributes. This is useful for ACPI-drivers extending the default ACPI-battery with their own charge_behaviour attributes. Signed-off-by: Thomas Weißschuh <linux@weissschuh.net> Acked-by: Sebastian Reichel <sebastian.reichel@collabora.com> Link: https://lore.kernel.org/r/20211123232704.25394-3-linux@weissschuh.net Signed-off-by: Hans de Goede <hdegoede@redhat.com>
* | Merge tag 'for-v5.17' of ↵Linus Torvalds2022-01-1127-1321/+1540
|\ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | git://git.kernel.org/pub/scm/linux/kernel/git/sre/linux-power-supply Pull power supply and reset updates from Sebastian Reichel: "Power-supply core: - introduce "No Battery" health status - use library interpolation - add power_supply_battery_info documentation - migrate power_supply_battery_info to be fully heap allocated making it more obvious that it needs to be free'd manually Drivers: - max77976-charger: new driver - qcom-smbb: add pm8226 charger support - bq25890-charger: support battery temperature readings - ab8500: continue migrating towards using standard core APIs" * tag 'for-v5.17' of git://git.kernel.org/pub/scm/linux/kernel/git/sre/linux-power-supply: (28 commits) power: supply_core: Pass pointer to battery info power: supply: ab8500: Fix the error handling path of ab8500_charger_probe() power: reset: mt6397: Check for null res pointer power: bq25890: add POWER_SUPPLY_PROP_TEMP power: supply: qcom_smbb: support pm8226 dt-bindings: power: supply: pm8941-charger: add pm8226 power: supply: ab8500: Standardize capacity lookup power: supply: ab8500: Standardize temp res lookup power: supply: ab8500: Standardize CV voltage power: supply: ab8500: Standardize CC current power: supply: ab8500: Make recharge capacity a constant power: supply: ab8500: Standardize termination current power: supply: ab8500: Standardize internal resistance power: supply: ab8500_fg: Init battery data in bind() power: supply: ab8500: Standardize voltages power: supply: ab8500: Standardize technology power: supply: ab8500: Standardize design capacity power: supply: ab8500: Use only one battery type power: supply: ab8500: Drop unused battery types power: supply: ab8500: Standardize operating temperature ...
| * | power: supply_core: Pass pointer to battery infoLinus Walleij2022-01-0318-126/+156
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The function to retrieve battery info (from the device tree) assumes we have a static info struct that gets populated by calling into power_supply_get_battery_info(). This is awkward since I want to support tables of static battery info by just assigning a pointer to all info based on e.g. a compatible value in the device tree. We also have a mixture of static and dynamically allocated variables here. Bite the bullet and let power_supply_get_battery_info() allocate also the memory used for the very top level struct power_supply_battery_info container. Pass pointers around and lifecycle this with the psy device just like the stuff we allocate inside it. Change all current users over. As part of the change, initializers need to be added to some previously uninitialized fields in struct power_supply_battery_info. Reviewed-By: Matti Vaittinen <matti.vaittinen@fi.rohmeurope.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
| * | power: supply: ab8500: Fix the error handling path of ab8500_charger_probe()Christophe JAILLET2022-01-031-2/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Since the commit below, ab8500_bm_of_remove() needs to be called after a successful ab8500_bm_of_probe() call. This commit has only updated the remove function. Fix the error handling path of the probe the same way. Fixes: 6252c706cdb0 ("power: supply: ab8500: Standardize operating temperature") Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr> Reviewed-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
| * | power: reset: mt6397: Check for null res pointerJiasheng Jiang2022-01-031-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The return value of platform_get_resource() needs to be checked. To avoid use of error pointer in case that there is no suitable resource. Fixes: d28c74c10751 ("power: reset: add driver for mt6323 poweroff") Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
| * | power: bq25890: add POWER_SUPPLY_PROP_TEMPAngus Ainslie2021-12-021-1/+36
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add the POWER_SUPPLY_PROP_TEMP and a NTC 10K percent VREGN to degrees LUT. Make sure that a conversion is forced when the power supply is offline so the temperature is valid. Signed-off-by: Angus Ainslie <angus@akkea.ca> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
| * | power: supply: qcom_smbb: support pm8226Luca Weiss2021-11-301-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | PM8226 (used in MSM8226) has v1 smbb hardware and works fine with the current driver. Signed-off-by: Luca Weiss <luca@z3ntu.xyz> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>