From: Diogo Ivo <diogo.ivo@tecnico.ulisboa.pt>
To: Mathias Nyman <mathias.nyman@intel.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Thierry Reding <thierry.reding@gmail.com>,
Jonathan Hunter <jonathanh@nvidia.com>,
JC Kuo <jckuo@nvidia.com>, Vinod Koul <vkoul@kernel.org>,
Kishon Vijay Abraham I <kishon@kernel.org>,
Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
Neil Armstrong <neil.armstrong@linaro.org>
Cc: linux-usb@vger.kernel.org, linux-tegra@vger.kernel.org,
linux-kernel@vger.kernel.org, linux-phy@lists.infradead.org,
devicetree@vger.kernel.org,
Diogo Ivo <diogo.ivo@tecnico.ulisboa.pt>
Subject: [PATCH v2 5/6] phy: tegra: xusb: Move .set_mode() to a shared location
Date: Tue, 27 Jan 2026 15:11:51 +0000 [thread overview]
Message-ID: <20260127-diogo-tegra_phy-v2-5-787b9eed3ed5@tecnico.ulisboa.pt> (raw)
In-Reply-To: <20260127-diogo-tegra_phy-v2-0-787b9eed3ed5@tecnico.ulisboa.pt>
As both Tegra210 and Tegra186 can have a common XUSB .set_mode()
implementation move it to a location where it can be used by both
platforms. Move Tegra210 to this common implementation.
While at it fix a typo in a comment.
Signed-off-by: Diogo Ivo <diogo.ivo@tecnico.ulisboa.pt>
---
v1->v2:
- New patch
---
drivers/phy/tegra/xusb-tegra210.c | 43 +--------------------------------------
drivers/phy/tegra/xusb.c | 40 ++++++++++++++++++++++++++++++++++++
drivers/phy/tegra/xusb.h | 2 ++
3 files changed, 43 insertions(+), 42 deletions(-)
diff --git a/drivers/phy/tegra/xusb-tegra210.c b/drivers/phy/tegra/xusb-tegra210.c
index be03a17afd7e..14e24296641b 100644
--- a/drivers/phy/tegra/xusb-tegra210.c
+++ b/drivers/phy/tegra/xusb-tegra210.c
@@ -1910,47 +1910,6 @@ static int tegra210_xusb_padctl_id_override(struct tegra_xusb_padctl *padctl,
return 0;
}
-static int tegra210_usb2_phy_set_mode(struct phy *phy, enum phy_mode mode,
- int submode)
-{
- struct tegra_xusb_lane *lane = phy_get_drvdata(phy);
- struct tegra_xusb_padctl *padctl = lane->pad->padctl;
- struct tegra_xusb_usb2_port *port = tegra_xusb_find_usb2_port(padctl,
- lane->index);
- int err = 0;
-
- mutex_lock(&padctl->lock);
-
- dev_dbg(&port->base.dev, "%s: mode %d", __func__, mode);
-
- if (mode == PHY_MODE_USB_OTG) {
- if (submode == USB_ROLE_HOST) {
- tegra210_xusb_padctl_id_override(padctl, true);
-
- err = regulator_enable(port->supply);
- } else if (submode == USB_ROLE_DEVICE) {
- tegra210_xusb_padctl_vbus_override(padctl, true);
- } else if (submode == USB_ROLE_NONE) {
- /*
- * When port is peripheral only or role transitions to
- * USB_ROLE_NONE from USB_ROLE_DEVICE, regulator is not
- * be enabled.
- */
- if (port->role == USB_ROLE_HOST)
- regulator_disable(port->supply);
-
- tegra210_xusb_padctl_id_override(padctl, false);
- tegra210_xusb_padctl_vbus_override(padctl, false);
- }
-
- port->role = submode;
- }
-
- mutex_unlock(&padctl->lock);
-
- return err;
-}
-
static int tegra210_usb2_phy_power_on(struct phy *phy)
{
struct tegra_xusb_lane *lane = phy_get_drvdata(phy);
@@ -2174,7 +2133,7 @@ static const struct phy_ops tegra210_usb2_phy_ops = {
.exit = tegra210_usb2_phy_exit,
.power_on = tegra210_usb2_phy_power_on,
.power_off = tegra210_usb2_phy_power_off,
- .set_mode = tegra210_usb2_phy_set_mode,
+ .set_mode = tegra_xusb_usb2_phy_set_mode,
.owner = THIS_MODULE,
};
diff --git a/drivers/phy/tegra/xusb.c b/drivers/phy/tegra/xusb.c
index 0443465bcf50..2327275740f8 100644
--- a/drivers/phy/tegra/xusb.c
+++ b/drivers/phy/tegra/xusb.c
@@ -770,6 +770,46 @@ bool tegra_xusb_usb2_port_wait_role_none(struct tegra_xusb_padctl *padctl, int i
}
EXPORT_SYMBOL_GPL(tegra_xusb_usb2_port_wait_role_none);
+int tegra_xusb_usb2_phy_set_mode(struct phy *phy, enum phy_mode mode, int submode)
+{
+ struct tegra_xusb_lane *lane = phy_get_drvdata(phy);
+ struct tegra_xusb_padctl *padctl = lane->pad->padctl;
+ struct tegra_xusb_usb2_port *port = tegra_xusb_find_usb2_port(padctl,
+ lane->index);
+ int err = 0;
+
+ mutex_lock(&padctl->lock);
+
+ dev_dbg(&port->base.dev, "%s: mode %d", __func__, mode);
+
+ if (mode == PHY_MODE_USB_OTG) {
+ if (submode == USB_ROLE_HOST) {
+ tegra_xusb_padctl_set_id_override(padctl, true);
+
+ err = regulator_enable(port->supply);
+ } else if (submode == USB_ROLE_DEVICE) {
+ tegra_xusb_padctl_set_vbus_override(padctl, true);
+ } else if (submode == USB_ROLE_NONE) {
+ /*
+ * When port is peripheral only or role transitions to
+ * USB_ROLE_NONE from USB_ROLE_DEVICE, regulator is not
+ * enabled.
+ */
+ if (port->role == USB_ROLE_HOST)
+ regulator_disable(port->supply);
+
+ tegra_xusb_padctl_set_id_override(padctl, false);
+ tegra_xusb_padctl_set_vbus_override(padctl, false);
+ }
+
+ port->role = submode;
+ }
+
+ mutex_unlock(&padctl->lock);
+
+ return err;
+}
+
static int tegra_xusb_usb2_port_parse_dt(struct tegra_xusb_usb2_port *usb2)
{
struct tegra_xusb_port *port = &usb2->base;
diff --git a/drivers/phy/tegra/xusb.h b/drivers/phy/tegra/xusb.h
index 08053a730d54..36cc87ae757e 100644
--- a/drivers/phy/tegra/xusb.h
+++ b/drivers/phy/tegra/xusb.h
@@ -501,6 +501,8 @@ struct tegra_xusb_lane *tegra_xusb_find_lane(struct tegra_xusb_padctl *padctl,
const char *name,
unsigned int index);
+int tegra_xusb_usb2_phy_set_mode(struct phy *phy, enum phy_mode mode, int submode);
+
#if defined(CONFIG_ARCH_TEGRA_124_SOC) || defined(CONFIG_ARCH_TEGRA_132_SOC)
extern const struct tegra_xusb_padctl_soc tegra124_xusb_padctl_soc;
#endif
--
2.52.0
next prev parent reply other threads:[~2026-01-27 15:20 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-27 15:11 [PATCH v2 0/6] Fixes to Tegra USB role switching and phy handling Diogo Ivo
2026-01-27 15:11 ` [PATCH v2 1/6] phy: tegra: xusb: Fix USB2 port regulator disable logic Diogo Ivo
2026-01-27 15:11 ` [PATCH v2 2/6] usb: xhci: tegra: Remove redundant mutex when setting phy mode Diogo Ivo
2026-03-24 11:48 ` Thierry Reding
2026-03-24 12:28 ` Diogo Ivo
2026-03-26 14:17 ` Diogo Ivo
2026-03-27 14:06 ` Thierry Reding
2026-01-27 15:11 ` [PATCH v2 3/6] phy: tegra: xusb: Fix ordering issue when switching roles on USB2 ports Diogo Ivo
2026-01-27 15:11 ` [PATCH v2 4/6] phy: tegra: xusb: Add ID override support to padctl Diogo Ivo
2026-01-27 15:11 ` Diogo Ivo [this message]
2026-01-27 15:11 ` [PATCH v2 6/6] phy: tegra: xusb: Move T186 .set_mode() to common implementation Diogo Ivo
2026-03-24 10:16 ` Jon Hunter
2026-03-24 11:31 ` Diogo Ivo
2026-03-24 13:33 ` Jon Hunter
2026-03-24 14:36 ` Diogo Ivo
2026-03-27 17:46 ` Jon Hunter
2026-03-02 9:10 ` [PATCH v2 0/6] Fixes to Tegra USB role switching and phy handling Diogo Ivo
2026-03-02 9:59 ` Vinod Koul
2026-03-23 16:15 ` Diogo Ivo
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=20260127-diogo-tegra_phy-v2-5-787b9eed3ed5@tecnico.ulisboa.pt \
--to=diogo.ivo@tecnico.ulisboa.pt \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=jckuo@nvidia.com \
--cc=jonathanh@nvidia.com \
--cc=kishon@kernel.org \
--cc=krzk+dt@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-phy@lists.infradead.org \
--cc=linux-tegra@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=mathias.nyman@intel.com \
--cc=neil.armstrong@linaro.org \
--cc=robh@kernel.org \
--cc=thierry.reding@gmail.com \
--cc=vkoul@kernel.org \
/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