linux/drivers/platform/chrome/cros_ec_typec.c

// SPDX-License-Identifier: GPL-2.0-only
/*
 * Copyright 2020 Google LLC
 *
 * This driver provides the ability to view and manage Type C ports through the
 * Chrome OS EC.
 */

#include <linux/acpi.h>
#include <linux/module.h>
#include <linux/of.h>
#include <linux/platform_data/cros_ec_commands.h>
#include <linux/platform_data/cros_usbpd_notify.h>
#include <linux/platform_device.h>
#include <linux/usb/pd_vdo.h>
#include <linux/usb/typec_dp.h>
#include <linux/usb/typec_tbt.h>

#include "cros_ec_typec.h"
#include "cros_typec_vdm.h"

#define DRV_NAME

#define DP_PORT_VDO

static void cros_typec_role_switch_quirk(struct fwnode_handle *fwnode)
{}

static int cros_typec_parse_port_props(struct typec_capability *cap,
				       struct fwnode_handle *fwnode,
				       struct device *dev)
{}

static int cros_typec_get_switch_handles(struct cros_typec_port *port,
					 struct fwnode_handle *fwnode,
					 struct device *dev)
{}

static int cros_typec_add_partner(struct cros_typec_data *typec, int port_num,
				  bool pd_en)
{}

static void cros_typec_unregister_altmodes(struct cros_typec_data *typec, int port_num,
					   bool is_partner)
{}

/*
 * Map the Type-C Mux state to retimer state and call the retimer set function. We need this
 * because we re-use the Type-C mux state for retimers.
 */
static int cros_typec_retimer_set(struct typec_retimer *retimer, struct typec_mux_state state)
{}

static int cros_typec_usb_disconnect_state(struct cros_typec_port *port)
{}

static void cros_typec_remove_partner(struct cros_typec_data *typec,
				      int port_num)
{}

static void cros_typec_remove_cable(struct cros_typec_data *typec,
				    int port_num)
{}

static void cros_typec_unregister_port_altmodes(struct cros_typec_port *port)
{}

static void cros_unregister_ports(struct cros_typec_data *typec)
{}

/*
 * Register port alt modes with known values till we start retrieving
 * port capabilities from the EC.
 */
static int cros_typec_register_port_altmodes(struct cros_typec_data *typec,
					      int port_num)
{}

static int cros_typec_init_ports(struct cros_typec_data *typec)
{}

static int cros_typec_usb_safe_state(struct cros_typec_port *port)
{}

/**
 * cros_typec_get_cable_vdo() - Get Cable VDO of the connected cable
 * @port: Type-C port data
 * @svid: Standard or Vendor ID to match
 *
 * Returns the Cable VDO if match is found and returns 0 if match is not found.
 */
static int cros_typec_get_cable_vdo(struct cros_typec_port *port, u16 svid)
{}

/*
 * Spoof the VDOs that were likely communicated by the partner for TBT alt
 * mode.
 */
static int cros_typec_enable_tbt(struct cros_typec_data *typec,
				 int port_num,
				 struct ec_response_usb_pd_control_v2 *pd_ctrl)
{}

/* Spoof the VDOs that were likely communicated by the partner. */
static int cros_typec_enable_dp(struct cros_typec_data *typec,
				int port_num,
				struct ec_response_usb_pd_control_v2 *pd_ctrl)
{}

static int cros_typec_enable_usb4(struct cros_typec_data *typec,
				  int port_num,
				  struct ec_response_usb_pd_control_v2 *pd_ctrl)
{}

static int cros_typec_configure_mux(struct cros_typec_data *typec, int port_num,
				struct ec_response_usb_pd_control_v2 *pd_ctrl)
{}

static void cros_typec_set_port_params_v0(struct cros_typec_data *typec,
		int port_num, struct ec_response_usb_pd_control *resp)
{}

static void cros_typec_set_port_params_v1(struct cros_typec_data *typec,
		int port_num, struct ec_response_usb_pd_control_v1 *resp)
{}

/*
 * Helper function to register partner/plug altmodes.
 */
static int cros_typec_register_altmodes(struct cros_typec_data *typec, int port_num,
					bool is_partner)
{}

/*
 * Parse the PD identity data from the EC PD discovery responses and copy that to the supplied
 * PD identity struct.
 */
static void cros_typec_parse_pd_identity(struct usb_pd_identity *id,
					 struct ec_response_typec_discovery *disc)
{}

static int cros_typec_handle_sop_prime_disc(struct cros_typec_data *typec, int port_num, u16 pd_revision)
{}

static int cros_typec_handle_sop_disc(struct cros_typec_data *typec, int port_num, u16 pd_revision)
{}

static int cros_typec_send_clear_event(struct cros_typec_data *typec, int port_num, u32 events_mask)
{}

static void cros_typec_register_partner_pdos(struct cros_typec_data *typec,
					     struct ec_response_typec_status *resp, int port_num)
{}

static void cros_typec_handle_status(struct cros_typec_data *typec, int port_num)
{}

static int cros_typec_port_update(struct cros_typec_data *typec, int port_num)
{}

static int cros_typec_get_cmd_version(struct cros_typec_data *typec)
{}

static void cros_typec_port_work(struct work_struct *work)
{}

static int cros_ec_typec_event(struct notifier_block *nb,
			       unsigned long host_event, void *_notify)
{}

#ifdef CONFIG_ACPI
static const struct acpi_device_id cros_typec_acpi_id[] =;
MODULE_DEVICE_TABLE(acpi, cros_typec_acpi_id);
#endif

#ifdef CONFIG_OF
static const struct of_device_id cros_typec_of_match[] =;
MODULE_DEVICE_TABLE(of, cros_typec_of_match);
#endif

static int cros_typec_probe(struct platform_device *pdev)
{}

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

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

static const struct dev_pm_ops cros_typec_pm_ops =;

static struct platform_driver cros_typec_driver =;

module_platform_driver();

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