linux/drivers/usb/typec/tipd/tps6598x.h

/* SPDX-License-Identifier: GPL-2.0+ */
/*
 * Driver for TI TPS6598x USB Power Delivery controller family
 *
 * Copyright (C) 2017, Intel Corporation
 * Author: Heikki Krogerus <[email protected]>
 */

#include <linux/bits.h>
#include <linux/bitfield.h>

#ifndef __TPS6598X_H__
#define __TPS6598X_H__

#define TPS_FIELD_GET(_mask, _reg)

/* TPS_REG_STATUS bits */
#define TPS_STATUS_PLUG_PRESENT
#define TPS_STATUS_PLUG_UPSIDE_DOWN
#define TPS_STATUS_TO_UPSIDE_DOWN(s)
#define TPS_STATUS_PORTROLE
#define TPS_STATUS_TO_TYPEC_PORTROLE(s)
#define TPS_STATUS_DATAROLE
#define TPS_STATUS_TO_TYPEC_DATAROLE(s)
#define TPS_STATUS_VCONN
#define TPS_STATUS_TO_TYPEC_VCONN(s)
#define TPS_STATUS_OVERCURRENT
#define TPS_STATUS_GOTO_MIN_ACTIVE
#define TPS_STATUS_BIST
#define TPS_STATUS_HIGH_VOLAGE_WARNING
#define TPS_STATUS_HIGH_LOW_VOLTAGE_WARNING

#define TPS_STATUS_CONN_STATE_MASK
#define TPS_STATUS_CONN_STATE(x)
#define TPS_STATUS_PP_5V0_SWITCH_MASK
#define TPS_STATUS_PP_5V0_SWITCH(x)
#define TPS_STATUS_PP_HV_SWITCH_MASK
#define TPS_STATUS_PP_HV_SWITCH(x)
#define TPS_STATUS_PP_EXT_SWITCH_MASK
#define TPS_STATUS_PP_EXT_SWITCH(x)
#define TPS_STATUS_PP_CABLE_SWITCH_MASK
#define TPS_STATUS_PP_CABLE_SWITCH(x)
#define TPS_STATUS_POWER_SOURCE_MASK
#define TPS_STATUS_POWER_SOURCE(x)
#define TPS_STATUS_VBUS_STATUS_MASK
#define TPS_STATUS_VBUS_STATUS(x)
#define TPS_STATUS_USB_HOST_PRESENT_MASK
#define TPS_STATUS_USB_HOST_PRESENT(x)
#define TPS_STATUS_LEGACY_MASK
#define TPS_STATUS_LEGACY(x)

#define TPS_STATUS_CONN_STATE_NO_CONN
#define TPS_STATUS_CONN_STATE_DISABLED
#define TPS_STATUS_CONN_STATE_AUDIO_CONN
#define TPS_STATUS_CONN_STATE_DEBUG_CONN
#define TPS_STATUS_CONN_STATE_NO_CONN_R_A
#define TPS_STATUS_CONN_STATE_RESERVED
#define TPS_STATUS_CONN_STATE_CONN_NO_R_A
#define TPS_STATUS_CONN_STATE_CONN_WITH_R_A

#define TPS_STATUS_PP_SWITCH_STATE_DISABLED
#define TPS_STATUS_PP_SWITCH_STATE_FAULT
#define TPS_STATUS_PP_SWITCH_STATE_OUT
#define TPS_STATUS_PP_SWITCH_STATE_IN

#define TPS_STATUS_POWER_SOURCE_UNKNOWN
#define TPS_STATUS_POWER_SOURCE_VIN_3P3
#define TPS_STATUS_POWER_SOURCE_DEAD_BAT
#define TPS_STATUS_POWER_SOURCE_VBUS

#define TPS_STATUS_VBUS_STATUS_VSAFE0V
#define TPS_STATUS_VBUS_STATUS_VSAFE5V
#define TPS_STATUS_VBUS_STATUS_PD
#define TPS_STATUS_VBUS_STATUS_FAULT

#define TPS_STATUS_USB_HOST_PRESENT_NO
#define TPS_STATUS_USB_HOST_PRESENT_PD_NO_USB
#define TPS_STATUS_USB_HOST_PRESENT_NO_PD
#define TPS_STATUS_USB_HOST_PRESENT_PD_USB

#define TPS_STATUS_LEGACY_NO
#define TPS_STATUS_LEGACY_SINK
#define TPS_STATUS_LEGACY_SOURCE

