Skip to content

Comments

Ucsi battery charging status#644

Merged
RobertZ2011 merged 9 commits intoOpenDevicePartnership:mainfrom
RobertZ2011:ucsi-battery-charging-status
Dec 20, 2025
Merged

Ucsi battery charging status#644
RobertZ2011 merged 9 commits intoOpenDevicePartnership:mainfrom
RobertZ2011:ucsi-battery-charging-status

Conversation

@RobertZ2011
Copy link
Contributor

@RobertZ2011 RobertZ2011 commented Dec 17, 2025

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:

  • Added min_consumer_threshold_mw to Config in power-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]
  • Introduced UcsiBatteryChargingThresholdConfig in type-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:

  • Added new PowerPolicyEvent variants (ConsumerConnected, ConsumerDisconnected) and updated event processing to track PSU connection state and trigger UCSI notifications when consumer connection status changes. [1] [2] [3]
  • Improved UCSI event handling by adding 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:

  • Added tracking for ports with valid battery charging capability and logic to determine and report charging status only after power negotiation is complete, avoiding premature or incorrect status reports. [1] [2] [3] [4]

Logging improvements:

  • Increased log level from trace! to debug! for port status reporting in the Type-C driver for better visibility during development and troubleshooting.

Internal refactoring:

  • Refactored UCSI command processing to operate on the correct state structure, improving code clarity and correctness. [1] [2] [3] [4]

These changes together provide more accurate and configurable power and charging management, enhance system observability, and improve the robustness of the Type-C service.

@RobertZ2011 RobertZ2011 self-assigned this Dec 17, 2025
Copilot AI review requested due to automatic review settings December 17, 2025 22:11
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@RobertZ2011 RobertZ2011 force-pushed the ucsi-battery-charging-status branch from 597b4ae to 64ef577 Compare December 17, 2025 22:30
Copilot AI review requested due to automatic review settings December 17, 2025 22:34
@RobertZ2011 RobertZ2011 force-pushed the ucsi-battery-charging-status branch 2 times, most recently from 4d8246f to 900224e Compare December 17, 2025 22:34
@RobertZ2011 RobertZ2011 marked this pull request as ready for review December 17, 2025 22:35
@RobertZ2011 RobertZ2011 requested review from a team as code owners December 17, 2025 22:35
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
asasine previously approved these changes Dec 17, 2025
Copy link

@asasine asasine left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nothing blocking so approved, just a few clarifying questions and suggestions

@jerrysxie jerrysxie added the enhancement New feature or request label Dec 18, 2025
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot AI review requested due to automatic review settings December 18, 2025 21:27
@RobertZ2011 RobertZ2011 force-pushed the ucsi-battery-charging-status branch from d5fe76a to a8249b9 Compare December 18, 2025 21:27
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

seanbrns
seanbrns previously approved these changes Dec 18, 2025
Add status_of function

This maintains the invariants established by the try_new constructor
@asasine asasine requested a review from Copilot December 19, 2025 23:15
@asasine asasine dismissed their stale review December 19, 2025 23:16

I pushed and can't review my own code.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>
Copilot AI review requested due to automatic review settings December 19, 2025 23:19
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>
Copilot AI review requested due to automatic review settings December 19, 2025 23:32
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link

@asasine asasine left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm the only one not OOF on the PD team so approving for myself.

@RobertZ2011 RobertZ2011 merged commit bef9e3f into OpenDevicePartnership:main Dec 20, 2025
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants