From: Jon Hunter <jonathanh@nvidia.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
Thierry Reding <thierry.reding@kernel.org>,
"Nagarjuna Kristam" <nkristam@nvidia.com>,
JC Kuo <jckuo@nvidia.com>,
Mathias Nyman <mathias.nyman@intel.com>
Cc: Thierry Reding <thierry.reding@gmail.com>,
<linux-usb@vger.kernel.org>, <devicetree@vger.kernel.org>,
<linux-tegra@vger.kernel.org>,
Thierry Reding <treding@nvidia.com>,
Wayne Chang <waynec@nvidia.com>,
Jon Hunter <jonathanh@nvidia.com>
Subject: [PATCH v2 06/12] usb: xhci: tegra: Add support for Tegra238
Date: Mon, 16 Nov 2026 15:24:03 +0000 [thread overview]
Message-ID: <20261116-tegra-usb-v2-6-42efc03a9700@nvidia.com> (raw)
In-Reply-To: <20261116-tegra-usb-v2-0-42efc03a9700@nvidia.com>
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
next prev parent reply other threads:[~2026-11-16 15:25 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
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:33 ` sashiko-bot
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
2026-11-16 15:24 ` [PATCH v2 03/12] dt-bindings: usb: tegra-xudc: Add Tegra238 XUDC support Jon Hunter
2026-11-16 15:32 ` sashiko-bot
2026-11-16 15:24 ` [PATCH v2 04/12] dt-bindings: usb: tegra-xudc: Add Tegra264 " Jon Hunter
2026-11-16 15:32 ` sashiko-bot
2026-11-16 15:24 ` [PATCH v2 05/12] usb: xhci: tegra: Fix missing semi-colon Jon Hunter
2026-11-16 15:30 ` sashiko-bot
2026-11-16 15:24 ` Jon Hunter [this message]
2026-11-16 15:36 ` [PATCH v2 06/12] usb: xhci: tegra: Add support for Tegra238 sashiko-bot
2026-11-16 15:24 ` [PATCH v2 07/12] usb: gadget: tegra-xudc: Fix CNT65 configuration Jon Hunter
2026-11-16 15:29 ` sashiko-bot
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:36 ` sashiko-bot
2026-11-16 15:24 ` [PATCH v2 09/12] usb: gadget: tegra-xudc: Add support for Tegra238 Jon Hunter
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:32 ` sashiko-bot
2026-11-16 15:24 ` [PATCH v2 11/12] usb: gadget: tegra-xudc: Add default settings " Jon Hunter
2026-11-16 15:34 ` sashiko-bot
2026-11-16 15:24 ` [PATCH v2 12/12] usb: gadget: tegra-xudc: Add support for Tegra264 Jon Hunter
2026-11-16 15:35 ` sashiko-bot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261116-tegra-usb-v2-6-42efc03a9700@nvidia.com \
--to=jonathanh@nvidia.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=jckuo@nvidia.com \
--cc=krzk+dt@kernel.org \
--cc=linux-tegra@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=mathias.nyman@intel.com \
--cc=nkristam@nvidia.com \
--cc=robh@kernel.org \
--cc=thierry.reding@gmail.com \
--cc=thierry.reding@kernel.org \
--cc=treding@nvidia.com \
--cc=waynec@nvidia.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox