Commit Graph

3142 Commits

Author SHA1 Message Date
Linus Torvalds
fd71b9a07b power supply and reset changes for the 6.11 series
* power-supply core
    - new charging_orange_full_green RGB LED trigger
    - simplify and cleanup power-supply LED trigger code
    - expose power information via hwmon compatibility layer
  * new hardware support
    - enable battery support for Qualcomm Snapdragon X Elite
    - new battery driver for Maxim MAX17201/MAX17205
    - new battery driver for Lenovo Yoga C630 laptop (custom EC)
  * cleanup 'struct i2c_device_id' initializations
  * misc. small battery driver cleanups and fixes
 -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCgAdFiEE72YNB0Y/i3JqeVQT2O7X88g7+poFAmadpdQACgkQ2O7X88g7
 +poOIBAAm8B28rdJc35M0qj4akFp67z84wxGs0yR3KmwwUyIv5bHMZKXuSgOdMJ7
 bVA/W5Lvzi/Mp6bF5lt4EbFt3QGIEG2odWMWcoc/PTdKaPYC7CcDBVGCZr7hQFJS
 2THzaUuLVDQzVwBc62YcFh7AB+xQmJ/SaX+Ci2k//vFyQJ1EfBiOkoq6MjJXCPcT
 hz21hXCQjGirNSsV4gxK1EwefrRomj4MVCHCf/E5i2tM2lNtO+HPu28UznJYEh9S
 NB+M4Z0EADnfPWoBmB3emonYYlGlYC34kYb6nqcn6sUm9usU9JUMeZBT1yOstUMd
 3p5V+uvUFQ9MGqXUgN8Qd5/ZfszCZzX2TaHDnWWRF4g7KTdSpcXOXrLW4gEO3TFf
 BtUU0WvZLiwXjMPrtvdTIPJCFTStfLcIAtWEyUhdCLouR2nJsAIYyfMm5OOyktqK
 KGeRaJhBp8c2bJTU1Xxj4FkO07z0iSY2EGDFCuEe4sBCN5EMA/ClwN/35P7Fwv30
 0sRjzwS/gRkT1IiLRjqu8We3dVUxclkgsXhZ/5UuOzRqTzV7VH0xYdgn6iCOs0nz
 RSLFo37DqjIYbAJGcv9E6/7TSy+lB1RVHQL1DsQVKOMTf4NW5REfSoMzbjPClj8u
 qYTVoONCXLQEzo8oxuIly9m6eeExA3+2ulvDq00FuDb+pCVZ1ig=
 =+h6p
 -----END PGP SIGNATURE-----

Merge tag 'for-v6.11' of 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:
   - new charging_orange_full_green RGB LED trigger
   - simplify and cleanup power-supply LED trigger code
   - expose power information via hwmon compatibility layer

  New hardware support:
   - enable battery support for Qualcomm Snapdragon X Elite
   - new battery driver for Maxim MAX17201/MAX17205
   - new battery driver for Lenovo Yoga C630 laptop (custom EC)

  Cleanups:
   - cleanup 'struct i2c_device_id' initializations
   - misc small battery driver cleanups and fixes"

* tag 'for-v6.11' of git://git.kernel.org/pub/scm/linux/kernel/git/sre/linux-power-supply:
  power: supply: sysfs: use power_supply_property_is_writeable()
  power: supply: qcom_battmgr: Enable battery support on x1e80100
  power: supply: add support for MAX1720x standalone fuel gauge
  dt-bindings: power: supply: add support for MAX17201/MAX17205 fuel gauge
  power: reset: piix4: add missing MODULE_DESCRIPTION() macro
  power: supply: samsung-sdi-battery: Constify struct power_supply_maintenance_charge_table
  power: supply: samsung-sdi-battery: Constify struct power_supply_vbat_ri_table
  power: supply: lenovo_yoga_c630_battery: add Lenovo C630 driver
  power: supply: ingenic: Fix some error handling paths in ingenic_battery_get_property()
  power: supply: ab8500: Clean some error messages
  power: supply: ab8500: Use iio_read_channel_processed_scale()
  power: supply: ab8500: Fix error handling when calling iio_read_channel_processed()
  power: supply: hwmon: Add support for power sensors
  power: supply: ab8500: remove unused struct 'inst_curr_result_list'
  power: supply: bd99954: remove unused struct 'battery_data'
  power: supply: leds: Add activate() callback to triggers
  power: supply: leds: Share trig pointer for online and charging_full
  power: supply: leds: Add power_supply_[un]register_led_trigger()
  power: supply: Drop explicit initialization of struct i2c_device_id::driver_data to 0
2024-07-23 09:38:27 -07:00
Linus Torvalds
9c67f9084a power sequencing fixes for v6.11-rc1
- fix an invalid pointer dereference in error path in pwrseq core
 - reduce the Kconfig noise from PCI pwrctl choices
 -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCgAdFiEEFp3rbAvDxGAT0sefEacuoBRx13IFAmaaMYkACgkQEacuoBRx
 13L0Uw/+JdFxMWwQYKwWs84rKaALFtH4+vKzdZlyonGtTCl8X4wr5JX/jqfjBPof
 kO8FIKTIofWiiYkL3A5hvZbfuG9aINzOwle5nYhlSyeR5JN/ZJwVOKzfkFF1vcgK
 XJdxBZjD8wIB/foouleLH1+DhQu5d9BuB+NsANCcVo4IqAupK618NEVwTqRmQEPf
 M4JdmzVTRSVVnKS9RQ8MbXotfUSAI7GuvSCd+xs5SdTlBcgNNTLx4PUWhcLsSY5t
 oJ1TCx4a7MrDaFxjt8IvtsfGl0F5+0GNljxvcgSC/bckTzP6WAJJnCf8EIPpq95z
 HPx+7fvyKoScZbup+s2HEbRsqLUDQYFyZ8BjbkLBVn0NZSeJngFyEb2+A4JM/zK2
 T2gGQk1Xe9HRwsWwi6Gd5wsL6kcknWdedh1B5m5zss2nIGXxO6Vw0Gz7U1dluS/P
 x/Olg2Le4oOahyFnsY4byG9hpO2898m/QHs7NMeCDZA3BEdXP2/+eVlASL6JZ2hl
 vRU8s6eheCBaI2iAUPF9Lc9+qtY4ry7b3DqCHDj11xxq+i4IwYErxs6ClsgpPBWZ
 l/VEPOFJYzFi1Y448uzn5vNPjPE7AsKn2Fl5ZERl7wTi4x8ZlJpVKiA3Cj3OPW1A
 hsuEOMJIVyZFEimexoIWK9sky9tY3mHsdhiE/AsF43Bj3aICTQE=
 =I1ot
 -----END PGP SIGNATURE-----

Merge tag 'pwrseq-fixes-for-v6.11-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/brgl/linux

Pull power sequencing fixes from Bartosz Golaszewski:
 "There's one fix for an invalid pointer dereference in error path
  reported by smatch and two patches that address the noisy config
  choices you reported earlier this week.

  Summary:

   - fix an invalid pointer dereference in error path in pwrseq core

   - reduce the Kconfig noise from PCI pwrctl choices"

* tag 'pwrseq-fixes-for-v6.11-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/brgl/linux:
  arm64: qcom: don't select HAVE_PWRCTL when PCI=n
  Kconfig: reduce the amount of power sequencing noise
  power: sequencing: fix an invalid pointer dereference in error path
2024-07-19 14:31:18 -07:00
Linus Torvalds
fea17683c4 - Core Frameworks
- Add new Trigger for Input Events
    - Add new led_mc_set_brightness() call to adapt colour/brightness for mutli-colour LEDs
    - Add new lled_mc_trigger_event() call to call the above based on given trigger conditions
    - Add new led_get_color_name() call, a wrapper around the existing led_colors[] array
    - Add a new flag to avoid automatic renaming of LED devices
 
  - New Drivers
    - Add support for Silergy SY7802 Flash LED Controller
    - Add support for Texas Instruments LP5569 LED Controller
    - Add support for ChromeOS EC LED Controller
 
  - New Device Support
    - Add support for KTD202{6,7} to Kinetic KTD2026/7 LEDs
 
  - Fix-ups
    - Replace ACPI/DT firmware helpers with agnostic variants
    - Make use of resource managed devm_* API calls
    - Device Tree binding adaptions/conversions/creation
    - Constify/staticise applicable data structures
    - Trivial; spelling, whitespace, coding-style adaptions
    - Drop i2c_device_id::driver_data where the value is unused
    - Utilise centrally provided helpers and macros to aid simplicity/duplication
    - Use generic platform device properties instead of OF/ACPI specific ones
    - Consolidate/de-duplicate various functionality
    - Remove superfluous/duplicated/unused sections
    - Make use of the new *_scoped() guard APIs
    - Improve/simplify error handling
 
  - Bug Fixes
    - Flush pending brightness changes before activating the trigger
    - Repair incorrect device naming preventing matches
    - Prevent memory leaks by correctly free resources during error handling routines
    - Repair locking issue causing circular dependency splats and lock-ups
    - Unregister sysfs entries before deactivating triggers to prevent use-after issues
    - Supply a bunch of MODULE_DESCRIPTIONs to silence modpost warnings
    - Use correct return codes expected by the callers
    - Omit set_brightness() error message for a LEDs that support only HW triggers
 -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCgAdFiEEdrbJNaO+IJqU8IdIUa+KL4f8d2EFAmaWgMEACgkQUa+KL4f8
 d2Glng//Sw3+ev7IFn4PmNfMHtKeWlJEerT8kyF0GdK05zn7ImlydkSVW5RvHN8B
 J2A8cfXXkhggYoG2i4zjs1wtfPDXP9iJMhVaRnPPuWgYJpPrhUFSSkJKiauSKyGN
 Tp3Vn6QaHM5Gs/THUidcTV0+USE6j9+DXdLjLASAi2YXqoGCC3KWcq4Hb6NdGM/Q
 ajEuGnrO1HEF0dOaEgkYuNIXcADHzeeQlU0Y96bGv7qnUBw7LAIpH+AC1d49jcXS
 gIJNxmtmn0QqCK0/lS74DmR9r2quofeYer6G5WDJVv72R8KIljFN16AGFLdC8ID/
 3B4JnjQKpEyn344gmvqzx23dp3jqvCupgDcojR6RY7yIZTXSjg0R0OocKYQlDnNY
 LoNZqZ9J2nNDWNlx7r7PXuIAm7Bb9kdY0/PWgXOwWsEb19DcxyAHE3+xGeyQF6f5
 /s1bGZxQyfBnDZm8+XiJ6KTsiZ1t0MljG9y7xil6vtzJIJTynao9qzZipcrx7UuT
 3UyoGa/Z4o95OkQye9n6tKGJJDKLJIZL7x4pGOW3HeHgfvJ1koyHr8WwhmK4Zoh/
 xeHfHABuaMoulTsuGjtnRP4/UWOTEf2hh7FK1mSrpxSCvv+I9W4lTO9QBkXU8xuD
 1oCekcTYWOwKhxaFX4jjaGEHXIWYzXDjE7hqroLzj8Ifhqe9xrc=
 =0Kyu
 -----END PGP SIGNATURE-----

Merge tag 'leds-next-6.11' of git://git.kernel.org/pub/scm/linux/kernel/git/lee/leds