/* TPS_REG_INT_* bits */
#define TPS_REG_INT_USER_VID_ALT_MODE_OTHER_VDM
#define TPS_REG_INT_USER_VID_ALT_MODE_ATTN_VDM
#define TPS_REG_INT_USER_VID_ALT_MODE_EXIT
#define TPS_REG_INT_USER_VID_ALT_MODE_ENTERED
#define TPS_REG_INT_EXIT_MODES_COMPLETE
#define TPS_REG_INT_DISCOVER_MODES_COMPLETE
#define TPS_REG_INT_VDM_MSG_SENT
#define TPS_REG_INT_VDM_ENTERED_MODE
#define TPS_REG_INT_ERROR_UNABLE_TO_SOURCE
#define TPS_REG_INT_SRC_TRANSITION
#define TPS_REG_INT_ERROR_DISCHARGE_FAILED
#define TPS_REG_INT_ERROR_MESSAGE_DATA
#define TPS_REG_INT_ERROR_PROTOCOL_ERROR
#define TPS_REG_INT_ERROR_MISSING_GET_CAP_MESSAGE
#define TPS_REG_INT_ERROR_POWER_EVENT_OCCURRED
#define TPS_REG_INT_ERROR_CAN_PROVIDE_PWR_LATER
#define TPS_REG_INT_ERROR_CANNOT_PROVIDE_PWR
#define TPS_REG_INT_ERROR_DEVICE_INCOMPATIBLE
#define TPS_REG_INT_CMD2_COMPLETE
#define TPS_REG_INT_CMD1_COMPLETE
#define TPS_REG_INT_ADC_HIGH_THRESHOLD
#define TPS_REG_INT_ADC_LOW_THRESHOLD
#define TPS_REG_INT_PD_STATUS_UPDATE
#define TPS_REG_INT_STATUS_UPDATE
#define TPS_REG_INT_DATA_STATUS_UPDATE
#define TPS_REG_INT_POWER_STATUS_UPDATE
#define TPS_REG_INT_PP_SWITCH_CHANGED
#define TPS_REG_INT_HIGH_VOLTAGE_WARNING
#define TPS_REG_INT_USB_HOST_PRESENT_NO_LONGER
#define TPS_REG_INT_USB_HOST_PRESENT
#define TPS_REG_INT_GOTO_MIN_RECEIVED
#define TPS_REG_INT_PR_SWAP_REQUESTED
#define TPS_REG_INT_SINK_CAP_MESSAGE_READY
#define TPS_REG_INT_SOURCE_CAP_MESSAGE_READY
#define TPS_REG_INT_NEW_CONTRACT_AS_PROVIDER
#define TPS_REG_INT_NEW_CONTRACT_AS_CONSUMER
#define TPS_REG_INT_VDM_RECEIVED
#define TPS_REG_INT_ATTENTION_RECEIVED
#define TPS_REG_INT_OVERCURRENT
#define TPS_REG_INT_BIST
#define TPS_REG_INT_RDO_RECEIVED_FROM_SINK
#define TPS_REG_INT_DR_SWAP_COMPLETE
#define TPS_REG_INT_PR_SWAP_COMPLETE
#define TPS_REG_INT_PLUG_EVENT
#define TPS_REG_INT_HARD_RESET
#define TPS_REG_INT_PD_SOFT_RESET

/* Apple-specific TPS_REG_INT_* bits */
#define APPLE_CD_REG_INT_DATA_STATUS_UPDATE
#define APPLE_CD_REG_INT_POWER_STATUS_UPDATE
#define APPLE_CD_REG_INT_STATUS_UPDATE
#define APPLE_CD_REG_INT_PLUG_EVENT

/* TPS_REG_SYSTEM_POWER_STATE states */
#define TPS_SYSTEM_POWER_STATE_S0
#define TPS_SYSTEM_POWER_STATE_S3
#define TPS_SYSTEM_POWER_STATE_S4
#define TPS_SYSTEM_POWER_STATE_S5

/* TPS_REG_POWER_STATUS bits */
#define TPS_POWER_STATUS_CONNECTION(x)
#define TPS_POWER_STATUS_SOURCESINK(x)
#define TPS_POWER_STATUS_BC12_DET(x)

#define TPS_POWER_STATUS_TYPEC_CURRENT_MASK
#define TPS_POWER_STATUS_PWROPMODE(p)
#define TPS_POWER_STATUS_BC12_STATUS_MASK
#define TPS_POWER_STATUS_BC12_STATUS(p)

#define TPS_POWER_STATUS_TYPEC_CURRENT_USB
#define TPS_POWER_STATUS_TYPEC_CURRENT_1A5
#define TPS_POWER_STATUS_TYPEC_CURRENT_3A0
#define TPS_POWER_STATUS_TYPEC_CURRENT_PD

#define TPS_POWER_STATUS_BC12_STATUS_SDP
#define TPS_POWER_STATUS_BC12_STATUS_CDP
#define TPS_POWER_STATUS_BC12_STATUS_DCP

/* TPS25750_REG_POWER_STATUS bits */
#define TPS25750_POWER_STATUS_CHARGER_DETECT_STATUS_MASK
#define TPS25750_POWER_STATUS_CHARGER_DETECT_STATUS(p)
#define TPS25750_POWER_STATUS_CHARGER_ADVERTISE_STATUS_MASK
#define TPS25750_POWER_STATUS_CHARGER_ADVERTISE_STATUS(p)

