#include <linux/module.h>
#include <linux/mutex.h>
#include <linux/property.h>
#include <linux/slab.h>
#include <linux/usb/pd_vdo.h>
#include <linux/usb/typec_mux.h>
#include <linux/usb/typec_retimer.h>
#include <linux/usb.h>
#include "bus.h"
#include "class.h"
#include "pd.h"
static DEFINE_IDA(typec_index_ida);
const struct class typec_class = …;
static const char * const typec_accessory_modes[] = …;
static const char * const product_type_ufp[8] = …;
static const char * const product_type_dfp[8] = …;
static const char * const product_type_cable[8] = …;
static struct usb_pd_identity *get_pd_identity(struct device *dev)
{ … }
static const char *get_pd_product_type(struct device *dev)
{ … }
static ssize_t id_header_show(struct device *dev, struct device_attribute *attr,
char *buf)
{ … }
static DEVICE_ATTR_RO(id_header);
static ssize_t cert_stat_show(struct device *dev, struct device_attribute *attr,
char *buf)
{ … }
static DEVICE_ATTR_RO(cert_stat);
static ssize_t product_show(struct device *dev, struct device_attribute *attr,
char *buf)
{ … }
static DEVICE_ATTR_RO(product);
static ssize_t product_type_vdo1_show(struct device *dev, struct device_attribute *attr,
char *buf)
{ … }
static DEVICE_ATTR_RO(product_type_vdo1);
static ssize_t product_type_vdo2_show(struct device *dev, struct device_attribute *attr,
char *buf)
{ … }
static DEVICE_ATTR_RO(product_type_vdo2);
static ssize_t product_type_vdo3_show(struct device *dev, struct device_attribute *attr,
char *buf)
{ … }
static DEVICE_ATTR_RO(product_type_vdo3);
static struct attribute *usb_pd_id_attrs[] = …;
static const struct attribute_group usb_pd_id_group = …;
static const struct attribute_group *usb_pd_id_groups[] = …;
static void typec_product_type_notify(struct device *dev)
{ … }
static void typec_report_identity(struct device *dev)
{ … }
static ssize_t
type_show(struct device *dev, struct device_attribute *attr, char *buf)
{ … }
static DEVICE_ATTR_RO(type);
static ssize_t usb_power_delivery_revision_show(struct device *dev,
struct device_attribute *attr,
char *buf);
static DEVICE_ATTR_RO(usb_power_delivery_revision);
static int altmode_match(struct device *dev, void *data)
{ … }
static void typec_altmode_set_partner(struct altmode *altmode)
{ … }
static void typec_altmode_put_partner(struct altmode *altmode)
{ … }
void typec_altmode_update_active(struct typec_altmode *adev, bool active)
{ … }
EXPORT_SYMBOL_GPL(…);
struct typec_port *typec_altmode2port(struct typec_altmode *alt)
{ … }
EXPORT_SYMBOL_GPL(…);
static ssize_t
vdo_show(struct device *dev, struct device_attribute *attr, char *buf)
{ … }
static DEVICE_ATTR_RO(vdo);
static ssize_t
description_show(struct device *dev, struct device_attribute *attr, char *buf)
{ … }
static DEVICE_ATTR_RO(description);
static ssize_t
active_show(struct device *dev, struct device_attribute *attr, char *buf)
{ … }
static ssize_t active_store(struct device *dev, struct device_attribute *attr,
const char *buf, size_t size)
{ … }
static DEVICE_ATTR_RW(active);
static ssize_t
supported_roles_show(struct device *dev, struct device_attribute *attr,
char *buf)
{ … }
static DEVICE_ATTR_RO(supported_roles);
static ssize_t
mode_show(struct device *dev, struct device_attribute *attr, char *buf)
{ … }
static DEVICE_ATTR_RO(mode);
static ssize_t
svid_show(struct device *dev, struct device_attribute *attr, char *buf)
{ … }
static DEVICE_ATTR_RO(svid);
static struct attribute *typec_altmode_attrs[] = …;
static umode_t typec_altmode_attr_is_visible(struct kobject *kobj,
struct attribute *attr, int n)
{ … }
static const struct attribute_group typec_altmode_group = …;
static const struct attribute_group *typec_altmode_groups[] = …;
void typec_altmode_set_ops(struct typec_altmode *adev,
const struct typec_altmode_ops *ops)
{ … }
EXPORT_SYMBOL_GPL(…);
static int altmode_id_get(struct device *dev)
{ … }
static void altmode_id_remove(struct device *dev, int id)
{ … }
static void typec_altmode_release(struct device *dev)
{ … }
const struct device_type typec_altmode_dev_type = …;
static struct typec_altmode *
typec_register_altmode(struct device *parent,
const struct typec_altmode_desc *desc)
{ … }
void typec_unregister_altmode(struct typec_altmode *adev)
{ … }
EXPORT_SYMBOL_GPL(…);
static ssize_t accessory_mode_show(struct device *dev,
struct device_attribute *attr,
char *buf)
{ … }
static DEVICE_ATTR_RO(accessory_mode);
static ssize_t supports_usb_power_delivery_show(struct device *dev,
struct device_attribute *attr,
char *buf)
{ … }
static DEVICE_ATTR_RO(supports_usb_power_delivery);
static ssize_t number_of_alternate_modes_show(struct device *dev, struct device_attribute *attr,
char *buf)
{ … }
static DEVICE_ATTR_RO(number_of_alternate_modes);
static struct attribute *typec_partner_attrs[] = …;
static umode_t typec_partner_attr_is_visible(struct kobject *kobj, struct attribute *attr, int n)
{ … }
static const struct attribute_group typec_partner_group = …;
static const struct attribute_group *typec_partner_groups[] = …;
static void typec_partner_release(struct device *dev)
{ … }
const struct device_type typec_partner_dev_type = …;
static void typec_partner_link_device(struct typec_partner *partner, struct device *dev)
{ … }
static void typec_partner_unlink_device(struct typec_partner *partner, struct device *dev)
{ … }
int typec_partner_set_identity(struct typec_partner *partner)
{ … }
EXPORT_SYMBOL_GPL(…);
void typec_partner_set_pd_revision(struct typec_partner *partner, u16 pd_revision)
{ … }
EXPORT_SYMBOL_GPL(…);
int typec_partner_set_usb_power_delivery(struct typec_partner *partner,
struct usb_power_delivery *pd)
{ … }
EXPORT_SYMBOL_GPL(…);
int typec_partner_set_num_altmodes(struct typec_partner *partner, int num_altmodes)
{ … }
EXPORT_SYMBOL_GPL(…);
struct typec_altmode *
typec_partner_register_altmode(struct typec_partner *partner,
const struct typec_altmode_desc *desc)
{ … }
EXPORT_SYMBOL_GPL(…);
void typec_partner_set_svdm_version(struct typec_partner *partner,
enum usb_pd_svdm_ver svdm_version)
{ … }
EXPORT_SYMBOL_GPL(…);
struct usb_power_delivery *
typec_partner_usb_power_delivery_register(struct typec_partner *partner,
struct usb_power_delivery_desc *desc)
{ … }
EXPORT_SYMBOL_GPL(…);
struct typec_partner *typec_register_partner(struct typec_port *port,
struct typec_partner_desc *desc)
{ … }
EXPORT_SYMBOL_GPL(…);
void typec_unregister_partner(struct typec_partner *partner)
{ … }
EXPORT_SYMBOL_GPL(…);
static void typec_plug_release(struct device *dev)
{ … }
static struct attribute *typec_plug_attrs[] = …;
static umode_t typec_plug_attr_is_visible(struct kobject *kobj, struct attribute *attr, int n)
{ … }
static const struct attribute_group typec_plug_group = …;
static const struct attribute_group *typec_plug_groups[] = …;
const struct device_type typec_plug_dev_type = …;
int typec_plug_set_num_altmodes(struct typec_plug *plug, int num_altmodes)
{ … }
EXPORT_SYMBOL_GPL(…);
struct typec_altmode *
typec_plug_register_altmode(struct typec_plug *plug,
const struct typec_altmode_desc *desc)
{ … }
EXPORT_SYMBOL_GPL(…);
struct typec_plug *typec_register_plug(struct typec_cable *cable,
struct typec_plug_desc *desc)
{ … }
EXPORT_SYMBOL_GPL(…);
void typec_unregister_plug(struct typec_plug *plug)
{ … }
EXPORT_SYMBOL_GPL(…);
static const char * const typec_plug_types[] = …;
static ssize_t plug_type_show(struct device *dev,
struct device_attribute *attr, char *buf)
{ … }
static DEVICE_ATTR_RO(plug_type);
static struct attribute *typec_cable_attrs[] = …;
ATTRIBUTE_GROUPS(…);
static void typec_cable_release(struct device *dev)
{ … }
const struct device_type typec_cable_dev_type = …;
static int cable_match(struct device *dev, void *data)
{ … }
struct typec_cable *typec_cable_get(struct typec_port *port)
{ … }
EXPORT_SYMBOL_GPL(…);
void typec_cable_put(struct typec_cable *cable)
{ … }
EXPORT_SYMBOL_GPL(…);
int typec_cable_is_active(struct typec_cable *cable)
{ … }
EXPORT_SYMBOL_GPL(…);
int typec_cable_set_identity(struct typec_cable *cable)
{ … }
EXPORT_SYMBOL_GPL(…);
struct typec_cable *typec_register_cable(struct typec_port *port,
struct typec_cable_desc *desc)
{ … }
EXPORT_SYMBOL_GPL(…);
void typec_unregister_cable(struct typec_cable *cable)
{ … }
EXPORT_SYMBOL_GPL(…);
int typec_port_set_usb_power_delivery(struct typec_port *port, struct usb_power_delivery *pd)
{ … }
EXPORT_SYMBOL_GPL(…);
static ssize_t select_usb_power_delivery_store(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t size)
{ … }
static ssize_t select_usb_power_delivery_show(struct device *dev,
struct device_attribute *attr, char *buf)
{ … }
static DEVICE_ATTR_RW(select_usb_power_delivery);
static struct attribute *port_attrs[] = …;
static umode_t port_attr_is_visible(struct kobject *kobj, struct attribute *attr, int n)
{ … }
static const struct attribute_group pd_group = …;
static const char * const typec_orientations[] = …;
static const char * const typec_roles[] = …;
static const char * const typec_data_roles[] = …;
static const char * const typec_port_power_roles[] = …;
static const char * const typec_port_data_roles[] = …;
static const char * const typec_port_types_drp[] = …;
static ssize_t
preferred_role_store(struct device *dev, struct device_attribute *attr,
const char *buf, size_t size)
{ … }
static ssize_t
preferred_role_show(struct device *dev, struct device_attribute *attr,
char *buf)
{ … }
static DEVICE_ATTR_RW(preferred_role);
static ssize_t data_role_store(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t size)
{ … }
static ssize_t data_role_show(struct device *dev,
struct device_attribute *attr, char *buf)
{ … }
static DEVICE_ATTR_RW(data_role);
static ssize_t power_role_store(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t size)
{ … }
static ssize_t power_role_show(struct device *dev,
struct device_attribute *attr, char *buf)
{ … }
static DEVICE_ATTR_RW(power_role);
static ssize_t
port_type_store(struct device *dev, struct device_attribute *attr,
const char *buf, size_t size)
{ … }
static ssize_t
port_type_show(struct device *dev, struct device_attribute *attr,
char *buf)
{ … }
static DEVICE_ATTR_RW(port_type);
static const char * const typec_pwr_opmodes[] = …;
static ssize_t power_operation_mode_show(struct device *dev,
struct device_attribute *attr,
char *buf)
{ … }
static DEVICE_ATTR_RO(power_operation_mode);
static ssize_t vconn_source_store(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t size)
{ … }
static ssize_t vconn_source_show(struct device *dev,
struct device_attribute *attr, char *buf)
{ … }
static DEVICE_ATTR_RW(vconn_source);
static ssize_t supported_accessory_modes_show(struct device *dev,
struct device_attribute *attr,
char *buf)
{ … }
static DEVICE_ATTR_RO(supported_accessory_modes);
static ssize_t usb_typec_revision_show(struct device *dev,
struct device_attribute *attr,
char *buf)
{ … }
static DEVICE_ATTR_RO(usb_typec_revision);
static ssize_t usb_power_delivery_revision_show(struct device *dev,
struct device_attribute *attr,
char *buf)
{ … }
static ssize_t orientation_show(struct device *dev,
struct device_attribute *attr,
char *buf)
{ … }
static DEVICE_ATTR_RO(orientation);
static struct attribute *typec_attrs[] = …;
static umode_t typec_attr_is_visible(struct kobject *kobj,
struct attribute *attr, int n)
{ … }
static const struct attribute_group typec_group = …;
static const struct attribute_group *typec_groups[] = …;
static int typec_uevent(const struct device *dev, struct kobj_uevent_env *env)
{ … }
static void typec_release(struct device *dev)
{ … }
const struct device_type typec_port_dev_type = …;
static int partner_match(struct device *dev, void *data)
{ … }
static struct typec_partner *typec_get_partner(struct typec_port *port)
{ … }
static void typec_partner_attach(struct typec_connector *con, struct device *dev)
{ … }
static void typec_partner_deattach(struct typec_connector *con, struct device *dev)
{ … }
void typec_set_data_role(struct typec_port *port, enum typec_data_role role)
{ … }
EXPORT_SYMBOL_GPL(…);
void typec_set_pwr_role(struct typec_port *port, enum typec_role role)
{ … }
EXPORT_SYMBOL_GPL(…);
void typec_set_vconn_role(struct typec_port *port, enum typec_role role)
{ … }
EXPORT_SYMBOL_GPL(…);
void typec_set_pwr_opmode(struct typec_port *port,
enum typec_pwr_opmode opmode)
{ … }
EXPORT_SYMBOL_GPL(…);
int typec_find_pwr_opmode(const char *name)
{ … }
EXPORT_SYMBOL_GPL(…);
int typec_find_orientation(const char *name)
{ … }
EXPORT_SYMBOL_GPL(…);
int typec_find_port_power_role(const char *name)
{ … }
EXPORT_SYMBOL_GPL(…);
int typec_find_power_role(const char *name)
{ … }
EXPORT_SYMBOL_GPL(…);
int typec_find_port_data_role(const char *name)
{ … }
EXPORT_SYMBOL_GPL(…);
int typec_set_orientation(struct typec_port *port,
enum typec_orientation orientation)
{ … }
EXPORT_SYMBOL_GPL(…);
enum typec_orientation typec_get_orientation(struct typec_port *port)
{ … }
EXPORT_SYMBOL_GPL(…);
int typec_set_mode(struct typec_port *port, int mode)
{ … }
EXPORT_SYMBOL_GPL(…);
int typec_get_negotiated_svdm_version(struct typec_port *port)
{ … }
EXPORT_SYMBOL_GPL(…);
int typec_get_cable_svdm_version(struct typec_port *port)
{ … }
EXPORT_SYMBOL_GPL(…);
void typec_cable_set_svdm_version(struct typec_cable *cable, enum usb_pd_svdm_ver svdm_version)
{ … }
EXPORT_SYMBOL_GPL(…);
void *typec_get_drvdata(struct typec_port *port)
{ … }
EXPORT_SYMBOL_GPL(…);
int typec_get_fw_cap(struct typec_capability *cap,
struct fwnode_handle *fwnode)
{ … }
EXPORT_SYMBOL_GPL(…);
struct typec_altmode *
typec_port_register_altmode(struct typec_port *port,
const struct typec_altmode_desc *desc)
{ … }
EXPORT_SYMBOL_GPL(…);
void typec_port_register_altmodes(struct typec_port *port,
const struct typec_altmode_ops *ops, void *drvdata,
struct typec_altmode **altmodes, size_t n)
{ … }
EXPORT_SYMBOL_GPL(…);
void typec_port_register_cable_ops(struct typec_altmode **altmodes, int max_altmodes,
const struct typec_cable_ops *ops)
{ … }
EXPORT_SYMBOL_GPL(…);
struct typec_port *typec_register_port(struct device *parent,
const struct typec_capability *cap)
{ … }
EXPORT_SYMBOL_GPL(…);
void typec_unregister_port(struct typec_port *port)
{ … }
EXPORT_SYMBOL_GPL(…);
static int __init typec_init(void)
{ … }
subsys_initcall(typec_init);
static void __exit typec_exit(void)
{ … }
module_exit(typec_exit);
MODULE_AUTHOR(…) …;
MODULE_LICENSE(…) …;
MODULE_DESCRIPTION(…) …;