usb: Add support for Tegra238 and device support for Tegra264
Subsystems (4)
Jon Hunter
maintainerv2 cover usb: Add support for Tegra238 and device support for Tegra264
Add USB device and host support for the Tegra238 device and add USB device support for the Tegra264 device. USB host support for Tegra264 is already present in the base tree.
The series adds the necessary device-tree binding updates for these devices and adds the SoC data to the USB drivers. For the Tegra264 USB device, the register offsets and default settings differ from previous generations and so the driver has been updated accordingly.
The series also fixes CNT65 register programming and preserves runtime PM state across system suspend in the Tegra XUDC driver, and replaces an unintended comma with a semicolon in the Tegra XHCI driver.
---
Changes in v2:
- Added a patch documenting required properties for the Tegra234 XUSB binding.
- Updated Tegra238 XHCI and XUDC bindings to require resets instead of power domains.
- Limited Tegra238 XHCI bindings to eight interrupts and one IOMMU entry, and clarified the PHY counts in the binding commit messages.
- Updated Tegra238 XHCI and XUDC drivers to manage resets directly.
- Added a patch replacing an unintended comma with a semicolon in the XHCI driver.
- Extended the CNT65 fix to cover both limiting and restoring port speed.
- Added a patch preserving XUDC runtime PM state across system suspend.
- Link to v1: https://patch.msgid.link/[email protected]
---
Jon Hunter (12):
dt-bindings: usb: tegra234-xusb: Add required properties
dt-bindings: usb: Add Tegra238 XUSB host controller support
dt-bindings: usb: tegra-xudc: Add Tegra238 XUDC support
dt-bindings: usb: tegra-xudc: Add Tegra264 XUDC support
usb: xhci: tegra: Fix missing semi-colon
usb: xhci: tegra: Add support for Tegra238
usb: gadget: tegra-xudc: Fix CNT65 configuration
usb: gadget: tegra-xudc: Preserve runtime PM across system suspend
usb: gadget: tegra-xudc: Add support for Tegra238
usb: gadget: tegra-xudc: Add SSPX register offset to SoC data
usb: gadget: tegra-xudc: Add default settings to SoC data
usb: gadget: tegra-xudc: Add support for Tegra264
.../devicetree/bindings/usb/nvidia,tegra-xudc.yaml | 38 ++- .../bindings/usb/nvidia,tegra234-xusb.yaml | 57 ++++ drivers/usb/gadget/udc/tegra-xudc.c | 339 ++++++++++++++++----- drivers/usb/host/xhci-tegra.c | 115 +++++-- 4 files changed, 449 insertions(+), 100 deletions(-)
---
base-commit: 84abb955b1015477aa11a96e2f3ac1b938b77f48
change-id: 20260918-tegra-usb-58d1d80e4797
Best regards,
Signature · 1 line
Jon Hunter <[email protected]>
Jon Hunter
maintainerPATCH v2 1/12 dt-bindings: usb: tegra234-xusb: Add required properties
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.
--- .../devicetree/bindings/usb/nvidia,tegra234-xusb.yaml | 13 +++++++++++++ 1 file changed, 13 insertions(+)
Documentation/devicetree/bindings/usb/nvidia,tegra234-xusb.yaml +13 -0
@@ -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
Signature · 1 line
2.43.0
[email protected]
AI reviewRe: [PATCH v2 01/12] dt-bindings: usb: tegra234-xusb: Add required properties
Sashiko has reviewed this patch and found no issues.
Quoted 8 lines
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 <[email protected]>
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Re: [PATCH v2 01/12] dt-bindings: usb: tegra234-xusb: Add required properties
In reply to Jon HunterQuoted 11 lines · 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 <[email protected]>--- .../devicetree/bindings/usb/nvidia,tegra234-xusb.yaml | 13 +++++++++++++ 1 file changed, 13 insertions(+)
Best regards,
Krzysztof
Jon Hunter
maintainerPATCH v2 2/12 dt-bindings: usb: Add Tegra238 XUSB host controller support
In reply to Jon HunterAdd 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.
--- .../bindings/usb/nvidia,tegra234-xusb.yaml | 48 +++++++++++++++++++++- 1 file changed, 46 insertions(+), 2 deletions(-)
Documentation/devicetree/bindings/usb/nvidia,tegra234-xusb.yaml +46 -2
@@ -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:
Signature · 1 line
2.43.0
[email protected]
AI reviewRe: [PATCH v2 02/12] dt-bindings: usb: Add Tegra238 XUSB host controller support
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 --
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 <[email protected]>
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.
Quoted 4 lines
Documentation/devicetree/bindings/usb/nvidia,tegra234-xusb.yaml +0
-0
[ ... ]
Quoted 34 lines
Documentation/devicetree/bindings/usb/nvidia,tegra234-xusb.yaml +25
-2@@ -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
Documentation/devicetree/bindings/usb/nvidia,tegra234-xusb.yaml required: · line 213
Quoted 10 lines
Documentation/devicetree/bindings/usb/nvidia,tegra234-xusb.yaml +10
-0+ 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.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2
Re: [PATCH v2 02/12] dt-bindings: usb: Add Tegra238 XUSB host controller support
In reply to Jon HunterQuoted 4 lines · Jon Hunter
reg:
Documentation/devicetree/bindings/usb/nvidia,tegra234-xusb.yaml +0
-0@@ -140,6 +141,16 @@ properties: - usb3-2 - usb3-3
Documentation/devicetree/bindings/usb/nvidia,tegra234-xusb.yaml properties: · line 152
Quoted 10 lines
Documentation/devicetree/bindings/usb/nvidia,tegra234-xusb.yaml +9
-0+ resets: + items: + - description: XUSB host controller reset + - description: XUSB SuperSpeed reset + + reset-names: + items: + - const: xusb_host + - const: xusb_ss
Drop xusb_ prefix, that's the name of this device.
Quoted 28 lines
Documentation/devicetree/bindings/usb/nvidia,tegra234-xusb.yaml +16
-2+ 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
Documentation/devicetree/bindings/usb/nvidia,tegra234-xusb.yaml required: · line 203
Quoted 10 lines
Documentation/devicetree/bindings/usb/nvidia,tegra234-xusb.yaml +10
-0+ phy-names: + maxItems: 6 + items: + enum: + - usb2-0 + - usb2-1 + - usb2-2 + - usb3-0 + - usb3-1 + - usb3-2
This should be rather fixed for this device, so without enum, just:
items:
- const: ...
- const: ...
....
Best regards,
Krzysztof
Re: [PATCH v2 02/12] dt-bindings: usb: Add Tegra238 XUSB host controller support
Quoted 20 lines · Krzysztof Kozlowski
Quoted 9 lines
Documentation/devicetree/bindings/usb/nvidia,tegra234-xusb.yaml +9
-0+ properties: + interrupts: + maxItems: 8 + iommus: + maxItems: 1 + power-domains: false + power-domain-names: false + phys: + maxItems: 6Documentation/devicetree/bindings/usb/nvidia,tegra234-xusb.yaml required: · line 203
Quoted 10 lines
Documentation/devicetree/bindings/usb/nvidia,tegra234-xusb.yaml +10
-0+ phy-names: + maxItems: 6 + items: + enum: + - usb2-0 + - usb2-1 + - usb2-2 + - usb3-0 + - usb3-1 + - usb3-2
Quoted 6 lines
This should be rather fixed for this device, so without enum, just:
items:
- const: ...
- const: ...
....
Although I see now we talked about this - this supports *up to 6* phys, so the list is not fixed per given IP block instance?
Best regards,
Krzysztof
Jon Hunter
maintainerRe: [PATCH v2 02/12] dt-bindings: usb: Add Tegra238 XUSB host controller support
Quoted 28 lines · Krzysztof Kozlowski
Quoted 20 lines · Krzysztof Kozlowski
Quoted 9 lines
Documentation/devicetree/bindings/usb/nvidia,tegra234-xusb.yaml +9
-0+ properties: + interrupts: + maxItems: 8 + iommus: + maxItems: 1 + power-domains: false + power-domain-names: false + phys: + maxItems: 6Documentation/devicetree/bindings/usb/nvidia,tegra234-xusb.yaml required: · line 203
Quoted 10 lines
Documentation/devicetree/bindings/usb/nvidia,tegra234-xusb.yaml +10
-0+ phy-names: + maxItems: 6 + items: + enum: + - usb2-0 + - usb2-1 + - usb2-2 + - usb3-0 + - usb3-1 + - usb3-2Quoted 6 lines
This should be rather fixed for this device, so without enum, just:
items:
- const: ...
- const: ...
....
Quoted 2 lines
Although I see now we talked about this - this supports *up to 6* phys, so the list is not fixed per given IP block instance?
Yes that's correct.
Jon
Signature · 1 line
nvpublic
Jon Hunter
maintainerRe: [PATCH v2 02/12] dt-bindings: usb: Add Tegra238 XUSB host controller support
In reply to Krzysztof KozlowskiQuoted 6 lines · Krzysztof Kozlowski
Quoted 5 lines · Jon Hunter
reg:
Documentation/devicetree/bindings/usb/nvidia,tegra234-xusb.yaml +0
-0@@ -140,6 +141,16 @@ properties: - usb3-2 - usb3-3
Quoted 11 lines
Documentation/devicetree/bindings/usb/nvidia,tegra234-xusb.yaml properties: · line 152
Quoted 9 lines
Documentation/devicetree/bindings/usb/nvidia,tegra234-xusb.yaml +9
-0+ resets: + items: + - description: XUSB host controller reset + - description: XUSB SuperSpeed reset + + reset-names: + items: + - const: xusb_host + - const: xusb_ssDrop
xusb_prefix, that's the name of this device.
While I don't disagree, this is consistent with the other naming for things such as ...
clock-names:
items:
- const: xusb_host
- const: xusb_falcon_src
- const: xusb_ss
- const: xusb_ss_src
- const: xusb_hs_src
- const: xusb_fs_src
- const: pll_u_480m
- const: clk_m
- const: pll_e
power-domain-names:
items:
- const: xusb_host
- const: xusb_ss
We probably should have dropped the 'xusb_' for all of these. Given the above do you still prefer we drop 'xusb_' for the resets?
Jon
Signature · 1 line
nvpublic
Re: [PATCH v2 02/12] dt-bindings: usb: Add Tegra238 XUSB host controller support
Quoted 23 lines · Jon Hunter
Quoted 6 lines
Documentation/devicetree/bindings/usb/nvidia,tegra234-xusb.yaml properties: · line 152
Quoted 4 lines
Documentation/devicetree/bindings/usb/nvidia,tegra234-xusb.yaml +4
-0+ reset-names: + items: + - const: xusb_host + - const: xusb_ssDrop
xusb_prefix, that's the name of this device.While I don't disagree, this is consistent with the other naming for things such as ...
clock-names:
items:
- const:xusb_host
- const:xusb_falcon_src
- const:xusb_ss
- const:xusb_ss_src
- const:xusb_hs_src
- const:xusb_fs_src
- const:pll_u_480m
- const:clk_m
- const:pll_e
Quoted 7 lines
power-domain-names:
items:
- const:xusb_host
- const:xusb_ssWe probably should have dropped the '
xusb_' for all of these. Given the above do you still prefer we drop 'xusb_' for the resets?
I prefer inconsistency, so resets without xusb, because otherwise we will never move from discouraged namings.
Best regards,
Krzysztof
Jon Hunter
maintainerPATCH v2 3/12 dt-bindings: usb: tegra-xudc: Add Tegra238 XUDC support
In reply to Jon HunterAdd 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
--- .../devicetree/bindings/usb/nvidia,tegra-xudc.yaml | 35 ++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-)
Documentation/devicetree/bindings/usb/nvidia,tegra-xudc.yaml +33 -2
@@ -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
Signature · 1 line
2.43.0
[email protected]
AI reviewRe: [PATCH v2 03/12] dt-bindings: usb: tegra-xudc: Add Tegra238 XUDC support
Sashiko has reviewed this patch and found no issues.
Quoted 7 lines
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.
Quoted 8 lines
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.yamlSigned-off-by Jon Hunter <[email protected]>
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=3
Jon Hunter
maintainerPATCH v2 4/12 dt-bindings: usb: tegra-xudc: Add Tegra264 XUDC support
In reply to Jon HunterAdd 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.
--- Documentation/devicetree/bindings/usb/nvidia,tegra-xudc.yaml | 3 +++ 1 file changed, 3 insertions(+)
Documentation/devicetree/bindings/usb/nvidia,tegra-xudc.yaml +3 -0
@@ -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
Signature · 1 line
2.43.0
[email protected]
AI reviewRe: [PATCH v2 04/12] dt-bindings: usb: tegra-xudc: Add Tegra264 XUDC support
Sashiko has reviewed this patch and found no issues.
Quoted 7 lines
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 <[email protected]>Signed-off-by Jon Hunter <[email protected]>
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=4
Jon Hunter
maintainerPATCH v2 5/12 usb: xhci: tegra: Fix missing semi-colon
In reply to Jon HunterCommit 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.
--- drivers/usb/host/xhci-tegra.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/host/xhci-tegra.c +1 -1
@@ -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 );
Signature · 1 line
2.43.0
[email protected]
AI reviewRe: [PATCH v2 05/12] usb: xhci: tegra: Fix missing semi-colon
Sashiko has reviewed this patch and found no issues.
Quoted 9 lines
Commit
6d45e9556d4a("usb: xhci: standardize multi bit-field macros") updated the Tegra XHCI driver replacing theHC_LENGTH()macro with theFIELD_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 <[email protected]>
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=5
Re: [PATCH v2 05/12] usb: xhci: tegra: Fix missing semi-colon
In reply to Jon HunterQuoted 19 lines · Jon Hunter
Commit
6d45e9556d4a("usb: xhci: standardize multi bit-field macros") updated the Tegra XHCI driver replacing theHC_LENGTH()macro with theFIELD_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 <[email protected]>--- drivers/usb/host/xhci-tegra.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/usb/host/xhci-tegra.c +0
-0
drivers/usb/host/xhci-tegra.c static int tegra_xusb_wait_for_falcon(struct tegra_xusb *tegra) · line 1001
Quoted 8 lines
drivers/usb/host/xhci-tegra.c +1
-1@@ -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 );
I'm cherry picking this as a separate fix for usb-linus
Thanks
Mathias
Jon Hunter
maintainerPATCH v2 6/12 usb: xhci: tegra: Add support for Tegra238
In reply to Jon HunterAdd 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.
--- drivers/usb/host/xhci-tegra.c | 113 +++++++++++++++++++++++++++++++++++------- 1 file changed, 96 insertions(+), 17 deletions(-)
drivers/usb/host/xhci-tegra.c +96 -17
@@ -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 }, { }, };
Signature · 1 line
2.43.0
[email protected]
AI reviewRe: [PATCH v2 06/12] usb: xhci: tegra: Add support for Tegra238
Sashiko has reviewed this patch and found no issues.
Quoted 19 lines
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 usesdevm_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.
Quoted 6 lines
Finally, rename the functions
tegra_xusb_powergate_partitionsandtegra_xusb_unpowergate_partitionsastegra_xusb_deactivateandtegra_xusb_activatebecause now these only handle the resets for Tegra238.Signed-off-by Jon Hunter <[email protected]>
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=6
Jon Hunter
maintainerPATCH v2 7/12 usb: gadget: tegra-xudc: Fix CNT65 configuration
In reply to Jon HunterBoth 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.
--- drivers/usb/gadget/udc/tegra-xudc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/usb/gadget/udc/tegra-xudc.c +2 -2
@@ -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 );
Signature · 1 line
2.43.0
[email protected]
AI reviewRe: [PATCH v2 07/12] usb: gadget: tegra-xudc: Fix CNT65 configuration
Sashiko has reviewed this patch and found no issues.
Quoted 11 lines
Both
tegra_xudc_limit_port_speed()andtegra_xudc_restore_port_speed()prepare a value forSSPX_CORE_CNT65but write it toSSPX_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 <[email protected]>
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=7
Jon Hunter
maintainerPATCH v2 8/12 usb: gadget: tegra-xudc: Preserve runtime PM across system suspend
In reply to Jon HunterThe 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.
--- drivers/usb/gadget/udc/tegra-xudc.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
drivers/usb/gadget/udc/tegra-xudc.c +7 -5
@@ -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 ; }
Signature · 1 line
2.43.0
[email protected]
AI reviewRe: [PATCH v2 08/12] usb: gadget: tegra-xudc: Preserve runtime PM across system suspend
Sashiko has reviewed this patch and found no issues.
Quoted 6 lines
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.
Quoted 6 lines
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 <[email protected]>
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=8
Jon Hunter
maintainerPATCH v2 9/12 usb: gadget: tegra-xudc: Add support for Tegra238
In reply to Jon HunterAdd 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.
--- drivers/usb/gadget/udc/tegra-xudc.c | 118 +++++++++++++++++++++++++++++++----- 1 file changed, 103 insertions(+), 15 deletions(-)
drivers/usb/gadget/udc/tegra-xudc.c +103 -15
@@ -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 = {
Signature · 1 line
2.43.0
[email protected]
AI reviewRe: [PATCH v2 09/12] usb: gadget: tegra-xudc: Add support for Tegra238
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() --
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 <[email protected]>
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.
Quoted 4 lines
drivers/usb/gadget/udc/tegra-xudc.c +0
-0
[ ... ]
Quoted 25 lines
drivers/usb/gadget/udc/tegra-xudc.c +17
-0@@ -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);
drivers/usb/gadget/udc/tegra-xudc.c static void tegra_xudc_remove(struct platform_device *pdev) · line 3996
Quoted 8 lines
drivers/usb/gadget/udc/tegra-xudc.c +4
-1@@ -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.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=9
Jon Hunter
maintainerPATCH v2 10/12 usb: gadget: tegra-xudc: Add SSPX register offset to SoC data
In reply to Jon HunterThe 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.
--- drivers/usb/gadget/udc/tegra-xudc.c | 90 ++++++++++++++++++++----------------- 1 file changed, 48 insertions(+), 42 deletions(-)
drivers/usb/gadget/udc/tegra-xudc.c +48 -42
@@ -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,
Signature · 1 line
2.43.0
[email protected]
AI reviewRe: [PATCH v2 10/12] usb: gadget: tegra-xudc: Add SSPX register offset to SoC data
Sashiko has reviewed this patch and found no issues.
Quoted 7 lines
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 <[email protected]>
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=10
Jon Hunter
maintainerPATCH v2 11/12 usb: gadget: tegra-xudc: Add default settings to SoC data
In reply to Jon HunterSome 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.
--- drivers/usb/gadget/udc/tegra-xudc.c | 80 ++++++++++++++++++++++++++----------- 1 file changed, 56 insertions(+), 24 deletions(-)
drivers/usb/gadget/udc/tegra-xudc.c +56 -24
@@ -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,
Signature · 1 line
2.43.0
[email protected]
AI reviewRe: [PATCH v2 11/12] usb: gadget: tegra-xudc: Add default settings to SoC data
Sashiko has reviewed this patch and found no issues.
Quoted 9 lines
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 <[email protected]>
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=11
Jon Hunter
maintainerPATCH v2 12/12 usb: gadget: tegra-xudc: Add support for Tegra264
In reply to Jon HunterAdd 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.
--- drivers/usb/gadget/udc/tegra-xudc.c | 61 ++++++++++++++++++++++++++++++++++--- 1 file changed, 56 insertions(+), 5 deletions(-)
drivers/usb/gadget/udc/tegra-xudc.c +56 -5
@@ -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);
Signature · 1 line
2.43.0
[email protected]
AI reviewRe: [PATCH v2 12/12] usb: gadget: tegra-xudc: Add support for Tegra264
Sashiko has reviewed this patch and found no issues.
Quoted 6 lines
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_CNT30register is different for Tegra264 and so move the mask into the SoC data.Signed-off-by Jon Hunter <[email protected]>
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=12