Linux Audio

Check our new training course

Loading...
Note: File does not exist in v3.1.
  1/* SPDX-License-Identifier: GPL-2.0 */
  2
  3#ifndef __USB_TYPEC_CLASS__
  4#define __USB_TYPEC_CLASS__
  5
  6#include <linux/device.h>
  7#include <linux/usb/typec.h>
  8
  9struct typec_mux;
 10struct typec_switch;
 11struct usb_device;
 12
 13struct typec_plug {
 14	struct device			dev;
 15	enum typec_plug_index		index;
 16	struct ida			mode_ids;
 17	int				num_altmodes;
 18};
 19
 20struct typec_cable {
 21	struct device			dev;
 22	enum typec_plug_type		type;
 23	struct usb_pd_identity		*identity;
 24	unsigned int			active:1;
 25	u16				pd_revision; /* 0300H = "3.0" */
 26	enum usb_pd_svdm_ver		svdm_version;
 27};
 28
 29struct typec_partner {
 30	struct device			dev;
 31	unsigned int			usb_pd:1;
 32	struct usb_pd_identity		*identity;
 33	enum typec_accessory		accessory;
 34	struct ida			mode_ids;
 35	int				num_altmodes;
 36	u16				pd_revision; /* 0300H = "3.0" */
 37	enum usb_pd_svdm_ver		svdm_version;
 38	enum usb_mode			usb_mode;
 39	u8				usb_capability;
 40
 41	struct usb_power_delivery	*pd;
 42
 43	void (*attach)(struct typec_partner *partner, struct device *dev);
 44	void (*deattach)(struct typec_partner *partner, struct device *dev);
 45};
 46
 47struct typec_port {
 48	unsigned int			id;
 49	struct device			dev;
 50	struct ida			mode_ids;
 51
 52	struct usb_power_delivery	*pd;
 53
 54	int				prefer_role;
 55	enum typec_data_role		data_role;
 56	enum typec_role			pwr_role;
 57	enum typec_role			vconn_role;
 58	enum typec_pwr_opmode		pwr_opmode;
 59	enum typec_port_type		port_type;
 60	enum usb_mode			usb_mode;
 61	struct mutex			port_type_lock;
 62
 63	enum typec_orientation		orientation;
 64	struct typec_switch		*sw;
 65	struct typec_mux		*mux;
 66	struct typec_retimer		*retimer;
 67
 68	const struct typec_capability	*cap;
 69	const struct typec_operations   *ops;
 70
 71	struct typec_connector		con;
 72
 73	/*
 74	 * REVISIT: Only USB devices for now. If there are others, these need to
 75	 * be converted into a list.
 76	 *
 77	 * NOTE: These may be registered first before the typec_partner, so they
 78	 * will always have to be kept here instead of struct typec_partner.
 79	 */
 80	struct device			*usb2_dev;
 81	struct device			*usb3_dev;
 82};
 83
 84#define to_typec_port(_dev_) container_of(_dev_, struct typec_port, dev)
 85#define to_typec_plug(_dev_) container_of(_dev_, struct typec_plug, dev)
 86#define to_typec_cable(_dev_) container_of(_dev_, struct typec_cable, dev)
 87#define to_typec_partner(_dev_) container_of(_dev_, struct typec_partner, dev)
 88
 89extern const struct device_type typec_partner_dev_type;
 90extern const struct device_type typec_cable_dev_type;
 91extern const struct device_type typec_plug_dev_type;
 92extern const struct device_type typec_port_dev_type;
 93
 94#define is_typec_partner(dev) ((dev)->type == &typec_partner_dev_type)
 95#define is_typec_cable(dev) ((dev)->type == &typec_cable_dev_type)
 96#define is_typec_plug(dev) ((dev)->type == &typec_plug_dev_type)
 97#define is_typec_port(dev) ((dev)->type == &typec_port_dev_type)
 98
 99extern const struct class typec_mux_class;
100extern const struct class retimer_class;
101extern const struct class typec_class;
102
103#if defined(CONFIG_ACPI)
104int typec_link_ports(struct typec_port *connector);
105void typec_unlink_ports(struct typec_port *connector);
106#else
107static inline int typec_link_ports(struct typec_port *connector) { return 0; }
108static inline void typec_unlink_ports(struct typec_port *connector) { }
109#endif
110
111#endif /* __USB_TYPEC_CLASS__ */