Skip to contentSkip to conversation

dt-bindings: usb: add documentation for typec switch simple driver

PATCH Superseded Li Jun 3 participants 13 messages Nov 3, 2020 – Nov 24, 2020

Subsystems (5)

v5 of 7 Superseded Latest is v7 →

lore
Share & tools
lore

Li Jun

author
#0 lore raw

PATCH v5 1/4 dt-bindings: usb: add documentation for typec switch simple driver

Some platforms need a simple driver to do some controls according to typec orientation, this can be extended to be a generic driver with compatible with "typec-orientation-switch".

---
No changes for v5.

changes on v4:
- Use compatible instead of bool property for switch matching.
- Change switch GPIO to be switch simple.
- Change the active channel selection GPIO to be optional.

previous discussion:
http://patchwork.ozlabs.org/patch/1054342/

 .../bindings/usb/typec-switch-simple.yaml          | 69 ++++++++++++++++++++++
 1 file changed, 69 insertions(+)
Documentation/devicetree/bindings/usb/typec-switch-simple.yaml new file +69 -0
new file mode 100644
index 0000000..244162d
@@ -0,0 +1,69 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/usb/typec-switch-simple.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Typec Orientation Switch Simple Solution Bindings
+
+maintainers:
+  - Li Jun <[email protected]>
+
+description: |-
+  USB SuperSpeed (SS) lanes routing to which side of typec connector is
+  decided by orientation, this maybe achieved by some simple control like
+  GPIO toggle.
+
+properties:
+  compatible:
+    const: typec-orientation-switch
+
+  switch-gpios:
+    description: |
+      gpio specifier to switch the super speed active channel,
+      GPIO_ACTIVE_HIGH: GPIO state high for cc1;
+      GPIO_ACTIVE_LOW:  GPIO state low for cc1.
+    maxItems: 1
+
+  port:
+    type: object
+    additionalProperties: false
+    description: -|
+      Connection to the remote endpoint using OF graph bindings that model SS
+      data bus to typec connector.
+
+    properties:
+      endpoint:
+        type: object
+        additionalProperties: false
+
+        properties:
+          remote-endpoint: true
+
+        required:
+          - remote-endpoint
+
+    required:
+      - endpoint
+
+required:
+  - compatible
+  - port
+
+additionalProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/gpio/gpio.h>
+    ptn36043 {
+        compatible = "typec-orientation-switch";
+        pinctrl-names = "default";
+        pinctrl-0 = <&pinctrl_ss_sel>;
+        switch-gpios = <&gpio3 15 GPIO_ACTIVE_HIGH>;
+
+        port {
+                usb3_data_ss: endpoint {
+                        remote-endpoint = <&typec_con_ss>;
+                };
+        };
+    };
Signature · 1 line
2.7.4
author
#1 lore raw

PATCH v5 2/4 device property: Add fwnode_is_compatible() and device_is_compatible() helpers

From: Heikki Krogerus <[email protected]>

Since there are also some ACPI platforms where the "compatible" property is used, introducing a generic helper function fwnode_is_compatible() that can be used with DT, ACPI and swnodes, and a wrapper function device_is_compatible() with it.

The function calls of_device_is_comaptible() with OF nodes, and with ACPI and swnodes it matches the given string against the "compatible" string property array.

---
change for v5
- A minor change to move the function return valure description to a new paragraph.

New patch for v4.

 drivers/base/property.c  | 39 +++++++++++++++++++++++++++++++++++++++
 include/linux/property.h |  2 ++
 2 files changed, 41 insertions(+)
drivers/base/property.c +39 -0
index d58aa98..d1c1f30 100644
@@ -1184,3 +1184,42 @@ const void *device_get_match_data(struct device *dev)
 	return fwnode_call_ptr_op(dev_fwnode(dev), device_get_match_data, dev);
 }
 EXPORT_SYMBOL_GPL(device_get_match_data);
+
+/**
+ * fwnode_is_compatible - Check does fwnode have the given compatible string
+ * @fwnode: fwnode with the "compatible" property
+ * @compat: The compatible string
+ *
+ * Match the compatible strings of @fwnode against @compat.
+ *
+ * Returns positive value on match, and 0 when no matching compatible
+ * string is found.
+ */
+int fwnode_is_compatible(struct fwnode_handle *fwnode, const char *compat)
+{
+	int ret;
+
+	if (is_of_node(fwnode))
+		return of_device_is_compatible(to_of_node(fwnode), compat);
+
+	ret = fwnode_property_match_string(fwnode, "compatible", compat);
+
+	return ret < 0 ? 0 : 1;
+}
+EXPORT_SYMBOL_GPL(fwnode_is_compatible);
+
+/**
+ * device_is_compatible - Check does a device have the given compatible string
+ * @dev: Device with the "compatible" property
+ * @compat: The compatible string
+ *
+ * Match the compatible strings of @dev against @compat.
+ *
+ * Returns positive value on match, and 0 when no matching compatible
+ * string is found.
+ */
+int device_is_compatible(struct device *dev, const char *compat)
+{
+	return fwnode_is_compatible(dev_fwnode(dev), compat);
+}
+EXPORT_SYMBOL_GPL(device_is_compatible);
include/linux/property.h +2 -0
index 9f805c4..42c1d99 100644
@@ -48,6 +48,7 @@ int device_property_read_string(struct device *dev, const char *propname,
 				const char **val);
 int device_property_match_string(struct device *dev,
 				 const char *propname, const char *string);
+int device_is_compatible(struct device *dev, const char *compat);
 
 bool fwnode_device_is_available(const struct fwnode_handle *fwnode);
 bool fwnode_property_present(const struct fwnode_handle *fwnode,
@@ -117,6 +118,7 @@ struct fwnode_handle *fwnode_handle_get(struct fwnode_handle *fwnode);
 void fwnode_handle_put(struct fwnode_handle *fwnode);
 
 int fwnode_irq_get(struct fwnode_handle *fwnode, unsigned int index);
+int fwnode_is_compatible(struct fwnode_handle *fwnode, const char *compat);
 
 unsigned int device_get_child_node_count(struct device *dev);
 
Signature · 1 line
2.7.4
author
#2 lore raw

PATCH v5 3/4 usb: typec: mux: add "compatible" property for switch match

In reply to Li Jun

For those need a dedicated typec switch simple solution driver, use compatible property for matching.

---
No changes for v5
New patch for v4

 drivers/usb/typec/mux.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/usb/typec/mux.c +4 -3
index 52ad277..3da17d1 100644
@@ -39,7 +39,8 @@ static void *typec_switch_match(struct device_connection *con, int ep,
 {
 	struct device *dev;
 
-	if (con->id && !fwnode_property_present(con->fwnode, con->id))
+	if (con->id && !fwnode_is_compatible(con->fwnode, con->id) &&
+		       !fwnode_property_present(con->fwnode, con->id))
 		return NULL;
 
 	dev = class_find_device(&typec_mux_class, NULL, con->fwnode,
@@ -61,8 +62,8 @@ struct typec_switch *fwnode_typec_switch_get(struct fwnode_handle *fwnode)
 {
 	struct typec_switch *sw;
 
-	sw = fwnode_connection_find_match(fwnode, "orientation-switch", NULL,
-					  typec_switch_match);
+	sw = fwnode_connection_find_match(fwnode, "typec-orientation-switch",
+					  NULL, typec_switch_match);
 	if (!IS_ERR_OR_NULL(sw))
 		WARN_ON(!try_module_get(sw->dev.parent->driver->owner));
 
Signature · 1 line
2.7.4
maintainer Acked-by on v5 3/4
#3 lore raw

Re: [PATCH v5 3/4] usb: typec: mux: add "compatible" property for switch match

Quoted 4 lines · Li Jun

For those need a dedicated typec switch simple solution driver, use compatible property for matching.

Quoted 34 lines

---
No changes for v5
New patch for v4

 drivers/usb/typec/mux.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/usb/typec/mux.c +4 -3
index 52ad277..3da17d1 100644
@@ -39,7 +39,8 @@ static void *typec_switch_match(struct device_connection *con, int ep,
 {
 	struct device *dev;
 
-	if (con->id && !fwnode_property_present(con->fwnode, con->id))
+	if (con->id && !fwnode_is_compatible(con->fwnode, con->id) &&
+		       !fwnode_property_present(con->fwnode, con->id))
 		return NULL;
 
 	dev = class_find_device(&typec_mux_class, NULL, con->fwnode,
@@ -61,8 +62,8 @@ struct typec_switch *fwnode_typec_switch_get(struct fwnode_handle *fwnode)
 {
 	struct typec_switch *sw;
 
-	sw = fwnode_connection_find_match(fwnode, "orientation-switch", NULL,
-					  typec_switch_match);
+	sw = fwnode_connection_find_match(fwnode, "typec-orientation-switch",
+					  NULL, typec_switch_match);
 	if (!IS_ERR_OR_NULL(sw))
 		WARN_ON(!try_module_get(sw->dev.parent->driver->owner));
 
Signature · 1 line
2.7.4

thanks,

Signature · 1 line
heikki
author
#4 lore raw

PATCH v5 4/4 usb: typec: mux: add typec switch simple driver

In reply to Li Jun

This patch adds a simple typec switch driver for cases which only needs some simple operations but a dedicated driver is required, current driver only supports GPIO toggle to switch the super speed active channel according to typec orientation.

---
Changes for v5:
- A few changes address Andy's comment, remove gpio check as it's optional, add module name for Kconfig, use correct header files, and other minor changes.
- Remove the mutex lock as it's not required currently.

Changes for v4:
- Change driver name to be switch simple from switch GPIO, to make it generic for possible extention.
- Use compatiable "typec-orientation-switch" instead of bool property for switch matching.
- Make acitve channel selection GPIO to be optional.
- Remove Andy's R-b tag since the driver changes a lot.

Change for v3:
- Remove file name in driver description.
- Add Andy Shevchenko's Reviewed-by tag.

Changes for v2:
- Use the correct head files for gpio api and of_device_id:
#include <linux/gpio/consumer.h>
#include <linux/mod_devicetable.h>
- Add driver dependency on GPIOLIB

 drivers/usb/typec/mux/Kconfig         |  10 ++++
 drivers/usb/typec/mux/Makefile        |   1 +
 drivers/usb/typec/mux/switch-simple.c | 100 ++++++++++++++++++++++++++++++++++
 3 files changed, 111 insertions(+)
drivers/usb/typec/mux/Kconfig +10 -0
index a4dbd11..11320d7 100644
@@ -18,4 +18,14 @@ config TYPEC_MUX_INTEL_PMC
 	  control the USB role switch and also the multiplexer/demultiplexer
 	  switches used with USB Type-C Alternate Modes.
 
+config TYPEC_SWITCH_SIMPLE
+	tristate "Type-C orientation switch simple driver"
+	depends on GPIOLIB
+	help
+	  Say Y or M if your system need a simple driver for typec switch
+	  control, like use GPIO to select active channel.
+
+	  To compile this driver as a module, choose M here: the
+	  module will be called switch-simple.
+
 endmenu
drivers/usb/typec/mux/Makefile +1 -0
index 280a6f5..712d0ad 100644
@@ -2,3 +2,4 @@
 
 obj-$(CONFIG_TYPEC_MUX_PI3USB30532)	+= pi3usb30532.o
 obj-$(CONFIG_TYPEC_MUX_INTEL_PMC)	+= intel_pmc_mux.o
+obj-$(CONFIG_TYPEC_SWITCH_SIMPLE)	+= switch-simple.o
drivers/usb/typec/mux/switch-simple.c new file +100 -0

100 lines not on this page · raw message

Signature · 1 line
2.7.4
maintainer Acked-by on v5 4/4
#5 lore raw

Re: [PATCH v5 4/4] usb: typec: mux: add typec switch simple driver

Quoted 6 lines · Li Jun

This patch adds a simple typec switch driver for cases which only needs some simple operations but a dedicated driver is required, current driver only supports GPIO toggle to switch the super speed active channel according to typec orientation.

Quoted 166 lines

---
Changes for v5:
- A few changes address Andy's comment, remove gpio check as it's optional, add module name for Kconfig, use correct header files, and other minor changes.
- Remove the mutex lock as it's not required currently.

Changes for v4:
- Change driver name to be switch simple from switch GPIO, to make it generic for possible extention.
- Use compatiable "typec-orientation-switch" instead of bool property for switch matching.
- Make acitve channel selection GPIO to be optional.
- Remove Andy's R-b tag since the driver changes a lot.

Change for v3:
- Remove file name in driver description.
- Add Andy Shevchenko's Reviewed-by tag.

Changes for v2:
- Use the correct head files for gpio api and of_device_id:
#include <linux/gpio/consumer.h>
#include <linux/mod_devicetable.h>
- Add driver dependency on GPIOLIB

 drivers/usb/typec/mux/Kconfig         |  10 ++++
 drivers/usb/typec/mux/Makefile        |   1 +
 drivers/usb/typec/mux/switch-simple.c | 100 ++++++++++++++++++++++++++++++++++
 3 files changed, 111 insertions(+)
drivers/usb/typec/mux/Kconfig +10 -0
index a4dbd11..11320d7 100644
@@ -18,4 +18,14 @@ config TYPEC_MUX_INTEL_PMC
 	  control the USB role switch and also the multiplexer/demultiplexer
 	  switches used with USB Type-C Alternate Modes.
 
+config TYPEC_SWITCH_SIMPLE
+	tristate "Type-C orientation switch simple driver"
+	depends on GPIOLIB
+	help
+	  Say Y or M if your system need a simple driver for typec switch
+	  control, like use GPIO to select active channel.
+
+	  To compile this driver as a module, choose M here: the
+	  module will be called switch-simple.
+
 endmenu
drivers/usb/typec/mux/Makefile +1 -0
index 280a6f5..712d0ad 100644
@@ -2,3 +2,4 @@
 
 obj-$(CONFIG_TYPEC_MUX_PI3USB30532)	+= pi3usb30532.o
 obj-$(CONFIG_TYPEC_MUX_INTEL_PMC)	+= intel_pmc_mux.o
+obj-$(CONFIG_TYPEC_SWITCH_SIMPLE)	+= switch-simple.o
drivers/usb/typec/mux/switch-simple.c new file +100 -0
new file mode 100644
index 0000000..8707703
@@ -0,0 +1,100 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Type-C switch simple control driver
+ *
+ * Copyright 2020 NXP
+ * Author: Jun Li <[email protected]>
+ */
+
+#include <linux/delay.h>
+#include <linux/gpio/consumer.h>
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/mod_devicetable.h>
+#include <linux/mutex.h>
+#include <linux/platform_device.h>
+#include <linux/usb/typec_mux.h>
+
+struct typec_switch_simple {
+	struct typec_switch *sw;
+	struct gpio_desc *sel_gpio;
+};
+
+static int typec_switch_simple_set(struct typec_switch *sw,
+				   enum typec_orientation orientation)
+{
+	struct typec_switch_simple *typec_sw = typec_switch_get_drvdata(sw);
+
+	switch (orientation) {
+	case TYPEC_ORIENTATION_NORMAL:
+		gpiod_set_value_cansleep(typec_sw->sel_gpio, 1);
+		break;
+	case TYPEC_ORIENTATION_REVERSE:
+		gpiod_set_value_cansleep(typec_sw->sel_gpio, 0);
+		break;
+	case TYPEC_ORIENTATION_NONE:
+		break;
+	}
+
+	return 0;
+}
+
+static int typec_switch_simple_probe(struct platform_device *pdev)
+{
+	struct device			*dev = &pdev->dev;
+	struct typec_switch_desc	sw_desc;
+	struct typec_switch_simple	*typec_sw;
+
+	typec_sw = devm_kzalloc(dev, sizeof(*typec_sw), GFP_KERNEL);
+	if (!typec_sw)
+		return -ENOMEM;
+
+	platform_set_drvdata(pdev, typec_sw);
+
+	sw_desc.drvdata = typec_sw;
+	sw_desc.fwnode = dev->fwnode;
+	sw_desc.set = typec_switch_simple_set;
+
+	/* Get the super speed active channel selection GPIO */
+	typec_sw->sel_gpio = devm_gpiod_get_optional(dev, "switch", GPIOD_OUT_LOW);
+	if (IS_ERR(typec_sw->sel_gpio))
+		return PTR_ERR(typec_sw->sel_gpio);
+
+	typec_sw->sw = typec_switch_register(dev, &sw_desc);
+	if (IS_ERR(typec_sw->sw)) {
+		dev_err(dev, "Error registering typec switch: %ld\n",
+			PTR_ERR(typec_sw->sw));
+		return PTR_ERR(typec_sw->sw);
+	}
+
+	return 0;
+}
+
+static int typec_switch_simple_remove(struct platform_device *pdev)
+{
+	struct typec_switch_simple *typec_sw = platform_get_drvdata(pdev);
+
+	typec_switch_unregister(typec_sw->sw);
+
+	return 0;
+}
+
+static const struct of_device_id of_typec_switch_simple_match[] = {
+	{ .compatible = "typec-orientation-switch" },
+	{ /* Sentinel */ }
+};
+MODULE_DEVICE_TABLE(of, of_typec_switch_simple_match);
+
+static struct platform_driver typec_switch_simple_driver = {
+	.probe		= typec_switch_simple_probe,
+	.remove		= typec_switch_simple_remove,
+	.driver		= {
+		.name	= "typec-switch-simple",
+		.of_match_table = of_typec_switch_simple_match,
+	},
+};
+
+module_platform_driver(typec_switch_simple_driver);
+MODULE_LICENSE("GPL v2");
+MODULE_DESCRIPTION("TypeC Orientation Switch Simple driver");
+MODULE_AUTHOR("Jun Li <[email protected]>");
Signature · 1 line
2.7.4

thanks,

Signature · 1 line
heikki
author
#6 lore raw

RE: [PATCH v5 4/4] usb: typec: mux: add typec switch simple driver

Quoted 15 lines

-----Original Message-----
From: Heikki Krogerus <[email protected]>
Sent: Monday, November 9, 2020 4:36 PM
To: Jun Li <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; dl-linux-imx <[email protected]>; Peter Chen <[email protected]>
Subject: Re: [PATCH v5 4/4] usb: typec: mux: add typec switch simple driver

On Tue, Nov 03, 2020 at 07:40:10PM +0800, Li Jun wrote:

Quoted 8 lines
Quoted 6 lines

This patch adds a simple typec switch driver for cases which only needs some simple operations but a dedicated driver is required, current driver only supports GPIO toggle to switch the super speed active channel according to typec orientation.

Hi, Heikki,

I have to drop your A-b tag as the driver updated to use mux bindings (drivers/mux/), see v6:

https://patchwork.kernel.org/project/linux-usb/patch/[email protected]/

thanks
Li Jun

maintainer
#7 lore raw
In reply to Li Jun
Quoted 40 lines · Li Jun

Some platforms need a simple driver to do some controls according to typec orientation, this can be extended to be a generic driver with compatible with "typec-orientation-switch".

---
No changes for v5.

changes on v4:
- Use compatible instead of bool property for switch matching.
- Change switch GPIO to be switch simple.
- Change the active channel selection GPIO to be optional.

previous discussion:
http://patchwork.ozlabs.org/patch/1054342/

 .../bindings/usb/typec-switch-simple.yaml          | 69 ++++++++++++++++++++++
 1 file changed, 69 insertions(+)
Documentation/devicetree/bindings/usb/typec-switch-simple.yaml new file +15 -0
new file mode 100644
index 0000000..244162d
@@ -0,0 +1,69 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/usb/typec-switch-simple.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Typec Orientation Switch Simple Solution Bindings
+
+maintainers:
+  - Li Jun <[email protected]>
+
+description: |-
+  USB SuperSpeed (SS) lanes routing to which side of typec connector is
+  decided by orientation, this maybe achieved by some simple control like
+  GPIO toggle.

Documentation/devicetree/bindings/usb/typec-switch-simple.yaml line 25

Quoted 10 lines
Documentation/devicetree/bindings/usb/typec-switch-simple.yaml new file +10 -0
+
+properties:
+  compatible:
+    const: typec-orientation-switch
+
+  switch-gpios:
+    description: |
+      gpio specifier to switch the super speed active channel,
+      GPIO_ACTIVE_HIGH: GPIO state high for cc1;
+      GPIO_ACTIVE_LOW:  GPIO state low for cc1.

What does active mean? There isn't really an active and inactive state, right? It's more a mux selecting 0 or 1 input?

I think you want flags 0 (aka GPIO_ACTIVE_HIGH) unless there's an inverter in the middle.

Quoted 31 lines
Documentation/devicetree/bindings/usb/typec-switch-simple.yaml new file +31 -0
+    maxItems: 1
+
+  port:
+    type: object
+    additionalProperties: false
+    description: -|
+      Connection to the remote endpoint using OF graph bindings that model SS
+      data bus to typec connector.
+
+    properties:
+      endpoint:
+        type: object
+        additionalProperties: false
+
+        properties:
+          remote-endpoint: true
+
+        required:
+          - remote-endpoint
+
+    required:
+      - endpoint
+
+required:
+  - compatible
+  - port
+
+additionalProperties: false
+
+examples:
+  - |

Documentation/devicetree/bindings/usb/typec-switch-simple.yaml line 66

Quoted 10 lines
Documentation/devicetree/bindings/usb/typec-switch-simple.yaml new file +10 -0
+    #include <dt-bindings/gpio/gpio.h>
+    ptn36043 {
+        compatible = "typec-orientation-switch";
+        pinctrl-names = "default";
+        pinctrl-0 = <&pinctrl_ss_sel>;
+        switch-gpios = <&gpio3 15 GPIO_ACTIVE_HIGH>;
+
+        port {
+                usb3_data_ss: endpoint {
+                        remote-endpoint = <&typec_con_ss>;

The data goes from the connector to here and then where? You need a connection to the USB host controller.

Quoted 6 lines
Documentation/devicetree/bindings/usb/typec-switch-simple.yaml new file +3 -0
+                };
+        };
+    };
Signature · 1 line
2.7.4
author
#8 lore raw
Quoted 103 lines

-----Original Message-----
From: Rob Herring <[email protected]>
Sent: Friday, November 6, 2020 6:26 AM
To: Jun Li <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; dl-linux-imx <[email protected]>; Peter Chen <[email protected]>
Subject: Re: [PATCH v5 1/4] dt-bindings: usb: add documentation for typec switch simple driver

Quoted 8 lines · Li Jun

Some platforms need a simple driver to do some controls according to typec orientation, this can be extended to be a generic driver with compatible with "typec-orientation-switch".

---
No changes for v5.

Quoted 7 lines

changes on v4:
- Use compatible instead of bool property for switch matching.
- Change switch GPIO to be switch simple.
- Change the active channel selection GPIO to be optional.

previous discussion:

https://eur01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fpatch

Quoted 1 line

work.ozlabs.org%2Fpatch%2F1054342%2F&amp;data=04%7C01%7Cjun.li%40nxp.c

Quoted 1 line

om%7C78ca5205695149e2743208d881d9c753%7C686ea1d3bc2b4c6fa92cd99c5c3016

Quoted 1 line

35%7C0%7C0%7C637402119664101856%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLj

Quoted 1 line

AwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&amp;sdata=

Quoted 3 lines

8TY%2BPRIui6HhxhYE1%2BLmwWL38Vp7SY1Ceb5rGG%2B4DUo%3D&amp;reserved=0

 .../bindings/usb/typec-switch-simple.yaml          | 69

++++++++++++++++++++++

Quoted 11 lines
 1 file changed, 69 insertions(+)

diff --git a/Documentation/devicetree/bindings/usb/typec-switch-simple.yaml b/Documentation/devicetree/bindings/usb/typec-switch-simple.yaml new file mode 100644
index 0000000..244162d

Documentation/devicetree/bindings/usb/typec-switch-simple.yaml line 3

Quoted 3 lines
Documentation/devicetree/bindings/usb/typec-switch-simple.yaml new file +3 -0
@@ -0,0 +1,69 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) %YAML 1.2
+---
+$id:

+https://eur01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fdevi

Quoted 1 line

+cetree.org%2Fschemas%2Fusb%2Ftypec-switch-simple.yaml%23&amp;data=04%

Quoted 1 line

+7C01%7Cjun.li%40nxp.com%7C78ca5205695149e2743208d881d9c753%7C686ea1d3

Quoted 1 line

+bc2b4c6fa92cd99c5c301635%7C0%7C0%7C637402119664111854%7CUnknown%7CTWF

Quoted 1 line

+pbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6

Quoted 1 line

+Mn0%3D%7C1000&amp;sdata=HjWfKlDLyqb%2FKLlL6vdnyPe%2BnB8pSllhokIXQ%2Bw

Quoted 3 lines

+yyw8%3D&amp;reserved=0
+$schema:

+https://eur01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fdevi

Quoted 1 line

+cetree.org%2Fmeta-schemas%2Fcore.yaml%23&amp;data=04%7C01%7Cjun.li%40

Quoted 1 line

+nxp.com%7C78ca5205695149e2743208d881d9c753%7C686ea1d3bc2b4c6fa92cd99c

Quoted 1 line

+5c301635%7C0%7C0%7C637402119664111854%7CUnknown%7CTWFpbGZsb3d8eyJWIjo

Quoted 1 line

+iMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&am

Quoted 1 line

+p;sdata=z0bO47QVl5gw0UE%2Bx3a5E27ALgz568zp%2Bf4suGlch%2Fo%3D&amp;rese

Quoted 18 lines
Documentation/devicetree/bindings/usb/typec-switch-simple.yaml new file +18 -0
+rved=0
+
+title: Typec Orientation Switch Simple Solution Bindings
+
+maintainers:
+  - Li Jun <[email protected]>
+
+description: |-
+  USB SuperSpeed (SS) lanes routing to which side of typec connector
+is
+  decided by orientation, this maybe achieved by some simple control
+like
+  GPIO toggle.
+
+properties:
+  compatible:
+    const: typec-orientation-switch
+
Quoted 8 lines

Documentation/devicetree/bindings/usb/typec-switch-simple.yaml line 25

Quoted 5 lines
Documentation/devicetree/bindings/usb/typec-switch-simple.yaml new file +5 -0
+  switch-gpios:
+    description: |
+      gpio specifier to switch the super speed active channel,
+      GPIO_ACTIVE_HIGH: GPIO state high for cc1;
+      GPIO_ACTIVE_LOW:  GPIO state low for cc1.

What does active mean? There isn't really an active and inactive state, right? It's more a mux selecting 0 or 1 input?

Yes, I will change the description:
gpio specifier to select the target channel of mux.

Quoted 3 lines

I think you want flags 0 (aka GPIO_ACTIVE_HIGH) unless there's an inverter in the middle.

This depends on the switch IC design and board design, leave 2 flags (GPIO_ACTIVE_HIGH and GPIO_ACTIVE_LOW) can cover all possible cases.

NXP has 2 diff IC parts for this:
1. PTN36043(used on iMX8MQ)
Output selection control
When SEL=0, RX_AP_*/TX_AP_* are connected to RX_CON_2*/TX_CON_2*, and RX_CON_1*/TX_CON_1* are connected to VDD thru low ohmic resistor. When SEL=1, RX_AP_*/TX_AP_* are connected to RX_CON_1*/TX_CON_1*, and RX_CON_2*/TX_CON_2* are connected to VDD thru low ohmic resistor.

Board design connects RX_CON_1*/TX_CON_1* to typec connector CC1, so GPIO_ACTIVE_HIGH

2. CBTU02043(used on iMX8MP)
SEL Function
--------------------------------------
Low A to B ports and vice versa
High A to C ports and vice versa

Board design connects B to typec connector CC1, so GPIO_ACTIVE_LOW

Therefore, we need 2 flags.

Quoted 38 lines

Documentation/devicetree/bindings/usb/typec-switch-simple.yaml

Quoted 8 lines
Documentation/devicetree/bindings/usb/typec-switch-simple.yaml new file +7 -0
+    maxItems: 1
+
+  port:
+    type: object
+    additionalProperties: false
+    description: -|
+      Connection to the remote endpoint using OF graph bindings that model

SS

Quoted 29 lines
Documentation/devicetree/bindings/usb/typec-switch-simple.yaml new file +29 -0
+      data bus to typec connector.
+
+    properties:
+      endpoint:
+        type: object
+        additionalProperties: false
+
+        properties:
+          remote-endpoint: true
+
+        required:
+          - remote-endpoint
+
+    required:
+      - endpoint
+
+required:
+  - compatible
+  - port
+
+additionalProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/gpio/gpio.h>
+    ptn36043 {
+        compatible = "typec-orientation-switch";
+        pinctrl-names = "default";
+        pinctrl-0 = <&pinctrl_ss_sel>;
Quoted 8 lines

Documentation/devicetree/bindings/usb/typec-switch-simple.yaml line 66

Quoted 5 lines
Documentation/devicetree/bindings/usb/typec-switch-simple.yaml new file +5 -0
+        switch-gpios = <&gpio3 15 GPIO_ACTIVE_HIGH>;
+
+        port {
+                usb3_data_ss: endpoint {
+                        remote-endpoint = <&typec_con_ss>;

The data goes from the connector to here and then where? You need a connection to the USB host controller.

The orientation switch only need interact with type-c, no any interaction with USB controller, do we still need a connection to it?

Thanks
Li Jun

Quoted 7 lines
Quoted 7 lines
Documentation/devicetree/bindings/usb/typec-switch-simple.yaml new file +3 -1
+                };
+        };
+    };
--

2.7.4

maintainer
#9 lore raw
Quoted 113 lines · Jun Li
Quoted 104 lines

-----Original Message-----
From: Rob Herring <[email protected]>
Sent: Friday, November 6, 2020 6:26 AM
To: Jun Li <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; dl-linux-imx <[email protected]>; Peter Chen <[email protected]>
Subject: Re: [PATCH v5 1/4] dt-bindings: usb: add documentation for typec switch simple driver

Quoted 8 lines · Li Jun

Some platforms need a simple driver to do some controls according to typec orientation, this can be extended to be a generic driver with compatible with "typec-orientation-switch".

---
No changes for v5.

Quoted 7 lines

changes on v4:
- Use compatible instead of bool property for switch matching.
- Change switch GPIO to be switch simple.
- Change the active channel selection GPIO to be optional.

previous discussion:

https://eur01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fpatch

Quoted 1 line

work.ozlabs.org%2Fpatch%2F1054342%2F&amp;data=04%7C01%7Cjun.li%40nxp.c

Quoted 1 line

om%7C78ca5205695149e2743208d881d9c753%7C686ea1d3bc2b4c6fa92cd99c5c3016

Quoted 1 line

35%7C0%7C0%7C637402119664101856%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLj

Quoted 1 line

AwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&amp;sdata=

Quoted 3 lines

8TY%2BPRIui6HhxhYE1%2BLmwWL38Vp7SY1Ceb5rGG%2B4DUo%3D&amp;reserved=0

 .../bindings/usb/typec-switch-simple.yaml          | 69

++++++++++++++++++++++

Quoted 11 lines
 1 file changed, 69 insertions(+)

diff --git a/Documentation/devicetree/bindings/usb/typec-switch-simple.yaml b/Documentation/devicetree/bindings/usb/typec-switch-simple.yaml new file mode 100644
index 0000000..244162d

Documentation/devicetree/bindings/usb/typec-switch-simple.yaml line 3

Quoted 3 lines
Documentation/devicetree/bindings/usb/typec-switch-simple.yaml new file +3 -0
@@ -0,0 +1,69 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) %YAML 1.2
+---
+$id:

+https://eur01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fdevi

Quoted 1 line

+cetree.org%2Fschemas%2Fusb%2Ftypec-switch-simple.yaml%23&amp;data=04%

Quoted 1 line

+7C01%7Cjun.li%40nxp.com%7C78ca5205695149e2743208d881d9c753%7C686ea1d3

Quoted 1 line

+bc2b4c6fa92cd99c5c301635%7C0%7C0%7C637402119664111854%7CUnknown%7CTWF

Quoted 1 line

+pbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6

Quoted 1 line

+Mn0%3D%7C1000&amp;sdata=HjWfKlDLyqb%2FKLlL6vdnyPe%2BnB8pSllhokIXQ%2Bw

Quoted 3 lines

+yyw8%3D&amp;reserved=0
+$schema:

+https://eur01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fdevi

Quoted 1 line

+cetree.org%2Fmeta-schemas%2Fcore.yaml%23&amp;data=04%7C01%7Cjun.li%40

Quoted 1 line

+nxp.com%7C78ca5205695149e2743208d881d9c753%7C686ea1d3bc2b4c6fa92cd99c

Quoted 1 line

+5c301635%7C0%7C0%7C637402119664111854%7CUnknown%7CTWFpbGZsb3d8eyJWIjo

Quoted 1 line

+iMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&am

Quoted 1 line

+p;sdata=z0bO47QVl5gw0UE%2Bx3a5E27ALgz568zp%2Bf4suGlch%2Fo%3D&amp;rese

Quoted 18 lines
Documentation/devicetree/bindings/usb/typec-switch-simple.yaml new file +18 -0
+rved=0
+
+title: Typec Orientation Switch Simple Solution Bindings
+
+maintainers:
+  - Li Jun <[email protected]>
+
+description: |-
+  USB SuperSpeed (SS) lanes routing to which side of typec connector
+is
+  decided by orientation, this maybe achieved by some simple control
+like
+  GPIO toggle.
+
+properties:
+  compatible:
+    const: typec-orientation-switch
+
Quoted 8 lines

Documentation/devicetree/bindings/usb/typec-switch-simple.yaml line 25

Quoted 5 lines
Documentation/devicetree/bindings/usb/typec-switch-simple.yaml new file +5 -0
+  switch-gpios:
+    description: |
+      gpio specifier to switch the super speed active channel,
+      GPIO_ACTIVE_HIGH: GPIO state high for cc1;
+      GPIO_ACTIVE_LOW:  GPIO state low for cc1.

What does active mean? There isn't really an active and inactive state, right? It's more a mux selecting 0 or 1 input?

Quoted 2 lines

Yes, I will change the description:
gpio specifier to select the target channel of mux.

I wonder if the existing mux bindings should be used here.

Quoted 23 lines
Quoted 2 lines

I think you want flags 0 (aka GPIO_ACTIVE_HIGH) unless there's an inverter in the middle.

This depends on the switch IC design and board design, leave 2 flags (GPIO_ACTIVE_HIGH and GPIO_ACTIVE_LOW) can cover all possible cases.

NXP has 2 diff IC parts for this:
1. PTN36043(used on iMX8MQ)
Output selection control
When SEL=0, RX_AP_*/TX_AP_* are connected to RX_CON_2*/TX_CON_2*, and RX_CON_1*/TX_CON_1* are connected to VDD thru low ohmic resistor. When SEL=1, RX_AP_*/TX_AP_* are connected to RX_CON_1*/TX_CON_1*, and RX_CON_2*/TX_CON_2* are connected to VDD thru low ohmic resistor.

Board design connects RX_CON_1*/TX_CON_1* to typec connector CC1, so GPIO_ACTIVE_HIGH

2. CBTU02043(used on iMX8MP)
SEL Function
--------------------------------------
Low A to B ports and vice versa
High A to C ports and vice versa

Quoted 3 lines

Board design connects B to typec connector CC1, so GPIO_ACTIVE_LOW

Therefore, we need 2 flags.

I'm not saying you don't. Just that the description is a bit odd. Please expand the description for how one decides how to set the flags.

Quoted 48 lines
Quoted 39 lines

Documentation/devicetree/bindings/usb/typec-switch-simple.yaml

Quoted 9 lines
Documentation/devicetree/bindings/usb/typec-switch-simple.yaml new file +7 -0
+    maxItems: 1
+
+  port:
+    type: object
+    additionalProperties: false
+    description: -|
+      Connection to the remote endpoint using OF graph bindings that model

SS

Quoted 29 lines
Documentation/devicetree/bindings/usb/typec-switch-simple.yaml new file +29 -0
+      data bus to typec connector.
+
+    properties:
+      endpoint:
+        type: object
+        additionalProperties: false
+
+        properties:
+          remote-endpoint: true
+
+        required:
+          - remote-endpoint
+
+    required:
+      - endpoint
+
+required:
+  - compatible
+  - port
+
+additionalProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/gpio/gpio.h>
+    ptn36043 {
+        compatible = "typec-orientation-switch";
+        pinctrl-names = "default";
+        pinctrl-0 = <&pinctrl_ss_sel>;
Quoted 8 lines

Documentation/devicetree/bindings/usb/typec-switch-simple.yaml line 66

Quoted 5 lines
Documentation/devicetree/bindings/usb/typec-switch-simple.yaml new file +5 -0
+        switch-gpios = <&gpio3 15 GPIO_ACTIVE_HIGH>;
+
+        port {
+                usb3_data_ss: endpoint {
+                        remote-endpoint = <&typec_con_ss>;

The data goes from the connector to here and then where? You need a connection to the USB host controller.

Quoted 2 lines

The orientation switch only need interact with type-c, no any interaction with USB controller, do we still need a connection to it?

If you have 2 USB hosts and 2 connectors (and 2 muxes), how would you describe which connector goes with which host?

Rob

author
#10 lore raw
Quoted 149 lines

-----Original Message-----
From: Rob Herring <[email protected]>
Sent: Friday, November 6, 2020 10:24 PM
To: Jun Li <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; dl-linux-imx <[email protected]>; Peter Chen <[email protected]>
Subject: Re: [PATCH v5 1/4] dt-bindings: usb: add documentation for typec switch simple driver

Quoted 123 lines · Jun Li
Quoted 123 lines

-----Original Message-----
From: Rob Herring <[email protected]>
Sent: Friday, November 6, 2020 6:26 AM
To: Jun Li <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; dl-linux-imx <[email protected]>; Peter Chen <[email protected]>
Subject: Re: [PATCH v5 1/4] dt-bindings: usb: add documentation for typec switch simple driver

Quoted 8 lines · Li Jun

Some platforms need a simple driver to do some controls according to typec orientation, this can be extended to be a generic driver with compatible with "typec-orientation-switch".

---
No changes for v5.

Quoted 7 lines

changes on v4:
- Use compatible instead of bool property for switch matching.
- Change switch GPIO to be switch simple.
- Change the active channel selection GPIO to be optional.

previous discussion:

https://eur01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fpat
ch

Quoted 1 line

work.ozlabs.org%2Fpatch%2F1054342%2F&amp;data=04%7C01%7Cjun.li%40nxp .c

Quoted 1 line

om%7C78ca5205695149e2743208d881d9c753%7C686ea1d3bc2b4c6fa92cd99c5c30 16

Quoted 1 line

35%7C0%7C0%7C637402119664101856%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4w Lj

Quoted 1 line

AwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&amp;sdat a=

Quoted 4 lines

8TY%2BPRIui6HhxhYE1%2BLmwWL38Vp7SY1Ceb5rGG%2B4DUo%3D&amp;reserved= 0

 .../bindings/usb/typec-switch-simple.yaml          | 69

++++++++++++++++++++++

Quoted 16 lines
 1 file changed, 69 insertions(+)

diff --git a/Documentation/devicetree/bindings/usb/typec-switch-simple.yaml b/Documentation/devicetree/bindings/usb/typec-switch-simple.yaml new file mode 100644
index 0000000..244162d

Documentation/devicetree/bindings/usb/typec-switch-simple.ya new file +5 -0
+++ ml
@@ -0,0 +1,69 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) %YAML
+1.2
+---
+$id:
(quoted diff) +2 -0
+https://eur01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fde
+vi
Quoted 1 line

+cetree.org%2Fschemas%2Fusb%2Ftypec-switch-simple.yaml%23&amp;data=0 +4%

Quoted 1 line

+7C01%7Cjun.li%40nxp.com%7C78ca5205695149e2743208d881d9c753%7C686ea1 +d3

Quoted 1 line
(quoted diff) +2 -0
+bc2b4c6fa92cd99c5c301635%7C0%7C0%7C637402119664111854%7CUnknown%7CT
+WF
Quoted 1 line
(quoted diff) +2 -0
+pbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVC
+I6
Quoted 1 line
(quoted diff) +2 -0
+Mn0%3D%7C1000&amp;sdata=HjWfKlDLyqb%2FKLlL6vdnyPe%2BnB8pSllhokIXQ%2
+Bw
Quoted 3 lines

+yyw8%3D&amp;reserved=0
+$schema:

(quoted diff) +2 -0
+https://eur01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fde
+vi
Quoted 1 line

+cetree.org%2Fmeta-schemas%2Fcore.yaml%23&amp;data=04%7C01%7Cjun.li% +40

Quoted 1 line

+nxp.com%7C78ca5205695149e2743208d881d9c753%7C686ea1d3bc2b4c6fa92cd9 +9c

Quoted 1 line

+5c301635%7C0%7C0%7C637402119664111854%7CUnknown%7CTWFpbGZsb3d8eyJWI +jo

Quoted 1 line
(quoted diff) +2 -0
+iMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&
+am
Quoted 1 line
(quoted diff) +2 -0
+p;sdata=z0bO47QVl5gw0UE%2Bx3a5E27ALgz568zp%2Bf4suGlch%2Fo%3D&amp;re
+se
Quoted 17 lines
Documentation/devicetree/bindings/usb/typec-switch-simple.ya new file +17 -0
+rved=0
+
+title: Typec Orientation Switch Simple Solution Bindings
+
+maintainers:
+  - Li Jun <[email protected]>
+
+description: |-
+  USB SuperSpeed (SS) lanes routing to which side of typec
+connector is
+  decided by orientation, this maybe achieved by some simple
+control like
+  GPIO toggle.
+
+properties:
+  compatible:
+    const: typec-orientation-switch
Quoted 8 lines
Quoted 8 lines

Documentation/devicetree/bindings/usb/typec-switch-simple.ya

Quoted 6 lines
Documentation/devicetree/bindings/usb/typec-switch-simple.ya new file +6 -0
+
+  switch-gpios:
+    description: |
+      gpio specifier to switch the super speed active channel,
+      GPIO_ACTIVE_HIGH: GPIO state high for cc1;
+      GPIO_ACTIVE_LOW:  GPIO state low for cc1.

What does active mean? There isn't really an active and inactive state,

Quoted 7 lines

right?

Quoted 4 lines
Quoted 1 line

It's more a mux selecting 0 or 1 input?

Yes, I will change the description:
gpio specifier to select the target channel of mux.

I wonder if the existing mux bindings should be used here.

If only consider typec switch via "gpio", existing "mux-gpio" binding may be used with property "mux-control-names" to be "typec-xxx" for match, but we still need create typec stuff at mux driver to hook to typec system, so little benefit, considering this binding is going to be for a generic typec orientation switch simple driver, I think a new typec binding make sense.

Quoted 24 lines
Quoted 24 lines
Quoted 3 lines

I think you want flags 0 (aka GPIO_ACTIVE_HIGH) unless there's an inverter in the middle.

This depends on the switch IC design and board design, leave 2 flags (GPIO_ACTIVE_HIGH and GPIO_ACTIVE_LOW) can cover all possible cases.

NXP has 2 diff IC parts for this:
1. PTN36043(used on iMX8MQ)
Output selection control
When SEL=0, RX_AP_*/TX_AP_* are connected to RX_CON_2*/TX_CON_2*, and RX_CON_1*/TX_CON_1* are connected to VDD thru low ohmic resistor. When SEL=1, RX_AP_*/TX_AP_* are connected to RX_CON_1*/TX_CON_1*, and RX_CON_2*/TX_CON_2* are connected to VDD thru low ohmic resistor.

Board design connects RX_CON_1*/TX_CON_1* to typec connector CC1, so GPIO_ACTIVE_HIGH

2. CBTU02043(used on iMX8MP)
SEL Function
--------------------------------------
Low A to B ports and vice versa
High A to C ports and vice versa

Quoted 6 lines
Quoted 3 lines

Board design connects B to typec connector CC1, so GPIO_ACTIVE_LOW

Therefore, we need 2 flags.

I'm not saying you don't. Just that the description is a bit odd. Please expand the description for how one decides how to set the flags.

Misunderstood your point, OK, I thought the "how to set the flags" was simple and clear enough:
Use GPIO_ACTIVE_HIGH if GPIO physical state high is for cc1; or Use GPIO_ACTIVE_LOW if GPIO physical state low is for cc1.

Quoted 50 lines
Quoted 50 lines
Quoted 49 lines

Documentation/devicetree/bindings/usb/typec-switch-simple.ya

Quoted 11 lines
Documentation/devicetree/bindings/usb/typec-switch-simple.ya new file +8 -0
+    maxItems: 1
+
+  port:
+    type: object
+    additionalProperties: false
+    description: -|
+      Connection to the remote endpoint using OF graph bindings
+ that model

SS

Quoted 24 lines
Documentation/devicetree/bindings/usb/typec-switch-simple.ya new file +24 -0
+      data bus to typec connector.
+
+    properties:
+      endpoint:
+        type: object
+        additionalProperties: false
+
+        properties:
+          remote-endpoint: true
+
+        required:
+          - remote-endpoint
+
+    required:
+      - endpoint
+
+required:
+  - compatible
+  - port
+
+additionalProperties: false
+
+examples:
+  - |

Documentation/devicetree/bindings/usb/typec-switch-simple.ya

Quoted 10 lines
Documentation/devicetree/bindings/usb/typec-switch-simple.ya new file +10 -0
+    #include <dt-bindings/gpio/gpio.h>
+    ptn36043 {
+        compatible = "typec-orientation-switch";
+        pinctrl-names = "default";
+        pinctrl-0 = <&pinctrl_ss_sel>;
+        switch-gpios = <&gpio3 15 GPIO_ACTIVE_HIGH>;
+
+        port {
+                usb3_data_ss: endpoint {
+                        remote-endpoint = <&typec_con_ss>;

The data goes from the connector to here and then where? You need a connection to the USB host controller.

Quoted 5 lines
Quoted 2 lines

The orientation switch only need interact with type-c, no any interaction with USB controller, do we still need a connection to it?

If you have 2 USB hosts and 2 connectors (and 2 muxes), how would you describe which connector goes with which host?

One instance of typec orientation switch defined by this binding only for One typec connector. With that, my understanding is
Whether a connection need be described depends on if the connector (typec driver) need notify the host controller driver to do something (e.g. role switch need a connection between controller node and connector node for controller driver to swap usb role). If the mux/switch control is transparent to usb host controller (e.g. my case, usb controller drivers normally don't need do anything for orientation change), there is no need to describe connection between orientation switch node and host controller node.

Thanks
Li Jun

Quoted 2 lines

Rob

maintainer
#11 lore raw
Quoted 21 lines · Jun Li
Quoted 21 lines

From: Rob Herring <[email protected]>

Quoted 13 lines · Jun Li
Quoted 13 lines

From: Rob Herring <[email protected]>

Documentation/devicetree/bindings/usb/typec-switch-simple.yaml line 25

Quoted 9 lines
Documentation/devicetree/bindings/usb/typec-switch-simple.yaml new file +9 -0
+properties:
+  compatible:
+    const: typec-orientation-switch
+
+  switch-gpios:
+    description: |
+      gpio specifier to switch the super speed active channel,
+      GPIO_ACTIVE_HIGH: GPIO state high for cc1;
+      GPIO_ACTIVE_LOW:  GPIO state low for cc1.

What does active mean? There isn't really an active and inactive state,

right?

Quoted 4 lines
Quoted 1 line

It's more a mux selecting 0 or 1 input?

Yes, I will change the description:
gpio specifier to select the target channel of mux.

Quoted 8 lines
Quoted 1 line

I wonder if the existing mux bindings should be used here.

If only consider typec switch via "gpio", existing "mux-gpio" binding may be used with property "mux-control-names" to be "typec-xxx" for match, but we still need create typec stuff at mux driver to hook to typec system, so little benefit, considering this binding is going to be for a generic typec orientation switch simple driver, I think a new typec binding make sense.

You can instantiate drivers without a compatible. That's just the easy way. However, using the mux binding doesn't necessarily mean you have to use 'mux-gpio'. Consider if you need to do more control than just the GPIO line. For example, the chips you mentioned may have a s/w controlled power supply or reset.

Also, consider what the mux would look like with different control interfaces. That could be I2C or some sub-block in a PMIC or ??? I'm sure we already have some examples. I'm not happy with these piecemeal additions to TypeC related bindings that don't consider more than 1 h/w possibility.

Quoted 27 lines
Quoted 27 lines
Quoted 26 lines
Quoted 2 lines

I think you want flags 0 (aka GPIO_ACTIVE_HIGH) unless there's an inverter in the middle.

This depends on the switch IC design and board design, leave 2 flags (GPIO_ACTIVE_HIGH and GPIO_ACTIVE_LOW) can cover all possible cases.

NXP has 2 diff IC parts for this:
1. PTN36043(used on iMX8MQ)
Output selection control
When SEL=0, RX_AP_*/TX_AP_* are connected to RX_CON_2*/TX_CON_2*, and RX_CON_1*/TX_CON_1* are connected to VDD thru low ohmic resistor. When SEL=1, RX_AP_*/TX_AP_* are connected to RX_CON_1*/TX_CON_1*, and RX_CON_2*/TX_CON_2* are connected to VDD thru low ohmic resistor.

Board design connects RX_CON_1*/TX_CON_1* to typec connector CC1, so GPIO_ACTIVE_HIGH

2. CBTU02043(used on iMX8MP)
SEL Function
--------------------------------------
Low A to B ports and vice versa
High A to C ports and vice versa

Board design connects B to typec connector CC1, so GPIO_ACTIVE_LOW

Therefore, we need 2 flags.

Quoted 7 lines
Quoted 2 lines

I'm not saying you don't. Just that the description is a bit odd. Please expand the description for how one decides how to set the flags.

Misunderstood your point, OK, I thought the "how to set the flags" was simple and clear enough:
Use GPIO_ACTIVE_HIGH if GPIO physical state high is for cc1; or Use GPIO_ACTIVE_LOW if GPIO physical state low is for cc1.

Okay.

Quoted 22 lines
Quoted 16 lines
Quoted 16 lines
Quoted 15 lines

Documentation/devicetree/bindings/usb/typec-switch-simple.yaml line 66

Quoted 12 lines
Documentation/devicetree/bindings/usb/typec-switch-simple.yaml new file +12 -0
+examples:
+  - |
+    #include <dt-bindings/gpio/gpio.h>
+    ptn36043 {
+        compatible = "typec-orientation-switch";
+        pinctrl-names = "default";
+        pinctrl-0 = <&pinctrl_ss_sel>;
+        switch-gpios = <&gpio3 15 GPIO_ACTIVE_HIGH>;
+
+        port {
+                usb3_data_ss: endpoint {
+                        remote-endpoint = <&typec_con_ss>;

The data goes from the connector to here and then where? You need a connection to the USB host controller.

Quoted 5 lines
Quoted 2 lines

The orientation switch only need interact with type-c, no any interaction with USB controller, do we still need a connection to it?

If you have 2 USB hosts and 2 connectors (and 2 muxes), how would you describe which connector goes with which host?

Quoted 10 lines

One instance of typec orientation switch defined by this binding only for One typec connector. With that, my understanding is
Whether a connection need be described depends on if the connector (typec driver) need notify the host controller driver to do something (e.g. role switch need a connection between controller node and connector node for controller driver to swap usb role). If the mux/switch control is transparent to usb host controller (e.g. my case, usb controller drivers normally don't need do anything for orientation change), there is no need to describe connection between orientation switch node and host controller node.

There can be several reasons you need to know the association. When writing the DT you can't assume what information is or isn't needed. That may vary by h/w or can evolve in an OS and the DT shouldn't change.

Rob

author
#12 lore raw

Hi Rob

Quoted 53 lines

-----Original Message-----
From: Rob Herring <[email protected]>
Sent: Monday, November 9, 2020 10:38 PM
To: Jun Li <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; dl-linux-imx <[email protected]>; Peter Chen <[email protected]>
Subject: Re: [PATCH v5 1/4] dt-bindings: usb: add documentation for typec switch simple driver

Quoted 22 lines · Jun Li
Quoted 22 lines

From: Rob Herring <[email protected]>

Quoted 14 lines · Jun Li
Quoted 14 lines

From: Rob Herring <[email protected]>

Documentation/devicetree/bindings/usb/typec-switch-simple.yaml line 25

Quoted 9 lines
Documentation/devicetree/bindings/usb/typec-switch-simple.yaml new file +9 -0
+properties:
+  compatible:
+    const: typec-orientation-switch
+
+  switch-gpios:
+    description: |
+      gpio specifier to switch the super speed active channel,
+      GPIO_ACTIVE_HIGH: GPIO state high for cc1;
+      GPIO_ACTIVE_LOW:  GPIO state low for cc1.

What does active mean? There isn't really an active and inactive state,

right?

Quoted 4 lines
Quoted 1 line

It's more a mux selecting 0 or 1 input?

Yes, I will change the description:
gpio specifier to select the target channel of mux.

Quoted 8 lines
Quoted 1 line

I wonder if the existing mux bindings should be used here.

If only consider typec switch via "gpio", existing "mux-gpio" binding may be used with property "mux-control-names" to be "typec-xxx" for match, but we still need create typec stuff at mux driver to hook to typec system, so little benefit, considering this binding is going to be for a generic typec orientation switch simple driver, I think a new typec binding make sense.

You can instantiate drivers without a compatible. That's just the easy way. However, using the mux binding doesn't necessarily mean you have to use 'mux-gpio'. Consider if you need to do more control than just the GPIO line. For example, the chips you mentioned may have a s/w controlled power supply or reset.

Quoted 4 lines

Also, consider what the mux would look like with different control interfaces. That could be I2C or some sub-block in a PMIC or ??? I'm sure we already have some examples. I'm not happy with these piecemeal additions to TypeC related bindings that don't consider more than 1 h/w possibility.

As typec class sub system already has its own interface(and users) to do switch/mux control, using existing mux bindings means typec class will add switch/mux control through another approach(mux chip/controller interface), this makes the typec mux looks having 2 similar way for the same function. so I was hesitating to use it.

After more check, I agree creating typec specific bindings will duplicate much existing mux bindings, the mux controller based bindings can be a good way used for various typec switch/mux, so I will try typec orientation compatible with mux controller bindings.

Quoted 74 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 3 lines

I think you want flags 0 (aka GPIO_ACTIVE_HIGH) unless there's an inverter in the middle.

This depends on the switch IC design and board design, leave 2 flags (GPIO_ACTIVE_HIGH and GPIO_ACTIVE_LOW) can cover all possible

cases.

Quoted 24 lines
Quoted 24 lines
Quoted 23 lines

NXP has 2 diff IC parts for this:
1. PTN36043(used on iMX8MQ)
Output selection control
When SEL=0, RX_AP_*/TX_AP_* are connected to RX_CON_2*/TX_CON_2*, and
RX_CON_1*/TX_CON_1* are connected to VDD thru low ohmic resistor. When SEL=1, RX_AP_*/TX_AP_* are connected to RX_CON_1*/TX_CON_1*, and
RX_CON_2*/TX_CON_2* are connected to VDD thru low ohmic resistor.

Board design connects RX_CON_1*/TX_CON_1* to typec connector CC1, so GPIO_ACTIVE_HIGH

2. CBTU02043(used on iMX8MP)
SEL Function
--------------------------------------
Low A to B ports and vice versa
High A to C ports and vice versa

Board design connects B to typec connector CC1, so GPIO_ACTIVE_LOW

Therefore, we need 2 flags.

Quoted 7 lines
Quoted 2 lines

I'm not saying you don't. Just that the description is a bit odd. Please expand the description for how one decides how to set the flags.

Misunderstood your point, OK, I thought the "how to set the flags" was simple and clear enough:
Use GPIO_ACTIVE_HIGH if GPIO physical state high is for cc1; or Use GPIO_ACTIVE_LOW if GPIO physical state low is for cc1.

Okay.

Quoted 22 lines
Quoted 16 lines
Quoted 16 lines
Quoted 15 lines

Documentation/devicetree/bindings/usb/typec-switch-simple.yaml line 66

Quoted 12 lines
Documentation/devicetree/bindings/usb/typec-switch-simple.yaml new file +12 -0
+examples:
+  - |
+    #include <dt-bindings/gpio/gpio.h>
+    ptn36043 {
+        compatible = "typec-orientation-switch";
+        pinctrl-names = "default";
+        pinctrl-0 = <&pinctrl_ss_sel>;
+        switch-gpios = <&gpio3 15 GPIO_ACTIVE_HIGH>;
+
+        port {
+                usb3_data_ss: endpoint {
+                        remote-endpoint = <&typec_con_ss>;

The data goes from the connector to here and then where? You need a connection to the USB host controller.

Quoted 5 lines
Quoted 2 lines

The orientation switch only need interact with type-c, no any interaction with USB controller, do we still need a connection to it?

If you have 2 USB hosts and 2 connectors (and 2 muxes), how would you describe which connector goes with which host?

Quoted 10 lines

One instance of typec orientation switch defined by this binding only for One typec connector. With that, my understanding is Whether a connection need be described depends on if the connector (typec driver) need notify the host controller driver to do something (e.g. role switch need a connection between controller node and connector node for controller driver to swap usb role). If the mux/switch control is transparent to usb host controller (e.g. my case, usb controller drivers normally don't need do anything for orientation change), there is no need to describe connection between orientation switch node and host controller node.

Quoted 3 lines

There can be several reasons you need to know the association. When writing the DT you can't assume what information is or isn't needed. That may vary by h/w or can evolve in an OS and the DT shouldn't change.

Okay, I will add the connection to usb controller in example.

Thanks
Li Jun

Quoted 2 lines

Rob