lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20260127-diogo-tegra_phy-v2-6-787b9eed3ed5@tecnico.ulisboa.pt>
Date: Tue, 27 Jan 2026 15:11:52 +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 6/6] phy: tegra: xusb: Move T186 .set_mode() to common
 implementation

Move the Tegra186 PHY .set_mode() callback to a common implementation.
In order to do this first revert cefc1caee9dd.

Signed-off-by: Diogo Ivo <diogo.ivo@...nico.ulisboa.pt>
---
v1->v2:
- New patch
---
 drivers/phy/tegra/xusb-tegra186.c | 73 ++++++---------------------------------
 1 file changed, 10 insertions(+), 63 deletions(-)

diff --git a/drivers/phy/tegra/xusb-tegra186.c b/drivers/phy/tegra/xusb-tegra186.c
index bec9616c4a2e..bf678829245d 100644
--- a/drivers/phy/tegra/xusb-tegra186.c
+++ b/drivers/phy/tegra/xusb-tegra186.c
@@ -786,15 +786,13 @@ static int tegra186_xusb_padctl_vbus_override(struct tegra_xusb_padctl *padctl,
 }
 
 static int tegra186_xusb_padctl_id_override(struct tegra_xusb_padctl *padctl,
-					    struct tegra_xusb_usb2_port *port, bool status)
+					    bool status)
 {
-	u32 value, id_override;
-	int err = 0;
+	u32 value;
 
 	dev_dbg(padctl->dev, "%s id override\n", status ? "set" : "clear");
 
 	value = padctl_readl(padctl, USB2_VBUS_ID);
-	id_override = value & ID_OVERRIDE(~0);
 
 	if (status) {
 		if (value & VBUS_OVERRIDE) {
@@ -805,68 +803,16 @@ static int tegra186_xusb_padctl_id_override(struct tegra_xusb_padctl *padctl,
 			value = padctl_readl(padctl, USB2_VBUS_ID);
 		}
 
-		if (id_override != ID_OVERRIDE_GROUNDED) {
-			value &= ~ID_OVERRIDE(~0);
-			value |= ID_OVERRIDE_GROUNDED;
-			padctl_writel(padctl, value, USB2_VBUS_ID);
-
-			err = regulator_enable(port->supply);
-			if (err) {
-				dev_err(padctl->dev, "Failed to enable regulator: %d\n", err);
-				return err;
-			}
-		}
+		value &= ~ID_OVERRIDE(~0);
+		value |= ID_OVERRIDE_GROUNDED;
 	} else {
-		if (id_override == ID_OVERRIDE_GROUNDED) {
-			/*
-			 * The regulator is disabled only when the role transitions
-			 * from USB_ROLE_HOST to USB_ROLE_NONE.
-			 */
-			err = regulator_disable(port->supply);
-			if (err) {
-				dev_err(padctl->dev, "Failed to disable regulator: %d\n", err);
-				return err;
-			}
-
-			value &= ~ID_OVERRIDE(~0);
-			value |= ID_OVERRIDE_FLOATING;
-			padctl_writel(padctl, value, USB2_VBUS_ID);
-		}
+		value &= ~ID_OVERRIDE(~0);
+		value |= ID_OVERRIDE_FLOATING;
 	}
 
-	return 0;
-}
-
-static int tegra186_utmi_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);
+	padctl_writel(padctl, value, USB2_VBUS_ID);
 
-	dev_dbg(&port->base.dev, "%s: mode %d", __func__, mode);
-
-	if (mode == PHY_MODE_USB_OTG) {
-		if (submode == USB_ROLE_HOST) {
-			err = tegra186_xusb_padctl_id_override(padctl, port, true);
-			if (err)
-				goto out;
-		} else if (submode == USB_ROLE_DEVICE) {
-			tegra186_xusb_padctl_vbus_override(padctl, true);
-		} else if (submode == USB_ROLE_NONE) {
-			err = tegra186_xusb_padctl_id_override(padctl, port, false);
-			if (err)
-				goto out;
-			tegra186_xusb_padctl_vbus_override(padctl, false);
-		}
-	}
-out:
-	mutex_unlock(&padctl->lock);
-	return err;
+	return 0;
 }
 
 static int tegra186_utmi_phy_power_on(struct phy *phy)
@@ -1017,7 +963,7 @@ static const struct phy_ops utmi_phy_ops = {
 	.exit = tegra186_utmi_phy_exit,
 	.power_on = tegra186_utmi_phy_power_on,
 	.power_off = tegra186_utmi_phy_power_off,
-	.set_mode = tegra186_utmi_phy_set_mode,
+	.set_mode = tegra_xusb_usb2_phy_set_mode,
 	.owner = THIS_MODULE,
 };
 
@@ -1578,6 +1524,7 @@ static const struct tegra_xusb_padctl_ops tegra186_xusb_padctl_ops = {
 	.suspend_noirq = tegra186_xusb_padctl_suspend_noirq,
 	.resume_noirq = tegra186_xusb_padctl_resume_noirq,
 	.vbus_override = tegra186_xusb_padctl_vbus_override,
+	.id_override = tegra186_xusb_padctl_id_override,
 	.utmi_pad_power_on = tegra186_utmi_pad_power_on,
 	.utmi_pad_power_down = tegra186_utmi_pad_power_down,
 };

-- 
2.52.0


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