Zephyr API Documentation 4.0.0-rc2
A Scalable Open Source RTOS
|
USB Type-C Port Controller API . More...
Data Structures | |
struct | tcpc_chip_info |
TCPC Chip Information. More... | |
struct | tcpc_driver_api |
Typedefs | |
typedef int(* | tcpc_vconn_control_cb_t) (const struct device *dev, enum tc_cc_polarity pol, bool enable) |
typedef int(* | tcpc_vconn_discharge_cb_t) (const struct device *dev, enum tc_cc_polarity pol, bool enable) |
typedef void(* | tcpc_alert_handler_cb_t) (const struct device *dev, void *data, enum tcpc_alert alert) |
Functions | |
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. | |
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. | |
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. | |
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. | |
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. | |
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. | |
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. | |
static int | tcpc_init (const struct device *dev) |
Initializes the TCPC. | |
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. | |
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. | |
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. | |
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. | |
static void | tcpc_set_vconn_cb (const struct device *dev, tcpc_vconn_control_cb_t vconn_cb) |
Sets a callback that can enable or disable VCONN if the TCPC is unable to or the system is configured in a way that does not use the VCONN control capabilities of the TCPC. | |
static void | tcpc_set_vconn_discharge_cb (const struct device *dev, tcpc_vconn_discharge_cb_t cb) |
Sets a callback that can enable or discharge VCONN if the TCPC is unable to or the system is configured in a way that does not use the VCONN control capabilities of the TCPC. | |
static int | tcpc_vconn_discharge (const struct device *dev, bool enable) |
Discharges VCONN. | |
static int | tcpc_set_vconn (const struct device *dev, bool enable) |
Enables or disables VCONN. | |
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. | |
static int | tcpc_get_rx_pending_msg (const struct device *dev, struct pd_msg *buf) |
Retrieves the Power Delivery message from the TCPC. | |
static int | tcpc_set_rx_enable (const struct device *dev, bool enable) |
Enables the reception of SOP* message types. | |
static int | tcpc_set_cc_polarity (const struct device *dev, enum tc_cc_polarity polarity) |
Sets the polarity of the CC lines. | |
static int | tcpc_transmit_data (const struct device *dev, struct pd_msg *msg) |
Transmits a Power Delivery message. | |
static int | tcpc_dump_std_reg (const struct device *dev) |
Dump a set of TCPC registers. | |
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. | |
static int | tcpc_get_status_register (const struct device *dev, enum tcpc_status_reg reg, int32_t *status) |
Gets a status register. | |
static int | tcpc_clear_status_register (const struct device *dev, enum tcpc_status_reg reg, uint32_t mask) |
Clears a TCPC status register. | |
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. | |
static int | tcpc_set_debug_accessory (const struct device *dev, bool enable) |
Manual control of TCPC DebugAccessory control. | |
static int | tcpc_set_debug_detach (const struct device *dev) |
Detach from a debug connection. | |
static int | tcpc_set_drp_toggle (const struct device *dev, bool enable) |
Enable TCPC auto dual role toggle. | |
static int | tcpc_get_snk_ctrl (const struct device *dev) |
Queries the current sinking state of the TCPC. | |
static int | tcpc_set_snk_ctrl (const struct device *dev, bool enable) |
Set the VBUS sinking state of the TCPC. | |
static int | tcpc_get_src_ctrl (const struct device *dev) |
Queries the current sourcing state of the TCPC. | |
static int | tcpc_set_src_ctrl (const struct device *dev, bool enable) |
Set the VBUS sourcing state of the TCPC. | |
static int | tcpc_set_bist_test_mode (const struct device *dev, bool enable) |
Controls the BIST Mode of the TCPC. | |
static int | tcpc_get_chip_info (const struct device *dev, struct tcpc_chip_info *chip_info) |
Gets the TCPC firmware version. | |
static int | tcpc_set_low_power_mode (const struct device *dev, bool enable) |
Instructs the TCPC to enter or exit low power mode. | |
static int | tcpc_sop_prime_enable (const struct device *dev, bool enable) |
Enables the reception of SOP Prime messages. | |
USB Type-C Port Controller API .
typedef void(* tcpc_alert_handler_cb_t) (const struct device *dev, void *data, enum tcpc_alert alert) |
#include <zephyr/drivers/usb_c/usbc_tcpc.h>
typedef int(* tcpc_vconn_control_cb_t) (const struct device *dev, enum tc_cc_polarity pol, bool enable) |
#include <zephyr/drivers/usb_c/usbc_tcpc.h>
typedef int(* tcpc_vconn_discharge_cb_t) (const struct device *dev, enum tc_cc_polarity pol, bool enable) |
#include <zephyr/drivers/usb_c/usbc_tcpc.h>
enum tcpc_alert |
#include <zephyr/drivers/usb_c/usbc_tcpc.h>
TCPC Alert bits.
enum tcpc_status_reg |
#include <zephyr/drivers/usb_c/usbc_tcpc.h>
TCPC Status register.
|
inlinestatic |
#include <zephyr/drivers/usb_c/usbc_tcpc.h>
Clears a TCPC status register.
dev | Runtime device structure |
reg | The status register to read |
mask | A bit mask of the status register to clear. A status bit is cleared when it's set to 1. |
0 | on success |
-EIO | on failure |
-ENOSYS | if not implemented |
|
inlinestatic |
#include <zephyr/drivers/usb_c/usbc_tcpc.h>
Dump a set of TCPC registers.
dev | Runtime device structure |
0 | on success |
-EIO | on failure |
-ENOSYS | if not implemented |
|
inlinestatic |
#include <zephyr/drivers/usb_c/usbc_tcpc.h>
Reads the status of the CC lines.
dev | Runtime device structure |
cc1 | A pointer where the CC1 status is written |
cc2 | A pointer where the CC2 status is written |
0 | on success |
-EIO | on failure |
-ENOSYS | if not implemented |
|
inlinestatic |
#include <zephyr/drivers/usb_c/usbc_tcpc.h>
Gets the TCPC firmware version.
dev | Runtime device structure |
chip_info | Pointer to TCPC chip info where the version is stored |
0 | on success |
-EIO | on failure |
-ENOSYS | if not implemented |
|
inlinestatic |
#include <zephyr/drivers/usb_c/usbc_tcpc.h>
Gets the value of the CC pull up resistor used when operating as a Source.
dev | Runtime device structure |
rp | pointer where the value of the Pull-Up Resistor is stored |
0 | on success |
-ENOSYS | |
-EIO | on failure |
#include <zephyr/drivers/usb_c/usbc_tcpc.h>
Retrieves the Power Delivery message from the TCPC.
If buf is NULL, then only the status is returned, where 0 means there is a message pending and -ENODATA means there is no pending message.
dev | Runtime device structure |
buf | pointer where the pd_buf pointer is written, NULL if only checking the status |
Greater | or equal to 0 is the number of bytes received if buf parameter is provided |
0 | if there is a message pending and buf parameter is NULL |
-EIO | on failure |
-ENODATA | if no message is pending |
|
inlinestatic |
#include <zephyr/drivers/usb_c/usbc_tcpc.h>
Queries the current sinking state of the TCPC.
dev | Runtime device structure |
true | if sinking power |
false | if not sinking power |
-ENOSYS | if not implemented |
|
inlinestatic |
#include <zephyr/drivers/usb_c/usbc_tcpc.h>
Queries the current sourcing state of the TCPC.
dev | Runtime device structure |
true | if sourcing power |
false | if not sourcing power |
-ENOSYS | if not implemented |
|
inlinestatic |
#include <zephyr/drivers/usb_c/usbc_tcpc.h>
Gets a status register.
dev | Runtime device structure |
reg | The status register to read |
status | Pointer where the status is stored |
0 | on success |
-EIO | on failure |
-ENOSYS | if not implemented |
|
inlinestatic |
#include <zephyr/drivers/usb_c/usbc_tcpc.h>
Initializes the TCPC.
dev | Runtime device structure |
0 | on success |
-EIO | on failure |
-EAGAIN | if initialization should be postponed |
|
inlinestatic |
#include <zephyr/drivers/usb_c/usbc_tcpc.h>
Returns true if the port partner is presenting at least one Rd.
|
inlinestatic |
#include <zephyr/drivers/usb_c/usbc_tcpc.h>
Returns true if the port partner is an audio accessory.
|
inlinestatic |
#include <zephyr/drivers/usb_c/usbc_tcpc.h>
Returns true if the port partner is presenting Rd on only one CC line.
|
inlinestatic |
#include <zephyr/drivers/usb_c/usbc_tcpc.h>
Returns true if both CC lines are completely open.
|
inlinestatic |
#include <zephyr/drivers/usb_c/usbc_tcpc.h>
Returns whether the sink has detected a Rp resistor on the other side.
|
inlinestatic |
#include <zephyr/drivers/usb_c/usbc_tcpc.h>
Returns true if we detect the port partner is a snk debug accessory.
|
inlinestatic |
#include <zephyr/drivers/usb_c/usbc_tcpc.h>
Returns true if we detect the port partner is a src debug accessory.
|
inlinestatic |
#include <zephyr/drivers/usb_c/usbc_tcpc.h>
Sets the mask of a TCPC status register.
dev | Runtime device structure |
reg | The status register to read |
mask | A bit mask of the status register to mask. The status bit is masked if it's 0, else it's unmasked. |
0 | on success |
-EIO | on failure |
-ENOSYS | if not implemented |
|
inlinestatic |
#include <zephyr/drivers/usb_c/usbc_tcpc.h>
Sets the value of CC pull up resistor used when operating as a Source.
dev | Runtime device structure |
rp | Value of the Pull-Up Resistor. |
0 | on success |
-ENOSYS | |
-EIO | on failure |
|
inlinestatic |
#include <zephyr/drivers/usb_c/usbc_tcpc.h>
Sets the alert function that's called when an interrupt is triggered due to an alert bit.
Calling this function enables the particular alert bit
dev | Runtime device structure |
handler | The callback function called when the bit is set |
data | user data passed to the callback |
0 | on success |
-EINVAL | on failure |
#include <zephyr/drivers/usb_c/usbc_tcpc.h>
Controls the BIST Mode of the TCPC.
It disables RX alerts while the mode is active.
dev | Runtime device structure |
enable | The TCPC enters BIST TEST Mode when true |
0 | on success |
-EIO | on failure |
-ENOSYS | if not implemented |
|
inlinestatic |
#include <zephyr/drivers/usb_c/usbc_tcpc.h>
Sets the CC pull resistor and sets the role as either Source or Sink.
dev | Runtime device structure |
pull | The pull resistor to set |
0 | on success |
-EIO | on failure |
|
inlinestatic |
#include <zephyr/drivers/usb_c/usbc_tcpc.h>
Sets the polarity of the CC lines.
dev | Runtime device structure |
polarity | Polarity of the cc line |
0 | on success |
-EIO | on failure |
#include <zephyr/drivers/usb_c/usbc_tcpc.h>
Manual control of TCPC DebugAccessory control.
dev | Runtime device structure |
enable | Enable Debug Accessory when true, else it's disabled |
0 | on success |
-EIO | on failure |
-ENOSYS | if not implemented |
|
inlinestatic |
#include <zephyr/drivers/usb_c/usbc_tcpc.h>
Detach from a debug connection.
dev | Runtime device structure |
0 | on success |
-EIO | on failure |
-ENOSYS | if not implemented |
#include <zephyr/drivers/usb_c/usbc_tcpc.h>
Enable TCPC auto dual role toggle.
dev | Runtime device structure |
enable | Auto dual role toggle is active when true, else it's disabled |
0 | on success |
-EIO | on failure |
-ENOSYS | if not implemented |
#include <zephyr/drivers/usb_c/usbc_tcpc.h>
Instructs the TCPC to enter or exit low power mode.
dev | Runtime device structure |
enable | The TCPC enters low power mode when true, else it exits it |
0 | on success |
-EIO | on failure |
-ENOSYS | if not implemented |
|
inlinestatic |
#include <zephyr/drivers/usb_c/usbc_tcpc.h>
Sets the Power and Data Role of the PD message header.
This function only needs to be called once per data / power role change
dev | Runtime device structure |
power_role | current power role |
data_role | current data role |
0 | on success |
-EIO | on failure |
-ENOSYS | if not implemented |
#include <zephyr/drivers/usb_c/usbc_tcpc.h>
Enables the reception of SOP* message types.
dev | Runtime device structure |
enable | Enable Power Delivery when true, else it's disabled |
0 | on success |
-EIO | on failure |
-ENOSYS | if not implemented |
#include <zephyr/drivers/usb_c/usbc_tcpc.h>
Set the VBUS sinking state of the TCPC.
dev | Runtime device structure |
enable | True if sinking should be enabled, false if disabled |
0 | on success |
-ENOSYS | if not implemented |
#include <zephyr/drivers/usb_c/usbc_tcpc.h>
Set the VBUS sourcing state of the TCPC.
dev | Runtime device structure |
enable | True if sourcing should be enabled, false if disabled |
0 | on success |
-ENOSYS | if not implemented |
#include <zephyr/drivers/usb_c/usbc_tcpc.h>
Enables or disables VCONN.
This function uses the TCPC to measure VCONN if possible or calls the callback function set by tcpc_set_vconn_cb
dev | Runtime device structure |
enable | VCONN is enabled when true, it's disabled |
0 | on success |
-EIO | on failure |
-ENOSYS | if not implemented |
|
inlinestatic |
#include <zephyr/drivers/usb_c/usbc_tcpc.h>
Sets a callback that can enable or disable VCONN if the TCPC is unable to or the system is configured in a way that does not use the VCONN control capabilities of the TCPC.
The callback is called in the tcpc_set_vconn function if vconn_cb isn't NULL
dev | Runtime device structure |
vconn_cb | pointer to the callback function that controls vconn |
|
inlinestatic |
#include <zephyr/drivers/usb_c/usbc_tcpc.h>
Sets a callback that can enable or discharge VCONN if the TCPC is unable to or the system is configured in a way that does not use the VCONN control capabilities of the TCPC.
The callback is called in the tcpc_vconn_discharge function if cb isn't NULL
dev | Runtime device structure |
cb | pointer to the callback function that discharges vconn |
#include <zephyr/drivers/usb_c/usbc_tcpc.h>
Enables the reception of SOP Prime messages.
dev | Runtime device structure |
enable | Can receive SOP Prime messages when true, else it can not |
0 | on success |
-EIO | on failure |
-ENOSYS | if not implemented |
#include <zephyr/drivers/usb_c/usbc_tcpc.h>
Transmits a Power Delivery message.
dev | Runtime device structure |
msg | Power Delivery message to transmit |
0 | on success |
-EIO | on failure |
-ENOSYS | if not implemented |
#include <zephyr/drivers/usb_c/usbc_tcpc.h>
Discharges VCONN.
This function uses the TCPC to discharge VCONN if possible or calls the callback function set by tcpc_set_vconn_cb
dev | Runtime device structure |
enable | VCONN discharge is enabled when true, it's disabled |
0 | on success |
-EIO | on failure |
-ENOSYS | if not implemented |