Pull LED updates from Lee Jones:
 "Core Frameworks:
   - New trigger for Input Events
   - New led_mc_set_brightness() call to adapt colour/brightness for
     mutli-colour LEDs
   - New lled_mc_trigger_event() call to call the above based on given
     trigger conditions
   - New led_get_color_name() call, a wrapper around the existing
     led_colors[] array
   - A new flag to avoid automatic renaming of LED devices

  New Drivers:
   - Silergy SY7802 Flash LED Controller
   - Texas Instruments LP5569 LED Controller
   - ChromeOS EC LED Controller

  New Device Support:
   - KTD202{6,7} support for Kinetic KTD2026/7 LEDs

  Fix-ups:
   - Replace ACPI/DT firmware helpers with agnostic variants
   - Make use of resource managed devm_* API calls
   - Device Tree binding adaptions/conversions/creation
   - Constify/staticise applicable data structures
   - Trivial; spelling, whitespace, coding-style adaptions
   - Drop i2c_device_id::driver_data where the value is unused
   - Utilise centrally provided helpers and macros to aid simplicity and
     avoid duplication
   - Use generic platform device properties instead of OF/ACPI specific
     ones
   - Consolidate/de-duplicate various functionality
   - Remove superfluous/duplicated/unused sections
   - Make use of the new *_scoped() guard APIs
   - Improve/simplify error handling

  Bug Fixes:
   - Flush pending brightness changes before activating the trigger
   - Repair incorrect device naming preventing matches
   - Prevent memory leaks by correctly free resources during error
     handling routines
   - Repair locking issue causing circular dependency splats and
     lock-ups
   - Unregister sysfs entries before deactivating triggers to prevent
     use-after issues
   - Supply a bunch of MODULE_DESCRIPTIONs to silence modpost warnings
   - Use correct return codes expected by the callers
   - Omit set_brightness() error message for a LEDs that support only HW
     triggers"

* tag 'leds-next-6.11' of git://git.kernel.org/pub/scm/linux/kernel/git/lee/leds: (65 commits)
  leds: leds-lp5569: Enable chip after chip configuration
  leds: leds-lp5569: Better handle enabling clock internal setting
  leds: leds-lp5569: Fix typo in driver name
  leds: flash: leds-qcom-flash: Test the correct variable in init
  leds: leds-lp55xx: Convert mutex lock/unlock to guard API
  leds: leds-lp5523: Convert to sysfs_emit API
  leds: leds-lp5569: Convert to sysfs_emit API
  Revert "leds: led-core: Fix refcount leak in of_led_get()"
  leds: leds-lp5569: Add support for Texas Instruments LP5569
  leds: leds-lp55xx: Drop deprecated defines
  leds: leds-lp55xx: Support ENGINE program up to 128 bytes
  leds: leds-lp55xx: Generalize sysfs master_fader
  leds: leds-lp55xx: Generalize sysfs engine_leds
  leds: leds-lp55xx: Generalize sysfs engine_load and engine_mode
  leds: leds-lp55xx: Generalize stop_engine function
  leds: leds-lp55xx: Generalize turn_off_channels function
  leds: leds-lp55xx: Generalize set_led_current function
  leds: leds-lp55xx: Generalize multicolor_brightness function
  leds: leds-lp55xx: Generalize led_brightness function
  leds: leds-lp55xx: Generalize firmware_loaded function
  ...
2024-07-17 17:51:30 -07:00
Bartosz Golaszewski
a19ce320c3 power: sequencing: fix an invalid pointer dereference in error path
We may end up calling pwrseq_target_free() on a partially initialized
target object whose unit is either NULL or an ERR_PTR(). Avoid
dereferencing invalid memory by adding an appropriate check to
pwrseq_target_free().

Fixes: 249ebf3f65 ("power: sequencing: implement the pwrseq core")
Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
Closes: https://lore.kernel.org/linux-pm/62a3531e-9927-40f8-b587-254a2dfa47ef@stanley.mountain/
Reviewed-by: Dan Carpenter <dan.carpenter@linaro.org>
Link: https://lore.kernel.org/r/20240712194004.241939-1-brgl@bgdev.pl
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
2024-07-17 16:30:50 +02:00
Linus Torvalds
e763c9ec71 pwrseq updates for v6.11-rc1
- add the pwrseq core framework
 - add the first power sequencing driver: pwrseq-qcom-wcn
 - add power control (pwrctl) changes to PCI core
 - add the first PCI pwrctl power sequencing driver
 -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCgAdFiEEFp3rbAvDxGAT0sefEacuoBRx13IFAmaQ72wACgkQEacuoBRx
 13K4fg//Qd8vxOH06/VSJRCwEvilUfYgDe/WiqTcBXL+8cK/3B0fUhfD83wgMnJn
 /yw2GgS5OjAvYe47nvM4T5M/XMpQ967XTED9cXxJWpBwcee+LZ6hsBGlPuSRunpo
 DQ4EuDh8wQ4j8Gw5pXj7dgtCN7zx4Idj+amh9i2ep+/7ZqT9UFqe294Tq9pX0X+a
 rhOrTooQo4uiwpSAh6k1db3o1VpVDhlx+m2CCQV6V5F3r7eiPv2tQE2B8GvlJlY/
 KjGECsbxKMch6dtKQumRnn3R07v1b3SlQOQOSP99blNv8dfDBOKS0dFPI4se2n2b
 FvKCtmfC9QD9MPvTFKGSIZTTLMInfGpniLyxMD3Ubu+l26AA7eLpv4BICExFo71c
 5gM/Xm8ypsrW7WadhAsl0mNS1CpbFZ2jNTBtuBrP5AFTMOvPqmYbN0VjRgYbX0Yw
 qXyu540iP8t8c0eTqRyrabhXFEehTso5cJGqtKvIARuoK1rF+wOPxTBU+RHjJWg/
 xp7ckCGP+VymcD1xNGpHPweHxwu0z2RMI4zYg2i6WOjWz6FY/V2x1Pf3PGlXF7pq
 yaTMqK5tiGizCF2/RNFGDFQ8re0qtZfh6/mNtT45GGbUBaYltPGQFdFhsaI6rwEi
 LMO7M387u0fPJlS0/ib8I+S5ZfKo65xjC/jQSuUL8WfQf85Ck9k=
 =rI5g
 -----END PGP SIGNATURE-----

Merge tag 'pwrseq-updates-for-v6.11-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/brgl/linux

