Re: [PATCH v1 3/3] tcpm: Implement sink support for PD SPR AVS negotiation

From: Heikki Krogerus

Date: Mon Mar 02 2026 - 07:56:30 EST


On Thu, Feb 26, 2026 at 05:53:11AM +0000, Badhri Jagan Sridharan wrote:
> Add support to enable TCPM to negotiate with
> USB PD Standard Power Range Adjustable Voltage Supply (SPR AVS) when
> acting as a power sink.
>
> * Added support to the tcpm power supply properties, allowing userspace
> to enable and control the dynamic limits (voltage and current)
> specific to the SPR AVS contract.
> * Implemented tcpm_pd_select_spr_avs_apdo() to select the appropriate
> APDO and validate the requested voltage/current against both the
> Source and Sink capabilities.
> * Implemented tcpm_pd_build_spr_avs_request() to construct the
> Request Data Object (RDO) for SPR AVS.
> * Added SNK_NEGOTIATE_SPR_AVS_CAPABILITIES state to the state machine to
> handle negotiation for SPR AVS.
> * Updated the SNK_TRANSITION_SINK state to implement the SPR
> AVS-specific VBUS transition rules, including reducing current draw to
> PD_I_SNK_STBY_MA for large voltage changes, as required by USB PD spec.
>
> Log stub captured when enabling AVS:
> $ echo 3 > /sys/class/power_supply/tcpm-source-psy-1-0025/online
> $ cat /d/usb/tcpm-1-0025/log
> [ 358.895775] request to set AVS online
> [ 358.895792] AMS POWER_NEGOTIATION start
> [ 358.895806] state change SNK_READY -> AMS_START [rev3 POWER_NEGOTIATION]
> [ 358.895850] state change AMS_START -> SNK_NEGOTIATE_SPR_AVS_CAPABILITIES [rev3 POWER_NEGOTIATION]
> [ 358.895866] SPR AVS src_pdo_index:4 snk_pdo_index:2 req_op_curr_ma roundup:2200 req_out_volt_mv roundup:9000
> [ 358.895880] Requesting APDO SPR AVS 4: 9000 mV, 2200 mA
> [ 358.896405] set_auto_vbus_discharge_threshold mode:0 pps_active:n vbus:0 pps_apdo_min_volt:0 ret:0
> [ 358.896422] PD TX, header: 0x1a82
> [ 358.900158] PD TX complete, status: 0
> [ 358.900205] pending state change SNK_NEGOTIATE_SPR_AVS_CAPABILITIES -> HARD_RESET_SEND @ 60 ms [rev3 POWER_NEGOTIATION]
> [ 358.904832] PD RX, header: 0x1a3 [1]
> [ 358.904854] state change SNK_NEGOTIATE_SPR_AVS_CAPABILITIES -> SNK_TRANSITION_SINK [rev3 POWER_NEGOTIATION]
> [ 358.904888] pending state change SNK_TRANSITION_SINK -> HARD_RESET_SEND @ 700 ms [rev3 POWER_NEGOTIATION]
> [ 359.021530] PD RX, header: 0x3a6 [1]
> [ 359.021546] Setting voltage/current limit 9000 mV 2200 mA
> [ 359.023035] set_auto_vbus_discharge_threshold mode:3 pps_active:n vbus:9000 pps_apdo_min_volt:0 ret:0
> [ 359.023053] state change SNK_TRANSITION_SINK -> SNK_READY [rev3 POWER_NEGOTIATION]
> [ 359.023090] AMS POWER_NEGOTIATION finished
>
> $ cat /sys/class/power_supply/tcpm-source-psy-1-0025/online
> 3
>
> Log stub captured when increasing voltage:
> $ echo 9100000 > /sys/class/power_supply/tcpm-source-psy-1-0025/voltage_now
> $ cat /d/usb/tcpm-1-0025/log
>
> [ 632.116714] AMS POWER_NEGOTIATION start
> [ 632.116728] state change SNK_READY -> AMS_START [rev3 POWER_NEGOTIATION]
> [ 632.116779] state change AMS_START -> SNK_NEGOTIATE_SPR_AVS_CAPABILITIES [rev3 POWER_NEGOTIATION]
> [ 632.116798] SPR AVS src_pdo_index:4 snk_pdo_index:2 req_op_curr_ma roundup:2200 req_out_volt_mv roundup:9100
> [ 632.116811] Requesting APDO SPR AVS 4: 9100 mV, 2200 mA
> [ 632.117315] set_auto_vbus_discharge_threshold mode:0 pps_active:n vbus:0 pps_apdo_min_volt:0 ret:0
> [ 632.117328] PD TX, header: 0x1c82
> [ 632.121007] PD TX complete, status: 0
> [ 632.121052] pending state change SNK_NEGOTIATE_SPR_AVS_CAPABILITIES -> HARD_RESET_SEND @ 60 ms [rev3 POWER_NEGOTIATION]
> [ 632.124572] PD RX, header: 0x5a3 [1]
> [ 632.124594] state change SNK_NEGOTIATE_SPR_AVS_CAPABILITIES -> SNK_TRANSITION_SINK [rev3 POWER_NEGOTIATION]
> [ 632.124623] pending state change SNK_TRANSITION_SINK -> HARD_RESET_SEND @ 700 ms [rev3 POWER_NEGOTIATION]
> [ 632.149256] PD RX, header: 0x7a6 [1]
> [ 632.149271] Setting voltage/current limit 9100 mV 2200 mA
> [ 632.150770] set_auto_vbus_discharge_threshold mode:3 pps_active:n vbus:9100 pps_apdo_min_volt:0 ret:0
> [ 632.150787] state change SNK_TRANSITION_SINK -> SNK_READY [rev3 POWER_NEGOTIATION]
> [ 632.150823] AMS POWER_NEGOTIATION finished
>
> $ cat /sys/class/power_supply/tcpm-source-psy-1-0025/voltage_now
> 9100000
>
> Signed-off-by: Badhri Jagan Sridharan <badhri@xxxxxxxxxx>
> Reviewed-by: Amit Sunil Dhamne <amitsd@xxxxxxxxxx>

Acked-by: Heikki Krogerus <heikki.krogerus@xxxxxxxxxxxxxxx>

--
heikki