Skip to contentSkip to conversation

USB Type-C device-connection, mux and switch support

PATCH Superseded Hans de Goede 4 participants 44 messages Feb 16, 2018 – Feb 25, 2018

Subsystems (12)

v1 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#0 lore raw

cover USB Type-C device-connection, mux and switch support

Hi All,

Some devices with an USB Type-C connector have a bunch of muxes behind that connector which need to be controlled by the kernel (rather then having them controlled by firmware as on most devices).

Quite a while back I submitted a patch-series to tie together these muxes and the Type-C Port Manager (tcpm) code, using the then new drivers/mux framework. But the way I used the mux framework went against what it was designed for, so in the end that series got nowhere.

Heikki Krogerus from Intel, who maintains the USB TYPEC subsystem, has recently been working on solving the same problem for some boards he is doing hardware-enablement for.

Heikki has come up with a number of infrastructure patches for this. The first one is a new device-connection framework. This solves the problem of describing non bus device-links on x86 in what in my experience with this problematic area is a really nice simple, clean and *generic* way. This could for example in the near future also replace the custom lookup code in the pwm subsys and the custom pwm_add_table() / pwm_remove_table() functions.

The other 3 patches add a framework for the different type of Type-C / USB "muxes".

Heikki and I have gone through a number of iterations of these patches together and we believe these are now ready for merging. Since merging infrastructure patches without users is not done and Heikki's own use-case for these is not yet ready for merging, the rest of this series consists of patches by me to make the Type-C connector found on some Cherry Trail devices (finally) be able to actually work as an USB port and not just a charge port.

The last patch uses the new usb-role-switch framework to also do proper devcie / host switching on CHT devices with a USB micro AB connector. This is also a big feature for CHT users, because before this they had to do a reboot to get an OTG-host cable recognized (on some devices).

Part of this series is an usb-role-switch driver for the role-switch found inside the xhci controller on e.g. CHT devices, this is currently implemented as the generic xhci controller instantiating a platform child-device for this, since this really is a separate chunk of HW which happens to sit in the XHCI mmio space. This approach may not be universally liked, given that in this new series the role-switch driver is much smaller and does not have any external deps anymore we could just integrate it into the xhci code if that is preferred.

About merging this series (once everything is reviewed, etc.), there are quite some interdependencies in it esp. a lot of the patches depend on the first patch. Luckily patches 1-10 all apply to subsystems which are maintained by Greg (most to the USB subsys). Which just leaves patches 11 and 12 once 1-10 are merged. Greg, can you create an immutable branch for the platform/x86 and extcon maintainers to merge once this is done?

Regards,

Hans

#1 lore raw

PATCH 1/12 drivers: base: Unified device connection lookup

From: Heikki Krogerus <[email protected]>

Several frameworks - clk, gpio, phy, pmw, etc. - maintain lookup tables for describing connections and provide custom API for handling them. This introduces a single generic lookup table and API for the connections.

The motivation for this commit is centralizing the connection lookup, but the goal is to ultimately extract the connection descriptions also from firmware by using the fwnode_graph_* functions and other mechanisms that are available.

---
 Documentation/driver-api/device_connection.rst |  43 ++++++++
 drivers/base/Makefile                          |   3 +-
 drivers/base/devcon.c                          | 139 +++++++++++++++++++++++++
 include/linux/connection.h                     |  33 ++++++
 4 files changed, 217 insertions(+), 1 deletion(-)
 create mode 100644 Documentation/driver-api/device_connection.rst
 create mode 100644 drivers/base/devcon.c
 create mode 100644 include/linux/connection.h
Documentation/driver-api/device_connection.rst new file +43 -0
new file mode 100644
index 000000000000..d52604448356
@@ -0,0 +1,43 @@
+==================
+Device connections
+==================
+
+Introduction
+------------
+
+Devices have often connections to other devices that are out side of the direct
+child/parent relationship. A serial or network communication controller, which
+could be a PCI device, may need to be able to get a reference to its PHY
+component, which could be attached to for example the I2C bus. Some device
+drivers need to be able to control the clocks or the GPIOs for their devices,
+and so on.
+
+Device connections are generic descriptions of any type of connection between
+two separate devices.
+
+Device connections alone do not create a dependency between the two devices.
+They are only descriptions which are not tied to either of devices directly.
+A dependency between the two devices exists only if one of the two endpoint
+devices requests a reference to the other. The descriptions themselves can be
+defined in firmware (not yet supported) or they can be build-in.
+
+Usage
+-----
+
+Device connections should exist before device ``->probe`` callback is called for
+either endpoint devices in the description. If the connections are defined in
+firmware, this is not a problem. It should be considered if the connection
+descriptions are "build-in", and need to be added separately.
+
+The connection description consist of the names of the two devices with the
+connection, i.e. the endpoints, and unique identifier for the connection which
+is needed if there are multiple connections between the two devices.
+
+After a descriptions exist, the devices in it can request reference to the other
+endpoint device, or they can request the description itself.
+
+API
+---
+
+.. kernel-doc:: drivers/base/devcon.c
+   : functions: __device_find_connection device_find_connection add_device_connection remove_device_connection
drivers/base/Makefile +2 -1
index e32a52490051..12a7f64d35a9 100644
@@ -5,7 +5,8 @@ obj-y			:= component.o core.o bus.o dd.o syscore.o \
 			   driver.o class.o platform.o \
 			   cpu.o firmware.o init.o map.o devres.o \
 			   attribute_container.o transport_class.o \
-			   topology.o container.o property.o cacheinfo.o
+			   topology.o container.o property.o cacheinfo.o \
+			   devcon.o
 obj-$(CONFIG_DEVTMPFS)	+= devtmpfs.o
 obj-$(CONFIG_DMA_CMA) += dma-contiguous.o
 obj-y			+= power/
drivers/base/devcon.c new file +139 -0

139 lines not on this page · raw message

include/linux/connection.h new file +33 -0
new file mode 100644
index 000000000000..1aed6f3d3d6f
@@ -0,0 +1,33 @@
+// SPDX-License-Identifier: GPL-2.0
+
+#ifndef _LINUX_CONNECTION_H_
+#define _LINUX_CONNECTION_H_
+
+#include <linux/list.h>
+
+struct device;
+
+/**
+ * struct devcon - Device Connection Descriptor
+ * @endpoint: The names of the two devices connected together
+ * @id: Unique identifier for the connection
+ */
+struct devcon {
+	const char		*endpoint[2];
+	const char		*id;
+	struct list_head	list;
+};
+
+void *__device_find_connection(struct device *dev, const char *con_id,
+			       void *data,
+			       void *(*match)(struct devcon *con, int ep,
+					      void *data));
+
+struct device *device_find_connection(struct device *dev, const char *con_id);
+
+#define DEVCON(_ep0, _ep1, _id)		{ { _ep0, _ep1 }, _id, }
+
+void add_device_connection(struct devcon *con);
+void remove_device_connection(struct devcon *con);
+
+#endif /* _LINUX_CONNECTION_H_ */
#2 lore raw

Re: [PATCH 01/12] drivers: base: Unified device connection lookup

Quoted 13 lines · Hans de Goede

From: Heikki Krogerus <[email protected]>

Several frameworks - clk, gpio, phy, pmw, etc. - maintain lookup tables for describing connections and provide custom API for handling them. This introduces a single generic lookup table and API for the connections.

The motivation for this commit is centralizing the connection lookup, but the goal is to ultimately extract the connection descriptions also from firmware by using the fwnode_graph_* functions and other mechanisms that are available.

drivers/base/devcon.c line 29

Quoted 5 lines
drivers/base/devcon.c new file +4 -0
+void *__device_find_connection(struct device *dev, const char *con_id,
 
+                              void *data,
+                              void *(*match)(struct devcon *con, int ep,
+                                             void *data))

Perhaps swap them, since data is dependent parameter to match.

And put match function on one line disregard 80 character limit?

Quoted 6 lines
include/linux/connection.h new file +6 -0
+/**
+ * struct devcon - Device Connection Descriptor
+ * @endpoint: The names of the two devices connected together
+ * @id: Unique identifier for the connection
+ */
+struct devcon {

include/linux/connection.h line 24

Quoted 10 lines
include/linux/connection.h new file +9 -0
+       const char              *endpoint[2];
+       const char              *id;
+       struct list_head        list;
+};
+
 
+void *__device_find_connection(struct device *dev, const char *con_id,
+                              void *data,
+                              void *(*match)(struct devcon *con, int ep,
+                                             void *data));

Ditto.

include/linux/connection.h line 28

Quoted 4 lines
include/linux/connection.h new file +4 -0
+
+struct device *device_find_connection(struct device *dev, const char *con_id);
+
+#define DEVCON(_ep0, _ep1, _id)                { { _ep0, _ep1 }, _id, }

Please use (struct devcon) here to make it possible to do like

struct devcon foo;

foo = DEVCON(...);

#3 lore raw

Re: [PATCH 01/12] drivers: base: Unified device connection lookup

Hi,

Quoted 14 lines · Andy Shevchenko
Quoted 12 lines · Hans de Goede

From: Heikki Krogerus <[email protected]>

Several frameworks - clk, gpio, phy, pmw, etc. - maintain lookup tables for describing connections and provide custom API for handling them. This introduces a single generic lookup table and API for the connections.

The motivation for this commit is centralizing the connection lookup, but the goal is to ultimately extract the connection descriptions also from firmware by using the fwnode_graph_* functions and other mechanisms that are available.

Quoted 7 lines

drivers/base/devcon.c line 29

Quoted 5 lines
drivers/base/devcon.c new file +4 -0
+void *__device_find_connection(struct device *dev, const char *con_id,
 
+                              void *data,
+                              void *(*match)(struct devcon *con, int ep,
+                                             void *data))

Perhaps swap them, since data is dependent parameter to match.

The pattern of having the data before the callback function is not unheard of in the kernel. Changing this now feels like needless churn, but if there is a strong preference for this then we can fix this for v2.

Heikki, do you want me to take care of minor changes like this for v2?

Quoted 1 line

And put match function on one line disregard 80 character limit?

I think that breaking the 80 chars limit here would make sense, yes. Any other opinions on this?

Quoted 20 lines
Quoted 7 lines
include/linux/connection.h new file +6 -0
+/**
+ * struct devcon - Device Connection Descriptor
+ * @endpoint: The names of the two devices connected together
+ * @id: Unique identifier for the connection
+ */
+struct devcon {

include/linux/connection.h line 24

Quoted 10 lines
include/linux/connection.h new file +9 -0
+       const char              *endpoint[2];
+       const char              *id;
+       struct list_head        list;
+};
+
 
+void *__device_find_connection(struct device *dev, const char *con_id,
+                              void *data,
+                              void *(*match)(struct devcon *con, int ep,
+                                             void *data));

Ditto.

Quoted 9 lines

include/linux/connection.h line 28

Quoted 4 lines
include/linux/connection.h new file +4 -0
+
+struct device *device_find_connection(struct device *dev, const char *con_id);
+
+#define DEVCON(_ep0, _ep1, _id)                { { _ep0, _ep1 }, _id, }

Please use (struct devcon) here to make it possible to do like

struct devcon foo;

Quoted 1 line

foo = DEVCON(...);

Good idea, will fix for v2.

Regards,

Hans
---
To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

maintainer
#4 lore raw

Re: [PATCH 01/12] drivers: base: Unified device connection lookup

Quoted 23 lines · Hans de Goede

Hi,

Quoted 20 lines · Andy Shevchenko
Quoted 18 lines · Hans de Goede

From: Heikki Krogerus <[email protected]>

Several frameworks - clk, gpio, phy, pmw, etc. - maintain lookup tables for describing connections and provide custom API for handling them. This introduces a single generic lookup table and API for the connections.

The motivation for this commit is centralizing the connection lookup, but the goal is to ultimately extract the connection descriptions also from firmware by using the fwnode_graph_* functions and other mechanisms that are available.

drivers/base/devcon.c new file +4 -0
+void *__device_find_connection(struct device *dev, const char *con_id,
 
+                              void *data,
+                              void *(*match)(struct devcon *con, int ep,
+                                             void *data))
Quoted 8 lines
Quoted 1 line

Perhaps swap them, since data is dependent parameter to match.

The pattern of having the data before the callback function is not unheard of in the kernel. Changing this now feels like needless churn, but if there is a strong preference for this then we can fix this for v2.

Heikki, do you want me to take care of minor changes like this for v2?

Yes, please do if you don't mind. I would appreciate it.

I'll be on vacation next week.

Thanks,

#5 lore raw

PATCH 2/12 usb: typec: Start using ERR_PTR

In reply to Hans de Goede

From: Heikki Krogerus <[email protected]>

In order to allow the USB Type-C Class driver take care of things like muxes and other possible dependencies for the port drivers, returning ERR_PTR instead of NULL from the registration functions in case of failure.

The reason for taking over control of the muxes for example is because handling them in the port drivers would be just boilerplate.

---
 drivers/usb/typec/tcpm.c      | 16 +++++++-------
 drivers/usb/typec/tps6598x.c  | 15 ++++++-------
 drivers/usb/typec/typec.c     | 49 +++++++++++++++++++------------------------
 drivers/usb/typec/ucsi/ucsi.c | 31 ++++++++++++++++-----------
 4 files changed, 58 insertions(+), 53 deletions(-)
