#ifndef __DRIVER_USB_TYPEC_UCSI_H
#define __DRIVER_USB_TYPEC_UCSI_H
#include <linux/bitops.h>
#include <linux/completion.h>
#include <linux/device.h>
#include <linux/power_supply.h>
#include <linux/types.h>
#include <linux/usb/typec.h>
#include <linux/usb/pd.h>
#include <linux/usb/role.h>
#include <asm/unaligned.h>
struct ucsi;
struct ucsi_altmode;
struct ucsi_connector;
struct dentry;
#define UCSI_VERSION …
#define UCSI_CCI …
#define UCSI_CONTROL …
#define UCSI_MESSAGE_IN …
#define UCSI_MESSAGE_OUT …
#define UCSIv2_MESSAGE_OUT …
#define UCSI_VERSION_1_2 …
#define UCSI_VERSION_2_0 …
#define UCSI_VERSION_2_1 …
#define UCSI_VERSION_3_0 …
#define UCSI_BCD_GET_MAJOR(_v_) …
#define UCSI_BCD_GET_MINOR(_v_) …
#define UCSI_BCD_GET_SUBMINOR(_v_) …
#define UCSI_SPEC_REVISION_TO_BCD(_v_) …
#define UCSI_CCI_CONNECTOR(_c_) …
#define UCSI_CCI_LENGTH(_c_) …
#define UCSI_CCI_NOT_SUPPORTED …
#define UCSI_CCI_CANCEL_COMPLETE …
#define UCSI_CCI_RESET_COMPLETE …
#define UCSI_CCI_BUSY …
#define UCSI_CCI_ACK_COMPLETE …
#define UCSI_CCI_ERROR …
#define UCSI_CCI_COMMAND_COMPLETE …
struct ucsi_operations { … };
struct ucsi *ucsi_create(struct device *dev, const struct ucsi_operations *ops);
void ucsi_destroy(struct ucsi *ucsi);
int ucsi_register(struct ucsi *ucsi);
void ucsi_unregister(struct ucsi *ucsi);
void *ucsi_get_drvdata(struct ucsi *ucsi);
void ucsi_set_drvdata(struct ucsi *ucsi, void *data);
void ucsi_connector_change(struct ucsi *ucsi, u8 num);
#define UCSI_PPM_RESET …
#define UCSI_CANCEL …
#define UCSI_CONNECTOR_RESET …
#define UCSI_ACK_CC_CI …
#define UCSI_SET_NOTIFICATION_ENABLE …
#define UCSI_GET_CAPABILITY …
#define UCSI_GET_CONNECTOR_CAPABILITY …
#define UCSI_SET_UOM …
#define UCSI_SET_UOR …
#define UCSI_SET_PDM …
#define UCSI_SET_PDR …
#define UCSI_GET_ALTERNATE_MODES …
#define UCSI_GET_CAM_SUPPORTED …
#define UCSI_GET_CURRENT_CAM …
#define UCSI_SET_NEW_CAM …
#define UCSI_GET_PDOS …
#define UCSI_GET_CABLE_PROPERTY …
#define UCSI_GET_CONNECTOR_STATUS …
#define UCSI_GET_ERROR_STATUS …
#define UCSI_GET_PD_MESSAGE …
#define UCSI_CONNECTOR_NUMBER(_num_) …
#define UCSI_COMMAND(_cmd_) …
#define UCSI_GET_ALTMODE_GET_CONNECTOR_NUMBER(_cmd_) …
#define UCSI_DEFAULT_GET_CONNECTOR_NUMBER(_cmd_) …
#define UCSI_CONNECTOR_RESET_HARD …
#define UCSI_ACK_CONNECTOR_CHANGE …
#define UCSI_ACK_COMMAND_COMPLETE …
#define UCSI_ENABLE_NTFY_CMD_COMPLETE …
#define UCSI_ENABLE_NTFY_EXT_PWR_SRC_CHANGE …
#define UCSI_ENABLE_NTFY_PWR_OPMODE_CHANGE …
#define UCSI_ENABLE_NTFY_ATTENTION …
#define UCSI_ENABLE_NTFY_LPM_FW_UPDATE_REQ …
#define UCSI_ENABLE_NTFY_CAP_CHANGE …
#define UCSI_ENABLE_NTFY_PWR_LEVEL_CHANGE …
#define UCSI_ENABLE_NTFY_PD_RESET_COMPLETE …
#define UCSI_ENABLE_NTFY_CAM_CHANGE …
#define UCSI_ENABLE_NTFY_BAT_STATUS_CHANGE …
#define UCSI_ENABLE_NTFY_SECURITY_REQ_PARTNER …
#define UCSI_ENABLE_NTFY_PARTNER_CHANGE …
#define UCSI_ENABLE_NTFY_PWR_DIR_CHANGE …
#define UCSI_ENABLE_NTFY_SET_RETIMER_MODE …
#define UCSI_ENABLE_NTFY_CONNECTOR_CHANGE …
#define UCSI_ENABLE_NTFY_ERROR …
#define UCSI_ENABLE_NTFY_SINK_PATH_STS_CHANGE …
#define UCSI_ENABLE_NTFY_ALL …
#define UCSI_SET_UOR_ROLE(_r_) …
#define UCSI_SET_UOR_ACCEPT_ROLE_SWAPS …
#define UCSI_SET_PDR_ROLE(_r_) …
#define UCSI_SET_PDR_ACCEPT_ROLE_SWAPS …
#define UCSI_ALTMODE_RECIPIENT(_r_) …
#define UCSI_GET_ALTMODE_RECIPIENT(_r_) …
#define UCSI_RECIPIENT_CON …
#define UCSI_RECIPIENT_SOP …
#define UCSI_RECIPIENT_SOP_P …
#define UCSI_RECIPIENT_SOP_PP …
#define UCSI_GET_ALTMODE_CONNECTOR_NUMBER(_r_) …
#define UCSI_ALTMODE_OFFSET(_r_) …
#define UCSI_GET_ALTMODE_OFFSET(_r_) …
#define UCSI_GET_ALTMODE_NUM_ALTMODES(_r_) …
#define UCSI_GET_PDOS_PARTNER_PDO(_r_) …
#define UCSI_GET_PDOS_PDO_OFFSET(_r_) …
#define UCSI_GET_PDOS_NUM_PDOS(_r_) …
#define UCSI_MAX_PDOS …
#define UCSI_GET_PDOS_SRC_PDOS …
#define UCSI_GET_PD_MESSAGE_RECIPIENT(_r_) …
#define UCSI_GET_PD_MESSAGE_OFFSET(_r_) …
#define UCSI_GET_PD_MESSAGE_BYTES(_r_) …
#define UCSI_GET_PD_MESSAGE_TYPE(_r_) …
#define UCSI_GET_PD_MESSAGE_TYPE_SNK_CAP_EXT …
#define UCSI_GET_PD_MESSAGE_TYPE_SRC_CAP_EXT …
#define UCSI_GET_PD_MESSAGE_TYPE_BAT_CAP …
#define UCSI_GET_PD_MESSAGE_TYPE_BAT_STAT …
#define UCSI_GET_PD_MESSAGE_TYPE_IDENTITY …
#define UCSI_GET_PD_MESSAGE_TYPE_REVISION …
#define UCSI_ERROR_UNREGONIZED_CMD …
#define UCSI_ERROR_INVALID_CON_NUM …
#define UCSI_ERROR_INVALID_CMD_ARGUMENT …
#define UCSI_ERROR_INCOMPATIBLE_PARTNER …
#define UCSI_ERROR_CC_COMMUNICATION_ERR …
#define UCSI_ERROR_DEAD_BATTERY …
#define UCSI_ERROR_CONTRACT_NEGOTIATION_FAIL …
#define UCSI_ERROR_OVERCURRENT …
#define UCSI_ERROR_UNDEFINED …
#define UCSI_ERROR_PARTNER_REJECTED_SWAP …
#define UCSI_ERROR_HARD_RESET …
#define UCSI_ERROR_PPM_POLICY_CONFLICT …
#define UCSI_ERROR_SWAP_REJECTED …
#define UCSI_ERROR_REVERSE_CURRENT_PROTECTION …
#define UCSI_ERROR_SET_SINK_PATH_REJECTED …
#define UCSI_SET_NEW_CAM_ENTER(x) …
#define UCSI_SET_NEW_CAM_GET_AM(x) …
#define UCSI_SET_NEW_CAM_AM_MASK …
#define UCSI_SET_NEW_CAM_SET_AM(x) …
#define UCSI_CMD_CONNECTOR_MASK …
struct ucsi_capability { … } __packed;
struct ucsi_connector_capability { … } __packed;
struct ucsi_altmode { … } __packed;
struct ucsi_cable_property { … } __packed;
struct ucsi_connector_status { … } __packed;
struct ucsi_pd_message_disc_id { … } __packed;
struct ucsi_debugfs_entry { … };
struct ucsi { … };
#define UCSI_MAX_SVID …
#define UCSI_MAX_ALTMODES …
#define UCSI_TYPEC_VSAFE5V …
#define UCSI_TYPEC_1_5_CURRENT …
#define UCSI_TYPEC_3_0_CURRENT …
struct ucsi_connector { … };
int ucsi_send_command(struct ucsi *ucsi, u64 command,
void *retval, size_t size);
void ucsi_altmode_update_active(struct ucsi_connector *con);
int ucsi_resume(struct ucsi *ucsi);
void ucsi_notify_common(struct ucsi *ucsi, u32 cci);
int ucsi_sync_control_common(struct ucsi *ucsi, u64 command);
#if IS_ENABLED(CONFIG_POWER_SUPPLY)
int ucsi_register_port_psy(struct ucsi_connector *con);
void ucsi_unregister_port_psy(struct ucsi_connector *con);
void ucsi_port_psy_changed(struct ucsi_connector *con);
#else
static inline int ucsi_register_port_psy(struct ucsi_connector *con) { return 0; }
static inline void ucsi_unregister_port_psy(struct ucsi_connector *con) { }
static inline void ucsi_port_psy_changed(struct ucsi_connector *con) { }
#endif
#if IS_ENABLED(CONFIG_TYPEC_DP_ALTMODE)
struct typec_altmode *
ucsi_register_displayport(struct ucsi_connector *con,
bool override, int offset,
struct typec_altmode_desc *desc);
void ucsi_displayport_remove_partner(struct typec_altmode *adev);
#else
static inline struct typec_altmode *
ucsi_register_displayport(struct ucsi_connector *con,
bool override, int offset,
struct typec_altmode_desc *desc)
{
return typec_port_register_altmode(con->port, desc);
}
static inline void
ucsi_displayport_remove_partner(struct typec_altmode *adev) { }
#endif
#ifdef CONFIG_DEBUG_FS
void ucsi_debugfs_init(void);
void ucsi_debugfs_exit(void);
void ucsi_debugfs_register(struct ucsi *ucsi);
void ucsi_debugfs_unregister(struct ucsi *ucsi);
#else
static inline void ucsi_debugfs_init(void) { }
static inline void ucsi_debugfs_exit(void) { }
static inline void ucsi_debugfs_register(struct ucsi *ucsi) { }
static inline void ucsi_debugfs_unregister(struct ucsi *ucsi) { }
#endif
#define USB_TYPEC_NVIDIA_VLINK_DP_VDO …
#define USB_TYPEC_NVIDIA_VLINK_DBG_VDO …
#endif