linux-tegra.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/2] phy: tegra: xusb: Default otg mode to peripheral
@ 2025-05-06 17:09 Aaron Kling via B4 Relay
  2025-05-06 17:09 ` [PATCH v2 1/2] dt-bindings: phy: tegra-xusb: Document role-switch-default-mode Aaron Kling via B4 Relay
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Aaron Kling via B4 Relay @ 2025-05-06 17:09 UTC (permalink / raw)
  To: JC Kuo, Vinod Koul, Kishon Vijay Abraham I, Thierry Reding,
	Jonathan Hunter, Rob Herring, Krzysztof Kozlowski, Conor Dooley
  Cc: linux-phy, linux-tegra, linux-kernel, devicetree, Aaron Kling

Signed-off-by: Aaron Kling <webgeek1234@gmail.com>
---
Changes in v2:
- Add new patch to document role-switch-default-mode in xusb padctl
- Simplify code change, per review
- Comment in code why device mode is default
- Link to v1: https://lore.kernel.org/r/20250404-xusb-peripheral-v1-1-99c184b9bf5f@gmail.com

---
Aaron Kling (2):
      dt-bindings: phy: tegra-xusb: Document role-switch-default-mode
      phy: tegra: xusb: Default otg mode to peripheral

 .../bindings/phy/nvidia,tegra124-xusb-padctl.yaml  | 33 ++++++++++++++++++++
 .../bindings/phy/nvidia,tegra186-xusb-padctl.yaml  | 27 ++++++++++++++++
 .../bindings/phy/nvidia,tegra194-xusb-padctl.yaml  | 36 ++++++++++++++++++++++
 .../bindings/phy/nvidia,tegra210-xusb-padctl.yaml  | 36 ++++++++++++++++++++++
 drivers/phy/tegra/xusb.c                           | 11 +++----
 5 files changed, 136 insertions(+), 7 deletions(-)
---
base-commit: 91e5bfe317d8f8471fbaa3e70cf66cae1314a516
change-id: 20250404-xusb-peripheral-c45b1637f33b

Best regards,
-- 
Aaron Kling <webgeek1234@gmail.com>



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

* [PATCH v2 1/2] dt-bindings: phy: tegra-xusb: Document role-switch-default-mode
  2025-05-06 17:09 [PATCH v2 0/2] phy: tegra: xusb: Default otg mode to peripheral Aaron Kling via B4 Relay
@ 2025-05-06 17:09 ` Aaron Kling via B4 Relay
  2025-05-06 17:09 ` [PATCH v2 2/2] phy: tegra: xusb: Default otg mode to peripheral Aaron Kling via B4 Relay
  2025-05-07 10:48 ` [PATCH v2 0/2] " Jon Hunter
  2 siblings, 0 replies; 5+ messages in thread
From: Aaron Kling via B4 Relay @ 2025-05-06 17:09 UTC (permalink / raw)
  To: JC Kuo, Vinod Koul, Kishon Vijay Abraham I, Thierry Reding,
	Jonathan Hunter, Rob Herring, Krzysztof Kozlowski, Conor Dooley
  Cc: linux-phy, linux-tegra, linux-kernel, devicetree, Aaron Kling

From: Aaron Kling <webgeek1234@gmail.com>

This property is used to default an otg port to host or peripheral.

Signed-off-by: Aaron Kling <webgeek1234@gmail.com>
---
 .../bindings/phy/nvidia,tegra124-xusb-padctl.yaml  | 33 ++++++++++++++++++++
 .../bindings/phy/nvidia,tegra186-xusb-padctl.yaml  | 27 ++++++++++++++++
 .../bindings/phy/nvidia,tegra194-xusb-padctl.yaml  | 36 ++++++++++++++++++++++
 .../bindings/phy/nvidia,tegra210-xusb-padctl.yaml  | 36 ++++++++++++++++++++++
 4 files changed, 132 insertions(+)

