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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20251001212709.579080-5-tommaso.merciai.xr@bp.renesas.com>
Date: Wed,  1 Oct 2025 23:26:48 +0200
From: Tommaso Merciai <tommaso.merciai.xr@...renesas.com>
To: tomm.merciai@...il.com
Cc: linux-renesas-soc@...r.kernel.org,
	biju.das.jz@...renesas.com,
	Tommaso Merciai <tommaso.merciai.xr@...renesas.com>,
	Yoshihiro Shimoda <yoshihiro.shimoda.uh@...esas.com>,
	Vinod Koul <vkoul@...nel.org>,
	Kishon Vijay Abraham I <kishon@...nel.org>,
	Geert Uytterhoeven <geert+renesas@...der.be>,
	Magnus Damm <magnus.damm@...il.com>,
	Fabrizio Castro <fabrizio.castro.jz@...esas.com>,
	Lad Prabhakar <prabhakar.mahadev-lad.rj@...renesas.com>,
	Philipp Zabel <p.zabel@...gutronix.de>,
	linux-phy@...ts.infradead.org,
	linux-kernel@...r.kernel.org
Subject: [PATCH 04/18] reset: rzv2h-usb2phy: Set VBENCTL register for OTG mode

Add logic to set the VBENCTL register when the USB controller operates in
OTG mode. This is required to ensure proper USB transceiver behavior when
the device is configured as OTG.

Signed-off-by: Tommaso Merciai <tommaso.merciai.xr@...renesas.com>
---
 drivers/reset/reset-rzv2h-usb2phy.c | 57 +++++++++++++++++++++++++++++
 1 file changed, 57 insertions(+)

diff --git a/drivers/reset/reset-rzv2h-usb2phy.c b/drivers/reset/reset-rzv2h-usb2phy.c
index 7cd559bc52aa..059915cbace5 100644
--- a/drivers/reset/reset-rzv2h-usb2phy.c
+++ b/drivers/reset/reset-rzv2h-usb2phy.c
@@ -10,10 +10,14 @@
 #include <linux/io.h>
 #include <linux/module.h>
 #include <linux/of.h>
+#include <linux/of_platform.h>
 #include <linux/platform_device.h>
 #include <linux/pm_runtime.h>
 #include <linux/reset.h>
 #include <linux/reset-controller.h>
+#include <linux/usb/of.h>
+
+#define VBENCTL		0xf0c
 
 struct rzv2h_usb2phy_regval {
 	u16 reg;
@@ -111,6 +115,57 @@ static int rzv2h_usb2phy_reset_of_xlate(struct reset_controller_dev *rcdev,
 	return 0;
 }
 
+static enum usb_dr_mode
+rzv2h_usb2phy_reset_of_usb_get_dr_mode_by_reset(struct device_node *np)
+{
+	struct device_node *controller;
+	struct of_phandle_args args;
+	struct platform_device *pd;
+	const char *dr_mode_str;
+	enum usb_dr_mode dr_mode;
+	int index;
+
+	for_each_node_with_property(controller, "dr_mode") {
+		index = 0;
+		while (!of_parse_phandle_with_args(controller, "resets",
+						   "#reset-cells", index++,
+						    &args)) {
+			if (args.np == np) {
+				of_node_put(args.np);
+
+				if (!of_property_read_string(controller,
+							     "dr_mode",
+							     &dr_mode_str)) {
+					pd = of_find_device_by_node(controller);
+					dr_mode = usb_get_dr_mode(&pd->dev);
+					of_node_put(controller);
+					put_device(&pd->dev);
+					return dr_mode;
+				}
+
+				of_node_put(controller);
+				break;
+			}
+			of_node_put(args.np);
+		}
+		of_node_put(controller);
+	}
+
+	return USB_DR_MODE_UNKNOWN;
+}
+
+static void rzv2h_usb2phy_reset_setup_vbenctl(struct rzv2h_usb2phy_reset_priv *priv)
+{
+	struct device *dev = priv->rcdev.dev;
+	enum usb_dr_mode dr_mode;
+
+	dr_mode = rzv2h_usb2phy_reset_of_usb_get_dr_mode_by_reset(dev->of_node);
+	dev_dbg(priv->rcdev.dev, "dr_mode: %d\n", dr_mode);
+
+	if (dr_mode == USB_DR_MODE_OTG)
+		writel(BIT(0), priv->base + VBENCTL);
+}
+
 static void rzv2h_usb2phy_reset_pm_runtime_put(void *data)
 {
 	pm_runtime_put(data);
@@ -172,6 +227,8 @@ static int rzv2h_usb2phy_reset_probe(struct platform_device *pdev)
 	if (error)
 		return dev_err_probe(dev, error, "could not register reset controller\n");
 
+	rzv2h_usb2phy_reset_setup_vbenctl(priv);
+
 	return 0;
 }
 
-- 
2.43.0


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