linux/include/linux/usb/tcpci.h

/* SPDX-License-Identifier: GPL-2.0+ */
/*
 * Copyright 2015-2017 Google, Inc
 *
 * USB Type-C Port Controller Interface.
 */

#ifndef __LINUX_USB_TCPCI_H
#define __LINUX_USB_TCPCI_H

#include <linux/usb/typec.h>
#include <linux/usb/tcpm.h>

#define TCPC_VENDOR_ID
#define TCPC_PRODUCT_ID
#define TCPC_BCD_DEV
#define TCPC_TC_REV
#define TCPC_PD_REV
#define TCPC_PD_INT_REV

#define TCPC_ALERT
#define TCPC_ALERT_EXTND
#define TCPC_ALERT_EXTENDED_STATUS
#define TCPC_ALERT_VBUS_DISCNCT
#define TCPC_ALERT_RX_BUF_OVF
#define TCPC_ALERT_FAULT
#define TCPC_ALERT_V_ALARM_LO
#define TCPC_ALERT_V_ALARM_HI
#define TCPC_ALERT_TX_SUCCESS
#define TCPC_ALERT_TX_DISCARDED
#define TCPC_ALERT_TX_FAILED
#define TCPC_ALERT_RX_HARD_RST
#define TCPC_ALERT_RX_STATUS
#define TCPC_ALERT_POWER_STATUS
#define TCPC_ALERT_CC_STATUS

#define TCPC_ALERT_MASK
#define TCPC_POWER_STATUS_MASK

#define TCPC_FAULT_STATUS_MASK
#define TCPC_FAULT_STATUS_MASK_VCONN_OC

#define TCPC_EXTENDED_STATUS_MASK
#define TCPC_EXTENDED_STATUS_MASK_VSAFE0V

#define TCPC_ALERT_EXTENDED_MASK
#define TCPC_SINK_FAST_ROLE_SWAP

#define TCPC_CONFIG_STD_OUTPUT
#define TCPC_CONFIG_STD_OUTPUT_ORIENTATION_MASK
#define TCPC_CONFIG_STD_OUTPUT_ORIENTATION_NORMAL
#define TCPC_CONFIG_STD_OUTPUT_ORIENTATION_FLIPPED

#define TCPC_TCPC_CTRL
#define TCPC_TCPC_CTRL_ORIENTATION
#define PLUG_ORNT_CC1
#define PLUG_ORNT_CC2
#define TCPC_TCPC_CTRL_BIST_TM
#define TCPC_TCPC_CTRL_EN_LK4CONN_ALRT

#define TCPC_EXTENDED_STATUS
#define TCPC_EXTENDED_STATUS_VSAFE0V

#define TCPC_ROLE_CTRL
#define TCPC_ROLE_CTRL_DRP
#define TCPC_ROLE_CTRL_RP_VAL_SHIFT
#define TCPC_ROLE_CTRL_RP_VAL_MASK
#define TCPC_ROLE_CTRL_RP_VAL_DEF
#define TCPC_ROLE_CTRL_RP_VAL_1_5
#define TCPC_ROLE_CTRL_RP_VAL_3_0
#define TCPC_ROLE_CTRL_CC2_SHIFT
#define TCPC_ROLE_CTRL_CC2_MASK
#define TCPC_ROLE_CTRL_CC1_SHIFT
#define TCPC_ROLE_CTRL_CC1_MASK
#define TCPC_ROLE_CTRL_CC_RA
#define TCPC_ROLE_CTRL_CC_RP
#define TCPC_ROLE_CTRL_CC_RD
#define TCPC_ROLE_CTRL_CC_OPEN

#define TCPC_FAULT_CTRL

#define TCPC_POWER_CTRL
#define TCPC_POWER_CTRL_VCONN_ENABLE
#define TCPC_POWER_CTRL_BLEED_DISCHARGE
#define TCPC_POWER_CTRL_AUTO_DISCHARGE
#define TCPC_DIS_VOLT_ALRM
#define TCPC_POWER_CTRL_VBUS_VOLT_MON
#define TCPC_FAST_ROLE_SWAP_EN

#define TCPC_CC_STATUS
#define TCPC_CC_STATUS_TOGGLING
#define TCPC_CC_STATUS_TERM
#define TCPC_CC_STATUS_TERM_RP
#define TCPC_CC_STATUS_TERM_RD
#define TCPC_CC_STATE_SRC_OPEN
#define TCPC_CC_STATUS_CC2_SHIFT
#define TCPC_CC_STATUS_CC2_MASK
#define TCPC_CC_STATUS_CC1_SHIFT
#define TCPC_CC_STATUS_CC1_MASK

#define TCPC_POWER_STATUS
#define TCPC_POWER_STATUS_DBG_ACC_CON
#define TCPC_POWER_STATUS_UNINIT
#define TCPC_POWER_STATUS_SOURCING_VBUS
#define TCPC_POWER_STATUS_VBUS_DET
#define TCPC_POWER_STATUS_VBUS_PRES
#define TCPC_POWER_STATUS_VCONN_PRES
#define TCPC_POWER_STATUS_SINKING_VBUS

#define TCPC_FAULT_STATUS
#define TCPC_FAULT_STATUS_ALL_REG_RST_TO_DEFAULT
#define TCPC_FAULT_STATUS_VCONN_OC