diff --git a/Documentation/devicetree/bindings/phy/nvidia,tegra124-xusb-padctl.yaml b/Documentation/devicetree/bindings/phy/nvidia,tegra124-xusb-padctl.yaml
index 33b41b6b2fd539450f9ce72db8bba204e9c08eba..f383f25d932071bb4e4c86cb9f87f51e6a59aaac 100644
--- a/Documentation/devicetree/bindings/phy/nvidia,tegra124-xusb-padctl.yaml
+++ b/Documentation/devicetree/bindings/phy/nvidia,tegra124-xusb-padctl.yaml
@@ -357,10 +357,21 @@ properties:
 
               See ../connector/usb-connector.yaml.
 
+          role-switch-default-mode:
+            description:
+              Indicates if usb-role-switch is enabled, the device default operation
+              mode of controller while usb role is USB_ROLE_NONE.
+            $ref: /schemas/types.yaml#/definitions/string
+            enum: [host, peripheral]
+            default: peripheral
+
           vbus-supply:
             description: A phandle to the regulator supplying the VBUS
               voltage.
 
+        dependencies:
+          role-switch-default-mode: [ usb-role-switch ]
+
       usb2-1:
         type: object
         additionalProperties: false
@@ -392,10 +403,21 @@ properties:
 
               See ../connector/usb-connector.yaml.
 
+          role-switch-default-mode:
+            description:
+              Indicates if usb-role-switch is enabled, the device default operation
+              mode of controller while usb role is USB_ROLE_NONE.
+            $ref: /schemas/types.yaml#/definitions/string
+            enum: [host, peripheral]
+            default: peripheral
+
           vbus-supply:
             description: A phandle to the regulator supplying the VBUS
               voltage.
 
+        dependencies:
+          role-switch-default-mode: [ usb-role-switch ]
+
       usb2-2:
         type: object
         additionalProperties: false
@@ -427,10 +449,21 @@ properties:
 
               See ../connector/usb-connector.yaml.
 
+          role-switch-default-mode:
+            description:
+              Indicates if usb-role-switch is enabled, the device default operation
+              mode of controller while usb role is USB_ROLE_NONE.
+            $ref: /schemas/types.yaml#/definitions/string
+            enum: [host, peripheral]
+            default: peripheral
+
           vbus-supply:
             description: A phandle to the regulator supplying the VBUS
               voltage.
 
+        dependencies:
+          role-switch-default-mode: [ usb-role-switch ]
+
       ulpi-0:
         type: object
         additionalProperties: false
diff --git a/Documentation/devicetree/bindings/phy/nvidia,tegra186-xusb-padctl.yaml b/Documentation/devicetree/bindings/phy/nvidia,tegra186-xusb-padctl.yaml
index 8b1d5a8529e38a1956a60e402c40ebec089ff2e9..f38ed6d339f125df136bcf0e954efb9f5b46466a 100644
--- a/Documentation/devicetree/bindings/phy/nvidia,tegra186-xusb-padctl.yaml
+++ b/Documentation/devicetree/bindings/phy/nvidia,tegra186-xusb-padctl.yaml
@@ -260,12 +260,21 @@ properties:
 
               See ../connector/usb-connector.yaml.
 
+          role-switch-default-mode:
+            description:
+              Indicates if usb-role-switch is enabled, the device default operation
+              mode of controller while usb role is USB_ROLE_NONE.
+            $ref: /schemas/types.yaml#/definitions/string
+            enum: [host, peripheral]
+            default: peripheral
+
           vbus-supply:
             description: A phandle to the regulator supplying the VBUS
               voltage.
 
         dependencies:
           usb-role-switch: [ connector ]
+          role-switch-default-mode: [ usb-role-switch ]
 
       usb2-1:
         type: object
@@ -298,12 +307,21 @@ properties:
 
               See ../connector/usb-connector.yaml.
 
+          role-switch-default-mode:
+            description:
+              Indicates if usb-role-switch is enabled, the device default operation
+              mode of controller while usb role is USB_ROLE_NONE.
+            $ref: /schemas/types.yaml#/definitions/string
+            enum: [host, peripheral]
+            default: peripheral
+
           vbus-supply:
             description: A phandle to the regulator supplying the VBUS
               voltage.
 
         dependencies:
           usb-role-switch: [ connector ]
