STRUCT TCPC_DEV(9)
π¦ struct tcpc_dev(9) β the Kernel API Manual, bestie edition β¨
okay so this is a page from the Kernel API Manual, section 9, and it's literally about struct tcpc_dev β the lil' bundle of pointers that lets a USB Type-C port controller (TCPC) talk to the TCPM core. it's giving "wiring diagram but make it fashion" π
πΈ NAME πΈ
struct tcpc_dev β Port configuration and callback functions π«Ά
β¨ SYNOPSIS β¨
here's the whole struct, no cap, every single member, copied exactly:
struct tcpc_dev {
struct fwnode_handle *fwnode;
int (*init)(struct tcpc_dev *dev);
int (*get_vbus)(struct tcpc_dev *dev);
int (*get_current_limit)(struct tcpc_dev *dev);
int (*set_cc)(struct tcpc_dev *dev, enum typec_cc_status cc);
int (*apply_rc)(struct tcpc_dev *dev, enum typec_cc_status cc, enum
typec_cc_polarity polarity);
int (*get_cc)(struct tcpc_dev *dev, enum typec_cc_status *cc1, enum
typec_cc_status *cc2);
int (*set_polarity)(struct tcpc_dev *dev, enum typec_cc_polarity
polarity);
int (*set_orientation)(struct tcpc_dev *dev, enum typec_orientation
orientation);
int (*set_vconn)(struct tcpc_dev *dev, bool on);
int (*set_vbus)(struct tcpc_dev *dev, bool on, bool charge);
int (*set_current_limit)(struct tcpc_dev *dev, u32 max_ma, u32 mv);
int (*set_pd_rx)(struct tcpc_dev *dev, bool on);
int (*set_roles)(struct tcpc_dev *dev, bool attached, enum
typec_role role, enum typec_data_role data);
int (*start_toggling)(struct tcpc_dev *dev, enum typec_port_type
port_type, enum typec_cc_status cc);
int (*try_role)(struct tcpc_dev *dev, int role);
int (*pd_transmit)(struct tcpc_dev *dev, enum tcpm_transmit_type
type, const struct pd_message *msg, unsigned int negotiated_rev);
int (*set_bist_data)(struct tcpc_dev *dev, bool on);
int (*enable_frs)(struct tcpc_dev *dev, bool enable);
void (*frs_sourcing_vbus)(struct tcpc_dev *dev);
int (*enable_auto_vbus_discharge)(struct tcpc_dev *dev, bool
enable);
int (*set_auto_vbus_discharge_threshold)(struct tcpc_dev *dev, enum
typec_pwr_opmode mode, bool pps_active, u32 requested_vbus_voltage, u32
pps_apdo_min_voltage);
bool (*is_vbus_vsafe0v)(struct tcpc_dev *dev);
void (*set_partner_usb_comm_capable)(struct tcpc_dev *dev, bool
enable);
void (*check_contaminant)(struct tcpc_dev *dev);
bool (*cable_comm_capable)(struct tcpc_dev *dev);
bool (*attempt_vconn_swap_discovery)(struct tcpc_dev *dev);
};
π Members π
okay so here's the rollout, member by member, no skips π₯
fwnodeβ pointer to the port fwnode. that's it, that's the whole vibe π§get_vbusβ gets called to read the current VBUS state β‘get_current_limitβ optional! it gets called by the tcpm core when it's configured as a snk andcc=Rp-def. this lets the tcpm provide a fallback current-limit detection method for thecc=Rp-defcase. for example, some tcpcs may includeBC1.2charger detection and use that in this case πset_ccβ gets called to set the value of the CC pins πapply_rcβ optional! needed to move a TCPCI based chipset to theAPPLY_RCstate as stated by the TCPCI specification πget_ccβ gets called to read the current CC pin values πset_polarityβ gets called to set polarity πset_vconnβ gets called to enable or disable VCONN πset_vbusβ gets called to enable or disable VBUS β‘set_current_limitβ optional! gets called to set the current limit as negotiated with the partner π€set_pd_rxβ gets called to enable or disable reception of PD messages π¨set_rolesβ gets called to set power and data roles π―start_togglingβ optional! if it's supported by the hardware, it gets called to start dual-role toggling or single-role connection detection. toggling stops automatically if a connection is established πtry_roleβ optional! gets called to set a preferred role π«pd_transmitβ gets called to transmit a PD message π€set_bist_dataβ turn on/off bist data mode for compliance testing π§ͺenable_frsβ optional! gets called to enable/disable PD 3.0 fast role swap. enabling frs is accessory dependent, because not all PD3.0 accessories support fast role swap π¨frs_sourcing_vbusβ optional! gets called to notify that vbus is now being sourced. low level drivers can perform chip specific operations, if any π«‘enable_auto_vbus_dischargeβ optional! TCPCI spec based TCPC implementations can optionally support hardware to autonomously discharge vbus upon disconnecting as sink or source. TCPM signals the TCPC to enable the mechanism upon entering connected state, and signals disabling upon disconnect πͺ«set_auto_vbus_discharge_thresholdβ mandatory whenenable_auto_vbus_dischargeis implemented. TCPM calls this function to let lower level drivers program the vbus threshold voltage below which the vbus discharge circuit will be turned on.requested_vbus_voltageis set to0when vbus is going to disappear knowingly, i.e. duringPR_SWAPandHARD_RESETetc. πis_vbus_vsafe0vβ optional! TCPCI spec based TCPC implementations are expected to detect theVSAFE0Vvoltage level at vbus. when detection ofVSAFE0Vis supported by the TCPC, set this callback so TCPM can query whether vbus is atVSAFE0Vwhen it needs to. returnstruewhen vbus is atVSAFE0V,falseotherwise βset_partner_usb_comm_capableβ optional! the USB Communications Capable bit indicates if the port partner is capable of communication over the USB data lines (e.g. D+/- or SS Tx/Rx). gets called to notify the status of the bit πΆcheck_contaminantβ optional! this callback gets called when the CC pins report open status at the end of the debounce period, or when the port is still toggling. chip level drivers are expected to check for contaminant and calltcpm_clean_portwhen the port is clean π§Όcable_comm_capableβ optional! returns whether cable communication overSOP'is supported by the tcpc πattempt_vconn_swap_discoveryβ optional! this callback gets called by the TCPM when the result of a Discover Identity request indicates that the port partner is a receptacle capable of modal operation. chip level TCPCI drivers can implement their own policy to determine if and when a Vconn swap following Discover Identity onSOP'occurs. returntruewhen the TCPM is allowed to request a Vconn swap after Discovery Identity onSOPπ
ok real talk bestie:set_auto_vbus_discharge_thresholdis the one that's mandatory if you implementenable_auto_vbus_discharge, and theOptional;members are exactly the ones flagged optional. don't get it twisted π
π SEE ALSO π
kernel file ./include/linux/usb/tcpm.h β go read it, iykyk π
and that's the whole page, bestie. this one came out of ./include/linux/usb, dated October 2026 β so go forth and toggle your roles responsibly, mwah ππβ¨
π¦ where this page comes from
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms