linux-usb.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3 00/11] chrome/platform: cros_ec_typec: Register cables, partner altmodes and plug altmodes
@ 2020-11-16 20:11 Prashant Malani
  2020-11-16 20:11 ` [PATCH v3 01/11] usb: pd: Add captive Type C cable type Prashant Malani
                   ` (12 more replies)
  0 siblings, 13 replies; 21+ messages in thread
From: Prashant Malani @ 2020-11-16 20:11 UTC (permalink / raw)
  To: linux-kernel, linux-usb, gregkh, heikki.krogerus, enric.balletbo
  Cc: Prashant Malani, Benson Leung, Guenter Roeck

This patch series adds support for the following bits of functionality,
parsing USB Type C Power Delivery information from the Chrome Embedded Controller
and using the Type C connector class:
- Register cable objects (including plug type).
- Register "number of altmodes" attribute for partners.
- Register altmodes and "number of altmodes" attribute for cable plugs.

The functionality was earlier part of multiple series ([1], [2], [3]), but
I've combined it into 1 series and re-ordered the patches to hopefully make
it easier to peruse. I've maintained the patch Acked-by/Reviewed-by tags where
they were received.

Patches 1/11, 2/11, 3/11 introduce the changes needed in the USB subsystem (PD VDO
header update, sysfs attribute additions) and hence the first three patches
can go through Greg's tree.
The others are users of the newly introduced USB changes and can go through
the chrome-platform tree.

Of course, the above is only a suggestion, so I'd be happy to follow
another means of integrating the patches if available.

The series is based on the following git branch and commit
Branch: chrome-platform for-next [4]
Commit: de0f49487db3 ("platform/chrome: cros_ec_typec: Register partner altmodes")

For reference, the patches in this series which are yet to be reviewed are
Patch 3/11, Patch 10/11 and Patch 11/11.

Version history:
- No v2 or v1, as mentioned earlier these patches were uploaded as separate
  series [1], [2] and [3] but have now been coalesced.

[1]:
https://lore.kernel.org/lkml/20201106184104.939284-1-pmalani@chromium.org/
[2]:
https://lore.kernel.org/lkml/20201110061535.2163599-1-pmalani@chromium.org/
[3]:
https://lore.kernel.org/linux-usb/20201112012329.1364975-1-pmalani@chromium.org/
[4]:
https://git.kernel.org/pub/scm/linux/kernel/git/chrome-platform/linux.git/log/?h=for-next

Prashant Malani (11):
  usb: pd: Add captive Type C cable type
  usb: typec: Add number of altmodes partner attr
  usb: typec: Add plug num_altmodes sysfs attr
  platform/chrome: cros_ec_typec: Make disc_done flag partner-only
  platform/chrome: cros_ec_typec: Factor out PD identity parsing
  platform/chrome: cros_ec_typec: Rename discovery struct
  platform/chrome: cros_ec_typec: Register cable
  platform/chrome: cros_ec_typec: Store cable plug type
  platform/chrome: cros_ec_typec: Set partner num_altmodes
  platform/chrome: cros_ec_typec: Register SOP' cable plug
  platform/chrome: cros_ec_typec: Register plug altmodes

 Documentation/ABI/testing/sysfs-class-typec |  17 ++
 drivers/platform/chrome/cros_ec_typec.c     | 219 ++++++++++++++++----
 drivers/usb/typec/class.c                   | 139 ++++++++++++-
 include/linux/usb/pd_vdo.h                  |   4 +-
 include/linux/usb/typec.h                   |   2 +
 5 files changed, 343 insertions(+), 38 deletions(-)

-- 
2.29.2.299.gdc1121823c-goog


^ permalink raw reply	[flat|nested] 21+ messages in thread

* [PATCH v3 01/11] usb: pd: Add captive Type C cable type
  2020-11-16 20:11 [PATCH v3 00/11] chrome/platform: cros_ec_typec: Register cables, partner altmodes and plug altmodes Prashant Malani
@ 2020-11-16 20:11 ` Prashant Malani
  2020-11-16 20:11 ` [PATCH v3 02/11] usb: typec: Add number of altmodes partner attr Prashant Malani
                   ` (11 subsequent siblings)
  12 siblings, 0 replies; 21+ messages in thread
From: Prashant Malani @ 2020-11-16 20:11 UTC (permalink / raw)
  To: linux-kernel, linux-usb, gregkh, heikki.krogerus, enric.balletbo
  Cc: Prashant Malani, Benson Leung, Guenter Roeck

The USB Power Delivery Specification R3.0 adds a captive cable type
to the "USB Type-C plug to USB Type-C/Captive" field (Bits 19-18,
Passive/Active Cable VDO, Table 6-38 & 6-39).

Add the corresponding definition to the Cable VDO header. Also add a
helper macro to get the Type C cable connector type, when provided
the cable VDO.

Cc: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Signed-off-by: Prashant Malani <pmalani@chromium.org>
Reviewed-by: Benson Leung <bleung@chromium.org>
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
---

Changes in v3:
- Re-arranged patch order and combined it with related series of
  patches.
- Added Reviewed-by tags

Changes in v2:
- No changes.

 include/linux/usb/pd_vdo.h | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/include/linux/usb/pd_vdo.h b/include/linux/usb/pd_vdo.h
index 68bdc4e2f5a9..8c5cb5830754 100644
--- a/include/linux/usb/pd_vdo.h
+++ b/include/linux/usb/pd_vdo.h
@@ -177,7 +177,7 @@
  * <31:28> :: Cable HW version
  * <27:24> :: Cable FW version
  * <23:20> :: Reserved, Shall be set to zero
- * <19:18> :: type-C to Type-A/B/C (00b == A, 01 == B, 10 == C)
+ * <19:18> :: type-C to Type-A/B/C/Captive (00b == A, 01 == B, 10 == C, 11 == Captive)
  * <17>    :: Type-C to Plug/Receptacle (0b == plug, 1b == receptacle)
  * <16:13> :: cable latency (0001 == <10ns(~1m length))
  * <12:11> :: cable termination type (11b == both ends active VCONN req)
@@ -193,6 +193,7 @@
 #define CABLE_ATYPE		0
 #define CABLE_BTYPE		1
 #define CABLE_CTYPE		2
+#define CABLE_CAPTIVE		3
 #define CABLE_PLUG		0
 #define CABLE_RECEPTACLE	1
 #define CABLE_CURR_1A5		0
@@ -208,6 +209,7 @@
 	 | (tx1d) << 10 | (tx2d) << 9 | (rx1d) << 8 | (rx2d) << 7	\
 	 | ((cur) & 0x3) << 5 | (vps) << 4 | (sopp) << 3		\
 	 | ((usbss) & 0x7))
+#define VDO_TYPEC_CABLE_TYPE(vdo)	(((vdo) >> 18) & 0x3)
 
 /*
  * AMA VDO
-- 
2.29.2.299.gdc1121823c-goog


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [PATCH v3 02/11] usb: typec: Add number of altmodes partner attr
  2020-11-16 20:11 [PATCH v3 00/11] chrome/platform: cros_ec_typec: Register cables, partner altmodes and plug altmodes Prashant Malani
  2020-11-16 20:11 ` [PATCH v3 01/11] usb: pd: Add captive Type C cable type Prashant Malani
@ 2020-11-16 20:11 ` Prashant Malani
  2020-11-16 20:11 ` [PATCH v3 03/11] usb: typec: Add plug num_altmodes sysfs attr Prashant Malani
                   ` (10 subsequent siblings)
  12 siblings, 0 replies; 21+ messages in thread
From: Prashant Malani @ 2020-11-16 20:11 UTC (permalink / raw)
  To: linux-kernel, linux-usb, gregkh, heikki.krogerus, enric.balletbo
  Cc: Prashant Malani, Benson Leung, Guenter Roeck

Add a user-visible attribute for the number of alternate modes available
in a partner. This allows userspace to determine whether there are any
remaining alternate modes left to be registered by the kernel driver. It
can begin executing any policy state machine after all available
alternate modes have been registered with the connector class framework.

This value is set to "-1" initially, signifying that a valid number of
alternate modes haven't been set for the partner.

Also add a sysfs file which exposes this attribute. The file remains
hidden as long as the attribute value is -1.

Cc: Benson Leung <bleung@chromium.org>
Cc: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Signed-off-by: Prashant Malani <pmalani@chromium.org>
Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
---

Changes in v3:
- Re-arranged patch order and combined it with related series of
  patches.
- Added Reviewed-by tags

Changes in v2:
- Added ABI/testing documentation entry for added sysfs file.
- Changed name of the sysfs file to "number_of_alternate_modes" based on
  review comments.
- Added is_visible() logic suggested by Heikki in the comments of v1.
- Updated commit message.

 Documentation/ABI/testing/sysfs-class-typec |  8 +++
 drivers/usb/typec/class.c                   | 66 ++++++++++++++++++++-
 include/linux/usb/typec.h                   |  1 +
 3 files changed, 74 insertions(+), 1 deletion(-)

diff --git a/Documentation/ABI/testing/sysfs-class-typec b/Documentation/ABI/testing/sysfs-class-typec
index b834671522d6..73ac7b461ae5 100644
--- a/Documentation/ABI/testing/sysfs-class-typec
+++ b/Documentation/ABI/testing/sysfs-class-typec
@@ -134,6 +134,14 @@ Description:
 		Shows if the partner supports USB Power Delivery communication:
 		Valid values: yes, no
 
+What:		/sys/class/typec/<port>-partner/number_of_alternate_modes
+Date:		November 2020
+Contact:	Prashant Malani <pmalani@chromium.org>
+Description:
+		Shows the number of alternate modes which are advertised by the partner
+		during Power Delivery discovery. This file remains hidden until a value
+		greater than or equal to 0 is set by Type C port driver.
+
 What:		/sys/class/typec/<port>-partner>/identity/
 Date:		April 2017
 Contact:	Heikki Krogerus <heikki.krogerus@linux.intel.com>
diff --git a/drivers/usb/typec/class.c b/drivers/usb/typec/class.c
index 35eec707cb51..c7412ddbd311 100644
--- a/drivers/usb/typec/class.c
+++ b/drivers/usb/typec/class.c
@@ -33,6 +33,7 @@ struct typec_partner {
 	struct usb_pd_identity		*identity;
 	enum typec_accessory		accessory;
 	struct ida			mode_ids;
+	int				num_altmodes;
 };
 
 struct typec_port {
@@ -532,12 +533,43 @@ static ssize_t supports_usb_power_delivery_show(struct device *dev,
 }
 static DEVICE_ATTR_RO(supports_usb_power_delivery);
 
+static ssize_t number_of_alternate_modes_show(struct device *dev, struct device_attribute *attr,
+					      char *buf)
+{
+	struct typec_partner *p = to_typec_partner(dev);
+
+	return sysfs_emit(buf, "%d\n", p->num_altmodes);
+}
+static DEVICE_ATTR_RO(number_of_alternate_modes);
+
 static struct attribute *typec_partner_attrs[] = {
 	&dev_attr_accessory_mode.attr,
 	&dev_attr_supports_usb_power_delivery.attr,
+	&dev_attr_number_of_alternate_modes.attr,
+	NULL
+};
+
+static umode_t typec_partner_attr_is_visible(struct kobject *kobj, struct attribute *attr, int n)
+{
+	struct typec_partner *partner = to_typec_partner(kobj_to_dev(kobj));
+
+	if (attr == &dev_attr_number_of_alternate_modes.attr) {
+		if (partner->num_altmodes < 0)
+			return 0;
+	}
+
+	return attr->mode;
+}
+
+static struct attribute_group typec_partner_group = {
+	.is_visible = typec_partner_attr_is_visible,
+	.attrs = typec_partner_attrs
+};
+
+static const struct attribute_group *typec_partner_groups[] = {
+	&typec_partner_group,
 	NULL
 };
-ATTRIBUTE_GROUPS(typec_partner);
 
 static void typec_partner_release(struct device *dev)
 {
@@ -570,6 +602,37 @@ int typec_partner_set_identity(struct typec_partner *partner)
 }
 EXPORT_SYMBOL_GPL(typec_partner_set_identity);
 
+/**
+ * typec_partner_set_num_altmodes - Set the number of available partner altmodes
+ * @partner: The partner to be updated.
+ * @num_alt_modes: The number of altmodes we want to specify as available.
+ *
+ * This routine is used to report the number of alternate modes supported by the
+ * partner. This value is *not* enforced in alternate mode registration routines.
+ *
+ * @partner.num_altmodes is set to -1 on partner registration, denoting that
+ * a valid value has not been set for it yet.
+ *
+ * Returns 0 on success or negative error number on failure.
+ */
+int typec_partner_set_num_altmodes(struct typec_partner *partner, int num_altmodes)
+{
+	int ret;
+
+	if (num_altmodes < 0)
+		return -EINVAL;
+
+	partner->num_altmodes = num_altmodes;
+	ret = sysfs_update_group(&partner->dev.kobj, &typec_partner_group);
+	if (ret < 0)
+		return ret;
+
+	sysfs_notify(&partner->dev.kobj, NULL, "number_of_alternate_modes");
+
+	return 0;
+}
+EXPORT_SYMBOL_GPL(typec_partner_set_num_altmodes);
+
 /**
  * typec_partner_register_altmode - Register USB Type-C Partner Alternate Mode
  * @partner: USB Type-C Partner that supports the alternate mode
@@ -612,6 +675,7 @@ struct typec_partner *typec_register_partner(struct typec_port *port,
 	ida_init(&partner->mode_ids);
 	partner->usb_pd = desc->usb_pd;
 	partner->accessory = desc->accessory;
+	partner->num_altmodes = -1;
 
 	if (desc->identity) {
 		/*
diff --git a/include/linux/usb/typec.h b/include/linux/usb/typec.h
index 6be558045942..bc6b1a71cb8a 100644
--- a/include/linux/usb/typec.h
+++ b/include/linux/usb/typec.h
@@ -126,6 +126,7 @@ struct typec_altmode_desc {
 	enum typec_port_data	roles;
 };
 
+int typec_partner_set_num_altmodes(struct typec_partner *partner, int num_altmodes);
 struct typec_altmode
 *typec_partner_register_altmode(struct typec_partner *partner,
 				const struct typec_altmode_desc *desc);
-- 
2.29.2.299.gdc1121823c-goog


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [PATCH v3 03/11] usb: typec: Add plug num_altmodes sysfs attr
  2020-11-16 20:11 [PATCH v3 00/11] chrome/platform: cros_ec_typec: Register cables, partner altmodes and plug altmodes Prashant Malani
  2020-11-16 20:11 ` [PATCH v3 01/11] usb: pd: Add captive Type C cable type Prashant Malani
  2020-11-16 20:11 ` [PATCH v3 02/11] usb: typec: Add number of altmodes partner attr Prashant Malani
@ 2020-11-16 20:11 ` Prashant Malani
  2020-11-17 12:41   ` Heikki Krogerus
  2020-11-16 20:11 ` [PATCH v3 04/11] platform/chrome: cros_ec_typec: Make disc_done flag partner-only Prashant Malani
                   ` (9 subsequent siblings)
  12 siblings, 1 reply; 21+ messages in thread
From: Prashant Malani @ 2020-11-16 20:11 UTC (permalink / raw)
  To: linux-kernel, linux-usb, gregkh, heikki.krogerus, enric.balletbo
  Cc: Prashant Malani

Add a field to the typec_plug struct to record the number of available
altmodes as well as the corresponding sysfs attribute to expose this to
userspace.

This allows userspace to determine whether there are any
remaining alternate modes left to be registered by the kernel driver. It
can begin executing any policy state machine after all available
alternate modes have been registered with the connector class framework.

This value is set to "-1" initially, signifying that a valid number of
alternate modes haven't been set for the plug. The sysfs file remains
hidden as long as the attribute value is -1.

We re-use the partner attribute for number_of_alternate_modes since the
usage and name is similar, and update the corresponding *_show() command
to support both partner and plugs.

Signed-off-by: Prashant Malani <pmalani@chromium.org>
---

Changes in v3:
- Re-arranged patch order and combined it with related series of
  patches.

No version v2.

 Documentation/ABI/testing/sysfs-class-typec |  9 +++
 drivers/usb/typec/class.c                   | 77 ++++++++++++++++++++-
 include/linux/usb/typec.h                   |  1 +
 3 files changed, 85 insertions(+), 2 deletions(-)

diff --git a/Documentation/ABI/testing/sysfs-class-typec b/Documentation/ABI/testing/sysfs-class-typec
index 73ac7b461ae5..29eccf5fb8ed 100644
--- a/Documentation/ABI/testing/sysfs-class-typec
+++ b/Documentation/ABI/testing/sysfs-class-typec
@@ -204,6 +204,15 @@ Description:
 		- type-c
 		- captive
 
+What:		/sys/class/typec/<port>-<plug>/number_of_alternate_modes
+Date:		November 2020
+Contact:	Prashant Malani <pmalani@chromium.org>
+Description:
+		Shows the number of alternate modes which are advertised by the plug
+		associated with a particular cable during Power Delivery discovery.
+		This file remains hidden until a value greater than or equal to 0
+		is set by Type C port driver.
+
 What:		/sys/class/typec/<port>-cable/identity/
 Date:		April 2017
 Contact:	Heikki Krogerus <heikki.krogerus@linux.intel.com>
diff --git a/drivers/usb/typec/class.c b/drivers/usb/typec/class.c
index c7412ddbd311..e68798599ca8 100644
--- a/drivers/usb/typec/class.c
+++ b/drivers/usb/typec/class.c
@@ -18,6 +18,7 @@ struct typec_plug {
 	struct device			dev;
 	enum typec_plug_index		index;
 	struct ida			mode_ids;
+	int				num_altmodes;
 };
 
 struct typec_cable {
@@ -536,9 +537,21 @@ static DEVICE_ATTR_RO(supports_usb_power_delivery);
 static ssize_t number_of_alternate_modes_show(struct device *dev, struct device_attribute *attr,
 					      char *buf)
 {
-	struct typec_partner *p = to_typec_partner(dev);
+	struct typec_partner *partner;
+	struct typec_plug *plug;
+	int num_altmodes;
+
+	if (is_typec_partner(dev)) {
+		partner = to_typec_partner(dev);
+		num_altmodes = partner->num_altmodes;
+	} else if (is_typec_plug(dev)) {
+		plug = to_typec_plug(dev);
+		num_altmodes = plug->num_altmodes;
+	} else {
+		return 0;
+	}
 
-	return sysfs_emit(buf, "%d\n", p->num_altmodes);
+	return sysfs_emit(buf, "%d\n", num_altmodes);
 }
 static DEVICE_ATTR_RO(number_of_alternate_modes);
 
@@ -726,11 +739,70 @@ static void typec_plug_release(struct device *dev)
 	kfree(plug);
 }
 
+static struct attribute *typec_plug_attrs[] = {
+	&dev_attr_number_of_alternate_modes.attr,
+	NULL
+};
+
+static umode_t typec_plug_attr_is_visible(struct kobject *kobj, struct attribute *attr, int n)
+{
+	struct typec_plug *plug = to_typec_plug(kobj_to_dev(kobj));
+
+	if (attr == &dev_attr_number_of_alternate_modes.attr) {
+		if (plug->num_altmodes < 0)
+			return 0;
+	}
+
+	return attr->mode;
+}
+
+static struct attribute_group typec_plug_group = {
+	.is_visible = typec_plug_attr_is_visible,
+	.attrs = typec_plug_attrs
+};
+
+static const struct attribute_group *typec_plug_groups[] = {
+	&typec_plug_group,
+	NULL
+};
+
 static const struct device_type typec_plug_dev_type = {
 	.name = "typec_plug",
+	.groups = typec_plug_groups,
 	.release = typec_plug_release,
 };
 
+/**
+ * typec_plug_set_num_altmodes - Set the number of available plug altmodes
+ * @plug: The plug to be updated.
+ * @num_altmodes: The number of altmodes we want to specify as available.
+ *
+ * This routine is used to report the number of alternate modes supported by the
+ * plug. This value is *not* enforced in alternate mode registration routines.
+ *
+ * @plug.num_altmodes is set to -1 on plug registration, denoting that
+ * a valid value has not been set for it yet.
+ *
+ * Returns 0 on success or negative error number on failure.
+ */
+int typec_plug_set_num_altmodes(struct typec_plug *plug, int num_altmodes)
+{
+	int ret;
+
+	if (num_altmodes < 0)
+		return -EINVAL;
+
+	plug->num_altmodes = num_altmodes;
+	ret = sysfs_update_group(&plug->dev.kobj, &typec_plug_group);
+	if (ret < 0)
+		return ret;
+
+	sysfs_notify(&plug->dev.kobj, NULL, "number_of_alternate_modes");
+
+	return 0;
+}
+EXPORT_SYMBOL_GPL(typec_plug_set_num_altmodes);
+
 /**
  * typec_plug_register_altmode - Register USB Type-C Cable Plug Alternate Mode
  * @plug: USB Type-C Cable Plug that supports the alternate mode
@@ -776,6 +848,7 @@ struct typec_plug *typec_register_plug(struct typec_cable *cable,
 	sprintf(name, "plug%d", desc->index);
 
 	ida_init(&plug->mode_ids);
+	plug->num_altmodes = -1;
 	plug->index = desc->index;
 	plug->dev.class = typec_class;
 	plug->dev.parent = &cable->dev;
diff --git a/include/linux/usb/typec.h b/include/linux/usb/typec.h
index bc6b1a71cb8a..54475323f83b 100644
--- a/include/linux/usb/typec.h
+++ b/include/linux/usb/typec.h
@@ -130,6 +130,7 @@ int typec_partner_set_num_altmodes(struct typec_partner *partner, int num_altmod
 struct typec_altmode
 *typec_partner_register_altmode(struct typec_partner *partner,
 				const struct typec_altmode_desc *desc);
+int typec_plug_set_num_altmodes(struct typec_plug *plug, int num_altmodes);
 struct typec_altmode
 *typec_plug_register_altmode(struct typec_plug *plug,
 			     const struct typec_altmode_desc *desc);
-- 
2.29.2.299.gdc1121823c-goog


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [PATCH v3 04/11] platform/chrome: cros_ec_typec: Make disc_done flag partner-only
  2020-11-16 20:11 [PATCH v3 00/11] chrome/platform: cros_ec_typec: Register cables, partner altmodes and plug altmodes Prashant Malani
                   ` (2 preceding siblings ...)
  2020-11-16 20:11 ` [PATCH v3 03/11] usb: typec: Add plug num_altmodes sysfs attr Prashant Malani
@ 2020-11-16 20:11 ` Prashant Malani
  2020-11-16 20:11 ` [PATCH v3 05/11] platform/chrome: cros_ec_typec: Factor out PD identity parsing Prashant Malani
                   ` (8 subsequent siblings)
  12 siblings, 0 replies; 21+ messages in thread
From: Prashant Malani @ 2020-11-16 20:11 UTC (permalink / raw)
  To: linux-kernel, linux-usb, gregkh, heikki.krogerus, enric.balletbo
  Cc: Prashant Malani, Benson Leung, Guenter Roeck

Change the disc_done flag, which indicates whether PD discovery is
complete, to sop_disc_done instead, since we will process SOP and SOP'
discovery data separately.

Signed-off-by: Prashant Malani <pmalani@chromium.org>
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
---

Changes in v3:
- Re-arranged patch order and combined it with related series of
  patches.
- Added Reviewed-by tags

Changes in v2:
- No changes.

 drivers/platform/chrome/cros_ec_typec.c | 19 +++++++------------
 1 file changed, 7 insertions(+), 12 deletions(-)

diff --git a/drivers/platform/chrome/cros_ec_typec.c b/drivers/platform/chrome/cros_ec_typec.c
index ce031a10eb1b..801c3d2c1fbd 100644
--- a/drivers/platform/chrome/cros_ec_typec.c
+++ b/drivers/platform/chrome/cros_ec_typec.c
@@ -57,8 +57,8 @@ struct cros_typec_port {
 	/* Port alt modes. */
 	struct typec_altmode p_altmode[CROS_EC_ALTMODE_MAX];
 
-	/* Flag indicating that PD discovery data parsing is completed. */
-	bool disc_done;
+	/* Flag indicating that PD partner discovery data parsing is completed. */
+	bool sop_disc_done;
 	struct ec_response_typec_discovery *sop_disc;
 	struct list_head partner_mode_list;
 };
@@ -210,7 +210,7 @@ static void cros_typec_remove_partner(struct cros_typec_data *typec,
 	typec_unregister_partner(port->partner);
 	port->partner = NULL;
 	memset(&port->p_identity, 0, sizeof(port->p_identity));
-	port->disc_done = false;
+	port->sop_disc_done = false;
 }
 
 static void cros_unregister_ports(struct cros_typec_data *typec)
@@ -727,18 +727,13 @@ static void cros_typec_handle_status(struct cros_typec_data *typec, int port_num
 		return;
 	}
 
-	if (typec->ports[port_num]->disc_done)
-		return;
-
 	/* Handle any events appropriately. */
-	if (resp.events & PD_STATUS_EVENT_SOP_DISC_DONE) {
+	if (resp.events & PD_STATUS_EVENT_SOP_DISC_DONE && !typec->ports[port_num]->sop_disc_done) {
 		ret = cros_typec_handle_sop_disc(typec, port_num);
-		if (ret < 0) {
+		if (ret < 0)
 			dev_err(typec->dev, "Couldn't parse SOP Disc data, port: %d\n", port_num);
-			return;
-		}
-
-		typec->ports[port_num]->disc_done = true;
+		else
+			typec->ports[port_num]->sop_disc_done = true;
 	}
 }
 
-- 
2.29.2.299.gdc1121823c-goog


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [PATCH v3 05/11] platform/chrome: cros_ec_typec: Factor out PD identity parsing
  2020-11-16 20:11 [PATCH v3 00/11] chrome/platform: cros_ec_typec: Register cables, partner altmodes and plug altmodes Prashant Malani
                   ` (3 preceding siblings ...)
  2020-11-16 20:11 ` [PATCH v3 04/11] platform/chrome: cros_ec_typec: Make disc_done flag partner-only Prashant Malani
@ 2020-11-16 20:11 ` Prashant Malani
  2020-11-16 20:11 ` [PATCH v3 06/11] platform/chrome: cros_ec_typec: Rename discovery struct Prashant Malani
                   ` (7 subsequent siblings)
  12 siblings, 0 replies; 21+ messages in thread
From: Prashant Malani @ 2020-11-16 20:11 UTC (permalink / raw)
  To: linux-kernel, linux-usb, gregkh, heikki.krogerus, enric.balletbo
  Cc: Prashant Malani, Benson Leung, Guenter Roeck

Factor out the PD identity parsing code into a separate function. This
way it can be re-used for Cable PD identity parsing in future patches.

No functional changes are introduced by this patch.

Signed-off-by: Prashant Malani <pmalani@chromium.org>
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
---

Changes in v3:
- Re-arranged patch order and combined it with related series of
  patches.
- Added Reviewed-by tags

Changes in v2:
- No changes.

 drivers/platform/chrome/cros_ec_typec.c | 35 ++++++++++++++++---------
 1 file changed, 23 insertions(+), 12 deletions(-)

diff --git a/drivers/platform/chrome/cros_ec_typec.c b/drivers/platform/chrome/cros_ec_typec.c
index 801c3d2c1fbd..f6d3c37c2c27 100644
--- a/drivers/platform/chrome/cros_ec_typec.c
+++ b/drivers/platform/chrome/cros_ec_typec.c
@@ -657,6 +657,28 @@ static int cros_typec_register_altmodes(struct cros_typec_data *typec, int port_
 	return ret;
 }
 
+/*
+ * Parse the PD identity data from the EC PD discovery responses and copy that to the supplied
+ * PD identity struct.
+ */
+static void cros_typec_parse_pd_identity(struct usb_pd_identity *id,
+					 struct ec_response_typec_discovery *disc)
+{
+	int i;
+
+	/* First, update the PD identity VDOs for the partner. */
+	if (disc->identity_count > 0)
+		id->id_header = disc->discovery_vdo[0];
+	if (disc->identity_count > 1)
+		id->cert_stat = disc->discovery_vdo[1];
+	if (disc->identity_count > 2)
+		id->product = disc->discovery_vdo[2];
+
+	/* Copy the remaining identity VDOs till a maximum of 6. */
+	for (i = 3; i < disc->identity_count && i < VDO_MAX_OBJECTS; i++)
+		id->vdo[i - 3] = disc->discovery_vdo[i];
+}
+
 static int cros_typec_handle_sop_disc(struct cros_typec_data *typec, int port_num)
 {
 	struct cros_typec_port *port = typec->ports[port_num];
@@ -666,7 +688,6 @@ static int cros_typec_handle_sop_disc(struct cros_typec_data *typec, int port_nu
 		.partner_type = TYPEC_PARTNER_SOP,
 	};
 	int ret = 0;
-	int i;
 
 	if (!port->partner) {
 		dev_err(typec->dev,
@@ -684,17 +705,7 @@ static int cros_typec_handle_sop_disc(struct cros_typec_data *typec, int port_nu
 		goto disc_exit;
 	}
 
-	/* First, update the PD identity VDOs for the partner. */
-	if (sop_disc->identity_count > 0)
-		port->p_identity.id_header = sop_disc->discovery_vdo[0];
-	if (sop_disc->identity_count > 1)
-		port->p_identity.cert_stat = sop_disc->discovery_vdo[1];
-	if (sop_disc->identity_count > 2)
-		port->p_identity.product = sop_disc->discovery_vdo[2];
-
-	/* Copy the remaining identity VDOs till a maximum of 6. */
-	for (i = 3; i < sop_disc->identity_count && i < VDO_MAX_OBJECTS; i++)
-		port->p_identity.vdo[i - 3] = sop_disc->discovery_vdo[i];
+	cros_typec_parse_pd_identity(&port->p_identity, sop_disc);
 
 	ret = typec_partner_set_identity(port->partner);
 	if (ret < 0) {
-- 
2.29.2.299.gdc1121823c-goog


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [PATCH v3 06/11] platform/chrome: cros_ec_typec: Rename discovery struct
  2020-11-16 20:11 [PATCH v3 00/11] chrome/platform: cros_ec_typec: Register cables, partner altmodes and plug altmodes Prashant Malani
                   ` (4 preceding siblings ...)
  2020-11-16 20:11 ` [PATCH v3 05/11] platform/chrome: cros_ec_typec: Factor out PD identity parsing Prashant Malani
@ 2020-11-16 20:11 ` Prashant Malani
  2020-11-16 20:11 ` [PATCH v3 07/11] platform/chrome: cros_ec_typec: Register cable Prashant Malani
                   ` (6 subsequent siblings)
  12 siblings, 0 replies; 21+ messages in thread
From: Prashant Malani @ 2020-11-16 20:11 UTC (permalink / raw)
  To: linux-kernel, linux-usb, gregkh, heikki.krogerus, enric.balletbo
  Cc: Prashant Malani, Benson Leung, Guenter Roeck

Rename the sop_disc data struct which is used to store PD discovery data
to the more generic name of disc_data. It can then be re-used to store
and process cable discovery data.

Signed-off-by: Prashant Malani <pmalani@chromium.org>
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
---

Changes in v3:
- Re-arranged patch order and combined it with related series of
  patches.
- Added Reviewed-by tags

Changes in v2:
- No changes.

 drivers/platform/chrome/cros_ec_typec.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/platform/chrome/cros_ec_typec.c b/drivers/platform/chrome/cros_ec_typec.c
index f6d3c37c2c27..3c8ff07c8803 100644
--- a/drivers/platform/chrome/cros_ec_typec.c
+++ b/drivers/platform/chrome/cros_ec_typec.c
@@ -59,7 +59,7 @@ struct cros_typec_port {
 
 	/* Flag indicating that PD partner discovery data parsing is completed. */
 	bool sop_disc_done;
-	struct ec_response_typec_discovery *sop_disc;
+	struct ec_response_typec_discovery *disc_data;
 	struct list_head partner_mode_list;
 };
 
@@ -323,8 +323,8 @@ static int cros_typec_init_ports(struct cros_typec_data *typec)
 
 		cros_typec_register_port_altmodes(typec, port_num);
 
