aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/usb
diff options
context:
space:
mode:
authorHeikki Krogerus <heikki.krogerus@linux.intel.com>2018-03-20 08:57:03 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2018-03-22 08:40:10 -0400
commitbdecb33af34f79cbfbb656661210f77c8b8b5b5f (patch)
tree057621e106f12ad7de132ebc5064c255f67a19c4 /include/linux/usb
parentf2d9b66d84f3ff5ea3aff111e6a403e04fa8bf37 (diff)
usb: typec: API for controlling USB Type-C Multiplexers
USB Type-C connectors consist of various muxes and switches that route the pins on the connector to the right locations. The USB Type-C drivers need to be able to control the muxes, as they are the ones that know things like the cable plug orientation, and the current mode that was negotiated with the partner. This introduces a small API for registering and controlling cable plug orientation switches, and separate small API for registering and controlling pin multiplexer/demultiplexer switches that are needed with Accessory/Alternate Modes. Reviewed-by: Hans de Goede <hdegoede@redhat.com> Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com> Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'include/linux/usb')
-rw-r--r--include/linux/usb/typec.h14
-rw-r--r--include/linux/usb/typec_mux.h55
2 files changed, 69 insertions, 0 deletions
diff --git a/include/linux/usb/typec.h b/include/linux/usb/typec.h
index 0d44ce6af08f..2408e5c2ed91 100644
--- a/include/linux/usb/typec.h
+++ b/include/linux/usb/typec.h
@@ -60,6 +60,12 @@ enum typec_accessory {
60 60
61#define TYPEC_MAX_ACCESSORY 3 61#define TYPEC_MAX_ACCESSORY 3
62 62
63enum typec_orientation {
64 TYPEC_ORIENTATION_NONE,
65 TYPEC_ORIENTATION_NORMAL,
66 TYPEC_ORIENTATION_REVERSE,
67};
68
63/* 69/*
64 * struct usb_pd_identity - USB Power Delivery identity data 70 * struct usb_pd_identity - USB Power Delivery identity data
65 * @id_header: ID Header VDO 71 * @id_header: ID Header VDO
@@ -185,6 +191,8 @@ struct typec_partner_desc {
185 * @pd_revision: USB Power Delivery Specification revision if supported 191 * @pd_revision: USB Power Delivery Specification revision if supported
186 * @prefer_role: Initial role preference 192 * @prefer_role: Initial role preference
187 * @accessory: Supported Accessory Modes 193 * @accessory: Supported Accessory Modes
194 * @sw: Cable plug orientation switch
195 * @mux: Multiplexer switch for Alternate/Accessory Modes
188 * @fwnode: Optional fwnode of the port 196 * @fwnode: Optional fwnode of the port
189 * @try_role: Set data role preference for DRP port 197 * @try_role: Set data role preference for DRP port
190 * @dr_set: Set Data Role 198 * @dr_set: Set Data Role
@@ -202,6 +210,8 @@ struct typec_capability {
202 int prefer_role; 210 int prefer_role;
203 enum typec_accessory accessory[TYPEC_MAX_ACCESSORY]; 211 enum typec_accessory accessory[TYPEC_MAX_ACCESSORY];
204 212
213 struct typec_switch *sw;
214 struct typec_mux *mux;
205 struct fwnode_handle *fwnode; 215 struct fwnode_handle *fwnode;
206 216
207 int (*try_role)(const struct typec_capability *, 217 int (*try_role)(const struct typec_capability *,
@@ -245,4 +255,8 @@ void typec_set_pwr_role(struct typec_port *port, enum typec_role role);
245void typec_set_vconn_role(struct typec_port *port, enum typec_role role); 255void typec_set_vconn_role(struct typec_port *port, enum typec_role role);
246void typec_set_pwr_opmode(struct typec_port *port, enum typec_pwr_opmode mode); 256void typec_set_pwr_opmode(struct typec_port *port, enum typec_pwr_opmode mode);
247 257
258int typec_set_orientation(struct typec_port *port,
259 enum typec_orientation orientation);
260int typec_set_mode(struct typec_port *port, int mode);
261
248#endif /* __LINUX_USB_TYPEC_H */ 262#endif /* __LINUX_USB_TYPEC_H */
diff --git a/include/linux/usb/typec_mux.h b/include/linux/usb/typec_mux.h
new file mode 100644
index 000000000000..12c1b057834b
--- /dev/null
+++ b/include/linux/usb/typec_mux.h
@@ -0,0 +1,55 @@
1// SPDX-License-Identifier: GPL-2.0
2
3#ifndef __USB_TYPEC_MUX
4#define __USB_TYPEC_MUX
5
6#include <linux/list.h>
7#include <linux/usb/typec.h>
8
9struct device;
10
11/**
12 * struct typec_switch - USB Type-C cable orientation switch
13 * @dev: Switch device
14 * @entry: List entry
15 * @set: Callback to the driver for setting the orientation
16 *
17 * USB Type-C pin flipper switch routing the correct data pairs from the
18 * connector to the USB controller depending on the orientation of the cable
19 * plug.
20 */
21struct typec_switch {
22 struct device *dev;
23 struct list_head entry;
24
25 int (*set)(struct typec_switch *sw, enum typec_orientation orientation);
26};
27
28/**
29 * struct typec_switch - USB Type-C connector pin mux
30 * @dev: Mux device
31 * @entry: List entry
32 * @set: Callback to the driver for setting the state of the mux
33 *
34 * Pin Multiplexer/DeMultiplexer switch routing the USB Type-C connector pins to
35 * different components depending on the requested mode of operation. Used with
36 * Accessory/Alternate modes.
37 */
38struct typec_mux {
39 struct device *dev;
40 struct list_head entry;
41
42 int (*set)(struct typec_mux *mux, int state);
43};
44
45struct typec_switch *typec_switch_get(struct device *dev);
46void typec_switch_put(struct typec_switch *sw);
47int typec_switch_register(struct typec_switch *sw);
48void typec_switch_unregister(struct typec_switch *sw);
49
50struct typec_mux *typec_mux_get(struct device *dev);
51void typec_mux_put(struct typec_mux *mux);
52int typec_mux_register(struct typec_mux *mux);
53void typec_mux_unregister(struct typec_mux *mux);
54
55#endif /* __USB_TYPEC_MUX */