Pull power sequencing updates from Bartosz Golaszewski:
 "This has been in development since last year's Linux Plumbers
  Conference and was inspired by the need to enable support upstream for
  Bluetooth/WLAN chips on Qualcomm platforms.

  The main problem we're fixing is powering up devices which are
  represented as separate objects in the kernel (binding to different
  drivers) but which share parts of the power-up sequence and thus need
  some kind of a mediator who knows the possible interactions and can
  assure they don't interfere with neither device's bring up. An example
  of such an inter-driver interaction is the WCN family of BT/WLAN chips
  from Qualcomm of which some models require the user to observe a
  certain delay between driving the bt-enable and wlan-enable GPIOs.

  This is not a new problem but up to this point all attempts at
  addressing it ended up hitting one wall or another and being dropped.
  The main obstacle was the fact that most these attempts tried to
  introduce the concept of a "power sequence" into the device-tree
  bindings which breaks the main DT rule: describe the hardware, not its
  behavior. The solution I proposed focuses on making the power
  sequencer drivers interpret the actual HW description flexibly. More
  details on that are in the linked cover letter.

  The second problem fixed here is powering up PCI devices before they
  are detected on the bus. This is achieved by creating special platform
  devices for device-tree nodes describing hard-wired PCI devices which
  bind to the so-called PCI power control drivers which enable required
  resources and trigger a bus rescan once the controlled device is up
  then setup the correct devlink hierarchy for power-management.

  By combining the two new frameworks we implemented the power
  sequencing PCI power control driver which is capable of powering up
  the WLAN modules of the QCom WCN family of chipsets.

  All this has spent a significant amount of time in linux-next and
  enabled WLAN/BT support on several Qualcomm platforms. To further
  prove that this is useful and needed: right after this was picked up
  into next, I was sent a series using the subsystem for a similar
  use-case on Amlogic platforms.

  This contains the core power sequencing framework, the first driver,
  PCI changes using the pwrseq library (blessed by Bjorn Helgaas) and
  some fixes that came later"

* tag 'pwrseq-updates-for-v6.11-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/brgl/linux:
  PCI/pwrctl: only call of_platform_populate() if CONFIG_OF is enabled
  power: sequencing: simplify returning pointer without cleanup
  PCI/pwrctl: Add a PCI power control driver for power sequenced devices
  PCI/pwrctl: Add PCI power control core code
  PCI/pwrctl: Create platform devices for child OF nodes of the port node
  PCI/pwrctl: Reuse the OF node for power controlled devices
  PCI: Hold the rescan mutex when scanning for the first time
  power: pwrseq: add a driver for the PMU module on the QCom WCN chipsets
  power: sequencing: implement the pwrseq core
2024-07-15 17:34:31 -07:00
Dan Carpenter
4baf1cc544 power: supply: cros_charge-control: Fix signedness bug in charge_behaviour_store()
The C standard is vague about the signedness of enums, but in this case
here, they are treated as unsigned so the error handling does not work.
Use an int type to fix this.

Fixes: c6ed48ef52 ("power: supply: add ChromeOS EC based charge control driver")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Acked-by: Thomas Weißschuh <linux@weissschuh.net>
Link: https://lore.kernel.org/r/ZoWKEs4mCqeLyTOB@stanley.mountain
Signed-off-by: Tzung-Bi Shih <tzungbi@kernel.org>
2024-07-05 01:51:33 +00:00
Thomas Weißschuh
be6299c6e5 power: supply: sysfs: use power_supply_property_is_writeable()
Instead of open-coding the helper use it directly.

Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
Link: https://lore.kernel.org/r/20240608-power-supply-extensions-v2-1-2dcd35b012ad@weissschuh.net
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2024-07-04 12:30:49 +02:00
Abel Vesa
29832adac0 power: supply: qcom_battmgr: Enable battery support on x1e80100
The x1e80100, being a compute platform, provides functionality for the
exact same power supplies as sc8280xp. Add the compatible and assign
the sc8280xp match data.

Signed-off-by: Abel Vesa <abel.vesa@linaro.org>
Reviewed-by: Johan Hovold <johan+linaro@kernel.org>
Tested-by: Johan Hovold <johan+linaro@kernel.org>
Link: https://lore.kernel.org/r/20240621-x1e80100-power-supply-qcom-battmgr-v1-1-40cb89a0c144@linaro.org
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2024-07-04 10:35:45 +02:00
Dimitri Fedrau
479b6d0496 power: supply: add support for MAX1720x standalone fuel gauge
The MAX17201 monitors a single cell pack. The MAX17205 monitors and
balances a 2S or 3S pack or monitors a multiple-series cell pack. Both
devices use a I2C interface.

Signed-off-by: Dimitri Fedrau <dima.fedrau@gmail.com>
Link: https://lore.kernel.org/r/20240702090308.8848-3-dima.fedrau@gmail.com
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2024-07-04 10:25:04 +02:00
Krzysztof Kozlowski
eba6d0f88b power: sequencing: simplify returning pointer without cleanup
Use 'return_ptr' helper for returning a pointer without cleanup for
shorter code.

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Link: https://lore.kernel.org/r/20240703083038.95777-1-krzysztof.kozlowski@linaro.org
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
2024-07-03 11:49:04 +02:00
Nathan Chancellor
c98f17fec3 power: supply: cros_charge-control: Avoid accessing attributes out of bounds
Clang warns (or errors with CONFIG_WERROR=y):

  drivers/power/supply/cros_charge-control.c:319:2: error: array index 3 is past the end of the array (that has type 'struct attribute *[3]') [-Werror,-Warray-bounds]
    319 |         priv->attributes[_CROS_CHCTL_ATTR_COUNT] = NULL;
        |         ^                ~~~~~~~~~~~~~~~~~~~~~~
  drivers/power/supply/cros_charge-control.c:49:2: note: array 'attributes' declared here
     49 |         struct attribute *attributes[_CROS_CHCTL_ATTR_COUNT];
        |         ^
  1 error generated.

In earlier revisions of the driver, the attributes array in
cros_chctl_priv had four elements with four distinct assignments but
during review, the number of elements was changed to three through use
of an enum and the assignments became a for loop, except for this one,
which is now out of bounds. This assignment is no longer necessary
because the size of the attributes array no longer accounts for it, so
just remove it to clear up the warning.

Fixes: c6ed48ef52 ("power: supply: add ChromeOS EC based charge control driver")
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
Acked-by: Thomas Weißschuh <linux@weissschuh.net>
Link: https://lore.kernel.org/r/20240702-cros_charge-control-fix-clang-array-bounds-warning-v1-1-ae04d995cd1d@kernel.org
Signed-off-by: Tzung-Bi Shih <tzungbi@kernel.org>
2024-07-03 05:54:29 +00:00
Thomas Weißschuh
3664706e87 power: supply: cros_charge-control: don't load if Framework control is present
Framework laptops implement a custom charge control EC command.
The upstream CrOS EC command is also present and functional but can get
overridden by the custom one.

Until Framework make both commands compatible or remove their custom
one, don't load the driver on those machines.

If the user knows they are not going to use the custom command they can
use a module parameter to load cros_charge-control anyways.

Note that the UEFI setup configuration for battery control also uses
their custom command.

Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
Link: https://lore.kernel.org/r/20240630-cros_ec-charge-control-v5-5-8f649d018c52@weissschuh.net
Signed-off-by: Tzung-Bi Shih <tzungbi@kernel.org>
2024-07-01 21:22:19 +08:00
Thomas Weißschuh
c6ed48ef52 power: supply: add ChromeOS EC based charge control driver
The ChromeOS Embedded Controller implements a command to control charge
thresholds and behaviour.

Use it to implement the standard Linux charge_control_start_threshold,
charge_control_end_threshold and charge_behaviour sysfs UAPIs.

The driver is designed to be probed via the cros_ec mfd device.

Acked-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
Link: https://lore.kernel.org/r/20240630-cros_ec-charge-control-v5-4-8f649d018c52@weissschuh.net
Signed-off-by: Tzung-Bi Shih <tzungbi@kernel.org>
2024-07-01 21:22:19 +08:00
Jeff Johnson
b498ddb6f2 power: reset: piix4: add missing MODULE_DESCRIPTION() macro
make allmodconfig && make W=1 C=1 reports:
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/power/reset/piix4-poweroff.o

Add the missing invocation of the MODULE_DESCRIPTION() macro.

Signed-off-by: Jeff Johnson <quic_jjohnson@quicinc.com>
Link: https://lore.kernel.org/r/20240608-md-drivers-power-reset-v1-1-08dbc1a546a2@quicinc.com
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2024-06-26 19:28:28 +02:00
Christophe JAILLET
0b209ec85b power: supply: samsung-sdi-battery: Constify struct power_supply_maintenance_charge_table
'struct power_supply_maintenance_charge_table' is not modified in this
driver.

Constifying this structure moves some data to a read-only section, so
increase overall security.

In order to do it, some code also needs to be adjusted to this new const
qualifier.

On a x86_64, with allmodconfig:
Before:
======
$ size drivers/power/supply/samsung-sdi-battery.o
   text	   data	    bss	    dec	    hex	filename
   4055	   4584	      0	   8639	   21bf	drivers/power/supply/samsung-sdi-battery.o

After:
=====
$ size drivers/power/supply/samsung-sdi-battery.o
   text	   data	    bss	    dec	    hex	filename
   4087	   4552	      0	   8639	   21bf	drivers/power/supply/samsung-sdi-battery.o

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Link: https://lore.kernel.org/r/6caafd0ac2556a40405273b1a4badc508ea8e9b0.1719125040.git.christophe.jaillet@wanadoo.fr
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2024-06-26 17:32:00 +02:00
Christophe JAILLET
5d55721d6e power: supply: samsung-sdi-battery: Constify struct power_supply_vbat_ri_table
'struct power_supply_vbat_ri_table' are not modified in this driver.

Constifying these structures moves some data to a read-only section, so
increase overall security.

In order to do it, some code also needs to be adjusted to this new const
qualifier.

On a x86_64, with allmodconfig:
Before:
======
$ size drivers/power/supply/samsung-sdi-battery.o
   text	   data	    bss	    dec	    hex	filename
    955	   7664	      0	   8619	   21ab	drivers/power/supply/samsung-sdi-battery.o

After:
=====
$ size drivers/power/supply/samsung-sdi-battery.o
   text	   data	    bss	    dec	    hex	filename
   4055	   4584	      0	   8639	   21bf	drivers/power/supply/samsung-sdi-battery.o

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Link: https://lore.kernel.org/r/d01818abd880bf435d1106a9a6cc11a7a8a3e661.1719125040.git.christophe.jaillet@wanadoo.fr
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2024-06-26 17:32:00 +02:00
Dmitry Baryshkov
db9cc84812 power: supply: lenovo_yoga_c630_battery: add Lenovo C630 driver
On the Lenovo Yoga C630 WOS laptop the EC provides access to the adapter
and battery status. Add the driver to read power supply status on the
laptop.

Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Link: https://lore.kernel.org/r/20240621-yoga-ec-driver-v8-1-daae67d0233d@linaro.org
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2024-06-26 15:37:14 +02:00
Christophe JAILLET
f8b6c1eb76 power: supply: ingenic: Fix some error handling paths in ingenic_battery_get_property()
If iio_read_channel_processed() fails, 'val->intval' is not updated, but it
is still *1000 just after. So, in case of error, the *1000 accumulate and
'val->intval' becomes erroneous.

So instead of rescaling the value after the fact, use the dedicated scaling
API. This way the result is updated only when needed. In case of error, the
previous value is kept, unmodified.

This should also reduce any inaccuracies resulting from the scaling.

Finally, this is also slightly more efficient as it saves a function call
and a multiplication.

Fixes: fb24ccfbe1 ("power: supply: add Ingenic JZ47xx battery driver.")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Acked-by: Artur Rojek <contact@artur-rojek.eu>
Link: https://lore.kernel.org/r/51e49c18574003db1e20c9299061a5ecd1661a3c.1719121781.git.christophe.jaillet@wanadoo.fr
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2024-06-26 15:16:57 +02:00
Christophe JAILLET
f62b267adc power: supply: ab8500: Clean some error messages
There is an useless extra comma at the end of some error messages, remove
them.

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Link: https://lore.kernel.org/r/e7ac0fa83c6100cbe4e0efa90cf99291c2423b10.1719037737.git.christophe.jaillet@wanadoo.fr
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2024-06-26 15:00:53 +02:00
Christophe JAILLET
dc6ce568af power: supply: ab8500: Use iio_read_channel_processed_scale()
Instead of rescaling current or voltage channels after the fact, use the
dedicated scaling API. This should reduce any inaccuracies resulting from
the scaling.