-		cros_port->sop_disc = devm_kzalloc(dev, EC_PROTO2_MAX_RESPONSE_SIZE, GFP_KERNEL);
-		if (!cros_port->sop_disc) {
+		cros_port->disc_data = devm_kzalloc(dev, EC_PROTO2_MAX_RESPONSE_SIZE, GFP_KERNEL);
+		if (!cros_port->disc_data) {
 			ret = -ENOMEM;
 			goto unregister_ports;
 		}
@@ -617,7 +617,7 @@ static int cros_typec_get_mux_info(struct cros_typec_data *typec, int port_num,
 static int cros_typec_register_altmodes(struct cros_typec_data *typec, int port_num)
 {
 	struct cros_typec_port *port = typec->ports[port_num];
-	struct ec_response_typec_discovery *sop_disc = port->sop_disc;
+	struct ec_response_typec_discovery *sop_disc = port->disc_data;
 	struct cros_typec_altmode_node *node;
 	struct typec_altmode_desc desc;
 	struct typec_altmode *amode;
@@ -682,7 +682,7 @@ static void cros_typec_parse_pd_identity(struct usb_pd_identity *id,
 static int cros_typec_handle_sop_disc(struct cros_typec_data *typec, int port_num)
 {
 	struct cros_typec_port *port = typec->ports[port_num];
-	struct ec_response_typec_discovery *sop_disc = port->sop_disc;
+	struct ec_response_typec_discovery *sop_disc = port->disc_data;
 	struct ec_params_typec_discovery req = {
 		.port = port_num,
 		.partner_type = TYPEC_PARTNER_SOP,
-- 
2.29.2.299.gdc1121823c-goog


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [PATCH v3 07/11] platform/chrome: cros_ec_typec: Register cable
  2020-11-16 20:11 [PATCH v3 00/11] chrome/platform: cros_ec_typec: Register cables, partner altmodes and plug altmodes Prashant Malani
                   ` (5 preceding siblings ...)
  2020-11-16 20:11 ` [PATCH v3 06/11] platform/chrome: cros_ec_typec: Rename discovery struct Prashant Malani
@ 2020-11-16 20:11 ` Prashant Malani
  2020-11-16 20:11 ` [PATCH v3 08/11] platform/chrome: cros_ec_typec: Store cable plug type Prashant Malani
                   ` (5 subsequent siblings)
  12 siblings, 0 replies; 21+ messages in thread
From: Prashant Malani @ 2020-11-16 20:11 UTC (permalink / raw)
  To: linux-kernel, linux-usb, gregkh, heikki.krogerus, enric.balletbo
  Cc: Prashant Malani, Benson Leung, Guenter Roeck

When the Chrome Embedded Controller notifies the driver that SOP'
discovery is complete, retrieve the PD discovery data and register a
cable object with the Type C connector class framework.

Cc: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Signed-off-by: Prashant Malani <pmalani@chromium.org>
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
---

Changes in v3:
- Re-arranged patch order and combined it with related series of
  patches.
- Added Reviewed-by tags

Changes in v2:
- No changes.

 drivers/platform/chrome/cros_ec_typec.c | 67 +++++++++++++++++++++++++
 1 file changed, 67 insertions(+)

diff --git a/drivers/platform/chrome/cros_ec_typec.c b/drivers/platform/chrome/cros_ec_typec.c
index 3c8ff07c8803..5e7f0b4ebbec 100644
--- a/drivers/platform/chrome/cros_ec_typec.c
+++ b/drivers/platform/chrome/cros_ec_typec.c
@@ -44,8 +44,11 @@ struct cros_typec_port {
 	/* Initial capabilities for the port. */
 	struct typec_capability caps;
 	struct typec_partner *partner;
+	struct typec_cable *cable;
 	/* Port partner PD identity info. */
 	struct usb_pd_identity p_identity;
+	/* Port cable PD identity info. */
+	struct usb_pd_identity c_identity;
 	struct typec_switch *ori_sw;
 	struct typec_mux *mux;
 	struct usb_role_switch *role_sw;
@@ -59,6 +62,7 @@ struct cros_typec_port {
 
 	/* Flag indicating that PD partner discovery data parsing is completed. */
 	bool sop_disc_done;
+	bool sop_prime_disc_done;
 	struct ec_response_typec_discovery *disc_data;
 	struct list_head partner_mode_list;
 };
@@ -213,6 +217,17 @@ static void cros_typec_remove_partner(struct cros_typec_data *typec,
 	port->sop_disc_done = false;
 }
 
+static void cros_typec_remove_cable(struct cros_typec_data *typec,
+				    int port_num)
+{
+	struct cros_typec_port *port = typec->ports[port_num];
+
+	typec_unregister_cable(port->cable);
+	port->cable = NULL;
+	memset(&port->c_identity, 0, sizeof(port->c_identity));
+	port->sop_prime_disc_done = false;
+}
+
 static void cros_unregister_ports(struct cros_typec_data *typec)
 {
 	int i;
@@ -224,6 +239,9 @@ static void cros_unregister_ports(struct cros_typec_data *typec)
 		if (typec->ports[i]->partner)
 			cros_typec_remove_partner(typec, i);
 
+		if (typec->ports[i]->cable)
+			cros_typec_remove_cable(typec, i);
+
 		usb_role_switch_put(typec->ports[i]->role_sw);
 		typec_switch_put(typec->ports[i]->ori_sw);
 		typec_mux_put(typec->ports[i]->mux);
@@ -600,6 +618,9 @@ static void cros_typec_set_port_params_v1(struct cros_typec_data *typec,
 		if (!typec->ports[port_num]->partner)
 			return;
 		cros_typec_remove_partner(typec, port_num);
+
+		if (typec->ports[port_num]->cable)
+			cros_typec_remove_cable(typec, port_num);
 	}
 }
 
@@ -679,6 +700,43 @@ static void cros_typec_parse_pd_identity(struct usb_pd_identity *id,
 		id->vdo[i - 3] = disc->discovery_vdo[i];
 }
 
+static int cros_typec_handle_sop_prime_disc(struct cros_typec_data *typec, int port_num)
+{
+	struct cros_typec_port *port = typec->ports[port_num];
+	struct ec_response_typec_discovery *disc = port->disc_data;
+	struct typec_cable_desc desc = {};
+	struct ec_params_typec_discovery req = {
+		.port = port_num,
+		.partner_type = TYPEC_PARTNER_SOP_PRIME,
+	};
+	int ret = 0;
+
+	memset(disc, 0, EC_PROTO2_MAX_RESPONSE_SIZE);
+	ret = cros_typec_ec_command(typec, 0, EC_CMD_TYPEC_DISCOVERY, &req, sizeof(req),
+				    disc, EC_PROTO2_MAX_RESPONSE_SIZE);
+	if (ret < 0) {
+		dev_err(typec->dev, "Failed to get SOP' discovery data for port: %d\n", port_num);
+		goto sop_prime_disc_exit;
+	}
+
+	/* Parse the PD identity data, even if only 0s were returned. */
+	cros_typec_parse_pd_identity(&port->c_identity, disc);
+
+	if (disc->identity_count != 0)
+		desc.active = PD_IDH_PTYPE(port->c_identity.id_header) == IDH_PTYPE_ACABLE;
+
+	desc.identity = &port->c_identity;
+
+	port->cable = typec_register_cable(port->port, &desc);
+	if (IS_ERR(port->cable)) {
+		ret = PTR_ERR(port->cable);
+		port->cable = NULL;
+	}
+
+sop_prime_disc_exit:
+	return ret;
+}
+
 static int cros_typec_handle_sop_disc(struct cros_typec_data *typec, int port_num)
 {
 	struct cros_typec_port *port = typec->ports[port_num];
@@ -746,6 +804,15 @@ static void cros_typec_handle_status(struct cros_typec_data *typec, int port_num
 		else
 			typec->ports[port_num]->sop_disc_done = true;
 	}
+
+	if (resp.events & PD_STATUS_EVENT_SOP_PRIME_DISC_DONE &&
+	    !typec->ports[port_num]->sop_prime_disc_done) {
+		ret = cros_typec_handle_sop_prime_disc(typec, port_num);
+		if (ret < 0)
+			dev_err(typec->dev, "Couldn't parse SOP' Disc data, port: %d\n", port_num);
+		else
+			typec->ports[port_num]->sop_prime_disc_done = true;
+	}
 }
 
 static int cros_typec_port_update(struct cros_typec_data *typec, int port_num)
-- 
2.29.2.299.gdc1121823c-goog


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [PATCH v3 08/11] platform/chrome: cros_ec_typec: Store cable plug type
  2020-11-16 20:11 [PATCH v3 00/11] chrome/platform: cros_ec_typec: Register cables, partner altmodes and plug altmodes Prashant Malani
                   ` (6 preceding siblings ...)
  2020-11-16 20:11 ` [PATCH v3 07/11] platform/chrome: cros_ec_typec: Register cable Prashant Malani
@ 2020-11-16 20:11 ` Prashant Malani
  2020-11-16 20:11 ` [PATCH v3 09/11] platform/chrome: cros_ec_typec: Set partner num_altmodes Prashant Malani
                   ` (4 subsequent siblings)
  12 siblings, 0 replies; 21+ messages in thread
From: Prashant Malani @ 2020-11-16 20:11 UTC (permalink / raw)
  To: linux-kernel, linux-usb, gregkh, heikki.krogerus, enric.balletbo
  Cc: Prashant Malani, Benson Leung, Guenter Roeck

Use the PD VDO Type C cable plug type macro to retrieve and store the
cable plug type in the cable descriptor.

Cc: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Prashant Malani <pmalani@chromium.org>
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
---

Changes in v3:
- Re-arranged patch order and combined it with related series of
  patches.
- Added Reviewed-by tags

Changes in v2:
- No changes.

 drivers/platform/chrome/cros_ec_typec.c | 21 ++++++++++++++++++++-
 1 file changed, 20 insertions(+), 1 deletion(-)

diff --git a/drivers/platform/chrome/cros_ec_typec.c b/drivers/platform/chrome/cros_ec_typec.c
index 5e7f0b4ebbec..cf609aa10567 100644
--- a/drivers/platform/chrome/cros_ec_typec.c
+++ b/drivers/platform/chrome/cros_ec_typec.c
@@ -709,6 +709,7 @@ static int cros_typec_handle_sop_prime_disc(struct cros_typec_data *typec, int p
 		.port = port_num,
 		.partner_type = TYPEC_PARTNER_SOP_PRIME,
 	};
+	u32 cable_plug_type;
 	int ret = 0;
 
 	memset(disc, 0, EC_PROTO2_MAX_RESPONSE_SIZE);
@@ -722,8 +723,26 @@ static int cros_typec_handle_sop_prime_disc(struct cros_typec_data *typec, int p
 	/* Parse the PD identity data, even if only 0s were returned. */
 	cros_typec_parse_pd_identity(&port->c_identity, disc);
 
-	if (disc->identity_count != 0)
+	if (disc->identity_count != 0) {
+		cable_plug_type = VDO_TYPEC_CABLE_TYPE(port->c_identity.vdo[0]);
+		switch (cable_plug_type) {
+		case CABLE_ATYPE:
+			desc.type = USB_PLUG_TYPE_A;
+			break;
+		case CABLE_BTYPE:
+			desc.type = USB_PLUG_TYPE_B;
+			break;
+		case CABLE_CTYPE:
+			desc.type = USB_PLUG_TYPE_C;
+			break;
+		case CABLE_CAPTIVE:
+			desc.type = USB_PLUG_CAPTIVE;
+			break;
+		default:
+			desc.type = USB_PLUG_NONE;
+		}
 		desc.active = PD_IDH_PTYPE(port->c_identity.id_header) == IDH_PTYPE_ACABLE;
+	}
 
 	desc.identity = &port->c_identity;
 
-- 
2.29.2.299.gdc1121823c-goog


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [PATCH v3 09/11] platform/chrome: cros_ec_typec: Set partner num_altmodes
  2020-11-16 20:11 [PATCH v3 00/11] chrome/platform: cros_ec_typec: Register cables, partner altmodes and plug altmodes Prashant Malani
                   ` (7 preceding siblings ...)
  2020-11-16 20:11 ` [PATCH v3 08/11] platform/chrome: cros_ec_typec: Store cable plug type Prashant Malani
@ 2020-11-16 20:11 ` Prashant Malani
  2020-11-16 20:11 ` [PATCH v3 10/11] platform/chrome: cros_ec_typec: Register SOP' cable plug Prashant Malani
                   ` (3 subsequent siblings)
  12 siblings, 0 replies; 21+ messages in thread
From: Prashant Malani @ 2020-11-16 20:11 UTC (permalink / raw)
  To: linux-kernel, linux-usb, gregkh, heikki.krogerus, enric.balletbo
  Cc: Prashant Malani, Benson Leung, Guenter Roeck

Set the number of altmodes available for a registered partner using the
Type C connector class framework routine.

Cc: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Signed-off-by: Prashant Malani <pmalani@chromium.org>
Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
---

Changes in v3:
- Re-arranged patch order and combined it with related series of
  patches.
- Added Reviewed-by tags

Changes in v2:
- Patch introduced for the first time in v2.

 drivers/platform/chrome/cros_ec_typec.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/drivers/platform/chrome/cros_ec_typec.c b/drivers/platform/chrome/cros_ec_typec.c
index cf609aa10567..ad5e37bfd45d 100644
--- a/drivers/platform/chrome/cros_ec_typec.c
+++ b/drivers/platform/chrome/cros_ec_typec.c
@@ -642,6 +642,7 @@ static int cros_typec_register_altmodes(struct cros_typec_data *typec, int port_
 	struct cros_typec_altmode_node *node;
 	struct typec_altmode_desc desc;
 	struct typec_altmode *amode;
+	int num_altmodes = 0;
 	int ret = 0;
 	int i, j;
 
@@ -668,9 +669,16 @@ static int cros_typec_register_altmodes(struct cros_typec_data *typec, int port_
 
 			node->amode = amode;
 			list_add_tail(&node->list, &port->partner_mode_list);
+			num_altmodes++;
 		}
 	}
 
+	ret = typec_partner_set_num_altmodes(port->partner, num_altmodes);
+	if (ret < 0) {
+		dev_err(typec->dev, "Unable to set partner num_altmodes for port: %d\n", port_num);
+		goto err_cleanup;
+	}
+
 	return 0;
 
 err_cleanup:
-- 
2.29.2.299.gdc1121823c-goog


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [PATCH v3 10/11] platform/chrome: cros_ec_typec: Register SOP' cable plug
  2020-11-16 20:11 [PATCH v3 00/11] chrome/platform: cros_ec_typec: Register cables, partner altmodes and plug altmodes Prashant Malani
                   ` (8 preceding siblings ...)
  2020-11-16 20:11 ` [PATCH v3 09/11] platform/chrome: cros_ec_typec: Set partner num_altmodes Prashant Malani
@ 2020-11-16 20:11 ` Prashant Malani
  2020-11-17 12:45   ` Heikki Krogerus
  2020-11-16 20:11 ` [PATCH v3 11/11] platform/chrome: cros_ec_typec: Register plug altmodes Prashant Malani
                   ` (2 subsequent siblings)
  12 siblings, 1 reply; 21+ messages in thread
From: Prashant Malani @ 2020-11-16 20:11 UTC (permalink / raw)
  To: linux-kernel, linux-usb, gregkh, heikki.krogerus, enric.balletbo
  Cc: Prashant Malani, Benson Leung, Guenter Roeck

In order to register cable alternate modes, we need to first register a
plug object. Use the Type C connector class framework to register a SOP'
plug for this purpose.

Since a cable and plug go hand in hand, we can handle the registration
and removal together.

Signed-off-by: Prashant Malani <pmalani@chromium.org>
---

Changes in v3:
- Re-arranged patch order and combined it with related series of
  patches.

No version v2.

 drivers/platform/chrome/cros_ec_typec.c | 35 ++++++++++++++++++-------
 1 file changed, 26 insertions(+), 9 deletions(-)

diff --git a/drivers/platform/chrome/cros_ec_typec.c b/drivers/platform/chrome/cros_ec_typec.c
index ad5e37bfd45d..d2e154ae2362 100644
--- a/drivers/platform/chrome/cros_ec_typec.c
+++ b/drivers/platform/chrome/cros_ec_typec.c
@@ -45,6 +45,8 @@ struct cros_typec_port {
 	struct typec_capability caps;
 	struct typec_partner *partner;
 	struct typec_cable *cable;
+	/* SOP' plug. */
+	struct typec_plug *plug;
 	/* Port partner PD identity info. */
 	struct usb_pd_identity p_identity;
 	/* Port cable PD identity info. */
@@ -222,6 +224,8 @@ static void cros_typec_remove_cable(struct cros_typec_data *typec,
 {
 	struct cros_typec_port *port = typec->ports[port_num];
 
+	typec_unregister_plug(port->plug);
+	port->plug = NULL;
 	typec_unregister_cable(port->cable);
 	port->cable = NULL;
 	memset(&port->c_identity, 0, sizeof(port->c_identity));
@@ -712,7 +716,8 @@ static int cros_typec_handle_sop_prime_disc(struct cros_typec_data *typec, int p
 {
 	struct cros_typec_port *port = typec->ports[port_num];
 	struct ec_response_typec_discovery *disc = port->disc_data;
-	struct typec_cable_desc desc = {};
+	struct typec_cable_desc c_desc = {};
+	struct typec_plug_desc p_desc;
 	struct ec_params_typec_discovery req = {
 		.port = port_num,
 		.partner_type = TYPEC_PARTNER_SOP_PRIME,
@@ -735,32 +740,44 @@ static int cros_typec_handle_sop_prime_disc(struct cros_typec_data *typec, int p
 		cable_plug_type = VDO_TYPEC_CABLE_TYPE(port->c_identity.vdo[0]);
 		switch (cable_plug_type) {
 		case CABLE_ATYPE:
-			desc.type = USB_PLUG_TYPE_A;
+			c_desc.type = USB_PLUG_TYPE_A;
 			break;
 		case CABLE_BTYPE:
-			desc.type = USB_PLUG_TYPE_B;
+			c_desc.type = USB_PLUG_TYPE_B;
 			break;
 		case CABLE_CTYPE:
-			desc.type = USB_PLUG_TYPE_C;
+			c_desc.type = USB_PLUG_TYPE_C;
 			break;
 		case CABLE_CAPTIVE:
-			desc.type = USB_PLUG_CAPTIVE;
+			c_desc.type = USB_PLUG_CAPTIVE;
 			break;
 		default:
-			desc.type = USB_PLUG_NONE;
+			c_desc.type = USB_PLUG_NONE;
 		}
-		desc.active = PD_IDH_PTYPE(port->c_identity.id_header) == IDH_PTYPE_ACABLE;
+		c_desc.active = PD_IDH_PTYPE(port->c_identity.id_header) == IDH_PTYPE_ACABLE;
 	}
 
-	desc.identity = &port->c_identity;
+	c_desc.identity = &port->c_identity;
 
-	port->cable = typec_register_cable(port->port, &desc);
+	port->cable = typec_register_cable(port->port, &c_desc);
 	if (IS_ERR(port->cable)) {
 		ret = PTR_ERR(port->cable);
 		port->cable = NULL;
+		goto sop_prime_disc_exit;
+	}
+
+	p_desc.index = TYPEC_PLUG_SOP_P;
+	port->plug = typec_register_plug(port->cable, &p_desc);
+	if (IS_ERR(port->plug)) {
+		ret = PTR_ERR(port->plug);
+		port->plug = NULL;
+		goto sop_prime_disc_exit;
 	}
 
+	return 0;
+
 sop_prime_disc_exit:
+	cros_typec_remove_cable(typec, port_num);
 	return ret;
 }
 
-- 
2.29.2.299.gdc1121823c-goog


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [PATCH v3 11/11] platform/chrome: cros_ec_typec: Register plug altmodes
  2020-11-16 20:11 [PATCH v3 00/11] chrome/platform: cros_ec_typec: Register cables, partner altmodes and plug altmodes Prashant Malani
                   ` (9 preceding siblings ...)
  2020-11-16 20:11 ` [PATCH v3 10/11] platform/chrome: cros_ec_typec: Register SOP' cable plug Prashant Malani
@ 2020-11-16 20:11 ` Prashant Malani
  2020-11-17 13:09   ` Heikki Krogerus
  2020-11-18 11:59 ` [PATCH v3 00/11] chrome/platform: cros_ec_typec: Register cables, partner altmodes and " Greg KH
  2021-01-05 19:26 ` Benson Leung
  12 siblings, 1 reply; 21+ messages in thread
From: Prashant Malani @ 2020-11-16 20:11 UTC (permalink / raw)
  To: linux-kernel, linux-usb, gregkh, heikki.krogerus, enric.balletbo
  Cc: Prashant Malani, Benson Leung, Guenter Roeck

Modify the altmode registration (and unregistration) code so that it
can be used by both partners and plugs.

Then, add code to register plug altmodes using the newly parameterized
function. Also set the number of alternate modes for the plug using the
associated Type C connector class function
typec_plug_set_num_altmodes().

Signed-off-by: Prashant Malani <pmalani@chromium.org>
---

Changes in v3:
- Re-arranged patch order and combined it with related series of
  patches.

No version v2.

 drivers/platform/chrome/cros_ec_typec.c | 50 ++++++++++++++++++++-----
 1 file changed, 40 insertions(+), 10 deletions(-)

diff --git a/drivers/platform/chrome/cros_ec_typec.c b/drivers/platform/chrome/cros_ec_typec.c
index d2e154ae2362..65c5d0090ccd 100644
--- a/drivers/platform/chrome/cros_ec_typec.c
+++ b/drivers/platform/chrome/cros_ec_typec.c
@@ -67,6 +67,7 @@ struct cros_typec_port {
 	bool sop_prime_disc_done;
 	struct ec_response_typec_discovery *disc_data;
 	struct list_head partner_mode_list;
+	struct list_head plug_mode_list;
 };
 
 /* Platform-specific data for the Chrome OS EC Type C controller. */
@@ -186,12 +187,15 @@ static int cros_typec_add_partner(struct cros_typec_data *typec, int port_num,
 	return ret;
 }
 
-static void cros_typec_unregister_altmodes(struct cros_typec_data *typec, int port_num)
+static void cros_typec_unregister_altmodes(struct cros_typec_data *typec, int port_num,
+					   bool is_partner)
 {
 	struct cros_typec_port *port = typec->ports[port_num];
 	struct cros_typec_altmode_node *node, *tmp;
+	struct list_head *head;
 
-	list_for_each_entry_safe(node, tmp, &port->partner_mode_list, list) {
+	head = is_partner ? &port->partner_mode_list : &port->plug_mode_list;
+	list_for_each_entry_safe(node, tmp, head, list) {
 		list_del(&node->list);
 		typec_unregister_altmode(node->amode);
 		devm_kfree(typec->dev, node);
@@ -203,7 +207,7 @@ static void cros_typec_remove_partner(struct cros_typec_data *typec,
 {
 	struct cros_typec_port *port = typec->ports[port_num];
 
-	cros_typec_unregister_altmodes(typec, port_num);
+	cros_typec_unregister_altmodes(typec, port_num, true);
 
 	port->state.alt = NULL;
 	port->state.mode = TYPEC_STATE_USB;
@@ -224,6 +228,8 @@ static void cros_typec_remove_cable(struct cros_typec_data *typec,
 {
 	struct cros_typec_port *port = typec->ports[port_num];
 
+	cros_typec_unregister_altmodes(typec, port_num, false);
+
 	typec_unregister_plug(port->plug);
 	port->plug = NULL;
 	typec_unregister_cable(port->cable);
@@ -352,6 +358,7 @@ static int cros_typec_init_ports(struct cros_typec_data *typec)
 		}
 
 		INIT_LIST_HEAD(&cros_port->partner_mode_list);
+		INIT_LIST_HEAD(&cros_port->plug_mode_list);
 	}
 
 	return 0;
@@ -639,7 +646,11 @@ static int cros_typec_get_mux_info(struct cros_typec_data *typec, int port_num,
 				     sizeof(req), resp, sizeof(*resp));
 }
 
-static int cros_typec_register_altmodes(struct cros_typec_data *typec, int port_num)
+/*
+ * Helper function to register partner/plug altmodes.
+ */
+static int cros_typec_register_altmodes(struct cros_typec_data *typec, int port_num,
+					bool is_partner)
 {
 	struct cros_typec_port *port = typec->ports[port_num];
 	struct ec_response_typec_discovery *sop_disc = port->disc_data;
@@ -657,7 +668,11 @@ static int cros_typec_register_altmodes(struct cros_typec_data *typec, int port_
 			desc.mode = j;
 			desc.vdo = sop_disc->svids[i].mode_vdo[j];
 
-			amode = typec_partner_register_altmode(port->partner, &desc);
+			if (is_partner)
+				amode = typec_partner_register_altmode(port->partner, &desc);
+			else
+				amode = typec_plug_register_altmode(port->plug, &desc);
+
 			if (IS_ERR(amode)) {
 				ret = PTR_ERR(amode);
 				goto err_cleanup;
@@ -672,21 +687,30 @@ static int cros_typec_register_altmodes(struct cros_typec_data *typec, int port_
 			}
 
 			node->amode = amode;
-			list_add_tail(&node->list, &port->partner_mode_list);
+
+			if (is_partner)
+				list_add_tail(&node->list, &port->partner_mode_list);
+			else
+				list_add_tail(&node->list, &port->plug_mode_list);
 			num_altmodes++;
 		}
 	}
 
-	ret = typec_partner_set_num_altmodes(port->partner, num_altmodes);
+	if (is_partner)
+		ret = typec_partner_set_num_altmodes(port->partner, num_altmodes);
+	else
+		ret = typec_plug_set_num_altmodes(port->plug, num_altmodes);
+
 	if (ret < 0) {
-		dev_err(typec->dev, "Unable to set partner num_altmodes for port: %d\n", port_num);
+		dev_err(typec->dev, "Unable to set %s num_altmodes for port: %d\n",
+			is_partner ? "partner" : "plug", port_num);
 		goto err_cleanup;
 	}
 
 	return 0;
 
 err_cleanup:
-	cros_typec_unregister_altmodes(typec, port_num);
+	cros_typec_unregister_altmodes(typec, port_num, is_partner);
 	return ret;
 }
 
@@ -774,6 +798,12 @@ static int cros_typec_handle_sop_prime_disc(struct cros_typec_data *typec, int p
 		goto sop_prime_disc_exit;
 	}
 
+	ret = cros_typec_register_altmodes(typec, port_num, false);
+	if (ret < 0) {
+		dev_err(typec->dev, "Failed to register plug altmodes, port: %d\n", port_num);
+		goto sop_prime_disc_exit;
+	}
+
 	return 0;
 
 sop_prime_disc_exit:
@@ -815,7 +845,7 @@ static int cros_typec_handle_sop_disc(struct cros_typec_data *typec, int port_nu
 		goto disc_exit;
 	}
 
-	ret = cros_typec_register_altmodes(typec, port_num);
+	ret = cros_typec_register_altmodes(typec, port_num, true);
 	if (ret < 0) {
 		dev_err(typec->dev, "Failed to register partner altmodes, port: %d\n", port_num);
 		goto disc_exit;
-- 
2.29.2.299.gdc1121823c-goog


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* Re: [PATCH v3 03/11] usb: typec: Add plug num_altmodes sysfs attr
  2020-11-16 20:11 ` [PATCH v3 03/11] usb: typec: Add plug num_altmodes sysfs attr Prashant Malani
@ 2020-11-17 12:41   ` Heikki Krogerus
  2020-11-17 17:40     ` Prashant Malani
  0 siblings, 1 reply; 21+ messages in thread
From: Heikki Krogerus @ 2020-11-17 12:41 UTC (permalink / raw)
  To: Prashant Malani; +Cc: linux-kernel, linux-usb, gregkh, enric.balletbo

On Mon, Nov 16, 2020 at 12:11:42PM -0800, Prashant Malani wrote:
> Add a field to the typec_plug struct to record the number of available
> altmodes as well as the corresponding sysfs attribute to expose this to
> userspace.
> 
> This allows userspace to determine whether there are any
> remaining alternate modes left to be registered by the kernel driver. It
> can begin executing any policy state machine after all available
> alternate modes have been registered with the connector class framework.
> 
> This value is set to "-1" initially, signifying that a valid number of
> alternate modes haven't been set for the plug. The sysfs file remains
> hidden as long as the attribute value is -1.

Why couldn't we just keep it hidden for as long as the number of
alt modes is 0? If you already explained that, then I apologise, I've
forgotten.

> We re-use the partner attribute for number_of_alternate_modes since the
> usage and name is similar, and update the corresponding *_show() command
> to support both partner and plugs.
> 
> Signed-off-by: Prashant Malani <pmalani@chromium.org>
> ---
> 
> Changes in v3:
> - Re-arranged patch order and combined it with related series of
>   patches.
> 
> No version v2.
> 
>  Documentation/ABI/testing/sysfs-class-typec |  9 +++
>  drivers/usb/typec/class.c                   | 77 ++++++++++++++++++++-
>  include/linux/usb/typec.h                   |  1 +
>  3 files changed, 85 insertions(+), 2 deletions(-)
> 
> diff --git a/Documentation/ABI/testing/sysfs-class-typec b/Documentation/ABI/testing/sysfs-class-typec
> index 73ac7b461ae5..29eccf5fb8ed 100644
> --- a/Documentation/ABI/testing/sysfs-class-typec
> +++ b/Documentation/ABI/testing/sysfs-class-typec
> @@ -204,6 +204,15 @@ Description:
>  		- type-c
>  		- captive
>  
> +What:		/sys/class/typec/<port>-<plug>/number_of_alternate_modes
> +Date:		November 2020
> +Contact:	Prashant Malani <pmalani@chromium.org>
> +Description:
> +		Shows the number of alternate modes which are advertised by the plug
> +		associated with a particular cable during Power Delivery discovery.
> +		This file remains hidden until a value greater than or equal to 0
> +		is set by Type C port driver.
> +
>  What:		/sys/class/typec/<port>-cable/identity/
>  Date:		April 2017
>  Contact:	Heikki Krogerus <heikki.krogerus@linux.intel.com>
> diff --git a/drivers/usb/typec/class.c b/drivers/usb/typec/class.c
> index c7412ddbd311..e68798599ca8 100644
> --- a/drivers/usb/typec/class.c
> +++ b/drivers/usb/typec/class.c
> @@ -18,6 +18,7 @@ struct typec_plug {
>  	struct device			dev;
>  	enum typec_plug_index		index;
>  	struct ida			mode_ids;
> +	int				num_altmodes;
>  };
>  
>  struct typec_cable {
> @@ -536,9 +537,21 @@ static DEVICE_ATTR_RO(supports_usb_power_delivery);
>  static ssize_t number_of_alternate_modes_show(struct device *dev, struct device_attribute *attr,
>  					      char *buf)
>  {
> -	struct typec_partner *p = to_typec_partner(dev);
> +	struct typec_partner *partner;
> +	struct typec_plug *plug;
> +	int num_altmodes;
> +
> +	if (is_typec_partner(dev)) {
> +		partner = to_typec_partner(dev);
> +		num_altmodes = partner->num_altmodes;
> +	} else if (is_typec_plug(dev)) {
> +		plug = to_typec_plug(dev);
> +		num_altmodes = plug->num_altmodes;
> +	} else {
> +		return 0;
> +	}
>  
> -	return sysfs_emit(buf, "%d\n", p->num_altmodes);
> +	return sysfs_emit(buf, "%d\n", num_altmodes);
>  }
>  static DEVICE_ATTR_RO(number_of_alternate_modes);
>  
> @@ -726,11 +739,70 @@ static void typec_plug_release(struct device *dev)
>  	kfree(plug);
>  }
>  
> +static struct attribute *typec_plug_attrs[] = {
> +	&dev_attr_number_of_alternate_modes.attr,
> +	NULL
> +};
> +
> +static umode_t typec_plug_attr_is_visible(struct kobject *kobj, struct attribute *attr, int n)
> +{
> +	struct typec_plug *plug = to_typec_plug(kobj_to_dev(kobj));
> +
> +	if (attr == &dev_attr_number_of_alternate_modes.attr) {
> +		if (plug->num_altmodes < 0)
> +			return 0;
> +	}
> +
> +	return attr->mode;
> +}
> +
> +static struct attribute_group typec_plug_group = {
> +	.is_visible = typec_plug_attr_is_visible,
> +	.attrs = typec_plug_attrs
> +};
> +
> +static const struct attribute_group *typec_plug_groups[] = {
> +	&typec_plug_group,
> +	NULL
> +};
> +
>  static const struct device_type typec_plug_dev_type = {
>  	.name = "typec_plug",
> +	.groups = typec_plug_groups,
>  	.release = typec_plug_release,
>  };
>  
> +/**
> + * typec_plug_set_num_altmodes - Set the number of available plug altmodes
> + * @plug: The plug to be updated.
> + * @num_altmodes: The number of altmodes we want to specify as available.
> + *
> + * This routine is used to report the number of alternate modes supported by the
> + * plug. This value is *not* enforced in alternate mode registration routines.
> + *
> + * @plug.num_altmodes is set to -1 on plug registration, denoting that
> + * a valid value has not been set for it yet.
> + *
> + * Returns 0 on success or negative error number on failure.
> + */
> +int typec_plug_set_num_altmodes(struct typec_plug *plug, int num_altmodes)
> +{
> +	int ret;
> +
> +	if (num_altmodes < 0)
> +		return -EINVAL;
> +
> +	plug->num_altmodes = num_altmodes;
> +	ret = sysfs_update_group(&plug->dev.kobj, &typec_plug_group);
> +	if (ret < 0)
> +		return ret;
> +
> +	sysfs_notify(&plug->dev.kobj, NULL, "number_of_alternate_modes");
> +
> +	return 0;
> +}
> +EXPORT_SYMBOL_GPL(typec_plug_set_num_altmodes);
> +
>  /**
>   * typec_plug_register_altmode - Register USB Type-C Cable Plug Alternate Mode
>   * @plug: USB Type-C Cable Plug that supports the alternate mode
> @@ -776,6 +848,7 @@ struct typec_plug *typec_register_plug(struct typec_cable *cable,
>  	sprintf(name, "plug%d", desc->index);
>  
>  	ida_init(&plug->mode_ids);
> +	plug->num_altmodes = -1;
>  	plug->index = desc->index;
>  	plug->dev.class = typec_class;
>  	plug->dev.parent = &cable->dev;
> diff --git a/include/linux/usb/typec.h b/include/linux/usb/typec.h
> index bc6b1a71cb8a..54475323f83b 100644
> --- a/include/linux/usb/typec.h
> +++ b/include/linux/usb/typec.h
> @@ -130,6 +130,7 @@ int typec_partner_set_num_altmodes(struct typec_partner *partner, int num_altmod
>  struct typec_altmode
>  *typec_partner_register_altmode(struct typec_partner *partner,
>  				const struct typec_altmode_desc *desc);
> +int typec_plug_set_num_altmodes(struct typec_plug *plug, int num_altmodes);
>  struct typec_altmode
>  *typec_plug_register_altmode(struct typec_plug *plug,
>  			     const struct typec_altmode_desc *desc);
> -- 
> 2.29.2.299.gdc1121823c-goog

thanks,

-- 
heikki

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH v3 10/11] platform/chrome: cros_ec_typec: Register SOP' cable plug
  2020-11-16 20:11 ` [PATCH v3 10/11] platform/chrome: cros_ec_typec: Register SOP' cable plug Prashant Malani
@ 2020-11-17 12:45   ` Heikki Krogerus
  0 siblings, 0 replies; 21+ messages in thread
From: Heikki Krogerus @ 2020-11-17 12:45 UTC (permalink / raw)
  To: Prashant Malani
  Cc: linux-kernel, linux-usb, gregkh, enric.balletbo, Benson Leung,
	Guenter Roeck

On Mon, Nov 16, 2020 at 12:11:56PM -0800, Prashant Malani wrote:
> In order to register cable alternate modes, we need to first register a
> plug object. Use the Type C connector class framework to register a SOP'
> plug for this purpose.
> 
> Since a cable and plug go hand in hand, we can handle the registration
> and removal together.
> 
> Signed-off-by: Prashant Malani <pmalani@chromium.org>

FWIW:

Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>

> ---
> 
> Changes in v3:
> - Re-arranged patch order and combined it with related series of
>   patches.
> 
> No version v2.
> 
>  drivers/platform/chrome/cros_ec_typec.c | 35 ++++++++++++++++++-------
>  1 file changed, 26 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/platform/chrome/cros_ec_typec.c b/drivers/platform/chrome/cros_ec_typec.c
> index ad5e37bfd45d..d2e154ae2362 100644
> --- a/drivers/platform/chrome/cros_ec_typec.c
> +++ b/drivers/platform/chrome/cros_ec_typec.c
> @@ -45,6 +45,8 @@ struct cros_typec_port {
>  	struct typec_capability caps;
>  	struct typec_partner *partner;
>  	struct typec_cable *cable;
> +	/* SOP' plug. */
> +	struct typec_plug *plug;
>  	/* Port partner PD identity info. */
>  	struct usb_pd_identity p_identity;
>  	/* Port cable PD identity info. */
> @@ -222,6 +224,8 @@ static void cros_typec_remove_cable(struct cros_typec_data *typec,
>  {
>  	struct cros_typec_port *port = typec->ports[port_num];
>  
> +	typec_unregister_plug(port->plug);
> +	port->plug = NULL;
>  	typec_unregister_cable(port->cable);
>  	port->cable = NULL;
>  	memset(&port->c_identity, 0, sizeof(port->c_identity));
> @@ -712,7 +716,8 @@ static int cros_typec_handle_sop_prime_disc(struct cros_typec_data *typec, int p
>  {
>  	struct cros_typec_port *port = typec->ports[port_num];
>  	struct ec_response_typec_discovery *disc = port->disc_data;
> -	struct typec_cable_desc desc = {};
> +	struct typec_cable_desc c_desc = {};
> +	struct typec_plug_desc p_desc;
>  	struct ec_params_typec_discovery req = {
>  		.port = port_num,
>  		.partner_type = TYPEC_PARTNER_SOP_PRIME,
> @@ -735,32 +740,44 @@ static int cros_typec_handle_sop_prime_disc(struct cros_typec_data *typec, int p
>  		cable_plug_type = VDO_TYPEC_CABLE_TYPE(port->c_identity.vdo[0]);
>  		switch (cable_plug_type) {
>  		case CABLE_ATYPE:
> -			desc.type = USB_PLUG_TYPE_A;
> +			c_desc.type = USB_PLUG_TYPE_A;
>  			break;
>  		case CABLE_BTYPE:
> -			desc.type = USB_PLUG_TYPE_B;
> +			c_desc.type = USB_PLUG_TYPE_B;
>  			break;
>  		case CABLE_CTYPE:
> -			desc.type = USB_PLUG_TYPE_C;
> +			c_desc.type = USB_PLUG_TYPE_C;
>  			break;
>  		case CABLE_CAPTIVE:
> -			desc.type = USB_PLUG_CAPTIVE;
> +			c_desc.type = USB_PLUG_CAPTIVE;
>  			break;
>  		default:
> -			desc.type = USB_PLUG_NONE;
> +			c_desc.type = USB_PLUG_NONE;
>  		}
> -		desc.active = PD_IDH_PTYPE(port->c_identity.id_header) == IDH_PTYPE_ACABLE;
> +		c_desc.active = PD_IDH_PTYPE(port->c_identity.id_header) == IDH_PTYPE_ACABLE;
>  	}
>  
> -	desc.identity = &port->c_identity;
> +	c_desc.identity = &port->c_identity;
>  
> -	port->cable = typec_register_cable(port->port, &desc);
> +	port->cable = typec_register_cable(port->port, &c_desc);
>  	if (IS_ERR(port->cable)) {
>  		ret = PTR_ERR(port->cable);
>  		port->cable = NULL;
> +		goto sop_prime_disc_exit;
> +	}
> +
> +	p_desc.index = TYPEC_PLUG_SOP_P;
> +	port->plug = typec_register_plug(port->cable, &p_desc);
> +	if (IS_ERR(port->plug)) {
> +		ret = PTR_ERR(port->plug);
> +		port->plug = NULL;
> +		goto sop_prime_disc_exit;
>  	}
>  
> +	return 0;
> +
>  sop_prime_disc_exit:
> +	cros_typec_remove_cable(typec, port_num);
>  	return ret;
>  }
>  
> -- 
> 2.29.2.299.gdc1121823c-goog

-- 
heikki

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH v3 11/11] platform/chrome: cros_ec_typec: Register plug altmodes
  2020-11-16 20:11 ` [PATCH v3 11/11] platform/chrome: cros_ec_typec: Register plug altmodes Prashant Malani
@ 2020-11-17 13:09   ` Heikki Krogerus
  0 siblings, 0 replies; 21+ messages in thread
From: Heikki Krogerus @ 2020-11-17 13:09 UTC (permalink / raw)
  To: Prashant Malani
  Cc: linux-kernel, linux-usb, gregkh, enric.balletbo, Benson Leung,
	Guenter Roeck

On Mon, Nov 16, 2020 at 12:11:58PM -0800, Prashant Malani wrote:
> Modify the altmode registration (and unregistration) code so that it
> can be used by both partners and plugs.
> 
> Then, add code to register plug altmodes using the newly parameterized
> function. Also set the number of alternate modes for the plug using the
> associated Type C connector class function
> typec_plug_set_num_altmodes().
> 
> Signed-off-by: Prashant Malani <pmalani@chromium.org>

Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>

> ---
> 
> Changes in v3:
> - Re-arranged patch order and combined it with related series of
>   patches.
> 
> No version v2.
> 
>  drivers/platform/chrome/cros_ec_typec.c | 50 ++++++++++++++++++++-----
>  1 file changed, 40 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/platform/chrome/cros_ec_typec.c b/drivers/platform/chrome/cros_ec_typec.c
> index d2e154ae2362..65c5d0090ccd 100644
> --- a/drivers/platform/chrome/cros_ec_typec.c
> +++ b/drivers/platform/chrome/cros_ec_typec.c
> @@ -67,6 +67,7 @@ struct cros_typec_port {
>  	bool sop_prime_disc_done;
>  	struct ec_response_typec_discovery *disc_data;
>  	struct list_head partner_mode_list;
> +	struct list_head plug_mode_list;
>  };
>  
>  /* Platform-specific data for the Chrome OS EC Type C controller. */
> @@ -186,12 +187,15 @@ static int cros_typec_add_partner(struct cros_typec_data *typec, int port_num,
>  	return ret;
>  }
>  
> -static void cros_typec_unregister_altmodes(struct cros_typec_data *typec, int port_num)
> +static void cros_typec_unregister_altmodes(struct cros_typec_data *typec, int port_num,
> +					   bool is_partner)
>  {
>  	struct cros_typec_port *port = typec->ports[port_num];
>  	struct cros_typec_altmode_node *node, *tmp;
> +	struct list_head *head;
>  
> -	list_for_each_entry_safe(node, tmp, &port->partner_mode_list, list) {
> +	head = is_partner ? &port->partner_mode_list : &port->plug_mode_list;
> +	list_for_each_entry_safe(node, tmp, head, list) {
>  		list_del(&node->list);
>  		typec_unregister_altmode(node->amode);
>  		devm_kfree(typec->dev, node);
> @@ -203,7 +207,7 @@ static void cros_typec_remove_partner(struct cros_typec_data *typec,
>  {
>  	struct cros_typec_port *port = typec->ports[port_num];
>  
> -	cros_typec_unregister_altmodes(typec, port_num);
> +	cros_typec_unregister_altmodes(typec, port_num, true);
>  
>  	port->state.alt = NULL;
>  	port->state.mode = TYPEC_STATE_USB;
> @@ -224,6 +228,8 @@ static void cros_typec_remove_cable(struct cros_typec_data *typec,
>  {
>  	struct cros_typec_port *port = typec->ports[port_num];
>  
> +	cros_typec_unregister_altmodes(typec, port_num, false);
> +
>  	typec_unregister_plug(port->plug);
>  	port->plug = NULL;
>  	typec_unregister_cable(port->cable);
> @@ -352,6 +358,7 @@ static int cros_typec_init_ports(struct cros_typec_data *typec)
>  		}
>  
>  		INIT_LIST_HEAD(&cros_port->partner_mode_list);
> +		INIT_LIST_HEAD(&cros_port->plug_mode_list);
>  	}
>  
>  	return 0;
> @@ -639,7 +646,11 @@ static int cros_typec_get_mux_info(struct cros_typec_data *typec, int port_num,
>  				     sizeof(req), resp, sizeof(*resp));
>  }
>  
> -static int cros_typec_register_altmodes(struct cros_typec_data *typec, int port_num)
> +/*
> + * Helper function to register partner/plug altmodes.
> + */
> +static int cros_typec_register_altmodes(struct cros_typec_data *typec, int port_num,
> +					bool is_partner)
>  {
>  	struct cros_typec_port *port = typec->ports[port_num];
>  	struct ec_response_typec_discovery *sop_disc = port->disc_data;
> @@ -657,7 +668,11 @@ static int cros_typec_register_altmodes(struct cros_typec_data *typec, int port_
>  			desc.mode = j;
>  			desc.vdo = sop_disc->svids[i].mode_vdo[j];
>  
> -			amode = typec_partner_register_altmode(port->partner, &desc);
> +			if (is_partner)
> +				amode = typec_partner_register_altmode(port->partner, &desc);
> +			else
> +				amode = typec_plug_register_altmode(port->plug, &desc);
> +
>  			if (IS_ERR(amode)) {
>  				ret = PTR_ERR(amode);
>  				goto err_cleanup;
> @@ -672,21 +687,30 @@ static int cros_typec_register_altmodes(struct cros_typec_data *typec, int port_
>  			}
>  
>  			node->amode = amode;
> -			list_add_tail(&node->list, &port->partner_mode_list);
> +
> +			if (is_partner)
> +				list_add_tail(&node->list, &port->partner_mode_list);
> +			else
> +				list_add_tail(&node->list, &port->plug_mode_list);
>  			num_altmodes++;
>  		}
>  	}
>  
> -	ret = typec_partner_set_num_altmodes(port->partner, num_altmodes);
> +	if (is_partner)
> +		ret = typec_partner_set_num_altmodes(port->partner, num_altmodes);
> +	else
> +		ret = typec_plug_set_num_altmodes(port->plug, num_altmodes);
> +
>  	if (ret < 0) {
> -		dev_err(typec->dev, "Unable to set partner num_altmodes for port: %d\n", port_num);
> +		dev_err(typec->dev, "Unable to set %s num_altmodes for port: %d\n",
> +			is_partner ? "partner" : "plug", port_num);
>  		goto err_cleanup;
>  	}
>  
>  	return 0;
>  
>  err_cleanup:
> -	cros_typec_unregister_altmodes(typec, port_num);
> +	cros_typec_unregister_altmodes(typec, port_num, is_partner);
>  	return ret;
>  }
>  
> @@ -774,6 +798,12 @@ static int cros_typec_handle_sop_prime_disc(struct cros_typec_data *typec, int p
>  		goto sop_prime_disc_exit;
>  	}
>  
> +	ret = cros_typec_register_altmodes(typec, port_num, false);
> +	if (ret < 0) {
> +		dev_err(typec->dev, "Failed to register plug altmodes, port: %d\n", port_num);
> +		goto sop_prime_disc_exit;
> +	}
> +
>  	return 0;
>  
>  sop_prime_disc_exit:
> @@ -815,7 +845,7 @@ static int cros_typec_handle_sop_disc(struct cros_typec_data *typec, int port_nu
>  		goto disc_exit;
>  	}
>  
> -	ret = cros_typec_register_altmodes(typec, port_num);
> +	ret = cros_typec_register_altmodes(typec, port_num, true);
>  	if (ret < 0) {
>  		dev_err(typec->dev, "Failed to register partner altmodes, port: %d\n", port_num);
>  		goto disc_exit;
> -- 
> 2.29.2.299.gdc1121823c-goog

thanks,

-- 
heikki

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH v3 03/11] usb: typec: Add plug num_altmodes sysfs attr
  2020-11-17 12:41   ` Heikki Krogerus
@ 2020-11-17 17:40     ` Prashant Malani
  2020-11-18 12:04       ` Heikki Krogerus
  0 siblings, 1 reply; 21+ messages in thread
From: Prashant Malani @ 2020-11-17 17:40 UTC (permalink / raw)
  To: Heikki Krogerus; +Cc: linux-kernel, linux-usb, gregkh, enric.balletbo

Hi Heikki,

On Tue, Nov 17, 2020 at 02:41:43PM +0200, Heikki Krogerus wrote:
> On Mon, Nov 16, 2020 at 12:11:42PM -0800, Prashant Malani wrote:
> > Add a field to the typec_plug struct to record the number of available
> > altmodes as well as the corresponding sysfs attribute to expose this to
> > userspace.
> > 
> > This allows userspace to determine whether there are any
> > remaining alternate modes left to be registered by the kernel driver. It
> > can begin executing any policy state machine after all available
> > alternate modes have been registered with the connector class framework.
> > 
> > This value is set to "-1" initially, signifying that a valid number of
> > alternate modes haven't been set for the plug. The sysfs file remains
> > hidden as long as the attribute value is -1.
> 
> Why couldn't we just keep it hidden for as long as the number of
> alt modes is 0? If you already explained that, then I apologise, I've
> forgotten.
> 

No worries :)

Succinctly, because 0 is a valid value for "number of altmodes
supported".

If we keep the attribute hidden for 0, then there won't
be a way for userspace to determine that PD discovery is done and we
don't expect any more cable plug altmodes to be registered by the kernel
Type C port driver (it can determine this by comparing
"number_of_altmodes" against the actual number of alt modes registered
by the Type C port driver).

If we keep "number_of_altmodes" hidden even for 0, the userspace cannot
differentiate between "this cable doesn't support any altmodes" and
"it does altmodes, but the PD stack hasn't completed PD Discovery
including DiscoverIdentity yet".

For reference, here is the initial patch and mini-discussion around it
back in July for port-partner altmodes [1] (I've followed a similar
logic here).

Hope this helps the rationale a bit more.

Best regards,

-Prashant

[1]:
https://lore.kernel.org/linux-usb/20200701082230.GF856968@kuha.fi.intel.com/

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH v3 00/11] chrome/platform: cros_ec_typec: Register cables, partner altmodes and plug altmodes
  2020-11-16 20:11 [PATCH v3 00/11] chrome/platform: cros_ec_typec: Register cables, partner altmodes and plug altmodes Prashant Malani
                   ` (10 preceding siblings ...)
  2020-11-16 20:11 ` [PATCH v3 11/11] platform/chrome: cros_ec_typec: Register plug altmodes Prashant Malani
@ 2020-11-18 11:59 ` Greg KH
  2020-11-18 12:16   ` Greg KH
  2021-01-05 19:26 ` Benson Leung
  12 siblings, 1 reply; 21+ messages in thread
From: Greg KH @ 2020-11-18 11:59 UTC (permalink / raw)
  To: Prashant Malani
  Cc: linux-kernel, linux-usb, heikki.krogerus, enric.balletbo,
	Benson Leung, Guenter Roeck

On Mon, Nov 16, 2020 at 12:11:36PM -0800, Prashant Malani wrote:
> This patch series adds support for the following bits of functionality,
> parsing USB Type C Power Delivery information from the Chrome Embedded Controller
> and using the Type C connector class:
> - Register cable objects (including plug type).
> - Register "number of altmodes" attribute for partners.
> - Register altmodes and "number of altmodes" attribute for cable plugs.
> 
> The functionality was earlier part of multiple series ([1], [2], [3]), but
> I've combined it into 1 series and re-ordered the patches to hopefully make
> it easier to peruse. I've maintained the patch Acked-by/Reviewed-by tags where
> they were received.
> 
> Patches 1/11, 2/11, 3/11 introduce the changes needed in the USB subsystem (PD VDO
> header update, sysfs attribute additions) and hence the first three patches
> can go through Greg's tree.

I've taken the first 2 patches in my usb tree now, waiting for Heikki's
response on patch 3 before I touch that.

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH v3 03/11] usb: typec: Add plug num_altmodes sysfs attr
  2020-11-17 17:40     ` Prashant Malani
@ 2020-11-18 12:04       ` Heikki Krogerus
  0 siblings, 0 replies; 21+ messages in thread
From: Heikki Krogerus @ 2020-11-18 12:04 UTC (permalink / raw)
  To: Prashant Malani; +Cc: linux-kernel, linux-usb, gregkh, enric.balletbo

On Tue, Nov 17, 2020 at 09:40:16AM -0800, Prashant Malani wrote:
> Hi Heikki,
> 
> On Tue, Nov 17, 2020 at 02:41:43PM +0200, Heikki Krogerus wrote:
> > On Mon, Nov 16, 2020 at 12:11:42PM -0800, Prashant Malani wrote:
> > > Add a field to the typec_plug struct to record the number of available
> > > altmodes as well as the corresponding sysfs attribute to expose this to
> > > userspace.
> > > 
> > > This allows userspace to determine whether there are any
> > > remaining alternate modes left to be registered by the kernel driver. It
> > > can begin executing any policy state machine after all available
> > > alternate modes have been registered with the connector class framework.
> > > 
> > > This value is set to "-1" initially, signifying that a valid number of
> > > alternate modes haven't been set for the plug. The sysfs file remains
> > > hidden as long as the attribute value is -1.
> > 
> > Why couldn't we just keep it hidden for as long as the number of
> > alt modes is 0? If you already explained that, then I apologise, I've
> > forgotten.
> > 
> 
> No worries :)
> 
> Succinctly, because 0 is a valid value for "number of altmodes
> supported".
> 
> If we keep the attribute hidden for 0, then there won't
> be a way for userspace to determine that PD discovery is done and we
> don't expect any more cable plug altmodes to be registered by the kernel
> Type C port driver (it can determine this by comparing
> "number_of_altmodes" against the actual number of alt modes registered
> by the Type C port driver).
> 
> If we keep "number_of_altmodes" hidden even for 0, the userspace cannot
> differentiate between "this cable doesn't support any altmodes" and
> "it does altmodes, but the PD stack hasn't completed PD Discovery
> including DiscoverIdentity yet".
> 
> For reference, here is the initial patch and mini-discussion around it
> back in July for port-partner altmodes [1] (I've followed a similar
> logic here).
> 
> Hope this helps the rationale a bit more.

Got it. Thanks for the explanation (again :-).

Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>

> Best regards,
> 
> -Prashant
> 
> [1]:
> https://lore.kernel.org/linux-usb/20200701082230.GF856968@kuha.fi.intel.com/

thanks,

-- 
heikki

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH v3 00/11] chrome/platform: cros_ec_typec: Register cables, partner altmodes and plug altmodes
  2020-11-18 11:59 ` [PATCH v3 00/11] chrome/platform: cros_ec_typec: Register cables, partner altmodes and " Greg KH
@ 2020-11-18 12:16   ` Greg KH
  2020-11-19  3:56     ` Prashant Malani
  0 siblings, 1 reply; 21+ messages in thread
From: Greg KH @ 2020-11-18 12:16 UTC (permalink / raw)
  To: Prashant Malani
  Cc: linux-kernel, linux-usb, heikki.krogerus, enric.balletbo,
	Benson Leung, Guenter Roeck

On Wed, Nov 18, 2020 at 12:59:59PM +0100, Greg KH wrote:
> On Mon, Nov 16, 2020 at 12:11:36PM -0800, Prashant Malani wrote:
> > This patch series adds support for the following bits of functionality,
> > parsing USB Type C Power Delivery information from the Chrome Embedded Controller
> > and using the Type C connector class:
> > - Register cable objects (including plug type).
> > - Register "number of altmodes" attribute for partners.
> > - Register altmodes and "number of altmodes" attribute for cable plugs.
> > 
> > The functionality was earlier part of multiple series ([1], [2], [3]), but
> > I've combined it into 1 series and re-ordered the patches to hopefully make
> > it easier to peruse. I've maintained the patch Acked-by/Reviewed-by tags where
> > they were received.
> > 
> > Patches 1/11, 2/11, 3/11 introduce the changes needed in the USB subsystem (PD VDO
> > header update, sysfs attribute additions) and hence the first three patches
> > can go through Greg's tree.
> 
> I've taken the first 2 patches in my usb tree now, waiting for Heikki's
> response on patch 3 before I touch that.

Ok, now taken patch 3 too.

I can take the rest in my usb-next tree if the platform people don't
object as well, but would need an ack for that.

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH v3 00/11] chrome/platform: cros_ec_typec: Register cables, partner altmodes and plug altmodes
  2020-11-18 12:16   ` Greg KH
@ 2020-11-19  3:56     ` Prashant Malani
  0 siblings, 0 replies; 21+ messages in thread
From: Prashant Malani @ 2020-11-19  3:56 UTC (permalink / raw)
  To: Greg KH
  Cc: linux-kernel, linux-usb, heikki.krogerus, enric.balletbo,
	Benson Leung, Guenter Roeck

Hi Greg,

On Wed, Nov 18, 2020 at 01:16:49PM +0100, Greg KH wrote:
> On Wed, Nov 18, 2020 at 12:59:59PM +0100, Greg KH wrote:
> > On Mon, Nov 16, 2020 at 12:11:36PM -0800, Prashant Malani wrote:
> > > This patch series adds support for the following bits of functionality,
> > > parsing USB Type C Power Delivery information from the Chrome Embedded Controller
> > > and using the Type C connector class:
> > > - Register cable objects (including plug type).
> > > - Register "number of altmodes" attribute for partners.
> > > - Register altmodes and "number of altmodes" attribute for cable plugs.
> > > 
> > > The functionality was earlier part of multiple series ([1], [2], [3]), but
> > > I've combined it into 1 series and re-ordered the patches to hopefully make
> > > it easier to peruse. I've maintained the patch Acked-by/Reviewed-by tags where
> > > they were received.
> > > 
> > > Patches 1/11, 2/11, 3/11 introduce the changes needed in the USB subsystem (PD VDO
> > > header update, sysfs attribute additions) and hence the first three patches
> > > can go through Greg's tree.
> > 
> > I've taken the first 2 patches in my usb tree now, waiting for Heikki's
> > response on patch 3 before I touch that.
> 
> Ok, now taken patch 3 too.
> 

Thanks!

> I can take the rest in my usb-next tree if the platform people don't
> object as well, but would need an ack for that.

Will defer to Enric on this, but Patch 4/11 and onwards have a
dependency on some patches which are already in the chrome-platform
tree [1], so they may have to go through there.

[1]
https://git.kernel.org/pub/scm/linux/kernel/git/chrome-platform/linux.git/log/?h=for-next

Best regards,

-Prashant

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH v3 00/11] chrome/platform: cros_ec_typec: Register cables, partner altmodes and plug altmodes
  2020-11-16 20:11 [PATCH v3 00/11] chrome/platform: cros_ec_typec: Register cables, partner altmodes and plug altmodes Prashant Malani
                   ` (11 preceding siblings ...)
  2020-11-18 11:59 ` [PATCH v3 00/11] chrome/platform: cros_ec_typec: Register cables, partner altmodes and " Greg KH
@ 2021-01-05 19:26 ` Benson Leung
  12 siblings, 0 replies; 21+ messages in thread
From: Benson Leung @ 2021-01-05 19:26 UTC (permalink / raw)
  To: enric.balletbo, linux-usb, linux-kernel, Prashant Malani,
	heikki.krogerus, gregkh
  Cc: Guenter Roeck, bleung

[-- Attachment #1: Type: text/plain, Size: 1445 bytes --]

Hi Prashant,

On Mon, 16 Nov 2020 12:11:36 -0800, Prashant Malani wrote:
> This patch series adds support for the following bits of functionality,
> parsing USB Type C Power Delivery information from the Chrome Embedded Controller
> and using the Type C connector class:
> - Register cable objects (including plug type).
> - Register "number of altmodes" attribute for partners.
> - Register altmodes and "number of altmodes" attribute for cable plugs.
> 
> [...]

Applied 4 through 11 of this series, staged for chrome-platform-5.12, thanks!

[04/11] platform/chrome: cros_ec_typec: Make disc_done flag partner-only
        (no commit info)
[05/11] platform/chrome: cros_ec_typec: Factor out PD identity parsing
        (no commit info)
[06/11] platform/chrome: cros_ec_typec: Rename discovery struct
        (no commit info)
[07/11] platform/chrome: cros_ec_typec: Register cable
        (no commit info)
[08/11] platform/chrome: cros_ec_typec: Store cable plug type
        (no commit info)
[09/11] platform/chrome: cros_ec_typec: Set partner num_altmodes
        (no commit info)
[10/11] platform/chrome: cros_ec_typec: Register SOP' cable plug
        (no commit info)
[11/11] platform/chrome: cros_ec_typec: Register plug altmodes
        (no commit info)

Best regards,
-- 
Benson Leung
Staff Software Engineer
Chrome OS Kernel
Google Inc.
bleung@google.com
Chromium OS Project
bleung@chromium.org

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

^ permalink raw reply	[flat|nested] 21+ messages in thread

end of thread, other threads:[~2021-01-05 19:27 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-16 20:11 [PATCH v3 00/11] chrome/platform: cros_ec_typec: Register cables, partner altmodes and plug altmodes Prashant Malani
2020-11-16 20:11 ` [PATCH v3 01/11] usb: pd: Add captive Type C cable type Prashant Malani
2020-11-16 20:11 ` [PATCH v3 02/11] usb: typec: Add number of altmodes partner attr Prashant Malani
2020-11-16 20:11 ` [PATCH v3 03/11] usb: typec: Add plug num_altmodes sysfs attr Prashant Malani
2020-11-17 12:41   ` Heikki Krogerus
2020-11-17 17:40     ` Prashant Malani
2020-11-18 12:04       ` Heikki Krogerus
2020-11-16 20:11 ` [PATCH v3 04/11] platform/chrome: cros_ec_typec: Make disc_done flag partner-only Prashant Malani
2020-11-16 20:11 ` [PATCH v3 05/11] platform/chrome: cros_ec_typec: Factor out PD identity parsing Prashant Malani
2020-11-16 20:11 ` [PATCH v3 06/11] platform/chrome: cros_ec_typec: Rename discovery struct Prashant Malani
2020-11-16 20:11 ` [PATCH v3 07/11] platform/chrome: cros_ec_typec: Register cable Prashant Malani
2020-11-16 20:11 ` [PATCH v3 08/11] platform/chrome: cros_ec_typec: Store cable plug type Prashant Malani
2020-11-16 20:11 ` [PATCH v3 09/11] platform/chrome: cros_ec_typec: Set partner num_altmodes Prashant Malani
2020-11-16 20:11 ` [PATCH v3 10/11] platform/chrome: cros_ec_typec: Register SOP' cable plug Prashant Malani
2020-11-17 12:45   ` Heikki Krogerus
2020-11-16 20:11 ` [PATCH v3 11/11] platform/chrome: cros_ec_typec: Register plug altmodes Prashant Malani
2020-11-17 13:09   ` Heikki Krogerus
2020-11-18 11:59 ` [PATCH v3 00/11] chrome/platform: cros_ec_typec: Register cables, partner altmodes and " Greg KH
2020-11-18 12:16   ` Greg KH
2020-11-19  3:56     ` Prashant Malani
2021-01-05 19:26 ` Benson Leung

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).