16#ifndef ZEPHYR_INCLUDE_DRIVERS_USB_C_USBC_TCPC_H_
17#define ZEPHYR_INCLUDE_DRIVERS_USB_C_USBC_TCPC_H_
213 const struct device *usbc_dev);
221 const struct device *usbc_dev);
527 __ASSERT(api->
init !=
NULL,
"Callback pointer should not be NULL");
529 return api->
init(dev);
552 return api->
get_cc(dev, cc1, cc2);
610 __ASSERT(api->
set_cc !=
NULL,
"Callback pointer should not be NULL");
612 return api->
set_cc(dev, pull);
627 const struct device *usbc_dev)
649 const struct device *usbc_dev)
728 return api->
set_roles(dev, power_role, data_role);
irp cc
Definition asm-macro-32-bit-gnu.h:13
#define DEVICE_API_GET(_class, _dev)
Expands to the pointer of a device's API for a given class.
Definition device.h:1449
#define ENOSYS
Function not implemented.
Definition errno.h:83
static int tcpc_clear_status_register(const struct device *dev, enum tcpc_status_reg reg, uint32_t mask)
Clears a TCPC status register.
Definition usbc_tcpc.h:892
static int tcpc_set_debug_accessory(const struct device *dev, bool enable)
Manual control of TCPC DebugAccessory control.
Definition usbc_tcpc.h:938
int(* tcpc_api_get_status_register_t)(const struct device *dev, enum tcpc_status_reg reg, uint32_t *status)
Callback API to get a status register.
Definition usbc_tcpc.h:285
static int tcpc_is_cc_src_dbg_acc(enum tc_cc_voltage_state cc1, enum tc_cc_voltage_state cc2)
Returns true if we detect the port partner is a src debug accessory.
Definition usbc_tcpc.h:484
static int tcpc_get_src_ctrl(const struct device *dev)
Queries the current sourcing state of the TCPC.
Definition usbc_tcpc.h:1038
int(* tcpc_vconn_control_cb_t)(const struct device *tcpc_dev, const struct device *usbc_dev, enum tc_cc_polarity pol, bool enable)
Callback type for VCONN control.
Definition usbc_tcpc.h:136
static int tcpc_get_snk_ctrl(const struct device *dev)
Queries the current sinking state of the TCPC.
Definition usbc_tcpc.h:999
static int tcpc_mask_status_register(const struct device *dev, enum tcpc_status_reg reg, uint32_t mask)
Sets the mask of a TCPC status register.
Definition usbc_tcpc.h:916
static int tcpc_is_cc_open(enum tc_cc_voltage_state cc1, enum tc_cc_voltage_state cc2)
Returns true if both CC lines are completely open.
Definition usbc_tcpc.h:468
static int tcpc_is_cc_audio_acc(enum tc_cc_voltage_state cc1, enum tc_cc_voltage_state cc2)
Returns true if the port partner is an audio accessory.
Definition usbc_tcpc.h:492
static void tcpc_set_vconn_cb(const struct device *dev, tcpc_vconn_control_cb_t vconn_cb, const struct device *usbc_dev)
Sets a callback that can enable or disable VCONN if the TCPC is unable to or the system is configured...
Definition usbc_tcpc.h:626
int(* tcpc_api_sop_prime_enable_t)(const struct device *dev, bool enable)
Callback API to enable or disable SOP' / SOP'' reception.
Definition usbc_tcpc.h:372
int(* tcpc_api_set_debug_accessory_t)(const struct device *dev, bool enable)
Callback API to enable or disable debug accessory control.
Definition usbc_tcpc.h:309
static int tcpc_set_vconn(const struct device *dev, bool enable)
Enables or disables VCONN.
Definition usbc_tcpc.h:695
static int tcpc_get_rp_value(const struct device *dev, enum tc_rp_value *rp)
Gets the value of the CC pull up resistor used when operating as a Source.
Definition usbc_tcpc.h:586
void(* tcpc_api_set_vconn_cb_t)(const struct device *dev, tcpc_vconn_control_cb_t vconn_cb, const struct device *usbc_dev)
Callback API to register the VCONN control application callback.
Definition usbc_tcpc.h:220
int(* tcpc_api_get_src_ctrl_t)(const struct device *dev)
Callback API to query VBUS source control state.
Definition usbc_tcpc.h:344
static int tcpc_get_rx_pending_msg(const struct device *dev, struct pd_msg *buf)
Retrieves the Power Delivery message from the TCPC.
Definition usbc_tcpc.h:744
static int tcpc_vconn_discharge(const struct device *dev, bool enable)
Discharges VCONN.
Definition usbc_tcpc.h:671
static int tcpc_select_rp_value(const struct device *dev, enum tc_rp_value rp)
Sets the value of CC pull up resistor used when operating as a Source.
Definition usbc_tcpc.h:565
int(* tcpc_api_get_cc_t)(const struct device *dev, enum tc_cc_voltage_state *cc1, enum tc_cc_voltage_state *cc2)
Callback API to read CC line status.
Definition usbc_tcpc.h:182
tcpc_alert
TCPC Alert bits.
Definition usbc_tcpc.h:42
int(* tcpc_api_set_debug_detach_t)(const struct device *dev)
Callback API to detach from a debug connection.
Definition usbc_tcpc.h:316
int(* tcpc_vconn_discharge_cb_t)(const struct device *tcpc_dev, const struct device *usbc_dev, enum tc_cc_polarity pol, bool enable)
Callback type for discharging VCONN.
Definition usbc_tcpc.h:150
int(* tcpc_api_set_alert_handler_cb_t)(const struct device *dev, tcpc_alert_handler_cb_t handler, void *data)
Callback API to register the alert application callback.
Definition usbc_tcpc.h:386
static int tcpc_set_cc_polarity(const struct device *dev, enum tc_cc_polarity polarity)
Sets the polarity of the CC lines.
Definition usbc_tcpc.h:784
int(* tcpc_api_set_drp_toggle_t)(const struct device *dev, bool enable)
Callback API to enable or disable DRP toggle.
Definition usbc_tcpc.h:323
void(* tcpc_alert_handler_cb_t)(const struct device *dev, void *data, enum tcpc_alert alert)
Callback type for handling TCPC alert events.
Definition usbc_tcpc.h:161
static int tcpc_get_cc(const struct device *dev, enum tc_cc_voltage_state *cc1, enum tc_cc_voltage_state *cc2)
Reads the status of the CC lines.
Definition usbc_tcpc.h:543
static int tcpc_is_cc_rp(enum tc_cc_voltage_state cc)
Returns whether the sink has detected a Rp resistor on the other side.
Definition usbc_tcpc.h:460
static void tcpc_set_vconn_discharge_cb(const struct device *dev, tcpc_vconn_discharge_cb_t cb, const struct device *usbc_dev)
Sets a callback that can enable or discharge VCONN if the TCPC is unable to or the system is configur...
Definition usbc_tcpc.h:647
static int tcpc_set_alert_handler_cb(const struct device *dev, tcpc_alert_handler_cb_t handler, void *data)
Sets the alert function that's called when an interrupt is triggered due to an alert bit.
Definition usbc_tcpc.h:847
static int tcpc_set_snk_ctrl(const struct device *dev, bool enable)
Set the VBUS sinking state of the TCPC.
Definition usbc_tcpc.h:1018
int(* tcpc_api_set_rx_enable_t)(const struct device *dev, bool enable)
Callback API to enable or disable SOP* RX.
Definition usbc_tcpc.h:257
int(* tcpc_api_set_src_ctrl_t)(const struct device *dev, bool enable)
Callback API to enable or disable VBUS sourcing.
Definition usbc_tcpc.h:351
int(* tcpc_api_clear_status_register_t)(const struct device *dev, enum tcpc_status_reg reg, uint32_t mask)
Callback API to clear bits in a status register.
Definition usbc_tcpc.h:293
static int tcpc_get_chip_info(const struct device *dev, struct tcpc_chip_info *chip_info)
Gets the TCPC firmware version.
Definition usbc_tcpc.h:1100
static int tcpc_transmit_data(const struct device *dev, struct pd_msg *msg)
Transmits a Power Delivery message.
Definition usbc_tcpc.h:803
static int tcpc_set_roles(const struct device *dev, enum tc_power_role power_role, enum tc_data_role data_role)
Sets the Power and Data Role of the PD message header.
Definition usbc_tcpc.h:719
static int tcpc_set_src_ctrl(const struct device *dev, bool enable)
Set the VBUS sourcing state of the TCPC.
Definition usbc_tcpc.h:1057
static int tcpc_set_rx_enable(const struct device *dev, bool enable)
Enables the reception of SOP* message types.
Definition usbc_tcpc.h:764
static int tcpc_is_cc_only_one_rd(enum tc_cc_voltage_state cc1, enum tc_cc_voltage_state cc2)
Returns true if the port partner is presenting Rd on only one CC line.
Definition usbc_tcpc.h:509
static int tcpc_dump_std_reg(const struct device *dev)
Dump a set of TCPC registers.
Definition usbc_tcpc.h:823
static int tcpc_set_low_power_mode(const struct device *dev, bool enable)
Instructs the TCPC to enter or exit low power mode.
Definition usbc_tcpc.h:1121
int(* tcpc_api_dump_std_reg_t)(const struct device *dev)
Callback API to dump standard TCPC registers.
Definition usbc_tcpc.h:278
static int tcpc_set_drp_toggle(const struct device *dev, bool enable)
Enable TCPC auto dual role toggle.
Definition usbc_tcpc.h:979
static int tcpc_is_cc_snk_dbg_acc(enum tc_cc_voltage_state cc1, enum tc_cc_voltage_state cc2)
Returns true if we detect the port partner is a snk debug accessory.
Definition usbc_tcpc.h:476
int(* tcpc_api_mask_status_register_t)(const struct device *dev, enum tcpc_status_reg reg, uint32_t mask)
Callback API to mask or unmask status register bits.
Definition usbc_tcpc.h:301
int(* tcpc_api_set_cc_polarity_t)(const struct device *dev, enum tc_cc_polarity polarity)
Callback API to set CC polarity.
Definition usbc_tcpc.h:264
static int tcpc_set_debug_detach(const struct device *dev)
Detach from a debug connection.
Definition usbc_tcpc.h:958
int(* tcpc_api_set_snk_ctrl_t)(const struct device *dev, bool enable)
Callback API to enable or disable VBUS sinking.
Definition usbc_tcpc.h:337
int(* tcpc_api_get_rx_pending_msg_t)(const struct device *dev, struct pd_msg *msg)
Callback API to get a pending RX message or query RX status.
Definition usbc_tcpc.h:250
static int tcpc_sop_prime_enable(const struct device *dev, bool enable)
Enables the reception of SOP Prime and optionally SOP Double Prime messages.
Definition usbc_tcpc.h:1143
int(* tcpc_api_transmit_data_t)(const struct device *dev, struct pd_msg *msg)
Callback API to transmit a PD message.
Definition usbc_tcpc.h:271
static int tcpc_is_cc_at_least_one_rd(enum tc_cc_voltage_state cc1, enum tc_cc_voltage_state cc2)
Returns true if the port partner is presenting at least one Rd.
Definition usbc_tcpc.h:500
int(* tcpc_api_vconn_discharge_t)(const struct device *dev, bool enable)
Callback API to enable or disable VCONN discharge.
Definition usbc_tcpc.h:228
int(* tcpc_api_get_snk_ctrl_t)(const struct device *dev)
Callback API to query VBUS sink control state.
Definition usbc_tcpc.h:330
static int tcpc_init(const struct device *dev)
Initializes the TCPC.
Definition usbc_tcpc.h:523
int(* tcpc_api_set_cc_t)(const struct device *dev, enum tc_cc_pull pull)
Callback API to set CC pull and role.
Definition usbc_tcpc.h:204
static int tcpc_set_cc(const struct device *dev, enum tc_cc_pull pull)
Sets the CC pull resistor and sets the role as either Source or Sink.
Definition usbc_tcpc.h:606
int(* tcpc_api_get_chip_info_t)(const struct device *dev, struct tcpc_chip_info *chip_info)
Callback API to read TCPC chip information.
Definition usbc_tcpc.h:358
static int tcpc_set_bist_test_mode(const struct device *dev, bool enable)
Controls the BIST Mode of the TCPC.
Definition usbc_tcpc.h:1079
static int tcpc_get_status_register(const struct device *dev, enum tcpc_status_reg reg, uint32_t *status)
Gets a status register.
Definition usbc_tcpc.h:868
int(* tcpc_api_get_rp_value_t)(const struct device *dev, enum tc_rp_value *rp)
Callback API to get source Rp value.
Definition usbc_tcpc.h:197
void(* tcpc_api_set_vconn_discharge_cb_t)(const struct device *dev, tcpc_vconn_discharge_cb_t cb, const struct device *usbc_dev)
Callback API to register the VCONN discharge application callback.
Definition usbc_tcpc.h:211
int(* tcpc_api_set_roles_t)(const struct device *dev, enum tc_power_role power_role, enum tc_data_role data_role)
Callback API to set power and data roles for PD message header.
Definition usbc_tcpc.h:242
int(* tcpc_api_init_t)(const struct device *dev)
@def_driverbackendgroup{USB Type-C Port Controller,usb_type_c_port_controller_api}
Definition usbc_tcpc.h:175
int(* tcpc_api_set_low_power_mode_t)(const struct device *dev, bool enable)
Callback API to enter or exit low power mode.
Definition usbc_tcpc.h:365
int(* tcpc_api_select_rp_value_t)(const struct device *dev, enum tc_rp_value rp)
Callback API to set source Rp value.
Definition usbc_tcpc.h:190
int(* tcpc_api_set_bist_test_mode_t)(const struct device *dev, bool enable)
Callback API to enable or disable BIST test mode.
Definition usbc_tcpc.h:379
int(* tcpc_api_set_vconn_t)(const struct device *dev, bool enable)
Callback API to enable or disable VCONN.
Definition usbc_tcpc.h:235
tcpc_status_reg
TCPC Status register.
Definition usbc_tcpc.h:86
@ TCPC_ALERT_EXTENDED_STATUS
Extended status changed.
Definition usbc_tcpc.h:73
@ TCPC_ALERT_TRANSMIT_MSG_DISCARDED
Reset or SOP* message transmission not sent due to an incoming receive message.
Definition usbc_tcpc.h:57
@ TCPC_ALERT_CC_STATUS
CC status changed.
Definition usbc_tcpc.h:44
@ TCPC_ALERT_EXTENDED
An extended interrupt event has occurred.
Definition usbc_tcpc.h:78
@ TCPC_ALERT_BEGINNING_MSG_STATUS
Receive buffer register changed.
Definition usbc_tcpc.h:71
@ TCPC_ALERT_MSG_STATUS
Receive Buffer register changed.
Definition usbc_tcpc.h:48
@ TCPC_ALERT_HARD_RESET_RECEIVED
Received Hard Reset message.
Definition usbc_tcpc.h:50
@ TCPC_ALERT_TRANSMIT_MSG_SUCCESS
Reset or SOP* message transmission successful.
Definition usbc_tcpc.h:59
@ TCPC_ALERT_VBUS_ALARM_HI
A high-voltage alarm has occurred.
Definition usbc_tcpc.h:61
@ TCPC_ALERT_VBUS_SNK_DISCONNECT
The TCPC in Attached.SNK state has detected a sink disconnect.
Definition usbc_tcpc.h:69
@ TCPC_ALERT_POWER_STATUS
Power status changed.
Definition usbc_tcpc.h:46
@ TCPC_ALERT_VBUS_ALARM_LO
A low-voltage alarm has occurred.
Definition usbc_tcpc.h:63
@ TCPC_ALERT_VENDOR_DEFINED
A vendor defined alert has been detected.
Definition usbc_tcpc.h:80
@ TCPC_ALERT_FAULT_STATUS
A fault has occurred.
Definition usbc_tcpc.h:65
@ TCPC_ALERT_TRANSMIT_MSG_FAILED
SOP* message transmission not successful.
Definition usbc_tcpc.h:52
@ TCPC_ALERT_RX_BUFFER_OVERFLOW
TCPC RX buffer has overflowed.
Definition usbc_tcpc.h:67
@ TCPC_FAULT_STATUS
The Fault Status register.
Definition usbc_tcpc.h:94
@ TCPC_ALERT_STATUS
The Alert register.
Definition usbc_tcpc.h:88
@ TCPC_VENDOR_DEFINED_STATUS
The Vendor Defined Status register.
Definition usbc_tcpc.h:100
@ TCPC_EXTENDED_ALERT_STATUS
The Extended Alert Status register.
Definition usbc_tcpc.h:98
@ TCPC_POWER_STATUS
The Power Status register.
Definition usbc_tcpc.h:92
@ TCPC_CC_STATUS
The CC Status register.
Definition usbc_tcpc.h:90
@ TCPC_EXTENDED_STATUS
The Extended Status register.
Definition usbc_tcpc.h:96
tc_cc_pull
CC pull resistors.
Definition usbc_tc.h:369
tc_rp_value
Pull-Up resistor values.
Definition usbc_tc.h:355
tc_cc_voltage_state
CC Voltage status.
Definition usbc_tc.h:325
tc_data_role
Power Delivery Data Role.
Definition usbc_tc.h:423
tc_power_role
Power Delivery Power Role.
Definition usbc_tc.h:413
tc_cc_polarity
Polarity of the CC lines.
Definition usbc_tc.h:435
@ TC_CC_VOLT_RP_DEF
Port partner is applying Rp (0.5A).
Definition usbc_tc.h:333
@ TC_CC_VOLT_RA
Port partner is applying Ra.
Definition usbc_tc.h:329
@ TC_CC_VOLT_RD
Port partner is applying Rd.
Definition usbc_tc.h:331
@ TC_CC_VOLT_RP_3A0
Port partner is applying Rp (3.0A).
Definition usbc_tc.h:337
@ TC_CC_VOLT_RP_1A5
Port partner is applying Rp (1.5A).
Definition usbc_tc.h:335
#define NULL
Definition iar_missing_defs.h:20
__UINT32_TYPE__ uint32_t
Definition stdint.h:90
__UINT64_TYPE__ uint64_t
Definition stdint.h:91
__UINT8_TYPE__ uint8_t
Definition stdint.h:88
__UINT16_TYPE__ uint16_t
Definition stdint.h:89
Runtime device structure (in ROM) per driver instance.
Definition device.h:513
void * data
Address of the device instance private data.
Definition device.h:523
Power Delivery message.
Definition usbc_pd.h:1052
TCPC Chip Information.
Definition usbc_tcpc.h:106
uint16_t product_id
Product Id.
Definition usbc_tcpc.h:110
uint8_t min_req_fw_version_string[8]
Minimum Required firmware version string.
Definition usbc_tcpc.h:119
uint64_t fw_version_number
Firmware version number.
Definition usbc_tcpc.h:114
uint64_t min_req_fw_version_number
Minimum Required firmware version number.
Definition usbc_tcpc.h:121
uint16_t device_id
Device Id.
Definition usbc_tcpc.h:112
uint16_t vendor_id
Vendor Id.
Definition usbc_tcpc.h:108
@driver_ops{USB Type-C Port Controller}
Definition usbc_tcpc.h:392
tcpc_api_set_vconn_cb_t set_vconn_cb
@driver_ops_mandatory Sets a callback that can enable or disable VCONN if the TCPC is unable to or ...
Definition usbc_tcpc.h:406
tcpc_api_set_cc_polarity_t set_cc_polarity
@driver_ops_mandatory Sets the polarity of the CC lines.
Definition usbc_tcpc.h:418
tcpc_api_dump_std_reg_t dump_std_reg
@driver_ops_optional Dump a set of TCPC registers.
Definition usbc_tcpc.h:422
tcpc_api_get_rx_pending_msg_t get_rx_pending_msg
@driver_ops_mandatory Retrieves the Power Delivery message from the TCPC.
Definition usbc_tcpc.h:414
tcpc_api_set_low_power_mode_t set_low_power_mode
@driver_ops_optional Instructs the TCPC to enter or exit low power mode.
Definition usbc_tcpc.h:446
tcpc_api_set_drp_toggle_t set_drp_toggle
@driver_ops_optional Enable TCPC auto dual role toggle.
Definition usbc_tcpc.h:434
tcpc_api_select_rp_value_t select_rp_value
@driver_ops_optional Sets the value of CC pull up resistor used when operating as a Source.
Definition usbc_tcpc.h:398
tcpc_api_get_rp_value_t get_rp_value
@driver_ops_optional Gets the value of the CC pull up resistor used when operating as a Source.
Definition usbc_tcpc.h:400
tcpc_api_set_vconn_t set_vconn
@driver_ops_optional Enables or disables VCONN.
Definition usbc_tcpc.h:410
tcpc_api_set_cc_t set_cc
@driver_ops_mandatory Sets the CC pull resistor and sets the role as either Source or Sink.
Definition usbc_tcpc.h:402
tcpc_api_get_snk_ctrl_t get_snk_ctrl
@driver_ops_optional Queries the current sinking state of the TCPC.
Definition usbc_tcpc.h:436
tcpc_api_set_src_ctrl_t set_src_ctrl
@driver_ops_optional Set the VBUS sourcing state of the TCPC.
Definition usbc_tcpc.h:442
tcpc_api_get_chip_info_t get_chip_info
@driver_ops_optional Gets the TCPC firmware version.
Definition usbc_tcpc.h:444
tcpc_api_set_debug_detach_t set_debug_detach
@driver_ops_optional Detach from a debug connection.
Definition usbc_tcpc.h:432
tcpc_api_get_src_ctrl_t get_src_ctrl
@driver_ops_optional Queries the current sourcing state of the TCPC.
Definition usbc_tcpc.h:440
tcpc_api_set_alert_handler_cb_t set_alert_handler_cb
@driver_ops_mandatory Sets the alert function that's called when an interrupt is triggered due to a...
Definition usbc_tcpc.h:452
tcpc_api_sop_prime_enable_t sop_prime_enable
@driver_ops_optional Enables the reception of SOP Prime and optionally SOP Double Prime messages.
Definition usbc_tcpc.h:448
tcpc_api_transmit_data_t transmit_data
@driver_ops_optional Transmits a Power Delivery message.
Definition usbc_tcpc.h:420
tcpc_api_set_debug_accessory_t set_debug_accessory
@driver_ops_optional Manual control of TCPC DebugAccessory control.
Definition usbc_tcpc.h:430
tcpc_api_get_status_register_t get_status_register
@driver_ops_optional Gets a status register.
Definition usbc_tcpc.h:424
tcpc_api_set_bist_test_mode_t set_bist_test_mode
@driver_ops_optional Controls the BIST Mode of the TCPC.
Definition usbc_tcpc.h:450
tcpc_api_set_rx_enable_t set_rx_enable
@driver_ops_optional Enables the reception of SOP* message types.
Definition usbc_tcpc.h:416
tcpc_api_set_snk_ctrl_t set_snk_ctrl
@driver_ops_optional Set the VBUS sinking state of the TCPC.
Definition usbc_tcpc.h:438
tcpc_api_mask_status_register_t mask_status_register
@driver_ops_optional Sets the mask of a TCPC status register.
Definition usbc_tcpc.h:428
tcpc_api_vconn_discharge_t vconn_discharge
@driver_ops_optional Discharges VCONN.
Definition usbc_tcpc.h:408
tcpc_api_init_t init
@driver_ops_mandatory Initializes the TCPC.
Definition usbc_tcpc.h:394
tcpc_api_set_roles_t set_roles
@driver_ops_optional Sets the Power and Data Role of the PD message header.
Definition usbc_tcpc.h:412
tcpc_api_clear_status_register_t clear_status_register
@driver_ops_optional Clears a TCPC status register.
Definition usbc_tcpc.h:426
tcpc_api_set_vconn_discharge_cb_t set_vconn_discharge_cb
@driver_ops_mandatory Sets a callback that can enable or discharge VCONN if the TCPC is unable to o...
Definition usbc_tcpc.h:404
tcpc_api_get_cc_t get_cc
@driver_ops_optional Reads the status of the CC lines.
Definition usbc_tcpc.h:396
USB-C Power Delivery API used for USB-C drivers.
USB Type-C Cable and Connector API used for USB-C drivers.