#define TCPC_ALERT_EXTENDED

#define TCPC_COMMAND
#define TCPC_CMD_WAKE_I2C
#define TCPC_CMD_DISABLE_VBUS_DETECT
#define TCPC_CMD_ENABLE_VBUS_DETECT
#define TCPC_CMD_DISABLE_SINK_VBUS
#define TCPC_CMD_SINK_VBUS
#define TCPC_CMD_DISABLE_SRC_VBUS
#define TCPC_CMD_SRC_VBUS_DEFAULT
#define TCPC_CMD_SRC_VBUS_HIGH
#define TCPC_CMD_LOOK4CONNECTION
#define TCPC_CMD_RXONEMORE
#define TCPC_CMD_I2C_IDLE

#define TCPC_DEV_CAP_1
#define TCPC_DEV_CAP_2
#define TCPC_STD_INPUT_CAP
#define TCPC_STD_OUTPUT_CAP
#define TCPC_STD_OUTPUT_CAP_ORIENTATION

#define TCPC_MSG_HDR_INFO
#define TCPC_MSG_HDR_INFO_DATA_ROLE
#define TCPC_MSG_HDR_INFO_PWR_ROLE
#define TCPC_MSG_HDR_INFO_REV_SHIFT
#define TCPC_MSG_HDR_INFO_REV_MASK

#define TCPC_RX_DETECT
#define TCPC_RX_DETECT_HARD_RESET
#define TCPC_RX_DETECT_SOP
#define TCPC_RX_DETECT_SOP1
#define TCPC_RX_DETECT_SOP2
#define TCPC_RX_DETECT_DBG1
#define TCPC_RX_DETECT_DBG2

#define TCPC_RX_BYTE_CNT
#define TCPC_RX_BUF_FRAME_TYPE
#define TCPC_RX_BUF_FRAME_TYPE_SOP
#define TCPC_RX_BUF_FRAME_TYPE_SOP1
#define TCPC_RX_HDR
#define TCPC_RX_DATA

#define TCPC_TRANSMIT
#define TCPC_TRANSMIT_RETRY_SHIFT
#define TCPC_TRANSMIT_RETRY_MASK
#define TCPC_TRANSMIT_TYPE_SHIFT
#define TCPC_TRANSMIT_TYPE_MASK

#define TCPC_TX_BYTE_CNT
#define TCPC_TX_HDR
#define TCPC_TX_DATA

#define TCPC_VBUS_VOLTAGE
#define TCPC_VBUS_VOLTAGE_MASK
#define TCPC_VBUS_VOLTAGE_LSB_MV
#define TCPC_VBUS_SINK_DISCONNECT_THRESH
#define TCPC_VBUS_SINK_DISCONNECT_THRESH_LSB_MV
#define TCPC_VBUS_SINK_DISCONNECT_THRESH_MAX
#define TCPC_VBUS_STOP_DISCHARGE_THRESH
#define TCPC_VBUS_VOLTAGE_ALARM_HI_CFG
#define TCPC_VBUS_VOLTAGE_ALARM_LO_CFG

/* I2C_WRITE_BYTE_COUNT + 1 when TX_BUF_BYTE_x is only accessible I2C_WRITE_BYTE_COUNT */
#define TCPC_TRANSMIT_BUFFER_MAX_LEN

#define tcpc_presenting_rd(reg, cc)

struct tcpci;

/*
 * @TX_BUF_BYTE_x_hidden:
 *		optional; Set when TX_BUF_BYTE_x can only be accessed through I2C_WRITE_BYTE_COUNT.
 * @frs_sourcing_vbus:
 *		Optional; Callback to perform chip specific operations when FRS
 *		is sourcing vbus.
 * @auto_discharge_disconnect:
 *		Optional; Enables TCPC to autonously discharge vbus on disconnect.
 * @vbus_vsafe0v:
 *		optional; Set when TCPC can detect whether vbus is at VSAFE0V.
 * @set_partner_usb_comm_capable:
 *		Optional; The USB Communications Capable bit indicates if port
 *		partner is capable of communication over the USB data lines
 *		(e.g. D+/- or SS Tx/Rx). Called to notify the status of the bit.
 * @check_contaminant:
 *		Optional; The callback is invoked when chiplevel drivers indicated
 *		that the USB port needs to be checked for contaminant presence.
 *		Chip level drivers are expected to check for contaminant and call
 *		tcpm_clean_port when the port is clean to put the port back into
 *		toggling state.
 * @cable_comm_capable
 *		optional; Set when TCPC can communicate with cable plugs over SOP'
 * @attempt_vconn_swap_discovery:
 *		Optional; The callback is 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.
 * @set_orientation:
 *		Optional; Enable setting the connector orientation
 *		CONFIG_STANDARD_OUTPUT (0x18) bit0.
 */
struct tcpci_data {};

struct tcpci *tcpci_register_port(struct device *dev, struct tcpci_data *data);
void tcpci_unregister_port(struct tcpci *tcpci);
irqreturn_t tcpci_irq(struct tcpci *tcpci);

struct tcpm_port;
struct tcpm_port *tcpci_get_tcpm_port(struct tcpci *tcpci);

static inline enum typec_cc_status tcpci_to_typec_cc(unsigned int cc, bool sink)
{}
#endif /* __LINUX_USB_TCPCI_H */