Skip to contentSkip to conversation

extcon: Add Type-C Virtual PD

PATCH In review Jagan Teki 4 participants 8 messages Sep 4, 2020 – Sep 15, 2020

Subsystems (3)
lore
Share & tools
lore

Jagan Teki

author
#0 lore raw

cover extcon: Add Type-C Virtual PD

USB Type-C protocol supports various modes of operations includes PD, USB3, and Altmode. If the platform design supports a Type-C connector then configuring these modes can be done via enumeration.

However, there are some platforms that design these modes of operations as separate protocol connectors like design Display Port from on-chip USB3 controller. So accessing Type-C Altmode Display Port via onboard Display Port connector instead of a Type-C connector.

These kinds of platforms require an explicit extcon driver in order to handle Power Delivery and Port Detection.

This series support this Type-C Virtual PD and enable the same in ROCK Pi 4C SBC.

Any inputs?
Jagan.

Jagan Teki (3):
dt-bindings: extcon: Document Type-C Virtual PD driver
extcon: Add Type-C Virtual PD driver
arm64: dts: rk3399-rock-pi-4c: Enable Display Port

 .../extcon/extcon-usbc-virtual-pd.yaml        |  66 ++++
 MAINTAINERS                                   |   6 +
 .../boot/dts/rockchip/rk3399-rock-pi-4c.dts   |  16 +
 drivers/extcon/Kconfig                        |  10 +
 drivers/extcon/Makefile                       |   1 +
 drivers/extcon/extcon-usbc-virtual-pd.c       | 285 ++++++++++++++++++
 6 files changed, 384 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/extcon/extcon-usbc-virtual-pd.yaml
 create mode 100644 drivers/extcon/extcon-usbc-virtual-pd.c
Signature · 1 line
2.25.1
author
#1 lore raw

PATCH 1/3 dt-bindings: extcon: Document Type-C Virtual PD driver

USB Type-C protocol supports various modes of operations includes PD, USB3, and Altmode. If the platform design supports a Type-C connector then configuring these modes can be done via enumeration.

However, there are some platforms that design these modes of operations as separate protocol connectors like design Display Port from on-chip USB3 controller. So accessing Type-C Altmode Display Port via onboard Display Port connector instead of a Type-C connector.

These kinds of platforms require an explicit extcon driver in order to handle Power Delivery and Port Detection.

Document dt-bindings for it.

---
 .../extcon/extcon-usbc-virtual-pd.yaml        | 66 +++++++++++++++++++
 1 file changed, 66 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/extcon/extcon-usbc-virtual-pd.yaml
Documentation/devicetree/bindings/extcon/extcon-usbc-virtual-pd.yaml new file +66 -0
new file mode 100644
index 000000000000..8110fbe2ddc2
@@ -0,0 +1,66 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/extcon/extcon-usbc-virtual-pd.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Type-C Virtual PD extcon
+
+maintainers:
+  - Jagan Teki <[email protected]>
+
+description: |
+  USB Type-C protocol supports various modes of operations includes PD,
+  USB3, and Altmode. If the platform design supports a Type-C connector
+  then configuring these modes can be done via enumeration.
+
+  However, there are some platforms that design these modes as separate
+  protocol connectors like design Display Port from on-chip USB3 controller.
+  So we can access Type-C Altmode Display Port via onboard Display Port
+  connector instead of a Type-C connector. These kinds of platforms require
+  an explicit extcon driver in order to handle Power Delivery and
+  Port Detection.
+
+properties:
+  compatible:
+    const: linux,extcon-usbc-virtual-pd
+
+  det-gpios:
+    description: Detect GPIO pin. Pin can be Display Port Detect or USB ID.
+    maxItems: 1
+
+  vpd-polarity:
+    description: USB Type-C Polarity. false for Normal and true for Flip.
+    type: boolean
+
+  vpd-super-speed:
+    description: USB Super Speed. false for USB2 and true for USB3.
+    type: boolean
+
+  vpd-data-role:
+    description: USB Data roles for Virtual Type-C.
+    $ref: /schemas/types.yaml#definitions/string
+
+    enum:
+      - host
+      - device
+      - display-port
+
+required:
+  - compatible
+  - det-gpios
+  - vpd-data-role
+
+additionalProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/gpio/gpio.h>
+    #include <dt-bindings/pinctrl/rockchip.h>
+
+    virtual_pd: virtual-pd {
+        compatible = "linux,extcon-usbc-virtual-pd";
+        det-gpios = <&gpio4 RK_PD1 GPIO_ACTIVE_LOW>;
+        vpd-data-role = "display-port";
+        vpd-super-speed;
+    };
Signature · 1 line
2.25.1
author
#2 lore raw

