usb_c: run clang-format
Run clang-format Signed-off-by: Sam Hurst <sbh1187@gmail.com>
This commit is contained in:
parent
7910c617be
commit
914fed36d5
12 changed files with 152 additions and 237 deletions
|
@ -50,8 +50,7 @@ void pe_suspend(const struct device *dev);
|
|||
* @param dev Pointer to the device structure for the driver instance
|
||||
* @param dpm_request Device Policy Manager request
|
||||
*/
|
||||
void pe_run(const struct device *dev,
|
||||
const int32_t dpm_request);
|
||||
void pe_run(const struct device *dev, const int32_t dpm_request);
|
||||
|
||||
/**
|
||||
* @brief Query if the Policy Engine is running
|
||||
|
@ -77,8 +76,7 @@ void pe_message_sent(const struct device *dev);
|
|||
* @param e policy error
|
||||
* @param type port partner address where error was generated
|
||||
*/
|
||||
void pe_report_error(const struct device *dev,
|
||||
const enum pe_error e,
|
||||
void pe_report_error(const struct device *dev, const enum pe_error e,
|
||||
const enum pd_packet_type type);
|
||||
|
||||
/**
|
||||
|
|
|
@ -118,8 +118,7 @@ bool pe_is_running(const struct device *dev)
|
|||
/**
|
||||
* @brief Run the Policy Engine layer
|
||||
*/
|
||||
void pe_run(const struct device *dev,
|
||||
const int32_t dpm_request)
|
||||
void pe_run(const struct device *dev, const int32_t dpm_request)
|
||||
{
|
||||
struct usbc_port_data *data = dev->data;
|
||||
struct policy_engine *pe = data->pe;
|
||||
|
@ -218,8 +217,7 @@ void pe_message_sent(const struct device *dev)
|
|||
/**
|
||||
* @brief Informs the Policy Engine of an error.
|
||||
*/
|
||||
void pe_report_error(const struct device *dev,
|
||||
const enum pe_error e,
|
||||
void pe_report_error(const struct device *dev, const enum pe_error e,
|
||||
const enum pd_packet_type type)
|
||||
{
|
||||
struct usbc_port_data *data = dev->data;
|
||||
|
@ -250,10 +248,9 @@ void pe_report_error(const struct device *dev,
|
|||
* response.
|
||||
*/
|
||||
/* All error types besides transmit errors are Protocol Errors. */
|
||||
if ((e != ERR_XMIT &&
|
||||
atomic_test_bit(&pe->flags, PE_FLAGS_INTERRUPTIBLE_AMS) == false) ||
|
||||
e == ERR_XMIT ||
|
||||
(atomic_test_bit(&pe->flags, PE_FLAGS_EXPLICIT_CONTRACT) == false &&
|
||||
if ((e != ERR_XMIT && atomic_test_bit(&pe->flags, PE_FLAGS_INTERRUPTIBLE_AMS) == false) ||
|
||||
e == ERR_XMIT ||
|
||||
(atomic_test_bit(&pe->flags, PE_FLAGS_EXPLICIT_CONTRACT) == false &&
|
||||
type == PD_PACKET_SOP)) {
|
||||
policy_notify(dev, PROTOCOL_ERROR);
|
||||
pe_send_soft_reset(dev, type);
|
||||
|
@ -342,8 +339,7 @@ bool pe_dpm_initiated_ams(const struct device *dev)
|
|||
/**
|
||||
* @brief Sets a Policy Engine state
|
||||
*/
|
||||
void pe_set_state(const struct device *dev,
|
||||
const enum usbc_pe_state state)
|
||||
void pe_set_state(const struct device *dev, const enum usbc_pe_state state)
|
||||
{
|
||||
struct usbc_port_data *data = dev->data;
|
||||
|
||||
|
@ -373,8 +369,7 @@ enum usbc_pe_state pe_get_last_state(const struct device *dev)
|
|||
/**
|
||||
* @brief Send a soft reset message
|
||||
*/
|
||||
void pe_send_soft_reset(const struct device *dev,
|
||||
const enum pd_packet_type type)
|
||||
void pe_send_soft_reset(const struct device *dev, const enum pd_packet_type type)
|
||||
{
|
||||
struct usbc_port_data *data = dev->data;
|
||||
|
||||
|
@ -385,9 +380,8 @@ void pe_send_soft_reset(const struct device *dev,
|
|||
/**
|
||||
* @brief Send a Power Delivery Data Message
|
||||
*/
|
||||
void pe_send_data_msg(const struct device *dev,
|
||||
const enum pd_packet_type type,
|
||||
const enum pd_data_msg_type msg)
|
||||
void pe_send_data_msg(const struct device *dev, const enum pd_packet_type type,
|
||||
const enum pd_data_msg_type msg)
|
||||
{
|
||||
struct usbc_port_data *data = dev->data;
|
||||
struct policy_engine *pe = data->pe;
|
||||
|
@ -400,9 +394,8 @@ void pe_send_data_msg(const struct device *dev,
|
|||
/**
|
||||
* @brief Send a Power Delivery Control Message
|
||||
*/
|
||||
void pe_send_ctrl_msg(const struct device *dev,
|
||||
const enum pd_packet_type type,
|
||||
const enum pd_ctrl_msg_type msg)
|
||||
void pe_send_ctrl_msg(const struct device *dev, const enum pd_packet_type type,
|
||||
const enum pd_ctrl_msg_type msg)
|
||||
{
|
||||
struct usbc_port_data *data = dev->data;
|
||||
struct policy_engine *pe = data->pe;
|
||||
|
@ -415,8 +408,7 @@ void pe_send_ctrl_msg(const struct device *dev,
|
|||
/**
|
||||
* @brief Request desired voltage from source.
|
||||
*/
|
||||
void pe_send_request_msg(const struct device *dev,
|
||||
const uint32_t rdo)
|
||||
void pe_send_request_msg(const struct device *dev, const uint32_t rdo)
|
||||
{
|
||||
struct usbc_port_data *data = dev->data;
|
||||
struct protocol_layer_tx_t *prl_tx = data->prl_tx;
|
||||
|
@ -441,8 +433,7 @@ void extended_message_not_supported(const struct device *dev)
|
|||
|
||||
ext_header.raw_value = *payload;
|
||||
|
||||
if (ext_header.chunked &&
|
||||
ext_header.data_size > PD_MAX_EXTENDED_MSG_CHUNK_LEN) {
|
||||
if (ext_header.chunked && ext_header.data_size > PD_MAX_EXTENDED_MSG_CHUNK_LEN) {
|
||||
pe_set_state(dev, PE_SNK_CHUNK_RECEIVED);
|
||||
} else {
|
||||
pe_set_state(dev, PE_SEND_NOT_SUPPORTED);
|
||||
|
@ -452,16 +443,13 @@ void extended_message_not_supported(const struct device *dev)
|
|||
/**
|
||||
* @brief Check if a specific control message was received
|
||||
*/
|
||||
bool received_control_message(const struct device *dev,
|
||||
const union pd_header header,
|
||||
const enum pd_ctrl_msg_type mt)
|
||||
bool received_control_message(const struct device *dev, const union pd_header header,
|
||||
const enum pd_ctrl_msg_type mt)
|
||||
{
|
||||
struct usbc_port_data *data = dev->data;
|
||||
struct protocol_layer_rx_t *prl_rx = data->prl_rx;
|
||||
|
||||
if (prl_rx->emsg.len == 0 &&
|
||||
header.message_type == mt &&
|
||||
header.extended == 0) {
|
||||
if (prl_rx->emsg.len == 0 && header.message_type == mt && header.extended == 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -471,16 +459,13 @@ bool received_control_message(const struct device *dev,
|
|||
/**
|
||||
* @brief Check if a specific data message was received
|
||||
*/
|
||||
bool received_data_message(const struct device *dev,
|
||||
const union pd_header header,
|
||||
const enum pd_data_msg_type mt)
|
||||
bool received_data_message(const struct device *dev, const union pd_header header,
|
||||
const enum pd_data_msg_type mt)
|
||||
{
|
||||
struct usbc_port_data *data = dev->data;
|
||||
struct protocol_layer_rx_t *prl_rx = data->prl_rx;
|
||||
|
||||
if (prl_rx->emsg.len > 0 &&
|
||||
header.message_type == mt &&
|
||||
header.extended == 0) {
|
||||
if (prl_rx->emsg.len > 0 && header.message_type == mt && header.extended == 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -490,8 +475,7 @@ bool received_data_message(const struct device *dev,
|
|||
/**
|
||||
* @brief Check a DPM policy
|
||||
*/
|
||||
bool policy_check(const struct device *dev,
|
||||
const enum usbc_policy_check_t pc)
|
||||
bool policy_check(const struct device *dev, const enum usbc_policy_check_t pc)
|
||||
{
|
||||
struct usbc_port_data *data = dev->data;
|
||||
|
||||
|
@ -505,8 +489,7 @@ bool policy_check(const struct device *dev,
|
|||
/**
|
||||
* @brief Notify the DPM of a policy change
|
||||
*/
|
||||
void policy_notify(const struct device *dev,
|
||||
const enum usbc_policy_notify_t notify)
|
||||
void policy_notify(const struct device *dev, const enum usbc_policy_notify_t notify)
|
||||
{
|
||||
struct usbc_port_data *data = dev->data;
|
||||
|
||||
|
@ -518,8 +501,7 @@ void policy_notify(const struct device *dev,
|
|||
/**
|
||||
* @brief Notify the DPM of a WAIT message reception
|
||||
*/
|
||||
bool policy_wait_notify(const struct device *dev,
|
||||
const enum usbc_policy_wait_t notify)
|
||||
bool policy_wait_notify(const struct device *dev, const enum usbc_policy_wait_t notify)
|
||||
{
|
||||
struct usbc_port_data *data = dev->data;
|
||||
|
||||
|
@ -533,9 +515,7 @@ bool policy_wait_notify(const struct device *dev,
|
|||
/**
|
||||
* @brief Send the received source caps to the DPM
|
||||
*/
|
||||
void policy_set_src_cap(const struct device *dev,
|
||||
const uint32_t *pdos,
|
||||
const int num_pdos)
|
||||
void policy_set_src_cap(const struct device *dev, const uint32_t *pdos, const int num_pdos)
|
||||
{
|
||||
struct usbc_port_data *data = dev->data;
|
||||
|
||||
|
@ -552,8 +532,7 @@ uint32_t policy_get_request_data_object(const struct device *dev)
|
|||
struct usbc_port_data *data = dev->data;
|
||||
|
||||
/* This callback must be implemented */
|
||||
__ASSERT(data->policy_cb_get_rdo != NULL,
|
||||
"Callback pointer should not be NULL");
|
||||
__ASSERT(data->policy_cb_get_rdo != NULL, "Callback pointer should not be NULL");
|
||||
|
||||
return data->policy_cb_get_rdo(dev);
|
||||
}
|
||||
|
@ -575,15 +554,12 @@ bool policy_is_snk_at_default(const struct device *dev)
|
|||
/**
|
||||
* @brief Get sink caps from the DPM
|
||||
*/
|
||||
void policy_get_snk_cap(const struct device *dev,
|
||||
uint32_t **pdos,
|
||||
int *num_pdos)
|
||||
void policy_get_snk_cap(const struct device *dev, uint32_t **pdos, int *num_pdos)
|
||||
{
|
||||
struct usbc_port_data *data = dev->data;
|
||||
|
||||
/* This callback must be implemented */
|
||||
__ASSERT(data->policy_cb_get_snk_cap != NULL,
|
||||
"Callback pointer should not be NULL");
|
||||
__ASSERT(data->policy_cb_get_snk_cap != NULL, "Callback pointer should not be NULL");
|
||||
|
||||
data->policy_cb_get_snk_cap(dev, pdos, num_pdos);
|
||||
}
|
||||
|
@ -597,8 +573,8 @@ void pe_drs_evaluate_swap_entry(void *obj)
|
|||
const struct device *dev = pe->dev;
|
||||
|
||||
/* Get evaluation of Data Role Swap request from Device Policy Manager */
|
||||
if (policy_check(dev, (pe->data_role == TC_ROLE_UFP) ?
|
||||
CHECK_DATA_ROLE_SWAP_TO_DFP : CHECK_DATA_ROLE_SWAP_TO_UFP)) {
|
||||
if (policy_check(dev, (pe->data_role == TC_ROLE_UFP) ? CHECK_DATA_ROLE_SWAP_TO_DFP
|
||||
: CHECK_DATA_ROLE_SWAP_TO_UFP)) {
|
||||
/*
|
||||
* PE_DRS_DFP_UFP_Accept_Swap and PE_DRS_UFP_DFP_Accept_Swap
|
||||
* State embedded here
|
||||
|
@ -634,8 +610,8 @@ void pe_drs_evaluate_swap_run(void *obj)
|
|||
/* Notify TCPC of role update */
|
||||
tcpc_set_roles(data->tcpc, pe->power_role, pe->data_role);
|
||||
/* Inform Device Policy Manager of Data Role Change */
|
||||
policy_notify(dev, (pe->data_role == TC_ROLE_UFP) ?
|
||||
DATA_ROLE_IS_UFP : DATA_ROLE_IS_DFP);
|
||||
policy_notify(dev, (pe->data_role == TC_ROLE_UFP) ? DATA_ROLE_IS_UFP
|
||||
: DATA_ROLE_IS_DFP);
|
||||
}
|
||||
pe_set_state(dev, PE_SNK_READY);
|
||||
} else if (atomic_test_and_clear_bit(&pe->flags, PE_FLAGS_MSG_DISCARDED)) {
|
||||
|
@ -699,8 +675,8 @@ void pe_drs_send_swap_run(void *obj)
|
|||
/* Notify TCPC of role update */
|
||||
tcpc_set_roles(data->tcpc, pe->power_role, pe->data_role);
|
||||
/* Inform Device Policy Manager of Data Role Change */
|
||||
policy_notify(dev, (pe->data_role == TC_ROLE_UFP) ?
|
||||
DATA_ROLE_IS_UFP : DATA_ROLE_IS_DFP);
|
||||
policy_notify(dev, (pe->data_role == TC_ROLE_UFP) ? DATA_ROLE_IS_UFP
|
||||
: DATA_ROLE_IS_DFP);
|
||||
} else {
|
||||
/* Protocol Error */
|
||||
policy_notify(dev, PROTOCOL_ERROR);
|
||||
|
|
|
@ -62,52 +62,52 @@ enum usbc_pe_state {
|
|||
*/
|
||||
enum pe_flags {
|
||||
/** Accept message received from port partner */
|
||||
PE_FLAGS_ACCEPT = 0,
|
||||
PE_FLAGS_ACCEPT = 0,
|
||||
/**
|
||||
* Protocol Error was determined based on error recovery
|
||||
* current state
|
||||
*/
|
||||
PE_FLAGS_PROTOCOL_ERROR = 1,
|
||||
PE_FLAGS_PROTOCOL_ERROR = 1,
|
||||
/** A message we requested to be sent has been transmitted */
|
||||
PE_FLAGS_TX_COMPLETE = 2,
|
||||
PE_FLAGS_TX_COMPLETE = 2,
|
||||
/** A message sent by a port partner has been received */
|
||||
PE_FLAGS_MSG_RECEIVED = 3,
|
||||
PE_FLAGS_MSG_RECEIVED = 3,
|
||||
/**
|
||||
* A hard reset has been requested by the DPM but has not been sent,
|
||||
* not currently used
|
||||
*/
|
||||
PE_FLAGS_HARD_RESET_PENDING = 4,
|
||||
PE_FLAGS_HARD_RESET_PENDING = 4,
|
||||
/** An explicit contract is in place with our port partner */
|
||||
PE_FLAGS_EXPLICIT_CONTRACT = 5,
|
||||
PE_FLAGS_EXPLICIT_CONTRACT = 5,
|
||||
/**
|
||||
* Waiting for Sink Capabailities timed out. Used for retry error
|
||||
* handling
|
||||
*/
|
||||
PE_FLAGS_SNK_WAIT_CAP_TIMEOUT = 6,
|
||||
PE_FLAGS_SNK_WAIT_CAP_TIMEOUT = 6,
|
||||
/**
|
||||
* Flag to note current Atomic Message Sequence (AMS) is interruptible.
|
||||
* If this flag is not set the AMS is non-interruptible. This flag must
|
||||
* be set in the interruptible's message state entry.
|
||||
*/
|
||||
PE_FLAGS_INTERRUPTIBLE_AMS = 7,
|
||||
PE_FLAGS_INTERRUPTIBLE_AMS = 7,
|
||||
/** Flag to trigger sending a Data Role Swap */
|
||||
PE_FLAGS_DR_SWAP_TO_DFP = 8,
|
||||
PE_FLAGS_DR_SWAP_TO_DFP = 8,
|
||||
/** Flag is set when an AMS is initiated by the Device Policy Manager */
|
||||
PE_FLAGS_DPM_INITIATED_AMS = 9,
|
||||
PE_FLAGS_DPM_INITIATED_AMS = 9,
|
||||
/** Flag to note message was discarded due to incoming message */
|
||||
PE_FLAGS_MSG_DISCARDED = 10,
|
||||
PE_FLAGS_MSG_DISCARDED = 10,
|
||||
/** Flag to trigger sending a soft reset */
|
||||
PE_FLAGS_SEND_SOFT_RESET = 11,
|
||||
PE_FLAGS_SEND_SOFT_RESET = 11,
|
||||
/**
|
||||
* This flag is set when a Wait message is received in response to a
|
||||
* Sink REQUEST
|
||||
*/
|
||||
PE_FLAGS_WAIT_SINK_REQUEST = 12,
|
||||
PE_FLAGS_WAIT_SINK_REQUEST = 12,
|
||||
/**
|
||||
* This flag is set when a Wait message is received in response to a
|
||||
* Data Role Swap
|
||||
*/
|
||||
PE_FLAGS_WAIT_DATA_ROLE_SWAP = 13
|
||||
PE_FLAGS_WAIT_DATA_ROLE_SWAP = 13
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -159,8 +159,7 @@ struct policy_engine {
|
|||
* @param dev Pointer to the device structure for the driver instance
|
||||
* @param state next PE State to enter
|
||||
*/
|
||||
void pe_set_state(const struct device *dev,
|
||||
const enum usbc_pe_state state);
|
||||
void pe_set_state(const struct device *dev, const enum usbc_pe_state state);
|
||||
|
||||
/**
|
||||
* @brief Get the Policy Engine's current state
|
||||
|
@ -184,8 +183,7 @@ enum usbc_pe_state pe_get_last_state(const struct device *dev);
|
|||
* @param dev Pointer to the device structure for the driver instance
|
||||
* @param type SOP* to send soft reset message
|
||||
*/
|
||||
void pe_send_soft_reset(const struct device *dev,
|
||||
const enum pd_packet_type type);
|
||||
void pe_send_soft_reset(const struct device *dev, const enum pd_packet_type type);
|
||||
|
||||
/**
|
||||
* @brief Send a Power Delivery Data Message
|
||||
|
@ -215,8 +213,7 @@ void pe_send_ctrl_msg(const struct device *dev,
|
|||
* @param dev Pointer to the device structure for the driver instance
|
||||
* @param rdo Request Data Object to send
|
||||
*/
|
||||
void pe_send_request_msg(const struct device *dev,
|
||||
const uint32_t rdo);
|
||||
void pe_send_request_msg(const struct device *dev, const uint32_t rdo);
|
||||
|
||||
/**
|
||||
* @brief Transitions state after receiving an extended message.
|
||||
|
@ -233,8 +230,7 @@ void extended_message_not_supported(const struct device *dev);
|
|||
* @param mt message type to check
|
||||
* @retval true if the header contains the message type, else false
|
||||
*/
|
||||
bool received_control_message(const struct device *dev,
|
||||
const union pd_header header,
|
||||
bool received_control_message(const struct device *dev, const union pd_header header,
|
||||
const enum pd_ctrl_msg_type mt);
|
||||
|
||||
/**
|
||||
|
@ -245,8 +241,7 @@ bool received_control_message(const struct device *dev,
|
|||
* @param mt message type to check
|
||||
* @param true if the header contains the message type, else false
|
||||
*/
|
||||
bool received_data_message(const struct device *dev,
|
||||
const union pd_header header,
|
||||
bool received_data_message(const struct device *dev, const union pd_header header,
|
||||
const enum pd_data_msg_type mt);
|
||||
|
||||
/**
|
||||
|
@ -256,8 +251,7 @@ bool received_data_message(const struct device *dev,
|
|||
* @param pc The DPM policy to check
|
||||
* @retval true if the DPM approves the check, else false
|
||||
*/
|
||||
bool policy_check(const struct device *dev,
|
||||
const enum usbc_policy_check_t pc);
|
||||
bool policy_check(const struct device *dev, const enum usbc_policy_check_t pc);
|
||||
|
||||
/**
|
||||
* @brief Notify the DPM of a policy change
|
||||
|
@ -265,8 +259,7 @@ bool policy_check(const struct device *dev,
|
|||
* @param dev Pointer to the device structure for the driver instance
|
||||
* @param notify The notification to send the the DPM
|
||||
*/
|
||||
void policy_notify(const struct device *dev,
|
||||
const enum usbc_policy_notify_t notify);
|
||||
void policy_notify(const struct device *dev, const enum usbc_policy_notify_t notify);
|
||||
|
||||
/**
|
||||
* @brief Notify the DPM of a WAIT message reception
|
||||
|
@ -275,9 +268,7 @@ void policy_notify(const struct device *dev,
|
|||
* @param notify Wait message to send to DPM
|
||||
* @retval true if the Policy Engine should wait and try the action again
|
||||
*/
|
||||
bool policy_wait_notify(const struct device *dev,
|
||||
const enum usbc_policy_wait_t notify);
|
||||
|
||||
bool policy_wait_notify(const struct device *dev, const enum usbc_policy_wait_t notify);
|
||||
|
||||
/**
|
||||
* @brief Send the received source caps to the DPM
|
||||
|
@ -286,9 +277,7 @@ bool policy_wait_notify(const struct device *dev,
|
|||
* @param pdos pointer to pdos to send
|
||||
* @param num_pdos number of pdos to send
|
||||
*/
|
||||
void policy_set_src_cap(const struct device *dev,
|
||||
const uint32_t *pdos,
|
||||
const int num_pdos);
|
||||
void policy_set_src_cap(const struct device *dev, const uint32_t *pdos, const int num_pdos);
|
||||
|
||||
/**
|
||||
* @brief Get a Request Data Object from the DPM
|
||||
|
@ -313,8 +302,6 @@ bool policy_is_snk_at_default(const struct device *dev);
|
|||
* @param pdos pointer to pdo sink caps
|
||||
* @param num_pdos number of pdo sink caps
|
||||
*/
|
||||
void policy_get_snk_cap(const struct device *dev,
|
||||
uint32_t **pdos,
|
||||
int *num_pdos);
|
||||
void policy_get_snk_cap(const struct device *dev, uint32_t **pdos, int *num_pdos);
|
||||
|
||||
#endif /* ZEPHYR_SUBSYS_USBC_PE_COMMON_INTERNAL_H_ */
|
||||
|
|
|
@ -205,7 +205,6 @@ void pe_snk_select_capability_entry(void *obj)
|
|||
policy_notify(dev, PD_CONNECTED);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief PE_SNK_Select_Capability Run State
|
||||
*/
|
||||
|
@ -274,7 +273,7 @@ void pe_snk_select_capability_run(void *obj)
|
|||
*/
|
||||
if (policy_wait_notify(dev, WAIT_SINK_REQUEST)) {
|
||||
atomic_set_bit(&pe->flags,
|
||||
PE_FLAGS_WAIT_SINK_REQUEST);
|
||||
PE_FLAGS_WAIT_SINK_REQUEST);
|
||||
usbc_timer_start(&pe->pd_t_wait_to_resend);
|
||||
}
|
||||
}
|
||||
|
@ -721,7 +720,7 @@ void pe_soft_reset_entry(void *obj)
|
|||
/**
|
||||
* @brief PE_SNK_Soft_Reset Run State
|
||||
*/
|
||||
void pe_soft_reset_run(void *obj)
|
||||
void pe_soft_reset_run(void *obj)
|
||||
{
|
||||
struct policy_engine *pe = (struct policy_engine *)obj;
|
||||
const struct device *dev = pe->dev;
|
||||
|
@ -770,7 +769,7 @@ void pe_send_not_supported_run(void *obj)
|
|||
const struct device *dev = pe->dev;
|
||||
|
||||
if (atomic_test_bit(&pe->flags, PE_FLAGS_TX_COMPLETE) ||
|
||||
atomic_test_bit(&pe->flags, PE_FLAGS_MSG_DISCARDED)) {
|
||||
atomic_test_bit(&pe->flags, PE_FLAGS_MSG_DISCARDED)) {
|
||||
atomic_clear_bit(&pe->flags, PE_FLAGS_TX_COMPLETE);
|
||||
atomic_clear_bit(&pe->flags, PE_FLAGS_MSG_DISCARDED);
|
||||
pe_set_state(dev, PE_SNK_READY);
|
||||
|
|
|
@ -29,24 +29,24 @@ LOG_MODULE_DECLARE(usbc_stack, CONFIG_USBC_STACK_LOG_LEVEL);
|
|||
*/
|
||||
enum prl_flags {
|
||||
/** Flag to note message transmission completed */
|
||||
PRL_FLAGS_TX_COMPLETE = 0,
|
||||
PRL_FLAGS_TX_COMPLETE = 0,
|
||||
/** Flag to note message was discarded */
|
||||
PRL_FLAGS_TX_DISCARDED = 1,
|
||||
PRL_FLAGS_TX_DISCARDED = 1,
|
||||
/** Flag to note PRL waited for SINK_OK CC state before transmitting */
|
||||
PRL_FLAGS_WAIT_SINK_OK = 2,
|
||||
PRL_FLAGS_WAIT_SINK_OK = 2,
|
||||
/** Flag to note transmission error occurred */
|
||||
PRL_FLAGS_TX_ERROR = 3,
|
||||
PRL_FLAGS_TX_ERROR = 3,
|
||||
/** Flag to note PE triggered a hard reset */
|
||||
PRL_FLAGS_PE_HARD_RESET = 4,
|
||||
PRL_FLAGS_PE_HARD_RESET = 4,
|
||||
/** Flag to note hard reset has completed */
|
||||
PRL_FLAGS_HARD_RESET_COMPLETE = 5,
|
||||
PRL_FLAGS_HARD_RESET_COMPLETE = 5,
|
||||
/** Flag to note port partner sent a hard reset */
|
||||
PRL_FLAGS_PORT_PARTNER_HARD_RESET = 6,
|
||||
PRL_FLAGS_PORT_PARTNER_HARD_RESET = 6,
|
||||
/**
|
||||
* Flag to note a message transmission has been requested. It is only
|
||||
* cleared when the message is sent to the TCPC layer.
|
||||
*/
|
||||
PRL_FLAGS_MSG_XMIT = 7,
|
||||
PRL_FLAGS_MSG_XMIT = 7,
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -94,10 +94,8 @@ static const struct smf_state prl_hr_states[];
|
|||
|
||||
static void prl_tx_construct_message(const struct device *dev);
|
||||
static void prl_rx_wait_for_phy_message(const struct device *dev);
|
||||
static void prl_hr_set_state(const struct device *dev,
|
||||
const enum usbc_prl_hr_state_t state);
|
||||
static void prl_tx_set_state(const struct device *dev,
|
||||
const enum usbc_prl_tx_state_t state);
|
||||
static void prl_hr_set_state(const struct device *dev, const enum usbc_prl_hr_state_t state);
|
||||
static void prl_tx_set_state(const struct device *dev, const enum usbc_prl_tx_state_t state);
|
||||
static void prl_init(const struct device *dev);
|
||||
static enum usbc_prl_hr_state_t prl_hr_get_state(const struct device *dev);
|
||||
|
||||
|
@ -167,8 +165,7 @@ void prl_hard_reset_complete(const struct device *dev)
|
|||
* @brief Directs the Protocol Layer to construct and transmit a Power Delivery
|
||||
* Control message.
|
||||
*/
|
||||
void prl_send_ctrl_msg(const struct device *dev,
|
||||
const enum pd_packet_type type,
|
||||
void prl_send_ctrl_msg(const struct device *dev, const enum pd_packet_type type,
|
||||
const enum pd_ctrl_msg_type msg)
|
||||
{
|
||||
struct usbc_port_data *data = dev->data;
|
||||
|
@ -191,8 +188,7 @@ void prl_send_ctrl_msg(const struct device *dev,
|
|||
* @note: Before calling this function prl_tx->emsg.data and prl_tx->emsg.len
|
||||
* must be set.
|
||||
*/
|
||||
void prl_send_data_msg(const struct device *dev,
|
||||
const enum pd_packet_type type,
|
||||
void prl_send_data_msg(const struct device *dev, const enum pd_packet_type type,
|
||||
const enum pd_data_msg_type msg)
|
||||
{
|
||||
struct usbc_port_data *data = dev->data;
|
||||
|
@ -317,8 +313,7 @@ void prl_run(const struct device *dev)
|
|||
* @brief Set revision for the give packet type. This function is called
|
||||
* from the Policy Engine.
|
||||
*/
|
||||
void prl_set_rev(const struct device *dev,
|
||||
const enum pd_packet_type type,
|
||||
void prl_set_rev(const struct device *dev, const enum pd_packet_type type,
|
||||
const enum pd_rev_type rev)
|
||||
{
|
||||
struct usbc_port_data *data = dev->data;
|
||||
|
@ -330,8 +325,7 @@ void prl_set_rev(const struct device *dev,
|
|||
* @brief Get the revision for the give packet type.
|
||||
* This function is called from the Policy Engine.
|
||||
*/
|
||||
enum pd_rev_type prl_get_rev(const struct device *dev,
|
||||
const enum pd_packet_type type)
|
||||
enum pd_rev_type prl_get_rev(const struct device *dev, const enum pd_packet_type type)
|
||||
{
|
||||
struct usbc_port_data *data = dev->data;
|
||||
|
||||
|
@ -343,9 +337,7 @@ enum pd_rev_type prl_get_rev(const struct device *dev,
|
|||
/**
|
||||
* @brief Alert Handler called by the TCPC driver
|
||||
*/
|
||||
static void alert_handler(const struct device *tcpc,
|
||||
void *port_dev,
|
||||
enum tcpc_alert alert)
|
||||
static void alert_handler(const struct device *tcpc, void *port_dev, enum tcpc_alert alert)
|
||||
{
|
||||
const struct device *dev = (const struct device *)port_dev;
|
||||
struct usbc_port_data *data = dev->data;
|
||||
|
@ -354,8 +346,7 @@ static void alert_handler(const struct device *tcpc,
|
|||
|
||||
switch (alert) {
|
||||
case TCPC_ALERT_HARD_RESET_RECEIVED:
|
||||
atomic_set_bit(&prl_hr->flags,
|
||||
PRL_FLAGS_PORT_PARTNER_HARD_RESET);
|
||||
atomic_set_bit(&prl_hr->flags, PRL_FLAGS_PORT_PARTNER_HARD_RESET);
|
||||
break;
|
||||
case TCPC_ALERT_TRANSMIT_MSG_FAILED:
|
||||
atomic_set_bit(&prl_tx->flags, PRL_FLAGS_TX_ERROR);
|
||||
|
@ -378,8 +369,7 @@ static void alert_handler(const struct device *tcpc,
|
|||
/**
|
||||
* @brief Set the Protocol Layer Message Transmission state
|
||||
*/
|
||||
static void prl_tx_set_state(const struct device *dev,
|
||||
const enum usbc_prl_tx_state_t state)
|
||||
static void prl_tx_set_state(const struct device *dev, const enum usbc_prl_tx_state_t state)
|
||||
{
|
||||
struct usbc_port_data *data = dev->data;
|
||||
struct protocol_layer_tx_t *prl_tx = data->prl_tx;
|
||||
|
@ -390,8 +380,7 @@ static void prl_tx_set_state(const struct device *dev,
|
|||
/**
|
||||
* @brief Set the Protocol Layer Hard Reset state
|
||||
*/
|
||||
static void prl_hr_set_state(const struct device *dev,
|
||||
const enum usbc_prl_hr_state_t state)
|
||||
static void prl_hr_set_state(const struct device *dev, const enum usbc_prl_hr_state_t state)
|
||||
{
|
||||
struct usbc_port_data *data = dev->data;
|
||||
struct protocol_hard_reset_t *prl_hr = data->prl_hr;
|
||||
|
@ -424,8 +413,7 @@ static void increment_msgid_counter(const struct device *dev)
|
|||
}
|
||||
|
||||
prl_tx->msg_id_counter[prl_tx->last_xmit_type] =
|
||||
(prl_tx->msg_id_counter[prl_tx->last_xmit_type] + 1) &
|
||||
PD_MESSAGE_ID_COUNT;
|
||||
(prl_tx->msg_id_counter[prl_tx->last_xmit_type] + 1) & PD_MESSAGE_ID_COUNT;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -442,11 +430,9 @@ static uint32_t get_sop_star_header(const struct device *dev)
|
|||
header.message_type = prl_tx->msg_type;
|
||||
header.port_data_role = is_sop_packet ? pe_get_data_role(dev) : 0;
|
||||
header.specification_revision = data->rev[prl_tx->emsg.type];
|
||||
header.port_power_role = is_sop_packet ?
|
||||
pe_get_power_role(dev) : pe_get_cable_plug(dev);
|
||||
header.port_power_role = is_sop_packet ? pe_get_power_role(dev) : pe_get_cable_plug(dev);
|
||||
header.message_id = prl_tx->msg_id_counter[prl_tx->emsg.type];
|
||||
header.number_of_data_objects =
|
||||
PD_CONVERT_BYTES_TO_PD_HEADER_COUNT(prl_tx->emsg.len);
|
||||
header.number_of_data_objects = PD_CONVERT_BYTES_TO_PD_HEADER_COUNT(prl_tx->emsg.len);
|
||||
header.extended = false;
|
||||
|
||||
return header.raw_value;
|
||||
|
@ -462,9 +448,8 @@ static void prl_tx_construct_message(const struct device *dev)
|
|||
const struct device *tcpc = data->tcpc;
|
||||
|
||||
/* The header is unused for hard reset, etc. */
|
||||
prl_tx->emsg.header.raw_value = prl_tx->emsg.type < NUM_SOP_STAR_TYPES ?
|
||||
get_sop_star_header(dev) : 0;
|
||||
|
||||
prl_tx->emsg.header.raw_value =
|
||||
prl_tx->emsg.type < NUM_SOP_STAR_TYPES ? get_sop_star_header(dev) : 0;
|
||||
|
||||
/* Save SOP* so the correct msg_id_counter can be incremented */
|
||||
prl_tx->last_xmit_type = prl_tx->emsg.type;
|
||||
|
@ -534,8 +519,7 @@ static void prl_init(const struct device *dev)
|
|||
|
||||
/* Initialize the PRL_HR state machine */
|
||||
prl_hr->flags = ATOMIC_INIT(0);
|
||||
usbc_timer_init(&prl_hr->pd_t_hard_reset_complete,
|
||||
PD_T_HARD_RESET_COMPLETE_MAX_MS);
|
||||
usbc_timer_init(&prl_hr->pd_t_hard_reset_complete, PD_T_HARD_RESET_COMPLETE_MAX_MS);
|
||||
prl_hr_set_state(dev, PRL_HR_WAIT_FOR_REQUEST);
|
||||
|
||||
/* Initialize the PRL_TX state machine */
|
||||
|
@ -626,8 +610,7 @@ static void prl_tx_wait_for_message_request_run(void *obj)
|
|||
/*
|
||||
* Soft Reset Message pending
|
||||
*/
|
||||
if ((prl_tx->msg_type == PD_CTRL_SOFT_RESET) &&
|
||||
(prl_tx->emsg.len == 0)) {
|
||||
if ((prl_tx->msg_type == PD_CTRL_SOFT_RESET) && (prl_tx->emsg.len == 0)) {
|
||||
prl_tx_set_state(dev, PRL_TX_LAYER_RESET_FOR_TRANSMIT);
|
||||
}
|
||||
/*
|
||||
|
|
|
@ -134,8 +134,7 @@ void prl_hard_reset_complete(const struct device *dev);
|
|||
* @param type SOP* packet sent from port partner
|
||||
* @param rev Revision sent from the port partner
|
||||
*/
|
||||
void prl_set_rev(const struct device *dev,
|
||||
const enum pd_packet_type type,
|
||||
void prl_set_rev(const struct device *dev, const enum pd_packet_type type,
|
||||
const enum pd_rev_type rev);
|
||||
|
||||
/**
|
||||
|
@ -146,8 +145,7 @@ void prl_set_rev(const struct device *dev,
|
|||
*
|
||||
* @retval revsion associated with the packet type
|
||||
*/
|
||||
enum pd_rev_type prl_get_rev(const struct device *dev,
|
||||
const enum pd_packet_type type);
|
||||
enum pd_rev_type prl_get_rev(const struct device *dev, const enum pd_packet_type type);
|
||||
|
||||
/**
|
||||
* @brief Instructs the Protocol Layer to send a Power Delivery control message
|
||||
|
@ -156,8 +154,7 @@ enum pd_rev_type prl_get_rev(const struct device *dev,
|
|||
* @param type The port partner to send this message to
|
||||
* @param msg The control message to send
|
||||
*/
|
||||
void prl_send_ctrl_msg(const struct device *dev,
|
||||
const enum pd_packet_type type,
|
||||
void prl_send_ctrl_msg(const struct device *dev, const enum pd_packet_type type,
|
||||
const enum pd_ctrl_msg_type msg);
|
||||
|
||||
/**
|
||||
|
@ -167,8 +164,7 @@ void prl_send_ctrl_msg(const struct device *dev,
|
|||
* @param type The port partner to send this message to
|
||||
* @param msg The data message to send
|
||||
*/
|
||||
void prl_send_data_msg(const struct device *dev,
|
||||
const enum pd_packet_type type,
|
||||
void prl_send_data_msg(const struct device *dev, const enum pd_packet_type type,
|
||||
const enum pd_data_msg_type msg);
|
||||
|
||||
/**
|
||||
|
|
|
@ -40,62 +40,50 @@ static ALWAYS_INLINE void usbc_handler(void *port_dev)
|
|||
k_msleep(CONFIG_USBC_STATE_MACHINE_CYCLE_TIME);
|
||||
}
|
||||
|
||||
#define USBC_SUBSYS_INIT(inst) \
|
||||
K_THREAD_STACK_DEFINE(my_stack_area_##inst, \
|
||||
CONFIG_USBC_STACK_SIZE); \
|
||||
\
|
||||
static struct tc_sm_t tc_##inst; \
|
||||
static struct policy_engine pe_##inst; \
|
||||
static struct protocol_layer_rx_t prl_rx_##inst; \
|
||||
static struct protocol_layer_tx_t prl_tx_##inst; \
|
||||
static struct protocol_hard_reset_t prl_hr_##inst; \
|
||||
\
|
||||
static void run_usbc_##inst(void *port_dev, \
|
||||
void *unused1, \
|
||||
void *unused2) \
|
||||
{ \
|
||||
while (1) { \
|
||||
usbc_handler(port_dev); \
|
||||
} \
|
||||
} \
|
||||
\
|
||||
static void create_thread_##inst(const struct device *dev) \
|
||||
{ \
|
||||
struct usbc_port_data *port = dev->data; \
|
||||
\
|
||||
port->port_thread = k_thread_create(&port->thread_data, \
|
||||
my_stack_area_##inst, \
|
||||
K_THREAD_STACK_SIZEOF(my_stack_area_##inst), \
|
||||
run_usbc_##inst, \
|
||||
(void *)dev, 0, 0, \
|
||||
CONFIG_USBC_THREAD_PRIORITY, \
|
||||
K_ESSENTIAL, \
|
||||
K_NO_WAIT); \
|
||||
k_thread_suspend(port->port_thread); \
|
||||
} \
|
||||
\
|
||||
static struct usbc_port_data usbc_port_data_##inst = { \
|
||||
.tc = &tc_##inst, \
|
||||
.pe = &pe_##inst, \
|
||||
.prl_rx = &prl_rx_##inst, \
|
||||
.prl_tx = &prl_tx_##inst, \
|
||||
.prl_hr = &prl_hr_##inst, \
|
||||
.tcpc = DEVICE_DT_GET(DT_INST_PROP(inst, tcpc)), \
|
||||
.vbus = DEVICE_DT_GET(DT_INST_PROP(inst, vbus)), \
|
||||
}; \
|
||||
\
|
||||
static const struct usbc_port_config usbc_port_config_##inst = { \
|
||||
.create_thread = create_thread_##inst, \
|
||||
}; \
|
||||
\
|
||||
DEVICE_DT_INST_DEFINE(inst, \
|
||||
&usbc_subsys_init, \
|
||||
NULL, \
|
||||
&usbc_port_data_##inst, \
|
||||
&usbc_port_config_##inst, \
|
||||
APPLICATION, \
|
||||
CONFIG_KERNEL_INIT_PRIORITY_DEFAULT, \
|
||||
NULL);
|
||||
#define USBC_SUBSYS_INIT(inst) \
|
||||
K_THREAD_STACK_DEFINE(my_stack_area_##inst, CONFIG_USBC_STACK_SIZE); \
|
||||
\
|
||||
static struct tc_sm_t tc_##inst; \
|
||||
static struct policy_engine pe_##inst; \
|
||||
static struct protocol_layer_rx_t prl_rx_##inst; \
|
||||
static struct protocol_layer_tx_t prl_tx_##inst; \
|
||||
static struct protocol_hard_reset_t prl_hr_##inst; \
|
||||
\
|
||||
static void run_usbc_##inst(void *port_dev, void *unused1, void *unused2) \
|
||||
{ \
|
||||
while (1) { \
|
||||
usbc_handler(port_dev); \
|
||||
} \
|
||||
} \
|
||||
\
|
||||
static void create_thread_##inst(const struct device *dev) \
|
||||
{ \
|
||||
struct usbc_port_data *port = dev->data; \
|
||||
\
|
||||
port->port_thread = k_thread_create( \
|
||||
&port->thread_data, my_stack_area_##inst, \
|
||||
K_THREAD_STACK_SIZEOF(my_stack_area_##inst), run_usbc_##inst, (void *)dev, \
|
||||
0, 0, CONFIG_USBC_THREAD_PRIORITY, K_ESSENTIAL, K_NO_WAIT); \
|
||||
k_thread_suspend(port->port_thread); \
|
||||
} \
|
||||
\
|
||||
static struct usbc_port_data usbc_port_data_##inst = { \
|
||||
.tc = &tc_##inst, \
|
||||
.pe = &pe_##inst, \
|
||||
.prl_rx = &prl_rx_##inst, \
|
||||
.prl_tx = &prl_tx_##inst, \
|
||||
.prl_hr = &prl_hr_##inst, \
|
||||
.tcpc = DEVICE_DT_GET(DT_INST_PROP(inst, tcpc)), \
|
||||
.vbus = DEVICE_DT_GET(DT_INST_PROP(inst, vbus)), \
|
||||
}; \
|
||||
\
|
||||
static const struct usbc_port_config usbc_port_config_##inst = { \
|
||||
.create_thread = create_thread_##inst, \
|
||||
}; \
|
||||
\
|
||||
DEVICE_DT_INST_DEFINE(inst, &usbc_subsys_init, NULL, &usbc_port_data_##inst, \
|
||||
&usbc_port_config_##inst, APPLICATION, \
|
||||
CONFIG_KERNEL_INIT_PRIORITY_DEFAULT, NULL);
|
||||
|
||||
DT_INST_FOREACH_STATUS_OKAY(USBC_SUBSYS_INIT)
|
||||
|
||||
|
@ -134,8 +122,7 @@ int usbc_suspend(const struct device *dev)
|
|||
* @brief Called by the Device Policy Manager to make a request of the
|
||||
* USB-C Subsystem
|
||||
*/
|
||||
int usbc_request(const struct device *dev,
|
||||
const enum usbc_policy_request_t req)
|
||||
int usbc_request(const struct device *dev, const enum usbc_policy_request_t req)
|
||||
{
|
||||
struct usbc_port_data *data = dev->data;
|
||||
|
||||
|
@ -149,8 +136,7 @@ int usbc_request(const struct device *dev,
|
|||
/**
|
||||
* @brief Sets the Device Policy Manager's data
|
||||
*/
|
||||
void usbc_set_dpm_data(const struct device *dev,
|
||||
void *dpm_data)
|
||||
void usbc_set_dpm_data(const struct device *dev, void *dpm_data)
|
||||
{
|
||||
struct usbc_port_data *data = dev->data;
|
||||
|
||||
|
@ -194,8 +180,7 @@ void usbc_set_policy_cb_set_src_cap(const struct device *dev,
|
|||
/**
|
||||
* @brief Set the callback for the Device Policy Manager policy check
|
||||
*/
|
||||
void usbc_set_policy_cb_check(const struct device *dev,
|
||||
const policy_cb_check_t policy_cb_check)
|
||||
void usbc_set_policy_cb_check(const struct device *dev, const policy_cb_check_t policy_cb_check)
|
||||
{
|
||||
struct usbc_port_data *data = dev->data;
|
||||
|
||||
|
@ -205,8 +190,7 @@ void usbc_set_policy_cb_check(const struct device *dev,
|
|||
/**
|
||||
* @brief Set the callback for the Device Policy Manager policy change notify
|
||||
*/
|
||||
void usbc_set_policy_cb_notify(const struct device *dev,
|
||||
const policy_cb_notify_t policy_cb_notify)
|
||||
void usbc_set_policy_cb_notify(const struct device *dev, const policy_cb_notify_t policy_cb_notify)
|
||||
{
|
||||
struct usbc_port_data *data = dev->data;
|
||||
|
||||
|
@ -239,8 +223,8 @@ void usbc_set_policy_cb_get_rdo(const struct device *dev,
|
|||
* @brief Set the callback for checking if Sink Power Supply is at
|
||||
* default level
|
||||
*/
|
||||
void usbc_set_policy_cb_is_snk_at_default(const struct device *dev,
|
||||
const policy_cb_is_snk_at_default_t 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 policy_cb_is_snk_at_default)
|
||||
{
|
||||
struct usbc_port_data *data = dev->data;
|
||||
|
||||
|
|
|
@ -14,8 +14,8 @@
|
|||
#include "usbc_pe.h"
|
||||
#include "usbc_prl.h"
|
||||
|
||||
#define PRIV_PORT_REQUEST_SUSPEND -1
|
||||
#define PRIV_PORT_REQUEST_START -2
|
||||
#define PRIV_PORT_REQUEST_SUSPEND -1
|
||||
#define PRIV_PORT_REQUEST_START -2
|
||||
|
||||
/**
|
||||
* @brief Each layer of the stack is composed of state machines that can be
|
||||
|
@ -131,16 +131,13 @@ struct usbc_port_data {
|
|||
* Callback used by the Policy Engine to get the Sink Capabilities
|
||||
* from the Device Policy Manager
|
||||
*/
|
||||
int (*policy_cb_get_snk_cap)(const struct device *dev,
|
||||
uint32_t **pdos,
|
||||
int *num_pdos);
|
||||
int (*policy_cb_get_snk_cap)(const struct device *dev, uint32_t **pdos, int *num_pdos);
|
||||
|
||||
/**
|
||||
* Callback used by the Policy Engine to send the received Source
|
||||
* Capabilities to the Device Policy Manager
|
||||
*/
|
||||
void (*policy_cb_set_src_cap)(const struct device *dev,
|
||||
const uint32_t *pdos,
|
||||
void (*policy_cb_set_src_cap)(const struct device *dev, const uint32_t *pdos,
|
||||
const int num_pdos);
|
||||
/**
|
||||
* Callback used by the Policy Engine to get the Request Data Object
|
||||
|
|
|
@ -68,8 +68,7 @@ void tc_run(const struct device *dev, const int32_t dpm_request)
|
|||
tcpc_get_cc(tcpc, &tc->cc1, &tc->cc2);
|
||||
|
||||
/* Detect polarity */
|
||||
tc->cc_polarity = (tc->cc1 > tc->cc2) ?
|
||||
TC_POLARITY_CC1 : TC_POLARITY_CC2;
|
||||
tc->cc_polarity = (tc->cc1 > tc->cc2) ? TC_POLARITY_CC1 : TC_POLARITY_CC2;
|
||||
|
||||
/* Execute any asyncronous Device Policy Manager Requests */
|
||||
if (dpm_request == REQUEST_TC_ERROR_RECOVERY) {
|
||||
|
@ -144,8 +143,7 @@ enum tc_state_t tc_get_state(const struct device *dev)
|
|||
/**
|
||||
* @brief Enable Power Delivery
|
||||
*/
|
||||
void tc_pd_enable(const struct device *dev,
|
||||
const bool enable)
|
||||
void tc_pd_enable(const struct device *dev, const bool enable)
|
||||
{
|
||||
if (enable) {
|
||||
prl_start(dev);
|
||||
|
|
|
@ -67,8 +67,7 @@ static void sink_power_sub_states(const struct device *dev)
|
|||
}
|
||||
|
||||
/* Notify DPM of sink sub-state power change */
|
||||
if (atomic_test_and_clear_bit(&tc->flags,
|
||||
TC_FLAGS_RP_SUBSTATE_CHANGE)) {
|
||||
if (atomic_test_and_clear_bit(&tc->flags, TC_FLAGS_RP_SUBSTATE_CHANGE)) {
|
||||
if (data->policy_cb_notify) {
|
||||
data->policy_cb_notify(dev, dpm_pwr_change_notify);
|
||||
}
|
||||
|
@ -138,7 +137,7 @@ void tc_attach_wait_snk_run(void *obj)
|
|||
|
||||
/* Wait for CC debounce */
|
||||
if (usbc_timer_running(&tc->tc_t_cc_debounce) &&
|
||||
usbc_timer_expired(&tc->tc_t_cc_debounce) == false) {
|
||||
usbc_timer_expired(&tc->tc_t_cc_debounce) == false) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -7,9 +7,9 @@
|
|||
#include "usbc_timer.h"
|
||||
|
||||
/** Timer flag to track if timer was started */
|
||||
#define TIMER_STARTED 0
|
||||
#define TIMER_STARTED 0
|
||||
/** Timer flag to track if timer has expired */
|
||||
#define TIMER_EXPIRED 1
|
||||
#define TIMER_EXPIRED 1
|
||||
|
||||
/**
|
||||
* @brief The timer function that's executed when the timer expires
|
||||
|
@ -21,8 +21,7 @@ static void usbc_timer_handler(struct k_timer *timer)
|
|||
atomic_set_bit(&usbc_timer->flags, TIMER_EXPIRED);
|
||||
}
|
||||
|
||||
void usbc_timer_init(struct usbc_timer_t *usbc_timer,
|
||||
uint32_t timeout_ms)
|
||||
void usbc_timer_init(struct usbc_timer_t *usbc_timer, uint32_t timeout_ms)
|
||||
{
|
||||
k_timer_init(&usbc_timer->timer, usbc_timer_handler, NULL);
|
||||
k_timer_user_data_set(&usbc_timer->timer, usbc_timer);
|
||||
|
|
|
@ -27,8 +27,7 @@ struct usbc_timer_t {
|
|||
* @param usbc_timer timer object
|
||||
* @param timeout_ms timer timeout in ms
|
||||
*/
|
||||
void usbc_timer_init(struct usbc_timer_t *usbc_timer,
|
||||
uint32_t timeout_ms);
|
||||
void usbc_timer_init(struct usbc_timer_t *usbc_timer, uint32_t timeout_ms);
|
||||
|
||||
/**
|
||||
* @brief Start a timer
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue