linux/drivers/usb/typec/stusb160x.c

// SPDX-License-Identifier: GPL-2.0
/*
 * STMicroelectronics STUSB160x Type-C controller family driver
 *
 * Copyright (C) 2020, STMicroelectronics
 * Author(s): Amelie Delaunay <[email protected]>
 */

#include <linux/bitfield.h>
#include <linux/i2c.h>
#include <linux/interrupt.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/regmap.h>
#include <linux/regulator/consumer.h>
#include <linux/usb/role.h>
#include <linux/usb/typec.h>

#define STUSB160X_ALERT_STATUS
#define STUSB160X_ALERT_STATUS_MASK_CTRL
#define STUSB160X_CC_CONNECTION_STATUS_TRANS
#define STUSB160X_CC_CONNECTION_STATUS
#define STUSB160X_MONITORING_STATUS_TRANS
#define STUSB160X_MONITORING_STATUS
#define STUSB160X_CC_OPERATION_STATUS
#define STUSB160X_HW_FAULT_STATUS_TRANS
#define STUSB160X_HW_FAULT_STATUS
#define STUSB160X_CC_CAPABILITY_CTRL
#define STUSB160X_CC_VCONN_SWITCH_CTRL
#define STUSB160X_VCONN_MONITORING_CTRL
#define STUSB160X_VBUS_MONITORING_RANGE_CTRL
#define STUSB160X_RESET_CTRL
#define STUSB160X_VBUS_DISCHARGE_TIME_CTRL
#define STUSB160X_VBUS_DISCHARGE_STATUS
#define STUSB160X_VBUS_ENABLE_STATUS
#define STUSB160X_CC_POWER_MODE_CTRL
#define STUSB160X_VBUS_MONITORING_CTRL
#define STUSB1600_REG_MAX

/* STUSB160X_ALERT_STATUS/STUSB160X_ALERT_STATUS_MASK_CTRL bitfields */
#define STUSB160X_HW_FAULT
#define STUSB160X_MONITORING
#define STUSB160X_CC_CONNECTION
#define STUSB160X_ALL_ALERTS

/* STUSB160X_CC_CONNECTION_STATUS_TRANS bitfields */
#define STUSB160X_CC_ATTACH_TRANS

/* STUSB160X_CC_CONNECTION_STATUS bitfields */
#define STUSB160X_CC_ATTACH
#define STUSB160X_CC_VCONN_SUPPLY
#define STUSB160X_CC_DATA_ROLE(s)
#define STUSB160X_CC_POWER_ROLE(s)
#define STUSB160X_CC_ATTACHED_MODE

/* STUSB160X_MONITORING_STATUS_TRANS bitfields */
#define STUSB160X_VCONN_PRESENCE_TRANS
#define STUSB160X_VBUS_PRESENCE_TRANS
#define STUSB160X_VBUS_VSAFE0V_TRANS
#define STUSB160X_VBUS_VALID_TRANS

/* STUSB160X_MONITORING_STATUS bitfields */
#define STUSB160X_VCONN_PRESENCE
#define STUSB160X_VBUS_PRESENCE
#define STUSB160X_VBUS_VSAFE0V
#define STUSB160X_VBUS_VALID

/* STUSB160X_CC_OPERATION_STATUS bitfields */
#define STUSB160X_TYPEC_FSM_STATE
#define STUSB160X_SINK_POWER_STATE
#define STUSB160X_CC_ATTACHED

/* STUSB160X_HW_FAULT_STATUS_TRANS bitfields */
#define STUSB160X_VCONN_SW_OVP_FAULT_TRANS
#define STUSB160X_VCONN_SW_OCP_FAULT_TRANS
#define STUSB160X_VCONN_SW_RVP_FAULT_TRANS
#define STUSB160X_VPU_VALID_TRANS
#define STUSB160X_VPU_OVP_FAULT_TRANS
#define STUSB160X_THERMAL_FAULT

/* STUSB160X_HW_FAULT_STATUS bitfields */
#define STUSB160X_VCONN_SW_OVP_FAULT_CC2
#define STUSB160X_VCONN_SW_OVP_FAULT_CC1
#define STUSB160X_VCONN_SW_OCP_FAULT_CC2
#define STUSB160X_VCONN_SW_OCP_FAULT_CC1
#define STUSB160X_VCONN_SW_RVP_FAULT_CC2
#define STUSB160X_VCONN_SW_RVP_FAULT_CC1
#define STUSB160X_VPU_VALID
#define STUSB160X_VPU_OVP_FAULT