+          role-switch-default-mode: [ usb-role-switch ]
 
       usb2-2:
         type: object
@@ -336,12 +354,21 @@ properties:
 
               See ../connector/usb-connector.yaml.
 
+          role-switch-default-mode:
+            description:
+              Indicates if usb-role-switch is enabled, the device default operation
+              mode of controller while usb role is USB_ROLE_NONE.
+            $ref: /schemas/types.yaml#/definitions/string
+            enum: [host, peripheral]
+            default: peripheral
+
           vbus-supply:
             description: A phandle to the regulator supplying the VBUS
               voltage.
 
         dependencies:
           usb-role-switch: [ connector ]
+          role-switch-default-mode: [ usb-role-switch ]
 
       hsic-0:
         type: object
diff --git a/Documentation/devicetree/bindings/phy/nvidia,tegra194-xusb-padctl.yaml b/Documentation/devicetree/bindings/phy/nvidia,tegra194-xusb-padctl.yaml
index 6e3398399628766e820ff2a5da0ee644dcdee956..8253ff3ac5e8cffba16ddca3fbbc0fa32b58384f 100644
--- a/Documentation/devicetree/bindings/phy/nvidia,tegra194-xusb-padctl.yaml
+++ b/Documentation/devicetree/bindings/phy/nvidia,tegra194-xusb-padctl.yaml
@@ -251,12 +251,21 @@ properties:
 
               See ../connector/usb-connector.yaml.
 
+          role-switch-default-mode:
+            description:
+              Indicates if usb-role-switch is enabled, the device default operation
+              mode of controller while usb role is USB_ROLE_NONE.
+            $ref: /schemas/types.yaml#/definitions/string
+            enum: [host, peripheral]
+            default: peripheral
+
           vbus-supply:
             description: A phandle to the regulator supplying the VBUS
               voltage.
 
         dependencies:
           usb-role-switch: [ connector ]
+          role-switch-default-mode: [ usb-role-switch ]
 
       usb2-1:
         type: object
@@ -289,12 +298,21 @@ properties:
 
               See ../connector/usb-connector.yaml.
 
+          role-switch-default-mode:
+            description:
+              Indicates if usb-role-switch is enabled, the device default operation
+              mode of controller while usb role is USB_ROLE_NONE.
+            $ref: /schemas/types.yaml#/definitions/string
+            enum: [host, peripheral]
+            default: peripheral
+
           vbus-supply:
             description: A phandle to the regulator supplying the VBUS
               voltage.
 
         dependencies:
           usb-role-switch: [ connector ]
+          role-switch-default-mode: [ usb-role-switch ]
 
       usb2-2:
         type: object
@@ -327,12 +345,21 @@ properties:
 
               See ../connector/usb-connector.yaml.
 
+          role-switch-default-mode:
+            description:
+              Indicates if usb-role-switch is enabled, the device default operation
+              mode of controller while usb role is USB_ROLE_NONE.
+            $ref: /schemas/types.yaml#/definitions/string
+            enum: [host, peripheral]
+            default: peripheral
+
           vbus-supply:
             description: A phandle to the regulator supplying the VBUS
               voltage.
 
         dependencies:
           usb-role-switch: [ connector ]
+          role-switch-default-mode: [ usb-role-switch ]
 
       usb2-3:
         type: object
@@ -365,12 +392,21 @@ properties:
 
               See ../connector/usb-connector.yaml.
 
+          role-switch-default-mode:
+            description:
+              Indicates if usb-role-switch is enabled, the device default operation
+              mode of controller while usb role is USB_ROLE_NONE.
+            $ref: /schemas/types.yaml#/definitions/string
+            enum: [host, peripheral]
+            default: peripheral
+
           vbus-supply:
             description: A phandle to the regulator supplying the VBUS
               voltage.
 
         dependencies:
           usb-role-switch: [ connector ]
+          role-switch-default-mode: [ usb-role-switch ]
 
       usb3-0:
         type: object
