Zephyr API Documentation  3.7.0
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
USB-C Device API

USB-C Device APIs. More...

Modules

 Sink_callbacks
 
 Source_callbacks
 

Macros

#define FIXED_5V_100MA_RDO   0x1100280a
 This Request Data Object (RDO) value can be returned from the policy_cb_get_rdo if 5V@100mA with the following options are sufficient for the Sink to operate.
 

Enumerations

enum  usbc_policy_request_t {
  REQUEST_NOP , REQUEST_TC_DISABLED , REQUEST_TC_ERROR_RECOVERY , REQUEST_TC_END ,
  REQUEST_PE_DR_SWAP , REQUEST_PE_HARD_RESET_SEND , REQUEST_PE_SOFT_RESET_SEND , REQUEST_PE_GET_SRC_CAPS ,
  REQUEST_GET_SNK_CAPS , REQUEST_PE_GOTO_MIN
}
 Device Policy Manager requests. More...
 
enum  usbc_policy_notify_t {
  MSG_ACCEPT_RECEIVED , MSG_REJECTED_RECEIVED , MSG_DISCARDED , MSG_NOT_SUPPORTED_RECEIVED ,
  DATA_ROLE_IS_UFP , DATA_ROLE_IS_DFP , PD_CONNECTED , NOT_PD_CONNECTED ,
  TRANSITION_PS , PORT_PARTNER_NOT_RESPONSIVE , PROTOCOL_ERROR , SNK_TRANSITION_TO_DEFAULT ,
  HARD_RESET_RECEIVED , POWER_CHANGE_0A0 , POWER_CHANGE_DEF , POWER_CHANGE_1A5 ,
  POWER_CHANGE_3A0 , SENDER_RESPONSE_TIMEOUT , SOURCE_CAPABILITIES_RECEIVED
}
 Device Policy Manager notifications. More...
 
enum  usbc_policy_check_t {
  CHECK_POWER_ROLE_SWAP , CHECK_DATA_ROLE_SWAP_TO_DFP , CHECK_DATA_ROLE_SWAP_TO_UFP , CHECK_SNK_AT_DEFAULT_LEVEL ,
  CHECK_VCONN_CONTROL , CHECK_SRC_PS_AT_DEFAULT_LEVEL
}
 Device Policy Manager checks. More...
 
enum  usbc_policy_wait_t { WAIT_SINK_REQUEST , WAIT_POWER_ROLE_SWAP , WAIT_DATA_ROLE_SWAP , WAIT_VCONN_SWAP }
 Device Policy Manager Wait message notifications. More...
 
enum  usbc_snk_req_reply_t { SNK_REQUEST_VALID , SNK_REQUEST_REJECT , SNK_REQUEST_WAIT }
 Device Policy Manager's response to a Sink Request. More...
 

Functions

int usbc_start (const struct device *dev)
 Start the USB-C Subsystem.
 
int usbc_suspend (const struct device *dev)
 Suspend the USB-C Subsystem.
 
int usbc_request (const struct device *dev, const enum usbc_policy_request_t req)
 Make a request of the USB-C Subsystem.
 
void usbc_bypass_next_sleep (const struct device *dev)
 
void usbc_set_dpm_data (const struct device *dev, void *dpm_data)
 Set pointer to Device Policy Manager (DPM) data.
 
void * usbc_get_dpm_data (const struct device *dev)
 Get pointer to Device Policy Manager (DPM) data.
 
void usbc_set_vconn_control_cb (const struct device *dev, const tcpc_vconn_control_cb_t cb)
 Set the callback used to set VCONN control.
 
void usbc_set_vconn_discharge_cb (const struct device *dev, const tcpc_vconn_discharge_cb_t cb)
 Set the callback used to discharge VCONN.
 
void usbc_set_policy_cb_check (const struct device *dev, const policy_cb_check_t cb)
 Set the callback used to check a policy.
 
void usbc_set_policy_cb_notify (const struct device *dev, const policy_cb_notify_t cb)
 Set the callback used to notify Device Policy Manager of a policy change.
 
void usbc_set_policy_cb_wait_notify (const struct device *dev, const policy_cb_wait_notify_t cb)
 Set the callback used to notify Device Policy Manager of WAIT message reception.
 
void usbc_set_policy_cb_get_snk_cap (const struct device *dev, const policy_cb_get_snk_cap_t cb)
 Set the callback used to get the Sink Capabilities.
 
void usbc_set_policy_cb_set_src_cap (const struct device *dev, const policy_cb_set_src_cap_t cb)
 Set the callback used to store the received Port Partner's Source Capabilities.
 
void usbc_set_policy_cb_get_rdo (const struct device *dev, const policy_cb_get_rdo_t cb)
 Set the callback used to get the Request Data Object (RDO)
 
