Zephyr API Documentation 4.5.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
15
16#ifndef ZEPHYR_INCLUDE_DRIVERS_USB_C_USBC_TCPC_H_
17#define ZEPHYR_INCLUDE_DRIVERS_USB_C_USBC_TCPC_H_
18
27
28#include <zephyr/types.h>
29#include <zephyr/device.h>
30#include <errno.h>
31
32#include "usbc_tc.h"
33#include "usbc_pd.h"
34
35#ifdef __cplusplus
36extern "C" {
37#endif
38
82
102
124
136typedef int (*tcpc_vconn_control_cb_t)(const struct device *tcpc_dev, const struct device *usbc_dev,
137 enum tc_cc_polarity pol, bool enable);
138
150typedef int (*tcpc_vconn_discharge_cb_t)(const struct device *tcpc_dev,
151 const struct device *usbc_dev, enum tc_cc_polarity pol,
152 bool enable);
153
161typedef void (*tcpc_alert_handler_cb_t)(const struct device *dev, void *data,
162 enum tcpc_alert alert);
163
169
175typedef int (*tcpc_api_init_t)(const struct device *dev);
176
182typedef int (*tcpc_api_get_cc_t)(const struct device *dev, enum tc_cc_voltage_state *cc1,
183 enum tc_cc_voltage_state *cc2);
184
190typedef int (*tcpc_api_select_rp_value_t)(const struct device *dev, enum tc_rp_value rp);
191
197typedef int (*tcpc_api_get_rp_value_t)(const struct device *dev, enum tc_rp_value *rp);
198
204typedef int (*tcpc_api_set_cc_t)(const struct device *dev, enum tc_cc_pull pull);
205
211typedef void (*tcpc_api_set_vconn_discharge_cb_t)(const struct device *dev,
213 const struct device *usbc_dev);
214
220typedef void (*tcpc_api_set_vconn_cb_t)(const struct device *dev, tcpc_vconn_control_cb_t vconn_cb,
221 const struct device *usbc_dev);
222
228typedef int (*tcpc_api_vconn_discharge_t)(const struct device *dev, bool enable);
229
235typedef int (*tcpc_api_set_vconn_t)(const struct device *dev, bool enable);
236
242typedef int (*tcpc_api_set_roles_t)(const struct device *dev, enum tc_power_role power_role,
243 enum tc_data_role data_role);
244
250typedef int (*tcpc_api_get_rx_pending_msg_t)(const struct device *dev, struct pd_msg *msg);
251
257typedef int (*tcpc_api_set_rx_enable_t)(const struct device *dev, bool enable);
258
264typedef int (*tcpc_api_set_cc_polarity_t)(const struct device *dev, enum tc_cc_polarity polarity);
265
271typedef int (*tcpc_api_transmit_data_t)(const struct device *dev, struct pd_msg *msg);
272
278typedef int (*tcpc_api_dump_std_reg_t)(const struct device *dev);
279
285typedef int (*tcpc_api_mask_status_register_t)(const struct device *dev, enum tcpc_status_reg reg,
286 uint32_t mask);
287
293typedef int (*tcpc_api_set_debug_accessory_t)(const struct device *dev, bool enable);
294
300typedef int (*tcpc_api_set_debug_detach_t)(const struct device *dev);
301
307typedef int (*tcpc_api_set_drp_toggle_t)(const struct device *dev, bool enable);
308
314typedef int (*tcpc_api_get_snk_ctrl_t)(const struct device *dev);
315
321typedef int (*tcpc_api_set_snk_ctrl_t)(const struct device *dev, bool enable);
322
328typedef int (*tcpc_api_get_src_ctrl_t)(const struct device *dev);
329
335typedef int (*tcpc_api_set_src_ctrl_t)(const struct device *dev, bool enable);
336
342typedef int (*tcpc_api_get_chip_info_t)(const struct device *dev, struct tcpc_chip_info *chip_info);
343
349typedef int (*tcpc_api_set_low_power_mode_t)(const struct device *dev, bool enable);
350
356typedef int (*tcpc_api_sop_prime_enable_t)(const struct device *dev, bool enable);
357
363typedef int (*tcpc_api_set_bist_test_mode_t)(const struct device *dev, bool enable);
364
370typedef int (*tcpc_api_set_alert_handler_cb_t)(const struct device *dev,
371 tcpc_alert_handler_cb_t handler, void *data);
372
378typedef int (*tcpc_api_dead_battery_enabled_t)(const struct device *dev, bool *enabled);
379
443
445
449static inline int tcpc_is_cc_rp(enum tc_cc_voltage_state cc)
450{
451 return (cc == TC_CC_VOLT_RP_DEF) || (cc == TC_CC_VOLT_RP_1A5) || (cc == TC_CC_VOLT_RP_3A0);
452}
453
457static inline int tcpc_is_cc_open(enum tc_cc_voltage_state cc1, enum tc_cc_voltage_state cc2)
458{
459 return (cc1 < TC_CC_VOLT_RD) && (cc2 < TC_CC_VOLT_RD);
460}
461
466{
467 return cc1 == TC_CC_VOLT_RD && cc2 == TC_CC_VOLT_RD;
468}
469
474{
475 return tcpc_is_cc_rp(cc1) && tcpc_is_cc_rp(cc2);
476}
477
482{
483 return cc1 == TC_CC_VOLT_RA && cc2 == TC_CC_VOLT_RA;
484}
485
490 enum tc_cc_voltage_state cc2)
491{
492 return cc1 == TC_CC_VOLT_RD || cc2 == TC_CC_VOLT_RD;
493}
494
499{
500 return tcpc_is_cc_at_least_one_rd(cc1, cc2) && cc1 != cc2;
501}
502
507{
508 return tcpc_is_cc_rp(cc1) != tcpc_is_cc_rp(cc2);
509}
510
520static inline int tcpc_init(const struct device *dev)
521{
522 const struct tcpc_driver_api *api = DEVICE_API_GET(tcpc, dev);
523
524 __ASSERT(api->init != NULL, "Callback pointer should not be NULL");
525
526 return api->init(dev);
527}
528
540static inline int tcpc_get_cc(const struct device *dev, enum tc_cc_voltage_state *cc1,
541 enum tc_cc_voltage_state *cc2)
542{
543 const struct tcpc_driver_api *api = DEVICE_API_GET(tcpc, dev);
544
545 if (api->get_cc == NULL) {
546 return -ENOSYS;
547 }
548
549 return api->get_cc(dev, cc1, cc2);
550}
551
562static inline int tcpc_select_rp_value(const struct device *dev, enum tc_rp_value rp)
563{
564 const struct tcpc_driver_api *api = DEVICE_API_GET(tcpc, dev);
565
566 if (api->select_rp_value == NULL) {
567 return -ENOSYS;
568 }
569
570 return api->select_rp_value(dev, rp);
571}
572
583static inline int tcpc_get_rp_value(const struct device *dev, enum tc_rp_value *rp)
584{
585 const struct tcpc_driver_api *api = DEVICE_API_GET(tcpc, dev);
586
587 if (api->get_rp_value == NULL) {
588 return -ENOSYS;
589 }
590
591 return api->get_rp_value(dev, rp);
592}
593
603static inline int tcpc_set_cc(const struct device *dev, enum tc_cc_pull pull)
604{
605 const struct tcpc_driver_api *api = DEVICE_API_GET(tcpc, dev);
606
607 __ASSERT(api->set_cc != NULL, "Callback pointer should not be NULL");
608
609 return api->set_cc(dev, pull);
610}
611
623static inline void tcpc_set_vconn_cb(const struct device *dev, tcpc_vconn_control_cb_t vconn_cb,
624 const struct device *usbc_dev)
625{
626 const struct tcpc_driver_api *api = DEVICE_API_GET(tcpc, dev);
627
628 __ASSERT(api->set_vconn_cb != NULL, "Callback pointer should not be NULL");
629
630 api->set_vconn_cb(dev, vconn_cb, usbc_dev);
631}
632
644static inline void tcpc_set_vconn_discharge_cb(const struct device *dev,
646 const struct device *usbc_dev)
647{
648 const struct tcpc_driver_api *api = DEVICE_API_GET(tcpc, dev);
649
650 __ASSERT(api->set_vconn_discharge_cb != NULL, "Callback pointer should not be NULL");
651
652 api->set_vconn_discharge_cb(dev, cb, usbc_dev);
653}
654
668static inline int tcpc_vconn_discharge(const struct device *dev, bool enable)
669{
670 const struct tcpc_driver_api *api = DEVICE_API_GET(tcpc, dev);
671
672 if (api->vconn_discharge == NULL) {
673 return -ENOSYS;
674 }
675
676 return api->vconn_discharge(dev, enable);
677}
678
692static inline int tcpc_set_vconn(const struct device *dev, bool enable)
693{
694 const struct tcpc_driver_api *api = DEVICE_API_GET(tcpc, dev);
695
696 if (api->set_vconn == NULL) {
697 return -ENOSYS;
698 }
699
700 return api->set_vconn(dev, enable);
701}
702
716static inline int tcpc_set_roles(const struct device *dev, enum tc_power_role power_role,
717 enum tc_data_role data_role)
718{
719 const struct tcpc_driver_api *api = DEVICE_API_GET(tcpc, dev);
720
721 if (api->set_roles == NULL) {
722 return -ENOSYS;
723 }
724
725 return api->set_roles(dev, power_role, data_role);
726}
727
741static inline int tcpc_get_rx_pending_msg(const struct device *dev, struct pd_msg *buf)
742{
743 const struct tcpc_driver_api *api = DEVICE_API_GET(tcpc, dev);
744
745 __ASSERT(api->get_rx_pending_msg != NULL, "Callback pointer should not be NULL");
746
747 return api->get_rx_pending_msg(dev, buf);
748}
749
761static inline int tcpc_set_rx_enable(const struct device *dev, bool enable)
762{
763 const struct tcpc_driver_api *api = DEVICE_API_GET(tcpc, dev);
764
765 if (api->set_rx_enable == NULL) {
766 return -ENOSYS;
767 }
768
769 return api->set_rx_enable(dev, enable);
770}
771
781static inline int tcpc_set_cc_polarity(const struct device *dev, enum tc_cc_polarity polarity)
782{
783 const struct tcpc_driver_api *api = DEVICE_API_GET(tcpc, dev);
784
785 __ASSERT(api->set_cc_polarity != NULL, "Callback pointer should not be NULL");
786
787 return api->set_cc_polarity(dev, polarity);
788}
789
800static inline int tcpc_transmit_data(const struct device *dev, struct pd_msg *msg)
801{
802 const struct tcpc_driver_api *api = DEVICE_API_GET(tcpc, dev);
803
804 if (api->transmit_data == NULL) {
805 return -ENOSYS;
806 }
807
808 return api->transmit_data(dev, msg);
809}
810
820static inline int tcpc_dump_std_reg(const struct device *dev)
821{
822 const struct tcpc_driver_api *api = DEVICE_API_GET(tcpc, dev);
823
824 if (api->dump_std_reg == NULL) {
825 return -ENOSYS;
826 }
827
828 return api->dump_std_reg(dev);
829}
830
844static inline int tcpc_set_alert_handler_cb(const struct device *dev,
845 tcpc_alert_handler_cb_t handler, void *data)
846{
847 const struct tcpc_driver_api *api = DEVICE_API_GET(tcpc, dev);
848
849 __ASSERT(api->set_alert_handler_cb != NULL, "Callback pointer should not be NULL");
850
851 return api->set_alert_handler_cb(dev, handler, data);
852}
853
866static inline int tcpc_mask_status_register(const struct device *dev, enum tcpc_status_reg reg,
867 uint32_t mask)
868{
869 const struct tcpc_driver_api *api = DEVICE_API_GET(tcpc, dev);
870
871 if (api->mask_status_register == NULL) {
872 return -ENOSYS;
873 }
874
875 return api->mask_status_register(dev, reg, mask);
876}
877
888static inline int tcpc_set_debug_accessory(const struct device *dev, bool enable)
889{
890 const struct tcpc_driver_api *api = DEVICE_API_GET(tcpc, dev);
891
892 if (api->set_debug_accessory == NULL) {
893 return -ENOSYS;
894 }
895
896 return api->set_debug_accessory(dev, enable);
897}
898
908static inline int tcpc_set_debug_detach(const struct device *dev)
909{
910 const struct tcpc_driver_api *api = DEVICE_API_GET(tcpc, dev);
911
912 if (api->set_debug_detach == NULL) {
913 return -ENOSYS;
914 }
915
916 return api->set_debug_detach(dev);
917}
918
929static inline int tcpc_set_drp_toggle(const struct device *dev, bool enable)
930{
931 const struct tcpc_driver_api *api = DEVICE_API_GET(tcpc, dev);
932
933 if (api->set_drp_toggle == NULL) {
934 return -ENOSYS;
935 }
936
937 return api->set_drp_toggle(dev, enable);
938}
939
949static inline int tcpc_get_snk_ctrl(const struct device *dev)
950{
951 const struct tcpc_driver_api *api = DEVICE_API_GET(tcpc, dev);
952
953 if (api->get_snk_ctrl == NULL) {
954 return -ENOSYS;
955 }
956
957 return api->get_snk_ctrl(dev);
958}
959
968static inline int tcpc_set_snk_ctrl(const struct device *dev, bool enable)
969{
970 const struct tcpc_driver_api *api = DEVICE_API_GET(tcpc, dev);
971
972 if (api->set_snk_ctrl == NULL) {
973 return -ENOSYS;
974 }
975
976 return api->set_snk_ctrl(dev, enable);
977}
978
988static inline int tcpc_get_src_ctrl(const struct device *dev)
989{
990 const struct tcpc_driver_api *api = DEVICE_API_GET(tcpc, dev);
991
992 if (api->get_src_ctrl == NULL) {
993 return -ENOSYS;
994 }
995
996 return api->get_src_ctrl(dev);
997}
998
1007static inline int tcpc_set_src_ctrl(const struct device *dev, bool enable)
1008{
1009 const struct tcpc_driver_api *api = DEVICE_API_GET(tcpc, dev);
1010
1011 if (api->set_src_ctrl == NULL) {
1012 return -ENOSYS;
1013 }
1014
1015 return api->set_src_ctrl(dev, enable);
1016}
1017
1029static inline int tcpc_set_bist_test_mode(const struct device *dev, bool enable)
1030{
1031 const struct tcpc_driver_api *api = DEVICE_API_GET(tcpc, dev);
1032
1033 if (api->set_bist_test_mode == NULL) {
1034 return -ENOSYS;
1035 }
1036
1037 return api->set_bist_test_mode(dev, enable);
1038}
1039
1050static inline int tcpc_get_chip_info(const struct device *dev, struct tcpc_chip_info *chip_info)
1051{
1052 const struct tcpc_driver_api *api = DEVICE_API_GET(tcpc, dev);
1053
1054 if (api->get_chip_info == NULL) {
1055 return -ENOSYS;
1056 }
1057
1058 return api->get_chip_info(dev, chip_info);
1059}
1060
1071static inline int tcpc_set_low_power_mode(const struct device *dev, bool enable)
1072{
1073 const struct tcpc_driver_api *api = DEVICE_API_GET(tcpc, dev);
1074
1075 if (api->set_low_power_mode == NULL) {
1076 return -ENOSYS;
1077 }
1078
1079 return api->set_low_power_mode(dev, enable);
1080}
1081
1093static inline int tcpc_sop_prime_enable(const struct device *dev, bool enable)
1094{
1095 const struct tcpc_driver_api *api = DEVICE_API_GET(tcpc, dev);
1096
1097 if (api->sop_prime_enable == NULL) {
1098 return -ENOSYS;
1099 }
1100
1101 return api->sop_prime_enable(dev, enable);
1102}
1103
1114static inline int tcpc_dead_battery_enabled(const struct device *dev, bool *enabled)
1115{
1116 const struct tcpc_driver_api *api = DEVICE_API_GET(tcpc, dev);
1117
1118 if (api->dead_battery_enabled == NULL) {
1119 return -ENOSYS;
1120 }
1121
1122 return api->dead_battery_enabled(dev, enabled);
1123}
1124
1128
1129#ifdef __cplusplus
1130}
1131#endif
1132
1133#endif /* ZEPHYR_INCLUDE_DRIVERS_USB_C_USBC_TCPC_H_ */
APIs and macros for the Zephyr device model.
#define DEVICE_API_GET(_class, _dev)
Expands to the pointer of a device's API for a given class.
Definition device.h:1505
System error numbers.
#define ENOSYS
Function not implemented.
Definition errno.h:83
int(* tcpc_api_dead_battery_enabled_t)(const struct device *dev, bool *enabled)
Callback API to query the dead battery configuration of the TCPC.
Definition usbc_tcpc.h:378
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:356
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:293
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:220
int(* tcpc_api_get_src_ctrl_t)(const struct device *dev)
Callback API to query VBUS source control state.
Definition usbc_tcpc.h:328
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:182
int(* tcpc_api_set_debug_detach_t)(const struct device *dev)
Callback API to detach from a debug connection.
Definition usbc_tcpc.h:300
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:370
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:307
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:257
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:335
int(* tcpc_api_dump_std_reg_t)(const struct device *dev)
Callback API to dump standard TCPC registers.
Definition usbc_tcpc.h:278
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:285
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:264
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:321
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:250
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:271
int(* tcpc_api_vconn_discharge_t)(const struct device *dev, bool enable)
Callback API to enable or disable VCONN discharge.
Definition usbc_tcpc.h:228
int(* tcpc_api_get_snk_ctrl_t)(const struct device *dev)
Callback API to query VBUS sink control state.
Definition usbc_tcpc.h:314
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:204
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:342
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:197
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:211
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:242
int(* tcpc_api_init_t)(const struct device *dev)
Callback API to initialize the TCPC.
Definition usbc_tcpc.h:175
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:349
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:190
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:363
int(* tcpc_api_set_vconn_t)(const struct device *dev, bool enable)
Callback API to enable or disable VCONN.
Definition usbc_tcpc.h:235
static int tcpc_set_debug_accessory(const struct device *dev, bool enable)
Manual control of TCPC DebugAccessory control.
Definition usbc_tcpc.h:888
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:473
static int tcpc_get_src_ctrl(const struct device *dev)
Queries the current sourcing state of the TCPC.
Definition usbc_tcpc.h:988
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:136
static int tcpc_get_snk_ctrl(const struct device *dev)
Queries the current sinking state of the TCPC.
Definition usbc_tcpc.h:949
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:866
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:457
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:481
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:623
static int tcpc_set_vconn(const struct device *dev, bool enable)
Enables or disables VCONN.
Definition usbc_tcpc.h:692
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:583
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:741
static int tcpc_vconn_discharge(const struct device *dev, bool enable)
Discharges VCONN.
Definition usbc_tcpc.h:668
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:562
tcpc_alert
TCPC Alert bits.
Definition usbc_tcpc.h:42
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:150
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:781
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:161
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:540
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:449
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:644
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:844
static int tcpc_set_snk_ctrl(const struct device *dev, bool enable)
Set the VBUS sinking state of the TCPC.
Definition usbc_tcpc.h:968
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:1050
static int tcpc_transmit_data(const struct device *dev, struct pd_msg *msg)
Transmits a Power Delivery message.
Definition usbc_tcpc.h:800
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:716
static int tcpc_set_src_ctrl(const struct device *dev, bool enable)
Set the VBUS sourcing state of the TCPC.
Definition usbc_tcpc.h:1007
static int tcpc_set_rx_enable(const struct device *dev, bool enable)
Enables the reception of SOP* message types.
Definition usbc_tcpc.h:761
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:498
static int tcpc_dump_std_reg(const struct device *dev)
Dump a set of TCPC registers.
Definition usbc_tcpc.h:820
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:1071
static int tcpc_set_drp_toggle(const struct device *dev, bool enable)
Enable TCPC auto dual role toggle.
Definition usbc_tcpc.h:929
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:465
static int tcpc_is_cc_only_one_rp(enum tc_cc_voltage_state cc1, enum tc_cc_voltage_state cc2)
Returns true if the port partner is presenting Rp on only one CC line.
Definition usbc_tcpc.h:506
static int tcpc_set_debug_detach(const struct device *dev)
Detach from a debug connection.
Definition usbc_tcpc.h:908
static int tcpc_dead_battery_enabled(const struct device *dev, bool *enabled)
Queries whether the TCPC applies the USB-C dead battery terminations.
Definition usbc_tcpc.h:1114
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:1093
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:489
static int tcpc_init(const struct device *dev)
Initializes the TCPC.
Definition usbc_tcpc.h:520
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:603
static int tcpc_set_bist_test_mode(const struct device *dev, bool enable)
Controls the BIST Mode of the TCPC.
Definition usbc_tcpc.h:1029
tcpc_status_reg
TCPC Status register.
Definition usbc_tcpc.h:86
@ TCPC_ALERT_EXTENDED_STATUS
Extended status changed.
Definition usbc_tcpc.h:73
@ TCPC_ALERT_TRANSMIT_MSG_DISCARDED
Reset or SOP* message transmission not sent due to an incoming receive message.
Definition usbc_tcpc.h:57
@ TCPC_ALERT_CC_STATUS
CC status changed.
Definition usbc_tcpc.h:44
@ TCPC_ALERT_EXTENDED
An extended interrupt event has occurred.
Definition usbc_tcpc.h:78
@ TCPC_ALERT_BEGINNING_MSG_STATUS
Receive buffer register changed.
Definition usbc_tcpc.h:71
@ TCPC_ALERT_MSG_STATUS
Receive Buffer register changed.
Definition usbc_tcpc.h:48
@ TCPC_ALERT_HARD_RESET_RECEIVED
Received Hard Reset message.
Definition usbc_tcpc.h:50
@ TCPC_ALERT_TRANSMIT_MSG_SUCCESS
Reset or SOP* message transmission successful.
Definition usbc_tcpc.h:59
@ TCPC_ALERT_VBUS_ALARM_HI
A high-voltage alarm has occurred.
Definition usbc_tcpc.h:61
@ TCPC_ALERT_VBUS_SNK_DISCONNECT
The TCPC in Attached.SNK state has detected a sink disconnect.
Definition usbc_tcpc.h:69
@ TCPC_ALERT_POWER_STATUS
Power status changed.
Definition usbc_tcpc.h:46
@ TCPC_ALERT_VBUS_ALARM_LO
A low-voltage alarm has occurred.
Definition usbc_tcpc.h:63
@ TCPC_ALERT_VENDOR_DEFINED
A vendor defined alert has been detected.
Definition usbc_tcpc.h:80
@ TCPC_ALERT_FAULT_STATUS
A fault has occurred.
Definition usbc_tcpc.h:65
@ TCPC_ALERT_TRANSMIT_MSG_FAILED
SOP* message transmission not successful.
Definition usbc_tcpc.h:52
@ TCPC_ALERT_RX_BUFFER_OVERFLOW
TCPC RX buffer has overflowed.
Definition usbc_tcpc.h:67
@ TCPC_FAULT_STATUS
The Fault Status register.
Definition usbc_tcpc.h:94
@ TCPC_ALERT_STATUS
The Alert register.
Definition usbc_tcpc.h:88
@ TCPC_VENDOR_DEFINED_STATUS
The Vendor Defined Status register.
Definition usbc_tcpc.h:100
@ TCPC_EXTENDED_ALERT_STATUS
The Extended Alert Status register.
Definition usbc_tcpc.h:98
@ TCPC_POWER_STATUS
The Power Status register.
Definition usbc_tcpc.h:92
@ TCPC_CC_STATUS
The CC Status register.
Definition usbc_tcpc.h:90
@ TCPC_EXTENDED_STATUS
The Extended Status register.
Definition usbc_tcpc.h:96
tc_cc_pull
CC pull resistors.
Definition usbc_tc.h:369
tc_rp_value
Pull-Up resistor values.
Definition usbc_tc.h:355
tc_cc_voltage_state
CC Voltage status.
Definition usbc_tc.h:325
tc_data_role
Power Delivery Data Role.
Definition usbc_tc.h:423
tc_power_role
Power Delivery Power Role.
Definition usbc_tc.h:413
tc_cc_polarity
Polarity of the CC lines.
Definition usbc_tc.h:435
@ TC_CC_VOLT_RP_DEF
Port partner is applying Rp (0.5A).
Definition usbc_tc.h:333
@ TC_CC_VOLT_RA
Port partner is applying Ra.
Definition usbc_tc.h:329
@ TC_CC_VOLT_RD
Port partner is applying Rd.
Definition usbc_tc.h:331
@ TC_CC_VOLT_RP_3A0
Port partner is applying Rp (3.0A).
Definition usbc_tc.h:337
@ TC_CC_VOLT_RP_1A5
Port partner is applying Rp (1.5A).
Definition usbc_tc.h:335
__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:543
void * data
Address of the device instance private data.
Definition device.h:553
Power Delivery message.
Definition usbc_pd.h:1086
TCPC Chip Information.
Definition usbc_tcpc.h:106
uint16_t product_id
Product Id.
Definition usbc_tcpc.h:110
uint8_t min_req_fw_version_string[8]
Minimum Required firmware version string.
Definition usbc_tcpc.h:119
uint64_t fw_version_number
Firmware version number.
Definition usbc_tcpc.h:114
uint64_t min_req_fw_version_number
Minimum Required firmware version number.
Definition usbc_tcpc.h:121
uint16_t device_id
Device Id.
Definition usbc_tcpc.h:112
uint16_t vendor_id
Vendor Id.
Definition usbc_tcpc.h:108
<span class="mlabel">Driver Operations</span> USB Type-C Port Controller driver operations
Definition usbc_tcpc.h:383
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:397
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:409
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:413
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:405
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:433
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:421
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:389
tcpc_api_dead_battery_enabled_t dead_battery_enabled
<span class="op-badge op-opt" title="This operation MAY optionally be implemented by the driver....
Definition usbc_tcpc.h:441
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:391
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:401
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:393
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:423
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:429
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:431
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:419
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:427
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:439
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:435
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:411
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:417
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:437
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:407
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:425
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:415
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:399
tcpc_api_init_t init
<span class="op-badge op-req" title="This operation MUST be implemented by the driver....
Definition usbc_tcpc.h:385
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:403
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:395
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:387
USB-C Power Delivery API used for USB-C drivers.
USB Type-C Cable and Connector API used for USB-C drivers.