#define TPS25750_POWER_STATUS_CHARGER_DET_STATUS_DISABLED
#define TPS25750_POWER_STATUS_CHARGER_DET_STATUS_IN_PROGRESS
#define TPS25750_POWER_STATUS_CHARGER_DET_STATUS_NONE
#define TPS25750_POWER_STATUS_CHARGER_DET_STATUS_SPD
#define TPS25750_POWER_STATUS_CHARGER_DET_STATUS_BC_1_2_CPD
#define TPS25750_POWER_STATUS_CHARGER_DET_STATUS_BC_1_2_DPD
#define TPS25750_POWER_STATUS_CHARGER_DET_STATUS_DIV_1_DCP
#define TPS25750_POWER_STATUS_CHARGER_DET_STATUS_DIV_2_DCP
#define TPS25750_POWER_STATUS_CHARGER_DET_STATUS_DIV_3_DCP
#define TPS25750_POWER_STATUS_CHARGER_DET_STATUS_1_2V_DCP

/* TPS_REG_DATA_STATUS bits */
#define TPS_DATA_STATUS_DATA_CONNECTION
#define TPS_DATA_STATUS_UPSIDE_DOWN
#define TPS_DATA_STATUS_ACTIVE_CABLE
#define TPS_DATA_STATUS_USB2_CONNECTION
#define TPS_DATA_STATUS_USB3_CONNECTION
#define TPS_DATA_STATUS_USB3_GEN2
#define TPS_DATA_STATUS_USB_DATA_ROLE
#define TPS_DATA_STATUS_DP_CONNECTION
#define TPS_DATA_STATUS_DP_SINK
#define TPS_DATA_STATUS_TBT_CONNECTION
#define TPS_DATA_STATUS_TBT_TYPE
#define TPS_DATA_STATUS_OPTICAL_CABLE
#define TPS_DATA_STATUS_ACTIVE_LINK_TRAIN
#define TPS_DATA_STATUS_FORCE_LSX
#define TPS_DATA_STATUS_POWER_MISMATCH

#define TPS_DATA_STATUS_DP_PIN_ASSIGNMENT_MASK
#define TPS_DATA_STATUS_DP_PIN_ASSIGNMENT(x)
#define TPS_DATA_STATUS_TBT_CABLE_SPEED_MASK
#define TPS_DATA_STATUS_TBT_CABLE_SPEED
#define TPS_DATA_STATUS_TBT_CABLE_GEN_MASK
#define TPS_DATA_STATUS_TBT_CABLE_GEN

/* Map data status to DP spec assignments */
#define TPS_DATA_STATUS_DP_SPEC_PIN_ASSIGNMENT(x)
#define TPS_DATA_STATUS_DP_SPEC_PIN_ASSIGNMENT_E
#define TPS_DATA_STATUS_DP_SPEC_PIN_ASSIGNMENT_F
#define TPS_DATA_STATUS_DP_SPEC_PIN_ASSIGNMENT_C
#define TPS_DATA_STATUS_DP_SPEC_PIN_ASSIGNMENT_D
#define TPS_DATA_STATUS_DP_SPEC_PIN_ASSIGNMENT_A
#define TPS_DATA_STATUS_DP_SPEC_PIN_ASSIGNMENT_B

/* BOOT STATUS REG*/
#define TPS_BOOT_STATUS_DEAD_BATTERY_FLAG
#define TPS_BOOT_STATUS_I2C_EEPROM_PRESENT

/* PD STATUS REG */
#define TPS_REG_PD_STATUS_PORT_TYPE_MASK
#define TPS_PD_STATUS_PORT_TYPE(x)

#define TPS_PD_STATUS_PORT_TYPE_SINK_SOURCE
#define TPS_PD_STATUS_PORT_TYPE_SINK
#define TPS_PD_STATUS_PORT_TYPE_SOURCE
#define TPS_PD_STATUS_PORT_TYPE_SOURCE_SINK

/* SLEEP CONF REG */
#define TPS_SLEEP_CONF_SLEEP_MODE_ALLOWED

/* Start Patch Download Sequence */
#define TPS_PTCS_CONTENT_APP
#define TPS_PTCS_CONTENT_DEV
#define TPS_PTCS_OUT_BYTES
#define TPS_PTCS_STATUS

#define TPS_PTCS_STATUS_FAIL
/* Patch Download */
#define TPS_PTCD_OUT_BYTES
#define TPS_PTCD_TRANSFER_STATUS
#define TPS_PTCD_LOADING_STATE

#define TPS_PTCD_LOAD_ERR
/* Patch Download Complete */
#define TPS_PTCC_OUT_BYTES
#define TPS_PTCC_DEV
#define TPS_PTCC_APP

/* Version Register */
#define TPS_VERSION_HW_VERSION_MASK
#define TPS_VERSION_HW_VERSION(x)
#define TPS_VERSION_HW_65981_2_6
#define TPS_VERSION_HW_65987_8_DH
#define TPS_VERSION_HW_65987_8_DK

/* Int Event Register length */
#define TPS_65981_2_6_INTEVENT_LEN
#define TPS_65987_8_INTEVENT_LEN

#endif /* __TPS6598X_H__ */