14#ifndef ZEPHYR_INCLUDE_DRIVERS_USBC_USBC_PD_H_
15#define ZEPHYR_INCLUDE_DRIVERS_USBC_USBC_PD_H_
35#define PD_MAX_EXTENDED_MSG_LEGACY_LEN 26
42#define PD_MAX_EXTENDED_MSG_LEN 260
54#define PD_MAX_EXTENDED_MSG_CHUNK_LEN 26
67#define PD_N_CAPS_COUNT 50
74#define PD_N_HARD_RESET_COUNT 2
88#define PD_T_NO_RESPONSE_MIN_MS 4500
95#define PD_T_NO_RESPONSE_MAX_MS 5500
103#define PD_T_PS_HARD_RESET_MIN_MS 25
111#define PD_T_PS_HARD_RESET_MAX_MS 35
118#define PD_T_SINK_TX_MIN_MS 16
125#define PD_T_SINK_TX_MAX_MS 20
134#define PD_T_TYPEC_SEND_SOURCE_CAP_MIN_MS 100
143#define PD_T_TYPEC_SEND_SOURCE_CAP_MAX_MS 200
153#define PD_T_TYPEC_SINK_WAIT_CAP_MIN_MS 310
161#define PD_T_TYPEC_SINK_WAIT_CAP_MAX_MS 620
168#define PD_V_SAFE_0V_MAX_MV 800
175#define PD_V_SAFE_5V_MIN_MV 4750
182#define PD_T_SAFE_0V_MAX_MS 650
189#define PD_T_SAFE_5V_MAX_MS 275
194#define PD_T_TX_TIMEOUT_MS 100
200#define PD_T_HARD_RESET_COMPLETE_MIN_MS 4
206#define PD_T_HARD_RESET_COMPLETE_MAX_MS 5
212#define PD_T_SENDER_RESPONSE_MIN_MS 24
218#define PD_T_SENDER_RESPONSE_NOM_MS 27
224#define PD_T_SENDER_RESPONSE_MAX_MS 30
230#define PD_T_SPR_PS_TRANSITION_MIN_MS 450
236#define PD_T_SPR_PS_TRANSITION_NOM_MS 500
242#define PD_T_SPR_PS_TRANSITION_MAX_MS 550
248#define PD_T_EPR_PS_TRANSITION_MIN_MS 830
254#define PD_T_EPR_PS_TRANSITION_NOM_MS 925
260#define PD_T_EPR_PS_TRANSITION_MAX_MS 1020
266#define PD_T_SINK_REQUEST_MIN_MS 100
273#define PD_T_CHUNKING_NOT_SUPPORTED_MIN_MS 40
280#define PD_T_CHUNKING_NOT_SUPPORTED_NOM_MS 45
287#define PD_T_CHUNKING_NOT_SUPPORTED_MAX_MS 50
295#define PD_CONVERT_BYTES_TO_PD_HEADER_COUNT(c) ((c) >> 2)
302#define PD_CONVERT_PD_HEADER_COUNT_TO_BYTES(c) ((c) << 2)
308#define SINK_TX_OK TC_RP_3A0
314#define SINK_TX_NG TC_RP_1A5
345#define PD_GET_EXT_HEADER(c) ((c) & 0xffff)
376#define PDO_MAX_DATA_OBJECTS 7
398#define PD_CONVERT_MA_TO_FIXED_PDO_CURRENT(c) ((c) / 10)
405#define PD_CONVERT_MV_TO_FIXED_PDO_VOLTAGE(v) ((v) / 50)
412#define PD_CONVERT_FIXED_PDO_CURRENT_TO_MA(c) ((c) * 10)
421#define PD_CONVERT_FIXED_PDO_VOLTAGE_TO_MV(v) ((v) * 50)
506#define PD_CONVERT_MA_TO_VARIABLE_PDO_CURRENT(c) ((c) / 10)
513#define PD_CONVERT_MV_TO_VARIABLE_PDO_VOLTAGE(v) ((v) / 50)
520#define PD_CONVERT_VARIABLE_PDO_CURRENT_TO_MA(c) ((c) * 10)
527#define PD_CONVERT_VARIABLE_PDO_VOLTAGE_TO_MV(v) ((v) * 50)
572#define PD_CONVERT_MW_TO_BATTERY_PDO_POWER(c) ((c) / 250)
579#define PD_CONVERT_MV_TO_BATTERY_PDO_VOLTAGE(v) ((v) / 50)
586#define PD_CONVERT_BATTERY_PDO_POWER_TO_MW(c) ((c) * 250)
593#define PD_CONVERT_BATTERY_PDO_VOLTAGE_TO_MV(v) ((v) * 50)
638#define PD_CONVERT_MA_TO_AUGMENTED_PDO_CURRENT(c) ((c) / 50)
645#define PD_CONVERT_MV_TO_AUGMENTED_PDO_VOLTAGE(v) ((v) / 100)
652#define PD_CONVERT_AUGMENTED_PDO_CURRENT_TO_MA(c) ((c) * 50)
659#define PD_CONVERT_AUGMENTED_PDO_VOLTAGE_TO_MV(v) ((v) * 100)
898#define NUM_SOP_STAR_TYPES (PD_PACKET_DEBUG_PRIME_PRIME + 1)
pdo_type
Power Data Object Type Table 6-7 Power Data Object.
Definition usbc_pd.h:382
pd_ext_msg_type
Extended message type for REV 3.0 See Table 6-48 Extended Message Types.
Definition usbc_pd.h:992
pd_frs_type
Fast Role Swap Required for USB Type-C current.
Definition usbc_pd.h:459
pd_ctrl_msg_type
Control Message type See Table 6-5 Control Message Types.
Definition usbc_pd.h:904
pd_data_msg_type
Data message type See Table 6-6 Data Message Types.
Definition usbc_pd.h:962
pd_rev_type
Protocol revision.
Definition usbc_pd.h:859
#define PD_MAX_EXTENDED_MSG_LEN
Maximum length of an Extended Message in bytes.
Definition usbc_pd.h:42
pd_packet_type
Power Delivery packet type See USB Type-C Port Controller Interface Specification,...
Definition usbc_pd.h:873
usbpd_cc_pin
Active PD CC pin.
Definition usbc_pd.h:1030
@ PDO_VARIABLE
Variable Supply (non-Battery)
Definition usbc_pd.h:388
@ PDO_BATTERY
Battery.
Definition usbc_pd.h:386
@ PDO_FIXED
Fixed supply (Vmin = Vmax)
Definition usbc_pd.h:384
@ PDO_AUGMENTED
Augmented Power Data Object (APDO)
Definition usbc_pd.h:390
@ PD_EXT_SECURITY_REQUEST
Security_Request Message.
Definition usbc_pd.h:1010
@ PD_EXT_FIRMWARE_UPDATE_REQUEST
Firmware_Update_Request Message.
Definition usbc_pd.h:1014
@ PD_EXT_FIRMWARE_UPDATE_RESPONSE
Firmware_Update_Response Message.
Definition usbc_pd.h:1016
@ PD_EXT_MANUFACTURER_INFO
Manufacturer_Info Message.
Definition usbc_pd.h:1008
@ PD_EXT_SOURCE_CAP
0 Reserved
Definition usbc_pd.h:996
@ PD_EXT_GET_BATTERY_STATUS
Get_Battery_Status Message.
Definition usbc_pd.h:1002
@ PD_EXT_PPS_STATUS
PPS_Status Message.
Definition usbc_pd.h:1018
@ PD_EXT_STATUS
Status Message.
Definition usbc_pd.h:998
@ PD_EXT_GET_BATTERY_CAP
Get_Battery_Cap Message.
Definition usbc_pd.h:1000
@ PD_EXT_COUNTRY_INFO
Country_Codes Message.
Definition usbc_pd.h:1020
@ PD_EXT_GET_MANUFACTURER_INFO
Get_Manufacturer_Info Message.
Definition usbc_pd.h:1006
@ PD_EXT_SECURITY_RESPONSE
Security_Response Message.
Definition usbc_pd.h:1012
@ PD_EXT_COUNTRY_CODES
Country_Info Message.
Definition usbc_pd.h:1022
@ PD_EXT_BATTERY_CAP
Battery_Capabilities Message.
Definition usbc_pd.h:1004
@ FRS_DEFAULT_USB_POWER
Default USB Power.
Definition usbc_pd.h:463
@ FRS_3P0A_5V
3.0A @ 5V
Definition usbc_pd.h:467
@ FRS_1P5A_5V
1.5A @ 5V
Definition usbc_pd.h:465
@ FRS_NOT_SUPPORTED
Fast Swap not supported.
Definition usbc_pd.h:461
@ PD_CTRL_DATA_RESET
Used for REV 3.0.
Definition usbc_pd.h:937
@ PD_CTRL_FR_SWAP
FR_Swap Message.
Definition usbc_pd.h:947
@ PD_CTRL_GET_STATUS
Get_Status Message.
Definition usbc_pd.h:945
@ PD_CTRL_DATA_RESET_COMPLETE
Data_Reset_Complete Message.
Definition usbc_pd.h:939
@ PD_CTRL_WAIT
Wait Message.
Definition usbc_pd.h:930
@ PD_CTRL_DR_SWAP
DR_Swap Message.
Definition usbc_pd.h:924
@ PD_CTRL_GOTO_MIN
GotoMin Message.
Definition usbc_pd.h:910
@ PD_CTRL_ACCEPT
Accept Message.
Definition usbc_pd.h:912
@ PD_CTRL_GET_COUNTRY_CODES
Get_Country_Codes Message.
Definition usbc_pd.h:951
@ PD_CTRL_VCONN_SWAP
VCONN_Swap Message.
Definition usbc_pd.h:928
@ PD_CTRL_PING
Ping Message.
Definition usbc_pd.h:916
@ PD_CTRL_GET_SOURCE_CAP
Get_Source_Cap Message.
Definition usbc_pd.h:920
@ PD_CTRL_REJECT
Reject Message.
Definition usbc_pd.h:914
@ PD_CTRL_GET_SINK_CAP_EXT
Get_Sink_Cap_Extended Message.
Definition usbc_pd.h:953
@ PD_CTRL_GET_SINK_CAP
Get_Sink_Cap Message.
Definition usbc_pd.h:922
@ PD_CTRL_GET_SOURCE_CAP_EXT
Get_Source_Cap_Extended Message.
Definition usbc_pd.h:943
@ PD_CTRL_GET_PPS_STATUS
Get_PPS_Status Message.
Definition usbc_pd.h:949
@ PD_CTRL_NOT_SUPPORTED
Not_Supported Message.
Definition usbc_pd.h:941
@ PD_CTRL_PR_SWAP
PR_Swap Message.
Definition usbc_pd.h:926
@ PD_CTRL_SOFT_RESET
Soft Reset Message.
Definition usbc_pd.h:932
@ PD_CTRL_GOOD_CRC
0 Reserved
Definition usbc_pd.h:908
@ PD_CTRL_PS_RDY
PS_RDY Message.
Definition usbc_pd.h:918
@ PD_DATA_ENTER_USB
8-14 Reserved for REV 3.0
Definition usbc_pd.h:983
@ PD_DATA_SINK_CAP
Sink Capabilities Message.
Definition usbc_pd.h:972
@ PD_DATA_BIST
BIST Message.
Definition usbc_pd.h:970
@ PD_DATA_ALERT
Alert Message.
Definition usbc_pd.h:976
@ PD_DATA_GET_COUNTRY_INFO
Get Country Info Message.
Definition usbc_pd.h:978
@ PD_DATA_VENDOR_DEF
Vendor Defined Message.
Definition usbc_pd.h:985
@ PD_DATA_BATTERY_STATUS
5-14 Reserved for REV 2.0
Definition usbc_pd.h:974
@ PD_DATA_SOURCE_CAP
0 Reserved
Definition usbc_pd.h:966
@ PD_DATA_REQUEST
Request Message.
Definition usbc_pd.h:968
@ PD_REV10
PD revision 1.0.
Definition usbc_pd.h:861
@ PD_REV20
PD revision 2.0.
Definition usbc_pd.h:863
@ PD_REV30
PD revision 3.0.
Definition usbc_pd.h:865
@ PD_PACKET_SOP
Port Partner message.
Definition usbc_pd.h:875
@ PD_PACKET_DEBUG_PRIME_PRIME
Currently undefined in the PD specification.
Definition usbc_pd.h:883
@ PD_PACKET_CABLE_RESET
Cable Reset message to the Cable.
Definition usbc_pd.h:887
@ PD_PACKET_MSG_INVALID
USED ONLY FOR RECEPTION OF UNKNOWN MSG TYPES.
Definition usbc_pd.h:892
@ PD_PACKET_PRIME_PRIME
Cable Plug message far end.
Definition usbc_pd.h:879
@ PD_PACKET_DEBUG_PRIME
Currently undefined in the PD specification.
Definition usbc_pd.h:881
@ PD_PACKET_TX_HARD_RESET
Hard Reset message to the Port Partner.
Definition usbc_pd.h:885
@ PD_PACKET_SOP_PRIME
Cable Plug message.
Definition usbc_pd.h:877
@ PD_PACKET_TX_BIST_MODE_2
BIST_MODE_2 message to the Port Partner.
Definition usbc_pd.h:889
@ USBPD_CC_PIN_2
PD is active on CC2.
Definition usbc_pd.h:1034
@ USBPD_CC_PIN_1
PD is active on CC1.
Definition usbc_pd.h:1032
__UINT32_TYPE__ uint32_t
Definition stdint.h:90
__UINT8_TYPE__ uint8_t
Definition stdint.h:88
__UINT16_TYPE__ uint16_t
Definition stdint.h:89
Power Delivery message.
Definition usbc_pd.h:1040
uint32_t len
Length of bytes in data.
Definition usbc_pd.h:1046
uint8_t data[260]
Message data.
Definition usbc_pd.h:1048
union pd_header header
Header of this message.
Definition usbc_pd.h:1044
enum pd_packet_type type
Type of this packet.
Definition usbc_pd.h:1042
Create Augmented Supply PDO Sink value See Table 6-17 Programmable Power Supply APDO - Sink.
Definition usbc_pd.h:698
uint32_t max_current
Maximum Current in 50mA increments.
Definition usbc_pd.h:701
uint32_t reserved3
00b – Programmable Power Supply 01b…11b - Reserved, Shall Not be used Setting as reserved because it ...
Definition usbc_pd.h:717
uint32_t reserved1
Reserved – Shall be set to zero.
Definition usbc_pd.h:707
uint32_t reserved0
Reserved – Shall be set to zero.
Definition usbc_pd.h:703
uint32_t min_voltage
Minimum Voltage in 100mV increments.
Definition usbc_pd.h:705
enum pdo_type type
Augmented Power Data Object (APDO).
Definition usbc_pd.h:719
uint32_t reserved2
Reserved – Shall be set to zero.
Definition usbc_pd.h:711
uint32_t raw_value
Raw PDO value.
Definition usbc_pd.h:722
uint32_t max_voltage
Maximum Voltage in 100mV increments.
Definition usbc_pd.h:709
Create Augmented Supply PDO Source value See Table 6-13 Programmable Power Supply APDO - Source.
Definition usbc_pd.h:665
uint32_t raw_value
Raw PDO value.
Definition usbc_pd.h:691
uint32_t min_voltage
Minimum Voltage in 100mV increments.
Definition usbc_pd.h:672
uint32_t max_current
Maximum Current in 50mA increments.
Definition usbc_pd.h:668
uint32_t reserved3
00b – Programmable Power Supply 01b…11b - Reserved, Shall Not be used Setting as reserved because it ...
Definition usbc_pd.h:686
enum pdo_type type
Augmented Power Data Object (APDO).
Definition usbc_pd.h:688
uint32_t reserved2
Reserved – Shall be set to zero.
Definition usbc_pd.h:678
uint32_t max_voltage
Maximum Voltage in 100mV increments.
Definition usbc_pd.h:676
uint32_t pps_power_limited
PPS Power Limited.
Definition usbc_pd.h:680
uint32_t reserved0
Reserved – Shall be set to zero.
Definition usbc_pd.h:670
uint32_t reserved1
Reserved – Shall be set to zero.
Definition usbc_pd.h:674
Create a Battery Supply PDO Sink value See Table 6-16 Battery Supply PDO - Sink.
Definition usbc_pd.h:618
uint32_t operational_power
Operational Power in 250mW units.
Definition usbc_pd.h:621
uint32_t min_voltage
Minimum Voltage in 50mV units.
Definition usbc_pd.h:623
uint32_t max_voltage
Maximum Voltage in 50mV units.
Definition usbc_pd.h:625
uint32_t raw_value
Raw PDO value.
Definition usbc_pd.h:630
enum pdo_type type
Battery supply.
Definition usbc_pd.h:627
Create a Battery Supply PDO Source value See Table 6-12 Battery Supply PDO - Source.
Definition usbc_pd.h:599
uint32_t max_power
Maximum Allowable Power in 250mW units.
Definition usbc_pd.h:602
uint32_t raw_value
Raw PDO value.
Definition usbc_pd.h:611
uint32_t max_voltage
Maximum Voltage in 50mV units.
Definition usbc_pd.h:606
enum pdo_type type
Battery supply.
Definition usbc_pd.h:608
uint32_t min_voltage
Minimum Voltage in 50mV units.
Definition usbc_pd.h:604
Create a Fixed Supply PDO Sink value See Table 6-14 Fixed Supply PDO - Sink.
Definition usbc_pd.h:474
uint32_t usb_comms_capable
USB Communications Capable.
Definition usbc_pd.h:487
uint32_t reserved0
Reserved – Shall be set to zero.
Definition usbc_pd.h:481
uint32_t operational_current
Operational Current in 10mA units.
Definition usbc_pd.h:477
uint32_t higher_capability
Higher Capability.
Definition usbc_pd.h:491
uint32_t dual_role_data
Dual-Role Data.
Definition usbc_pd.h:485
enum pd_frs_type frs_required
Fast Role Swap required USB Type-C Current.
Definition usbc_pd.h:483
uint32_t dual_role_power
Dual-Role Power.
Definition usbc_pd.h:493
uint32_t unconstrained_power
Unconstrained Power.
Definition usbc_pd.h:489
uint32_t voltage
Voltage in 50mV units.
Definition usbc_pd.h:479
enum pdo_type type
Fixed supply.
Definition usbc_pd.h:495
uint32_t raw_value
Raw PDO value.
Definition usbc_pd.h:498
Create a Fixed Supply PDO Source value See Table 6-9 Fixed Supply PDO - Source.
Definition usbc_pd.h:427
enum pdo_type type
Fixed supply.
Definition usbc_pd.h:450
uint32_t peak_current
Peak Current.
Definition usbc_pd.h:434
uint32_t unchunked_ext_msg_supported
Unchunked Extended Messages Supported.
Definition usbc_pd.h:438
uint32_t usb_suspend_supported
USB Suspend Supported.
Definition usbc_pd.h:446
uint32_t voltage
Voltage in 50mV units.
Definition usbc_pd.h:432
uint32_t reserved0
Reserved – Shall be set to zero.
Definition usbc_pd.h:436
uint32_t usb_comms_capable
USB Communications Capable.
Definition usbc_pd.h:442
uint32_t dual_role_data
Dual-Role Data.
Definition usbc_pd.h:440
uint32_t max_current
Maximum Current in 10mA units.
Definition usbc_pd.h:430
uint32_t raw_value
Raw PDO value.
Definition usbc_pd.h:453
uint32_t unconstrained_power
Unconstrained Power.
Definition usbc_pd.h:444
uint32_t dual_role_power
Dual-Role Power.
Definition usbc_pd.h:448
The Request Data Object (RDO) Shall be returned by the Sink making a request for power.
Definition usbc_pd.h:730
struct pd_rdo::@272 fixed
Create a Fixed RDO value See Table 6-19 Fixed and Variable Request Data Object.
uint32_t usb_comm_capable
USB Communications Capable.
Definition usbc_pd.h:753
uint32_t min_or_max_operating_current
Operating Current 10mA units NOTE: If Give Back Flag is zero, this field is the Maximum Operating Cur...
Definition usbc_pd.h:743
uint32_t raw_value
Raw RDO value.
Definition usbc_pd.h:853
uint32_t reserved2
Reserved - Shall be set to zero.
Definition usbc_pd.h:846
uint32_t operating_power
Operating power in 250mW units.
Definition usbc_pd.h:805
struct pd_rdo::@275 augmented
Create an Augmented RDO value See Table 6-22 Programmable Request Data Object.
uint32_t operating_current
Operating current in 10mA units.
Definition usbc_pd.h:745
uint32_t reserved3
Reserved - Shall be set to zero.
Definition usbc_pd.h:850
uint32_t reserved1
Reserved - Shall be set to zero.
Definition usbc_pd.h:761
struct pd_rdo::@274 battery
Create a Battery RDO value See Table 6-20 Battery Request Data Object.
uint32_t reserved0
Reserved - Shall be set to zero.
Definition usbc_pd.h:747
uint32_t min_operating_power
Minimum Operating Power in 250mW units.
Definition usbc_pd.h:803
struct pd_rdo::@273 variable
Create a Variable RDO value See Table 6-19 Fixed and Variable Request Data Object.
uint32_t output_voltage
Output Voltage in 20mV units.
Definition usbc_pd.h:834
uint32_t giveback
Give Back Flag.
Definition usbc_pd.h:757
uint32_t unchunked_ext_msg_supported
Unchunked Extended Messages Supported.
Definition usbc_pd.h:749
uint32_t no_usb_suspend
No USB Suspend.
Definition usbc_pd.h:751
uint32_t cap_mismatch
Capability Mismatch.
Definition usbc_pd.h:755
uint32_t object_pos
Object Position (000b is Reserved and Shall Not be used)
Definition usbc_pd.h:759
Create a Variable Supply PDO Sink value See Table 6-15 Variable Supply (non-Battery) PDO - Sink.
Definition usbc_pd.h:552
uint32_t raw_value
Raw PDO value.
Definition usbc_pd.h:564
enum pdo_type type
Variable supply.
Definition usbc_pd.h:561
uint32_t min_voltage
Minimum Voltage in 50mV units.
Definition usbc_pd.h:557
uint32_t operational_current
operational Current in 10mA units
Definition usbc_pd.h:555
uint32_t max_voltage
Maximum Voltage in 50mV units.
Definition usbc_pd.h:559
Create a Variable Supply PDO Source value See Table 6-11 Variable Supply (non-Battery) PDO - Source.
Definition usbc_pd.h:533
uint32_t max_voltage
Maximum Voltage in 50mV units.
Definition usbc_pd.h:540
enum pdo_type type
Variable supply.
Definition usbc_pd.h:542
uint32_t min_voltage
Minimum Voltage in 50mV units.
Definition usbc_pd.h:538
uint32_t max_current
Maximum Current in 10mA units.
Definition usbc_pd.h:536
uint32_t raw_value
Raw PDO value.
Definition usbc_pd.h:545