This is also slightly more efficient as it saves a function call and a
multiplication.

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Link: https://lore.kernel.org/r/5668d73b92eb6318c7f094a9a8fa914c909485ca.1719037737.git.christophe.jaillet@wanadoo.fr
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2024-06-26 15:00:53 +02:00
Christophe JAILLET
3288757087 power: supply: ab8500: Fix error handling when calling iio_read_channel_processed()
The ab8500_charger_get_[ac|vbus]_[current|voltage]() functions should
return an error code on error.

Up to now, an un-initialized value is returned.
This makes the error handling of the callers un-reliable.

Return the error code instead, to fix the issue.

Fixes: 97ab78bac5 ("power: supply: ab8500_charger: Convert to IIO ADC")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Link: https://lore.kernel.org/r/f9f65642331c9e40aaebb888589db043db80b7eb.1719037737.git.christophe.jaillet@wanadoo.fr
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2024-06-26 15:00:53 +02:00
Bartosz Golaszewski
2f1630f437 power: pwrseq: add a driver for the PMU module on the QCom WCN chipsets
This adds the power sequencing driver for the PMU modules present on the
Qualcomm WCN Bluetooth and Wifi chipsets. It uses the pwrseq subsystem
and knows how to match the sequencer to the consumer device by verifying
the relevant properties and DT layout. Using this driver will allow the
BT and WLAN drivers to respect the required delays between enabling the
two modules.

Tested-by: Amit Pundir <amit.pundir@linaro.org>
Tested-by: Neil Armstrong <neil.armstrong@linaro.org> # on SM8550-QRD, SM8650-QRD & SM8650-HDK
Tested-by: Caleb Connolly <caleb.connolly@linaro.org> # OnePlus 8T
Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Link: https://lore.kernel.org/r/20240605123850.24857-3-brgl@bgdev.pl
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
2024-06-12 09:20:13 +02:00
Bartosz Golaszewski
249ebf3f65 power: sequencing: implement the pwrseq core
Implement the power sequencing subsystem allowing devices to share
complex powering-up and down procedures. It's split into the consumer
and provider parts but does not implement any new DT bindings so that
the actual power sequencing is never revealed in the DT representation.

Tested-by: Amit Pundir <amit.pundir@linaro.org>
Tested-by: Neil Armstrong <neil.armstrong@linaro.org> # on SM8550-QRD, SM8650-QRD & SM8650-HDK
Tested-by: Caleb Connolly <caleb.connolly@linaro.org> # OnePlus 8T
Acked-by: Krzysztof Kozlowski <krzk@kernel.org>
Link: https://lore.kernel.org/r/20240605123850.24857-2-brgl@bgdev.pl
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
2024-06-12 09:20:13 +02:00
Armin Wolf
ad175de1f8 power: supply: hwmon: Add support for power sensors
Currently, more than seven power supply drivers are supporting
POWER_SUPPLY_PROP_POWER_NOW, but their power readings are not being
reported through the hwmon subsystem.

Fix this by adding support for power sensors to the power supply
hwmon integration.

Signed-off-by: Armin Wolf <W_Armin@gmx.de>
Link: https://lore.kernel.org/r/20240528222115.791511-1-W_Armin@gmx.de
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2024-06-03 01:29:46 +02:00
Dr. David Alan Gilbert
a5dd84f3bd power: supply: ab8500: remove unused struct 'inst_curr_result_list'
'inst_curr_result_list' is unused since the original
commit 13151631b5 ("ab8500-fg: A8500 fuel gauge driver").

Remove it.

Signed-off-by: Dr. David Alan Gilbert <linux@treblig.org>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Link: https://lore.kernel.org/r/20240528000634.196707-3-linux@treblig.org
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2024-06-03 01:29:46 +02:00
Dr. David Alan Gilbert
ef1f6783fe power: supply: bd99954: remove unused struct 'battery_data'
'battery_data' is unused since the original
commit 0902f83664 ("power: supply: Support ROHM bd99954 charger").

Remove it.

Signed-off-by: Dr. David Alan Gilbert <linux@treblig.org>
Acked-by: Matti Vaittinen <mazziesaccount@gmail.com>
Link: https://lore.kernel.org/r/20240528000634.196707-2-linux@treblig.org
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2024-06-03 01:29:46 +02:00
Hans de Goede
8179b068d5 power: supply: leds: Add activate() callback to triggers
Add an activate() callback to the power-supply LED triggers so that
the LED being activated will properly reflect the current power-supply
state for power-supply devices which are already fully registered
when the trigger gets activated.

This fixes e.g. wrong LED state (1) when the LED gets registered
after the power-supply device.

1) Until the psy driver has a reason to call power_supply_changed()
   which may take quite a while

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Andy Shevchenko <andy@kernel.org>
Link: https://lore.kernel.org/r/20240531134702.166145-4-hdegoede@redhat.com
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2024-06-03 01:29:43 +02:00
Hans de Goede
6c951a84da power: supply: leds: Share trig pointer for online and charging_full
Either 5 different LED triggers are registered for battery power-supply
devices or a single online LED trigger is used for non battery power-supply
devices.

These 5 / 1 LED trigger(s) are never used at the same time. So there is
no need for a separate LED trigger pointer for the online trigger. Rename
the first battery trigger from charging_full_trig to just trig and use this
for the online trigger too.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Andy Shevchenko <andy@kernel.org>
Link: https://lore.kernel.org/r/20240531134702.166145-3-hdegoede@redhat.com
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2024-06-03 01:29:39 +02:00
Hans de Goede
964a504b12 power: supply: leds: Add power_supply_[un]register_led_trigger()
Add power_supply_[un]register_led_trigger() helper functions.

The primary goal of this is as a preparation patch for adding an activate
callback to the power-supply LED triggers to ensure that power-supply
LEDs get the correct initial value when the LED gets registered after
the power_supply has been registered (this will use the psy back pointer).

