STRUCT TCPC_DEV(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ¦‹ 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 and cc=Rp-def. this lets the tcpm provide a fallback current-limit detection method for the cc=Rp-def case. for example, some tcpcs may include BC1.2 charger 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 the APPLY_RC state 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 when enable_auto_vbus_discharge is 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_voltage is set to 0 when vbus is going to disappear knowingly, i.e. during PR_SWAP and HARD_RESET etc. πŸ’€
  • is_vbus_vsafe0v β€” optional! TCPCI spec based TCPC implementations are expected to detect the VSAFE0V voltage level at vbus. when detection of VSAFE0V is supported by the TCPC, set this callback so TCPM can query whether vbus is at VSAFE0V when it needs to. returns true when vbus is at VSAFE0V, false otherwise βœ…
  • 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 call tcpm_clean_port when the port is clean 🧼
  • cable_comm_capable β€” optional! returns whether cable communication over SOP' 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 on SOP' occurs. return true when the TCPM is allowed to request a Vconn swap after Discovery Identity on SOP 🌈
ok real talk bestie: set_auto_vbus_discharge_threshold is the one that's mandatory if you implement enable_auto_vbus_discharge, and the Optional; 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