Lines Matching refs:dev

25 static void pe_set_ready_state(const struct device *dev)  in pe_set_ready_state()  argument
27 struct usbc_port_data *data = dev->data; in pe_set_ready_state()
30 pe_set_state(dev, PE_SRC_READY); in pe_set_ready_state()
32 pe_set_state(dev, PE_SNK_READY); in pe_set_ready_state()
41 bool common_dpm_requests(const struct device *dev) in common_dpm_requests() argument
43 struct usbc_port_data *data = dev->data; in common_dpm_requests()
50 pe_set_state(dev, PE_DRS_SEND_SWAP); in common_dpm_requests()
53 pe_set_state(dev, PE_SEND_SOFT_RESET); in common_dpm_requests()
64 void pe_subsys_init(const struct device *dev) in pe_subsys_init() argument
66 struct usbc_port_data *data = dev->data; in pe_subsys_init()
70 pe->dev = dev; in pe_subsys_init()
79 void pe_start(const struct device *dev) in pe_start() argument
81 struct usbc_port_data *data = dev->data; in pe_start()
89 void pe_suspend(const struct device *dev) in pe_suspend() argument
91 struct usbc_port_data *data = dev->data; in pe_suspend()
99 pe_set_state(dev, PE_SUSPEND); in pe_suspend()
105 static void pe_init(const struct device *dev) in pe_init() argument
107 struct usbc_port_data *data = dev->data; in pe_init()
121 pe_snk_init(dev); in pe_init()
123 pe_src_init(dev); in pe_init()
130 bool pe_is_running(const struct device *dev) in pe_is_running() argument
132 struct usbc_port_data *data = dev->data; in pe_is_running()
140 void pe_run(const struct device *dev, const int32_t dpm_request) in pe_run() argument
142 struct usbc_port_data *data = dev->data; in pe_run()
152 pe_init(dev); in pe_run()
161 if (prl_is_running(dev) == false) { in pe_run()
175 pe_set_state(dev, PE_SNK_HARD_RESET); in pe_run()
188 void pe_set_data_role(const struct device *dev, enum tc_data_role dr) in pe_set_data_role() argument
190 struct usbc_port_data *data = dev->data; in pe_set_data_role()
203 enum tc_data_role pe_get_data_role(const struct device *dev) in pe_get_data_role() argument
205 struct usbc_port_data *data = dev->data; in pe_get_data_role()
213 enum tc_power_role pe_get_power_role(const struct device *dev) in pe_get_power_role() argument
215 struct usbc_port_data *data = dev->data; in pe_get_power_role()
223 enum tc_cable_plug pe_get_cable_plug(const struct device *dev) in pe_get_cable_plug() argument
231 void pe_got_soft_reset(const struct device *dev) in pe_got_soft_reset() argument
237 pe_set_state(dev, PE_SOFT_RESET); in pe_got_soft_reset()
243 void pe_message_sent(const struct device *dev) in pe_message_sent() argument
245 struct usbc_port_data *data = dev->data; in pe_message_sent()
266 static bool pe_soft_reset_is_required(const struct device *dev, const enum pd_packet_type type) in pe_soft_reset_is_required() argument
268 struct usbc_port_data *data = dev->data; in pe_soft_reset_is_required()
302 void pe_report_error(const struct device *dev, const enum pe_error e, in pe_report_error() argument
305 struct usbc_port_data *data = dev->data; in pe_report_error()
312 if (pe_get_state(dev) == PE_SEND_SOFT_RESET || in pe_report_error()
313 pe_get_state(dev) == PE_SOFT_RESET) { in pe_report_error()
323 else if (pe_soft_reset_is_required(dev, type)) { in pe_report_error()
324 policy_notify(dev, PROTOCOL_ERROR); in pe_report_error()
325 pe_send_soft_reset(dev, type); in pe_report_error()
332 pe_set_ready_state(dev); in pe_report_error()
339 void pe_report_discard(const struct device *dev) in pe_report_discard() argument
341 struct usbc_port_data *data = dev->data; in pe_report_discard()
348 pe_dpm_end_ams(dev); in pe_report_discard()
356 void pe_message_received(const struct device *dev) in pe_message_received() argument
358 struct usbc_port_data *data = dev->data; in pe_message_received()
364 usbc_bypass_next_sleep(dev); in pe_message_received()
370 void pe_got_hard_reset(const struct device *dev) in pe_got_hard_reset() argument
372 pe_set_state(dev, PE_SNK_TRANSITION_TO_DEFAULT); in pe_got_hard_reset()
378 void pe_hard_reset_sent(const struct device *dev) in pe_hard_reset_sent() argument
380 struct usbc_port_data *data = dev->data; in pe_hard_reset_sent()
389 bool pe_is_explicit_contract(const struct device *dev) in pe_is_explicit_contract() argument
391 struct usbc_port_data *data = dev->data; in pe_is_explicit_contract()
401 bool pe_dpm_initiated_ams(const struct device *dev) in pe_dpm_initiated_ams() argument
403 struct usbc_port_data *data = dev->data; in pe_dpm_initiated_ams()
412 void pe_dpm_end_ams(const struct device *dev) in pe_dpm_end_ams() argument
414 struct usbc_port_data *data = dev->data; in pe_dpm_end_ams()
423 void pe_first_msg_sent(const struct device *dev) in pe_first_msg_sent() argument
425 struct usbc_port_data *data = dev->data; in pe_first_msg_sent()
436 void pe_set_state(const struct device *dev, const enum usbc_pe_state state) in pe_set_state() argument
438 struct usbc_port_data *data = dev->data; in pe_set_state()
444 usbc_bypass_next_sleep(dev); in pe_set_state()
450 enum usbc_pe_state pe_get_state(const struct device *dev) in pe_get_state() argument
452 struct usbc_port_data *data = dev->data; in pe_get_state()
460 enum usbc_pe_state pe_get_last_state(const struct device *dev) in pe_get_last_state() argument
462 struct usbc_port_data *data = dev->data; in pe_get_last_state()
470 void pe_send_soft_reset(const struct device *dev, const enum pd_packet_type type) in pe_send_soft_reset() argument
472 struct usbc_port_data *data = dev->data; in pe_send_soft_reset()
475 pe_set_state(dev, PE_SEND_SOFT_RESET); in pe_send_soft_reset()
481 void pe_send_data_msg(const struct device *dev, const enum pd_packet_type type, in pe_send_data_msg() argument
484 struct usbc_port_data *data = dev->data; in pe_send_data_msg()
489 prl_send_data_msg(dev, type, msg); in pe_send_data_msg()
495 void pe_send_ctrl_msg(const struct device *dev, const enum pd_packet_type type, in pe_send_ctrl_msg() argument
498 struct usbc_port_data *data = dev->data; in pe_send_ctrl_msg()
503 prl_send_ctrl_msg(dev, type, msg); in pe_send_ctrl_msg()
509 void pe_send_request_msg(const struct device *dev, const uint32_t rdo) in pe_send_request_msg() argument
511 struct usbc_port_data *data = dev->data; in pe_send_request_msg()
519 pe_send_data_msg(dev, PD_PACKET_SOP, PD_DATA_REQUEST); in pe_send_request_msg()
525 void extended_message_not_supported(const struct device *dev) in extended_message_not_supported() argument
527 struct usbc_port_data *data = dev->data; in extended_message_not_supported()
535 pe_set_state(dev, PE_CHUNK_RECEIVED); in extended_message_not_supported()
537 pe_set_state(dev, PE_SEND_NOT_SUPPORTED); in extended_message_not_supported()
544 bool received_control_message(const struct device *dev, const union pd_header header, in received_control_message() argument
547 struct usbc_port_data *data = dev->data; in received_control_message()
560 bool received_data_message(const struct device *dev, const union pd_header header, in received_data_message() argument
563 struct usbc_port_data *data = dev->data; in received_data_message()
576 bool policy_check(const struct device *dev, const enum usbc_policy_check_t pc) in policy_check() argument
578 struct usbc_port_data *data = dev->data; in policy_check()
581 return data->policy_cb_check(dev, pc); in policy_check()
590 void policy_notify(const struct device *dev, const enum usbc_policy_notify_t notify) in policy_notify() argument
592 struct usbc_port_data *data = dev->data; in policy_notify()
595 data->policy_cb_notify(dev, notify); in policy_notify()
602 bool policy_wait_notify(const struct device *dev, const enum usbc_policy_wait_t notify) in policy_wait_notify() argument
604 struct usbc_port_data *data = dev->data; in policy_wait_notify()
607 return data->policy_cb_wait_notify(dev, notify); in policy_wait_notify()
618 uint32_t policy_get_request_data_object(const struct device *dev) in policy_get_request_data_object() argument
620 struct usbc_port_data *data = dev->data; in policy_get_request_data_object()
625 return data->policy_cb_get_rdo(dev); in policy_get_request_data_object()
631 void policy_set_src_cap(const struct device *dev, const uint32_t *pdos, const int num_pdos) in policy_set_src_cap() argument
633 struct usbc_port_data *data = dev->data; in policy_set_src_cap()
636 data->policy_cb_set_src_cap(dev, pdos, num_pdos); in policy_set_src_cap()
643 bool policy_is_snk_at_default(const struct device *dev) in policy_is_snk_at_default() argument
645 struct usbc_port_data *data = dev->data; in policy_is_snk_at_default()
648 return data->policy_cb_is_snk_at_default(dev); in policy_is_snk_at_default()
657 void policy_get_snk_cap(const struct device *dev, uint32_t **pdos, int *num_pdos) in policy_get_snk_cap() argument
659 struct usbc_port_data *data = dev->data; in policy_get_snk_cap()
664 data->policy_cb_get_snk_cap(dev, pdos, num_pdos); in policy_get_snk_cap()
672 void policy_set_port_partner_snk_cap(const struct device *dev, in policy_set_port_partner_snk_cap() argument
676 struct usbc_port_data *data = dev->data; in policy_set_port_partner_snk_cap()
679 data->policy_cb_set_port_partner_snk_cap(dev, pdos, num_pdos); in policy_set_port_partner_snk_cap()
686 enum usbc_snk_req_reply_t policy_check_sink_request(const struct device *dev, in policy_check_sink_request() argument
689 struct usbc_port_data *data = dev->data; in policy_check_sink_request()
695 return data->policy_cb_check_sink_request(dev, request_msg); in policy_check_sink_request()
701 bool policy_present_contract_is_valid(const struct device *dev, in policy_present_contract_is_valid() argument
704 struct usbc_port_data *data = dev->data; in policy_present_contract_is_valid()
710 return data->policy_present_contract_is_valid(dev, present_contract); in policy_present_contract_is_valid()
716 bool policy_is_ps_ready(const struct device *dev) in policy_is_ps_ready() argument
718 struct usbc_port_data *data = dev->data; in policy_is_ps_ready()
724 return data->policy_is_ps_ready(dev); in policy_is_ps_ready()
731 bool policy_change_src_caps(const struct device *dev) in policy_change_src_caps() argument
733 struct usbc_port_data *data = dev->data; in policy_change_src_caps()
739 return data->policy_change_src_caps(dev); in policy_change_src_caps()
750 const struct device *dev = pe->dev; in pe_drs_evaluate_swap_entry() local
753 if (policy_check(dev, (pe->data_role == TC_ROLE_UFP) ? CHECK_DATA_ROLE_SWAP_TO_DFP in pe_drs_evaluate_swap_entry()
760 pe_send_ctrl_msg(dev, PD_PACKET_SOP, PD_CTRL_ACCEPT); in pe_drs_evaluate_swap_entry()
767 pe_send_ctrl_msg(dev, PD_PACKET_SOP, PD_CTRL_REJECT); in pe_drs_evaluate_swap_entry()
777 const struct device *dev = pe->dev; in pe_drs_evaluate_swap_run() local
778 struct usbc_port_data *data = dev->data; 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()
792 pe_set_ready_state(dev); in pe_drs_evaluate_swap_run()
798 policy_notify(dev, MSG_DISCARDED); in pe_drs_evaluate_swap_run()
799 pe_send_soft_reset(dev, prl_rx->emsg.type); in pe_drs_evaluate_swap_run()
811 const struct device *dev = pe->dev; in pe_drs_send_swap_entry() local
814 pe_send_ctrl_msg(dev, PD_PACKET_SOP, PD_CTRL_DR_SWAP); in pe_drs_send_swap_entry()
824 const struct device *dev = pe->dev; in pe_drs_send_swap_run() local
825 struct usbc_port_data *data = dev->data; in pe_drs_send_swap_run()
831 if (received_control_message(dev, header, PD_CTRL_REJECT)) { in pe_drs_send_swap_run()
836 policy_notify(dev, MSG_REJECTED_RECEIVED); in pe_drs_send_swap_run()
837 } else if (received_control_message(dev, header, PD_CTRL_WAIT)) { in pe_drs_send_swap_run()
842 if (policy_wait_notify(dev, WAIT_DATA_ROLE_SWAP)) { in pe_drs_send_swap_run()
846 } else if (received_control_message(dev, header, PD_CTRL_ACCEPT)) { 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()
860 usbc_request(dev, REQUEST_TC_ERROR_RECOVERY); in pe_drs_send_swap_run()
865 pe_set_ready_state(dev); in pe_drs_send_swap_run()
872 policy_notify(dev, MSG_DISCARDED); in pe_drs_send_swap_run()
873 pe_set_ready_state(dev); in pe_drs_send_swap_run()
886 const struct device *dev = pe->dev; in pe_get_sink_cap_entry() local
893 pe_send_ctrl_msg(dev, PD_PACKET_SOP, PD_CTRL_GET_SINK_CAP); in pe_get_sink_cap_entry()
905 const struct device *dev = pe->dev; in pe_get_sink_cap_run() local
906 struct usbc_port_data *data = dev->data; in pe_get_sink_cap_run()
922 if (received_data_message(dev, header, PD_DATA_SINK_CAP)) { in pe_get_sink_cap_run()
928 policy_set_port_partner_snk_cap(dev, pdos, num_pdos); in pe_get_sink_cap_run()
930 pe_set_ready_state(dev); in pe_get_sink_cap_run()
932 } else if (received_control_message(dev, header, PD_CTRL_REJECT) || in pe_get_sink_cap_run()
933 received_control_message(dev, in pe_get_sink_cap_run()
935 pe_set_ready_state(dev); in pe_get_sink_cap_run()
940 pe_send_soft_reset(dev, PD_PACKET_SOP); in pe_get_sink_cap_run()
948 policy_notify(dev, MSG_DISCARDED); in pe_get_sink_cap_run()
949 pe_set_ready_state(dev); in pe_get_sink_cap_run()
982 const struct device *dev = pe->dev; in pe_soft_reset_entry() local
985 prl_reset(dev); in pe_soft_reset_entry()
994 const struct device *dev = pe->dev; in pe_soft_reset_run() local
996 if (!prl_is_running(dev)) { in pe_soft_reset_run()
1003 pe_send_ctrl_msg(dev, PD_PACKET_SOP, PD_CTRL_ACCEPT); in pe_soft_reset_run()
1014 pe_set_state(dev, PE_SNK_WAIT_FOR_CAPABILITIES); in pe_soft_reset_run()
1022 pe_set_state(dev, PE_SNK_HARD_RESET); in pe_soft_reset_run()
1035 const struct device *dev = pe->dev; in pe_send_soft_reset_entry() local
1040 prl_reset(dev); in pe_send_soft_reset_entry()
1050 const struct device *dev = pe->dev; in pe_send_soft_reset_run() local
1051 struct usbc_port_data *data = dev->data; in pe_send_soft_reset_run()
1055 if (prl_is_running(dev) == false) { 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()
1067 policy_notify(dev, MSG_DISCARDED); in pe_send_soft_reset_run()
1068 pe_set_ready_state(dev); in pe_send_soft_reset_run()
1077 if (received_control_message(dev, header, PD_CTRL_ACCEPT)) { in pe_send_soft_reset_run()
1078 pe_set_state(dev, PE_SNK_WAIT_FOR_CAPABILITIES); in pe_send_soft_reset_run()
1086 pe_set_state(dev, PE_SNK_HARD_RESET); in pe_send_soft_reset_run()
1096 const struct device *dev = pe->dev; in pe_send_not_supported_entry() local
1101 policy_notify(dev, MSG_NOT_SUPPORTED_RECEIVED); in pe_send_not_supported_entry()
1104 if (prl_get_rev(dev, PD_PACKET_SOP) > PD_REV20) { in pe_send_not_supported_entry()
1105 pe_send_ctrl_msg(dev, PD_PACKET_SOP, PD_CTRL_NOT_SUPPORTED); in pe_send_not_supported_entry()
1107 pe_send_ctrl_msg(dev, PD_PACKET_SOP, PD_CTRL_REJECT); in pe_send_not_supported_entry()
1114 const struct device *dev = pe->dev; in pe_send_not_supported_run() local
1120 pe_set_ready_state(dev); in pe_send_not_supported_run()
1146 const struct device *dev = pe->dev; in pe_chunk_received_run() local
1154 pe_set_state(dev, PE_SEND_NOT_SUPPORTED); in pe_chunk_received_run()
1165 const struct device *dev = pe->dev; in pe_sender_response_run() local
1166 enum usbc_pe_state current_state = pe_get_state(dev); in pe_sender_response_run()
1183 pe_set_state(dev, PE_SNK_HARD_RESET); in pe_sender_response_run()
1186 pe_set_state(dev, PE_SNK_READY); in pe_sender_response_run()
1199 pe_set_state(dev, PE_SUSPEND); in pe_sender_response_run()
1211 usbc_request(dev, REQUEST_TC_ERROR_RECOVERY); in pe_sender_response_run()
1219 pe_set_state(dev, PE_SRC_HARD_RESET); in pe_sender_response_run()
1223 pe_send_soft_reset(dev, PD_PACKET_SOP); in pe_sender_response_run()
1232 pe_set_state(dev, PE_SNK_HARD_RESET); in pe_sender_response_run()
1235 pe_set_state(dev, PE_SNK_READY); in pe_sender_response_run()