linux/drivers/usb/typec/anx7411.c

// SPDX-License-Identifier: GPL-2.0-only

/*
 * Driver for Analogix ANX7411 USB Type-C and PD controller
 *
 * Copyright(c) 2022, Analogix Semiconductor. All rights reserved.
 *
 */
#include <linux/bitfield.h>
#include <linux/gpio/consumer.h>
#include <linux/i2c.h>
#include <linux/interrupt.h>
#include <linux/iopoll.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/mutex.h>
#include <linux/of_graph.h>
#include <linux/of_platform.h>
#include <linux/pm_runtime.h>
#include <linux/regulator/consumer.h>
#include <linux/slab.h>
#include <linux/types.h>
#include <linux/usb/pd.h>
#include <linux/usb/role.h>
#include <linux/usb/tcpci.h>
#include <linux/usb/typec.h>
#include <linux/usb/typec_dp.h>
#include <linux/usb/typec_mux.h>
#include <linux/workqueue.h>
#include <linux/power_supply.h>

#define TCPC_ADDRESS1
#define TCPC_ADDRESS2
#define TCPC_ADDRESS3
#define TCPC_ADDRESS4
#define SPI_ADDRESS1
#define SPI_ADDRESS2
#define SPI_ADDRESS3
#define SPI_ADDRESS4

struct anx7411_i2c_select {};

#define VID_ANALOGIX
#define PID_ANALOGIX

/* TCPC register define */

#define ANALOG_CTRL_10

#define STATUS_LEN
#define ALERT_0
#define RECEIVED_MSG
#define SOFTWARE_INT
#define MSG_LEN
#define HEADER_LEN
#define MSG_HEADER
#define MSG_TYPE
#define MSG_RAWDATA
#define MSG_LEN_MASK

#define ALERT_1
#define INTP_POW_ON
#define INTP_POW_OFF

#define VBUS_THRESHOLD_H
#define VBUS_THRESHOLD_L

#define FW_CTRL_0
#define UNSTRUCT_VDM_EN
#define DELAY_200MS
#define VSAFE0
#define VSAFE1
#define VSAFE2
#define VSAFE3
#define FRS_EN

#define FW_PARAM
#define DONGLE_IOP

#define FW_CTRL_2
#define SINK_CTRL_DIS_FLAG

/* SPI register define */
#define OCM_CTRL_0
#define OCM_RESET

#define MAX_VOLTAGE
#define MAX_POWER
#define MIN_POWER

#define REQUEST_VOLTAGE
#define VOLTAGE_UNIT

#define REQUEST_CURRENT
#define CURRENT_UNIT

#define CMD_SEND_BUF
#define CMD_RECV_BUF

#define REQ_VOL_20V_IN_100MV
#define REQ_CUR_2_25A_IN_50MA
#define REQ_CUR_3_25A_IN_50MA

#define DEF_5V
#define DEF_1_5A

#define LOBYTE(w)
#define HIBYTE(w)

enum anx7411_typec_message_type {};

#define FW_CTRL_1
#define AUTO_PD_EN
#define TRYSRC_EN
#define TRYSNK_EN
#define FORCE_SEND_RDO

#define FW_VER
#define FW_SUBVER

#define INT_MASK
#define INT_STS
#define OCM_BOOT_UP
#define OC_OV_EVENT
#define VCONN_CHANGE
#define VBUS_CHANGE
#define CC_STATUS_CHANGE
#define DATA_ROLE_CHANGE
#define PR_CONSUMER_GOT_POWER
#define HPD_STATUS_CHANGE

#define SYSTEM_STSTUS
/* 0: SINK off; 1: SINK on */
#define SINK_STATUS
/* 0: VCONN off; 1: VCONN on*/
#define VCONN_STATUS
/* 0: vbus off; 1: vbus on*/
#define VBUS_STATUS
/* 1: host; 0:device*/
#define DATA_ROLE
/* 0: Chunking; 1: Unchunked*/
#define SUPPORT_UNCHUNKING
/* 0: HPD low; 1: HPD high*/
#define HPD_STATUS

#define DATA_DFP
#define DATA_UFP
#define POWER_SOURCE
#define POWER_SINK

#define CC_STATUS
#define CC1_RD
#define CC2_RD
#define CC1_RA
#define CC2_RA
#define CC1_RD
#define CC1_RP(cc)
#define CC2_RP(cc)

#define PD_REV_INIT

#define PD_EXT_MSG_CTRL
#define SRC_CAP_EXT_REPLY
#define MANUFACTURER_INFO_REPLY
#define BATTERY_STS_REPLY
#define BATTERY_CAP_REPLY
#define ALERT_REPLY
#define STATUS_REPLY
#define PPS_STATUS_REPLY
#define SNK_CAP_EXT_REPLY

#define NO_CONNECT
#define USB3_1_CONNECTED
#define DP_ALT_4LANES
#define USB3_1_DP_2LANES
#define CC1_CONNECTED
#define CC2_CONNECTED
#define SELECT_PIN_ASSIGMENT_C
#define SELECT_PIN_ASSIGMENT_D
#define SELECT_PIN_ASSIGMENT_E
#define SELECT_PIN_ASSIGMENT_U
#define REDRIVER_ADDRESS
#define REDRIVER_OFFSET

#define DP_SVID
#define VDM_ACK
#define VDM_CMD_RES
#define VDM_CMD_DIS_ID
#define VDM_CMD_DIS_SVID
#define VDM_CMD_DIS_MOD
#define VDM_CMD_ENTER_MODE
#define VDM_CMD_EXIT_MODE
#define VDM_CMD_ATTENTION
#define VDM_CMD_GET_STS
#define VDM_CMD_AND_ACK_MASK