There also is quite a lot of code duplication in the existing LED trigger
registration in the form of the kasprintf() for the name-template for each
trigger + related error handling. This duplication is removed by these
new helpers.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Andy Shevchenko <andy@kernel.org>
Link: https://lore.kernel.org/r/20240531134702.166145-2-hdegoede@redhat.com
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2024-06-03 01:29:36 +02:00
Sebastian Reichel
447bbf76e6 Immutable branch between LEDs, Power and RGB due for the v6.11 merge window
-----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCgAdFiEEdrbJNaO+IJqU8IdIUa+KL4f8d2EFAmZZ1mAACgkQUa+KL4f8
 d2FTKA//T3n1ouAmIGtIBKLmfWgDCfo+ryfLUrcSPdpD/u+E27wwm8TyGC6Rau40
 sRDnP9Yf2otgu1TB1UEKfjIq28si81BFdVWkCYz5ycPhTGzYXb0aQ+rfqcBCTtyj
 cYPM9OYaF898jPRlahUtpcJlw8UYzbUSjD6bxYCAc6WeBINha6iaOGbhBzY/ELvi
 WC/cLZ06iVb4h1uEMAPoRTg6SFuONfWYXsDk9lVbL+ig6Dmk7LWSX5A+ly4fdzX6
 6fR6DbUpmdAI17SSCDx2G7TgIfX1gFnDg0BVpHk7Z3xbX00H8tsUSVXnd/gSGn+4
 Yj5ys2eHxB3WCSyGTOV38ur8quTt61XwyYFHmeaNt7gZ+BI5QcYDtBZrJlkCrDEg
 FocXpbmRz2Zki9wjsHqatDAS46ku/P3cF4ssb+/yQB73s9L0OSt8/+1ml79tYnU6
 s9jmKlUOT8I6iR8p1fmRHsq8oQchyrj2Vrxax6SJtfrsF0h4CqUMftKMOK5wSbkC
 VK420lM/x45dU3FsgjTIikszy3PCYit3GRQKQL4bUJwegyQi2MDyMaga7c/1UwSY
 mo3TE77PK+SEPOq3HzkQiolLlM9Iq1w9N3OEUFN+Y3epaz87sOqaClYLWNpJ3eFu
 EFDRAJDJx1huRy11slw0fnH39i0XJQz8kklxSZ1dA18URpNJPz0=
 =nAvT
 -----END PGP SIGNATURE-----

Merge tag 'ib-leds-platform-power-v6.11'

Immutable branch between LEDs, Power and RGB due for the v6.11 merge
window.

Merge it to provide functionality required by power-supply specific
LED handler cleanups depending on the newly added (multi-colour) LED
features.

Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2024-06-03 00:49:44 +02:00
Kate Hsuan
9af12f57f1 power: supply: power-supply-leds: Add charging_orange_full_green trigger for RGB LED
Add a charging_orange_full_green LED trigger and the trigger is based on
led_mc_trigger_event() which can set an RGB LED when the trigger is
triggered. The LED will show orange when the battery status is charging.
The LED will show green when the battery status is full.

Link: https://lore.kernel.org/linux-leds/f40a0b1a-ceac-e269-c2dd-0158c5b4a1ad@gmail.com/
Signed-off-by: Kate Hsuan <hpa@redhat.com>
Acked-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Reviewed-by: Andy Shevchenko <andy@kernel.org>
[hdegoede@redhat.com change color order to RGB]
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Link: https://lore.kernel.org/r/20240531114124.45346-7-hdegoede@redhat.com
Signed-off-by: Lee Jones <lee@kernel.org>
2024-05-31 12:57:43 +01:00
Uwe Kleine-König
ebacfa1f09 power: supply: Drop explicit initialization of struct i2c_device_id::driver_data to 0
These drivers don't use the driver_data member of struct i2c_device_id,
so don't explicitly initialize this member.

This prepares putting driver_data in an anonymous union which requires
either no initialization or named designators. But it's also a nice
cleanup on its own.

While add it, also remove commas after the sentinel entries.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Link: https://lore.kernel.org/r/20240522164830.61646-2-u.kleine-koenig@pengutronix.de
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2024-05-27 18:47:11 +02:00
Linus Torvalds
0a07e09085 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.
 -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCgAdFiEEOZGx6rniZ1Gk92RdFA3kzBSgKbYFAmZLFfoACgkQFA3kzBSg
 KbaTlxAAq+VXWNEEK41X6SNVnzwm1H9zoq/vg92rQ1oKh/AUfO6W4pJTg3OQz0gT
 4x5Z4yeRZwtWE7zdTQlQUdUvcj490cTUF9f7gTTeH0uhFCyECzOZSIpa4kG+A/mI
 JUCCVLMziq6rIscYFdomvKSzwitzhoCuLVsOthYgK3TvbbGH6FHe4h6MDP/u3ok7
 seL7ZhqsudL26fFv5+U9095xM0OLDB1R7+DJXaibS6hY1/+WX3qMWHjCF7tf4gAr
 bHg/LaDNIiW2pwj7LFhaLrQzchxV/zPKRJYlO05M4mn9hxyVM9ztKtGPLRqglZEX
 yPqD857/Rac4y30PihWSVf4uG9pJWY0BEMjucuL0DZLX98C8kqJKK1SSi1FMd5qf
 ROAlCMQt+pSVcO6V9cEVIxzpJ2ZhAT4NM2T7yaGrdt6WX9W/an9hNqPcMUBVU6G2
 Fzk960eftI/V+IRGswHuBD4w4duIlxUMWd5961UdI0LqzQrhzyNq3IZu/jpw49DH
 ZnJ/0UPkV9FfZvZpglf/ztlUESkCqWFjbxOfiejHCnUrvla5JGQTPXVTyP9p38X9
 cxevlLgdsKz4F9WqEzpeI7L0HrxpTI863lmhFy+LuWYjYUfYSqIbiB0lWuCP+9Fy
 Cjnfp8KRp0lJD206Yyj4WC1B8xi1G44MkB2seGH7GtejM4I9A+U=
 =viLd
 -----END PGP SIGNATURE-----

