* [PATCH v2 01/12] dt-bindings: usb: tegra234-xusb: Add required properties
2026-11-16 15:23 [PATCH v2 00/12] usb: Add support for Tegra238 and device support for Tegra264 Jon Hunter
@ 2026-11-16 15:23 ` Jon Hunter
2026-11-16 15:23 ` [PATCH v2 02/12] dt-bindings: usb: Add Tegra238 XUSB host controller support Jon Hunter
` (10 subsequent siblings)
11 siblings, 0 replies; 15+ messages in thread
From: Jon Hunter @ 2026-11-16 15:23 UTC (permalink / raw)
To: Greg Kroah-Hartman, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Thierry Reding, Nagarjuna Kristam, JC Kuo,
Mathias Nyman
Cc: Thierry Reding, linux-usb, devicetree, linux-tegra,
Thierry Reding, Wayne Chang, Jon Hunter
The Tegra234 XUSB binding does not specify any required properties, so
nodes missing the resources needed by the controller can pass validation.
Add a required list for the registers, interrupts, clocks, pad
controller, PHYs and power domains described by the Tegra234 device
tree.
Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
---
.../devicetree/bindings/usb/nvidia,tegra234-xusb.yaml | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/Documentation/devicetree/bindings/usb/nvidia,tegra234-xusb.yaml b/Documentation/devicetree/bindings/usb/nvidia,tegra234-xusb.yaml
index 3f56110be915..4e4d7fc352f1 100644
--- a/Documentation/devicetree/bindings/usb/nvidia,tegra234-xusb.yaml
+++ b/Documentation/devicetree/bindings/usb/nvidia,tegra234-xusb.yaml
@@ -152,6 +152,19 @@ properties:
dma-coherent: true
+required:
+ - compatible
+ - reg
+ - reg-names
+ - interrupts
+ - clocks
+ - clock-names
+ - nvidia,xusb-padctl
+ - phys
+ - phy-names
+ - power-domains
+ - power-domain-names
+
allOf:
- $ref: usb-xhci.yaml
--
2.43.0
^ permalink raw reply related [flat|nested] 15+ messages in thread* [PATCH v2 02/12] dt-bindings: usb: Add Tegra238 XUSB host controller support
2026-11-16 15:23 [PATCH v2 00/12] usb: Add support for Tegra238 and device support for Tegra264 Jon Hunter
2026-11-16 15:23 ` [PATCH v2 01/12] dt-bindings: usb: tegra234-xusb: Add required properties Jon Hunter
@ 2026-11-16 15:23 ` Jon Hunter
2026-11-16 15:38 ` sashiko-bot
2026-11-16 15:24 ` [PATCH v2 03/12] dt-bindings: usb: tegra-xudc: Add Tegra238 XUDC support Jon Hunter
` (9 subsequent siblings)
11 siblings, 1 reply; 15+ messages in thread
From: Jon Hunter @ 2026-11-16 15:23 UTC (permalink / raw)
To: Greg Kroah-Hartman, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Thierry Reding, Nagarjuna Kristam, JC Kuo,
Mathias Nyman
Cc: Thierry Reding, linux-usb, devicetree, linux-tegra,
Thierry Reding, Wayne Chang, Jon Hunter
Add a compatible string for the Tegra238 XUSB host controller. The
Tegra238 XUSB host controller is similar to that found on the Tegra234
device but only supports up to 3 USB2 and 3 USB3 PHYs compared to the 4
USB2 and 4 USB3 PHYs on the Tegra234. Hence, the binding is also updated
to limit the number of PHYs and interrupts that can be specified for the
Tegra238 device. Note that for Tegra238 there are 8 interrupts supported
in total; 2 for the host controller and then 1 for each PHY.
Unlike the other supported SoCs, Tegra238 controls the XHCI resets
directly instead of using power domains. Describe and require the host
and SuperSpeed resets for Tegra238, and keep power domains required for
the other SoCs.
Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
---
.../bindings/usb/nvidia,tegra234-xusb.yaml | 48 +++++++++++++++++++++-
1 file changed, 46 insertions(+), 2 deletions(-)
diff --git a/Documentation/devicetree/bindings/usb/nvidia,tegra234-xusb.yaml b/Documentation/devicetree/bindings/usb/nvidia,tegra234-xusb.yaml
index 4e4d7fc352f1..989cce0bb52c 100644
--- a/Documentation/devicetree/bindings/usb/nvidia,tegra234-xusb.yaml
+++ b/Documentation/devicetree/bindings/usb/nvidia,tegra234-xusb.yaml
@@ -19,6 +19,7 @@ properties:
compatible:
enum:
- nvidia,tegra234-xusb
+ - nvidia,tegra238-xusb
- nvidia,tegra264-xusb
reg:
@@ -140,6 +141,16 @@ properties:
- usb3-2
- usb3-3
+ resets:
+ items:
+ - description: XUSB host controller reset
+ - description: XUSB SuperSpeed reset
+
+ reset-names:
+ items:
+ - const: xusb_host
+ - const: xusb_ss
+
power-domains:
items:
- description: XUSBC power domain (for Host and USB 2.0)
@@ -162,11 +173,44 @@ required:
- nvidia,xusb-padctl
- phys
- phy-names
- - power-domains
- - power-domain-names
allOf:
- $ref: usb-xhci.yaml
+ - if:
+ properties:
+ compatible:
+ contains:
+ const: nvidia,tegra238-xusb
+ then:
+ properties:
+ interrupts:
+ maxItems: 8
+ iommus:
+ maxItems: 1
+ power-domains: false
+ power-domain-names: false
+ phys:
+ maxItems: 6
+ phy-names:
+ maxItems: 6
+ items:
+ enum:
+ - usb2-0
+ - usb2-1
+ - usb2-2
+ - usb3-0
+ - usb3-1
+ - usb3-2
+ required:
+ - resets
+ - reset-names
+ else:
+ properties:
+ resets: false
+ reset-names: false
+ required:
+ - power-domains
+ - power-domain-names
- if:
properties:
--
2.43.0
^ permalink raw reply related [flat|nested] 15+ messages in thread* Re: [PATCH v2 02/12] dt-bindings: usb: Add Tegra238 XUSB host controller support
2026-11-16 15:23 ` [PATCH v2 02/12] dt-bindings: usb: Add Tegra238 XUSB host controller support Jon Hunter
@ 2026-11-16 15:38 ` sashiko-bot
0 siblings, 0 replies; 15+ messages in thread
From: sashiko-bot @ 2026-11-16 15:38 UTC (permalink / raw)
To: Jon Hunter; +Cc: linux-usb, devicetree, robh, conor+dt
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Low] dt-bindings: usb: unwieldy per-compatible conditionals for
tegra238-xusb
--
commit 68b69d5e79cc5b22a7419c3753f57282df3a1a08
Author: Jon Hunter <jonathanh@nvidia.com>
dt-bindings: usb: Add Tegra238 XUSB host controller support
This commit adds Device Tree binding support for the Tegra238 XUSB host
controller to nvidia,tegra234-xusb.yaml, constraining its PHYs and
interrupts and requiring direct resets instead of power domains.
> diff --git a/Documentation/devicetree/bindings/usb/nvidia,tegra234-xusb.yaml b/Documentation/devicetree/bindings/usb/nvidia,tegra234-xusb.yaml
> index 4e4d7fc352f15..989cce0bb52c1 100644
> --- a/Documentation/devicetree/bindings/usb/nvidia,tegra234-xusb.yaml
> +++ b/Documentation/devicetree/bindings/usb/nvidia,tegra234-xusb.yaml
[ ... ]
> @@ -162,11 +173,44 @@ required:
> - nvidia,xusb-padctl
> - phys
> - phy-names
> - - power-domains
> - - power-domain-names
>
> allOf:
> - $ref: usb-xhci.yaml
> + - if:
> + properties:
> + compatible:
> + contains:
> + const: nvidia,tegra238-xusb
> + then:
> + properties:
> + interrupts:
> + maxItems: 8
> + iommus:
> + maxItems: 1
> + power-domains: false
> + power-domain-names: false
> + phys:
> + maxItems: 6
> + phy-names:
> + maxItems: 6
> + items:
> + enum:
> + - usb2-0
> + - usb2-1
> + - usb2-2
> + - usb3-0
> + - usb3-1
> + - usb3-2
> + required:
> + - resets
> + - reset-names
> + else:
> + properties:
> + resets: false
> + reset-names: false
> + required:
> + - power-domains
> + - power-domain-names
[Severity: Low]
This isn't a bug, but would nvidia,tegra238-xusb be cleaner as a separate
binding schema document rather than adding another large conditional block to
nvidia,tegra234-xusb.yaml?
Tegra238 differs substantially from Tegra234 and Tegra264: it uses resets and
reset-names instead of power-domains and power-domain-names, supports 6 PHYs
instead of 8, and has different interrupts and iommus limits. Fitting it into
this schema moves power-domains out of the top-level required list and adds
an if/then/else block that overrides most of the properties alongside the
existing per-SoC conditionals.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261116-tegra-usb-v2-0-42efc03a9700@nvidia.com?part=2
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH v2 03/12] dt-bindings: usb: tegra-xudc: Add Tegra238 XUDC support
2026-11-16 15:23 [PATCH v2 00/12] usb: Add support for Tegra238 and device support for Tegra264 Jon Hunter
2026-11-16 15:23 ` [PATCH v2 01/12] dt-bindings: usb: tegra234-xusb: Add required properties Jon Hunter
2026-11-16 15:23 ` [PATCH v2 02/12] dt-bindings: usb: Add Tegra238 XUSB host controller support Jon Hunter
@ 2026-11-16 15:24 ` Jon Hunter
2026-11-16 15:24 ` [PATCH v2 04/12] dt-bindings: usb: tegra-xudc: Add Tegra264 " Jon Hunter
` (8 subsequent siblings)
11 siblings, 0 replies; 15+ messages in thread
From: Jon Hunter @ 2026-11-16 15:24 UTC (permalink / raw)
To: Greg Kroah-Hartman, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Thierry Reding, Nagarjuna Kristam, JC Kuo,
Mathias Nyman
Cc: Thierry Reding, linux-usb, devicetree, linux-tegra,
Thierry Reding, Wayne Chang, Jon Hunter
Add a compatible string for the Tegra238 XUDC device. The Tegra238 XUDC
is similar to that found on the Tegra234 device but only supports 3 USB2
and 3 USB3 PHYs compared to the 4 USB2 and 4 USB3 PHYs on the Tegra234.
The XUDC binding only defines which of the available PHYs is used by the
XUDC controller and the Tegra XUSB pad controller binding [0] defines
the PHYs that are available.
Unlike the other supported SoCs, Tegra238 controls the XUDC resets
directly instead of using power domains. Describe and require the
device and SuperSpeed resets for Tegra238, and keep power domains
required for the other SoCs.
[0] Documentation/devicetree/bindings/phy/nvidia,tegra194-xusb-padctl.yaml
Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
---
.../devicetree/bindings/usb/nvidia,tegra-xudc.yaml | 35 ++++++++++++++++++++--
1 file changed, 33 insertions(+), 2 deletions(-)
diff --git a/Documentation/devicetree/bindings/usb/nvidia,tegra-xudc.yaml b/Documentation/devicetree/bindings/usb/nvidia,tegra-xudc.yaml
index c6e661e8915c..99a6322eaceb 100644
--- a/Documentation/devicetree/bindings/usb/nvidia,tegra-xudc.yaml
+++ b/Documentation/devicetree/bindings/usb/nvidia,tegra-xudc.yaml
@@ -23,6 +23,7 @@ properties:
- nvidia,tegra186-xudc # For Tegra186
- nvidia,tegra194-xudc # For Tegra194
- nvidia,tegra234-xudc # For Tegra234
+ - nvidia,tegra238-xudc # For Tegra238
reg:
minItems: 2
@@ -73,6 +74,16 @@ properties:
iommus:
maxItems: 1
+ resets:
+ items:
+ - description: XUSB device controller reset
+ - description: XUSB SuperSpeed reset
+
+ reset-names:
+ items:
+ - const: xusb_dev
+ - const: xusb_ss
+
power-domains:
items:
- description: XUSBB(device) power-domain
@@ -117,13 +128,31 @@ required:
- interrupts
- clocks
- clock-names
- - power-domains
- - power-domain-names
- nvidia,xusb-padctl
- phys
- phy-names
allOf:
+ - if:
+ properties:
+ compatible:
+ contains:
+ const: nvidia,tegra238-xudc
+ then:
+ properties:
+ power-domains: false
+ power-domain-names: false
+ required:
+ - resets
+ - reset-names
+ else:
+ properties:
+ resets: false
+ reset-names: false
+ required:
+ - power-domains
+ - power-domain-names
+
- if:
properties:
compatible:
@@ -152,6 +181,7 @@ allOf:
- nvidia,tegra186-xudc
- nvidia,tegra194-xudc
- nvidia,tegra234-xudc
+ - nvidia,tegra238-xudc
then:
properties:
reg:
@@ -170,6 +200,7 @@ allOf:
enum:
- nvidia,tegra194-xudc
- nvidia,tegra234-xudc
+ - nvidia,tegra238-xudc
then:
required:
- dma-coherent
--
2.43.0
^ permalink raw reply related [flat|nested] 15+ messages in thread* [PATCH v2 04/12] dt-bindings: usb: tegra-xudc: Add Tegra264 XUDC support
2026-11-16 15:23 [PATCH v2 00/12] usb: Add support for Tegra238 and device support for Tegra264 Jon Hunter
` (2 preceding siblings ...)
2026-11-16 15:24 ` [PATCH v2 03/12] dt-bindings: usb: tegra-xudc: Add Tegra238 XUDC support Jon Hunter
@ 2026-11-16 15:24 ` Jon Hunter
2026-11-16 15:24 ` [PATCH v2 05/12] usb: xhci: tegra: Fix missing semi-colon Jon Hunter
` (7 subsequent siblings)
11 siblings, 0 replies; 15+ messages in thread
From: Jon Hunter @ 2026-11-16 15:24 UTC (permalink / raw)
To: Greg Kroah-Hartman, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Thierry Reding, Nagarjuna Kristam, JC Kuo,
Mathias Nyman
Cc: Thierry Reding, linux-usb, devicetree, linux-tegra,
Thierry Reding, Wayne Chang, Jon Hunter, Krzysztof Kozlowski
Add a compatible string for the Tegra264 XUDC device. The Tegra264 XUDC
is similar to that found on the Tegra234 device supporting 4 PHYs,
however, the register offsets for the Tegra264 device are different to
previous Tegra devices.
Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com>
Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
---
Documentation/devicetree/bindings/usb/nvidia,tegra-xudc.yaml | 3 +++
1 file changed, 3 insertions(+)
diff --git a/Documentation/devicetree/bindings/usb/nvidia,tegra-xudc.yaml b/Documentation/devicetree/bindings/usb/nvidia,tegra-xudc.yaml
index 99a6322eaceb..aca525c937d2 100644
--- a/Documentation/devicetree/bindings/usb/nvidia,tegra-xudc.yaml
+++ b/Documentation/devicetree/bindings/usb/nvidia,tegra-xudc.yaml
@@ -24,6 +24,7 @@ properties:
- nvidia,tegra194-xudc # For Tegra194
- nvidia,tegra234-xudc # For Tegra234
- nvidia,tegra238-xudc # For Tegra238
+ - nvidia,tegra264-xudc # For Tegra264
reg:
minItems: 2
@@ -182,6 +183,7 @@ allOf:
- nvidia,tegra194-xudc
- nvidia,tegra234-xudc
- nvidia,tegra238-xudc
+ - nvidia,tegra264-xudc
then:
properties:
reg:
@@ -201,6 +203,7 @@ allOf:
- nvidia,tegra194-xudc
- nvidia,tegra234-xudc
- nvidia,tegra238-xudc
+ - nvidia,tegra264-xudc
then:
required:
- dma-coherent
--
2.43.0
^ permalink raw reply related [flat|nested] 15+ messages in thread* [PATCH v2 05/12] usb: xhci: tegra: Fix missing semi-colon
2026-11-16 15:23 [PATCH v2 00/12] usb: Add support for Tegra238 and device support for Tegra264 Jon Hunter
` (3 preceding siblings ...)
2026-11-16 15:24 ` [PATCH v2 04/12] dt-bindings: usb: tegra-xudc: Add Tegra264 " Jon Hunter
@ 2026-11-16 15:24 ` Jon Hunter
2026-11-16 15:24 ` [PATCH v2 06/12] usb: xhci: tegra: Add support for Tegra238 Jon Hunter
` (6 subsequent siblings)
11 siblings, 0 replies; 15+ messages in thread
From: Jon Hunter @ 2026-11-16 15:24 UTC (permalink / raw)
To: Greg Kroah-Hartman, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Thierry Reding, Nagarjuna Kristam, JC Kuo,
Mathias Nyman
Cc: Thierry Reding, linux-usb, devicetree, linux-tegra,
Thierry Reding, Wayne Chang, Jon Hunter
Commit 6d45e9556d4a ("usb: xhci: standardize multi bit-field macros")
updated the Tegra XHCI driver replacing the HC_LENGTH() macro with the
FIELD_GET() macro, but in doing so dropped the trailing semi-colon. This
still compiled because the comma operator joined the assignment with the
following polling expression. Replace the comma with a semicolon to make
them separate statements.
Fixes: 6d45e9556d4a ("usb: xhci: standardize multi bit-field macros")
Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
---
drivers/usb/host/xhci-tegra.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/usb/host/xhci-tegra.c b/drivers/usb/host/xhci-tegra.c
index 1a14aea58b0b..5fbb09d2a1ae 100644
--- a/drivers/usb/host/xhci-tegra.c
+++ b/drivers/usb/host/xhci-tegra.c
@@ -995,7 +995,7 @@ static int tegra_xusb_wait_for_falcon(struct tegra_xusb *tegra)
u32 value;
cap_regs = tegra->regs;
- op_regs = tegra->regs + FIELD_GET(HC_LENGTH, readl(&cap_regs->hc_capbase)),
+ op_regs = tegra->regs + FIELD_GET(HC_LENGTH, readl(&cap_regs->hc_capbase));
ret = readl_poll_timeout(&op_regs->status, value, !(value & STS_CNR), 1000, 200000);
--
2.43.0
^ permalink raw reply related [flat|nested] 15+ messages in thread* [PATCH v2 06/12] usb: xhci: tegra: Add support for Tegra238
2026-11-16 15:23 [PATCH v2 00/12] usb: Add support for Tegra238 and device support for Tegra264 Jon Hunter
` (4 preceding siblings ...)
2026-11-16 15:24 ` [PATCH v2 05/12] usb: xhci: tegra: Fix missing semi-colon Jon Hunter
@ 2026-11-16 15:24 ` Jon Hunter
2026-11-16 15:24 ` [PATCH v2 07/12] usb: gadget: tegra-xudc: Fix CNT65 configuration Jon Hunter
` (5 subsequent siblings)
11 siblings, 0 replies; 15+ messages in thread
From: Jon Hunter @ 2026-11-16 15:24 UTC (permalink / raw)
To: Greg Kroah-Hartman, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Thierry Reding, Nagarjuna Kristam, JC Kuo,
Mathias Nyman
Cc: Thierry Reding, linux-usb, devicetree, linux-tegra,
Thierry Reding, Wayne Chang, Jon Hunter
Add XHCI support for the Tegra238 SoC which is similar to the Tegra234
XHCI but only supports 3 USB2 and 3 USB3 ports compared to the 4 USB2
and 4 USB3 ports on Tegra234.
Unlike other Tegra devices, Tegra238 does not have powergates for the
USB host and Superspeed controllers and so for Tegra238 it is only
necessary to manage the resets for these controllers. Add a
'has_powergates' variable to the SoC data to indicate if the Tegra
device supports powergates for the USB host and Superspeed devices.
For Tegra238 the driver uses devm_reset_control_get_shared() to
obtain the 'xusb_ss' reset because it is shared with the Tegra XUDC
driver.
Handle host and superspeed resets independently. During deactivation,
attempt both assertions without rollback so a host reset failure does
not retain the shared superspeed reset vote. During activation, deassert
host before superspeed and unwind failed deassertions to keep the shared
reset count balanced.
Finally, rename the functions tegra_xusb_powergate_partitions and
tegra_xusb_unpowergate_partitions as tegra_xusb_deactivate and
tegra_xusb_activate because now these only handle the resets for
Tegra238.
Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
---
drivers/usb/host/xhci-tegra.c | 113 +++++++++++++++++++++++++++++++++++-------
1 file changed, 96 insertions(+), 17 deletions(-)
diff --git a/drivers/usb/host/xhci-tegra.c b/drivers/usb/host/xhci-tegra.c
index 5fbb09d2a1ae..87c0c827832e 100644
--- a/drivers/usb/host/xhci-tegra.c
+++ b/drivers/usb/host/xhci-tegra.c
@@ -252,6 +252,7 @@ struct tegra_xusb_soc {
bool has_bar2;
bool enable_firmware_messages;
+ bool has_powergates;
};
struct tegra_xusb_context {
@@ -1173,7 +1174,7 @@ static int tegra_xusb_powerdomain_init(struct device *dev,
return 0;
}
-static int tegra_xusb_unpowergate_partitions(struct tegra_xusb *tegra)
+static int tegra_xusb_activate(struct tegra_xusb *tegra)
{
struct device *dev = tegra->dev;
int rc;
@@ -1191,7 +1192,7 @@ static int tegra_xusb_unpowergate_partitions(struct tegra_xusb *tegra)
pm_runtime_put_sync(tegra->genpd_dev_ss);
return rc;
}
- } else {
+ } else if (tegra->soc->has_powergates) {
rc = tegra_pmc_powergate_sequence_power_up(tegra->pmc,
TEGRA_POWERGATE_XUSBA,
tegra->ss_clk,
@@ -1211,15 +1212,33 @@ static int tegra_xusb_unpowergate_partitions(struct tegra_xusb *tegra)
TEGRA_POWERGATE_XUSBA);
return rc;
}
+ } else {
+ rc = reset_control_deassert(tegra->host_rst);
+ if (rc < 0) {
+ dev_err(dev, "failed to deassert host reset: %d\n", rc);
+ goto assert_host;
+ }
+
+ rc = reset_control_deassert(tegra->ss_rst);
+ if (rc < 0) {
+ dev_err(dev, "failed to deassert SS reset: %d\n", rc);
+ goto assert_ss;
+ }
}
return 0;
+
+assert_ss:
+ reset_control_assert(tegra->ss_rst);
+assert_host:
+ reset_control_assert(tegra->host_rst);
+ return rc;
}
-static int tegra_xusb_powergate_partitions(struct tegra_xusb *tegra)
+static int tegra_xusb_deactivate(struct tegra_xusb *tegra)
{
struct device *dev = tegra->dev;
- int rc;
+ int rc, err;
if (tegra->use_genpd) {
rc = pm_runtime_put_sync(tegra->genpd_dev_host);
@@ -1234,7 +1253,7 @@ static int tegra_xusb_powergate_partitions(struct tegra_xusb *tegra)
pm_runtime_get_sync(tegra->genpd_dev_host);
return rc;
}
- } else {
+ } else if (tegra->soc->has_powergates) {
rc = tegra_pmc_powergate_power_off(tegra->pmc,
TEGRA_POWERGATE_XUSBC);
if (rc < 0) {
@@ -1252,6 +1271,20 @@ static int tegra_xusb_powergate_partitions(struct tegra_xusb *tegra)
tegra->host_rst);
return rc;
}
+ } else {
+ rc = reset_control_assert(tegra->host_rst);
+ if (rc < 0)
+ dev_err(dev, "failed to assert host reset: %d\n", rc);
+
+ /*
+ * Release the shared SS reset vote even if the host reset fails,
+ * otherwise the next activation adds an unbalanced deassert vote.
+ */
+ err = reset_control_assert(tegra->ss_rst);
+ if (err < 0)
+ dev_err(dev, "failed to assert SS reset: %d\n", err);
+
+ return rc ? rc : err;
}
return 0;
@@ -1741,7 +1774,10 @@ static int tegra_xusb_probe(struct platform_device *pdev)
goto put_padctl;
}
- tegra->ss_rst = devm_reset_control_get(&pdev->dev, "xusb_ss");
+ if (tegra->soc->has_powergates)
+ tegra->ss_rst = devm_reset_control_get(&pdev->dev, "xusb_ss");
+ else
+ tegra->ss_rst = devm_reset_control_get_shared(&pdev->dev, "xusb_ss");
if (IS_ERR(tegra->ss_rst)) {
err = PTR_ERR(tegra->ss_rst);
dev_err(&pdev->dev, "failed to get xusb_ss reset: %d\n",
@@ -1749,11 +1785,13 @@ static int tegra_xusb_probe(struct platform_device *pdev)
goto put_padctl;
}
- tegra->pmc = devm_tegra_pmc_get(&pdev->dev);
- if (IS_ERR(tegra->pmc)) {
- err = dev_err_probe(&pdev->dev, PTR_ERR(tegra->pmc),
- "failed to get PMC\n");
- goto put_padctl;
+ if (tegra->soc->has_powergates) {
+ tegra->pmc = devm_tegra_pmc_get(&pdev->dev);
+ if (IS_ERR(tegra->pmc)) {
+ err = dev_err_probe(&pdev->dev, PTR_ERR(tegra->pmc),
+ "failed to get PMC\n");
+ goto put_padctl;
+ }
}
} else {
err = tegra_xusb_powerdomain_init(&pdev->dev, tegra);
@@ -1867,7 +1905,7 @@ static int tegra_xusb_probe(struct platform_device *pdev)
}
}
- err = tegra_xusb_unpowergate_partitions(tegra);
+ err = tegra_xusb_activate(tegra);
if (err)
goto free_firmware;
@@ -1959,7 +1997,7 @@ static int tegra_xusb_probe(struct platform_device *pdev)
remove_usb2:
usb_remove_hcd(tegra->hcd);
powergate:
- tegra_xusb_powergate_partitions(tegra);
+ tegra_xusb_deactivate(tegra);
free_firmware:
dma_free_coherent(&pdev->dev, tegra->fw.size, tegra->fw.virt,
tegra->fw.phys);
@@ -1981,7 +2019,7 @@ static int tegra_xusb_probe(struct platform_device *pdev)
static void tegra_xusb_disable(struct tegra_xusb *tegra)
{
- tegra_xusb_powergate_partitions(tegra);
+ tegra_xusb_deactivate(tegra);
tegra_xusb_powerdomain_remove(tegra->dev, tegra);
tegra_xusb_phy_disable(tegra);
tegra_xusb_clk_disable(tegra);
@@ -2270,7 +2308,7 @@ static int tegra_xusb_enter_elpg(struct tegra_xusb *tegra, bool is_auto_resume)
if (wakeup)
tegra_xhci_enable_phy_sleepwalk_wake(tegra);
- tegra_xusb_powergate_partitions(tegra);
+ tegra_xusb_deactivate(tegra);
for (i = 0; i < tegra->num_phys; i++) {
if (!tegra->phys[i])
@@ -2316,7 +2354,7 @@ static int tegra_xusb_exit_elpg(struct tegra_xusb *tegra, bool is_auto_resume)
goto out;
}
- err = tegra_xusb_unpowergate_partitions(tegra);
+ err = tegra_xusb_activate(tegra);
if (err)
goto disable_clks;
@@ -2374,7 +2412,8 @@ static int tegra_xusb_exit_elpg(struct tegra_xusb *tegra, bool is_auto_resume)
if (!wakeup)
phy_exit(tegra->phys[i]);
}
- tegra_xusb_powergate_partitions(tegra);
+
+ tegra_xusb_deactivate(tegra);
disable_clks:
tegra_xusb_clk_disable(tegra);
out:
@@ -2581,6 +2620,7 @@ static const struct tegra_xusb_soc tegra124_soc = {
.smi_intr = XUSB_CFG_ARU_SMI_INTR,
},
.enable_firmware_messages = true,
+ .has_powergates = true,
};
#if IS_ENABLED(CONFIG_ARCH_TEGRA_124_SOC) || IS_ENABLED(CONFIG_ARCH_TEGRA_132_SOC)
MODULE_FIRMWARE("nvidia/tegra124/xusb.bin");
@@ -2623,6 +2663,7 @@ static const struct tegra_xusb_soc tegra210_soc = {
.smi_intr = XUSB_CFG_ARU_SMI_INTR,
},
.enable_firmware_messages = true,
+ .has_powergates = true,
};
#if IS_ENABLED(CONFIG_ARCH_TEGRA_210_SOC)
MODULE_FIRMWARE("nvidia/tegra210/xusb.bin");
@@ -2673,6 +2714,7 @@ static const struct tegra_xusb_soc tegra186_soc = {
},
.lpm_support = true,
.enable_firmware_messages = true,
+ .has_powergates = true,
};
static const char * const tegra194_supply_names[] = {
@@ -2708,6 +2750,7 @@ static const struct tegra_xusb_soc tegra194_soc = {
},
.lpm_support = true,
.enable_firmware_messages = true,
+ .has_powergates = true,
};
#if IS_ENABLED(CONFIG_ARCH_TEGRA_194_SOC)
MODULE_FIRMWARE("nvidia/tegra194/xusb.bin");
@@ -2746,6 +2789,40 @@ static const struct tegra_xusb_soc tegra234_soc = {
.lpm_support = true,
.has_bar2 = true,
.enable_firmware_messages = true,
+ .has_powergates = true,
+};
+
+static const struct tegra_xusb_phy_type tegra238_phy_types[] = {
+ { .name = "usb3", .num = 3, },
+ { .name = "usb2", .num = 3, },
+};
+
+static const struct tegra_xusb_soc tegra238_soc = {
+ .supply_names = tegra194_supply_names,
+ .num_supplies = ARRAY_SIZE(tegra194_supply_names),
+ .phy_types = tegra238_phy_types,
+ .num_types = ARRAY_SIZE(tegra238_phy_types),
+ .max_num_wakes = 6,
+ .context = &tegra186_xusb_context,
+ .ports = {
+ .usb3 = { .offset = 0, .count = 3, },
+ .usb2 = { .offset = 3, .count = 3, },
+ },
+ .scale_ss_clock = false,
+ .has_ipfs = false,
+ .otg_reset_sspi = false,
+ .ops = &tegra234_ops,
+ .mbox = {
+ .cmd = XUSB_BAR2_ARU_MBOX_CMD,
+ .data_in = XUSB_BAR2_ARU_MBOX_DATA_IN,
+ .data_out = XUSB_BAR2_ARU_MBOX_DATA_OUT,
+ .owner = XUSB_BAR2_ARU_MBOX_OWNER,
+ .smi_intr = XUSB_BAR2_ARU_SMI_INTR,
+ },
+ .lpm_support = true,
+ .has_bar2 = true,
+ .enable_firmware_messages = true,
+ .has_powergates = false,
};
static const struct tegra_xusb_soc tegra264_soc = {
@@ -2773,6 +2850,7 @@ static const struct tegra_xusb_soc tegra264_soc = {
.lpm_support = true,
.has_bar2 = true,
.enable_firmware_messages = false,
+ .has_powergates = true,
};
static const struct of_device_id tegra_xusb_of_match[] = {
@@ -2781,6 +2859,7 @@ static const struct of_device_id tegra_xusb_of_match[] = {
{ .compatible = "nvidia,tegra186-xusb", .data = &tegra186_soc },
{ .compatible = "nvidia,tegra194-xusb", .data = &tegra194_soc },
{ .compatible = "nvidia,tegra234-xusb", .data = &tegra234_soc },
+ { .compatible = "nvidia,tegra238-xusb", .data = &tegra238_soc },
{ .compatible = "nvidia,tegra264-xusb", .data = &tegra264_soc },
{ },
};
--
2.43.0
^ permalink raw reply related [flat|nested] 15+ messages in thread* [PATCH v2 07/12] usb: gadget: tegra-xudc: Fix CNT65 configuration
2026-11-16 15:23 [PATCH v2 00/12] usb: Add support for Tegra238 and device support for Tegra264 Jon Hunter
` (5 preceding siblings ...)
2026-11-16 15:24 ` [PATCH v2 06/12] usb: xhci: tegra: Add support for Tegra238 Jon Hunter
@ 2026-11-16 15:24 ` Jon Hunter
2026-11-16 15:24 ` [PATCH v2 08/12] usb: gadget: tegra-xudc: Preserve runtime PM across system suspend Jon Hunter
` (4 subsequent siblings)
11 siblings, 0 replies; 15+ messages in thread
From: Jon Hunter @ 2026-11-16 15:24 UTC (permalink / raw)
To: Greg Kroah-Hartman, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Thierry Reding, Nagarjuna Kristam, JC Kuo,
Mathias Nyman
Cc: Thierry Reding, linux-usb, devicetree, linux-tegra,
Thierry Reding, Wayne Chang, Jon Hunter
Both tegra_xudc_limit_port_speed() and tegra_xudc_restore_port_speed()
prepare a value for SSPX_CORE_CNT65 but write it to SSPX_CORE_CNT66.
This leaves CNT65 unchanged and overwrites the preserved bits of CNT66
with those read from CNT65.
Write the prepared value to CNT65 in both paths so the Gen1 and Gen2
timing values are programmed correctly and CNT66 retains its own
preserved bits.
Fixes: 88607a821ffc ("usb: gadget: tegra-xudc: add port_speed_quirk")
Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
---
drivers/usb/gadget/udc/tegra-xudc.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/usb/gadget/udc/tegra-xudc.c b/drivers/usb/gadget/udc/tegra-xudc.c
index a7736627e6e2..b2af5107747c 100644
--- a/drivers/usb/gadget/udc/tegra-xudc.c
+++ b/drivers/usb/gadget/udc/tegra-xudc.c
@@ -642,7 +642,7 @@ static void tegra_xudc_limit_port_speed(struct tegra_xudc *xudc)
val = xudc_readl(xudc, SSPX_CORE_CNT65);
val &= ~(SSPX_CORE_CNT65_TX_SCD_END_TRPT_MID_MASK);
val |= SSPX_CORE_CNT65_TX_SCD_END_TRPT_MID(0x4B0);
- xudc_writel(xudc, val, SSPX_CORE_CNT66);
+ xudc_writel(xudc, val, SSPX_CORE_CNT65);
val = xudc_readl(xudc, SSPX_CORE_CNT66);
val &= ~(SSPX_CORE_CNT66_TX_SCD_BIT0_TRPT_MID_MASK);
@@ -678,7 +678,7 @@ static void tegra_xudc_restore_port_speed(struct tegra_xudc *xudc)
val = xudc_readl(xudc, SSPX_CORE_CNT65);
val &= ~(SSPX_CORE_CNT65_TX_SCD_END_TRPT_MID_MASK);
val |= SSPX_CORE_CNT65_TX_SCD_END_TRPT_MID(0xE10);
- xudc_writel(xudc, val, SSPX_CORE_CNT66);
+ xudc_writel(xudc, val, SSPX_CORE_CNT65);
val = xudc_readl(xudc, SSPX_CORE_CNT66);
val &= ~(SSPX_CORE_CNT66_TX_SCD_BIT0_TRPT_MID_MASK);
--
2.43.0
^ permalink raw reply related [flat|nested] 15+ messages in thread* [PATCH v2 08/12] usb: gadget: tegra-xudc: Preserve runtime PM across system suspend
2026-11-16 15:23 [PATCH v2 00/12] usb: Add support for Tegra238 and device support for Tegra264 Jon Hunter
` (6 preceding siblings ...)
2026-11-16 15:24 ` [PATCH v2 07/12] usb: gadget: tegra-xudc: Fix CNT65 configuration Jon Hunter
@ 2026-11-16 15:24 ` Jon Hunter
2026-11-16 15:24 ` [PATCH v2 09/12] usb: gadget: tegra-xudc: Add support for Tegra238 Jon Hunter
` (3 subsequent siblings)
11 siblings, 0 replies; 15+ messages in thread
From: Jon Hunter @ 2026-11-16 15:24 UTC (permalink / raw)
To: Greg Kroah-Hartman, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Thierry Reding, Nagarjuna Kristam, JC Kuo,
Mathias Nyman
Cc: Thierry Reding, linux-usb, devicetree, linux-tegra,
Thierry Reding, Wayne Chang, Jon Hunter
The system suspend callback leaves an already runtime-suspended
controller alone, but the system resume callback unconditionally
activates it. This enables clocks and regulators while runtime PM still
considers the device suspended. A subsequent runtime resume activates
the controller again, unbalancing the clock and regulator enable counts.
Only activate the controller during system resume if it is not runtime
suspended. Enable runtime PM before scheduling USB role work so that the
worker can resume the controller when entering device mode.
Fixes: 49db427232fe ("usb: gadget: Add UDC driver for tegra XUSB device mode controller")
Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
---
drivers/usb/gadget/udc/tegra-xudc.c | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/drivers/usb/gadget/udc/tegra-xudc.c b/drivers/usb/gadget/udc/tegra-xudc.c
index b2af5107747c..43a1940ed88a 100644
--- a/drivers/usb/gadget/udc/tegra-xudc.c
+++ b/drivers/usb/gadget/udc/tegra-xudc.c
@@ -4039,9 +4039,13 @@ static int __maybe_unused tegra_xudc_resume(struct device *dev)
unsigned long flags;
int err;
- err = tegra_xudc_unpowergate(xudc);
- if (err < 0)
- return err;
+ if (!pm_runtime_status_suspended(dev)) {
+ err = tegra_xudc_unpowergate(xudc);
+ if (err < 0)
+ return err;
+ }
+
+ pm_runtime_enable(dev);
spin_lock_irqsave(&xudc->lock, flags);
xudc->suspended = false;
@@ -4049,8 +4053,6 @@ static int __maybe_unused tegra_xudc_resume(struct device *dev)
schedule_work(&xudc->usb_role_sw_work);
spin_unlock_irqrestore(&xudc->lock, flags);
- pm_runtime_enable(dev);
-
return 0;
}
--
2.43.0
^ permalink raw reply related [flat|nested] 15+ messages in thread* [PATCH v2 09/12] usb: gadget: tegra-xudc: Add support for Tegra238
2026-11-16 15:23 [PATCH v2 00/12] usb: Add support for Tegra238 and device support for Tegra264 Jon Hunter
` (7 preceding siblings ...)
2026-11-16 15:24 ` [PATCH v2 08/12] usb: gadget: tegra-xudc: Preserve runtime PM across system suspend Jon Hunter
@ 2026-11-16 15:24 ` Jon Hunter
2026-11-16 15:54 ` sashiko-bot
2026-11-16 15:24 ` [PATCH v2 10/12] usb: gadget: tegra-xudc: Add SSPX register offset to SoC data Jon Hunter
` (2 subsequent siblings)
11 siblings, 1 reply; 15+ messages in thread
From: Jon Hunter @ 2026-11-16 15:24 UTC (permalink / raw)
To: Greg Kroah-Hartman, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Thierry Reding, Nagarjuna Kristam, JC Kuo,
Mathias Nyman
Cc: Thierry Reding, linux-usb, devicetree, linux-tegra,
Thierry Reding, Wayne Chang, Jon Hunter
Add XUDC support for the Tegra238 SoC which is similar to Tegra234 XUDC
but only supports 3 PHYs compared to the 4 PHYs on the Tegra234.
Unlike other Tegra devices, Tegra238 does not have powergates for the
USB device and Superspeed controllers, so it only needs reset management
for these controllers. Add a 'has_powergates' variable to the SoC data
to select between power domains and reset controls. Acquire xusb_dev
exclusively and xusb_ss shared because the latter is also used by the
host controller.
Handle the resets independently. During suspend and removal, assert DEV
before SS and attempt both assertions without rollback. Always release
the shared SS vote even if DEV assertion fails, so subsequent activation
does not accumulate unmatched deassert votes. Log assertion failures and
retain best-effort teardown behavior.
During activation, deassert DEV before SS and unwind failed deassertions.
Shared reset deassertion increments its count even on provider failure,
so balance a failed SS deassertion before reasserting DEV and disabling
clocks and regulators.
Rename tegra_xudc_powergate and tegra_xudc_unpowergate to
tegra_xudc_deactivate and tegra_xudc_activate because Tegra238 does not
use powergates.
Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
---
drivers/usb/gadget/udc/tegra-xudc.c | 118 +++++++++++++++++++++++++++++++-----
1 file changed, 103 insertions(+), 15 deletions(-)
diff --git a/drivers/usb/gadget/udc/tegra-xudc.c b/drivers/usb/gadget/udc/tegra-xudc.c
index 43a1940ed88a..3d7254d6ebcd 100644
--- a/drivers/usb/gadget/udc/tegra-xudc.c
+++ b/drivers/usb/gadget/udc/tegra-xudc.c
@@ -501,6 +501,9 @@ struct tegra_xudc {
struct clk_bulk_data *clks;
+ struct reset_control *dev_rst;
+ struct reset_control *ss_rst;
+
bool device_mode;
bool current_device_mode;
struct work_struct usb_role_sw_work;
@@ -556,6 +559,7 @@ struct tegra_xudc_soc {
bool port_reset_quirk;
bool port_speed_quirk;
bool has_ipfs;
+ bool has_powergates;
};
static inline u32 fpci_readl(struct tegra_xudc *xudc, unsigned int offset)
@@ -3649,6 +3653,7 @@ static struct tegra_xudc_soc tegra210_xudc_soc_data = {
.port_reset_quirk = true,
.port_speed_quirk = false,
.has_ipfs = true,
+ .has_powergates = true,
};
static struct tegra_xudc_soc tegra186_xudc_soc_data = {
@@ -3663,6 +3668,7 @@ static struct tegra_xudc_soc tegra186_xudc_soc_data = {
.port_reset_quirk = false,
.port_speed_quirk = false,
.has_ipfs = false,
+ .has_powergates = true,
};
static struct tegra_xudc_soc tegra194_xudc_soc_data = {
@@ -3677,6 +3683,7 @@ static struct tegra_xudc_soc tegra194_xudc_soc_data = {
.port_reset_quirk = false,
.port_speed_quirk = true,
.has_ipfs = false,
+ .has_powergates = true,
};
static struct tegra_xudc_soc tegra234_xudc_soc_data = {
@@ -3690,6 +3697,21 @@ static struct tegra_xudc_soc tegra234_xudc_soc_data = {
.pls_quirk = false,
.port_reset_quirk = false,
.has_ipfs = false,
+ .has_powergates = true,
+};
+
+static struct tegra_xudc_soc tegra238_xudc_soc_data = {
+ .clock_names = tegra186_xudc_clock_names,
+ .num_clks = ARRAY_SIZE(tegra186_xudc_clock_names),
+ .num_phys = 3,
+ .u1_enable = true,
+ .u2_enable = true,
+ .lpm_enable = true,
+ .invalid_seq_num = false,
+ .pls_quirk = false,
+ .port_reset_quirk = false,
+ .has_ipfs = false,
+ .has_powergates = false,
};
static const struct of_device_id tegra_xudc_of_match[] = {
@@ -3709,6 +3731,10 @@ static const struct of_device_id tegra_xudc_of_match[] = {
.compatible = "nvidia,tegra234-xudc",
.data = &tegra234_xudc_soc_data
},
+ {
+ .compatible = "nvidia,tegra238-xudc",
+ .data = &tegra238_xudc_soc_data
+ },
{ }
};
MODULE_DEVICE_TABLE(of, tegra_xudc_of_match);
@@ -3849,9 +3875,25 @@ static int tegra_xudc_probe(struct platform_device *pdev)
if (err)
goto disable_regulator;
- err = tegra_xudc_powerdomain_init(xudc);
- if (err)
- goto put_powerdomains;
+ if (xudc->soc->has_powergates) {
+ err = tegra_xudc_powerdomain_init(xudc);
+ if (err)
+ goto put_powerdomains;
+ } else {
+ xudc->dev_rst = devm_reset_control_get_exclusive(xudc->dev, "xusb_dev");
+ if (IS_ERR(xudc->dev_rst)) {
+ err = PTR_ERR(xudc->dev_rst);
+ dev_err(xudc->dev, "failed to get xusb_dev reset: %d\n", err);
+ goto disable_regulator;
+ }
+
+ xudc->ss_rst = devm_reset_control_get_shared(xudc->dev, "xusb_ss");
+ if (IS_ERR(xudc->ss_rst)) {
+ err = PTR_ERR(xudc->ss_rst);
+ dev_err(xudc->dev, "failed to get xusb_ss reset: %d\n", err);
+ goto disable_regulator;
+ }
+ }
err = tegra_xudc_phy_init(xudc);
if (err)
@@ -3916,6 +3958,23 @@ static int tegra_xudc_probe(struct platform_device *pdev)
return err;
}
+static void tegra_xudc_assert_resets(struct tegra_xudc *xudc)
+{
+ int err;
+
+ err = reset_control_assert(xudc->dev_rst);
+ if (err)
+ dev_err(xudc->dev, "failed to assert device reset: %d\n", err);
+
+ /*
+ * Release the shared SS reset vote even if the device reset fails,
+ * otherwise the next activation adds an unbalanced deassert vote.
+ */
+ err = reset_control_assert(xudc->ss_rst);
+ if (err)
+ dev_err(xudc->dev, "failed to assert SS reset: %d\n", err);
+}
+
static void tegra_xudc_remove(struct platform_device *pdev)
{
struct tegra_xudc *xudc = platform_get_drvdata(pdev);
@@ -3931,7 +3990,10 @@ static void tegra_xudc_remove(struct platform_device *pdev)
tegra_xudc_free_eps(xudc);
tegra_xudc_free_event_ring(xudc);
- tegra_xudc_powerdomain_remove(xudc);
+ if (xudc->soc->has_powergates)
+ tegra_xudc_powerdomain_remove(xudc);
+ else
+ tegra_xudc_assert_resets(xudc);
regulator_bulk_disable(xudc->soc->num_supplies, xudc->supplies);
@@ -3948,12 +4010,12 @@ static void tegra_xudc_remove(struct platform_device *pdev)
tegra_xusb_padctl_put(xudc->padctl);
}
-static int __maybe_unused tegra_xudc_powergate(struct tegra_xudc *xudc)
+static int __maybe_unused tegra_xudc_deactivate(struct tegra_xudc *xudc)
{
unsigned long flags;
u32 val;
- dev_dbg(xudc->dev, "entering ELPG\n");
+ dev_dbg(xudc->dev, "entering %s\n", __func__);
spin_lock_irqsave(&xudc->lock, flags);
@@ -3972,16 +4034,19 @@ static int __maybe_unused tegra_xudc_powergate(struct tegra_xudc *xudc)
regulator_bulk_disable(xudc->soc->num_supplies, xudc->supplies);
- dev_dbg(xudc->dev, "entering ELPG done\n");
+ if (!xudc->soc->has_powergates)
+ tegra_xudc_assert_resets(xudc);
+
+ dev_dbg(xudc->dev, "exiting %s\n", __func__);
return 0;
}
-static int __maybe_unused tegra_xudc_unpowergate(struct tegra_xudc *xudc)
+static int __maybe_unused tegra_xudc_activate(struct tegra_xudc *xudc)
{
unsigned long flags;
int err;
- dev_dbg(xudc->dev, "exiting ELPG\n");
+ dev_dbg(xudc->dev, "entering %s\n", __func__);
err = regulator_bulk_enable(xudc->soc->num_supplies,
xudc->supplies);
@@ -3990,7 +4055,21 @@ static int __maybe_unused tegra_xudc_unpowergate(struct tegra_xudc *xudc)
err = clk_bulk_prepare_enable(xudc->soc->num_clks, xudc->clks);
if (err < 0)
- return err;
+ goto err_clocks;
+
+ if (!xudc->soc->has_powergates) {
+ err = reset_control_deassert(xudc->dev_rst);
+ if (err) {
+ dev_err(xudc->dev, "failed to deassert device reset: %d\n", err);
+ goto assert_dev;
+ }
+
+ err = reset_control_deassert(xudc->ss_rst);
+ if (err) {
+ dev_err(xudc->dev, "failed to deassert SS reset: %d\n", err);
+ goto assert_ss;
+ }
+ }
tegra_xudc_fpci_ipfs_init(xudc);
@@ -4007,8 +4086,17 @@ static int __maybe_unused tegra_xudc_unpowergate(struct tegra_xudc *xudc)
xudc->powergated = false;
spin_unlock_irqrestore(&xudc->lock, flags);
- dev_dbg(xudc->dev, "exiting ELPG done\n");
+ dev_dbg(xudc->dev, "exiting %s\n", __func__);
return 0;
+
+assert_ss:
+ reset_control_assert(xudc->ss_rst);
+assert_dev:
+ reset_control_assert(xudc->dev_rst);
+ clk_bulk_disable_unprepare(xudc->soc->num_clks, xudc->clks);
+err_clocks:
+ regulator_bulk_disable(xudc->soc->num_supplies, xudc->supplies);
+ return err;
}
static int __maybe_unused tegra_xudc_suspend(struct device *dev)
@@ -4025,7 +4113,7 @@ static int __maybe_unused tegra_xudc_suspend(struct device *dev)
if (!pm_runtime_status_suspended(dev)) {
/* Forcibly disconnect before powergating. */
tegra_xudc_device_mode_off(xudc);
- tegra_xudc_powergate(xudc);
+ tegra_xudc_deactivate(xudc);
}
pm_runtime_disable(dev);
@@ -4040,7 +4128,7 @@ static int __maybe_unused tegra_xudc_resume(struct device *dev)
int err;
if (!pm_runtime_status_suspended(dev)) {
- err = tegra_xudc_unpowergate(xudc);
+ err = tegra_xudc_activate(xudc);
if (err < 0)
return err;
}
@@ -4060,14 +4148,14 @@ static int __maybe_unused tegra_xudc_runtime_suspend(struct device *dev)
{
struct tegra_xudc *xudc = dev_get_drvdata(dev);
- return tegra_xudc_powergate(xudc);
+ return tegra_xudc_deactivate(xudc);
}
static int __maybe_unused tegra_xudc_runtime_resume(struct device *dev)
{
struct tegra_xudc *xudc = dev_get_drvdata(dev);
- return tegra_xudc_unpowergate(xudc);
+ return tegra_xudc_activate(xudc);
}
static const struct dev_pm_ops tegra_xudc_pm_ops = {
--
2.43.0
^ permalink raw reply related [flat|nested] 15+ messages in thread* Re: [PATCH v2 09/12] usb: gadget: tegra-xudc: Add support for Tegra238
2026-11-16 15:24 ` [PATCH v2 09/12] usb: gadget: tegra-xudc: Add support for Tegra238 Jon Hunter
@ 2026-11-16 15:54 ` sashiko-bot
0 siblings, 0 replies; 15+ messages in thread
From: sashiko-bot @ 2026-11-16 15:54 UTC (permalink / raw)
To: Jon Hunter; +Cc: linux-usb, devicetree, robh, conor+dt
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] usb: gadget: tegra-xudc: unconditional reset assert in
tegra_xudc_remove()
--
commit 01f4840c1e0e2937e62224e3b8e14a7ec36d25bd
Author: Jon Hunter <jonathanh@nvidia.com>
usb: gadget: tegra-xudc: Add support for Tegra238
This commit adds Tegra238 SoC support to the Tegra XUDC driver, managing
the xusb_dev and xusb_ss resets instead of power domains when
has_powergates is false.
> diff --git a/drivers/usb/gadget/udc/tegra-xudc.c b/drivers/usb/gadget/udc/tegra-xudc.c
> index 43a1940ed88ab..3d7254d6ebcd1 100644
> --- a/drivers/usb/gadget/udc/tegra-xudc.c
> +++ b/drivers/usb/gadget/udc/tegra-xudc.c
[ ... ]
> @@ -3916,6 +3958,23 @@ static int tegra_xudc_probe(struct platform_device *pdev)
> return err;
> }
>
> +static void tegra_xudc_assert_resets(struct tegra_xudc *xudc)
> +{
> + int err;
> +
> + err = reset_control_assert(xudc->dev_rst);
> + if (err)
> + dev_err(xudc->dev, "failed to assert device reset: %d\n", err);
> +
> + /*
> + * Release the shared SS reset vote even if the device reset fails,
> + * otherwise the next activation adds an unbalanced deassert vote.
> + */
> + err = reset_control_assert(xudc->ss_rst);
> + if (err)
> + dev_err(xudc->dev, "failed to assert SS reset: %d\n", err);
> +}
> +
> static void tegra_xudc_remove(struct platform_device *pdev)
> {
> struct tegra_xudc *xudc = platform_get_drvdata(pdev);
> @@ -3931,7 +3990,10 @@ static void tegra_xudc_remove(struct platform_device *pdev)
> tegra_xudc_free_eps(xudc);
> tegra_xudc_free_event_ring(xudc);
>
> - tegra_xudc_powerdomain_remove(xudc);
> + if (xudc->soc->has_powergates)
> + tegra_xudc_powerdomain_remove(xudc);
> + else
> + tegra_xudc_assert_resets(xudc);
[Severity: Medium]
Can tegra_xudc_remove() call tegra_xudc_assert_resets() when xudc does not
hold a deassert vote on xudc->ss_rst?
tegra_xudc_probe() only acquires dev_rst and ss_rst, leaving them to be
deasserted by tegra_xudc_activate() on runtime resume. In
tegra_xudc_remove(), pm_runtime_get_sync() is called without checking its
return value before tegra_xudc_assert_resets() runs unconditionally. If
tegra_xudc_activate() fails (after already unwinding its reset
deassertions) or never runs when runtime PM is disabled in the kernel
configuration, reset_control_assert(xudc->ss_rst) will underflow
deassert_count in __reset_control_assert() or drop the shared SuperSpeed
reset vote held by the active xhci-tegra host controller.
Also, when pm_runtime_get_sync() succeeds, tegra_xudc_free_eps() and
tegra_xudc_free_event_ring() free the coherent transfer and event rings
while the controller, clocks, and bus mastering are still enabled, before
tegra_xudc_assert_resets() asserts the resets.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261116-tegra-usb-v2-0-42efc03a9700@nvidia.com?part=9
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH v2 10/12] usb: gadget: tegra-xudc: Add SSPX register offset to SoC data
2026-11-16 15:23 [PATCH v2 00/12] usb: Add support for Tegra238 and device support for Tegra264 Jon Hunter
` (8 preceding siblings ...)
2026-11-16 15:24 ` [PATCH v2 09/12] usb: gadget: tegra-xudc: Add support for Tegra238 Jon Hunter
@ 2026-11-16 15:24 ` Jon Hunter
2026-11-16 15:24 ` [PATCH v2 11/12] usb: gadget: tegra-xudc: Add default settings " Jon Hunter
2026-11-16 15:24 ` [PATCH v2 12/12] usb: gadget: tegra-xudc: Add support for Tegra264 Jon Hunter
11 siblings, 0 replies; 15+ messages in thread
From: Jon Hunter @ 2026-11-16 15:24 UTC (permalink / raw)
To: Greg Kroah-Hartman, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Thierry Reding, Nagarjuna Kristam, JC Kuo,
Mathias Nyman
Cc: Thierry Reding, linux-usb, devicetree, linux-tegra,
Thierry Reding, Wayne Chang, Jon Hunter
The SuperSpeed Port (SSPX) register offsets for Tegra264 (0x4000) are
different to the existing Tegra devices (0x600). In preparation for
adding support for Tegra264, add the SSPX register offset into the SoC
data and update the register definitions and register accesses to use
the offset from the SoC data.
Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
---
drivers/usb/gadget/udc/tegra-xudc.c | 90 ++++++++++++++++++++-----------------
1 file changed, 48 insertions(+), 42 deletions(-)
diff --git a/drivers/usb/gadget/udc/tegra-xudc.c b/drivers/usb/gadget/udc/tegra-xudc.c
index 3d7254d6ebcd..d11c2f5069f2 100644
--- a/drivers/usb/gadget/udc/tegra-xudc.c
+++ b/drivers/usb/gadget/udc/tegra-xudc.c
@@ -143,42 +143,42 @@
#define HSFSPI_COUNT13_U2_RESUME_K_DURATION(x) ((x) & \
HSFSPI_COUNT13_U2_RESUME_K_DURATION_MASK)
#define BLCG 0x840
-#define SSPX_CORE_CNT0 0x610
+#define SSPX_CORE_CNT0 0x10
#define SSPX_CORE_CNT0_PING_TBURST_MASK GENMASK(7, 0)
#define SSPX_CORE_CNT0_PING_TBURST(x) ((x) & SSPX_CORE_CNT0_PING_TBURST_MASK)
-#define SSPX_CORE_CNT30 0x688
+#define SSPX_CORE_CNT30 0x88
#define SSPX_CORE_CNT30_LMPITP_TIMER_MASK GENMASK(19, 0)
#define SSPX_CORE_CNT30_LMPITP_TIMER(x) ((x) & \
SSPX_CORE_CNT30_LMPITP_TIMER_MASK)
-#define SSPX_CORE_CNT32 0x690
+#define SSPX_CORE_CNT32 0x90
#define SSPX_CORE_CNT32_POLL_TBURST_MAX_MASK GENMASK(7, 0)
#define SSPX_CORE_CNT32_POLL_TBURST_MAX(x) ((x) & \
SSPX_CORE_CNT32_POLL_TBURST_MAX_MASK)
-#define SSPX_CORE_CNT56 0x6fc
+#define SSPX_CORE_CNT56 0xfc
#define SSPX_CORE_CNT56_SCD_BIT0_TRPT_MAX_MASK GENMASK(19, 0)
#define SSPX_CORE_CNT56_SCD_BIT0_TRPT_MAX(x) ((x) & \
SSPX_CORE_CNT56_SCD_BIT0_TRPT_MAX_MASK)
-#define SSPX_CORE_CNT57 0x700
+#define SSPX_CORE_CNT57 0x100
#define SSPX_CORE_CNT57_SCD_BIT1_TRPT_MAX_MASK GENMASK(19, 0)
#define SSPX_CORE_CNT57_SCD_BIT1_TRPT_MAX(x) ((x) & \
SSPX_CORE_CNT57_SCD_BIT1_TRPT_MAX_MASK)
-#define SSPX_CORE_CNT65 0x720
+#define SSPX_CORE_CNT65 0x120
#define SSPX_CORE_CNT65_TX_SCD_END_TRPT_MID_MASK GENMASK(19, 0)
#define SSPX_CORE_CNT65_TX_SCD_END_TRPT_MID(x) ((x) & \
SSPX_CORE_CNT65_TX_SCD_END_TRPT_MID_MASK)
-#define SSPX_CORE_CNT66 0x724
+#define SSPX_CORE_CNT66 0x124
#define SSPX_CORE_CNT66_TX_SCD_BIT0_TRPT_MID_MASK GENMASK(19, 0)
#define SSPX_CORE_CNT66_TX_SCD_BIT0_TRPT_MID(x) ((x) & \
SSPX_CORE_CNT66_TX_SCD_BIT0_TRPT_MID_MASK)
-#define SSPX_CORE_CNT67 0x728
+#define SSPX_CORE_CNT67 0x128
#define SSPX_CORE_CNT67_TX_SCD_BIT1_TRPT_MID_MASK GENMASK(19, 0)
#define SSPX_CORE_CNT67_TX_SCD_BIT1_TRPT_MID(x) ((x) & \
SSPX_CORE_CNT67_TX_SCD_BIT1_TRPT_MID_MASK)
-#define SSPX_CORE_CNT72 0x73c
+#define SSPX_CORE_CNT72 0x13c
#define SSPX_CORE_CNT72_SCD_LFPS_TIMEOUT_MASK GENMASK(19, 0)
#define SSPX_CORE_CNT72_SCD_LFPS_TIMEOUT(x) ((x) & \
SSPX_CORE_CNT72_SCD_LFPS_TIMEOUT_MASK)
-#define SSPX_CORE_PADCTL4 0x750
+#define SSPX_CORE_PADCTL4 0x150
#define SSPX_CORE_PADCTL4_RXDAT_VLD_TIMEOUT_U3_MASK GENMASK(19, 0)
#define SSPX_CORE_PADCTL4_RXDAT_VLD_TIMEOUT_U3(x) ((x) & \
SSPX_CORE_PADCTL4_RXDAT_VLD_TIMEOUT_U3_MASK)
@@ -551,6 +551,7 @@ struct tegra_xudc_soc {
const char * const *clock_names;
unsigned int num_clks;
unsigned int num_phys;
+ unsigned int sspx_offset;
bool u1_enable;
bool u2_enable;
bool lpm_enable;
@@ -633,35 +634,35 @@ static void tegra_xudc_limit_port_speed(struct tegra_xudc *xudc)
u32 val;
/* limit port speed to gen 1 */
- val = xudc_readl(xudc, SSPX_CORE_CNT56);
+ val = xudc_readl(xudc, xudc->soc->sspx_offset + SSPX_CORE_CNT56);
val &= ~(SSPX_CORE_CNT56_SCD_BIT0_TRPT_MAX_MASK);
val |= SSPX_CORE_CNT56_SCD_BIT0_TRPT_MAX(0x260);
- xudc_writel(xudc, val, SSPX_CORE_CNT56);
+ xudc_writel(xudc, val, xudc->soc->sspx_offset + SSPX_CORE_CNT56);
- val = xudc_readl(xudc, SSPX_CORE_CNT57);
+ val = xudc_readl(xudc, xudc->soc->sspx_offset + SSPX_CORE_CNT57);
val &= ~(SSPX_CORE_CNT57_SCD_BIT1_TRPT_MAX_MASK);
val |= SSPX_CORE_CNT57_SCD_BIT1_TRPT_MAX(0x6D6);
- xudc_writel(xudc, val, SSPX_CORE_CNT57);
+ xudc_writel(xudc, val, xudc->soc->sspx_offset + SSPX_CORE_CNT57);
- val = xudc_readl(xudc, SSPX_CORE_CNT65);
+ val = xudc_readl(xudc, xudc->soc->sspx_offset + SSPX_CORE_CNT65);
val &= ~(SSPX_CORE_CNT65_TX_SCD_END_TRPT_MID_MASK);
val |= SSPX_CORE_CNT65_TX_SCD_END_TRPT_MID(0x4B0);
- xudc_writel(xudc, val, SSPX_CORE_CNT65);
+ xudc_writel(xudc, val, xudc->soc->sspx_offset + SSPX_CORE_CNT65);
- val = xudc_readl(xudc, SSPX_CORE_CNT66);
+ val = xudc_readl(xudc, xudc->soc->sspx_offset + SSPX_CORE_CNT66);
val &= ~(SSPX_CORE_CNT66_TX_SCD_BIT0_TRPT_MID_MASK);
val |= SSPX_CORE_CNT66_TX_SCD_BIT0_TRPT_MID(0x4B0);
- xudc_writel(xudc, val, SSPX_CORE_CNT66);
+ xudc_writel(xudc, val, xudc->soc->sspx_offset + SSPX_CORE_CNT66);
- val = xudc_readl(xudc, SSPX_CORE_CNT67);
+ val = xudc_readl(xudc, xudc->soc->sspx_offset + SSPX_CORE_CNT67);
val &= ~(SSPX_CORE_CNT67_TX_SCD_BIT1_TRPT_MID_MASK);
val |= SSPX_CORE_CNT67_TX_SCD_BIT1_TRPT_MID(0x4B0);
- xudc_writel(xudc, val, SSPX_CORE_CNT67);
+ xudc_writel(xudc, val, xudc->soc->sspx_offset + SSPX_CORE_CNT67);
- val = xudc_readl(xudc, SSPX_CORE_CNT72);
+ val = xudc_readl(xudc, xudc->soc->sspx_offset + SSPX_CORE_CNT72);
val &= ~(SSPX_CORE_CNT72_SCD_LFPS_TIMEOUT_MASK);
val |= SSPX_CORE_CNT72_SCD_LFPS_TIMEOUT(0x10);
- xudc_writel(xudc, val, SSPX_CORE_CNT72);
+ xudc_writel(xudc, val, xudc->soc->sspx_offset + SSPX_CORE_CNT72);
}
static void tegra_xudc_restore_port_speed(struct tegra_xudc *xudc)
@@ -669,35 +670,35 @@ static void tegra_xudc_restore_port_speed(struct tegra_xudc *xudc)
u32 val;
/* restore port speed to gen2 */
- val = xudc_readl(xudc, SSPX_CORE_CNT56);
+ val = xudc_readl(xudc, xudc->soc->sspx_offset + SSPX_CORE_CNT56);
val &= ~(SSPX_CORE_CNT56_SCD_BIT0_TRPT_MAX_MASK);
val |= SSPX_CORE_CNT56_SCD_BIT0_TRPT_MAX(0x438);
- xudc_writel(xudc, val, SSPX_CORE_CNT56);
+ xudc_writel(xudc, val, xudc->soc->sspx_offset + SSPX_CORE_CNT56);
- val = xudc_readl(xudc, SSPX_CORE_CNT57);
+ val = xudc_readl(xudc, xudc->soc->sspx_offset + SSPX_CORE_CNT57);
val &= ~(SSPX_CORE_CNT57_SCD_BIT1_TRPT_MAX_MASK);
val |= SSPX_CORE_CNT57_SCD_BIT1_TRPT_MAX(0x528);
- xudc_writel(xudc, val, SSPX_CORE_CNT57);
+ xudc_writel(xudc, val, xudc->soc->sspx_offset + SSPX_CORE_CNT57);
- val = xudc_readl(xudc, SSPX_CORE_CNT65);
+ val = xudc_readl(xudc, xudc->soc->sspx_offset + SSPX_CORE_CNT65);
val &= ~(SSPX_CORE_CNT65_TX_SCD_END_TRPT_MID_MASK);
val |= SSPX_CORE_CNT65_TX_SCD_END_TRPT_MID(0xE10);
- xudc_writel(xudc, val, SSPX_CORE_CNT65);
+ xudc_writel(xudc, val, xudc->soc->sspx_offset + SSPX_CORE_CNT65);
- val = xudc_readl(xudc, SSPX_CORE_CNT66);
+ val = xudc_readl(xudc, xudc->soc->sspx_offset + SSPX_CORE_CNT66);
val &= ~(SSPX_CORE_CNT66_TX_SCD_BIT0_TRPT_MID_MASK);
val |= SSPX_CORE_CNT66_TX_SCD_BIT0_TRPT_MID(0x348);
- xudc_writel(xudc, val, SSPX_CORE_CNT66);
+ xudc_writel(xudc, val, xudc->soc->sspx_offset + SSPX_CORE_CNT66);
- val = xudc_readl(xudc, SSPX_CORE_CNT67);
+ val = xudc_readl(xudc, xudc->soc->sspx_offset + SSPX_CORE_CNT67);
val &= ~(SSPX_CORE_CNT67_TX_SCD_BIT1_TRPT_MID_MASK);
val |= SSPX_CORE_CNT67_TX_SCD_BIT1_TRPT_MID(0x5a0);
- xudc_writel(xudc, val, SSPX_CORE_CNT67);
+ xudc_writel(xudc, val, xudc->soc->sspx_offset + SSPX_CORE_CNT67);
- val = xudc_readl(xudc, SSPX_CORE_CNT72);
+ val = xudc_readl(xudc, xudc->soc->sspx_offset + SSPX_CORE_CNT72);
val &= ~(SSPX_CORE_CNT72_SCD_LFPS_TIMEOUT_MASK);
val |= SSPX_CORE_CNT72_SCD_LFPS_TIMEOUT(0x1c21);
- xudc_writel(xudc, val, SSPX_CORE_CNT72);
+ xudc_writel(xudc, val, xudc->soc->sspx_offset + SSPX_CORE_CNT72);
}
static void tegra_xudc_device_mode_on(struct tegra_xudc *xudc)
@@ -3413,22 +3414,22 @@ static void tegra_xudc_device_params_init(struct tegra_xudc *xudc)
tegra_xudc_limit_port_speed(xudc);
/* Set a reasonable U3 exit timer value. */
- val = xudc_readl(xudc, SSPX_CORE_PADCTL4);
+ val = xudc_readl(xudc, xudc->soc->sspx_offset + SSPX_CORE_PADCTL4);
val &= ~(SSPX_CORE_PADCTL4_RXDAT_VLD_TIMEOUT_U3_MASK);
val |= SSPX_CORE_PADCTL4_RXDAT_VLD_TIMEOUT_U3(0x5dc0);
- xudc_writel(xudc, val, SSPX_CORE_PADCTL4);
+ xudc_writel(xudc, val, xudc->soc->sspx_offset + SSPX_CORE_PADCTL4);
/* Default ping LFPS tBurst is too large. */
- val = xudc_readl(xudc, SSPX_CORE_CNT0);
+ val = xudc_readl(xudc, xudc->soc->sspx_offset + SSPX_CORE_CNT0);
val &= ~(SSPX_CORE_CNT0_PING_TBURST_MASK);
val |= SSPX_CORE_CNT0_PING_TBURST(0xa);
- xudc_writel(xudc, val, SSPX_CORE_CNT0);
+ xudc_writel(xudc, val, xudc->soc->sspx_offset + SSPX_CORE_CNT0);
/* Default tPortConfiguration timeout is too small. */
- val = xudc_readl(xudc, SSPX_CORE_CNT30);
+ val = xudc_readl(xudc, xudc->soc->sspx_offset + SSPX_CORE_CNT30);
val &= ~(SSPX_CORE_CNT30_LMPITP_TIMER_MASK);
val |= SSPX_CORE_CNT30_LMPITP_TIMER(0x978);
- xudc_writel(xudc, val, SSPX_CORE_CNT30);
+ xudc_writel(xudc, val, xudc->soc->sspx_offset + SSPX_CORE_CNT30);
if (xudc->soc->lpm_enable) {
/* Set L1 resume duration to 95 us. */
@@ -3442,10 +3443,10 @@ static void tegra_xudc_device_params_init(struct tegra_xudc *xudc)
* Compliance suite appears to be violating polling LFPS tBurst max
* of 1.4us. Send 1.45us instead.
*/
- val = xudc_readl(xudc, SSPX_CORE_CNT32);
+ val = xudc_readl(xudc, xudc->soc->sspx_offset + SSPX_CORE_CNT32);
val &= ~(SSPX_CORE_CNT32_POLL_TBURST_MAX_MASK);
val |= SSPX_CORE_CNT32_POLL_TBURST_MAX(0xb0);
- xudc_writel(xudc, val, SSPX_CORE_CNT32);
+ xudc_writel(xudc, val, xudc->soc->sspx_offset + SSPX_CORE_CNT32);
/* Direct HS/FS port instance to RxDetect. */
val = xudc_readl(xudc, CFG_DEV_FE);
@@ -3645,6 +3646,7 @@ static struct tegra_xudc_soc tegra210_xudc_soc_data = {
.clock_names = tegra210_xudc_clock_names,
.num_clks = ARRAY_SIZE(tegra210_xudc_clock_names),
.num_phys = 4,
+ .sspx_offset = 0x600,
.u1_enable = false,
.u2_enable = true,
.lpm_enable = false,
@@ -3660,6 +3662,7 @@ static struct tegra_xudc_soc tegra186_xudc_soc_data = {
.clock_names = tegra186_xudc_clock_names,
.num_clks = ARRAY_SIZE(tegra186_xudc_clock_names),
.num_phys = 4,
+ .sspx_offset = 0x600,
.u1_enable = true,
.u2_enable = true,
.lpm_enable = false,
@@ -3675,6 +3678,7 @@ static struct tegra_xudc_soc tegra194_xudc_soc_data = {
.clock_names = tegra186_xudc_clock_names,
.num_clks = ARRAY_SIZE(tegra186_xudc_clock_names),
.num_phys = 4,
+ .sspx_offset = 0x600,
.u1_enable = true,
.u2_enable = true,
.lpm_enable = true,
@@ -3690,6 +3694,7 @@ static struct tegra_xudc_soc tegra234_xudc_soc_data = {
.clock_names = tegra186_xudc_clock_names,
.num_clks = ARRAY_SIZE(tegra186_xudc_clock_names),
.num_phys = 4,
+ .sspx_offset = 0x600,
.u1_enable = true,
.u2_enable = true,
.lpm_enable = true,
@@ -3704,6 +3709,7 @@ static struct tegra_xudc_soc tegra238_xudc_soc_data = {
.clock_names = tegra186_xudc_clock_names,
.num_clks = ARRAY_SIZE(tegra186_xudc_clock_names),
.num_phys = 3,
+ .sspx_offset = 0x600,
.u1_enable = true,
.u2_enable = true,
.lpm_enable = true,
--
2.43.0
^ permalink raw reply related [flat|nested] 15+ messages in thread* [PATCH v2 11/12] usb: gadget: tegra-xudc: Add default settings to SoC data
2026-11-16 15:23 [PATCH v2 00/12] usb: Add support for Tegra238 and device support for Tegra264 Jon Hunter
` (9 preceding siblings ...)
2026-11-16 15:24 ` [PATCH v2 10/12] usb: gadget: tegra-xudc: Add SSPX register offset to SoC data Jon Hunter
@ 2026-11-16 15:24 ` Jon Hunter
2026-11-16 15:24 ` [PATCH v2 12/12] usb: gadget: tegra-xudc: Add support for Tegra264 Jon Hunter
11 siblings, 0 replies; 15+ messages in thread
From: Jon Hunter @ 2026-11-16 15:24 UTC (permalink / raw)
To: Greg Kroah-Hartman, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Thierry Reding, Nagarjuna Kristam, JC Kuo,
Mathias Nyman
Cc: Thierry Reding, linux-usb, devicetree, linux-tegra,
Thierry Reding, Wayne Chang, Jon Hunter
Some of the default settings that need to be programmed into the
SuperSpeed Port (SSPX) registers differ for Tegra264. In preparation for
adding support for Tegra264 move the necessary register settings into
the SoC data so that different values can be programmed for Tegra264.
Note that for Tegra264 not all of the SSPX registers programmed for
existing Tegra devices are programmed and so only write these registers
if there is a non-zero value in the SoC data.
Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
---
drivers/usb/gadget/udc/tegra-xudc.c | 80 ++++++++++++++++++++++++++-----------
1 file changed, 56 insertions(+), 24 deletions(-)
diff --git a/drivers/usb/gadget/udc/tegra-xudc.c b/drivers/usb/gadget/udc/tegra-xudc.c
index d11c2f5069f2..caf437d6b754 100644
--- a/drivers/usb/gadget/udc/tegra-xudc.c
+++ b/drivers/usb/gadget/udc/tegra-xudc.c
@@ -552,6 +552,10 @@ struct tegra_xudc_soc {
unsigned int num_clks;
unsigned int num_phys;
unsigned int sspx_offset;
+ unsigned int lfps_ping;
+ unsigned int lfps_poll;
+ unsigned int lmpitp_timer;
+ unsigned int u3_timeout;
bool u1_enable;
bool u2_enable;
bool lpm_enable;
@@ -3395,7 +3399,7 @@ static void tegra_xudc_fpci_ipfs_init(struct tegra_xudc *xudc)
static void tegra_xudc_device_params_init(struct tegra_xudc *xudc)
{
- u32 val, imod;
+ u32 val, imod, offset = xudc->soc->sspx_offset;
val = xudc_readl(xudc, BLCG);
if (xudc->soc->has_ipfs) {
@@ -3413,23 +3417,29 @@ static void tegra_xudc_device_params_init(struct tegra_xudc *xudc)
if (xudc->soc->port_speed_quirk)
tegra_xudc_limit_port_speed(xudc);
- /* Set a reasonable U3 exit timer value. */
- val = xudc_readl(xudc, xudc->soc->sspx_offset + SSPX_CORE_PADCTL4);
- val &= ~(SSPX_CORE_PADCTL4_RXDAT_VLD_TIMEOUT_U3_MASK);
- val |= SSPX_CORE_PADCTL4_RXDAT_VLD_TIMEOUT_U3(0x5dc0);
- xudc_writel(xudc, val, xudc->soc->sspx_offset + SSPX_CORE_PADCTL4);
+ if (xudc->soc->u3_timeout) {
+ /* Set U3 exit timer value. */
+ val = xudc_readl(xudc, offset + SSPX_CORE_PADCTL4);
+ val &= ~(SSPX_CORE_PADCTL4_RXDAT_VLD_TIMEOUT_U3_MASK);
+ val |= SSPX_CORE_PADCTL4_RXDAT_VLD_TIMEOUT_U3(xudc->soc->u3_timeout);
+ xudc_writel(xudc, val, offset + SSPX_CORE_PADCTL4);
+ }
- /* Default ping LFPS tBurst is too large. */
- val = xudc_readl(xudc, xudc->soc->sspx_offset + SSPX_CORE_CNT0);
- val &= ~(SSPX_CORE_CNT0_PING_TBURST_MASK);
- val |= SSPX_CORE_CNT0_PING_TBURST(0xa);
- xudc_writel(xudc, val, xudc->soc->sspx_offset + SSPX_CORE_CNT0);
+ if (xudc->soc->lfps_ping) {
+ /* Default ping LFPS tBurst is too large. */
+ val = xudc_readl(xudc, offset + SSPX_CORE_CNT0);
+ val &= ~(SSPX_CORE_CNT0_PING_TBURST_MASK);
+ val |= SSPX_CORE_CNT0_PING_TBURST(xudc->soc->lfps_ping);
+ xudc_writel(xudc, val, offset + SSPX_CORE_CNT0);
+ }
- /* Default tPortConfiguration timeout is too small. */
- val = xudc_readl(xudc, xudc->soc->sspx_offset + SSPX_CORE_CNT30);
- val &= ~(SSPX_CORE_CNT30_LMPITP_TIMER_MASK);
- val |= SSPX_CORE_CNT30_LMPITP_TIMER(0x978);
- xudc_writel(xudc, val, xudc->soc->sspx_offset + SSPX_CORE_CNT30);
+ if (xudc->soc->lmpitp_timer) {
+ /* Default tPortConfiguration timeout is too small. */
+ val = xudc_readl(xudc, offset + SSPX_CORE_CNT30);
+ val &= ~(SSPX_CORE_CNT30_LMPITP_TIMER_MASK);
+ val |= SSPX_CORE_CNT30_LMPITP_TIMER(xudc->soc->lmpitp_timer);
+ xudc_writel(xudc, val, offset + SSPX_CORE_CNT30);
+ }
if (xudc->soc->lpm_enable) {
/* Set L1 resume duration to 95 us. */
@@ -3439,14 +3449,16 @@ static void tegra_xudc_device_params_init(struct tegra_xudc *xudc)
xudc_writel(xudc, val, HSFSPI_COUNT13);
}
- /*
- * Compliance suite appears to be violating polling LFPS tBurst max
- * of 1.4us. Send 1.45us instead.
- */
- val = xudc_readl(xudc, xudc->soc->sspx_offset + SSPX_CORE_CNT32);
- val &= ~(SSPX_CORE_CNT32_POLL_TBURST_MAX_MASK);
- val |= SSPX_CORE_CNT32_POLL_TBURST_MAX(0xb0);
- xudc_writel(xudc, val, xudc->soc->sspx_offset + SSPX_CORE_CNT32);
+ if (xudc->soc->lfps_poll) {
+ /*
+ * Compliance suite appears to be violating polling LFPS tBurst
+ * max of 1.4us.
+ */
+ val = xudc_readl(xudc, offset + SSPX_CORE_CNT32);
+ val &= ~(SSPX_CORE_CNT32_POLL_TBURST_MAX_MASK);
+ val |= SSPX_CORE_CNT32_POLL_TBURST_MAX(xudc->soc->lfps_poll);
+ xudc_writel(xudc, val, offset + SSPX_CORE_CNT32);
+ }
/* Direct HS/FS port instance to RxDetect. */
val = xudc_readl(xudc, CFG_DEV_FE);
@@ -3647,6 +3659,10 @@ static struct tegra_xudc_soc tegra210_xudc_soc_data = {
.num_clks = ARRAY_SIZE(tegra210_xudc_clock_names),
.num_phys = 4,
.sspx_offset = 0x600,
+ .lfps_ping = 0xa,
+ .lfps_poll = 0xb0, /* 1.45us */
+ .lmpitp_timer = 0x978,
+ .u3_timeout = 0x5dc0,
.u1_enable = false,
.u2_enable = true,
.lpm_enable = false,
@@ -3663,6 +3679,10 @@ static struct tegra_xudc_soc tegra186_xudc_soc_data = {
.num_clks = ARRAY_SIZE(tegra186_xudc_clock_names),
.num_phys = 4,
.sspx_offset = 0x600,
+ .lfps_ping = 0xa,
+ .lfps_poll = 0xb0, /* 1.45us */
+ .lmpitp_timer = 0x978,
+ .u3_timeout = 0x5dc0,
.u1_enable = true,
.u2_enable = true,
.lpm_enable = false,
@@ -3679,6 +3699,10 @@ static struct tegra_xudc_soc tegra194_xudc_soc_data = {
.num_clks = ARRAY_SIZE(tegra186_xudc_clock_names),
.num_phys = 4,
.sspx_offset = 0x600,
+ .lfps_ping = 0xa,
+ .lfps_poll = 0xb0, /* 1.45us */
+ .lmpitp_timer = 0x978,
+ .u3_timeout = 0x5dc0,
.u1_enable = true,
.u2_enable = true,
.lpm_enable = true,
@@ -3695,6 +3719,10 @@ static struct tegra_xudc_soc tegra234_xudc_soc_data = {
.num_clks = ARRAY_SIZE(tegra186_xudc_clock_names),
.num_phys = 4,
.sspx_offset = 0x600,
+ .lfps_ping = 0xa,
+ .lfps_poll = 0xb0, /* 1.45us */
+ .lmpitp_timer = 0x978,
+ .u3_timeout = 0x5dc0,
.u1_enable = true,
.u2_enable = true,
.lpm_enable = true,
@@ -3710,6 +3738,10 @@ static struct tegra_xudc_soc tegra238_xudc_soc_data = {
.num_clks = ARRAY_SIZE(tegra186_xudc_clock_names),
.num_phys = 3,
.sspx_offset = 0x600,
+ .lfps_ping = 0xa,
+ .lfps_poll = 0xb0, /* 1.45us */
+ .lmpitp_timer = 0x978,
+ .u3_timeout = 0x5dc0,
.u1_enable = true,
.u2_enable = true,
.lpm_enable = true,
--
2.43.0
^ permalink raw reply related [flat|nested] 15+ messages in thread* [PATCH v2 12/12] usb: gadget: tegra-xudc: Add support for Tegra264
2026-11-16 15:23 [PATCH v2 00/12] usb: Add support for Tegra238 and device support for Tegra264 Jon Hunter
` (10 preceding siblings ...)
2026-11-16 15:24 ` [PATCH v2 11/12] usb: gadget: tegra-xudc: Add default settings " Jon Hunter
@ 2026-11-16 15:24 ` Jon Hunter
11 siblings, 0 replies; 15+ messages in thread
From: Jon Hunter @ 2026-11-16 15:24 UTC (permalink / raw)
To: Greg Kroah-Hartman, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Thierry Reding, Nagarjuna Kristam, JC Kuo,
Mathias Nyman
Cc: Thierry Reding, linux-usb, devicetree, linux-tegra,
Thierry Reding, Wayne Chang, Jon Hunter
Add support for the Tegra264 XUDC by adding the device-tree compatible
string, SoC data and additional registers that need to be configured for
Tegra264. The LMP ITP timer mask in the SSPX_CORE_CNT30 register is
different for Tegra264 and so move the mask into the SoC data.
Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
---
drivers/usb/gadget/udc/tegra-xudc.c | 61 ++++++++++++++++++++++++++++++++++---
1 file changed, 56 insertions(+), 5 deletions(-)
diff --git a/drivers/usb/gadget/udc/tegra-xudc.c b/drivers/usb/gadget/udc/tegra-xudc.c
index caf437d6b754..b4b6fdc9367b 100644
--- a/drivers/usb/gadget/udc/tegra-xudc.c
+++ b/drivers/usb/gadget/udc/tegra-xudc.c
@@ -146,10 +146,15 @@
#define SSPX_CORE_CNT0 0x10
#define SSPX_CORE_CNT0_PING_TBURST_MASK GENMASK(7, 0)
#define SSPX_CORE_CNT0_PING_TBURST(x) ((x) & SSPX_CORE_CNT0_PING_TBURST_MASK)
+#define SSPX_CORE_CNT13 0x44
+#define SSPX_CORE_CNT13_CRDTHP_TIMER_MASK GENMASK(11, 0)
+#define SSPX_CORE_CNT13_CRDTHP_TIMER(x) ((x) & \
+ SSPX_CORE_CNT13_CRDTHP_TIMER_MASK)
+#define SSPX_CORE_CNT27 0x7c
+#define SSPX_CORE_CNT27_PING_LFPS_TRPT_MASK GENMASK(29, 0)
+#define SSPX_CORE_CNT27_PING_LFPS_TRPT(x) ((x) & \
+ SSPX_CORE_CNT27_PING_LFPS_TRPT_MASK)
#define SSPX_CORE_CNT30 0x88
-#define SSPX_CORE_CNT30_LMPITP_TIMER_MASK GENMASK(19, 0)
-#define SSPX_CORE_CNT30_LMPITP_TIMER(x) ((x) & \
- SSPX_CORE_CNT30_LMPITP_TIMER_MASK)
#define SSPX_CORE_CNT32 0x90
#define SSPX_CORE_CNT32_POLL_TBURST_MAX_MASK GENMASK(7, 0)
#define SSPX_CORE_CNT32_POLL_TBURST_MAX(x) ((x) & \
@@ -552,9 +557,12 @@ struct tegra_xudc_soc {
unsigned int num_clks;
unsigned int num_phys;
unsigned int sspx_offset;
+ unsigned int crdthp_timer;
unsigned int lfps_ping;
+ unsigned int lfps_ping_trpt;
unsigned int lfps_poll;
unsigned int lmpitp_timer;
+ unsigned int lmpitp_timer_mask;
unsigned int u3_timeout;
bool u1_enable;
bool u2_enable;
@@ -3433,11 +3441,25 @@ static void tegra_xudc_device_params_init(struct tegra_xudc *xudc)
xudc_writel(xudc, val, offset + SSPX_CORE_CNT0);
}
+ if (xudc->soc->crdthp_timer) {
+ val = xudc_readl(xudc, offset + SSPX_CORE_CNT13);
+ val &= ~(SSPX_CORE_CNT13_CRDTHP_TIMER_MASK);
+ val |= SSPX_CORE_CNT13_CRDTHP_TIMER(xudc->soc->crdthp_timer);
+ xudc_writel(xudc, val, offset + SSPX_CORE_CNT13);
+ }
+
+ if (xudc->soc->lfps_ping_trpt) {
+ val = xudc_readl(xudc, offset + SSPX_CORE_CNT27);
+ val &= ~(SSPX_CORE_CNT27_PING_LFPS_TRPT_MASK);
+ val |= SSPX_CORE_CNT27_PING_LFPS_TRPT(xudc->soc->lfps_ping_trpt);
+ xudc_writel(xudc, val, offset + SSPX_CORE_CNT27);
+ }
+
if (xudc->soc->lmpitp_timer) {
/* Default tPortConfiguration timeout is too small. */
val = xudc_readl(xudc, offset + SSPX_CORE_CNT30);
- val &= ~(SSPX_CORE_CNT30_LMPITP_TIMER_MASK);
- val |= SSPX_CORE_CNT30_LMPITP_TIMER(xudc->soc->lmpitp_timer);
+ val &= ~(xudc->soc->lmpitp_timer_mask);
+ val |= xudc->soc->lmpitp_timer & xudc->soc->lmpitp_timer_mask;
xudc_writel(xudc, val, offset + SSPX_CORE_CNT30);
}
@@ -3662,6 +3684,7 @@ static struct tegra_xudc_soc tegra210_xudc_soc_data = {
.lfps_ping = 0xa,
.lfps_poll = 0xb0, /* 1.45us */
.lmpitp_timer = 0x978,
+ .lmpitp_timer_mask = GENMASK(19, 0),
.u3_timeout = 0x5dc0,
.u1_enable = false,
.u2_enable = true,
@@ -3682,6 +3705,7 @@ static struct tegra_xudc_soc tegra186_xudc_soc_data = {
.lfps_ping = 0xa,
.lfps_poll = 0xb0, /* 1.45us */
.lmpitp_timer = 0x978,
+ .lmpitp_timer_mask = GENMASK(19, 0),
.u3_timeout = 0x5dc0,
.u1_enable = true,
.u2_enable = true,
@@ -3702,6 +3726,7 @@ static struct tegra_xudc_soc tegra194_xudc_soc_data = {
.lfps_ping = 0xa,
.lfps_poll = 0xb0, /* 1.45us */
.lmpitp_timer = 0x978,
+ .lmpitp_timer_mask = GENMASK(19, 0),
.u3_timeout = 0x5dc0,
.u1_enable = true,
.u2_enable = true,
@@ -3722,6 +3747,7 @@ static struct tegra_xudc_soc tegra234_xudc_soc_data = {
.lfps_ping = 0xa,
.lfps_poll = 0xb0, /* 1.45us */
.lmpitp_timer = 0x978,
+ .lmpitp_timer_mask = GENMASK(19, 0),
.u3_timeout = 0x5dc0,
.u1_enable = true,
.u2_enable = true,
@@ -3741,6 +3767,7 @@ static struct tegra_xudc_soc tegra238_xudc_soc_data = {
.lfps_ping = 0xa,
.lfps_poll = 0xb0, /* 1.45us */
.lmpitp_timer = 0x978,
+ .lmpitp_timer_mask = GENMASK(19, 0),
.u3_timeout = 0x5dc0,
.u1_enable = true,
.u2_enable = true,
@@ -3752,6 +3779,26 @@ static struct tegra_xudc_soc tegra238_xudc_soc_data = {
.has_powergates = false,
};
+static struct tegra_xudc_soc tegra264_xudc_soc_data = {
+ .clock_names = tegra186_xudc_clock_names,
+ .num_clks = ARRAY_SIZE(tegra186_xudc_clock_names),
+ .num_phys = 4,
+ .sspx_offset = 0x4000,
+ .crdthp_timer = 0x33,
+ .lfps_ping_trpt = 0x7a1200,
+ .lfps_poll = 0x3b, /* 1.466us */
+ .lmpitp_timer = 0xc9,
+ .lmpitp_timer_mask = GENMASK(11, 0),
+ .u1_enable = true,
+ .u2_enable = true,
+ .lpm_enable = true,
+ .invalid_seq_num = false,
+ .pls_quirk = false,
+ .port_reset_quirk = false,
+ .has_ipfs = false,
+ .has_powergates = true,
+};
+
static const struct of_device_id tegra_xudc_of_match[] = {
{
.compatible = "nvidia,tegra210-xudc",
@@ -3773,6 +3820,10 @@ static const struct of_device_id tegra_xudc_of_match[] = {
.compatible = "nvidia,tegra238-xudc",
.data = &tegra238_xudc_soc_data
},
+ {
+ .compatible = "nvidia,tegra264-xudc",
+ .data = &tegra264_xudc_soc_data
+ },
{ }
};
MODULE_DEVICE_TABLE(of, tegra_xudc_of_match);
--
2.43.0
^ permalink raw reply related [flat|nested] 15+ messages in thread