#define MAX_ALTMODE

#define HAS_SOURCE_CAP
#define HAS_SINK_CAP
#define HAS_SINK_WATT

enum anx7411_psy_state {};

struct typec_params {};

#define MAX_BUF_LEN
struct fw_msg {} __packed;

struct anx7411_data {};

static u8 snk_identity[] =;

static u8 dp_caps[4] =;

static int anx7411_reg_read(struct i2c_client *client,
			    u8 reg_addr)
{}

static int anx7411_reg_block_read(struct i2c_client *client,
				  u8 reg_addr, u8 len, u8 *buf)
{}

static int anx7411_reg_write(struct i2c_client *client,
			     u8 reg_addr, u8 reg_val)
{}

static int anx7411_reg_block_write(struct i2c_client *client,
				   u8 reg_addr, u8 len, u8 *buf)
{}

static struct anx7411_i2c_select anx7411_i2c_addr[] =;

static int anx7411_detect_power_mode(struct anx7411_data *ctx)
{}

static int anx7411_register_partner(struct anx7411_data *ctx,
				    int pd, int accessory)
{}

static int anx7411_detect_cc_orientation(struct anx7411_data *ctx)
{}

static int anx7411_set_mux(struct anx7411_data *ctx, int pin_assignment)
{}

static int anx7411_set_usb_role(struct anx7411_data *ctx, enum usb_role role)
{}

static int anx7411_data_role_detect(struct anx7411_data *ctx)
{}

static int anx7411_power_role_detect(struct anx7411_data *ctx)
{}

static int anx7411_cc_status_detect(struct anx7411_data *ctx)
{}

static void anx7411_partner_unregister_altmode(struct anx7411_data *ctx)
{}

static int anx7411_typec_register_altmode(struct anx7411_data *ctx,
					  int svid, int vdo)
{}

static void anx7411_unregister_partner(struct anx7411_data *ctx)
{}

static int anx7411_update_altmode(struct anx7411_data *ctx, int svid)
{}

static int anx7411_register_altmode(struct anx7411_data *ctx,
				    bool dp_altmode, u8 *buf)
{}

static int anx7411_parse_cmd(struct anx7411_data *ctx, u8 type, u8 *buf, u8 len)
{}

static u8 checksum(struct device *dev, u8 *buf, u8 len)
{}

static int anx7411_read_msg_ctrl_status(struct i2c_client *client)
{}

static int anx7411_wait_msg_empty(struct i2c_client *client)
{}

static int anx7411_send_msg(struct anx7411_data *ctx, u8 type, u8 *buf, u8 size)
{}

static int anx7411_process_cmd(struct anx7411_data *ctx)
{}

static void anx7411_translate_payload(struct device *dev, __le32 *payload,
				      u32 *pdo, int nr, const char *type)
{}

static int anx7411_config(struct anx7411_data *ctx)
{}

static void anx7411_chip_standby(struct anx7411_data *ctx)
{}

static void anx7411_work_func(struct work_struct *work)
{}

static irqreturn_t anx7411_intr_isr(int irq, void *data)
{}

static int anx7411_register_i2c_dummy_clients(struct anx7411_data *ctx,
					      struct i2c_client *client)
{}

static void anx7411_port_unregister_altmodes(struct typec_altmode **adev)
{}

static int anx7411_usb_mux_set(struct typec_mux_dev *mux,
			       struct typec_mux_state *state)
{}

static int anx7411_usb_set_orientation(struct typec_switch_dev *sw,
				       enum typec_orientation orientation)
{}

static int anx7411_register_switch(struct anx7411_data *ctx,
				   struct device *dev,
				   struct fwnode_handle *fwnode)
{}

static int anx7411_register_mux(struct anx7411_data *ctx,
				struct device *dev,
				struct fwnode_handle *fwnode)
{}

static void anx7411_unregister_mux(struct anx7411_data *ctx)
{}

static void anx7411_unregister_switch(struct anx7411_data *ctx)
{}

static int anx7411_typec_switch_probe(struct anx7411_data *ctx,
				      struct device *dev)
{}

static int anx7411_typec_port_probe(struct anx7411_data *ctx,
				    struct device *dev)
{}

static int anx7411_typec_check_connection(struct anx7411_data *ctx)
{}

static int __maybe_unused anx7411_runtime_pm_suspend(struct device *dev)
{}

static int __maybe_unused anx7411_runtime_pm_resume(struct device *dev)
{}

static const struct dev_pm_ops anx7411_pm_ops =;

static void anx7411_get_gpio_irq(struct anx7411_data *ctx)
{}

static enum power_supply_property anx7411_psy_props[] =;

static int anx7411_psy_set_prop(struct power_supply *psy,
				enum power_supply_property psp,
				const union power_supply_propval *val)
{}

static int anx7411_psy_prop_writeable(struct power_supply *psy,
				      enum power_supply_property psp)
{}

static int anx7411_psy_get_prop(struct power_supply *psy,
				enum power_supply_property psp,
				union power_supply_propval *val)
{}

static int anx7411_psy_register(struct anx7411_data *ctx)
{}

static int anx7411_i2c_probe(struct i2c_client *client)
{}

static void anx7411_i2c_remove(struct i2c_client *client)
{}

static const struct i2c_device_id anx7411_id[] =;

MODULE_DEVICE_TABLE(i2c, anx7411_id);

static const struct of_device_id anx_match_table[] =;
MODULE_DEVICE_TABLE(of, anx_match_table);

static struct i2c_driver anx7411_driver =;

module_i2c_driver();

MODULE_DESCRIPTION();
MODULE_AUTHOR();
MODULE_LICENSE();
MODULE_VERSION();