linux/drivers/usb/typec/tcpm/fusb302.c

// SPDX-License-Identifier: GPL-2.0+
/*
 * Copyright 2016-2017 Google, Inc
 *
 * Fairchild FUSB302 Type-C Chip Driver
 */

#include <linux/debugfs.h>
#include <linux/delay.h>
#include <linux/errno.h>
#include <linux/extcon.h>
#include <linux/gpio/consumer.h>
#include <linux/i2c.h>
#include <linux/interrupt.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/mutex.h>
#include <linux/of.h>
#include <linux/pinctrl/consumer.h>
#include <linux/proc_fs.h>
#include <linux/regulator/consumer.h>
#include <linux/sched/clock.h>
#include <linux/seq_file.h>
#include <linux/slab.h>
#include <linux/spinlock.h>
#include <linux/string.h>
#include <linux/types.h>
#include <linux/usb.h>
#include <linux/usb/typec.h>
#include <linux/usb/tcpm.h>
#include <linux/usb/pd.h>
#include <linux/workqueue.h>

#include "fusb302_reg.h"

/*
 * When the device is SNK, BC_LVL interrupt is used to monitor cc pins
 * for the current capability offered by the SRC. As FUSB302 chip fires
 * the BC_LVL interrupt on PD signalings, cc lvl should be handled after
 * a delay to avoid measuring on PD activities. The delay is slightly
 * longer than PD_T_PD_DEBPUNCE (10-20ms).
 */
#define T_BC_LVL_DEBOUNCE_DELAY_MS

enum toggling_mode {};

enum src_current_status {};

static const u8 ra_mda_value[] =;

static const u8 rd_mda_value[] =;

#define LOG_BUFFER_ENTRIES
#define LOG_BUFFER_ENTRY_SIZE

struct fusb302_chip {};

/*
 * Logging
 */

#ifdef CONFIG_DEBUG_FS
static bool fusb302_log_full(struct fusb302_chip *chip)
{}

__printf(2, 0)
static void _fusb302_log(struct fusb302_chip *chip, const char *fmt,
			 va_list args)
{}

__printf(2, 3)
static void fusb302_log(struct fusb302_chip *chip, const char *fmt, ...)
{}

static int fusb302_debug_show(struct seq_file *s, void *v)
{}
DEFINE_SHOW_ATTRIBUTE();

static void fusb302_debugfs_init(struct fusb302_chip *chip)
{}

static void fusb302_debugfs_exit(struct fusb302_chip *chip)
{}

#else

static void fusb302_log(const struct fusb302_chip *chip,
			const char *fmt, ...) { }
static void fusb302_debugfs_init(const struct fusb302_chip *chip) { }
static void fusb302_debugfs_exit(const struct fusb302_chip *chip) { }

#endif

static int fusb302_i2c_write(struct fusb302_chip *chip,
			     u8 address, u8 data)
{}

static int fusb302_i2c_block_write(struct fusb302_chip *chip, u8 address,
				   u8 length, const u8 *data)
{}

static int fusb302_i2c_read(struct fusb302_chip *chip,
			    u8 address, u8 *data)
{}

static int fusb302_i2c_block_read(struct fusb302_chip *chip, u8 address,
				  u8 length, u8 *data)
{}

static int fusb302_i2c_mask_write(struct fusb302_chip *chip, u8 address,
				  u8 mask, u8 value)
{}

static int fusb302_i2c_set_bits(struct fusb302_chip *chip, u8 address,
				u8 set_bits)
{}

static int fusb302_i2c_clear_bits(struct fusb302_chip *chip, u8 address,
				  u8 clear_bits)
{}

static int fusb302_sw_reset(struct fusb302_chip *chip)
{}

static int fusb302_enable_tx_auto_retries(struct fusb302_chip *chip, u8 retry_count)
{}

/*
 * initialize interrupt on the chip
 * - unmasked interrupt: VBUS_OK
 */
static int fusb302_init_interrupt(struct fusb302_chip *chip)
{}

static int fusb302_set_power_mode(struct fusb302_chip *chip, u8 power_mode)
{}

static int tcpm_init(struct tcpc_dev *dev)
{}

static int tcpm_get_vbus(struct tcpc_dev *dev)
{}

static int tcpm_get_current_limit(struct tcpc_dev *dev)
{}