diff --git a/Documentation/devicetree/bindings/phy/nvidia,tegra210-xusb-padctl.yaml b/Documentation/devicetree/bindings/phy/nvidia,tegra210-xusb-padctl.yaml
index e9237c58ce45df7fa25cac861891b3fe76efe83d..c14bb947d306912fb732ff219511c6d6fda80f7c 100644
--- a/Documentation/devicetree/bindings/phy/nvidia,tegra210-xusb-padctl.yaml
+++ b/Documentation/devicetree/bindings/phy/nvidia,tegra210-xusb-padctl.yaml
@@ -379,12 +379,21 @@ properties:
 
               See ../connector/usb-connector.yaml.
 
+          role-switch-default-mode:
+            description:
+              Indicates if usb-role-switch is enabled, the device default operation
+              mode of controller while usb role is USB_ROLE_NONE.
+            $ref: /schemas/types.yaml#/definitions/string
+            enum: [host, peripheral]
+            default: peripheral
+
           vbus-supply:
             description: A phandle to the regulator supplying the VBUS
               voltage.
 
         dependencies:
           usb-role-switch: [ connector ]
+          role-switch-default-mode: [ usb-role-switch ]
 
       usb2-1:
         type: object
@@ -417,12 +426,21 @@ properties:
 
               See ../connector/usb-connector.yaml.
 
+          role-switch-default-mode:
+            description:
+              Indicates if usb-role-switch is enabled, the device default operation
+              mode of controller while usb role is USB_ROLE_NONE.
+            $ref: /schemas/types.yaml#/definitions/string
+            enum: [host, peripheral]
+            default: peripheral
+
           vbus-supply:
             description: A phandle to the regulator supplying the VBUS
               voltage.
 
         dependencies:
           usb-role-switch: [ connector ]
+          role-switch-default-mode: [ usb-role-switch ]
 
       usb2-2:
         type: object
@@ -455,12 +473,21 @@ properties:
 
               See ../connector/usb-connector.yaml.
 
+          role-switch-default-mode:
+            description:
+              Indicates if usb-role-switch is enabled, the device default operation
+              mode of controller while usb role is USB_ROLE_NONE.
+            $ref: /schemas/types.yaml#/definitions/string
+            enum: [host, peripheral]
+            default: peripheral
+
           vbus-supply:
             description: A phandle to the regulator supplying the VBUS
               voltage.
 
         dependencies:
           usb-role-switch: [ connector ]
+          role-switch-default-mode: [ usb-role-switch ]
 
       usb2-3:
         type: object
@@ -493,12 +520,21 @@ properties:
 
               See ../connector/usb-connector.yaml.
 
+          role-switch-default-mode:
+            description:
+              Indicates if usb-role-switch is enabled, the device default operation
+              mode of controller while usb role is USB_ROLE_NONE.
+            $ref: /schemas/types.yaml#/definitions/string
+            enum: [host, peripheral]
+            default: peripheral
+
           vbus-supply:
             description: A phandle to the regulator supplying the VBUS
               voltage.
 
         dependencies:
           usb-role-switch: [ connector ]
+          role-switch-default-mode: [ usb-role-switch ]
 
       hsic-0:
         type: object

-- 
2.48.1



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

