Zephyr API Documentation 4.4.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
usbc_tcpc.h
Go to the documentation of this file.
1/*
2 * Copyright 2022 The Chromium OS Authors
3 * SPDX-License-Identifier: Apache-2.0
4 */
5
14
15#ifndef ZEPHYR_INCLUDE_DRIVERS_USBC_USBC_TCPC_H_
16#define ZEPHYR_INCLUDE_DRIVERS_USBC_USBC_TCPC_H_
17
26
27#include <zephyr/types.h>
28#include <zephyr/device.h>
29#include <errno.h>
30
31#include "usbc_tc.h"
32#include "usbc_pd.h"
33
34#ifdef __cplusplus
35extern "C" {
36#endif
37
81
101
123
135typedef int (*tcpc_vconn_control_cb_t)(const struct device *tcpc_dev, const struct device *usbc_dev,
136 enum tc_cc_polarity pol, bool enable);
137
149typedef int (*tcpc_vconn_discharge_cb_t)(const struct device *tcpc_dev,
150 const struct device *usbc_dev, enum tc_cc_polarity pol,
151 bool enable);
152
160typedef void (*tcpc_alert_handler_cb_t)(const struct device *dev, void *data,
161 enum tcpc_alert alert);
162
168
174typedef int (*tcpc_api_init_t)(const struct device *dev);
175
181typedef int (*tcpc_api_get_cc_t)(const struct device *dev, enum tc_cc_voltage_state *cc1,
182 enum tc_cc_voltage_state *cc2);
183
189typedef int (*tcpc_api_select_rp_value_t)(const struct device *dev, enum tc_rp_value rp);
190
196typedef int (*tcpc_api_get_rp_value_t)(const struct device *dev, enum tc_rp_value *rp);
197
203typedef int (*tcpc_api_set_cc_t)(const struct device *dev, enum tc_cc_pull pull);
204
210typedef void (*tcpc_api_set_vconn_discharge_cb_t)(const struct device *dev,
212 const struct device *usbc_dev);
213
219typedef void (*tcpc_api_set_vconn_cb_t)(const struct device *dev, tcpc_vconn_control_cb_t vconn_cb,
220 const struct device *usbc_dev);
221
227typedef int (*tcpc_api_vconn_discharge_t)(const struct device *dev, bool enable);
228
234typedef int (*tcpc_api_set_vconn_t)(const struct device *dev, bool enable);
235
241typedef int (*tcpc_api_set_roles_t)(const struct device *dev, enum tc_power_role power_role,
242 enum tc_data_role data_role);
243
249typedef int (*tcpc_api_get_rx_pending_msg_t)(const struct device *dev, struct pd_msg *msg);
250
256typedef int (*tcpc_api_set_rx_enable_t)(const struct device *dev, bool enable);
257
263typedef int (*tcpc_api_set_cc_polarity_t)(const struct device *dev, enum tc_cc_polarity polarity);
264
270typedef int (*tcpc_api_transmit_data_t)(const struct device *dev, struct pd_msg *msg);
271
277typedef int (*tcpc_api_dump_std_reg_t)(const struct device *dev);
278
284typedef int (*tcpc_api_get_status_register_t)(const struct device *dev, enum tcpc_status_reg reg,
285 uint32_t *status);
286
292typedef int (*tcpc_api_clear_status_register_t)(const struct device *dev, enum tcpc_status_reg reg,
293 uint32_t mask);
294
300typedef int (*tcpc_api_mask_status_register_t)(const struct device *dev, enum tcpc_status_reg reg,
301 uint32_t mask);
302
308typedef int (*tcpc_api_set_debug_accessory_t)(const struct device *dev, bool enable);
309
315typedef int (*tcpc_api_set_debug_detach_t)(const struct device *dev);
316
322typedef int (*tcpc_api_set_drp_toggle_t)(const struct device *dev, bool enable);
323
329typedef int (*tcpc_api_get_snk_ctrl_t)(const struct device *dev);
330
336typedef int (*tcpc_api_set_snk_ctrl_t)(const struct device *dev, bool enable);
337
343typedef int (*tcpc_api_get_src_ctrl_t)(const struct device *dev);
344
350typedef int (*tcpc_api_set_src_ctrl_t)(const struct device *dev, bool enable);
351
357typedef int (*tcpc_api_get_chip_info_t)(const struct device *dev, struct tcpc_chip_info *chip_info);
358
364typedef int (*tcpc_api_set_low_power_mode_t)(const struct device *dev, bool enable);
365
371typedef int (*tcpc_api_sop_prime_enable_t)(const struct device *dev, bool enable);
372
378typedef int (*tcpc_api_set_bist_test_mode_t)(const struct device *dev, bool enable);
379
385typedef int (*tcpc_api_set_alert_handler_cb_t)(const struct device *dev,
386 tcpc_alert_handler_cb_t handler, void *data);
387
453
455
459static inline int tcpc_is_cc_rp(enum tc_cc_voltage_state cc)
460{
461 return (cc == TC_CC_VOLT_RP_DEF) || (cc == TC_CC_VOLT_RP_1A5) || (cc == TC_CC_VOLT_RP_3A0);
462}
463
467static inline int tcpc_is_cc_open(enum tc_cc_voltage_state cc1, enum tc_cc_voltage_state cc2)
468{
469 return (cc1 < TC_CC_VOLT_RD) && (cc2 < TC_CC_VOLT_RD);
470}
471
476{
477 return cc1 == TC_CC_VOLT_RD && cc2 == TC_CC_VOLT_RD;
478}
479
484{
485 return tcpc_is_cc_rp(cc1) && tcpc_is_cc_rp(cc2);
486}
487
492{
493 return cc1 == TC_CC_VOLT_RA && cc2 == TC_CC_VOLT_RA;
494}
495
500 enum tc_cc_voltage_state cc2)
501{
502 return cc1 == TC_CC_VOLT_RD || cc2 == TC_CC_VOLT_RD;
503}
504
509{
510 return tcpc_is_cc_at_least_one_rd(cc1, cc2) && cc1 != cc2;
511}
512
522static inline int tcpc_init(const struct device *dev)
523{
524 const struct tcpc_driver_api *api = DEVICE_API_GET(tcpc, dev);
525
526 __ASSERT(api->init != NULL, "Callback pointer should not be NULL");
527
528 return api->init(dev);
529}
530
542static inline int tcpc_get_cc(const struct device *dev, enum tc_cc_voltage_state *cc1,
543 enum tc_cc_voltage_state *cc2)
544{
545 const struct tcpc_driver_api *api = DEVICE_API_GET(tcpc, dev);
546
547 if (api->get_cc == NULL) {
548 return -ENOSYS;
549 }
550
551 return api->get_cc(dev, cc1, cc2);
552}
553
564static inline int tcpc_select_rp_value(const struct device *dev, enum tc_rp_value rp)
565{
566 const struct tcpc_driver_api *api = DEVICE_API_GET(tcpc, dev);
567
568 if (api->select_rp_value == NULL) {
569 return -ENOSYS;
570 }
571
572 return api->select_rp_value(dev, rp);
573}
574
585static inline int tcpc_get_rp_value(const struct device *dev, enum tc_rp_value *rp)
586{
587 const struct tcpc_driver_api *api = DEVICE_API_GET(tcpc, dev);
588
589 if (api->get_rp_value == NULL) {
590 return -ENOSYS;
591 }
592
593 return api->get_rp_value(dev, rp);
594}
595
605static inline int tcpc_set_cc(const struct device *dev, enum tc_cc_pull pull)
606{
607 const struct tcpc_driver_api *api = DEVICE_API_GET(tcpc, dev);
608
609 __ASSERT(api->set_cc != NULL, "Callback pointer should not be NULL");
610
611 return api->set_cc(dev, pull);
612}
613
625static inline void tcpc_set_vconn_cb(const struct device *dev, tcpc_vconn_control_cb_t vconn_cb,
626 const struct device *usbc_dev)
627{
628 const struct tcpc_driver_api *api = DEVICE_API_GET(tcpc, dev);
629
630 __ASSERT(api->set_vconn_cb != NULL, "Callback pointer should not be NULL");
631
632 api->set_vconn_cb(dev, vconn_cb, usbc_dev);
633}
634
646static inline void tcpc_set_vconn_discharge_cb(const struct device *dev,
648 const struct device *usbc_dev)
649{
650 const struct tcpc_driver_api *api = DEVICE_API_GET(tcpc, dev);
651
652 __ASSERT(api->set_vconn_discharge_cb != NULL, "Callback pointer should not be NULL");
653
654 api->set_vconn_discharge_cb(dev, cb, usbc_dev);
655}
656
670static inline int tcpc_vconn_discharge(const struct device *dev, bool enable)
671{
672 const struct tcpc_driver_api *api = DEVICE_API_GET(tcpc, dev);
673
674 if (api->vconn_discharge == NULL) {
675 return -ENOSYS;
676 }
677
678 return api->vconn_discharge(dev, enable);
679}
680
694static inline int tcpc_set_vconn(const struct device *dev, bool enable)
695{
696 const struct tcpc_driver_api *api = DEVICE_API_GET(tcpc, dev);
697
698 if (api->set_vconn == NULL) {
699 return -ENOSYS;
700 }
701
702 return api->set_vconn(dev, enable);
703}
704
718static inline int tcpc_set_roles(const struct device *dev, enum tc_power_role power_role,
719 enum tc_data_role data_role)
720{
721 const struct tcpc_driver_api *api = DEVICE_API_GET(tcpc, dev);
722
723 if (api->set_roles == NULL) {
724 return -ENOSYS;
725 }
726
727 return api->set_roles(dev, power_role, data_role);
728}
729
743static inline int tcpc_get_rx_pending_msg(const struct device *dev, struct pd_msg *buf)
744{
745 const struct tcpc_driver_api *api = DEVICE_API_GET(tcpc, dev);
746
747 __ASSERT(api->get_rx_pending_msg != NULL, "Callback pointer should not be NULL");
748
749 return api->get_rx_pending_msg(dev, buf);
750}
751
763static inline int tcpc_set_rx_enable(const struct device *dev, bool enable)
764{
765 const struct tcpc_driver_api *api = DEVICE_API_GET(tcpc, dev);
766
767 if (api->set_rx_enable == NULL) {
768 return -ENOSYS;
769 }
770
771 return api->set_rx_enable(dev, enable);
772}
773
783static inline int tcpc_set_cc_polarity(const struct device *dev, enum tc_cc_polarity polarity)
784{
785 const struct tcpc_driver_api *api = DEVICE_API_GET(tcpc, dev);
786
787 __ASSERT(api->set_cc_polarity != NULL, "Callback pointer should not be NULL");
788
789 return api->set_cc_polarity(dev, polarity);
790}
791
802static inline int tcpc_transmit_data(const struct device *dev, struct pd_msg *msg)
803{
804 const struct tcpc_driver_api *api = DEVICE_API_GET(tcpc, dev);
805
806 if (api->transmit_data == NULL) {
807 return -ENOSYS;
808 }
809
810 return api->transmit_data(dev, msg);
811}
812
822static inline int tcpc_dump_std_reg(const struct device *dev)
823{
824 const struct tcpc_driver_api *api = DEVICE_API_GET(tcpc, dev);
825
826 if (api->dump_std_reg == NULL) {
827 return -ENOSYS;
828 }
829
830 return api->dump_std_reg(dev);
831}
832
846static inline int tcpc_set_alert_handler_cb(const struct device *dev,
847 tcpc_alert_handler_cb_t handler, void *data)
848{
849 const struct tcpc_driver_api *api = DEVICE_API_GET(tcpc, dev);
850
851 __ASSERT(api->set_alert_handler_cb != NULL, "Callback pointer should not be NULL");
852
853 return api->set_alert_handler_cb(dev, handler, data);
854}
855
867static inline int tcpc_get_status_register(const struct device *dev, enum tcpc_status_reg reg,
868 uint32_t *status)
869{
870 const struct tcpc_driver_api *api = DEVICE_API_GET(tcpc, dev);
871
872 if (api->get_status_register == NULL) {
873 return -ENOSYS;
874 }
875
876 return api->get_status_register(dev, reg, status);
877}
878
891static inline int tcpc_clear_status_register(const struct device *dev, enum tcpc_status_reg reg,
892 uint32_t mask)
893{
894 const struct tcpc_driver_api *api = DEVICE_API_GET(tcpc, dev);
895
896 if (api->clear_status_register == NULL) {
897 return -ENOSYS;
898 }
899
900 return api->clear_status_register(dev, reg, mask);
901}
902
915static inline int tcpc_mask_status_register(const struct device *dev, enum tcpc_status_reg reg,
916 uint32_t mask)
917{
918 const struct tcpc_driver_api *api = DEVICE_API_GET(tcpc, dev);
919
920 if (api->mask_status_register == NULL) {
921 return -ENOSYS;
922 }
923
924 return api->mask_status_register(dev, reg, mask);
925}
926
937static inline int tcpc_set_debug_accessory(const struct device *dev, bool enable)
938{
939 const struct tcpc_driver_api *api = DEVICE_API_GET(tcpc, dev);
940
941 if (api->set_debug_accessory == NULL) {
942 return -ENOSYS;
943 }
944
945 return api->set_debug_accessory(dev, enable);
946}
947
957static inline int tcpc_set_debug_detach(const struct device *dev)
958{
959 const struct tcpc_driver_api *api = DEVICE_API_GET(tcpc, dev);
960
961 if (api->set_debug_detach == NULL) {
962 return -ENOSYS;
963 }
964
965 return api->set_debug_detach(dev);
966}
967
978static inline int tcpc_set_drp_toggle(const struct device *dev, bool enable)
979{
980 const struct tcpc_driver_api *api = DEVICE_API_GET(tcpc, dev);
981
982 if (api->set_drp_toggle == NULL) {
983 return -ENOSYS;
984 }
985
986 return api->set_drp_toggle(dev, enable);
987}
988
998static inline int tcpc_get_snk_ctrl(const struct device *dev)
999{
1000 const struct tcpc_driver_api *api = DEVICE_API_GET(tcpc, dev);
1001
1002 if (api->get_snk_ctrl == NULL) {
1003 return -ENOSYS;
1004 }
1005
1006 return api->get_snk_ctrl(dev);
1007}
1008
1017static inline int tcpc_set_snk_ctrl(const struct device *dev, bool enable)
1018{
1019 const struct tcpc_driver_api *api = DEVICE_API_GET(tcpc, dev);
1020
1021 if (api->set_snk_ctrl == NULL) {
1022 return -ENOSYS;
1023 }
1024
1025 return api->set_snk_ctrl(dev, enable);
1026}
1027
1037static inline int tcpc_get_src_ctrl(const struct device *dev)
1038{
1039 const struct tcpc_driver_api *api = DEVICE_API_GET(tcpc, dev);
1040
1041 if (api->get_src_ctrl == NULL) {
1042 return -ENOSYS;
1043 }
1044
1045 return api->get_src_ctrl(dev);
1046}
1047
1056static inline int tcpc_set_src_ctrl(const struct device *dev, bool enable)
1057{
1058 const struct tcpc_driver_api *api = DEVICE_API_GET(tcpc, dev);
1059
1060 if (api->set_src_ctrl == NULL) {
1061 return -ENOSYS;
1062 }
1063
1064 return api->set_src_ctrl(dev, enable);
1065}
1066
1078static inline int tcpc_set_bist_test_mode(const struct device *dev, bool enable)
1079{
1080 const struct tcpc_driver_api *api = DEVICE_API_GET(tcpc, dev);
1081
1082 if (api->set_bist_test_mode == NULL) {
1083 return -ENOSYS;
1084 }
1085
1086 return api->set_bist_test_mode(dev, enable);
1087}
1088
1099static inline int tcpc_get_chip_info(const struct device *dev, struct tcpc_chip_info *chip_info)
1100{
1101 const struct tcpc_driver_api *api = DEVICE_API_GET(tcpc, dev);
1102
1103 if (api->get_chip_info == NULL) {
1104 return -ENOSYS;
1105 }
1106
1107 return api->get_chip_info(dev, chip_info);
1108}
1109
1120static inline int tcpc_set_low_power_mode(const struct device *dev, bool enable)
1121{
1122 const struct tcpc_driver_api *api = DEVICE_API_GET(tcpc, dev);
1123
1124 if (api->set_low_power_mode == NULL) {
1125 return -ENOSYS;
1126 }
1127
1128 return api->set_low_power_mode(dev, enable);
1129}
1130
1142static inline int tcpc_sop_prime_enable(const struct device *dev, bool enable)
1143{
1144 const struct tcpc_driver_api *api = DEVICE_API_GET(tcpc, dev);
1145
1146 if (api->sop_prime_enable == NULL) {
1147 return -ENOSYS;
1148 }
1149
1150 return api->sop_prime_enable(dev, enable);
1151}
1152
1156
1157#ifdef __cplusplus
1158}
1159#endif
1160
1161#endif /* ZEPHYR_INCLUDE_DRIVERS_USBC_USBC_TCPC_H_ */
#define DEVICE_API_GET(_class, _dev)
Expands to the pointer of a device's API for a given class.
Definition device.h:1425
System error numbers.
#define ENOSYS
Function not implemented.
Definition errno.h:82
int(* tcpc_api_get_status_register_t)(const struct device *dev, enum tcpc_status_reg reg, uint32_t *status)
Callback API to get a status register.
Definition usbc_tcpc.h:284
int(* tcpc_api_sop_prime_enable_t)(const struct device *dev, bool enable)
Callback API to enable or disable SOP' / SOP'' reception.
Definition usbc_tcpc.h:371
int(* tcpc_api_set_debug_accessory_t)(const struct device *dev, bool enable)
Callback API to enable or disable debug accessory control.
Definition usbc_tcpc.h:308
void(* tcpc_api_set_vconn_cb_t)(const struct device *dev, tcpc_vconn_control_cb_t vconn_cb, const struct device *usbc_dev)
Callback API to register the VCONN control application callback.
Definition usbc_tcpc.h:219
int(* tcpc_api_get_src_ctrl_t)(const struct device *dev)
Callback API to query VBUS source control state.
Definition usbc_tcpc.h:343
int(* tcpc_api_get_cc_t)(const struct device *dev, enum tc_cc_voltage_state *cc1, enum tc_cc_voltage_state *cc2)
Callback API to read CC line status.
Definition usbc_tcpc.h:181
int(* tcpc_api_set_debug_detach_t)(const struct device *dev)
Callback API to detach from a debug connection.
Definition usbc_tcpc.h:315
int(* tcpc_api_set_alert_handler_cb_t)(const struct device *dev, tcpc_alert_handler_cb_t handler, void *data)
Callback API to register the alert application callback.
Definition usbc_tcpc.h:385
int(* tcpc_api_set_drp_toggle_t)(const struct device *dev, bool enable)
Callback API to enable or disable DRP toggle.
Definition usbc_tcpc.h:322
int(* tcpc_api_set_rx_enable_t)(const struct device *dev, bool enable)
Callback API to enable or disable SOP* RX.
Definition usbc_tcpc.h:256
int(* tcpc_api_set_src_ctrl_t)(const struct device *dev, bool enable)
Callback API to enable or disable VBUS sourcing.
Definition usbc_tcpc.h:350
int(* tcpc_api_clear_status_register_t)(const struct device *dev, enum tcpc_status_reg reg, uint32_t mask)
Callback API to clear bits in a status register.
Definition usbc_tcpc.h:292
int(* tcpc_api_dump_std_reg_t)(const struct device *dev)
Callback API to dump standard TCPC registers.
Definition usbc_tcpc.h:277
int(* tcpc_api_mask_status_register_t)(const struct device *dev, enum tcpc_status_reg reg, uint32_t mask)
Callback API to mask or unmask status register bits.
Definition usbc_tcpc.h:300
int(* tcpc_api_set_cc_polarity_t)(const struct device *dev, enum tc_cc_polarity polarity)
Callback API to set CC polarity.
Definition usbc_tcpc.h:263
int(* tcpc_api_set_snk_ctrl_t)(const struct device *dev, bool enable)
Callback API to enable or disable VBUS sinking.
Definition usbc_tcpc.h:336
int(* tcpc_api_get_rx_pending_msg_t)(const struct device *dev, struct pd_msg *msg)
Callback API to get a pending RX message or query RX status.
Definition usbc_tcpc.h:249
int(* tcpc_api_transmit_data_t)(const struct device *dev, struct pd_msg *msg)
Callback API to transmit a PD message.
Definition usbc_tcpc.h:270
int(* tcpc_api_vconn_discharge_t)(const struct device *dev, bool enable)
Callback API to enable or disable VCONN discharge.
Definition usbc_tcpc.h:227
int(* tcpc_api_get_snk_ctrl_t)(const struct device *dev)
Callback API to query VBUS sink control state.
Definition usbc_tcpc.h:329
int(* tcpc_api_set_cc_t)(const struct device *dev, enum tc_cc_pull pull)
Callback API to set CC pull and role.
Definition usbc_tcpc.h:203
int(* tcpc_api_get_chip_info_t)(const struct device *dev, struct tcpc_chip_info *chip_info)
Callback API to read TCPC chip information.
Definition usbc_tcpc.h:357
int(* tcpc_api_get_rp_value_t)(const struct device *dev, enum tc_rp_value *rp)
Callback API to get source Rp value.
Definition usbc_tcpc.h:196
void(* tcpc_api_set_vconn_discharge_cb_t)(const struct device *dev, tcpc_vconn_discharge_cb_t cb, const struct device *usbc_dev)
Callback API to register the VCONN discharge application callback.
Definition usbc_tcpc.h:210
int(* tcpc_api_set_roles_t)(const struct device *dev, enum tc_power_role power_role, enum tc_data_role data_role)
Callback API to set power and data roles for PD message header.
Definition usbc_tcpc.h:241
int(* tcpc_api_init_t)(const struct device *dev)
Callback API to initialize the TCPC.
Definition usbc_tcpc.h:174
int(* tcpc_api_set_low_power_mode_t)(const struct device *dev, bool enable)
Callback API to enter or exit low power mode.
Definition usbc_tcpc.h:364
int(* tcpc_api_select_rp_value_t)(const struct device *dev, enum tc_rp_value rp)
Callback API to set source Rp value.
Definition usbc_tcpc.h:189
int(* tcpc_api_set_bist_test_mode_t)(const struct device *dev, bool enable)
Callback API to enable or disable BIST test mode.
Definition usbc_tcpc.h:378
int(* tcpc_api_set_vconn_t)(const struct device *dev, bool enable)
Callback API to enable or disable VCONN.
Definition usbc_tcpc.h:234
static int tcpc_clear_status_register(const struct device *dev, enum tcpc_status_reg reg, uint32_t mask)
Clears a TCPC status register.
Definition usbc_tcpc.h:891
static int tcpc_set_debug_accessory(const struct device *dev, bool enable)
Manual control of TCPC DebugAccessory control.
Definition usbc_tcpc.h:937
static int tcpc_is_cc_src_dbg_acc(enum tc_cc_voltage_state cc1, enum tc_cc_voltage_state cc2)
Returns true if we detect the port partner is a src debug accessory.
Definition usbc_tcpc.h:483
static int tcpc_get_src_ctrl(const struct device *dev)
Queries the current sourcing state of the TCPC.
Definition usbc_tcpc.h:1037
int(* tcpc_vconn_control_cb_t)(const struct device *tcpc_dev, const struct device *usbc_dev, enum tc_cc_polarity pol, bool enable)
Callback type for VCONN control.
Definition usbc_tcpc.h:135
static int tcpc_get_snk_ctrl(const struct device *dev)
Queries the current sinking state of the TCPC.
Definition usbc_tcpc.h:998
static int tcpc_mask_status_register(const struct device *dev, enum tcpc_status_reg reg, uint32_t mask)
Sets the mask of a TCPC status register.
Definition usbc_tcpc.h:915
static int tcpc_is_cc_open(enum tc_cc_voltage_state cc1, enum tc_cc_voltage_state cc2)
Returns true if both CC lines are completely open.
Definition usbc_tcpc.h:467
static int tcpc_is_cc_audio_acc(enum tc_cc_voltage_state cc1, enum tc_cc_voltage_state cc2)
Returns true if the port partner is an audio accessory.
Definition usbc_tcpc.h:491
static void tcpc_set_vconn_cb(const struct device *dev, tcpc_vconn_control_cb_t vconn_cb, const struct device *usbc_dev)
Sets a callback that can enable or disable VCONN if the TCPC is unable to or the system is configured...
Definition usbc_tcpc.h:625
static int tcpc_set_vconn(const struct device *dev, bool enable)
Enables or disables VCONN.
Definition usbc_tcpc.h:694
static int tcpc_get_rp_value(const struct device *dev, enum tc_rp_value *rp)
Gets the value of the CC pull up resistor used when operating as a Source.
Definition usbc_tcpc.h:585
static int tcpc_get_rx_pending_msg(const struct device *dev, struct pd_msg *buf)
Retrieves the Power Delivery message from the TCPC.
Definition usbc_tcpc.h:743
static int tcpc_vconn_discharge(const struct device *dev, bool enable)
Discharges VCONN.
Definition usbc_tcpc.h:670
static int tcpc_select_rp_value(const struct device *dev, enum tc_rp_value rp)
Sets the value of CC pull up resistor used when operating as a Source.
Definition usbc_tcpc.h:564
tcpc_alert
TCPC Alert bits.
Definition usbc_tcpc.h:41
int(* tcpc_vconn_discharge_cb_t)(const struct device *tcpc_dev, const struct device *usbc_dev, enum tc_cc_polarity pol, bool enable)
Callback type for discharging VCONN.
Definition usbc_tcpc.h:149
static int tcpc_set_cc_polarity(const struct device *dev, enum tc_cc_polarity polarity)
Sets the polarity of the CC lines.
Definition usbc_tcpc.h:783
void(* tcpc_alert_handler_cb_t)(const struct device *dev, void *data, enum tcpc_alert alert)
Callback type for handling TCPC alert events.
Definition usbc_tcpc.h:160
static int tcpc_get_cc(const struct device *dev, enum tc_cc_voltage_state *cc1, enum tc_cc_voltage_state *cc2)
Reads the status of the CC lines.
Definition usbc_tcpc.h:542
static int tcpc_is_cc_rp(enum tc_cc_voltage_state cc)
Returns whether the sink has detected a Rp resistor on the other side.
Definition usbc_tcpc.h:459
static void tcpc_set_vconn_discharge_cb(const struct device *dev, tcpc_vconn_discharge_cb_t cb, const struct device *usbc_dev)
Sets a callback that can enable or discharge VCONN if the TCPC is unable to or the system is configur...
Definition usbc_tcpc.h:646
static int tcpc_set_alert_handler_cb(const struct device *dev, tcpc_alert_handler_cb_t handler, void *data)
Sets the alert function that's called when an interrupt is triggered due to an alert bit.
Definition usbc_tcpc.h:846
static int tcpc_set_snk_ctrl(const struct device *dev, bool enable)
Set the VBUS sinking state of the TCPC.
Definition usbc_tcpc.h:1017
static int tcpc_get_chip_info(const struct device *dev, struct tcpc_chip_info *chip_info)
Gets the TCPC firmware version.
Definition usbc_tcpc.h:1099
static int tcpc_transmit_data(const struct device *dev, struct pd_msg *msg)
Transmits a Power Delivery message.
Definition usbc_tcpc.h:802
static int tcpc_set_roles(const struct device *dev, enum tc_power_role power_role, enum tc_data_role data_role)
Sets the Power and Data Role of the PD message header.
Definition usbc_tcpc.h:718
static int tcpc_set_src_ctrl(const struct device *dev, bool enable)
Set the VBUS sourcing state of the TCPC.
Definition usbc_tcpc.h:1056
static int tcpc_set_rx_enable(const struct device *dev, bool enable)
Enables the reception of SOP* message types.
Definition usbc_tcpc.h:763
static int tcpc_is_cc_only_one_rd(enum tc_cc_voltage_state cc1, enum tc_cc_voltage_state cc2)
Returns true if the port partner is presenting Rd on only one CC line.
Definition usbc_tcpc.h:508
static int tcpc_dump_std_reg(const struct device *dev)
Dump a set of TCPC registers.
Definition usbc_tcpc.h:822
static int tcpc_set_low_power_mode(const struct device *dev, bool enable)
Instructs the TCPC to enter or exit low power mode.
Definition usbc_tcpc.h:1120
static int tcpc_set_drp_toggle(const struct device *dev, bool enable)
Enable TCPC auto dual role toggle.
Definition usbc_tcpc.h:978
static int tcpc_is_cc_snk_dbg_acc(enum tc_cc_voltage_state cc1, enum tc_cc_voltage_state cc2)
Returns true if we detect the port partner is a snk debug accessory.
Definition usbc_tcpc.h:475
static int tcpc_set_debug_detach(const struct device *dev)
Detach from a debug connection.
Definition usbc_tcpc.h:957
static int tcpc_sop_prime_enable(const struct device *dev, bool enable)
Enables the reception of SOP Prime and optionally SOP Double Prime messages.
Definition usbc_tcpc.h:1142
static int tcpc_is_cc_at_least_one_rd(enum tc_cc_voltage_state cc1, enum tc_cc_voltage_state cc2)
Returns true if the port partner is presenting at least one Rd.
Definition usbc_tcpc.h:499
static int tcpc_init(const struct device *dev)
Initializes the TCPC.
Definition usbc_tcpc.h:522
static int tcpc_set_cc(const struct device *dev, enum tc_cc_pull pull)
Sets the CC pull resistor and sets the role as either Source or Sink.
Definition usbc_tcpc.h:605
static int tcpc_set_bist_test_mode(const struct device *dev, bool enable)
Controls the BIST Mode of the TCPC.
Definition usbc_tcpc.h:1078
static int tcpc_get_status_register(const struct device *dev, enum tcpc_status_reg reg, uint32_t *status)
Gets a status register.
Definition usbc_tcpc.h:867
tcpc_status_reg
TCPC Status register.
Definition usbc_tcpc.h:85
@ TCPC_ALERT_EXTENDED_STATUS
Extended status changed.
Definition usbc_tcpc.h:72
@ TCPC_ALERT_TRANSMIT_MSG_DISCARDED
Reset or SOP* message transmission not sent due to an incoming receive message.
Definition usbc_tcpc.h:56
@ TCPC_ALERT_CC_STATUS
CC status changed.
Definition usbc_tcpc.h:43
@ TCPC_ALERT_EXTENDED
An extended interrupt event has occurred.
Definition usbc_tcpc.h:77
@ TCPC_ALERT_BEGINNING_MSG_STATUS
Receive buffer register changed.
Definition usbc_tcpc.h:70
@ TCPC_ALERT_MSG_STATUS
Receive Buffer register changed.
Definition usbc_tcpc.h:47
@ TCPC_ALERT_HARD_RESET_RECEIVED
Received Hard Reset message.
Definition usbc_tcpc.h:49
@ TCPC_ALERT_TRANSMIT_MSG_SUCCESS
Reset or SOP* message transmission successful.
Definition usbc_tcpc.h:58
@ TCPC_ALERT_VBUS_ALARM_HI
A high-voltage alarm has occurred.
Definition usbc_tcpc.h:60
@ TCPC_ALERT_VBUS_SNK_DISCONNECT
The TCPC in Attached.SNK state has detected a sink disconnect.
Definition usbc_tcpc.h:68
@ TCPC_ALERT_POWER_STATUS
Power status changed.
Definition usbc_tcpc.h:45
@ TCPC_ALERT_VBUS_ALARM_LO
A low-voltage alarm has occurred.
Definition usbc_tcpc.h:62
@ TCPC_ALERT_VENDOR_DEFINED
A vendor defined alert has been detected.
Definition usbc_tcpc.h:79
@ TCPC_ALERT_FAULT_STATUS
A fault has occurred.
Definition usbc_tcpc.h:64
@ TCPC_ALERT_TRANSMIT_MSG_FAILED
SOP* message transmission not successful.
Definition usbc_tcpc.h:51
@ TCPC_ALERT_RX_BUFFER_OVERFLOW
TCPC RX buffer has overflowed.
Definition usbc_tcpc.h:66
@ TCPC_FAULT_STATUS
The Fault Status register.
Definition usbc_tcpc.h:93
@ TCPC_ALERT_STATUS
The Alert register.
Definition usbc_tcpc.h:87
@ TCPC_VENDOR_DEFINED_STATUS
The Vendor Defined Status register.
Definition usbc_tcpc.h:99
@ TCPC_EXTENDED_ALERT_STATUS
The Extended Alert Status register.
Definition usbc_tcpc.h:97
@ TCPC_POWER_STATUS
The Power Status register.
Definition usbc_tcpc.h:91
@ TCPC_CC_STATUS
The CC Status register.
Definition usbc_tcpc.h:89
@ TCPC_EXTENDED_STATUS
The Extended Status register.
Definition usbc_tcpc.h:95
tc_cc_pull
CC pull resistors.
Definition usbc_tc.h:368
tc_rp_value
Pull-Up resistor values.
Definition usbc_tc.h:354
tc_cc_voltage_state
CC Voltage status.
Definition usbc_tc.h:324
tc_data_role
Power Delivery Data Role.
Definition usbc_tc.h:422
tc_power_role
Power Delivery Power Role.
Definition usbc_tc.h:412
tc_cc_polarity
Polarity of the CC lines.
Definition usbc_tc.h:434
@ TC_CC_VOLT_RP_DEF
Port partner is applying Rp (0.5A).
Definition usbc_tc.h:332
@ TC_CC_VOLT_RA
Port partner is applying Ra.
Definition usbc_tc.h:328
@ TC_CC_VOLT_RD
Port partner is applying Rd.
Definition usbc_tc.h:330
@ TC_CC_VOLT_RP_3A0
Port partner is applying Rp (3.0A).
Definition usbc_tc.h:336
@ TC_CC_VOLT_RP_1A5
Port partner is applying Rp (1.5A).
Definition usbc_tc.h:334
__UINT32_TYPE__ uint32_t
Definition stdint.h:90
__UINT64_TYPE__ uint64_t
Definition stdint.h:91
__UINT8_TYPE__ uint8_t
Definition stdint.h:88
__UINT16_TYPE__ uint16_t
Definition stdint.h:89
Runtime device structure (in ROM) per driver instance.
Definition device.h:513
void * data
Address of the device instance private data.
Definition device.h:523
Power Delivery message.
Definition usbc_pd.h:1040
TCPC Chip Information.
Definition usbc_tcpc.h:105
uint16_t product_id
Product Id.
Definition usbc_tcpc.h:109
uint8_t min_req_fw_version_string[8]
Minimum Required firmware version string.
Definition usbc_tcpc.h:118
uint64_t fw_version_number
Firmware version number.
Definition usbc_tcpc.h:113
uint64_t min_req_fw_version_number
Minimum Required firmware version number.
Definition usbc_tcpc.h:120
uint16_t device_id
Device Id.
Definition usbc_tcpc.h:111
uint16_t vendor_id
Vendor Id.
Definition usbc_tcpc.h:107
<span class="mlabel">Driver Operations</span> USB Type-C Port Controller driver operations
Definition usbc_tcpc.h:391
tcpc_api_set_vconn_cb_t set_vconn_cb
<span class="op-badge op-req" title="This operation MUST be implemented by the driver....
Definition usbc_tcpc.h:405
tcpc_api_set_cc_polarity_t set_cc_polarity
<span class="op-badge op-req" title="This operation MUST be implemented by the driver....
Definition usbc_tcpc.h:417
tcpc_api_dump_std_reg_t dump_std_reg
<span class="op-badge op-opt" title="This operation MAY optionally be implemented by the driver....
Definition usbc_tcpc.h:421
tcpc_api_get_rx_pending_msg_t get_rx_pending_msg
<span class="op-badge op-req" title="This operation MUST be implemented by the driver....
Definition usbc_tcpc.h:413
tcpc_api_set_low_power_mode_t set_low_power_mode
<span class="op-badge op-opt" title="This operation MAY optionally be implemented by the driver....
Definition usbc_tcpc.h:445
tcpc_api_set_drp_toggle_t set_drp_toggle
<span class="op-badge op-opt" title="This operation MAY optionally be implemented by the driver....
Definition usbc_tcpc.h:433
tcpc_api_select_rp_value_t select_rp_value
<span class="op-badge op-opt" title="This operation MAY optionally be implemented by the driver....
Definition usbc_tcpc.h:397
tcpc_api_get_rp_value_t get_rp_value
<span class="op-badge op-opt" title="This operation MAY optionally be implemented by the driver....
Definition usbc_tcpc.h:399
tcpc_api_set_vconn_t set_vconn
<span class="op-badge op-opt" title="This operation MAY optionally be implemented by the driver....
Definition usbc_tcpc.h:409
tcpc_api_set_cc_t set_cc
<span class="op-badge op-req" title="This operation MUST be implemented by the driver....
Definition usbc_tcpc.h:401
tcpc_api_get_snk_ctrl_t get_snk_ctrl
<span class="op-badge op-opt" title="This operation MAY optionally be implemented by the driver....
Definition usbc_tcpc.h:435
tcpc_api_set_src_ctrl_t set_src_ctrl
<span class="op-badge op-opt" title="This operation MAY optionally be implemented by the driver....
Definition usbc_tcpc.h:441
tcpc_api_get_chip_info_t get_chip_info
<span class="op-badge op-opt" title="This operation MAY optionally be implemented by the driver....
Definition usbc_tcpc.h:443
tcpc_api_set_debug_detach_t set_debug_detach
<span class="op-badge op-opt" title="This operation MAY optionally be implemented by the driver....
Definition usbc_tcpc.h:431
tcpc_api_get_src_ctrl_t get_src_ctrl
<span class="op-badge op-opt" title="This operation MAY optionally be implemented by the driver....
Definition usbc_tcpc.h:439
tcpc_api_set_alert_handler_cb_t set_alert_handler_cb
<span class="op-badge op-req" title="This operation MUST be implemented by the driver....
Definition usbc_tcpc.h:451
tcpc_api_sop_prime_enable_t sop_prime_enable
<span class="op-badge op-opt" title="This operation MAY optionally be implemented by the driver....
Definition usbc_tcpc.h:447
tcpc_api_transmit_data_t transmit_data
<span class="op-badge op-opt" title="This operation MAY optionally be implemented by the driver....
Definition usbc_tcpc.h:419
tcpc_api_set_debug_accessory_t set_debug_accessory
<span class="op-badge op-opt" title="This operation MAY optionally be implemented by the driver....
Definition usbc_tcpc.h:429
tcpc_api_get_status_register_t get_status_register
<span class="op-badge op-opt" title="This operation MAY optionally be implemented by the driver....
Definition usbc_tcpc.h:423
tcpc_api_set_bist_test_mode_t set_bist_test_mode
<span class="op-badge op-opt" title="This operation MAY optionally be implemented by the driver....
Definition usbc_tcpc.h:449
tcpc_api_set_rx_enable_t set_rx_enable
<span class="op-badge op-opt" title="This operation MAY optionally be implemented by the driver....
Definition usbc_tcpc.h:415
tcpc_api_set_snk_ctrl_t set_snk_ctrl
<span class="op-badge op-opt" title="This operation MAY optionally be implemented by the driver....
Definition usbc_tcpc.h:437
tcpc_api_mask_status_register_t mask_status_register
<span class="op-badge op-opt" title="This operation MAY optionally be implemented by the driver....
Definition usbc_tcpc.h:427
tcpc_api_vconn_discharge_t vconn_discharge
<span class="op-badge op-opt" title="This operation MAY optionally be implemented by the driver....
Definition usbc_tcpc.h:407
tcpc_api_init_t init
<span class="op-badge op-req" title="This operation MUST be implemented by the driver....
Definition usbc_tcpc.h:393
tcpc_api_set_roles_t set_roles
<span class="op-badge op-opt" title="This operation MAY optionally be implemented by the driver....
Definition usbc_tcpc.h:411
tcpc_api_clear_status_register_t clear_status_register
<span class="op-badge op-opt" title="This operation MAY optionally be implemented by the driver....
Definition usbc_tcpc.h:425
tcpc_api_set_vconn_discharge_cb_t set_vconn_discharge_cb
<span class="op-badge op-req" title="This operation MUST be implemented by the driver....
Definition usbc_tcpc.h:403
tcpc_api_get_cc_t get_cc
<span class="op-badge op-opt" title="This operation MAY optionally be implemented by the driver....
Definition usbc_tcpc.h:395
USB-C Power Delivery API used for USB-C drivers.
USB Type-C Cable and Connector API used for USB-C drivers.