void usbc_set_policy_cb_is_snk_at_default (const struct device *dev, const policy_cb_is_snk_at_default_t cb)
 Set the callback used to check if the sink power supply is at the default level.
 
void usbc_set_policy_cb_get_src_rp (const struct device *dev, const policy_cb_get_src_rp_t cb)
 Set the callback used to get the Rp value that should be placed on the CC lines.
 
void usbc_set_policy_cb_src_en (const struct device *dev, const policy_cb_src_en_t cb)
 Set the callback used to enable VBUS.
 
void usbc_set_policy_cb_get_src_caps (const struct device *dev, const policy_cb_get_src_caps_t cb)
 Set the callback used to get the Source Capabilities from the Device Policy Manager.
 
void usbc_set_policy_cb_check_sink_request (const struct device *dev, const policy_cb_check_sink_request_t cb)
 Set the callback used to check if Sink request is valid.
 
void usbc_set_policy_cb_is_ps_ready (const struct device *dev, const policy_cb_is_ps_ready_t cb)
 Set the callback used to check if Source Power Supply is ready.
 
void usbc_set_policy_cb_present_contract_is_valid (const struct device *dev, const policy_cb_present_contract_is_valid_t cb)
 Set the callback to check if present Contract is still valid.
 
void usbc_set_policy_cb_change_src_caps (const struct device *dev, const policy_cb_change_src_caps_t cb)
 Set the callback used to request that a different set of Source Caps be sent to the Sink.
 
void usbc_set_policy_cb_set_port_partner_snk_cap (const struct device *dev, const policy_cb_set_port_partner_snk_cap_t cb)
 Set the callback used to store the Capabilities received from a Sink Port Partner.
 

Detailed Description

USB-C Device APIs.

Since
3.3
Version
0.1.0

Macro Definition Documentation

◆ FIXED_5V_100MA_RDO

#define FIXED_5V_100MA_RDO   0x1100280a

#include <zephyr/usb_c/usbc.h>

This Request Data Object (RDO) value can be returned from the policy_cb_get_rdo if 5V@100mA with the following options are sufficient for the Sink to operate.

The RDO is configured as follows: Maximum operating current 100mA Operating current 100mA Unchunked Extended Messages Not Supported No USB Suspend Not USB Communications Capable No capability mismatch Don't giveback Object position 1 (5V PDO)

Enumeration Type Documentation

◆ usbc_policy_check_t

#include <zephyr/usb_c/usbc.h>

Device Policy Manager checks.

Enumerator
CHECK_POWER_ROLE_SWAP 

Check if Power Role Swap is allowed.

CHECK_DATA_ROLE_SWAP_TO_DFP 

Check if Data Role Swap to DFP is allowed.

CHECK_DATA_ROLE_SWAP_TO_UFP 

Check if Data Role Swap to UFP is allowed.

CHECK_SNK_AT_DEFAULT_LEVEL 

Check if Sink is at default level.

CHECK_VCONN_CONTROL 

Check if should control VCONN.

CHECK_SRC_PS_AT_DEFAULT_LEVEL 

Check if Source Power Supply is at default level.

◆ usbc_policy_notify_t

#include <zephyr/usb_c/usbc.h>

Device Policy Manager notifications.

Enumerator
MSG_ACCEPT_RECEIVED 

Power Delivery Accept message was received.

MSG_REJECTED_RECEIVED 

Power Delivery Reject message was received.

MSG_DISCARDED 

Power Delivery discarded the message being transmitted.

MSG_NOT_SUPPORTED_RECEIVED 

Power Delivery Not Supported message was received.

DATA_ROLE_IS_UFP 

Data Role has been set to Upstream Facing Port (UFP)

DATA_ROLE_IS_DFP 

Data Role has been set to Downstream Facing Port (DFP)

PD_CONNECTED 

A PD Explicit Contract is in place.

NOT_PD_CONNECTED 

No PD Explicit Contract is in place.

TRANSITION_PS 

Transition the Power Supply.

PORT_PARTNER_NOT_RESPONSIVE 

Port partner is not responsive.

PROTOCOL_ERROR 

Protocol Error occurred.

SNK_TRANSITION_TO_DEFAULT 

Transition the Sink to default.

HARD_RESET_RECEIVED 

Hard Reset Received.

POWER_CHANGE_0A0 

Sink SubPower state at 0V.

POWER_CHANGE_DEF 

Sink SubPower state a 5V / 500mA.

POWER_CHANGE_1A5 

Sink SubPower state a 5V / 1.5A.

POWER_CHANGE_3A0 

Sink SubPower state a 5V / 3A.

SENDER_RESPONSE_TIMEOUT 

Sender Response Timeout.