PATCH 2/3 extcon: Add Type-C Virtual PD driver

In reply to Jagan Teki

USB Type-C protocol supports various modes of operations includes PD, USB3, and Altmode. If the platform design supports a Type-C connector then configuring these modes can be done via enumeration.

However, there are some platforms that design these modes of operations as separate protocol connectors like design Display Port from on-chip USB3 controller. So accessing Type-C Altmode Display Port via onboard Display Port connector instead of a Type-C connector.

These kinds of platforms require an explicit extcon driver in order to handle Power Delivery and Port Detection.

Add extcon driver for it.

---
 MAINTAINERS                             |   6 +
 drivers/extcon/Kconfig                  |  10 +
 drivers/extcon/Makefile                 |   1 +
 drivers/extcon/extcon-usbc-virtual-pd.c | 285 ++++++++++++++++++++++++
 4 files changed, 302 insertions(+)
 create mode 100644 drivers/extcon/extcon-usbc-virtual-pd.c
MAINTAINERS +6 -0
index 68f21d46614c..aeb161b19dae 100644
@@ -6466,6 +6466,12 @@ T:	git git://git.kernel.org/pub/scm/linux/kernel/git/tytso/ext4.git
 F:	Documentation/filesystems/ext4/
 F:	fs/ext4/
 
+EXTCON DRIVER FOR TYPE-C VIRTUAL PD
+M:	Jagan Teki <[email protected]>
+S:	Maintained
+F:	Documentation/devicetree/bindings/extcon/extcon-usbc-virtual-pd.yaml
+F:	drivers/extcon/extcon-usbc-virtual-pd.c
+
 Extended Verification Module (EVM)
 M:	Mimi Zohar <[email protected]>
 L:	[email protected]
drivers/extcon/Kconfig +10 -0
index aac507bff135..edd6c3c52699 100644
@@ -186,4 +186,14 @@ config EXTCON_USBC_CROS_EC
 	  Say Y here to enable USB Type C cable detection extcon support when
 	  using Chrome OS EC based USB Type-C ports.
 
+config EXTCON_USBC_VIRTUAL_PD
+	tristate "Virtual Type-C PD EXTCON support"
+	depends on GPIOLIB || COMPILE_TEST
+	help
+	  Say Y here to enable Virtual Type-C PD extcon driver support, if
+	  hardware platform designed Type-C modes separately.
+
+	  Example, of designing Display Port separately from Type-C Altmode
+	  instead of accessing Altmode Display Port in Type-C connector.
+
 endif
drivers/extcon/Makefile +1 -0
index 52096fd8a216..c35191eef0e1 100644
@@ -25,3 +25,4 @@ obj-$(CONFIG_EXTCON_RT8973A)	+= extcon-rt8973a.o
 obj-$(CONFIG_EXTCON_SM5502)	+= extcon-sm5502.o
 obj-$(CONFIG_EXTCON_USB_GPIO)	+= extcon-usb-gpio.o
 obj-$(CONFIG_EXTCON_USBC_CROS_EC) += extcon-usbc-cros-ec.o
+obj-$(CONFIG_EXTCON_USBC_VIRTUAL_PD) += extcon-usbc-virtual-pd.o
drivers/extcon/extcon-usbc-virtual-pd.c new file +285 -0

285 lines not on this page · raw message

Signature · 1 line
2.25.1
author
#3 lore raw

PATCH 3/3 arm64: dts: rk3399-rock-pi-4c: Enable Display Port

In reply to Jagan Teki

Enable Display Port on ROCK Pi 4C board.

Unlike, other RK3399 platforms with accessing DP Altmode via Type-C connector, the display Port on ROCK Pi 4C is accessible via physical display port connector by means of Type-C Virtual PD extcon configuration.

