phy: tegra: xusb: Default otg mode to peripheral
Subsystems (4)
v2 cover phy: tegra: xusb: Default otg mode to peripheral
---
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/[email protected]
---
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,
Signature · 1 line
Aaron Kling <[email protected]>
PATCH v2 1/2 dt-bindings: phy: tegra-xusb: Document role-switch-default-mode
This property is used to default an otg port to host or 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 ++++++++++++++++++++++ 4 files changed, 132 insertions(+)
Documentation/devicetree/bindings/phy/nvidia,tegra124-xusb-padctl.yaml +33 -0
@@ -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
Documentation/devicetree/bindings/phy/nvidia,tegra186-xusb-padctl.yaml +27 -0
@@ -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
Documentation/devicetree/bindings/phy/nvidia,tegra194-xusb-padctl.yaml +36 -0
@@ -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
Documentation/devicetree/bindings/phy/nvidia,tegra210-xusb-padctl.yaml +36 -0
@@ -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
Signature · 1 line
2.48.1
PATCH v2 2/2 phy: tegra: xusb: Default otg mode to peripheral
In reply to Aaron KlingCurrently, 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.
--- drivers/phy/tegra/xusb.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-)
drivers/phy/tegra/xusb.c +4 -7
@@ -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)
Signature · 1 line
2.48.1
Jon Hunter
maintainerQuoted 7 lines · On 06/05/2025 18:09, Aaron Kling via B4 Relay wrote:
Signed-off-by Aaron Kling <[email protected]>---
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/[email protected]
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
Signature · 1 line
nvpublic
Quoted 34 lines · Jon Hunter
Quoted 7 lines · On 06/05/2025 18:09, Aaron Kling via B4 Relay wrote:
Signed-off-by Aaron Kling <[email protected]>---
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/[email protected]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."
Quoted 5 lines
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