* [PATCH v2 2/2] phy: tegra: xusb: Default otg mode to peripheral
  2025-05-06 17:09 [PATCH v2 0/2] phy: tegra: xusb: Default otg mode to peripheral Aaron Kling via B4 Relay
  2025-05-06 17:09 ` [PATCH v2 1/2] dt-bindings: phy: tegra-xusb: Document role-switch-default-mode Aaron Kling via B4 Relay
@ 2025-05-06 17:09 ` Aaron Kling via B4 Relay
  2025-05-07 10:48 ` [PATCH v2 0/2] " Jon Hunter
  2 siblings, 0 replies; 5+ messages in thread
From: Aaron Kling via B4 Relay @ 2025-05-06 17:09 UTC (permalink / raw)
  To: JC Kuo, Vinod Koul, Kishon Vijay Abraham I, Thierry Reding,
	Jonathan Hunter, Rob Herring, Krzysztof Kozlowski, Conor Dooley
  Cc: linux-phy, linux-tegra, linux-kernel, devicetree, Aaron Kling

From: Aaron Kling <webgeek1234@gmail.com>

Currently, if usb-role-switch is set and role-switch-default-mode is
not, a xusb port will be inoperable until that port is hotplugged,
because the driver defaults to role none. Instead of requiring all
devices to set the default mode, assume that the port is primarily
intended for use in device mode.

Signed-off-by: Aaron Kling <webgeek1234@gmail.com>
---
 drivers/phy/tegra/xusb.c | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/drivers/phy/tegra/xusb.c b/drivers/phy/tegra/xusb.c
index 79d4814d758d5e1f0e8200d61e131606adbb0e2d..22338f3f24a0794c22544a0e16e0fc706c4fb6d7 100644
--- a/drivers/phy/tegra/xusb.c
+++ b/drivers/phy/tegra/xusb.c
@@ -726,18 +726,15 @@ static int tegra_xusb_setup_usb_role_switch(struct tegra_xusb_port *port)
 
 static void tegra_xusb_parse_usb_role_default_mode(struct tegra_xusb_port *port)
 {
-	enum usb_role role = USB_ROLE_NONE;
+	/* Most switchable usb ports are normally used in device mode */
+	enum usb_role role = USB_ROLE_DEVICE;
 	enum usb_dr_mode mode = usb_get_role_switch_default_mode(&port->dev);
 
 	if (mode == USB_DR_MODE_HOST)
 		role = USB_ROLE_HOST;
-	else if (mode == USB_DR_MODE_PERIPHERAL)
-		role = USB_ROLE_DEVICE;
 
-	if (role != USB_ROLE_NONE) {
-		usb_role_switch_set_role(port->usb_role_sw, role);
-		dev_dbg(&port->dev, "usb role default mode is %s", modes[mode]);
-	}
+	usb_role_switch_set_role(port->usb_role_sw, role);
+	dev_dbg(&port->dev, "usb role default mode is %s", modes[mode]);
 }
 
 static int tegra_xusb_usb2_port_parse_dt(struct tegra_xusb_usb2_port *usb2)

-- 
2.48.1



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

* Re: [PATCH v2 0/2] phy: tegra: xusb: Default otg mode to peripheral
  2025-05-06 17:09 [PATCH v2 0/2] phy: tegra: xusb: Default otg mode to peripheral Aaron Kling via B4 Relay
  2025-05-06 17:09 ` [PATCH v2 1/2] dt-bindings: phy: tegra-xusb: Document role-switch-default-mode Aaron Kling via B4 Relay
  2025-05-06 17:09 ` [PATCH v2 2/2] phy: tegra: xusb: Default otg mode to peripheral Aaron Kling via B4 Relay
@ 2025-05-07 10:48 ` Jon Hunter
  2025-05-13 20:39   ` Aaron Kling
  2 siblings, 1 reply; 5+ messages in thread
From: Jon Hunter @ 2025-05-07 10:48 UTC (permalink / raw)
  To: webgeek1234, JC Kuo, Vinod Koul, Kishon Vijay Abraham I,
	Thierry Reding, Rob Herring, Krzysztof Kozlowski, Conor Dooley
  Cc: linux-phy, linux-tegra, linux-kernel, devicetree


On 06/05/2025 18:09, Aaron Kling via B4 Relay wrote:
> Signed-off-by: Aaron Kling <webgeek1234@gmail.com>
> ---
> Changes in v2:
> - Add new patch to document role-switch-default-mode in xusb padctl
> - Simplify code change, per review
> - Comment in code why device mode is default
> - Link to v1: https://lore.kernel.org/r/20250404-xusb-peripheral-v1-1-99c184b9bf5f@gmail.com


I have been asking our team about this and this is the feedback I 
received ...

"By design, a port’s data role starts out as USB_ROLE_NONE.
It remains in that state until a dedicated role‐switch driver, such as 
the GPIO-based driver, usb-conn-gpio, or a Type-C controller driver, 
CCG, probes VBUS/ID or CC lines and tells the USB core whether to switch 
to host or device.
The role-switch-default-mode DT property exists precisely for controlled 
use cases where a board truly only ever needs one role and doesn’t 
include any role-detection hardware.
In that scenario, you’re effectively opting out of dynamic role switching.
In the general OTG case, though, we shouldn’t assume the data role of an 
OTG port.

In his case, he should work out
1. If his platform has a role-switch component, then he should enable it 
rather than adding this change.
2. If his platform doesn’t have a role-switch controller, add 
role-switch-default-mode = "peripheral"; to the PHY node instead of 
changing the core driver."

So I guess the question is, does your platform have a role-switch 
controller?

The bottom line here is that we don't want to make this change by 
default for all Tegra platforms.

Thanks
Jon

-- 
nvpublic


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

* Re: [PATCH v2 0/2] phy: tegra: xusb: Default otg mode to peripheral
  2025-05-07 10:48 ` [PATCH v2 0/2] " Jon Hunter
@ 2025-05-13 20:39   ` Aaron Kling
  0 siblings, 0 replies; 5+ messages in thread
From: Aaron Kling @ 2025-05-13 20:39 UTC (permalink / raw)
  To: Jon Hunter
  Cc: JC Kuo, Vinod Koul, Kishon Vijay Abraham I, Thierry Reding,
	Rob Herring, Krzysztof Kozlowski, Conor Dooley, linux-phy,
	linux-tegra, linux-kernel, devicetree

On Wed, May 7, 2025 at 5:48 AM Jon Hunter <jonathanh@nvidia.com> wrote:
>
>
> On 06/05/2025 18:09, Aaron Kling via B4 Relay wrote:
> > Signed-off-by: Aaron Kling <webgeek1234@gmail.com>
> > ---
> > Changes in v2:
> > - Add new patch to document role-switch-default-mode in xusb padctl
> > - Simplify code change, per review
> > - Comment in code why device mode is default
> > - Link to v1: https://lore.kernel.org/r/20250404-xusb-peripheral-v1-1-99c184b9bf5f@gmail.com
>
>
> I have been asking our team about this and this is the feedback I
> received ...
>
> "By design, a port’s data role starts out as USB_ROLE_NONE.
> It remains in that state until a dedicated role‐switch driver, such as
> the GPIO-based driver, usb-conn-gpio, or a Type-C controller driver,
> CCG, probes VBUS/ID or CC lines and tells the USB core whether to switch
> to host or device.
> The role-switch-default-mode DT property exists precisely for controlled
> use cases where a board truly only ever needs one role and doesn’t
> include any role-detection hardware.
> In that scenario, you’re effectively opting out of dynamic role switching.
> In the general OTG case, though, we shouldn’t assume the data role of an
> OTG port.
>
> In his case, he should work out
> 1. If his platform has a role-switch component, then he should enable it
> rather than adding this change.
> 2. If his platform doesn’t have a role-switch controller, add
> role-switch-default-mode = "peripheral"; to the PHY node instead of
> changing the core driver."
>
> So I guess the question is, does your platform have a role-switch
> controller?
>
> The bottom line here is that we don't want to make this change by
> default for all Tegra platforms.

I wasn't familiar with role-switch controllers and that seems to have
been my problem. I wasn't loading the usb-conn-gpio or ucsi_ccg
modules which was why the current role wasn't being auto-detected.
After loading those, the majority of the Jetson devkits and Shield
devices I'm targeting worked as expected without this change. The only
failure I've seen so far is p3509+p3636. And I've got a fix I'll push
separately for that. So this series can be abandoned.

Sincerely,
Aaron

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

end of thread, other threads:[~2025-05-13 20:39 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-06 17:09 [PATCH v2 0/2] phy: tegra: xusb: Default otg mode to peripheral Aaron Kling via B4 Relay
2025-05-06 17:09 ` [PATCH v2 1/2] dt-bindings: phy: tegra-xusb: Document role-switch-default-mode Aaron Kling via B4 Relay
2025-05-06 17:09 ` [PATCH v2 2/2] phy: tegra: xusb: Default otg mode to peripheral Aaron Kling via B4 Relay
2025-05-07 10:48 ` [PATCH v2 0/2] " Jon Hunter
2025-05-13 20:39   ` Aaron Kling

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).