drivers/usb/typec/tcpm.c +9 -7
index f4d563ee7690..7cd28b700a7f 100644
@@ -1044,7 +1044,7 @@ static int tcpm_pd_svdm(struct tcpm_port *port, const __le32 *payload, int cnt,
 		break;
 	case CMDT_RSP_ACK:
 		/* silently drop message if we are not connected */
-		if (!port->partner)
+		if (IS_ERR_OR_NULL(port->partner))
 			break;
 
 		switch (cmd) {
@@ -3743,8 +3743,8 @@ struct tcpm_port *tcpm_register_port(struct device *dev, struct tcpc_dev *tcpc)
 	port->port_type = tcpc->config->type;
 
 	port->typec_port = typec_register_port(port->dev, &port->typec_caps);
-	if (!port->typec_port) {
-		err = -ENOMEM;
+	if (IS_ERR(port->typec_port)) {
+		err = PTR_ERR(port->typec_port);
 		goto out_destroy_wq;
 	}
 
@@ -3753,15 +3753,17 @@ struct tcpm_port *tcpm_register_port(struct device *dev, struct tcpc_dev *tcpc)
 
 		i = 0;
 		while (paltmode->svid && i < ARRAY_SIZE(port->port_altmode)) {
-			port->port_altmode[i] =
-			  typec_port_register_altmode(port->typec_port,
-						      paltmode);
-			if (!port->port_altmode[i]) {
+			struct typec_altmode *alt;
+
+			alt = typec_port_register_altmode(port->typec_port,
+							  paltmode);
+			if (IS_ERR(alt)) {
 				tcpm_log(port,
 					 "%s: failed to register port alternate mode 0x%x",
 					 dev_name(dev), paltmode->svid);
 				break;
 			}
+			port->port_altmode[i] = alt;
 			i++;
 			paltmode++;
 		}
drivers/usb/typec/tps6598x.c +8 -7
index 2719f5d382f7..37a15c14a6c6 100644
@@ -158,15 +158,15 @@ static int tps6598x_connect(struct tps6598x *tps, u32 status)
 		desc.identity = &tps->partner_identity;
 	}
 
-	tps->partner = typec_register_partner(tps->port, &desc);
-	if (!tps->partner)
-		return -ENODEV;
-
 	typec_set_pwr_opmode(tps->port, mode);
 	typec_set_pwr_role(tps->port, TPS_STATUS_PORTROLE(status));
 	typec_set_vconn_role(tps->port, TPS_STATUS_VCONN(status));
 	typec_set_data_role(tps->port, TPS_STATUS_DATAROLE(status));
 
+	tps->partner = typec_register_partner(tps->port, &desc);
+	if (IS_ERR(tps->partner))
+		return PTR_ERR(tps->partner);
+
 	if (desc.identity)
 		typec_partner_set_identity(tps->partner);
 
@@ -175,7 +175,8 @@ static int tps6598x_connect(struct tps6598x *tps, u32 status)
 
 static void tps6598x_disconnect(struct tps6598x *tps, u32 status)
 {
-	typec_unregister_partner(tps->partner);
+	if (!IS_ERR(tps->partner))
+		typec_unregister_partner(tps->partner);
 	tps->partner = NULL;
 	typec_set_pwr_opmode(tps->port, TYPEC_PWR_MODE_USB);
 	typec_set_pwr_role(tps->port, TPS_STATUS_PORTROLE(status));
@@ -418,8 +419,8 @@ static int tps6598x_probe(struct i2c_client *client)
 	tps->typec_cap.prefer_role = TYPEC_NO_PREFERRED_ROLE;
 
 	tps->port = typec_register_port(&client->dev, &tps->typec_cap);
-	if (!tps->port)
-		return -ENODEV;
+	if (IS_ERR(tps->port))
+		return PTR_ERR(tps->port);
 
 	if (status & TPS_STATUS_PLUG_PRESENT) {
 		ret = tps6598x_connect(tps, status);
drivers/usb/typec/typec.c +22 -27

179 lines not on this page · raw message

drivers/usb/typec/ucsi/ucsi.c +19 -12
index 79046fe66426..69d544cfcd45 100644
@@ -260,38 +260,45 @@ static void ucsi_pwr_opmode_change(struct ucsi_connector *con)
 
 static int ucsi_register_partner(struct ucsi_connector *con)
 {
-	struct typec_partner_desc partner;
+	struct typec_partner_desc desc;
+	struct typec_partner *partner;
 
 	if (con->partner)
 		return 0;
 
-	memset(&partner, 0, sizeof(partner));
+	memset(&desc, 0, sizeof(desc));
 
 	switch (con->status.partner_type) {
 	case UCSI_CONSTAT_PARTNER_TYPE_DEBUG:
-		partner.accessory = TYPEC_ACCESSORY_DEBUG;
+		desc.accessory = TYPEC_ACCESSORY_DEBUG;
 		break;
 	case UCSI_CONSTAT_PARTNER_TYPE_AUDIO:
-		partner.accessory = TYPEC_ACCESSORY_AUDIO;
+		desc.accessory = TYPEC_ACCESSORY_AUDIO;
 		break;
 	default:
 		break;
 	}
 
-	partner.usb_pd = con->status.pwr_op_mode == UCSI_CONSTAT_PWR_OPMODE_PD;
+	desc.usb_pd = con->status.pwr_op_mode == UCSI_CONSTAT_PWR_OPMODE_PD;
 
-	con->partner = typec_register_partner(con->port, &partner);
-	if (!con->partner) {
-		dev_err(con->ucsi->dev, "con%d: failed to register partner\n",
-			con->num);
-		return -ENODEV;
+	partner = typec_register_partner(con->port, &desc);
+	if (IS_ERR(partner)) {
+		dev_err(con->ucsi->dev,
+			"con%d: failed to register partner (%ld)\n", con->num,
+			PTR_ERR(partner));
+		return PTR_ERR(partner);
 	}
 
+	con->partner = partner;
+
 	return 0;
 }
 
 static void ucsi_unregister_partner(struct ucsi_connector *con)
 {
+	if (!con->partner)
+		return;
+
 	typec_unregister_partner(con->partner);
 	con->partner = NULL;
 }
@@ -606,8 +613,8 @@ static int ucsi_register_port(struct ucsi *ucsi, int index)
 
 	/* Register the connector */
 	con->port = typec_register_port(ucsi->dev, cap);
-	if (!con->port)
-		return -ENODEV;
+	if (IS_ERR(con->port))
+		return PTR_ERR(con->port);
 
 	/* Get the status */
 	UCSI_CMD_GET_CONNECTOR_STATUS(ctrl, con->num);
#6 lore raw

Re: [PATCH 02/12] usb: typec: Start using ERR_PTR

Quoted 13 lines · Hans de Goede

From: Heikki Krogerus <[email protected]>

In order to allow the USB Type-C Class driver take care of things like muxes and other possible dependencies for the port drivers, returning ERR_PTR instead of NULL from the registration functions in case of failure.

The reason for taking over control of the muxes for example is because handling them in the port drivers would be just boilerplate.

void typec_unregister_altmode(struct typec_altmode *alt) {

drivers/usb/typec/typec.c typec_register_altmode(struct device *parent, · line 421

Quoted 4 lines
drivers/usb/typec/typec.c +1 -2
-       if (alt)
-               device_unregister(&alt->dev);
+       device_unregister(&alt->dev);
 }

But it's a pattern to guarantee that unregister type of functions are NULL (or ERR_PTR) aware.

drivers/usb/typec/typec.c EXPORT_SYMBOL_GPL(typec_register_partner); · line 560

Quoted 6 lines

void typec_unregister_partner(struct typec_partner *partner) {

drivers/usb/typec/typec.c +1 -2
-       if (partner)
-               device_unregister(&partner->dev);
+       device_unregister(&partner->dev);
 }

Ditto.

#7 lore raw

Re: [PATCH 02/12] usb: typec: Start using ERR_PTR

Hi,

Quoted 19 lines · Andy Shevchenko
Quoted 13 lines · Hans de Goede

From: Heikki Krogerus <[email protected]>

In order to allow the USB Type-C Class driver take care of things like muxes and other possible dependencies for the port drivers, returning ERR_PTR instead of NULL from the registration functions in case of failure.

The reason for taking over control of the muxes for example is because handling them in the port drivers would be just boilerplate.

  void typec_unregister_altmode(struct typec_altmode *alt)
  {

drivers/usb/typec/typec.c typec_register_altmode(struct device *parent, · line 421

Quoted 4 lines
drivers/usb/typec/typec.c +1 -2
-       if (alt)
-               device_unregister(&alt->dev);
+       device_unregister(&alt->dev);
  }
Quoted 2 lines

But it's a pattern to guarantee that unregister type of functions are NULL (or ERR_PTR) aware.

Agreed this needs an if (!IS_ERR_OR_NULL()), will fix for v2.

Regards,

Hans

Quoted 11 lines

drivers/usb/typec/typec.c EXPORT_SYMBOL_GPL(typec_register_partner); · line 560

Quoted 8 lines

  void typec_unregister_partner(struct typec_partner *partner)
  {
drivers/usb/typec/typec.c +1 -2
-       if (partner)
-               device_unregister(&partner->dev);
+       device_unregister(&partner->dev);
  }

Ditto.

---
To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#8 lore raw

PATCH 3/12 usb: typec: API for controlling USB Type-C Multiplexers

In reply to Hans de Goede

From: Heikki Krogerus <[email protected]>

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.

---
 Documentation/driver-api/usb/typec.rst |  73 +++++++++++--
 drivers/usb/typec/Makefile             |   1 +
 drivers/usb/typec/{typec.c => class.c} |  70 ++++++++++++
 drivers/usb/typec/mux.c                | 188 +++++++++++++++++++++++++++++++++
 include/linux/usb/typec.h              |  14 +++
 include/linux/usb/typec_mux.h          |  55 ++++++++++
 6 files changed, 390 insertions(+), 11 deletions(-)
 rename drivers/usb/typec/{typec.c => class.c} (95%)
 create mode 100644 drivers/usb/typec/mux.c
 create mode 100644 include/linux/usb/typec_mux.h
Documentation/driver-api/usb/typec.rst +62 -11
index 8a7249f2ff04..091e4def3a39 100644
@@ -61,7 +61,7 @@ Registering the ports
 The port drivers will describe every Type-C port they control with struct
 typec_capability data structure, and register them with the following API:
 
-.. kernel-doc:: drivers/usb/typec/typec.c
+.. kernel-doc:: drivers/usb/typec/class.c
    :functions: typec_register_port typec_unregister_port
 
 When registering the ports, the prefer_role member in struct typec_capability
@@ -80,7 +80,7 @@ typec_partner_desc. The class copies the details of the partner during
 registration. The class offers the following API for registering/unregistering
 partners.
 
-.. kernel-doc:: drivers/usb/typec/typec.c
+.. kernel-doc:: drivers/usb/typec/class.c
    :functions: typec_register_partner typec_unregister_partner
 
 The class will provide a handle to struct typec_partner if the registration was
@@ -92,7 +92,7 @@ should include handle to struct usb_pd_identity instance. The class will then
 create a sysfs directory for the identity under the partner device. The result
 of Discover Identity command can then be reported with the following API:
 
-.. kernel-doc:: drivers/usb/typec/typec.c
+.. kernel-doc:: drivers/usb/typec/class.c
    :functions: typec_partner_set_identity
 
 Registering Cables
@@ -113,7 +113,7 @@ typec_cable_desc and about a plug in struct typec_plug_desc. The class copies
 the details during registration. The class offers the following API for
 registering/unregistering cables and their plugs:
 
-.. kernel-doc:: drivers/usb/typec/typec.c
+.. kernel-doc:: drivers/usb/typec/class.c
    :functions: typec_register_cable typec_unregister_cable typec_register_plug typec_unregister_plug
 
 The class will provide a handle to struct typec_cable and struct typec_plug if
@@ -125,7 +125,7 @@ include handle to struct usb_pd_identity instance. The class will then create a
 sysfs directory for the identity under the cable device. The result of Discover
 Identity command can then be reported with the following API:
 
-.. kernel-doc:: drivers/usb/typec/typec.c
+.. kernel-doc:: drivers/usb/typec/class.c
    :functions: typec_cable_set_identity
 
 Notifications
@@ -135,7 +135,7 @@ When the partner has executed a role change, or when the default roles change
 during connection of a partner or cable, the port driver must use the following
 APIs to report it to the class:
 
-.. kernel-doc:: drivers/usb/typec/typec.c
+.. kernel-doc:: drivers/usb/typec/class.c
    :functions: typec_set_data_role typec_set_pwr_role typec_set_vconn_role typec_set_pwr_opmode
 
 Alternate Modes
@@ -150,7 +150,7 @@ and struct typec_altmode_desc which is a container for all the supported modes.
 Ports that support Alternate Modes need to register each SVID they support with
 the following API:
 
-.. kernel-doc:: drivers/usb/typec/typec.c
+.. kernel-doc:: drivers/usb/typec/class.c
    :functions: typec_port_register_altmode
 
 If a partner or cable plug provides a list of SVIDs as response to USB Power
@@ -159,12 +159,12 @@ registered.
 
 API for the partners:
 
-.. kernel-doc:: drivers/usb/typec/typec.c
+.. kernel-doc:: drivers/usb/typec/class.c
    :functions: typec_partner_register_altmode
 
 API for the Cable Plugs:
 
-.. kernel-doc:: drivers/usb/typec/typec.c
+.. kernel-doc:: drivers/usb/typec/class.c
    :functions: typec_plug_register_altmode
 
 So ports, partners and cable plugs will register the alternate modes with their
@@ -172,11 +172,62 @@ own functions, but the registration will always return a handle to struct
 typec_altmode on success, or NULL. The unregistration will happen with the same
 function:
 
-.. kernel-doc:: drivers/usb/typec/typec.c
+.. kernel-doc:: drivers/usb/typec/class.c
    :functions: typec_unregister_altmode
 
 If a partner or cable plug enters or exits a mode, the port driver needs to
 notify the class with the following API:
 
-.. kernel-doc:: drivers/usb/typec/typec.c
+.. kernel-doc:: drivers/usb/typec/class.c
    :functions: typec_altmode_update_active
+
+Multiplexer/DeMultiplexer Switches
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+USB Type-C connectors may have one or more mux/demux switches behind them. Since
+the plugs can be inserted right-side-up or upside-down, a switch is needed to
+route the correct data pairs from the connector to the USB controllers. If
+Alternate or Accessory Modes are supported, an other switch is needed that can
+route the pins on the connector to some other component besides USB. USB Type-C
+Connector Class supplies an API for registering those switches.
+
+.. kernel-doc:: drivers/usb/typec/mux.c
+   :functions: typec_switch_register typec_switch_unregister typec_mux_register typec_mux_unregister
+
+In most cases the same physical mux will handle both the orientation and mode.
+However, as the port drivers will be responsible of the orientation, and the
+alternate mode drivers of the mode, the two are always separated into their own
+logical components: "mux" for the mode and "switch" for the orientation.
+
+When a port is registered, USB Type-C Connector Class requests both the mux and
+the switch for the port. The drivers can then use the following API for
+controlling them:
+
+.. kernel-doc:: drivers/usb/typec/class.c
+   :functions: typec_set_orientation typec_set_mode
+
+If the connector is dual-role capable, there may also be a switch for the data
+role. USB Type-C Connector Class does not supply separate API for them. The
+port drivers can use USB Role Class API with those.
+
+Illustration of the muxes behind a connector that supports an alternate mode:
+
+                     ------------------------
+                     |       Connector      |
+                     ------------------------
+                            |         |
+                     ------------------------
+                      \     Orientation    /
+                       --------------------
+                                |
+                       --------------------
+                      /        Mode        \
+                     ------------------------
+                         /              \
+      ------------------------        --------------------
+      |       Alt Mode       |       /      USB Role      \
+      ------------------------      ------------------------
+                                         /            \
+                     ------------------------      ------------------------
+                     |       USB Host       |      |       USB Device     |
+                     ------------------------      ------------------------
drivers/usb/typec/Makefile +1 -0
index bb3138a6eaac..56b2e9516ec1 100644
@@ -1,5 +1,6 @@
 # SPDX-License-Identifier: GPL-2.0
 obj-$(CONFIG_TYPEC)		+= typec.o
+typec-y				:= class.o mux.o
 obj-$(CONFIG_TYPEC_TCPM)	+= tcpm.o
 obj-y				+= fusb302/
 obj-$(CONFIG_TYPEC_WCOVE)	+= typec_wcove.o
drivers/usb/typec/class.c renamed from drivers/usb/typec/typec.c +70 -0

112 lines not on this page · raw message

drivers/usb/typec/mux.c new file +188 -0

188 lines not on this page · raw message

include/linux/usb/typec.h +14 -0
index 0d44ce6af08f..2408e5c2ed91 100644
@@ -60,6 +60,12 @@ enum typec_accessory {
 
 #define TYPEC_MAX_ACCESSORY	3
 
+enum typec_orientation {
+	TYPEC_ORIENTATION_NONE,
+	TYPEC_ORIENTATION_NORMAL,
+	TYPEC_ORIENTATION_REVERSE,
+};
+
 /*
  * struct usb_pd_identity - USB Power Delivery identity data
  * @id_header: ID Header VDO
@@ -185,6 +191,8 @@ struct typec_partner_desc {
  * @pd_revision: USB Power Delivery Specification revision if supported
  * @prefer_role: Initial role preference
  * @accessory: Supported Accessory Modes
+ * @sw: Cable plug orientation switch
+ * @mux: Multiplexer switch for Alternate/Accessory Modes
  * @fwnode: Optional fwnode of the port
  * @try_role: Set data role preference for DRP port
  * @dr_set: Set Data Role
@@ -202,6 +210,8 @@ struct typec_capability {
 	int			prefer_role;
 	enum typec_accessory	accessory[TYPEC_MAX_ACCESSORY];
 
+	struct typec_switch	*sw;
+	struct typec_mux	*mux;
 	struct fwnode_handle	*fwnode;
 
 	int		(*try_role)(const struct typec_capability *,
@@ -245,4 +255,8 @@ void typec_set_pwr_role(struct typec_port *port, enum typec_role role);
 void typec_set_vconn_role(struct typec_port *port, enum typec_role role);
 void typec_set_pwr_opmode(struct typec_port *port, enum typec_pwr_opmode mode);
 
+int typec_set_orientation(struct typec_port *port,
+			  enum typec_orientation orientation);
+int typec_set_mode(struct typec_port *port, int mode);
+
 #endif /* __LINUX_USB_TYPEC_H */
include/linux/usb/typec_mux.h new file +55 -0

55 lines not on this page · raw message

#9 lore raw

Re: [PATCH 03/12] usb: typec: API for controlling USB Type-C Multiplexers

Quoted 12 lines · Hans de Goede

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.

drivers/usb/typec/mux.c line 49

Quoted 2 lines
drivers/usb/typec/mux.c new file +2 -0
+       sw = __device_find_connection(dev, "typec-switch", NULL,
+                                     typec_switch_match);

Perhaps one line? (even if it takes ~83 characters)

#10 lore raw

Re: [PATCH 03/12] usb: typec: API for controlling USB Type-C Multiplexers

Hi,

Quoted 13 lines · Andy Shevchenko
Quoted 11 lines · Hans de Goede

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.

Quoted 4 lines

drivers/usb/typec/mux.c line 49

Quoted 2 lines
drivers/usb/typec/mux.c new file +2 -0
+       sw = __device_find_connection(dev, "typec-switch", NULL,
+                                     typec_switch_match);

Perhaps one line? (even if it takes ~83 characters)

I'm not a fan of breaking the 80 chars limit when we can reasonably cleanly split a statement (such as here), so I'm keeping this as is for v2.

Regards,

Hans
---
To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#11 lore raw

PATCH 4/12 usb: common: Small class for USB role switches

In reply to Hans de Goede

From: Heikki Krogerus <[email protected]>

USB role switch is a device that can be used to choose the data role for USB connector. With dual-role capable USB controllers, the controller itself will be the switch, but on some platforms the USB host and device controllers are separate IPs and there is a mux between them and the connector. On those platforms the mux driver will need to register the switch.

With USB Type-C connectors, the host-to-device relationship is negotiated over the Configuration Channel (CC). That means the USB Type-C drivers need to be in control of the role switch. The class provides a simple API for the USB Type-C drivers for the control.

For other types of USB connectors (mainly microAB) the class provides user space control via sysfs attribute file that can be used to request role swapping from the switch.

---
 Documentation/ABI/testing/sysfs-class-usb_role |  21 ++
 drivers/usb/Kconfig                            |   3 +
 drivers/usb/common/Makefile                    |   1 +
 drivers/usb/common/roles.c                     | 305 +++++++++++++++++++++++++
 include/linux/usb/role.h                       |  51 +++++
 5 files changed, 381 insertions(+)
 create mode 100644 Documentation/ABI/testing/sysfs-class-usb_role
 create mode 100644 drivers/usb/common/roles.c
 create mode 100644 include/linux/usb/role.h
Documentation/ABI/testing/sysfs-class-usb_role new file +21 -0
new file mode 100644
index 000000000000..3b810a425a52
@@ -0,0 +1,21 @@
+What:		/sys/class/usb_role/
+Date:		Jan 2018
+Contact:	Heikki Krogerus <[email protected]>
+Description:
+		Place in sysfs for USB Role Switches. USB Role Switch is a
+		device that can select the data role (host or device) for USB
+		port.
+
+What:		/sys/class/usb_role/<switch>/role
+Date:		Jan 2018
+Contact:	Heikki Krogerus <[email protected]>
+Description:
+		The current role of the switch. This attribute can be used for
+		requesting role swapping with non-USB Type-C ports. With USB
+		Type-C ports, the ABI defined for USB Type-C connector class
+		must be used.
+
+		Valid values:
+		- none
+		- host
+		- device
drivers/usb/Kconfig +3 -0
index f699abab1787..a79198f5f1a6 100644
@@ -197,4 +197,7 @@ config USB_ULPI_BUS
 	  To compile this driver as a module, choose M here: the module will
 	  be called ulpi.
 
+config USB_ROLE_SWITCH
+	tristate
+
 endif # USB_SUPPORT
drivers/usb/common/Makefile +1 -0
index 0a7c45e85481..fb4d5ef4165c 100644
@@ -9,3 +9,4 @@ usb-common-$(CONFIG_USB_LED_TRIG) += led.o
 
 obj-$(CONFIG_USB_OTG_FSM) += usb-otg-fsm.o
 obj-$(CONFIG_USB_ULPI_BUS)	+= ulpi.o
+obj-$(CONFIG_USB_ROLE_SWITCH)	+= roles.o
drivers/usb/common/roles.c new file +305 -0

305 lines not on this page · raw message

include/linux/usb/role.h new file +51 -0

51 lines not on this page · raw message

#12 lore raw

Re: [PATCH 04/12] usb: common: Small class for USB role switches

Quoted 14 lines · Hans de Goede

USB role switch is a device that can be used to choose the data role for USB connector. With dual-role capable USB controllers, the controller itself will be the switch, but on some platforms the USB host and device controllers are separate IPs and there is a mux between them and the connector. On those platforms the mux driver will need to register the switch.

With USB Type-C connectors, the host-to-device relationship is negotiated over the Configuration Channel (CC). That means the USB Type-C drivers need to be in control of the role switch. The class provides a simple API for the USB Type-C drivers for the control.

Quoted 5 lines

For other types of USB connectors (mainly microAB) the class provides user space control via sysfs attribute file that can be used to request role swapping from the switch.

+static int __switch_match(struct device *dev, const void *name)

bool?

Quoted 17 lines
drivers/usb/common/roles.c new file +15 -0
+{
+       return !strcmp((const char *)name, dev_name(dev));
+}
 
 
+static ssize_t role_store(struct device *dev, struct device_attribute *attr,
+                         const char *buf, size_t size)
+{
+       struct usb_role_switch *sw = to_role_switch(dev);
+       int ret;
+
+       ret = sysfs_match_string(usb_roles, buf);
+       if (ret < 0) {
+               bool res;
+
+               /* Extra check if the user wants to disable the switch */
+               ret = kstrtobool(buf, &res);

drivers/usb/common/roles.c line 177

Quoted 10 lines
drivers/usb/common/roles.c new file +9 -0
+               if (ret || res)
+                       return -EINVAL;
+       }
+
 
+       ret = usb_role_switch_set_role(sw, ret);
+       if (!ret)
+               ret = size;
+
+       return ret;

Perhaps

ret = ...
if (ret)
return ret;

return size;

Quoted 9 lines
drivers/usb/common/roles.c new file +8 -0
+}
 
+struct usb_role_switch *
+usb_role_switch_register(struct device *parent,
+                        const struct usb_role_switch_desc *desc)
+{
+       struct usb_role_switch *sw;
+       int ret;
+

drivers/usb/common/roles.c line 266

Quoted 10 lines
drivers/usb/common/roles.c new file +9 -0
+       if (!desc || !desc->set)
+               return ERR_PTR(-EINVAL);
+
+       sw = kzalloc(sizeof(*sw), GFP_KERNEL);
+       if (!sw)
+               return ERR_PTR(-ENOMEM);
 
+       ret = device_register(&sw->dev);
+       if (ret) {
+               put_device(&sw->dev);

Memory leak?

drivers/usb/common/roles.c line 284

Quoted 11 lines
drivers/usb/common/roles.c new file +10 -0
+               return ERR_PTR(ret);
+       }
+
+       /* TODO: Symlinks for the host port and the device controller. */
+
+       return sw;
+}
 
+void usb_role_switch_unregister(struct usb_role_switch *sw)
+{
+       if (sw && !IS_ERR(sw))

!IS_ERR_OR_NULL() ?

Quoted 2 lines
(quoted diff) +2 -0
+               device_unregister(&sw->dev);
+}
maintainer
#13 lore raw

Re: [PATCH 04/12] usb: common: Small class for USB role switches

Quoted 16 lines · Andy Shevchenko
Quoted 14 lines · Hans de Goede

USB role switch is a device that can be used to choose the data role for USB connector. With dual-role capable USB controllers, the controller itself will be the switch, but on some platforms the USB host and device controllers are separate IPs and there is a mux between them and the connector. On those platforms the mux driver will need to register the switch.

With USB Type-C connectors, the host-to-device relationship is negotiated over the Configuration Channel (CC). That means the USB Type-C drivers need to be in control of the role switch. The class provides a simple API for the USB Type-C drivers for the control.

Quoted 7 lines
Quoted 5 lines

For other types of USB connectors (mainly microAB) the class provides user space control via sysfs attribute file that can be used to request role swapping from the switch.

+static int __switch_match(struct device *dev, const void *name)

bool?

No, this is callback for class_find_device(). It takes int so int it is.

Quoted 28 lines
Quoted 17 lines
drivers/usb/common/roles.c new file +15 -0
+{
+       return !strcmp((const char *)name, dev_name(dev));
+}
 
 
+static ssize_t role_store(struct device *dev, struct device_attribute *attr,
+                         const char *buf, size_t size)
+{
+       struct usb_role_switch *sw = to_role_switch(dev);
+       int ret;
+
+       ret = sysfs_match_string(usb_roles, buf);
+       if (ret < 0) {
+               bool res;
+
+               /* Extra check if the user wants to disable the switch */
+               ret = kstrtobool(buf, &res);

drivers/usb/common/roles.c line 177

Quoted 10 lines
drivers/usb/common/roles.c new file +9 -0
+               if (ret || res)
+                       return -EINVAL;
+       }
+
 
+       ret = usb_role_switch_set_role(sw, ret);
+       if (!ret)
+               ret = size;
+
+       return ret;
Quoted 7 lines

Perhaps

ret = ...
if (ret)
return ret;

return size;

Sure. Hans, can you clean-up this as well?

Quoted 16 lines
Quoted 15 lines
drivers/usb/common/roles.c new file +14 -0
+}
 
+struct usb_role_switch *
+usb_role_switch_register(struct device *parent,
+                        const struct usb_role_switch_desc *desc)
+{
+       struct usb_role_switch *sw;
+       int ret;
+
+       if (!desc || !desc->set)
+               return ERR_PTR(-EINVAL);
+
+       sw = kzalloc(sizeof(*sw), GFP_KERNEL);
+       if (!sw)
+               return ERR_PTR(-ENOMEM);
Quoted 5 lines

drivers/usb/common/roles.c line 266

Quoted 3 lines
drivers/usb/common/roles.c new file +3 -0
+       ret = device_register(&sw->dev);
+       if (ret) {
+               put_device(&sw->dev);

Memory leak?

No. Check usb_role_switch_release().

Thanks,

#14 lore raw

Re: [PATCH 04/12] usb: common: Small class for USB role switches

Hi,

Quoted 58 lines · Heikki Krogerus
Quoted 16 lines · Andy Shevchenko
Quoted 14 lines · Hans de Goede

USB role switch is a device that can be used to choose the data role for USB connector. With dual-role capable USB controllers, the controller itself will be the switch, but on some platforms the USB host and device controllers are separate IPs and there is a mux between them and the connector. On those platforms the mux driver will need to register the switch.

With USB Type-C connectors, the host-to-device relationship is negotiated over the Configuration Channel (CC). That means the USB Type-C drivers need to be in control of the role switch. The class provides a simple API for the USB Type-C drivers for the control.

Quoted 7 lines
Quoted 5 lines

For other types of USB connectors (mainly microAB) the class provides user space control via sysfs attribute file that can be used to request role swapping from the switch.

+static int __switch_match(struct device *dev, const void *name)

bool?

No, this is callback for class_find_device(). It takes int so int it is.

Quoted 30 lines
Quoted 17 lines
drivers/usb/common/roles.c new file +15 -0
+{
+       return !strcmp((const char *)name, dev_name(dev));
+}
 
 
+static ssize_t role_store(struct device *dev, struct device_attribute *attr,
+                         const char *buf, size_t size)
+{
+       struct usb_role_switch *sw = to_role_switch(dev);
+       int ret;
+
+       ret = sysfs_match_string(usb_roles, buf);
+       if (ret < 0) {
+               bool res;
+
+               /* Extra check if the user wants to disable the switch */
+               ret = kstrtobool(buf, &res);

drivers/usb/common/roles.c line 177

Quoted 10 lines
drivers/usb/common/roles.c new file +9 -0
+               if (ret || res)
+                       return -EINVAL;
+       }
+
 
+       ret = usb_role_switch_set_role(sw, ret);
+       if (!ret)
+               ret = size;
+
+       return ret;

Perhaps

Quoted 7 lines
Quoted 5 lines

ret = ...
if (ret)
return ret;

return size;

Sure. Hans, can you clean-up this as well?

Yes I can, not sure when exactly I will get around to this, but I will try to get out a v2 addressing all comments made this week.

And thank you for your reviews.

Andy, thank you for all the reviews too.

Regards,

Hans

Quoted 21 lines
Quoted 21 lines
Quoted 20 lines
drivers/usb/common/roles.c new file +17 -0
+}
 
+struct usb_role_switch *
+usb_role_switch_register(struct device *parent,
+                        const struct usb_role_switch_desc *desc)
+{
+       struct usb_role_switch *sw;
+       int ret;
+
+       if (!desc || !desc->set)
+               return ERR_PTR(-EINVAL);
+
+       sw = kzalloc(sizeof(*sw), GFP_KERNEL);
+       if (!sw)
+               return ERR_PTR(-ENOMEM);
 
+       ret = device_register(&sw->dev);
+       if (ret) {
+               put_device(&sw->dev);
Quoted 7 lines
Quoted 1 line

Memory leak?

No. Check usb_role_switch_release().

Thanks,

---
To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#15 lore raw

Re: [PATCH 04/12] usb: common: Small class for USB role switches

In reply to Andy Shevchenko

Hi,

Quoted 52 lines · Andy Shevchenko
Quoted 14 lines · Hans de Goede

USB role switch is a device that can be used to choose the data role for USB connector. With dual-role capable USB controllers, the controller itself will be the switch, but on some platforms the USB host and device controllers are separate IPs and there is a mux between them and the connector. On those platforms the mux driver will need to register the switch.

With USB Type-C connectors, the host-to-device relationship is negotiated over the Configuration Channel (CC). That means the USB Type-C drivers need to be in control of the role switch. The class provides a simple API for the USB Type-C drivers for the control.

Quoted 5 lines

For other types of USB connectors (mainly microAB) the class provides user space control via sysfs attribute file that can be used to request role swapping from the switch.

+static int __switch_match(struct device *dev, const void *name)

bool?

Quoted 17 lines
drivers/usb/common/roles.c new file +15 -0
+{
+       return !strcmp((const char *)name, dev_name(dev));
+}
 
 
+static ssize_t role_store(struct device *dev, struct device_attribute *attr,
+                         const char *buf, size_t size)
+{
+       struct usb_role_switch *sw = to_role_switch(dev);
+       int ret;
+
+       ret = sysfs_match_string(usb_roles, buf);
+       if (ret < 0) {
+               bool res;
+
+               /* Extra check if the user wants to disable the switch */
+               ret = kstrtobool(buf, &res);

drivers/usb/common/roles.c line 177

Quoted 10 lines
drivers/usb/common/roles.c new file +9 -0
+               if (ret || res)
+                       return -EINVAL;
+       }
+
 
+       ret = usb_role_switch_set_role(sw, ret);
+       if (!ret)
+               ret = size;
+
+       return ret;
Quoted 7 lines

Perhaps

ret = ...
if (ret)
return ret;

return size;

Ack, that is better, fixed for v2.

Regards,

Hans

Quoted 31 lines
Quoted 10 lines
drivers/usb/common/roles.c new file +8 -0
+}
 
+struct usb_role_switch *
+usb_role_switch_register(struct device *parent,
+                        const struct usb_role_switch_desc *desc)
+{
+       struct usb_role_switch *sw;
+       int ret;
+

drivers/usb/common/roles.c line 266

Quoted 10 lines
drivers/usb/common/roles.c new file +9 -0
+       if (!desc || !desc->set)
+               return ERR_PTR(-EINVAL);
+
+       sw = kzalloc(sizeof(*sw), GFP_KERNEL);
+       if (!sw)
+               return ERR_PTR(-ENOMEM);
 
+       ret = device_register(&sw->dev);
+       if (ret) {
+               put_device(&sw->dev);

Memory leak?

Quoted 7 lines
drivers/usb/common/roles.c new file +7 -0
+               return ERR_PTR(ret);
+       }
+
+       /* TODO: Symlinks for the host port and the device controller. */
+
+       return sw;
+}
Quoted 9 lines

drivers/usb/common/roles.c line 284

Quoted 3 lines
drivers/usb/common/roles.c new file +3 -0
+void usb_role_switch_unregister(struct usb_role_switch *sw)
+{
+       if (sw && !IS_ERR(sw))

!IS_ERR_OR_NULL() ?

Quoted 2 lines
(quoted diff) +2 -0
+               device_unregister(&sw->dev);
+}

---
To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

reviewer
#16 lore raw

Re: [PATCH 04/12] usb: common: Small class for USB role switches

In reply to Hans de Goede

drivers/usb/common/roles.c line 2

Quoted 11 lines · Hans de Goede

From: Heikki Krogerus <[email protected]>

drivers/usb/common/roles.c new file +2 -0
new file mode 100644
index 000000000000..923e3721d183
@@ -0,0 +1,305 @@
+// SPDX-License-Identifier: GPL-2.0
+/**

Just use /* since this is not kernel-doc notation.

Quoted 6 lines
drivers/usb/common/roles.c new file +6 -0
+ * USB Role Switch Support
+ *
+ * Copyright (C) 2018 Intel Corporation
+ * Author: Heikki Krogerus <[email protected]>
+ *         Hans de Goede <[email protected]>
+ */
#17 lore raw

Re: [PATCH 04/12] usb: common: Small class for USB role switches

Hi,

Quoted 4 lines · Randy Dunlap
Quoted 2 lines · Hans de Goede

From: Heikki Krogerus <[email protected]>

Quoted 10 lines

drivers/usb/common/roles.c line 2

Quoted 8 lines
drivers/usb/common/roles.c new file +2 -0
new file mode 100644
index 000000000000..923e3721d183
@@ -0,0 +1,305 @@
+// SPDX-License-Identifier: GPL-2.0
+/**

Just use /* since this is not kernel-doc notation.

Thank you for catching this, fixed for v2.

Regards,

Hans

Quoted 9 lines

drivers/usb/common/roles.c line 8

Quoted 7 lines
drivers/usb/common/roles.c new file +6 -0
+ * USB Role Switch Support
+ *
+ * Copyright (C) 2018 Intel Corporation
+ * Author: Heikki Krogerus <[email protected]>
+ *         Hans de Goede <[email protected]>
+ */

---
To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#18 lore raw

PATCH 5/12 usb: typec: tcpm: Set USB role switch to device mode when configured as such

In reply to Hans de Goede

Setting the mux to MUX_NONE and the switch to USB_SWITCH_DISCONNECT when the data-role is device is not correct. Plenty of devices support operating as USB device through a (separate) USB device controller.

We really need 2 different versions of USB_SWITCH_CONNECT, USB_SWITCH_CONNECT_HOST and USB_SWITCH_DEVICE. Rather then modifying the tcpc_usb_switch enum for this, simply remove it and switch to the usb_role enum which provides exactly this, this will save use needing to convert betweent the 2 enums when calling an usb-role-switch driver later.

Besides switching to the usb_role type, this commit also actually sets the mux to TYPEC_MUX_USB and the switch to USB_ROLE_DEVICE instead of setting both to none when the data-role is device.

This commit also makes tcpm_reset_port() call tcpm_mux_set(port, TYPEC_MUX_NONE, USB_ROLE_NONE) so that the mux and switch do _not_ stay in their last mode after a detach.

---
 drivers/usb/typec/tcpm.c | 22 +++++++++++-----------
 include/linux/usb/tcpm.h |  8 ++------
 2 files changed, 13 insertions(+), 17 deletions(-)
drivers/usb/typec/tcpm.c +11 -11
index 7cd28b700a7f..00ca2822432f 100644
@@ -618,15 +618,15 @@ void tcpm_pd_transmit_complete(struct tcpm_port *port,
 EXPORT_SYMBOL_GPL(tcpm_pd_transmit_complete);
 
 static int tcpm_mux_set(struct tcpm_port *port, enum tcpc_mux_mode mode,
-			enum tcpc_usb_switch config)
+			enum usb_role usb_role)
 {
 	int ret = 0;
 
-	tcpm_log(port, "Requesting mux mode %d, config %d, polarity %d",
-		 mode, config, port->polarity);
+	tcpm_log(port, "Requesting mux mode %d, usb-role %d, polarity %d",
+		 mode, usb_role, port->polarity);
 
 	if (port->tcpc->mux)
-		ret = port->tcpc->mux->set(port->tcpc->mux, mode, config,
+		ret = port->tcpc->mux->set(port->tcpc->mux, mode, usb_role,
 					   port->polarity);
 
 	return ret;
@@ -742,14 +742,15 @@ static int tcpm_set_attached_state(struct tcpm_port *port, bool attached)
 static int tcpm_set_roles(struct tcpm_port *port, bool attached,
 			  enum typec_role role, enum typec_data_role data)
 {
+	enum usb_role usb_role;
 	int ret;
 
 	if (data == TYPEC_HOST)
-		ret = tcpm_mux_set(port, TYPEC_MUX_USB,
-				   TCPC_USB_SWITCH_CONNECT);
+		usb_role = USB_ROLE_HOST;
 	else
-		ret = tcpm_mux_set(port, TYPEC_MUX_NONE,
-				   TCPC_USB_SWITCH_DISCONNECT);
+		usb_role = USB_ROLE_DEVICE;
+
+	ret = tcpm_mux_set(port, TYPEC_MUX_USB, usb_role);
 	if (ret < 0)
 		return ret;
 
@@ -2096,7 +2097,7 @@ static int tcpm_src_attach(struct tcpm_port *port)
 out_disable_pd:
 	port->tcpc->set_pd_rx(port->tcpc, false);
 out_disable_mux:
-	tcpm_mux_set(port, TYPEC_MUX_NONE, TCPC_USB_SWITCH_DISCONNECT);
+	tcpm_mux_set(port, TYPEC_MUX_NONE, USB_ROLE_NONE);
 	return ret;
 }
 
@@ -2140,6 +2141,7 @@ static void tcpm_reset_port(struct tcpm_port *port)
 	tcpm_init_vconn(port);
 	tcpm_set_current_limit(port, 0, 0);
 	tcpm_set_polarity(port, TYPEC_POLARITY_CC1);
+	tcpm_mux_set(port, TYPEC_MUX_NONE, USB_ROLE_NONE);
 	tcpm_set_attached_state(port, false);
 	port->try_src_count = 0;
 	port->try_snk_count = 0;
@@ -2190,8 +2192,6 @@ static int tcpm_snk_attach(struct tcpm_port *port)
 static void tcpm_snk_detach(struct tcpm_port *port)
 {
 	tcpm_detach(port);
-
-	/* XXX: (Dis)connect SuperSpeed mux? */
 }
 
 static int tcpm_acc_attach(struct tcpm_port *port)
include/linux/usb/tcpm.h +2 -6
index ca1c0b57f03f..268721bff2c1 100644
@@ -16,6 +16,7 @@
 #define __LINUX_USB_TCPM_H
 
 #include <linux/bitops.h>
+#include <linux/usb/role.h>
 #include <linux/usb/typec.h>
 #include "pd.h"
 
@@ -97,11 +98,6 @@ struct tcpc_config {
 	const struct typec_altmode_desc *alt_modes;
 };
 
-enum tcpc_usb_switch {
-	TCPC_USB_SWITCH_CONNECT,
-	TCPC_USB_SWITCH_DISCONNECT,
-};
-
 /* Mux state attributes */
 #define TCPC_MUX_USB_ENABLED		BIT(0)	/* USB enabled */
 #define TCPC_MUX_DP_ENABLED		BIT(1)	/* DP enabled */
@@ -118,7 +114,7 @@ enum tcpc_mux_mode {
 
 struct tcpc_mux_dev {
 	int (*set)(struct tcpc_mux_dev *dev, enum tcpc_mux_mode mux_mode,
-		   enum tcpc_usb_switch usb_config,
+		   enum usb_role usb_role,
 		   enum typec_cc_polarity polarity);
 	bool dfp_only;
 	void *priv_data;
maintainer Reviewed-by on v1 5/12
#19 lore raw

Re: [PATCH 05/12] usb: typec: tcpm: Set USB role switch to device mode when configured as such

Quoted 14 lines · Hans de Goede

Setting the mux to MUX_NONE and the switch to USB_SWITCH_DISCONNECT when the data-role is device is not correct. Plenty of devices support operating as USB device through a (separate) USB device controller.

We really need 2 different versions of USB_SWITCH_CONNECT, USB_SWITCH_CONNECT_HOST and USB_SWITCH_DEVICE. Rather then modifying the tcpc_usb_switch enum for this, simply remove it and switch to the usb_role enum which provides exactly this, this will save use needing to convert betweent the 2 enums when calling an usb-role-switch driver later.

Besides switching to the usb_role type, this commit also actually sets the mux to TYPEC_MUX_USB and the switch to USB_ROLE_DEVICE instead of setting both to none when the data-role is device.

Quoted 5 lines

This commit also makes tcpm_reset_port() call tcpm_mux_set(port, TYPEC_MUX_NONE, USB_ROLE_NONE) so that the mux and switch do _not_ stay in their last mode after a detach.

I'm happy with this, but Guenter should also check tcpm changes.

Quoted 110 lines
---
 drivers/usb/typec/tcpm.c | 22 +++++++++++-----------
 include/linux/usb/tcpm.h |  8 ++------
 2 files changed, 13 insertions(+), 17 deletions(-)
drivers/usb/typec/tcpm.c +11 -11
index 7cd28b700a7f..00ca2822432f 100644
@@ -618,15 +618,15 @@ void tcpm_pd_transmit_complete(struct tcpm_port *port,
 EXPORT_SYMBOL_GPL(tcpm_pd_transmit_complete);
 
 static int tcpm_mux_set(struct tcpm_port *port, enum tcpc_mux_mode mode,
-			enum tcpc_usb_switch config)
+			enum usb_role usb_role)
 {
 	int ret = 0;
 
-	tcpm_log(port, "Requesting mux mode %d, config %d, polarity %d",
-		 mode, config, port->polarity);
+	tcpm_log(port, "Requesting mux mode %d, usb-role %d, polarity %d",
+		 mode, usb_role, port->polarity);
 
 	if (port->tcpc->mux)
-		ret = port->tcpc->mux->set(port->tcpc->mux, mode, config,
+		ret = port->tcpc->mux->set(port->tcpc->mux, mode, usb_role,
 					   port->polarity);
 
 	return ret;
@@ -742,14 +742,15 @@ static int tcpm_set_attached_state(struct tcpm_port *port, bool attached)
 static int tcpm_set_roles(struct tcpm_port *port, bool attached,
 			  enum typec_role role, enum typec_data_role data)
 {
+	enum usb_role usb_role;
 	int ret;
 
 	if (data == TYPEC_HOST)
-		ret = tcpm_mux_set(port, TYPEC_MUX_USB,
-				   TCPC_USB_SWITCH_CONNECT);
+		usb_role = USB_ROLE_HOST;
 	else
-		ret = tcpm_mux_set(port, TYPEC_MUX_NONE,
-				   TCPC_USB_SWITCH_DISCONNECT);
+		usb_role = USB_ROLE_DEVICE;
+
+	ret = tcpm_mux_set(port, TYPEC_MUX_USB, usb_role);
 	if (ret < 0)
 		return ret;
 
@@ -2096,7 +2097,7 @@ static int tcpm_src_attach(struct tcpm_port *port)
 out_disable_pd:
 	port->tcpc->set_pd_rx(port->tcpc, false);
 out_disable_mux:
-	tcpm_mux_set(port, TYPEC_MUX_NONE, TCPC_USB_SWITCH_DISCONNECT);
+	tcpm_mux_set(port, TYPEC_MUX_NONE, USB_ROLE_NONE);
 	return ret;
 }
 
@@ -2140,6 +2141,7 @@ static void tcpm_reset_port(struct tcpm_port *port)
 	tcpm_init_vconn(port);
 	tcpm_set_current_limit(port, 0, 0);
 	tcpm_set_polarity(port, TYPEC_POLARITY_CC1);
+	tcpm_mux_set(port, TYPEC_MUX_NONE, USB_ROLE_NONE);
 	tcpm_set_attached_state(port, false);
 	port->try_src_count = 0;
 	port->try_snk_count = 0;
@@ -2190,8 +2192,6 @@ static int tcpm_snk_attach(struct tcpm_port *port)
 static void tcpm_snk_detach(struct tcpm_port *port)
 {
 	tcpm_detach(port);
-
-	/* XXX: (Dis)connect SuperSpeed mux? */
 }
 
 static int tcpm_acc_attach(struct tcpm_port *port)
include/linux/usb/tcpm.h +2 -6
index ca1c0b57f03f..268721bff2c1 100644
@@ -16,6 +16,7 @@
 #define __LINUX_USB_TCPM_H
 
 #include <linux/bitops.h>
+#include <linux/usb/role.h>
 #include <linux/usb/typec.h>
 #include "pd.h"
 
@@ -97,11 +98,6 @@ struct tcpc_config {
 	const struct typec_altmode_desc *alt_modes;
 };
 
-enum tcpc_usb_switch {
-	TCPC_USB_SWITCH_CONNECT,
-	TCPC_USB_SWITCH_DISCONNECT,
-};
-
 /* Mux state attributes */
 #define TCPC_MUX_USB_ENABLED		BIT(0)	/* USB enabled */
 #define TCPC_MUX_DP_ENABLED		BIT(1)	/* DP enabled */
@@ -118,7 +114,7 @@ enum tcpc_mux_mode {
 
 struct tcpc_mux_dev {
 	int (*set)(struct tcpc_mux_dev *dev, enum tcpc_mux_mode mux_mode,
-		   enum tcpc_usb_switch usb_config,
+		   enum usb_role usb_role,
 		   enum typec_cc_polarity polarity);
 	bool dfp_only;
 	void *priv_data;
Signature · 1 line
2.14.3

Thanks,

#20 lore raw

PATCH 6/12 usb: typec: tcpm: Use new Type-C switch/mux and usb-role-switch functions

In reply to Hans de Goede

Remove the unused (not implemented anywhere) tcpc_mux_dev abstraction and replace it with calling the new typec_set_orientation, usb_role_switch_set and typec_set_mode functions.

---
 drivers/usb/typec/Kconfig           |  1 +
 drivers/usb/typec/fusb302/fusb302.c |  1 -
 drivers/usb/typec/tcpm.c            | 46 ++++++++++++++++++++++++++++---------
 include/linux/usb/tcpm.h            | 10 --------
 4 files changed, 36 insertions(+), 22 deletions(-)
drivers/usb/typec/Kconfig +1 -0
index bcb2744c5977..a2a0684e7c82 100644
@@ -48,6 +48,7 @@ if TYPEC
 config TYPEC_TCPM
 	tristate "USB Type-C Port Controller Manager"
 	depends on USB
+	select USB_ROLE_SWITCH
 	help
 	  The Type-C Port Controller Manager provides a USB PD and USB Type-C
 	  state machine for use with Type-C Port Controllers.
drivers/usb/typec/fusb302/fusb302.c +0 -1
index 9ce4756adad6..b267b907bf24 100644
@@ -1249,7 +1249,6 @@ static void init_tcpc_dev(struct tcpc_dev *fusb302_tcpc_dev)
 	fusb302_tcpc_dev->set_roles = tcpm_set_roles;
 	fusb302_tcpc_dev->start_drp_toggling = tcpm_start_drp_toggling;
 	fusb302_tcpc_dev->pd_transmit = tcpm_pd_transmit;
-	fusb302_tcpc_dev->mux = NULL;
 }
 
 static const char * const cc_polarity_name[] = {
drivers/usb/typec/tcpm.c +35 -11

106 lines not on this page · raw message

include/linux/usb/tcpm.h +0 -10
index 268721bff2c1..fe3508e6e1df 100644
@@ -16,7 +16,6 @@
 #define __LINUX_USB_TCPM_H
 
 #include <linux/bitops.h>
-#include <linux/usb/role.h>
 #include <linux/usb/typec.h>
 #include "pd.h"
 
@@ -112,14 +111,6 @@ enum tcpc_mux_mode {
 			  TCPC_MUX_DP_ENABLED,
 };
 
-struct tcpc_mux_dev {
-	int (*set)(struct tcpc_mux_dev *dev, enum tcpc_mux_mode mux_mode,
-		   enum usb_role usb_role,
-		   enum typec_cc_polarity polarity);
-	bool dfp_only;
-	void *priv_data;
-};
-
 /**
  * struct tcpc_dev - Port configuration and callback functions
  * @config:	Pointer to port configuration
@@ -171,7 +162,6 @@ struct tcpc_dev {
 	int (*try_role)(struct tcpc_dev *dev, int role);
 	int (*pd_transmit)(struct tcpc_dev *dev, enum tcpm_transmit_type type,
 			   const struct pd_message *msg);
-	struct tcpc_mux_dev *mux;
 };
 
 struct tcpm_port;
maintainer Reviewed-by on v1 6/12
#21 lore raw

Re: [PATCH 06/12] usb: typec: tcpm: Use new Type-C switch/mux and usb-role-switch functions

Quoted 5 lines · Hans de Goede

Remove the unused (not implemented anywhere) tcpc_mux_dev abstraction and replace it with calling the new typec_set_orientation, usb_role_switch_set and typec_set_mode functions.

Thanks,

#22 lore raw

PATCH 7/12 xhci: Add option to get next extended capability in list by passing id = 0

In reply to Hans de Goede

From: Mathias Nyman <[email protected]>

Modify xhci_find_next_ext_cap(base, offset, id) to return the next capability offset if 0 is passed for id. Otherwise it will behave as previously and return the offset of the next capability with matching id

capability id 0 is not used by xhci (reserved)

This is useful when we want to loop through all capabilities.

---
 drivers/usb/host/xhci-ext-caps.h | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/usb/host/xhci-ext-caps.h +3 -2
index bf7316e130d3..631e7cc62604 100644
@@ -84,7 +84,8 @@
  * @base	PCI MMIO registers base address.
  * @start	address at which to start looking, (0 or HCC_PARAMS to start at
  *		beginning of list)
- * @id		Extended capability ID to search for.
+ * @id		Extended capability ID to search for, or 0 for the next
+ *		capability
  *
  * Returns the offset of the next matching extended capability structure.
  * Some capabilities can occur several times, e.g., the XHCI_EXT_CAPS_PROTOCOL,
@@ -110,7 +111,7 @@ static inline int xhci_find_next_ext_cap(void __iomem *base, u32 start, int id)
 		val = readl(base + offset);
 		if (val == ~0)
 			return 0;
-		if (XHCI_EXT_CAPS_ID(val) == id && offset != start)
+		if (offset != start && (id == 0 || XHCI_EXT_CAPS_ID(val) == id))
 			return offset;
 
 		next = XHCI_EXT_CAPS_NEXT(val);
maintainer Reviewed-by on v1 7/12
#23 lore raw

Re: [PATCH 07/12] xhci: Add option to get next extended capability in list by passing id = 0

Quoted 6 lines · Hans de Goede

From: Mathias Nyman <[email protected]>

Modify xhci_find_next_ext_cap(base, offset, id) to return the next capability offset if 0 is passed for id. Otherwise it will behave as previously and return the offset of the next capability with matching id

Quoted 6 lines

capability id 0 is not used by xhci (reserved)

This is useful when we want to loop through all capabilities.

FWIW:

Br,

#24 lore raw

PATCH 8/12 xhci: Add Intel extended cap / otg phy mux handling

In reply to Hans de Goede

The xHCI controller on various Intel SoCs has an extended cap mmio-range which contains registers to control the muxing to the xHCI (host mode) or the dwc3 (device mode) and vbus-detection for the otg usb-phy.

Having a role-sw driver included in the xhci code (under drivers/usb/host) is not desirable. So this commit adds a simple handler for this extended capability, which creates a platform device with the caps mmio region as resource, this allows us to write a separate platform role-sw driver for the role-switch.

Note this commit adds a call to the new xhci_ext_cap_init() function to xhci_pci_probe(), it is added here because xhci_ext_cap_init() must be called only once. If in the future we also want to handle ext-caps on non pci xHCI HCDs from xhci_ext_cap_init() a call to it should also be added to other bus probe paths.

---
Changes in v2:
-Check xHCI controller PCI device-id instead of only checking for the
Intel Extended capability ID, as the Extended capability ID is used on other model Intel xHCI controllers too

Changes in v3:
-Add a new generic xhci_ext_cap_init() function and handle the new
XHCI_INTEL_CHT_USB_MUX quirk there.

Changes in v4:
-Stop using Cherry Trail / CHT in various places as other Intel SoCs
(e.g. Broxton / Apollo Lake) also have this

---
 drivers/usb/host/Makefile        |  2 +-
 drivers/usb/host/xhci-ext-caps.c | 89 ++++++++++++++++++++++++++++++++++++++++
 drivers/usb/host/xhci-ext-caps.h |  2 +
 drivers/usb/host/xhci-pci.c      |  5 +++
 drivers/usb/host/xhci.h          |  2 +
 5 files changed, 99 insertions(+), 1 deletion(-)
 create mode 100644 drivers/usb/host/xhci-ext-caps.c
drivers/usb/host/Makefile +1 -1
index 4ede4ce12366..8a8cffe0b445 100644
@@ -11,7 +11,7 @@ fhci-y += fhci-mem.o fhci-tds.o fhci-sched.o
 
 fhci-$(CONFIG_FHCI_DEBUG) += fhci-dbg.o
 
-xhci-hcd-y := xhci.o xhci-mem.o
+xhci-hcd-y := xhci.o xhci-mem.o xhci-ext-caps.o
 xhci-hcd-y += xhci-ring.o xhci-hub.o xhci-dbg.o
 xhci-hcd-y += xhci-trace.o
 
drivers/usb/host/xhci-ext-caps.c new file +89 -0

89 lines not on this page · raw message

drivers/usb/host/xhci-ext-caps.h +2 -0
index 631e7cc62604..268328c20681 100644
@@ -39,6 +39,8 @@
 #define XHCI_EXT_CAPS_ROUTE	5
 /* IDs 6-9 reserved */
 #define XHCI_EXT_CAPS_DEBUG	10
+/* Vendor caps */
+#define XHCI_EXT_CAPS_VENDOR_INTEL	192
 /* USB Legacy Support Capability - section 7.1.1 */
 #define XHCI_HC_BIOS_OWNED	(1 << 16)
 #define XHCI_HC_OS_OWNED	(1 << 24)
drivers/usb/host/xhci-pci.c +5 -0
index 6c79037876db..4486640d925c 100644
@@ -164,6 +164,7 @@ static void xhci_pci_quirks(struct device *dev, struct xhci_hcd *xhci)
 	if (pdev->vendor == PCI_VENDOR_ID_INTEL &&
 		 pdev->device == PCI_DEVICE_ID_INTEL_CHERRYVIEW_XHCI) {
 		xhci->quirks |= XHCI_SSIC_PORT_UNUSED;
+		xhci->quirks |= XHCI_INTEL_USB_ROLE_SW;
 	}
 	if (pdev->vendor == PCI_VENDOR_ID_INTEL &&
 	    (pdev->device == PCI_DEVICE_ID_INTEL_CHERRYVIEW_XHCI ||
@@ -297,6 +298,10 @@ static int xhci_pci_probe(struct pci_dev *dev, const struct pci_device_id *id)
 		goto dealloc_usb2_hcd;
 	}
 
+	retval = xhci_ext_cap_init(xhci);
+	if (retval)
+		goto put_usb3_hcd;
+
 	retval = usb_add_hcd(xhci->shared_hcd, dev->irq,
 			IRQF_SHARED);
 	if (retval)
drivers/usb/host/xhci.h +2 -0
index 96099a245c69..5917e3095e2a 100644
@@ -1825,6 +1825,7 @@ struct xhci_hcd {
 /* Reserved. It was XHCI_U2_DISABLE_WAKE */
 #define XHCI_ASMEDIA_MODIFY_FLOWCONTROL	(1 << 28)
 #define XHCI_HW_LPM_DISABLE	(1 << 29)
+#define XHCI_INTEL_USB_ROLE_SW	(1 << 30)
 
 	unsigned int		num_active_eps;
 	unsigned int		limit_active_eps;
@@ -2020,6 +2021,7 @@ int xhci_gen_setup(struct usb_hcd *hcd, xhci_get_quirks_t get_quirks);
 void xhci_init_driver(struct hc_driver *drv,
 		      const struct xhci_driver_overrides *over);
 int xhci_disable_slot(struct xhci_hcd *xhci, u32 slot_id);
+int xhci_ext_cap_init(struct xhci_hcd *xhci);
 
 int xhci_suspend(struct xhci_hcd *xhci, bool do_wakeup);
 int xhci_resume(struct xhci_hcd *xhci, bool hibernated);
maintainer Reviewed-by on v1 8/12
#25 lore raw

Re: [PATCH 08/12] xhci: Add Intel extended cap / otg phy mux handling

Quoted 10 lines · Hans de Goede

The xHCI controller on various Intel SoCs has an extended cap mmio-range which contains registers to control the muxing to the xHCI (host mode) or the dwc3 (device mode) and vbus-detection for the otg usb-phy.

Having a role-sw driver included in the xhci code (under drivers/usb/host) is not desirable. So this commit adds a simple handler for this extended capability, which creates a platform device with the caps mmio region as resource, this allows us to write a separate platform role-sw driver for the role-switch.

Quoted 8 lines

Note this commit adds a call to the new xhci_ext_cap_init() function to xhci_pci_probe(), it is added here because xhci_ext_cap_init() must be called only once. If in the future we also want to handle ext-caps on non pci xHCI HCDs from xhci_ext_cap_init() a call to it should also be added to other bus probe paths.

Thanks,

#26 lore raw

Re: [PATCH 08/12] xhci: Add Intel extended cap / otg phy mux handling

In reply to Hans de Goede
Quoted 10 lines · Hans de Goede

The xHCI controller on various Intel SoCs has an extended cap mmio-range which contains registers to control the muxing to the xHCI (host mode) or the dwc3 (device mode) and vbus-detection for the otg usb-phy.

Having a role-sw driver included in the xhci code (under drivers/usb/host) is not desirable. So this commit adds a simple handler for this extended capability, which creates a platform device with the caps mmio region as resource, this allows us to write a separate platform role-sw driver for the role-switch.

Quoted 5 lines

Note this commit adds a call to the new xhci_ext_cap_init() function to xhci_pci_probe(), it is added here because xhci_ext_cap_init() must be called only once. If in the future we also want to handle ext-caps on non pci xHCI HCDs from xhci_ext_cap_init() a call to it should also be added to other bus probe paths.

SPDX?

drivers/usb/host/xhci-ext-caps.c line 27

Quoted 11 lines
drivers/usb/host/xhci-ext-caps.c new file +10 -0
+/*
+ * XHCI extended capability handling
+ *
+ * Copyright (c) 2017 Hans de Goede <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
 
+       pdev = platform_device_alloc("intel_xhci_usb_sw", PLATFORM_DEVID_NONE);

Perhaps,

#define USB_SW_DRV_NAME "..."

drivers/usb/host/xhci-ext-caps.c line 29

Quoted 2 lines
drivers/usb/host/xhci-ext-caps.c new file +2 -0
+       if (!pdev) {
+               xhci_err(xhci, "couldn't allocate intel_xhci_usb_sw pdev\n");

...and re-use it everywhere here.

pdev -> platform device.

drivers/usb/host/xhci-ext-caps.c line 34

Quoted 5 lines
drivers/usb/host/xhci-ext-caps.c new file +5 -0
+               return -ENOMEM;
+       }
+
+       res.start = hcd->rsrc_start + cap_offset;
+       res.end   = res.start + 0x3ff;

Is this magic always the same? Where its value comes from? At least define with comment.

Quoted 7 lines
drivers/usb/host/xhci-ext-caps.c new file +7 -0
+int xhci_ext_cap_init(struct xhci_hcd *xhci)
+{
+       void __iomem *base = &xhci->cap_regs->hc_capbase;
+       u32 cap_offset, val;
+       int ret;
+
+       cap_offset = xhci_find_next_ext_cap(base, 0, 0);

drivers/usb/host/xhci-ext-caps.c line 78

Quoted 10 lines
drivers/usb/host/xhci-ext-caps.c new file +9 -0
+
+       while (cap_offset) {
+               val = readl(base + cap_offset);
+
+               switch (XHCI_EXT_CAPS_ID(val)) {
+               case XHCI_EXT_CAPS_VENDOR_INTEL:
+                       if (xhci->quirks & XHCI_INTEL_USB_ROLE_SW) {
 
+                               ret = xhci_create_intel_xhci_sw_pdev(
+                                                           xhci, cap_offset);

Can we leave xhci on previous line?

Quoted 10 lines
drivers/usb/host/xhci-ext-caps.c new file +10 -0
+                               if (ret)
+                                       return ret;
+                       }
+                       break;
+               }
+               cap_offset = xhci_find_next_ext_cap(base, cap_offset, 0);
+       }
+
+       return 0;
+}
#27 lore raw

Re: [PATCH 08/12] xhci: Add Intel extended cap / otg phy mux handling

Hi,

Quoted 11 lines · Andy Shevchenko
Quoted 10 lines · Hans de Goede

The xHCI controller on various Intel SoCs has an extended cap mmio-range which contains registers to control the muxing to the xHCI (host mode) or the dwc3 (device mode) and vbus-detection for the otg usb-phy.

Having a role-sw driver included in the xhci code (under drivers/usb/host) is not desirable. So this commit adds a simple handler for this extended capability, which creates a platform device with the caps mmio region as resource, this allows us to write a separate platform role-sw driver for the role-switch.

Quoted 7 lines
Quoted 5 lines

Note this commit adds a call to the new xhci_ext_cap_init() function to xhci_pci_probe(), it is added here because xhci_ext_cap_init() must be called only once. If in the future we also want to handle ext-caps on non pci xHCI HCDs from xhci_ext_cap_init() a call to it should also be added to other bus probe paths.

SPDX?

Ack, fixed for v2.

Quoted 10 lines
Quoted 9 lines

+/*
+ * XHCI extended capability handling
+ *
+ * Copyright (c) 2017 Hans de Goede <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */

Quoted 5 lines
Quoted 1 line

+ pdev = platform_device_alloc("intel_xhci_usb_sw", PLATFORM_DEVID_NONE);

Perhaps,

#define USB_SW_DRV_NAME "..."

Ack, fixed for v2.

Quoted 7 lines

drivers/usb/host/xhci-ext-caps.c line 29

Quoted 2 lines
drivers/usb/host/xhci-ext-caps.c new file +2 -0
+       if (!pdev) {
+               xhci_err(xhci, "couldn't allocate intel_xhci_usb_sw pdev\n");

...and re-use it everywhere here.

pdev -> platform device.

Quoted 8 lines

drivers/usb/host/xhci-ext-caps.c line 34

Quoted 5 lines
drivers/usb/host/xhci-ext-caps.c new file +5 -0
+               return -ENOMEM;
+       }
+
+       res.start = hcd->rsrc_start + cap_offset;
+       res.end   = res.start + 0x3ff;

Is this magic always the same? Where its value comes from? At least define with comment.

Ack, I've added a USB_SW_RESOURCE_SIZE #define for this for v2.

Quoted 15 lines
Quoted 14 lines
drivers/usb/host/xhci-ext-caps.c new file +14 -0
+int xhci_ext_cap_init(struct xhci_hcd *xhci)
+{
+       void __iomem *base = &xhci->cap_regs->hc_capbase;
+       u32 cap_offset, val;
+       int ret;
+
+       cap_offset = xhci_find_next_ext_cap(base, 0, 0);
+
+       while (cap_offset) {
+               val = readl(base + cap_offset);
+
+               switch (XHCI_EXT_CAPS_ID(val)) {
+               case XHCI_EXT_CAPS_VENDOR_INTEL:
+                       if (xhci->quirks & XHCI_INTEL_USB_ROLE_SW) {
Quoted 4 lines

drivers/usb/host/xhci-ext-caps.c line 78

Quoted 2 lines
drivers/usb/host/xhci-ext-caps.c new file +2 -0
+                               ret = xhci_create_intel_xhci_sw_pdev(
+                                                           xhci, cap_offset);

Can we leave xhci on previous line?

Fixed for v2.

Quoted 12 lines

drivers/usb/host/xhci-ext-caps.c line 88

Quoted 10 lines
drivers/usb/host/xhci-ext-caps.c new file +10 -0
+                               if (ret)
+                                       return ret;
+                       }
+                       break;
+               }
+               cap_offset = xhci_find_next_ext_cap(base, cap_offset, 0);
+       }
+
+       return 0;
+}

Regards,

Hans
---
To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#28 lore raw

PATCH 9/12 usb: roles: Add Intel XHCI USB role switch driver

In reply to Hans de Goede

Various Intel SoCs (Cherry Trail, Broxton and others) have an internal USB role switch for swiching the OTG USB data lines between the xHCI host controller and the dwc3 gadget controller.

Note on some Cherry Trail systems there is ACPI/AML code listening to edge interrupts on the id-pin (through an _AIE ACPI method) and switching the role between ROLE_HOST and ROLE_NONE based on the id-pin. Note it does not set the role to ROLE_DEVICE, because device-mode is usually not used under Windows.

The presence of AML code which modifies the cfg0 reg (on some systems) means that we our read/write/modify of cfg0 may race with the AML code doing the same to avoid this we take the global ACPI lock while doing the read/write/modify.

---
 MAINTAINERS                                    |   6 +
 drivers/usb/Kconfig                            |   2 +
 drivers/usb/Makefile                           |   2 +
 drivers/usb/roles/Kconfig                      |  14 ++
 drivers/usb/roles/Makefile                     |   1 +
 drivers/usb/roles/intel-xhci-usb-role-switch.c | 201 +++++++++++++++++++++++++
 6 files changed, 226 insertions(+)
 create mode 100644 drivers/usb/roles/Kconfig
 create mode 100644 drivers/usb/roles/Makefile
 create mode 100644 drivers/usb/roles/intel-xhci-usb-role-switch.c
MAINTAINERS +6 -0
index 3a6334da07d1..385ef9080287 100644
@@ -14385,6 +14385,12 @@ S:	Maintained
 F:	Documentation/hid/hiddev.txt
 F:	drivers/hid/usbhid/
 
+USB INTEL XHCI ROLE MUX DRIVER
+M:	Hans de Goede <[email protected]>
+L:	[email protected]
+S:	Maintained
+F:	drivers/usb/roles/intel-xhci-usb-role-switch.c
+
 USB ISP116X DRIVER
 M:	Olav Kongas <[email protected]>
 L:	[email protected]
drivers/usb/Kconfig +2 -0
index a79198f5f1a6..3f123edba6e8 100644
@@ -165,6 +165,8 @@ source "drivers/usb/gadget/Kconfig"
 
 source "drivers/usb/typec/Kconfig"
 
+source "drivers/usb/roles/Kconfig"
+
 config USB_LED_TRIG
 	bool "USB LED Triggers"
 	depends on LEDS_CLASS && LEDS_TRIGGERS
drivers/usb/Makefile +2 -0
index 060643a1b5c8..7d1b8c82b208 100644
@@ -65,3 +65,5 @@ obj-$(CONFIG_USB_COMMON)	+= common/
 obj-$(CONFIG_USBIP_CORE)	+= usbip/
 
 obj-$(CONFIG_TYPEC)		+= typec/
+
+obj-$(CONFIG_USB_ROLE_SWITCH)	+= roles/
drivers/usb/roles/Kconfig new file +14 -0
new file mode 100644
index 000000000000..e5c2bfaf8ba5
@@ -0,0 +1,14 @@
+if USB_ROLE_SWITCH
+
+config USB_ROLES_INTEL_XHCI
+	tristate "Intel XHCI USB Role Switch"
+	depends on ACPI && X86 && EXTCON
+	help
+	  Driver for the internal USB role switch for switching the USB data
+	  lines between the xHCI host controller and the dwc3 gadget controller
+	  found on various Intel SoCs.
+
+	  To compile the driver as a module, choose M here: the module will
+	  be called intel-xhci-usb-role-switch.
+
+endif # USB_ROLE_SWITCH
drivers/usb/roles/Makefile new file +1 -0
new file mode 100644
index 000000000000..e44b179ba275
@@ -0,0 +1 @@
+obj-$(CONFIG_USB_ROLES_INTEL_XHCI) += intel-xhci-usb-role-switch.o
drivers/usb/roles/intel-xhci-usb-role-switch.c new file +201 -0

201 lines not on this page · raw message

maintainer
#29 lore raw

Re: [PATCH 09/12] usb: roles: Add Intel XHCI USB role switch driver

Quoted 16 lines · Hans de Goede
drivers/usb/Makefile +2 -0
index 060643a1b5c8..7d1b8c82b208 100644
@@ -65,3 +65,5 @@ obj-$(CONFIG_USB_COMMON)	+= common/
 obj-$(CONFIG_USBIP_CORE)	+= usbip/
 
 obj-$(CONFIG_TYPEC)		+= typec/
+
+obj-$(CONFIG_USB_ROLE_SWITCH)	+= roles/
drivers/usb/roles/Kconfig new file +0 -0
new file mode 100644
index 000000000000..e5c2bfaf8ba5

drivers/usb/roles/Kconfig line 5

Quoted 5 lines
drivers/usb/roles/Kconfig new file +5 -0
@@ -0,0 +1,14 @@
+if USB_ROLE_SWITCH
+
+config USB_ROLES_INTEL_XHCI
+	tristate "Intel XHCI USB Role Switch"
+	depends on ACPI && X86 && EXTCON

Hold on... There is no dependency on extcon, or is there?

Thanks,

#30 lore raw

Re: [PATCH 09/12] usb: roles: Add Intel XHCI USB role switch driver

Hi,

Quoted 8 lines · Heikki Krogerus
Quoted 7 lines · Hans de Goede
drivers/usb/Makefile +0 -0
index 060643a1b5c8..7d1b8c82b208 100644
@@ -65,3 +65,5 @@ obj-$(CONFIG_USB_COMMON)	+= common/
  obj-$(CONFIG_USBIP_CORE)	+= usbip/
 
Quoted 16 lines
Quoted 9 lines
drivers/usb/Makefile +2 -0
  obj-$(CONFIG_TYPEC)		+= typec/
+
+obj-$(CONFIG_USB_ROLE_SWITCH)	+= roles/
drivers/usb/roles/Kconfig new file +0 -0
new file mode 100644
index 000000000000..e5c2bfaf8ba5

drivers/usb/roles/Kconfig line 5

Quoted 5 lines
drivers/usb/roles/Kconfig new file +5 -0
@@ -0,0 +1,14 @@
+if USB_ROLE_SWITCH
+
+config USB_ROLES_INTEL_XHCI
+	tristate "Intel XHCI USB Role Switch"
+	depends on ACPI && X86 && EXTCON

Hold on... There is no dependency on extcon, or is there?

You are right, this is an old leftover, removed for v2 of this patchset which I'm preparing atm.

Regards,

Hans
---
To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#31 lore raw

Re: [PATCH 09/12] usb: roles: Add Intel XHCI USB role switch driver

In reply to Hans de Goede
Quoted 15 lines · Hans de Goede

Various Intel SoCs (Cherry Trail, Broxton and others) have an internal USB role switch for swiching the OTG USB data lines between the xHCI host controller and the dwc3 gadget controller.

Note on some Cherry Trail systems there is ACPI/AML code listening to edge interrupts on the id-pin (through an _AIE ACPI method) and switching the role between ROLE_HOST and ROLE_NONE based on the id-pin. Note it does not set the role to ROLE_DEVICE, because device-mode is usually not used under Windows.

The presence of AML code which modifies the cfg0 reg (on some systems) means that we our read/write/modify of cfg0 may race with the AML code doing the same to avoid this we take the global ACPI lock while doing the read/write/modify.

drivers/usb/roles/intel-xhci-usb-role-switch.c line 30

Quoted 8 lines
drivers/usb/roles/intel-xhci-usb-role-switch.c new file +8 -0
+/* register definition */
+#define DUAL_ROLE_CFG0                 0x68
+#define SW_VBUS_VALID                  (1 << 24)
+#define SW_IDPIN_EN                    (1 << 21)
+#define SW_IDPIN                       (1 << 20)
+
+#define DUAL_ROLE_CFG1                 0x6c
+#define HOST_MODE                      (1 << 29)

Does it make sense to use BIT() macro above?

drivers/usb/roles/intel-xhci-usb-role-switch.c line 44

Quoted 4 lines
drivers/usb/roles/intel-xhci-usb-role-switch.c new file +4 -0
+struct intel_xhci_acpi_match {
+       const char *hid;
+       int hrv;
+};

Consider to unify with struct acpi_ac_bl.

drivers/usb/roles/intel-xhci-usb-role-switch.c line 60

Quoted 11 lines
drivers/usb/roles/intel-xhci-usb-role-switch.c new file +10 -0
+static const struct intel_xhci_acpi_match allow_userspace_ctrl_ids[] = {
+       { "INT33F4",  3 }, /* X-Powers AXP288 PMIC */
+};
+
+static int intel_xhci_usb_set_role(struct device *dev, enum usb_role role)
+{
+       struct intel_xhci_usb_data *data = dev_get_drvdata(dev);
+       unsigned long timeout;
+       acpi_status status;
 
+       u32 glk = -1U;

I prefer to see consistency and moreover less confusing set, like

~0U

drivers/usb/roles/intel-xhci-usb-role-switch.c line 68

Quoted 8 lines
drivers/usb/roles/intel-xhci-usb-role-switch.c new file +8 -0
+       u32 val;
+
+       /*
+        * On many CHT devices ACPI event (_AEI) handlers read / modify /
+        * write the cfg0 register, just like we do. Take the ACPI lock
+        * to avoid us racing with the AML code.
+        */
+       status = acpi_acquire_global_lock(ACPI_WAIT_FOREVER, &glk);

FOREVER?!
Wouldn't be slightly long under certain circumstances?

drivers/usb/roles/intel-xhci-usb-role-switch.c line 102

Quoted 12 lines
drivers/usb/roles/intel-xhci-usb-role-switch.c new file +9 -0
+       if (ACPI_FAILURE(status) && status != AE_NOT_CONFIGURED) {
+               dev_err(dev, "Error could not acquire lock\n");
+               return -EIO;
+       }
 
+       acpi_release_global_lock(glk);
 
+       /* Polling on CFG1 register to confirm mode switch.*/
+       do {
+               val = readl(data->base + DUAL_ROLE_CFG1);
 
+               if (!!(val & HOST_MODE) == (role == USB_ROLE_HOST))

I would prefer ^ instead of first ==, but it's up to you.

Quoted 11 lines
drivers/usb/roles/intel-xhci-usb-role-switch.c new file +10 -0
+                       return 0;
+
+               /* Interval for polling is set to about 5 - 10 ms */
+               usleep_range(5000, 10000);
+       } while (time_before(jiffies, timeout));
+
+       dev_warn(dev, "Timeout waiting for role-switch\n");
+       return -ETIMEDOUT;
+}
 
+static int intel_xhci_usb_probe(struct platform_device *pdev)

drivers/usb/roles/intel-xhci-usb-role-switch.c line 149

Quoted 10 lines
drivers/usb/roles/intel-xhci-usb-role-switch.c new file +9 -0
+{
+       struct device *dev = &pdev->dev;
+       struct intel_xhci_usb_data *data;
+       struct resource *res;
+       resource_size_t size;
+       int i, ret;
+
+       res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 
+       size = (res->end + 1) - res->start;

resource_size()

Quoted 1 line

+ data->base = devm_ioremap_nocache(dev, res->start, size);

So, what's wrong with devm_ioremap_resource() ?
...which also prints an error message.

drivers/usb/roles/intel-xhci-usb-role-switch.c line 153

Quoted 4 lines
drivers/usb/roles/intel-xhci-usb-role-switch.c new file +3 -0
+       if (IS_ERR(data->base)) {
+               ret = PTR_ERR(data->base);
 
+               dev_err(dev, "Error iomaping registers: %d\n", ret);

At least printing return code is useless. Driver core does this.

drivers/usb/roles/intel-xhci-usb-role-switch.c line 167

Quoted 9 lines
drivers/usb/roles/intel-xhci-usb-role-switch.c new file +7 -0
+               return ret;
+       }
+
 
+       data->role_sw = usb_role_switch_register(dev, &sw_desc);
+       if (IS_ERR(data->role_sw)) {
+               ret = PTR_ERR(data->role_sw);
 
+               dev_err(dev, "Error registering role-switch: %d\n", ret);

Ditto.

drivers/usb/roles/intel-xhci-usb-role-switch.c line 184

Quoted 10 lines
drivers/usb/roles/intel-xhci-usb-role-switch.c new file +8 -0
+               return ret;
+       }
+
+       return 0;
+}
 
+static const struct platform_device_id intel_xhci_usb_table[] = {
+       { .name = DRV_NAME },
 
+       {},

No comma, please.

Quoted 1 line

+};

#32 lore raw

Re: [PATCH 09/12] usb: roles: Add Intel XHCI USB role switch driver

Hi,

Quoted 16 lines · Andy Shevchenko
Quoted 14 lines · Hans de Goede

Various Intel SoCs (Cherry Trail, Broxton and others) have an internal USB role switch for swiching the OTG USB data lines between the xHCI host controller and the dwc3 gadget controller.

Note on some Cherry Trail systems there is ACPI/AML code listening to edge interrupts on the id-pin (through an _AIE ACPI method) and switching the role between ROLE_HOST and ROLE_NONE based on the id-pin. Note it does not set the role to ROLE_DEVICE, because device-mode is usually not used under Windows.

The presence of AML code which modifies the cfg0 reg (on some systems) means that we our read/write/modify of cfg0 may race with the AML code doing the same to avoid this we take the global ACPI lock while doing the read/write/modify.

Quoted 10 lines

drivers/usb/roles/intel-xhci-usb-role-switch.c line 30

Quoted 8 lines
drivers/usb/roles/intel-xhci-usb-role-switch.c new file +8 -0
+/* register definition */
+#define DUAL_ROLE_CFG0                 0x68
+#define SW_VBUS_VALID                  (1 << 24)
+#define SW_IDPIN_EN                    (1 << 21)
+#define SW_IDPIN                       (1 << 20)
+
+#define DUAL_ROLE_CFG1                 0x6c
+#define HOST_MODE                      (1 << 29)

Does it make sense to use BIT() macro above?

Yes, fixed for v2.

Quoted 8 lines

drivers/usb/roles/intel-xhci-usb-role-switch.c line 44

Quoted 6 lines
drivers/usb/roles/intel-xhci-usb-role-switch.c new file +4 -0
+struct intel_xhci_acpi_match {
+       const char *hid;
+       int hrv;
+};

Consider to unify with struct acpi_ac_bl.

That is not a bad idea, but probably best done as a follow-up commit, since this patch-set already touches enough subsystems as is.

I just added this to my TODO:
-Add acpi_find_dev_present() helprt which takes an array of and returns a
pointer to (or NULL):

   struct acpi_dev_present_match {
         const char *hid;
         const char *uid;
         int hrv;

};
And use this in drivers/acpi/ac.c drivers/acpi/battery.c, drivers/usb/roles/intel-xhci-usb-role-switch.c, ...

Quoted 10 lines
Quoted 9 lines
drivers/usb/roles/intel-xhci-usb-role-switch.c new file +9 -0
+static const struct intel_xhci_acpi_match allow_userspace_ctrl_ids[] = {
+       { "INT33F4",  3 }, /* X-Powers AXP288 PMIC */
+};
+
+static int intel_xhci_usb_set_role(struct device *dev, enum usb_role role)
+{
+       struct intel_xhci_usb_data *data = dev_get_drvdata(dev);
+       unsigned long timeout;
+       acpi_status status;
Quoted 5 lines
Quoted 1 line

+ u32 glk = -1U;

I prefer to see consistency and moreover less confusing set, like

~0U

Looks like a chose a bad example as user of the acpi_acquire_global_lock() function, others don't init this at all because it is not necessary.

Quoted 10 lines

drivers/usb/roles/intel-xhci-usb-role-switch.c line 68

Quoted 9 lines
drivers/usb/roles/intel-xhci-usb-role-switch.c new file +8 -0
+       u32 val;
+
+       /*
+        * On many CHT devices ACPI event (_AEI) handlers read / modify /
+        * write the cfg0 register, just like we do. Take the ACPI lock
+        * to avoid us racing with the AML code.
+        */
+       status = acpi_acquire_global_lock(ACPI_WAIT_FOREVER, &glk);
Quoted 2 lines

FOREVER?!
Wouldn't be slightly long under certain circumstances?

The mode-switch itself may take up-to 600ms, so I don't think any delays caused by this will be a problem. This is just some weird ACPI-subsys-ism where instead of just having a mutex and using mutex_trylock() where necessary, the ACPICA code has its own private timeout handling. I'm sure if I were to just do a mutex_lock() here nobody would fall over that. The FOREVER just makes this look scarier then it really is, in theory any mutex_lock() call can wait forever.

Quoted 35 lines

drivers/usb/roles/intel-xhci-usb-role-switch.c line 102

Quoted 12 lines
drivers/usb/roles/intel-xhci-usb-role-switch.c new file +9 -0
+       if (ACPI_FAILURE(status) && status != AE_NOT_CONFIGURED) {
+               dev_err(dev, "Error could not acquire lock\n");
+               return -EIO;
+       }
 
+       acpi_release_global_lock(glk);
 
+       /* Polling on CFG1 register to confirm mode switch.*/
+       do {
+               val = readl(data->base + DUAL_ROLE_CFG1);
 
+               if (!!(val & HOST_MODE) == (role == USB_ROLE_HOST))

I would prefer ^ instead of first ==, but it's up to you.

Quoted 19 lines
drivers/usb/roles/intel-xhci-usb-role-switch.c new file +18 -0
+                       return 0;
+
+               /* Interval for polling is set to about 5 - 10 ms */
+               usleep_range(5000, 10000);
+       } while (time_before(jiffies, timeout));
+
+       dev_warn(dev, "Timeout waiting for role-switch\n");
+       return -ETIMEDOUT;
+}
 
+static int intel_xhci_usb_probe(struct platform_device *pdev)
+{
+       struct device *dev = &pdev->dev;
+       struct intel_xhci_usb_data *data;
+       struct resource *res;
+       resource_size_t size;
+       int i, ret;
+
+       res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
Quoted 3 lines
Quoted 1 line

+ size = (res->end + 1) - res->start;

resource_size()

Fixed for v2.

Quoted 4 lines
Quoted 1 line

+ data->base = devm_ioremap_nocache(dev, res->start, size);

So, what's wrong with devm_ioremap_resource() ?
...which also prints an error message.

Nothing, I inherited this from the Android X86 patches this is based on, fixed for v2.

Quoted 12 lines

drivers/usb/roles/intel-xhci-usb-role-switch.c line 153

Quoted 5 lines
drivers/usb/roles/intel-xhci-usb-role-switch.c new file +3 -0
+       if (IS_ERR(data->base)) {
+               ret = PTR_ERR(data->base);
 
+               dev_err(dev, "Error iomaping registers: %d\n", ret);

At least printing return code is useless. Driver core does this.

Quoted 3 lines
drivers/usb/roles/intel-xhci-usb-role-switch.c new file +3 -0
+               return ret;
+       }
+
Quoted 7 lines

drivers/usb/roles/intel-xhci-usb-role-switch.c line 167

Quoted 5 lines
drivers/usb/roles/intel-xhci-usb-role-switch.c new file +4 -0
+       data->role_sw = usb_role_switch_register(dev, &sw_desc);
+       if (IS_ERR(data->role_sw)) {
+               ret = PTR_ERR(data->role_sw);
 
+               dev_err(dev, "Error registering role-switch: %d\n", ret);

Ditto.

Ok, both dropped.

Quoted 7 lines
Quoted 6 lines
drivers/usb/roles/intel-xhci-usb-role-switch.c new file +5 -0
+               return ret;
+       }
+
+       return 0;
+}
Quoted 6 lines

drivers/usb/roles/intel-xhci-usb-role-switch.c line 184

Quoted 4 lines
drivers/usb/roles/intel-xhci-usb-role-switch.c new file +3 -0
+static const struct platform_device_id intel_xhci_usb_table[] = {
+       { .name = DRV_NAME },
 
+       {},

No comma, please.

Fixed for v2.

Regards,

Hans
---
To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#33 lore raw

PATCH 10/12 usb: typec: driver for Pericom PI3USB30532 Type-C cross switch

In reply to Hans de Goede

Add a driver for the Pericom PI3USB30532 Type-C cross switch / mux chip found on some devices with a Type-C port.

---
Note this is a rewrite of my previous driver which was using the drivers/mux framework to use the new drivers/usb/typec/mux framework

---
 MAINTAINERS                         |   6 ++
 drivers/usb/typec/Kconfig           |   2 +
 drivers/usb/typec/Makefile          |   1 +
 drivers/usb/typec/mux/Kconfig       |  10 ++
 drivers/usb/typec/mux/Makefile      |   3 +
 drivers/usb/typec/mux/pi3usb30532.c | 177 ++++++++++++++++++++++++++++++++++++
 6 files changed, 199 insertions(+)
 create mode 100644 drivers/usb/typec/mux/Kconfig
 create mode 100644 drivers/usb/typec/mux/Makefile
 create mode 100644 drivers/usb/typec/mux/pi3usb30532.c
MAINTAINERS +6 -0
index 385ef9080287..ec047e7e3c43 100644
@@ -14521,6 +14521,12 @@ F:	drivers/usb/
 F:	include/linux/usb.h
 F:	include/linux/usb/
 
+USB TYPEC PI3USB30532 MUX DRIVER
+M:	Hans de Goede <[email protected]>
+L:	[email protected]
+S:	Maintained
+F:	drivers/usb/typec/mux/pi3usb30532.c
+
 USB TYPEC SUBSYSTEM
 M:	Heikki Krogerus <[email protected]>
 L:	[email protected]
drivers/usb/typec/Kconfig +2 -0
index a2a0684e7c82..030f88cb0c3f 100644
@@ -85,4 +85,6 @@ config TYPEC_TPS6598X
 	  If you choose to build this driver as a dynamically linked module, the
 	  module will be called tps6598x.ko.
 
+source "drivers/usb/typec/mux/Kconfig"
+
 endif # TYPEC
drivers/usb/typec/Makefile +1 -0
index 56b2e9516ec1..1f599a6c30cc 100644
@@ -6,3 +6,4 @@ obj-y				+= fusb302/
 obj-$(CONFIG_TYPEC_WCOVE)	+= typec_wcove.o
 obj-$(CONFIG_TYPEC_UCSI)	+= ucsi/
 obj-$(CONFIG_TYPEC_TPS6598X)	+= tps6598x.o
+obj-$(CONFIG_TYPEC)		+= mux/
drivers/usb/typec/mux/Kconfig new file +10 -0
new file mode 100644
index 000000000000..9a954d2b8d8f
@@ -0,0 +1,10 @@
+menu "USB Type-C Multiplexer/DeMultiplexer Switch support"
+
+config TYPEC_MUX_PI3USB30532
+	tristate "Pericom PI3USB30532 Type-C cross switch driver"
+	depends on I2C
+	help
+	  Say Y or M if your system has a Pericom PI3USB30532 Type-C cross
+	  switch / mux chip found on some devices with a Type-C port.
+
+endmenu
drivers/usb/typec/mux/Makefile new file +3 -0
new file mode 100644
index 000000000000..1332e469b8a0
@@ -0,0 +1,3 @@
+# SPDX-License-Identifier: GPL-2.0
+
+obj-$(CONFIG_TYPEC_MUX_PI3USB30532)	+= pi3usb30532.o
drivers/usb/typec/mux/pi3usb30532.c new file +177 -0

177 lines not on this page · raw message

#34 lore raw

Re: [PATCH 10/12] usb: typec: driver for Pericom PI3USB30532 Type-C cross switch

Quoted 7 lines · Hans de Goede

Add a driver for the Pericom PI3USB30532 Type-C cross switch / mux chip found on some devices with a Type-C port.

drivers/usb/typec/mux/pi3usb30532.c new file +3 -0
+static int pi3usb30532_set_conf(struct pi3usb30532 *pi, u8 new_conf)
+{
+       int ret = 0;

drivers/usb/typec/mux/pi3usb30532.c line 42

Quoted 10 lines
drivers/usb/typec/mux/pi3usb30532.c new file +9 -0
+
+       if (pi->conf == new_conf)
+               return 0;
+
+       ret = i2c_smbus_write_byte_data(pi->client, PI3USB30532_CONF, new_conf);
 
+       if (ret == 0)
+               pi->conf = new_conf;
+       else
+               dev_err(&pi->client->dev, "Error writing conf: %d\n", ret);

Usual pattern, please.

if (ret) {
...
return ret;
}

return 0;

Quoted 3 lines
drivers/usb/typec/mux/pi3usb30532.c new file +3 -0
+
+       return ret;
+}
#36 lore raw

PATCH 11/12 platform/x86: intel_cht_int33fe: Add device connections for the Type-C port

In reply to Hans de Goede

We need to add device-connections for the TYPE-C mux/switch and usb-role code to be able to find the PI3USB30532 Type-C cross-switch and the device/host switch integrated in the CHT SoC.

---
 drivers/platform/x86/intel_cht_int33fe.c | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)
drivers/platform/x86/intel_cht_int33fe.c +25 -0
index 380ef7ec094f..a3f8674f14da 100644
@@ -21,6 +21,7 @@
  */
 
 #include <linux/acpi.h>
+#include <linux/connection.h>
 #include <linux/i2c.h>
 #include <linux/interrupt.h>
 #include <linux/module.h>
@@ -33,6 +34,8 @@ struct cht_int33fe_data {
 	struct i2c_client *max17047;
 	struct i2c_client *fusb302;
 	struct i2c_client *pi3usb30532;
+	/* Contain a list-head must be per device */
+	struct devcon connections[3];
 };
 
 /*
@@ -172,6 +175,20 @@ static int cht_int33fe_probe(struct i2c_client *client)
 			return -EPROBE_DEFER; /* Wait for i2c-adapter to load */
 	}
 
+	data->connections[0].endpoint[0] = "i2c-fusb302";
+	data->connections[0].endpoint[1] = "i2c-pi3usb30532";
+	data->connections[0].id = "typec-switch";
+	data->connections[1].endpoint[0] = "i2c-fusb302";
+	data->connections[1].endpoint[1] = "i2c-pi3usb30532";
+	data->connections[1].id = "typec-mux";
+	data->connections[2].endpoint[0] = "i2c-fusb302";
+	data->connections[2].endpoint[1] = "intel_xhci_usb_sw-role-switch";
+	data->connections[2].id = "usb-role-switch";
+
+	add_device_connection(&data->connections[0]);
+	add_device_connection(&data->connections[1]);
+	add_device_connection(&data->connections[2]);
+
 	memset(&board_info, 0, sizeof(board_info));
 	strlcpy(board_info.type, "typec_fusb302", I2C_NAME_SIZE);
 	board_info.dev_name = "fusb302";
@@ -201,6 +218,10 @@ static int cht_int33fe_probe(struct i2c_client *client)
 	if (data->max17047)
 		i2c_unregister_device(data->max17047);
 
+	remove_device_connection(&data->connections[2]);
+	remove_device_connection(&data->connections[1]);
+	remove_device_connection(&data->connections[0]);
+
 	return -EPROBE_DEFER; /* Wait for the i2c-adapter to load */
 }
 
@@ -213,6 +234,10 @@ static int cht_int33fe_remove(struct i2c_client *i2c)
 	if (data->max17047)
 		i2c_unregister_device(data->max17047);
 
+	remove_device_connection(&data->connections[2]);
+	remove_device_connection(&data->connections[1]);
+	remove_device_connection(&data->connections[0]);
+
 	return 0;
 }
 
Acked-by on v1 11/12
#37 lore raw

Re: [PATCH 11/12] platform/x86: intel_cht_int33fe: Add device connections for the Type-C port

Quoted 4 lines · Hans de Goede

We need to add device-connections for the TYPE-C mux/switch and usb-role code to be able to find the PI3USB30532 Type-C cross-switch and the device/host switch integrated in the CHT SoC.

Quoted 72 lines
---
 drivers/platform/x86/intel_cht_int33fe.c | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)
drivers/platform/x86/intel_cht_int33fe.c +25 -1
index 380ef7ec094f..a3f8674f14da 100644
@@ -21,6 +21,7 @@
  */
 
 #include <linux/acpi.h>
+#include <linux/connection.h>
 #include <linux/i2c.h>
 #include <linux/interrupt.h>
 #include <linux/module.h>
@@ -33,6 +34,8 @@ struct cht_int33fe_data {
        struct i2c_client *max17047;
        struct i2c_client *fusb302;
        struct i2c_client *pi3usb30532;
+       /* Contain a list-head must be per device */
+       struct devcon connections[3];
 };
 
 /*
@@ -172,6 +175,20 @@ static int cht_int33fe_probe(struct i2c_client *client)
                        return -EPROBE_DEFER; /* Wait for i2c-adapter to load */
        }
 
+       data->connections[0].endpoint[0] = "i2c-fusb302";
+       data->connections[0].endpoint[1] = "i2c-pi3usb30532";
+       data->connections[0].id = "typec-switch";
+       data->connections[1].endpoint[0] = "i2c-fusb302";
+       data->connections[1].endpoint[1] = "i2c-pi3usb30532";
+       data->connections[1].id = "typec-mux";
+       data->connections[2].endpoint[0] = "i2c-fusb302";
+       data->connections[2].endpoint[1] = "intel_xhci_usb_sw-role-switch";
+       data->connections[2].id = "usb-role-switch";
+
+       add_device_connection(&data->connections[0]);
+       add_device_connection(&data->connections[1]);
+       add_device_connection(&data->connections[2]);
+
        memset(&board_info, 0, sizeof(board_info));
        strlcpy(board_info.type, "typec_fusb302", I2C_NAME_SIZE);
        board_info.dev_name = "fusb302";
@@ -201,6 +218,10 @@ static int cht_int33fe_probe(struct i2c_client *client)
        if (data->max17047)
                i2c_unregister_device(data->max17047);
 
+       remove_device_connection(&data->connections[2]);
+       remove_device_connection(&data->connections[1]);
+       remove_device_connection(&data->connections[0]);
+
        return -EPROBE_DEFER; /* Wait for the i2c-adapter to load */
 }
 
@@ -213,6 +234,10 @@ static int cht_int33fe_remove(struct i2c_client *i2c)
        if (data->max17047)
                i2c_unregister_device(data->max17047);
 
+       remove_device_connection(&data->connections[2]);
+       remove_device_connection(&data->connections[1]);
+       remove_device_connection(&data->connections[0]);
+
        return 0;
 }
 
--

2.14.3

maintainer Reviewed-by on v1 11/12
#38 lore raw

Re: [PATCH 11/12] platform/x86: intel_cht_int33fe: Add device connections for the Type-C port

In reply to Hans de Goede
Quoted 5 lines · Hans de Goede

We need to add device-connections for the TYPE-C mux/switch and usb-role code to be able to find the PI3USB30532 Type-C cross-switch and the device/host switch integrated in the CHT SoC.

Thanks,

#39 lore raw

PATCH 12/12 extcon: axp288: Set USB role where necessary

In reply to Hans de Goede

The AXP288 BC1.2 charger detection / extcon code may seem like a strange place to add code to control the USB role-switch on devices with an AXP288, but there are 2 reasons to do this inside the axp288 extcon code:

1) On many devices the USB role is controlled by ACPI AML code, but the AML code only switches between the host and none roles, because of Windows not really using device mode. To make device mode work we need to toggle between the none/device roles based on VBus presence, and the axp288 extcon gets interrupts on VBus insertion / removal.

2) In order for our BC1.2 charger detection to work properly the role mux must be properly set to device mode before we do the detection.

Also note the Kconfig help-text / obsolete depends on USB_PHY which are remnants from older never upstreamed code also controlling the mux from the axp288 extcon code.

This commit also adds code to get notifications from the INT3496 extcon device, which is used on some devices to notify the kernel about id-pin changes instead of them being handled through AML code.

This fixes:
-Device mode not working on most CHT devices with an AXP288 -Host mode not working on devices with an INT3496 ACPI device -Charger-type misdetection (always SDP) on devices with an INT3496 when the
USB role (always) gets initialized as host

---
 drivers/extcon/Kconfig         |   3 +-
 drivers/extcon/extcon-axp288.c | 175 +++++++++++++++++++++++++++++++++++++++--
 2 files changed, 169 insertions(+), 9 deletions(-)
drivers/extcon/Kconfig +2 -1
index a7bca4207f44..0dc2d5441c3b 100644
@@ -30,7 +30,8 @@ config EXTCON_ARIZONA
 
 config EXTCON_AXP288
 	tristate "X-Power AXP288 EXTCON support"
-	depends on MFD_AXP20X && USB_PHY
+	depends on MFD_AXP20X && USB_SUPPORT
+	select USB_ROLE_SWITCH
 	help
 	  Say Y here to enable support for USB peripheral detection
 	  and USB MUX switching by X-Power AXP288 PMIC.
drivers/extcon/extcon-axp288.c +167 -8

259 lines not on this page · raw message

#40 lore raw

Re: [PATCH 12/12] extcon: axp288: Set USB role where necessary

Quoted 31 lines · Hans de Goede

The AXP288 BC1.2 charger detection / extcon code may seem like a strange place to add code to control the USB role-switch on devices with an AXP288, but there are 2 reasons to do this inside the axp288 extcon code:

1) On many devices the USB role is controlled by ACPI AML code, but the AML code only switches between the host and none roles, because of Windows not really using device mode. To make device mode work we need to toggle between the none/device roles based on VBus presence, and the axp288 extcon gets interrupts on VBus insertion / removal.

2) In order for our BC1.2 charger detection to work properly the role mux must be properly set to device mode before we do the detection.

Also note the Kconfig help-text / obsolete depends on USB_PHY which are remnants from older never upstreamed code also controlling the mux from the axp288 extcon code.

This commit also adds code to get notifications from the INT3496 extcon device, which is used on some devices to notify the kernel about id-pin changes instead of them being handled through AML code.

This fixes:

(quoted diff) +0 -3
-Device mode not working on most CHT devices with an AXP288
-Host mode not working on devices with an INT3496 ACPI device
-Charger-type misdetection (always SDP) on devices with an INT3496 when the
 USB role (always) gets initialized as host

config EXTCON_AXP288
tristate "X-Power AXP288 EXTCON support"

drivers/extcon/Kconfig config EXTCON_ARIZONA · line 34

Quoted 3 lines
drivers/extcon/Kconfig +2 -1
-       depends on MFD_AXP20X && USB_PHY
+       depends on MFD_AXP20X && USB_SUPPORT
+       select USB_ROLE_SWITCH

Is it supposed to work outside of x86 world?..

drivers/extcon/extcon-axp288.c line 35

Quoted 2 lines
drivers/extcon/extcon-axp288.c +2 -0
+#include <asm/cpu_device_id.h>
+#include <asm/intel-family.h>

...if yes, this should go under CONFIG_X86 along with accompanying parts.

...if no, put corresponding dependency to Kconfig.

drivers/extcon/extcon-axp288.c static int axp288_extcon_probe(struct platform_device *pdev) · line 361

Quoted 7 lines
drivers/extcon/extcon-axp288.c +7 -0
+       if (info->role_sw) {
+               ret = devm_add_action_or_reset(dev, axp288_put_role_sw, info);
+               if (ret)
+                       return ret;
+
+               if (acpi_dev_present("INT3496", NULL, -1)) {
+                       info->id_extcon = extcon_get_extcon_dev("INT3496:00");

Please use instance found by acpi_dev_present(). Okay, actually new helper is here:
acpi_dev_get_first_match_name().

Quoted 9 lines
drivers/extcon/extcon-axp288.c +9 -0
+                       if (!info->id_extcon)
+                               return -EPROBE_DEFER;
+
+                       dev_info(dev, "controlling USB role\n");
+               } else {
+                       dev_info(dev, "controlling USB role based on vbus presence\n");
+               }
+       }
+
#41 lore raw

Re: [PATCH 12/12] extcon: axp288: Set USB role where necessary

Hi,

Quoted 30 lines · Andy Shevchenko
Quoted 28 lines · Hans de Goede

The AXP288 BC1.2 charger detection / extcon code may seem like a strange place to add code to control the USB role-switch on devices with an AXP288, but there are 2 reasons to do this inside the axp288 extcon code:

1) On many devices the USB role is controlled by ACPI AML code, but the AML code only switches between the host and none roles, because of Windows not really using device mode. To make device mode work we need to toggle between the none/device roles based on VBus presence, and the axp288 extcon gets interrupts on VBus insertion / removal.

2) In order for our BC1.2 charger detection to work properly the role mux must be properly set to device mode before we do the detection.

Also note the Kconfig help-text / obsolete depends on USB_PHY which are remnants from older never upstreamed code also controlling the mux from the axp288 extcon code.

This commit also adds code to get notifications from the INT3496 extcon device, which is used on some devices to notify the kernel about id-pin changes instead of them being handled through AML code.

This fixes:

(quoted diff) +0 -3
-Device mode not working on most CHT devices with an AXP288
-Host mode not working on devices with an INT3496 ACPI device
-Charger-type misdetection (always SDP) on devices with an INT3496 when the
  USB role (always) gets initialized as host
Quoted 7 lines

drivers/extcon/Kconfig config EXTCON_ARIZONA · line 34

Quoted 5 lines

config EXTCON_AXP288
tristate "X-Power AXP288 EXTCON support"

drivers/extcon/Kconfig +2 -1
-       depends on MFD_AXP20X && USB_PHY
+       depends on MFD_AXP20X && USB_SUPPORT
+       select USB_ROLE_SWITCH

Is it supposed to work outside of x86 world?..

No.

Quoted 6 lines

drivers/extcon/extcon-axp288.c line 35

Quoted 2 lines
drivers/extcon/extcon-axp288.c +2 -0
+#include <asm/cpu_device_id.h>
+#include <asm/intel-family.h>

...if yes, this should go under CONFIG_X86 along with accompanying parts.

...if no, put corresponding dependency to Kconfig.

Ack, added the dependency for v2 of the patch-set.

Quoted 11 lines

drivers/extcon/extcon-axp288.c static int axp288_extcon_probe(struct platform_device *pdev) · line 361

Quoted 7 lines
drivers/extcon/extcon-axp288.c +7 -0
+       if (info->role_sw) {
+               ret = devm_add_action_or_reset(dev, axp288_put_role_sw, info);
+               if (ret)
+                       return ret;
+
+               if (acpi_dev_present("INT3496", NULL, -1)) {
+                       info->id_extcon = extcon_get_extcon_dev("INT3496:00");

Please use instance found by acpi_dev_present(). Okay, actually new helper is here:
acpi_dev_get_first_match_name().

Good call, I've switched to acpi_dev_get_first_match_name() for v2.

Quoted 11 lines

drivers/extcon/extcon-axp288.c static int axp288_extcon_probe(struct platform_device *pdev) · line 370

Quoted 10 lines
drivers/extcon/extcon-axp288.c +9 -0
+                       if (!info->id_extcon)
+                               return -EPROBE_DEFER;
+
+                       dev_info(dev, "controlling USB role\n");
+               } else {
+                       dev_info(dev, "controlling USB role based on vbus presence\n");
+               }
+       }
+

Andy, Thank you for all the reviews!

Regards,

Hans
---
To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

maintainer Reviewed-by on v1 12/12
#42 lore raw

Re: [PATCH 12/12] extcon: axp288: Set USB role where necessary

In reply to Hans de Goede
Quoted 27 lines · Hans de Goede

The AXP288 BC1.2 charger detection / extcon code may seem like a strange place to add code to control the USB role-switch on devices with an AXP288, but there are 2 reasons to do this inside the axp288 extcon code:

1) On many devices the USB role is controlled by ACPI AML code, but the AML code only switches between the host and none roles, because of Windows not really using device mode. To make device mode work we need to toggle between the none/device roles based on VBus presence, and the axp288 extcon gets interrupts on VBus insertion / removal.

2) In order for our BC1.2 charger detection to work properly the role mux must be properly set to device mode before we do the detection.

Also note the Kconfig help-text / obsolete depends on USB_PHY which are remnants from older never upstreamed code also controlling the mux from the axp288 extcon code.

This commit also adds code to get notifications from the INT3496 extcon device, which is used on some devices to notify the kernel about id-pin changes instead of them being handled through AML code.

This fixes:

(quoted diff) +0 -3
-Device mode not working on most CHT devices with an AXP288
-Host mode not working on devices with an INT3496 ACPI device
-Charger-type misdetection (always SDP) on devices with an INT3496 when the
 USB role (always) gets initialized as host
Quoted 1 line

After addressing Andy's comments:

Thanks,

#43 lore raw
In reply to Hans de Goede

On Fri, Feb 16, 2018 at 12:47 PM, Hans de Goede <[email protected]> wrote:

While I'm going through patches, one notice to all of them: be consistent with xHCI abbreviation.
Also check others, like vBus (or whatever is standard de facto to show it in comments and to the user in messages).

Signature · 2 lines
With Best Regards,
Andy Shevchenko