SOURCE_CAPABILITIES_RECEIVED 

Source Capabilities Received.

◆ usbc_policy_request_t

#include <zephyr/usb_c/usbc.h>

Device Policy Manager requests.

Enumerator
REQUEST_NOP 

No request.

REQUEST_TC_DISABLED 

Request Type-C layer to transition to Disabled State.

REQUEST_TC_ERROR_RECOVERY 

Request Type-C layer to transition to Error Recovery State.

REQUEST_TC_END 

End of Type-C requests.

REQUEST_PE_DR_SWAP 

Request Policy Engine layer to perform a Data Role Swap.

REQUEST_PE_HARD_RESET_SEND 

Request Policy Engine layer to send a hard reset.

REQUEST_PE_SOFT_RESET_SEND 

Request Policy Engine layer to send a soft reset.

REQUEST_PE_GET_SRC_CAPS 

Request Policy Engine layer to get Source Capabilities from port partner.

REQUEST_GET_SNK_CAPS 

Request Policy Engine to get Sink Capabilities from port partner.

REQUEST_PE_GOTO_MIN 

Request Policy Engine to request the port partner to source minimum power.

◆ usbc_policy_wait_t

#include <zephyr/usb_c/usbc.h>

Device Policy Manager Wait message notifications.

Enumerator
WAIT_SINK_REQUEST 

The port partner is unable to meet the sink request at this time.

WAIT_POWER_ROLE_SWAP 

The port partner is unable to do a Power Role Swap at this time.

WAIT_DATA_ROLE_SWAP 

The port partner is unable to do a Data Role Swap at this time.

WAIT_VCONN_SWAP 

The port partner is unable to do a VCONN Swap at this time.

◆ usbc_snk_req_reply_t

#include <zephyr/usb_c/usbc.h>

Device Policy Manager's response to a Sink Request.

Enumerator
SNK_REQUEST_VALID 

The sink port partner's request can be met.

SNK_REQUEST_REJECT 

The sink port partner's request can not be met.

SNK_REQUEST_WAIT 

The sink port partner's request can be met at a later time.

Function Documentation

◆ usbc_bypass_next_sleep()

void usbc_bypass_next_sleep ( const struct device dev)

#include <zephyr/usb_c/usbc.h>

◆ usbc_get_dpm_data()

void * usbc_get_dpm_data ( const struct device dev)

#include <zephyr/usb_c/usbc.h>

Get pointer to Device Policy Manager (DPM) data.

Parameters
devRuntime device structure
Return values
pointerto dpm data that was set with usbc_set_dpm_data
NULLif dpm data was not set

◆ usbc_request()

int usbc_request ( const struct device dev,
const enum usbc_policy_request_t  req 
)

#include <zephyr/usb_c/usbc.h>

Make a request of the USB-C Subsystem.

Parameters
devRuntime device structure
reqrequest
Return values
0on success

◆ usbc_set_dpm_data()

void usbc_set_dpm_data ( const struct device dev,
void *  dpm_data 
)

#include <zephyr/usb_c/usbc.h>

Set pointer to Device Policy Manager (DPM) data.

Parameters
devRuntime device structure
dpm_datapointer to dpm data

◆ usbc_set_policy_cb_change_src_caps()

void usbc_set_policy_cb_change_src_caps ( const struct device dev,
const policy_cb_change_src_caps_t  cb 
)

#include <zephyr/usb_c/usbc.h>

Set the callback used to request that a different set of Source Caps be sent to the Sink.

Parameters
devUSB-C Connector Instance
cbcallback

◆ usbc_set_policy_cb_check()

void usbc_set_policy_cb_check ( const struct device dev,
const policy_cb_check_t  cb 
)

#include <zephyr/usb_c/usbc.h>

Set the callback used to check a policy.

Parameters
devRuntime device structure
cbcallback

◆ usbc_set_policy_cb_check_sink_request()

void usbc_set_policy_cb_check_sink_request ( const struct device dev,
const policy_cb_check_sink_request_t  cb 
)

#include <zephyr/usb_c/usbc.h>

Set the callback used to check if Sink request is valid.

Parameters
devUSB-C Connector Instance
cbcallback

◆ usbc_set_policy_cb_get_rdo()

void usbc_set_policy_cb_get_rdo ( const struct device dev,
const policy_cb_get_rdo_t  cb 
)

#include <zephyr/usb_c/usbc.h>

Set the callback used to get the Request Data Object (RDO)

Parameters
devRuntime device structure
cbcallback

◆ usbc_set_policy_cb_get_snk_cap()

void usbc_set_policy_cb_get_snk_cap ( const struct device dev,
const policy_cb_get_snk_cap_t  cb 
)

#include <zephyr/usb_c/usbc.h>