/* STUSB160X_CC_CAPABILITY_CTRL bitfields */
#define STUSB160X_CC_VCONN_SUPPLY_EN
#define STUSB160X_CC_VCONN_DISCHARGE_EN
#define STUSB160X_CC_CURRENT_ADVERTISED

/* STUSB160X_VCONN_SWITCH_CTRL bitfields */
#define STUSB160X_CC_VCONN_SWITCH_ILIM

/* STUSB160X_VCONN_MONITORING_CTRL bitfields */
#define STUSB160X_VCONN_UVLO_THRESHOLD
#define STUSB160X_VCONN_MONITORING_EN

/* STUSB160X_VBUS_MONITORING_RANGE_CTRL bitfields */
#define STUSB160X_SHIFT_LOW_VBUS_LIMIT
#define STUSB160X_SHIFT_HIGH_VBUS_LIMIT

/* STUSB160X_RESET_CTRL bitfields */
#define STUSB160X_SW_RESET_EN

/* STUSB160X_VBUS_DISCHARGE_TIME_CTRL bitfields */
#define STUSBXX02_VBUS_DISCHARGE_TIME_TO_PDO
#define STUSB160X_VBUS_DISCHARGE_TIME_TO_0V

/* STUSB160X_VBUS_DISCHARGE_STATUS bitfields */
#define STUSB160X_VBUS_DISCHARGE_EN

/* STUSB160X_VBUS_ENABLE_STATUS bitfields */
#define STUSB160X_VBUS_SOURCE_EN
#define STUSB160X_VBUS_SINK_EN

/* STUSB160X_CC_POWER_MODE_CTRL bitfields */
#define STUSB160X_CC_POWER_MODE

/* STUSB160X_VBUS_MONITORING_CTRL bitfields */
#define STUSB160X_VDD_UVLO_DISABLE
#define STUSB160X_VBUS_VSAFE0V_THRESHOLD
#define STUSB160X_VBUS_RANGE_DISABLE
#define STUSB160X_VDD_OVLO_DISABLE

enum stusb160x_pwr_mode {};

enum stusb160x_attached_mode {};

struct stusb160x {};

static bool stusb160x_reg_writeable(struct device *dev, unsigned int reg)
{}

static bool stusb160x_reg_readable(struct device *dev, unsigned int reg)
{}

static bool stusb160x_reg_volatile(struct device *dev, unsigned int reg)
{}

static bool stusb160x_reg_precious(struct device *dev, unsigned int reg)
{}

static const struct regmap_config stusb1600_regmap_config =;

static bool stusb160x_get_vconn(struct stusb160x *chip)
{}

static int stusb160x_set_vconn(struct stusb160x *chip, bool on)
{}

static enum typec_pwr_opmode stusb160x_get_pwr_opmode(struct stusb160x *chip)
{}

static enum typec_accessory stusb160x_get_accessory(u32 status)
{}

static enum typec_role stusb160x_get_vconn_role(u32 status)
{}

static void stusb160x_set_data_role(struct stusb160x *chip,
				    enum typec_data_role data_role,
				    bool attached)
{}

static int stusb160x_attach(struct stusb160x *chip, u32 status)
{}

static void stusb160x_detach(struct stusb160x *chip, u32 status)
{}

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

static int stusb160x_irq_init(struct stusb160x *chip, int irq)
{}

static int stusb160x_chip_init(struct stusb160x *chip)
{}

static int stusb160x_get_fw_caps(struct stusb160x *chip,
				 struct fwnode_handle *fwnode)
{}

static int stusb160x_get_caps(struct stusb160x *chip)
{}

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

static int stusb160x_probe(struct i2c_client *client)
{}

static void stusb160x_remove(struct i2c_client *client)
{}

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

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

static SIMPLE_DEV_PM_OPS(stusb160x_pm_ops, stusb160x_suspend, stusb160x_resume);

static struct i2c_driver stusb160x_driver =;
module_i2c_driver();

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