static int fusb302_set_src_current(struct fusb302_chip *chip,
				   enum src_current_status status)
{}

static int fusb302_set_toggling(struct fusb302_chip *chip,
				enum toggling_mode mode)
{}

static const char * const typec_cc_status_name[] =;

static const enum src_current_status cc_src_current[] =;

static int tcpm_set_cc(struct tcpc_dev *dev, enum typec_cc_status cc)
{}

static int tcpm_get_cc(struct tcpc_dev *dev, enum typec_cc_status *cc1,
		       enum typec_cc_status *cc2)
{}

static int tcpm_set_polarity(struct tcpc_dev *dev,
			     enum typec_cc_polarity polarity)
{}

static int tcpm_set_vconn(struct tcpc_dev *dev, bool on)
{}

static int tcpm_set_vbus(struct tcpc_dev *dev, bool on, bool charge)
{}

static int fusb302_pd_tx_flush(struct fusb302_chip *chip)
{}

static int fusb302_pd_rx_flush(struct fusb302_chip *chip)
{}

static int fusb302_pd_set_auto_goodcrc(struct fusb302_chip *chip, bool on)
{}

static int fusb302_pd_set_interrupts(struct fusb302_chip *chip, bool on)
{}

static int tcpm_set_pd_rx(struct tcpc_dev *dev, bool on)
{}

static const char * const typec_role_name[] =;

static const char * const typec_data_role_name[] =;

static int tcpm_set_roles(struct tcpc_dev *dev, bool attached,
			  enum typec_role pwr, enum typec_data_role data)
{}

static int tcpm_start_toggling(struct tcpc_dev *dev,
			       enum typec_port_type port_type,
			       enum typec_cc_status cc)
{}

static int fusb302_pd_send_message(struct fusb302_chip *chip,
				   const struct pd_message *msg)
{}

static int fusb302_pd_send_hardreset(struct fusb302_chip *chip)
{}

static const char * const transmit_type_name[] =;

static int tcpm_pd_transmit(struct tcpc_dev *dev, enum tcpm_transmit_type type,
			    const struct pd_message *msg, unsigned int negotiated_rev)
{}

static enum typec_cc_status fusb302_bc_lvl_to_cc(u8 bc_lvl)
{}

static void fusb302_bc_lvl_handler_work(struct work_struct *work)
{}

static void init_tcpc_dev(struct tcpc_dev *fusb302_tcpc_dev)
{}

static const char * const cc_polarity_name[] =;

static int fusb302_set_cc_polarity_and_pull(struct fusb302_chip *chip,
					    enum typec_cc_polarity cc_polarity,
					    bool pull_up, bool pull_down)
{}

static int fusb302_handle_togdone_snk(struct fusb302_chip *chip,
				      u8 togdone_result)
{}

/* On error returns < 0, otherwise a typec_cc_status value */
static int fusb302_get_src_cc_status(struct fusb302_chip *chip,
				     enum typec_cc_polarity cc_polarity,
				     enum typec_cc_status *cc)
{}

static int fusb302_handle_togdone_src(struct fusb302_chip *chip,
				      u8 togdone_result)
{}

static int fusb302_handle_togdone(struct fusb302_chip *chip)
{}

static int fusb302_pd_reset(struct fusb302_chip *chip)
{}

static int fusb302_pd_read_message(struct fusb302_chip *chip,
				   struct pd_message *msg)
{}

static irqreturn_t fusb302_irq_intn(int irq, void *dev_id)
{}

static void fusb302_irq_work(struct work_struct *work)
{}

static int init_gpio(struct fusb302_chip *chip)
{}

#define PDO_FIXED_FLAGS

static const u32 src_pdo[] =;

static const u32 snk_pdo[] =;

static const struct property_entry port_props[] =;

static struct fwnode_handle *fusb302_fwnode_get(struct device *dev)
{}

static int fusb302_probe(struct i2c_client *client)
{}

static void fusb302_remove(struct i2c_client *client)
{}

static int fusb302_pm_suspend(struct device *dev)
{}

static int fusb302_pm_resume(struct device *dev)
{}

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

static const struct i2c_device_id fusb302_i2c_device_id[] =;
MODULE_DEVICE_TABLE(i2c, fusb302_i2c_device_id);

static const struct dev_pm_ops fusb302_pm_ops =;

static struct i2c_driver fusb302_driver =;
module_i2c_driver();

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