ViezeVingertjes opened a new pull request, #22399: URL: https://github.com/apache/nuttx/pull/22399
## Summary Add a driver for the X-Powers AXP2101 PMIC (I2C, address 0x34), found on several ESP32-S3 boards. It follows the AXP202 driver and provides the lower half of the battery charger driver: charge state, health, VBUS presence, charge voltage, charge current, input current limit, charge termination and power off. With CONFIG_BATTERY_GAUGE it also provides a battery gauge lower half: battery voltage, state of charge from the gauge of the chip and die temperature. The driver checks the chip ID and enables the VBAT, VBUS, VSYS and die temperature ADC channels. It does not change the DCDC and LDO outputs, which keep the values of the OTP, and it does not use the IRQ pin. axp2101_poweroff() turns off the outputs, for board_power_off(). The fault flags used for the health are latched by the chip; they are cleared after reading, so each fault is reported once. Tested on Waveshare ESP32-S3-Touch-AMOLED-2.16 with USB power and a full battery: chip ID, charge state, VBUS, health, battery voltage, state of charge and die temperature match the raw registers, and power off works. Built with and without CONFIG_BATTERY_GAUGE. ## Impact * Is new feature added? Is existing feature changed? YES: new driver (CONFIG_AXP2101), off by default. * Impact on user (will user need to adapt to change)? NO * Impact on build (will build process change)? NO * Impact on hardware (will arch(s) / board(s) / driver(s) change)? NO * Impact on documentation (is update required / provided)? YES: driver documentation. * Impact on security (any sort of implications)? NO * Impact on compatibility (backward/forward/interoperability)? NO ## Testing I confirm that changes are verified on local setup and works as intended: * Build Host(s): Linux x86_64, xtensa-esp-elf GCC 15.2.0 (esp-15.2.0_20251204), riscv32-esp-elf GCC 15.2.0 for the ESP32-C3 build. * Target(s): Waveshare ESP32-S3-Touch-AMOLED-2.16 (ESP32-S3R8, 16 MB flash, 8 MB PSRAM). * On the board (board support follows in a separate PR): batterydump on /dev/batt0 and /dev/gauge0, cross-checked with raw registers; poweroff. Builds (each on current master plus this PR only): * PASS pr/axp2101-pmic charger esp32s3-devkit:nsh (warnings: 0; no work queue) * PASS pr/axp2101-pmic gauge esp32s3-devkit:nsh (warnings: 0; no work queue) Testing logs before change: ``` n/a (new driver) ``` Testing logs after change: ``` mask:0, state:3, online:1, health:1, vol:4165, protocol:0 mask:0, state:3, online:1, vol:4164mV, capacity:100%, current:0mA, temperature:34.0C ``` ## PR verification Self-Check * [x] This PR introduces only one functional change. * [x] I have updated all required description fields above. * [x] My PR adheres to Contributing Guidelines and Documentation (git commit title and message, coding standard, etc). * [ ] My PR is still work in progress (not ready for review). * [x] My PR is ready for review and can be safely merged into a codebase. 🤖 Generated with [Claude Code](https://claude.com/claude-code) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
