[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20260127-diogo-tegra_phy-v2-5-787b9eed3ed5@tecnico.ulisboa.pt>
Date: Tue, 27 Jan 2026 15:11:51 +0000
From: Diogo Ivo <diogo.ivo@...nico.ulisboa.pt>
To: Mathias Nyman <mathias.nyman@...el.com>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Thierry Reding <thierry.reding@...il.com>,
Jonathan Hunter <jonathanh@...dia.com>, JC Kuo <jckuo@...dia.com>,
Vinod Koul <vkoul@...nel.org>, Kishon Vijay Abraham I <kishon@...nel.org>,
Rob Herring <robh@...nel.org>, Krzysztof Kozlowski <krzk+dt@...nel.org>,
Conor Dooley <conor+dt@...nel.org>,
Neil Armstrong <neil.armstrong@...aro.org>
Cc: linux-usb@...r.kernel.org, linux-tegra@...r.kernel.org,
linux-kernel@...r.kernel.org, linux-phy@...ts.infradead.org,
devicetree@...r.kernel.org, Diogo Ivo <diogo.ivo@...nico.ulisboa.pt>
Subject: [PATCH v2 5/6] phy: tegra: xusb: Move .set_mode() to a shared
location
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@...nico.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
Powered by blists - more mailing lists