Lines Matching full:pe
29 if (data->pe->power_role == TC_ROLE_SOURCE) { in pe_set_ready_state()
44 struct policy_engine *pe = data->pe; in common_dpm_requests() local
46 if (pe->dpm_request > REQUEST_TC_END) { in common_dpm_requests()
47 atomic_set_bit(pe->flags, PE_FLAGS_DPM_INITIATED_AMS); in common_dpm_requests()
49 if (pe->dpm_request == REQUEST_PE_DR_SWAP) { in common_dpm_requests()
52 } else if (pe->dpm_request == REQUEST_PE_SOFT_RESET_SEND) { in common_dpm_requests()
62 * @brief Initializes the PE state machine and enters the PE_SUSPEND state.
67 struct policy_engine *pe = data->pe; in pe_subsys_init() local
70 pe->dev = dev; in pe_subsys_init()
73 smf_set_initial(SMF_CTX(pe), &pe_states[PE_SUSPEND]); in pe_subsys_init()
108 struct policy_engine *pe = data->pe; in pe_init() local
111 atomic_clear(pe->flags); in pe_init()
114 usbc_timer_init(&pe->pd_t_sender_response, PD_T_NO_RESPONSE_MAX_MS); in pe_init()
115 usbc_timer_init(&pe->pd_t_chunking_not_supported, PD_T_CHUNKING_NOT_SUPPORTED_NOM_MS); in pe_init()
118 pe->hard_reset_counter = 0; in pe_init()
143 struct policy_engine *pe = data->pe; in pe_run() local
166 pe->dpm_request = dpm_request; in pe_run()
179 smf_run_state(SMF_CTX(pe)); in pe_run()
191 struct policy_engine *pe = data->pe; in pe_set_data_role() local
194 pe->data_role = dr; in pe_set_data_role()
197 tcpc_set_roles(data->tcpc, pe->power_role, pe->data_role); in pe_set_data_role()
207 return data->pe->data_role; in pe_get_data_role()
217 return data->pe->power_role; in pe_get_power_role()
246 struct policy_engine *pe = data->pe; in pe_message_sent() local
248 atomic_set_bit(pe->flags, PE_FLAGS_TX_COMPLETE); in pe_message_sent()
269 struct policy_engine *pe = data->pe; in pe_soft_reset_is_required() local
276 if (atomic_test_bit(pe->flags, PE_FLAGS_EXPLICIT_CONTRACT)) { in pe_soft_reset_is_required()
283 if (!atomic_test_bit(pe->flags, PE_FLAGS_FIRST_MSG_SENT)) { in pe_soft_reset_is_required()
291 if (atomic_test_bit(pe->flags, PE_FLAGS_INTERRUPTIBLE_AMS)) { in pe_soft_reset_is_required()
306 struct policy_engine *pe = data->pe; in pe_report_error() local
314 atomic_set_bit(pe->flags, PE_FLAGS_PROTOCOL_ERROR); in pe_report_error()
320 atomic_set_bit(pe->flags, PE_FLAGS_MSG_XMIT_ERROR); in pe_report_error()
342 struct policy_engine *pe = data->pe; in pe_report_discard() local
346 * the discard for the PE in pe_report_discard()
349 atomic_set_bit(pe->flags, PE_FLAGS_MSG_DISCARDED); in pe_report_discard()
359 struct policy_engine *pe = data->pe; in pe_message_received() local
361 atomic_set_bit(pe->flags, PE_FLAGS_MSG_RECEIVED); in pe_message_received()
363 /* Allow the PE to be executed once more and respond faster for the received message */ in pe_message_received()
381 struct policy_engine *pe = data->pe; in pe_hard_reset_sent() local
383 atomic_clear_bit(pe->flags, PE_FLAGS_HARD_RESET_PENDING); in pe_hard_reset_sent()
392 struct policy_engine *pe = data->pe; in pe_is_explicit_contract() local
394 return atomic_test_bit(pe->flags, PE_FLAGS_EXPLICIT_CONTRACT); in pe_is_explicit_contract()
398 * @brief Return true if the PE is within an atomic messaging sequence
404 struct policy_engine *pe = data->pe; in pe_dpm_initiated_ams() local
406 return atomic_test_bit(pe->flags, PE_FLAGS_DPM_INITIATED_AMS); in pe_dpm_initiated_ams()
415 struct policy_engine *pe = data->pe; in pe_dpm_end_ams() local
417 atomic_clear_bit(pe->flags, PE_FLAGS_DPM_INITIATED_AMS); in pe_dpm_end_ams()
426 struct policy_engine *pe = data->pe; in pe_first_msg_sent() local
428 atomic_set_bit(pe->flags, PE_FLAGS_FIRST_MSG_SENT); in pe_first_msg_sent()
441 smf_set_state(SMF_CTX(data->pe), &pe_states[state]); in pe_set_state()
443 /* Allow the PE to execute logic from the new state without additional delay */ in pe_set_state()
454 return data->pe->ctx.current - &pe_states[0]; in pe_get_state()
464 return data->pe->ctx.previous - &pe_states[0]; in pe_get_last_state()
474 data->pe->soft_reset_sop = type; in pe_send_soft_reset()
485 struct policy_engine *pe = data->pe; in pe_send_data_msg() local
488 atomic_clear_bit(pe->flags, PE_FLAGS_TX_COMPLETE); in pe_send_data_msg()
499 struct policy_engine *pe = data->pe; in pe_send_ctrl_msg() local
502 atomic_clear_bit(pe->flags, PE_FLAGS_TX_COMPLETE); in pe_send_ctrl_msg()
749 struct policy_engine *pe = (struct policy_engine *)obj; in pe_drs_evaluate_swap_entry() local
750 const struct device *dev = pe->dev; in pe_drs_evaluate_swap_entry()
753 if (policy_check(dev, (pe->data_role == TC_ROLE_UFP) ? CHECK_DATA_ROLE_SWAP_TO_DFP in pe_drs_evaluate_swap_entry()
776 struct policy_engine *pe = (struct policy_engine *)obj; in pe_drs_evaluate_swap_run() local
777 const struct device *dev = pe->dev; in pe_drs_evaluate_swap_run()
782 if (atomic_test_and_clear_bit(pe->flags, PE_FLAGS_TX_COMPLETE)) { in pe_drs_evaluate_swap_run()
786 pe_set_data_role(dev, (pe->data_role == TC_ROLE_UFP) in pe_drs_evaluate_swap_run()
789 policy_notify(dev, (pe->data_role == TC_ROLE_UFP) ? DATA_ROLE_IS_UFP in pe_drs_evaluate_swap_run()
793 } else if (atomic_test_and_clear_bit(pe->flags, PE_FLAGS_MSG_DISCARDED)) { in pe_drs_evaluate_swap_run()
810 struct policy_engine *pe = (struct policy_engine *)obj; in pe_drs_send_swap_entry() local
811 const struct device *dev = pe->dev; in pe_drs_send_swap_entry()
823 struct policy_engine *pe = (struct policy_engine *)obj; in pe_drs_send_swap_run() local
824 const struct device *dev = pe->dev; in pe_drs_send_swap_run()
829 if (atomic_test_and_clear_bit(pe->flags, PE_FLAGS_MSG_RECEIVED)) { in pe_drs_send_swap_run()
843 atomic_set_bit(pe->flags, PE_FLAGS_WAIT_DATA_ROLE_SWAP); in pe_drs_send_swap_run()
844 usbc_timer_start(&pe->pd_t_wait_to_resend); in pe_drs_send_swap_run()
848 pe->data_role = (pe->data_role == TC_ROLE_UFP) ? TC_ROLE_DFP : TC_ROLE_UFP; in pe_drs_send_swap_run()
850 tcpc_set_roles(data->tcpc, pe->power_role, pe->data_role); in pe_drs_send_swap_run()
852 policy_notify(dev, (pe->data_role == TC_ROLE_UFP) ? DATA_ROLE_IS_UFP in pe_drs_send_swap_run()
867 } else if (atomic_test_and_clear_bit(pe->flags, PE_FLAGS_MSG_DISCARDED)) { in pe_drs_send_swap_run()
885 struct policy_engine *pe = (struct policy_engine *)obj; in pe_get_sink_cap_entry() local
886 const struct device *dev = pe->dev; in pe_get_sink_cap_entry()
895 pe->submachine = SM_WAIT_FOR_TX; in pe_get_sink_cap_entry()
904 struct policy_engine *pe = (struct policy_engine *)obj; in pe_get_sink_cap_run() local
905 const struct device *dev = pe->dev; in pe_get_sink_cap_run()
910 switch (pe->submachine) { in pe_get_sink_cap_run()
912 if (!atomic_test_and_clear_bit(pe->flags, PE_FLAGS_TX_COMPLETE)) { in pe_get_sink_cap_run()
915 pe->submachine = SM_WAIT_FOR_RX; in pe_get_sink_cap_run()
918 if (atomic_test_and_clear_bit(pe->flags, PE_FLAGS_MSG_RECEIVED)) { in pe_get_sink_cap_run()
947 else if (atomic_test_and_clear_bit(pe->flags, PE_FLAGS_MSG_DISCARDED)) { in pe_get_sink_cap_run()
981 struct policy_engine *pe = (struct policy_engine *)obj; in pe_soft_reset_entry() local
982 const struct device *dev = pe->dev; in pe_soft_reset_entry()
987 /* Initialize PE Submachine */ in pe_soft_reset_entry()
988 pe->submachine = PE_SOFT_RESET_RUN_SEND_ACCEPT_MSG; in pe_soft_reset_entry()
993 struct policy_engine *pe = (struct policy_engine *)obj; in pe_soft_reset_run() local
994 const struct device *dev = pe->dev; in pe_soft_reset_run()
1000 switch (pe->submachine) { in pe_soft_reset_run()
1005 pe->submachine = PE_SOFT_RESET_RUN_SEND_ACCEPT_MSG_COMPLETE; in pe_soft_reset_run()
1013 if (atomic_test_and_clear_bit(pe->flags, PE_FLAGS_TX_COMPLETE)) { in pe_soft_reset_run()
1015 } else if (atomic_test_and_clear_bit(pe->flags, PE_FLAGS_PROTOCOL_ERROR)) { in pe_soft_reset_run()
1034 struct policy_engine *pe = (struct policy_engine *)obj; in pe_send_soft_reset_entry() local
1035 const struct device *dev = pe->dev; in pe_send_soft_reset_entry()
1041 atomic_set_bit(pe->flags, PE_FLAGS_SEND_SOFT_RESET); in pe_send_soft_reset_entry()
1049 struct policy_engine *pe = (struct policy_engine *)obj; in pe_send_soft_reset_run() local
1050 const struct device *dev = pe->dev; in pe_send_soft_reset_run()
1059 if (atomic_test_and_clear_bit(pe->flags, PE_FLAGS_SEND_SOFT_RESET)) { in pe_send_soft_reset_run()
1061 pe_send_ctrl_msg(dev, pe->soft_reset_sop, PD_CTRL_SOFT_RESET); in pe_send_soft_reset_run()
1065 if (atomic_test_and_clear_bit(pe->flags, PE_FLAGS_MSG_DISCARDED)) { in pe_send_soft_reset_run()
1069 } else if (atomic_test_and_clear_bit(pe->flags, PE_FLAGS_MSG_RECEIVED)) { in pe_send_soft_reset_run()
1080 } else if (atomic_test_and_clear_bit(pe->flags, PE_FLAGS_PROTOCOL_ERROR)) { in pe_send_soft_reset_run()
1095 struct policy_engine *pe = (struct policy_engine *)obj; in pe_send_not_supported_entry() local
1096 const struct device *dev = pe->dev; in pe_send_not_supported_entry()
1113 struct policy_engine *pe = (struct policy_engine *)obj; in pe_send_not_supported_run() local
1114 const struct device *dev = pe->dev; in pe_send_not_supported_run()
1116 if (atomic_test_bit(pe->flags, PE_FLAGS_TX_COMPLETE) || in pe_send_not_supported_run()
1117 atomic_test_bit(pe->flags, PE_FLAGS_MSG_DISCARDED)) { in pe_send_not_supported_run()
1118 atomic_clear_bit(pe->flags, PE_FLAGS_TX_COMPLETE); in pe_send_not_supported_run()
1119 atomic_clear_bit(pe->flags, PE_FLAGS_MSG_DISCARDED); in pe_send_not_supported_run()
1129 struct policy_engine *pe = (struct policy_engine *)obj; in pe_chunk_received_entry() local
1137 usbc_timer_start(&pe->pd_t_chunking_not_supported); in pe_chunk_received_entry()
1145 struct policy_engine *pe = (struct policy_engine *)obj; in pe_chunk_received_run() local
1146 const struct device *dev = pe->dev; in pe_chunk_received_run()
1153 if (usbc_timer_expired(&pe->pd_t_chunking_not_supported)) { in pe_chunk_received_run()
1164 struct policy_engine *pe = (struct policy_engine *)obj; in pe_sender_response_run() local
1165 const struct device *dev = pe->dev; in pe_sender_response_run()
1169 if (atomic_test_and_clear_bit(pe->flags, PE_FLAGS_TX_COMPLETE)) { in pe_sender_response_run()
1171 usbc_timer_start(&pe->pd_t_sender_response); in pe_sender_response_run()
1175 if (usbc_timer_expired(&pe->pd_t_sender_response)) { in pe_sender_response_run()
1197 if ((atomic_test_bit(pe->flags, PE_FLAGS_HAS_BEEN_PD_CONNECTED) == false) in pe_sender_response_run()
1198 && pe->hard_reset_counter > PD_N_HARD_RESET_COUNT) { in pe_sender_response_run()
1209 if (atomic_test_bit(pe->flags, PE_FLAGS_HAS_BEEN_PD_CONNECTED) in pe_sender_response_run()
1210 && pe->hard_reset_counter > PD_N_HARD_RESET_COUNT) { in pe_sender_response_run()
1247 struct policy_engine *pe = (struct policy_engine *)obj; in pe_sender_response_exit() local
1250 usbc_timer_stop(&pe->pd_t_sender_response); in pe_sender_response_exit()
1257 /* PE Super States */