Merge tag 'i2c-for-6.10-rc1' of 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-20 08:55:18 -07:00
Linus Torvalds
85d46148f8 power supply and reset changes for the 6.10 series
* 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
 -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCgAdFiEE72YNB0Y/i3JqeVQT2O7X88g7+poFAmZHe7IACgkQ2O7X88g7
 +ppzRw/7BndhO6gBQEIRsM+elBE3GkFfdvAjfkjn3756mJZpTI0zhcOSQWHIJ6TA
 6MRU2CDrG4eXuhkoJ1bsXa9+gSTuKBBBV41BNoUdBqTlg/i8D8T1U97Ofjxf5+4w
 zcd1GYndzaTMakC3Pn18sg026+QI3n31wl8LyvrfrP3fv2VMmHOQ3mg0AxyxhtzE
 cWc2Qi4lpVH456vR9LYTSmJhxph5mF5ZQ0sfx/s8OO4si6GGLV1l9KrR2NxW1bAY
 6ZCT8C56KWddQqGOPE5kz9XLzc1j0EYyoMzxr9UwNYSgZroHgjj2bmQMRgsTWpC0
 cZ9NOtxv+Xlnio7H1SNhgVwGnesw3nFZz7IgdGBcMZhJzwt+rG3h4OfoaGEr0arZ
 fN2lnJXU6Tjs7ArYVJjGLGqx9HdG1LKsLsFFSeWU+zwqOAhLCveXha9oJsulkHta
 zjrG0pYjexCM6YF/2kp5jwpDln9pWJ7AeuP2ZH57/kaREdl79qU6oEosVZuB+cy8
 Zkf09dy3ZAI/gBL73dIOK0blaSY4A36CyWCZGQvhn8x6Ai0AecxcV8y136pdfFjH
 7C17/DUtbUfclEyp2IlO/EIKPv/aZVs4x57tUcwlNomjG7Pe1Qw3wnrUV7ZAOAx7
 tihCn8mDFj46MCE+CsmdK4YAAGuVR44llQv3t249Yxm1mEEB79E=
 =T4Sm
 -----END PGP SIGNATURE-----

Merge tag 'for-v6.10' of 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-18 12:54:32 -07:00
Wolfram Sang
068a95ef39 power: supply: sbs-manager: Remove class argument from i2c_mux_add_adapter()
Commit 99a741aa7a ("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: fec1982d70 ("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-05-14 09:21:43 +02:00
AngeloGioacchino Del Regno
1e0fb11364 power: supply: mt6360_charger: Fix of_match for usb-otg-vbus regulator
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: 0402e8ebb8 ("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-15 13:31:37 +02:00
Arnd Bergmann
452d8950db power: rt9455: hide unused rt9455_boost_voltage_values
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: e86d69dd78 ("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-10 09:57:29 +02:00
Andrew Davis
50f0ff7c8c power: supply: bq27xxx: Move health reading out of update loop
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-01 12:29:44 +02:00
Andrew Davis
656489ac90 power: supply: bq27xxx: Move cycle count reading out of update loop
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-01 12:29:44 +02:00
Andrew Davis
39cf1c4cd0 power: supply: bq27xxx: Move energy reading out of update loop
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-01 12:29:44 +02:00
Andrew Davis
8d84633520 power: supply: bq27xxx: Move charge reading out of update loop
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-01 12:29:44 +02:00
Andrew Davis
651a620aa4 power: supply: bq27xxx: Move time reading out of update loop
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-01 12:29:44 +02:00
Andrew Davis
c32c617de8 power: supply: bq27xxx: Move temperature reading out of update loop
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-01 12:29:44 +02:00
Tzung-Bi Shih
d6486a1366 power: supply: cros_pchg: provide ID table for avoiding fallback match
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-01 11:35:47 +02:00
Tzung-Bi Shih
0f8678c34c power: supply: cros_usbpd: provide ID table for avoiding fallback match
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-04-01 11:35:46 +02:00
Thomas Weißschuh
91b623cda4 power: supply: core: simplify charge_behaviour formatting
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: 4e61f1e9d5 ("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-29 13:36:39 +01:00
Thomas Weißschuh
070c1470ae power: supply: test-power: implement charge_behaviour property
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-25 23:29:06 +01:00
Linus Torvalds
44f89c6d3c power supply and reset changes for the 6.9 series
* 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
 -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCgAdFiEE72YNB0Y/i3JqeVQT2O7X88g7+poFAmXyI98ACgkQ2O7X88g7
 +prwAQ/+OyQSOwPQYvPe46YFVKwN+cDyEqgqwu3ndHgbx3x/VNbRDzsykQVIKp1/
 H57CzESX6tHA+gdnXBGCHSVBEGuBy3broJi4FBI6DuLmHM0ezIDoYrzScS+yanza
 0cmYDjqUDGfcyAO5xstjXY+yEZ3Dju2pd+uNM66b73FDh1Ch6wj96KTWTSUOO0zb
 O8vbSqfltE6FeqKrtVH3itodiGP5rEcEGypiwl9DG0PCbqKGbgm7TWW7vNcHvMUl
 BYZnJeVmrtHa18uAt6JtO5xB9pb6dst2GZf3cMtLBeAUDvO5mzz4MxEk3FczPnIQ
 sBEBn4GCpgvctIt7I2TPmG+sjNTCv2BX6SWEtmQECMK8w+J9LlEM3Y0dwzP/c87z
 9nrnYDbK/RBtI/C6FEOb5Eb/IYR/2J6l7B1dJOKFgqZI/HnFRn4U+dUJWL/LL9Vg
 QH2hUkiply/7F6ziq7LRFfvDDohZbRnrlBuEjYII5GPyFVBLU2pjtw6wBWsqYUG9
 cm3+BAx+idHjuOP9rxLWBUOBIFhqUkkAjZscTM7FUbEtgXbb7bGQcnjvSBZN/k4O
 4bhW9PFjDa6Isioy3dM+TRmxbn06r8fLa330rcCIhD1kf1zTM8M0sNGM0HixE/+t
 MThYC1dmXl5gQ59OlW3wa192mzim1iTFx1mkXSvlAOzRbGcFY20=
 =II3q
 -----END PGP SIGNATURE-----

Merge tag 'for-v6.9' of 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-14 10:19:48 -07:00
Thomas Weißschuh
4e61f1e9d5 power: supply: core: fix charge_behaviour formatting
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
1b0b6cc803 ("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-06 00:39:45 +01:00
Thomas Weißschuh
521d75b417 power: supply: core: ease special formatting implementations
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-06 00:37:36 +01:00