Ucsi battery charging status#644
Conversation
There was a problem hiding this comment.
Pull request overview
This PR implements battery charging status reporting in the UCSI (USB Type-C Connector System Software Interface) service. It adds support for reporting different charging states (NotCharging, VerySlow, Slow, Nominal) based on power thresholds and PSU connection status, along with filtering logic to prevent low-power consumers from being selected by the power policy service.
Key Changes:
- Adds battery charging capability status determination based on configurable power thresholds
- Tracks PSU connection state to adjust charging status reporting behavior
- Implements minimum consumer power threshold filtering in power policy service
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| type-c-service/src/service/ucsi.rs | Implements battery charging status logic, adds state tracking for valid battery charging capability and PSU connection, modifies command processing to inject charging status |
| type-c-service/src/service/power.rs | Handles PSU connected/disconnected power policy events to update charging status and trigger UCSI notifications |
| type-c-service/src/service/mod.rs | Updates event handling to pass port status to UCSI event handler, adds new power policy event variants |
| type-c-service/src/service/config.rs | Adds configuration struct for battery charging power thresholds |
| type-c-service/src/driver/tps6699x.rs | Changes logging level from trace to debug for port status queries |
| power-policy-service/src/consumer.rs | Adds filtering to exclude consumers below minimum power threshold |
| power-policy-service/src/config.rs | Adds optional minimum consumer threshold configuration |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
597b4ae to
64ef577
Compare
4d8246f to
900224e
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
asasine
left a comment
There was a problem hiding this comment.
Nothing blocking so approved, just a few clarifying questions and suggestions
bcd8b7d to
435eec1
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 7 out of 10 changed files in this pull request and generated 7 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
d5fe76a to
a8249b9
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 8 out of 12 changed files in this pull request and generated 7 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Add status_of function This maintains the invariants established by the try_new constructor
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 8 out of 12 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 8 out of 12 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 8 out of 12 changed files in this pull request and generated 6 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
asasine
left a comment
There was a problem hiding this comment.
I'm the only one not OOF on the PD team so approving for myself.
Depends on OpenDevicePartnership/embedded-usb-pd#58
This pull request introduces several enhancements and fixes to the power policy and Type-C service modules, primarily adding more granular control and reporting for power and battery charging status. The most significant changes include the introduction of configurable battery charging thresholds, improved event handling for consumer connections and disconnections, and more robust tracking and reporting of battery charging capabilities.
Power policy and battery charging improvements:
min_consumer_threshold_mwtoConfiginpower-policy-service, allowing configuration of a minimum power threshold for considering consumers. Consumers below this threshold are ignored, improving power selection logic. [1] [2] [3]UcsiBatteryChargingThresholdConfigintype-c-service, enabling configuration of thresholds for "no", "very slow", and "slow" battery charging reporting. This allows more accurate UCSI battery charging status based on negotiated power. [1] [2]Event handling and state management:
PowerPolicyEventvariants (ConsumerConnected,ConsumerDisconnected) and updated event processing to track PSU connection state and trigger UCSI notifications when consumer connection status changes. [1] [2] [3]handle_ucsi_port_event, which updates battery charging capability status when power negotiation completes or ports are disconnected, and ensures correct notification behavior. [1] [2] [3]Battery charging status tracking:
Logging improvements:
trace!todebug!for port status reporting in the Type-C driver for better visibility during development and troubleshooting.Internal refactoring:
These changes together provide more accurate and configurable power and charging management, enhance system observability, and improve the robustness of the Type-C service.