Enable support for it.

---
 .../boot/dts/rockchip/rk3399-rock-pi-4c.dts      | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
arch/arm64/boot/dts/rockchip/rk3399-rock-pi-4c.dts +16 -0
index 4c7ebb1c5d2d..19a648add355 100644
@@ -11,6 +11,22 @@
 / {
 	model = "Radxa ROCK Pi 4C";
 	compatible = "radxa,rockpi4c", "radxa,rockpi4", "rockchip,rk3399";
+
+	virtual_pd: virtual-pd {
+		compatible = "linux,extcon-usbc-virtual-pd";
+		det-gpios = <&gpio4 RK_PD1 GPIO_ACTIVE_LOW>;	/* DP_HPD */
+		vpd-data-role = "display-port";
+		vpd-super-speed;
+	};
+};
+
+&cdn_dp {
+	extcon = <&virtual_pd>;
+	status = "okay";
+};
+
+&tcphy0 {
+	extcon = <&virtual_pd>;
 };
 
 &sdio0 {
Signature · 1 line
2.25.1
maintainer
#4 lore raw
In reply to Jagan Teki

Hi Jagan,

Am Freitag, 4. September 2020, 21:18:27 CEST schrieb Jagan Teki:

Quoted 11 lines

USB Type-C protocol supports various modes of operations includes PD, USB3, and Altmode. If the platform design supports a Type-C connector then configuring these modes can be done via enumeration.

However, there are some platforms that design these modes of operations as separate protocol connectors like design Display Port from on-chip USB3 controller. So accessing Type-C Altmode Display Port via onboard Display Port connector instead of a Type-C connector.

Quoted 7 lines

These kinds of platforms require an explicit extcon driver in order to handle Power Delivery and Port Detection.

This series support this Type-C Virtual PD and enable the same in ROCK Pi 4C SBC.

Any inputs?

I tend to disagree on the design via an extcon.

That the Rockchip rk3399 currently carries that extcon thingy is unfortunate and only works for ChromeOS devices based on the rk3399.

The kernel now has a real type-c framework so we should not extend this extcon hack any further, because that will make it even harder to roll back later. Also simply because other Rockchip boards currently can't really make use of type-c due to this, as they use the fsusb302 phys directly connected.

ChromeOS actually spend some time to make the cros-ec pd part of the type-c framework if I remember correctly, so a viable battle plan would be to:

(1) move the Rockchip type-c phy driver to actually be part of the type-c framework, with the extcon being a deprecated fallback for old DTs.
(2) implement your gpio-altmode as part of the type-c framework (which may even already exist)

In short, please don't extend the rk3399 type-c extcon hack.

Thanks
Heiko

author
#5 lore raw

Hi Heiko,

Quoted 18 lines · Heiko Stübner

Hi Jagan,

Am Freitag, 4. September 2020, 21:18:27 CEST schrieb Jagan Teki:

Quoted 14 lines

USB Type-C protocol supports various modes of operations includes PD, USB3, and Altmode. If the platform design supports a Type-C connector then configuring these modes can be done via enumeration.

However, there are some platforms that design these modes of operations as separate protocol connectors like design Display Port from on-chip USB3 controller. So accessing Type-C Altmode Display Port via onboard Display Port connector instead of a Type-C connector.

These kinds of platforms require an explicit extcon driver in order to handle Power Delivery and Port Detection.

Quoted 6 lines
Quoted 4 lines

This series support this Type-C Virtual PD and enable the same in ROCK Pi 4C SBC.

Any inputs?

I tend to disagree on the design via an extcon.

Okay, are you disagree with the extcon extension for fusb chips routing or entire rk3399 designs?

I totally agree with this point of bypassing extcon for the designs which has fusb302 chips. My only concern is about designs that don't have fusb chips - for example rock-pi-4. Designs that do have fusb302 chips, has dynamic possibilities to identify data roles, like detecting Altmode DP via Type-C connector whereas designs that don't have fusb302 or any type-c chip need static identification of data role, polarity, and ss for detecting direct DP port ie where virtual-pd is useful.

Look like we have two potential issues of handling DP on rk3399 here, let me know if you think these non-type-c chips designs also possible to detect w/o extcon?

Jagan.

_______________________________________________
Linux-rockchip mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-rockchip

maintainer
#6 lore raw
In reply to Heiko Stübner
Quoted 17 lines · Heiko Stübner

Hi Jagan,

Am Freitag, 4. September 2020, 21:18:27 CEST schrieb Jagan Teki:

Quoted 14 lines

USB Type-C protocol supports various modes of operations includes PD, USB3, and Altmode. If the platform design supports a Type-C connector then configuring these modes can be done via enumeration.

However, there are some platforms that design these modes of operations as separate protocol connectors like design Display Port from on-chip USB3 controller. So accessing Type-C Altmode Display Port via onboard Display Port connector instead of a Type-C connector.

These kinds of platforms require an explicit extcon driver in order to handle Power Delivery and Port Detection.

Quoted 6 lines
Quoted 4 lines

This series support this Type-C Virtual PD and enable the same in ROCK Pi 4C SBC.

Any inputs?

I tend to disagree on the design via an extcon.

I don't accept new extcon bindings or users of it either. It's a poorly thought out collection of Linux driver properties. Use the usb connector binding.

Quoted 26 lines

That the Rockchip rk3399 currently carries that extcon thingy is unfortunate and only works for ChromeOS devices based on the rk3399.

The kernel now has a real type-c framework so we should not extend this extcon hack any further, because that will make it even harder to roll back later. Also simply because other Rockchip boards currently can't really make use of type-c due to this, as they use the fsusb302 phys directly connected.

ChromeOS actually spend some time to make the cros-ec pd part of the type-c framework if I remember correctly, so a viable battle plan would be to:

(1) move the Rockchip type-c phy driver to actually be part of the type-c framework, with the extcon being a deprecated fallback for old DTs.
(2) implement your gpio-altmode as part of the type-c framework (which may even already exist)

In short, please don't extend the rk3399 type-c extcon hack.

Thanks
Heiko

maintainer
#7 lore raw

Hi Rob,

Quoted 21 lines · Rob Herring
Quoted 20 lines · Heiko Stübner

Hi Jagan,

Am Freitag, 4. September 2020, 21:18:27 CEST schrieb Jagan Teki:

Quoted 17 lines

USB Type-C protocol supports various modes of operations includes PD, USB3, and Altmode. If the platform design supports a Type-C connector then configuring these modes can be done via enumeration.

However, there are some platforms that design these modes of operations as separate protocol connectors like design Display Port from on-chip USB3 controller. So accessing Type-C Altmode Display Port via onboard Display Port connector instead of a Type-C connector.

These kinds of platforms require an explicit extcon driver in order to handle Power Delivery and Port Detection.

This series support this Type-C Virtual PD and enable the same in ROCK Pi 4C SBC.

Quoted 7 lines
Quoted 3 lines
Quoted 1 line

Any inputs?

I tend to disagree on the design via an extcon.

I don't accept new extcon bindings or users of it either. It's a poorly thought out collection of Linux driver properties. Use the usb connector binding.

I agree the prior binding format of extcon with 'extcon' property name is not proper. So, I'll try to bind new style. But, I have a question. Do you have the objection of the use of extcon like 'users of it either' of your comment?

Quoted 29 lines
Quoted 27 lines

That the Rockchip rk3399 currently carries that extcon thingy is unfortunate and only works for ChromeOS devices based on the rk3399.

The kernel now has a real type-c framework so we should not extend this extcon hack any further, because that will make it even harder to roll back later. Also simply because other Rockchip boards currently can't really make use of type-c due to this, as they use the fsusb302 phys directly connected.

ChromeOS actually spend some time to make the cros-ec pd part of the type-c framework if I remember correctly, so a viable battle plan would be to:

(1) move the Rockchip type-c phy driver to actually be part of the type-c framework, with the extcon being a deprecated fallback for old DTs.
(2) implement your gpio-altmode as part of the type-c framework (which may even already exist)

In short, please don't extend the rk3399 type-c extcon hack.

Thanks
Heiko

Signature · 3 lines
Best Regards,
Chanwoo Choi
Samsung Electronics