drivers: power_switch: add power switch driver

Add a driver class for power switches, e.g. used for load and USB
outputs. Besides switching on and off, drivers may provide a power-good
feedback and report faults that were already handled in hardware.

Two backends are available:

- libresolar,gpio-power-switch: Switch driven by a GPIO with optional
  latching power-good feedback and charge pump PWM for high-side gate
  drivers. The latch time is handled by delayable work instead of
  blocking the caller.
- libresolar,stm32-lptim-power-switch: Switch driven by LPTIM1 of
  STM32L0, which is triggered by COMP2 to switch off within a few
  microseconds in case of a short circuit (PWM 2420 LUS).

The GPIO backend is tested on native_sim using the GPIO emulator and the
fake PWM driver.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Martin Jäger
2026-11-01 13:43:57 +01:00
co-authored by Claude Opus 5.5
parent a7838b022c
commit 01b48b26e1
18 changed files with 951 additions and 0 deletions
+1
View File
@@ -47,5 +47,6 @@ The full license text is available at `<https://creativecommons.org/licenses/by-
src/api/half_bridge
src/api/load
src/api/power_port
src/api/power_switch
src/api/pwm_switch
src/api/misc
+5
View File
@@ -0,0 +1,5 @@
Power Switch Driver
===================
.. doxygenfile:: power_switch.h
:project: app