Set the callback used to get the Sink Capabilities.

Parameters
devRuntime device structure
cbcallback

◆ usbc_set_policy_cb_get_src_caps()

void usbc_set_policy_cb_get_src_caps ( const struct device dev,
const policy_cb_get_src_caps_t  cb 
)

#include <zephyr/usb_c/usbc.h>

Set the callback used to get the Source Capabilities from the Device Policy Manager.

Parameters
devUSB-C Connector Instance
cbcallback

◆ usbc_set_policy_cb_get_src_rp()

void usbc_set_policy_cb_get_src_rp ( const struct device dev,
const policy_cb_get_src_rp_t  cb 
)

#include <zephyr/usb_c/usbc.h>

Set the callback used to get the Rp value that should be placed on the CC lines.

Parameters
devUSB-C Connector Instance
cbcallback

◆ usbc_set_policy_cb_is_ps_ready()

void usbc_set_policy_cb_is_ps_ready ( const struct device dev,
const policy_cb_is_ps_ready_t  cb 
)

#include <zephyr/usb_c/usbc.h>

Set the callback used to check if Source Power Supply is ready.

Parameters
devUSB-C Connector Instance
cbcallback

◆ usbc_set_policy_cb_is_snk_at_default()

void usbc_set_policy_cb_is_snk_at_default ( const struct device dev,
const policy_cb_is_snk_at_default_t  cb 
)

#include <zephyr/usb_c/usbc.h>

Set the callback used to check if the sink power supply is at the default level.

Parameters
devRuntime device structure
cbcallback

◆ usbc_set_policy_cb_notify()

void usbc_set_policy_cb_notify ( const struct device dev,
const policy_cb_notify_t  cb 
)

#include <zephyr/usb_c/usbc.h>

Set the callback used to notify Device Policy Manager of a policy change.

Parameters
devRuntime device structure
cbcallback

◆ usbc_set_policy_cb_present_contract_is_valid()

void usbc_set_policy_cb_present_contract_is_valid ( const struct device dev,
const policy_cb_present_contract_is_valid_t  cb 
)

#include <zephyr/usb_c/usbc.h>

Set the callback to check if present Contract is still valid.

Parameters
devUSB-C Connector Instance
cbcallback

◆ usbc_set_policy_cb_set_port_partner_snk_cap()

void usbc_set_policy_cb_set_port_partner_snk_cap ( const struct device dev,
const policy_cb_set_port_partner_snk_cap_t  cb 
)

#include <zephyr/usb_c/usbc.h>

Set the callback used to store the Capabilities received from a Sink Port Partner.

Parameters
devUSB-C Connector Instance
cbcallback

◆ usbc_set_policy_cb_set_src_cap()

void usbc_set_policy_cb_set_src_cap ( const struct device dev,
const policy_cb_set_src_cap_t  cb 
)

#include <zephyr/usb_c/usbc.h>

Set the callback used to store the received Port Partner's Source Capabilities.

Parameters
devRuntime device structure
cbcallback

◆ usbc_set_policy_cb_src_en()

void usbc_set_policy_cb_src_en ( const struct device dev,
const policy_cb_src_en_t  cb 
)

#include <zephyr/usb_c/usbc.h>

Set the callback used to enable VBUS.

Parameters
devUSB-C Connector Instance
cbcallback

◆ usbc_set_policy_cb_wait_notify()

void usbc_set_policy_cb_wait_notify ( const struct device dev,
const policy_cb_wait_notify_t  cb 
)

#include <zephyr/usb_c/usbc.h>

Set the callback used to notify Device Policy Manager of WAIT message reception.

Parameters
devRuntime device structure
cbcallback

◆ usbc_set_vconn_control_cb()

void usbc_set_vconn_control_cb ( const struct device dev,
const tcpc_vconn_control_cb_t  cb 
)

#include <zephyr/usb_c/usbc.h>

Set the callback used to set VCONN control.

Parameters
devRuntime device structure
cbVCONN control callback

◆ usbc_set_vconn_discharge_cb()

void usbc_set_vconn_discharge_cb ( const struct device dev,
const tcpc_vconn_discharge_cb_t  cb 
)

#include <zephyr/usb_c/usbc.h>

Set the callback used to discharge VCONN.

Parameters
devRuntime device structure
cbVCONN discharge callback

◆ usbc_start()

int usbc_start ( const struct device dev)

#include <zephyr/usb_c/usbc.h>

Start the USB-C Subsystem.

Parameters
devRuntime device structure
Return values
0on success

◆ usbc_suspend()

int usbc_suspend ( const struct device dev)

#include <zephyr/usb_c/usbc.h>

Suspend the USB-C Subsystem.

Parameters
devRuntime device structure
Return values
0on success