Zephyr API Documentation 4.4.0-rc1
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
122
134typedef int (*tcpc_vconn_control_cb_t)(const struct device *tcpc_dev, const struct device *usbc_dev,
135 enum tc_cc_polarity pol, bool enable);
136
148typedef int (*tcpc_vconn_discharge_cb_t)(const struct device *tcpc_dev,
149 const struct device *usbc_dev, enum tc_cc_polarity pol,
150 bool enable);
151
159typedef void (*tcpc_alert_handler_cb_t)(const struct device *dev, void *data,
160 enum tcpc_alert alert);
161
167
173typedef int (*tcpc_api_init_t)(const struct device *dev);
174
180typedef int (*tcpc_api_get_cc_t)(const struct device *dev, enum tc_cc_voltage_state *cc1,
181 enum tc_cc_voltage_state *cc2);
182
188typedef int (*tcpc_api_select_rp_value_t)(const struct device *dev, enum tc_rp_value rp);
189
195typedef int (*tcpc_api_get_rp_value_t)(const struct device *dev, enum tc_rp_value *rp);
196
202typedef int (*tcpc_api_set_cc_t)(const struct device *dev, enum tc_cc_pull pull);
203
209typedef void (*tcpc_api_set_vconn_discharge_cb_t)(const struct device *dev,
211 const struct device *usbc_dev);
212
218typedef void (*tcpc_api_set_vconn_cb_t)(const struct device *dev, tcpc_vconn_control_cb_t vconn_cb,
219 const struct device *usbc_dev);
220
226typedef int (*tcpc_api_vconn_discharge_t)(const struct device *dev, bool enable);
227
233typedef int (*tcpc_api_set_vconn_t)(const struct device *dev, bool enable);
234
240typedef int (*tcpc_api_set_roles_t)(const struct device *dev, enum tc_power_role power_role,
241 enum tc_data_role data_role);
242
248typedef int (*tcpc_api_get_rx_pending_msg_t)(const struct device *dev, struct pd_msg *msg);
249
255typedef int (*tcpc_api_set_rx_enable_t)(const struct device *dev, bool enable);
256
262typedef int (*tcpc_api_set_cc_polarity_t)(const struct device *dev, enum tc_cc_polarity polarity);
263
269typedef int (*tcpc_api_transmit_data_t)(const struct device *dev, struct pd_msg *msg);
270
276typedef int (*tcpc_api_dump_std_reg_t)(const struct device *dev);
277
283typedef int (*tcpc_api_get_status_register_t)(const struct device *dev, enum tcpc_status_reg reg,
284 uint32_t *status);
285
291typedef int (*tcpc_api_clear_status_register_t)(const struct device *dev, enum tcpc_status_reg reg,
292 uint32_t mask);
293
299typedef int (*tcpc_api_mask_status_register_t)(const struct device *dev, enum tcpc_status_reg reg,
300 uint32_t mask);
301
307typedef int (*tcpc_api_set_debug_accessory_t)(const struct device *dev, bool enable);
308
314typedef int (*tcpc_api_set_debug_detach_t)(const struct device *dev);
315
321typedef int (*tcpc_api_set_drp_toggle_t)(const struct device *dev, bool enable);
322
328typedef int (*tcpc_api_get_snk_ctrl_t)(const struct device *dev);
329
335typedef int (*tcpc_api_set_snk_ctrl_t)(const struct device *dev, bool enable);
336
342typedef int (*tcpc_api_get_src_ctrl_t)(const struct device *dev);
343
349typedef int (*tcpc_api_set_src_ctrl_t)(const struct device *dev, bool enable);
350
356typedef int (*tcpc_api_get_chip_info_t)(const struct device *dev, struct tcpc_chip_info *chip_info);
357
363typedef int (*tcpc_api_set_low_power_mode_t)(const struct device *dev, bool enable);
364
370typedef int (*tcpc_api_sop_prime_enable_t)(const struct device *dev, bool enable);
371
377typedef int (*tcpc_api_set_bist_test_mode_t)(const struct device *dev, bool enable);
378
384typedef int (*tcpc_api_set_alert_handler_cb_t)(const struct device *dev,
385 tcpc_alert_handler_cb_t handler, void *data);
386
452
454
458static inline int tcpc_is_cc_rp(enum tc_cc_voltage_state cc)
459{
460 return (cc == TC_CC_VOLT_RP_DEF) || (cc == TC_CC_VOLT_RP_1A5) || (cc == TC_CC_VOLT_RP_3A0);
461}
462
466static inline int tcpc_is_cc_open(enum tc_cc_voltage_state cc1, enum tc_cc_voltage_state cc2)
467{
468 return (cc1 < TC_CC_VOLT_RD) && (cc2 < TC_CC_VOLT_RD);
469}
470
475{
476 return cc1 == TC_CC_VOLT_RD && cc2 == TC_CC_VOLT_RD;
477}
478
483{
484 return tcpc_is_cc_rp(cc1) && tcpc_is_cc_rp(cc2);
485}
486
491{
492 return cc1 == TC_CC_VOLT_RA && cc2 == TC_CC_VOLT_RA;
493}
494
499 enum tc_cc_voltage_state cc2)
500{
501 return cc1 == TC_CC_VOLT_RD || cc2 == TC_CC_VOLT_RD;
502}
503
508{
509 return tcpc_is_cc_at_least_one_rd(cc1, cc2) && cc1 != cc2;
510}
511
521static inline int tcpc_init(const struct device *dev)
522{
523 const struct tcpc_driver_api *api = (const struct tcpc_driver_api *)dev->api;
524
525 __ASSERT(api->init != NULL, "Callback pointer should not be NULL");
526
527 return api->init(dev);
528}
529
541static inline int tcpc_get_cc(const struct device *dev, enum tc_cc_voltage_state *cc1,
542 enum tc_cc_voltage_state *cc2)
543{
544 const struct tcpc_driver_api *api = (const struct tcpc_driver_api *)dev->api;
545
546 if (api->get_cc == NULL) {
547 return -ENOSYS;
548 }
549
550 return api->get_cc(dev, cc1, cc2);
551}
552
563static inline int tcpc_select_rp_value(const struct device *dev, enum tc_rp_value rp)
564{
565 const struct tcpc_driver_api *api = (const struct tcpc_driver_api *)dev->api;
566
567 if (api->select_rp_value == NULL) {
568 return -ENOSYS;
569 }
570
571 return api->select_rp_value(dev, rp);
572}
573
584static inline int tcpc_get_rp_value(const struct device *dev, enum tc_rp_value *rp)
585{
586 const struct tcpc_driver_api *api = (const struct tcpc_driver_api *)dev->api;
587
588 if (api->get_rp_value == NULL) {
589 return -ENOSYS;
590 }
591
592 return api->get_rp_value(dev, rp);
593}
594
604static inline int tcpc_set_cc(const struct device *dev, enum tc_cc_pull pull)
605{
606 const struct tcpc_driver_api *api = (const struct tcpc_driver_api *)dev->api;
607
608 __ASSERT(api->set_cc != NULL, "Callback pointer should not be NULL");
609
610 return api->set_cc(dev, pull);
611}
612
624static inline void tcpc_set_vconn_cb(const struct device *dev, tcpc_vconn_control_cb_t vconn_cb,
625 const struct device *usbc_dev)
626{
627 const struct tcpc_driver_api *api = (const struct tcpc_driver_api *)dev->api;
628
629 __ASSERT(api->set_vconn_cb != NULL, "Callback pointer should not be NULL");
630
631 api->set_vconn_cb(dev, vconn_cb, usbc_dev);
632}
633
645static inline void tcpc_set_vconn_discharge_cb(const struct device *dev,
647 const struct device *usbc_dev)
648{
649 const struct tcpc_driver_api *api = (const struct tcpc_driver_api *)dev->api;
650
651 __ASSERT(api->set_vconn_discharge_cb != NULL, "Callback pointer should not be NULL");
652
653 api->set_vconn_discharge_cb(dev, cb, usbc_dev);
654}
655
669static inline int tcpc_vconn_discharge(const struct device *dev, bool enable)
670{
671 const struct tcpc_driver_api *api = (const struct tcpc_driver_api *)dev->api;
672
673 if (api->vconn_discharge == NULL) {
674 return -ENOSYS;
675 }
676
677 return api->vconn_discharge(dev, enable);
678}
679
693static inline int tcpc_set_vconn(const struct device *dev, bool enable)
694{
695 const struct tcpc_driver_api *api = (const struct tcpc_driver_api *)dev->api;
696
697 if (api->set_vconn == NULL) {
698 return -ENOSYS;
699 }
700
701 return api->set_vconn(dev, enable);
702}
703
717static inline int tcpc_set_roles(const struct device *dev, enum tc_power_role power_role,
718 enum tc_data_role data_role)
719{
720 const struct tcpc_driver_api *api = (const struct tcpc_driver_api *)dev->api;
721
722 if (api->set_roles == NULL) {
723 return -ENOSYS;
724 }
725
726 return api->set_roles(dev, power_role, data_role);
727}
728
742static inline int tcpc_get_rx_pending_msg(const struct device *dev, struct pd_msg *buf)
743{
744 const struct tcpc_driver_api *api = (const struct tcpc_driver_api *)dev->api;
745
746 __ASSERT(api->get_rx_pending_msg != NULL, "Callback pointer should not be NULL");
747
748 return api->get_rx_pending_msg(dev, buf);
749}
750
762static inline int tcpc_set_rx_enable(const struct device *dev, bool enable)
763{
764 const struct tcpc_driver_api *api = (const struct tcpc_driver_api *)dev->api;
765
766 if (api->set_rx_enable == NULL) {
767 return -ENOSYS;
768 }
769
770 return api->set_rx_enable(dev, enable);
771}
772
782static inline int tcpc_set_cc_polarity(const struct device *dev, enum tc_cc_polarity polarity)
783{
784 const struct tcpc_driver_api *api = (const struct tcpc_driver_api *)dev->api;
785
786 __ASSERT(api->set_cc_polarity != NULL, "Callback pointer should not be NULL");
787
788 return api->set_cc_polarity(dev, polarity);
789}
790
801static inline int tcpc_transmit_data(const struct device *dev, struct pd_msg *msg)
802{
803 const struct tcpc_driver_api *api = (const struct tcpc_driver_api *)dev->api;
804
805 if (api->transmit_data == NULL) {
806 return -ENOSYS;
807 }
808
809 return api->transmit_data(dev, msg);
810}
811
821static inline int tcpc_dump_std_reg(const struct device *dev)
822{
823 const struct tcpc_driver_api *api = (const struct tcpc_driver_api *)dev->api;
824
825 if (api->dump_std_reg == NULL) {
826 return -ENOSYS;
827 }
828
829 return api->dump_std_reg(dev);
830}
831
845static inline int tcpc_set_alert_handler_cb(const struct device *dev,
846 tcpc_alert_handler_cb_t handler, void *data)
847{
848 const struct tcpc_driver_api *api = (const struct tcpc_driver_api *)dev->api;
849
850 __ASSERT(api->set_alert_handler_cb != NULL, "Callback pointer should not be NULL");
851
852 return api->set_alert_handler_cb(dev, handler, data);
853}
854
866static inline int tcpc_get_status_register(const struct device *dev, enum tcpc_status_reg reg,
867 uint32_t *status)
868{
869 const struct tcpc_driver_api *api = (const struct tcpc_driver_api *)dev->api;
870
871 if (api->get_status_register == NULL) {
872 return -ENOSYS;
873 }
874
875 return api->get_status_register(dev, reg, status);
876}
877
890static inline int tcpc_clear_status_register(const struct device *dev, enum tcpc_status_reg reg,
891 uint32_t mask)
892{
893 const struct tcpc_driver_api *api = (const struct tcpc_driver_api *)dev->api;
894
895 if (api->clear_status_register == NULL) {
896 return -ENOSYS;
897 }
898
899 return api->clear_status_register(dev, reg, mask);
900}
901
914static inline int tcpc_mask_status_register(const struct device *dev, enum tcpc_status_reg reg,
915 uint32_t mask)
916{
917 const struct tcpc_driver_api *api = (const struct tcpc_driver_api *)dev->api;
918
919 if (api->mask_status_register == NULL) {
920 return -ENOSYS;
921 }
922
923 return api->mask_status_register(dev, reg, mask);
924}
925
936static inline int tcpc_set_debug_accessory(const struct device *dev, bool enable)
937{
938 const struct tcpc_driver_api *api = (const struct tcpc_driver_api *)dev->api;
939
940 if (api->set_debug_accessory == NULL) {
941 return -ENOSYS;
942 }
943
944 return api->set_debug_accessory(dev, enable);
945}
946
956static inline int tcpc_set_debug_detach(const struct device *dev)
957{
958 const struct tcpc_driver_api *api = (const struct tcpc_driver_api *)dev->api;
959
960 if (api->set_debug_detach == NULL) {
961 return -ENOSYS;
962 }
963
964 return api->set_debug_detach(dev);
965}
966
977static inline int tcpc_set_drp_toggle(const struct device *dev, bool enable)
978{
979 const struct tcpc_driver_api *api = (const struct tcpc_driver_api *)dev->api;
980
981 if (api->set_drp_toggle == NULL) {
982 return -ENOSYS;
983 }
984
985 return api->set_drp_toggle(dev, enable);
986}
987
997static inline int tcpc_get_snk_ctrl(const struct device *dev)
998{
999 const struct tcpc_driver_api *api = (const struct tcpc_driver_api *)dev->api;
1000
1001 if (api->get_snk_ctrl == NULL) {
1002 return -ENOSYS;
1003 }
1004
1005 return api->get_snk_ctrl(dev);
1006}
1007
1016static inline int tcpc_set_snk_ctrl(const struct device *dev, bool enable)
1017{
1018 const struct tcpc_driver_api *api = (const struct tcpc_driver_api *)dev->api;
1019
1020 if (api->set_snk_ctrl == NULL) {
1021 return -ENOSYS;
1022 }
1023
1024 return api->set_snk_ctrl(dev, enable);
1025}
1026
1036static inline int tcpc_get_src_ctrl(const struct device *dev)
1037{
1038 const struct tcpc_driver_api *api = (const struct tcpc_driver_api *)dev->api;
1039
1040 if (api->get_src_ctrl == NULL) {
1041 return -ENOSYS;
1042 }
1043
1044 return api->get_src_ctrl(dev);
1045}
1046
1055static inline int tcpc_set_src_ctrl(const struct device *dev, bool enable)
1056{
1057 const struct tcpc_driver_api *api = (const struct tcpc_driver_api *)dev->api;
1058
1059 if (api->set_src_ctrl == NULL) {
1060 return -ENOSYS;
1061 }
1062
1063 return api->set_src_ctrl(dev, enable);
1064}
1065
1077static inline int tcpc_set_bist_test_mode(const struct device *dev, bool enable)
1078{
1079 const struct tcpc_driver_api *api = (const struct tcpc_driver_api *)dev->api;
1080
1081 if (api->set_bist_test_mode == NULL) {
1082 return -ENOSYS;
1083 }
1084
1085 return api->set_bist_test_mode(dev, enable);
1086}
1087
1098static inline int tcpc_get_chip_info(const struct device *dev, struct tcpc_chip_info *chip_info)
1099{
1100 const struct tcpc_driver_api *api = (const struct tcpc_driver_api *)dev->api;
1101
1102 if (api->get_chip_info == NULL) {
1103 return -ENOSYS;
1104 }
1105
1106 return api->get_chip_info(dev, chip_info);
1107}
1108
1119static inline int tcpc_set_low_power_mode(const struct device *dev, bool enable)
1120{
1121 const struct tcpc_driver_api *api = (const struct tcpc_driver_api *)dev->api;
1122
1123 if (api->set_low_power_mode == NULL) {
1124 return -ENOSYS;
1125 }
1126
1127 return api->set_low_power_mode(dev, enable);
1128}
1129
1141static inline int tcpc_sop_prime_enable(const struct device *dev, bool enable)
1142{
1143 const struct tcpc_driver_api *api = (const struct tcpc_driver_api *)dev->api;
1144
1145 if (api->sop_prime_enable == NULL) {
1146 return -ENOSYS;
1147 }
1148
1149 return api->sop_prime_enable(dev, enable);
1150}
1151
1155
1156#ifdef __cplusplus
1157}
1158#endif
1159
1160#endif /* ZEPHYR_INCLUDE_DRIVERS_USBC_USBC_TCPC_H_ */
irp cc
Definition asm-macro-32-bit-gnu.h:10
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:283
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:370
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:307
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:218
int(* tcpc_api_get_src_ctrl_t)(const struct device *dev)
Callback API to query VBUS source control state.
Definition usbc_tcpc.h:342
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:180
int(* tcpc_api_set_debug_detach_t)(const struct device *dev)
Callback API to detach from a debug connection.
Definition usbc_tcpc.h:314
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:384
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:321
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:255
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:349
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:291
int(* tcpc_api_dump_std_reg_t)(const struct device *dev)
Callback API to dump standard TCPC registers.
Definition usbc_tcpc.h:276
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:299
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:262
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:335
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:248
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:269
int(* tcpc_api_vconn_discharge_t)(const struct device *dev, bool enable)
Callback API to enable or disable VCONN discharge.
Definition usbc_tcpc.h:226
int(* tcpc_api_get_snk_ctrl_t)(const struct device *dev)
Callback API to query VBUS sink control state.
Definition usbc_tcpc.h:328
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:202
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:356
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:195
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:209
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:240
int(* tcpc_api_init_t)(const struct device *dev)
Callback API to initialize the TCPC.
Definition usbc_tcpc.h:173
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:363
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:188
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:377
int(* tcpc_api_set_vconn_t)(const struct device *dev, bool enable)
Callback API to enable or disable VCONN.
Definition usbc_tcpc.h:233
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:890
static int tcpc_set_debug_accessory(const struct device *dev, bool enable)
Manual control of TCPC DebugAccessory control.
Definition usbc_tcpc.h:936
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:482
static int tcpc_get_src_ctrl(const struct device *dev)
Queries the current sourcing state of the TCPC.
Definition usbc_tcpc.h:1036
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:134
static int tcpc_get_snk_ctrl(const struct device *dev)
Queries the current sinking state of the TCPC.
Definition usbc_tcpc.h:997
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:914
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:466
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:490
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:624
static int tcpc_set_vconn(const struct device *dev, bool enable)
Enables or disables VCONN.
Definition usbc_tcpc.h:693
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:584
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:742
static int tcpc_vconn_discharge(const struct device *dev, bool enable)
Discharges VCONN.
Definition usbc_tcpc.h:669
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:563
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:148
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:782
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:159
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:541
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:458
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:645
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:845
static int tcpc_set_snk_ctrl(const struct device *dev, bool enable)
Set the VBUS sinking state of the TCPC.
Definition usbc_tcpc.h:1016
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:1098
static int tcpc_transmit_data(const struct device *dev, struct pd_msg *msg)
Transmits a Power Delivery message.
Definition usbc_tcpc.h:801
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:717
static int tcpc_set_src_ctrl(const struct device *dev, bool enable)
Set the VBUS sourcing state of the TCPC.
Definition usbc_tcpc.h:1055
static int tcpc_set_rx_enable(const struct device *dev, bool enable)
Enables the reception of SOP* message types.
Definition usbc_tcpc.h:762
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:507
static int tcpc_dump_std_reg(const struct device *dev)
Dump a set of TCPC registers.
Definition usbc_tcpc.h:821
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:1119
static int tcpc_set_drp_toggle(const struct device *dev, bool enable)
Enable TCPC auto dual role toggle.
Definition usbc_tcpc.h:977
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:474
static int tcpc_set_debug_detach(const struct device *dev)
Detach from a debug connection.
Definition usbc_tcpc.h:956
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:1141
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:498
static int tcpc_init(const struct device *dev)
Initializes the TCPC.
Definition usbc_tcpc.h:521
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:604
static int tcpc_set_bist_test_mode(const struct device *dev, bool enable)
Controls the BIST Mode of the TCPC.
Definition usbc_tcpc.h:1077
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:866
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
#define NULL
Definition iar_missing_defs.h:20
__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
const void * api
Address of the API structure exposed by the device instance.
Definition device.h:519
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:117
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:119
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:390
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:404
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:416
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:420
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:412
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:444
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:432
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:396
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:398
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:408
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:400
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:434
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:440
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:442
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:430
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:438
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:450
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:446
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:418
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:428
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:422
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:448
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:414
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:436
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:426
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:406
tcpc_api_init_t init
<span class="op-badge op-req" title="This operation MUST be implemented by the driver....
Definition usbc_tcpc.h:392
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:410
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:424
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:402
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:394
USB-C Power Delivery API used for USB-C drivers.
USB Type-C Cable and Connector API used for USB-C drivers.