usb_c: Add protocol error flag
Use a flag to report a protocol error to the states. This keeps state specific actions in the state. Currently, those state specific actions are handled in the pe_report_error function. Signed-off-by: Sam Hurst <sbh1187@gmail.com>
This commit is contained in:
parent
6984162e92
commit
f84ee58abd
|
@ -230,7 +230,7 @@ void pe_report_error(const struct device *dev, const enum pe_error e,
|
|||
*/
|
||||
if (pe_get_state(dev) == PE_SEND_SOFT_RESET ||
|
||||
pe_get_state(dev) == PE_SOFT_RESET) {
|
||||
pe_set_state(dev, PE_SNK_HARD_RESET);
|
||||
atomic_set_bit(pe->flags, PE_FLAGS_PROTOCOL_ERROR);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -106,6 +106,10 @@ enum pe_flags {
|
|||
* Data Role Swap
|
||||
*/
|
||||
PE_FLAGS_WAIT_DATA_ROLE_SWAP = 12,
|
||||
/**
|
||||
* This flag is set when a protocol error occurs.
|
||||
*/
|
||||
PE_FLAGS_PROTOCOL_ERROR = 13,
|
||||
|
||||
/** Number of PE Flags */
|
||||
PE_FLAGS_COUNT
|
||||
|
|
|
@ -725,10 +725,11 @@ void pe_send_soft_reset_run(void *obj)
|
|||
}
|
||||
/*
|
||||
* The Policy Engine Shall transition to the PE_SNK_Hard_Reset state when:
|
||||
* 1: A SenderResponseTimer timeout occurs (Handled in pe_report_error function)
|
||||
* 1: A SenderResponseTimer timeout occurs
|
||||
* 2: Or the Protocol Layer indicates that a transmission error has occurred
|
||||
*/
|
||||
else if (usbc_timer_expired(&pe->pd_t_sender_response)) {
|
||||
else if (usbc_timer_expired(&pe->pd_t_sender_response) ||
|
||||
atomic_test_and_clear_bit(pe->flags, PE_FLAGS_PROTOCOL_ERROR)) {
|
||||
pe_set_state(dev, PE_SNK_HARD_RESET);
|
||||
}
|
||||
}
|
||||
|
@ -774,23 +775,24 @@ void pe_soft_reset_run(void *obj)
|
|||
if (atomic_test_and_clear_bit(pe->flags, PE_FLAGS_SEND_SOFT_RESET)) {
|
||||
/* Send Accept message */
|
||||
pe_send_ctrl_msg(dev, PD_PACKET_SOP, PD_CTRL_ACCEPT);
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* The Policy Engine Shall transition to the PE_SNK_Wait_for_Capabilities
|
||||
* state when:
|
||||
* 1: The Accept Message has been sent on SOP.
|
||||
*/
|
||||
if (atomic_test_and_clear_bit(pe->flags, PE_FLAGS_TX_COMPLETE)) {
|
||||
else if (atomic_test_and_clear_bit(pe->flags, PE_FLAGS_TX_COMPLETE)) {
|
||||
pe_set_state(dev, PE_SNK_WAIT_FOR_CAPABILITIES);
|
||||
}
|
||||
/*
|
||||
* The Policy Engine Shall transition to the PE_SNK_Hard_Reset
|
||||
* state when:
|
||||
* 1: The Protocol Layer indicates that a transmission error
|
||||
* has occurred. (Handled in pe_report_error function)
|
||||
* has occurred.
|
||||
*/
|
||||
else if (atomic_test_and_clear_bit(pe->flags, PE_FLAGS_PROTOCOL_ERROR)) {
|
||||
pe_set_state(dev, PE_SNK_HARD_RESET);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue