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-next>] [day] [month] [year] [list]
Message-ID:
 <KL1PR01MB5448631F2D6F71021602117FE6769@KL1PR01MB5448.apcprd01.prod.exchangelabs.com>
Date: Tue,  9 May 2023 18:44:02 +0800
From: Yan Wang <rk.code@...look.com>
To: andrew@...n.ch,
	hkallweit1@...il.com,
	davem@...emloft.net,
	edumazet@...gle.com,
	kuba@...nel.org,
	pabeni@...hat.com,
	netdev@...r.kernel.org,
	linux-kernel@...r.kernel.org,
	linux@...linux.org.uk
Cc: Yan Wang <rk.code@...look.com>
Subject: [PATCH v1] net: mdiobus: Add a function to deassert reset

Every PHY chip has a reset pin. the state isn't
sure of the PHY before scanning.

It is resetting, Scanning phy ID will fail, so
deassert reset for the chip ,normal operation.

Release the reset pin, because it needs to be
registered to the created phy device.

Signed-off-by: Yan Wang <rk.code@...look.com>

diff --git a/drivers/net/mdio/fwnode_mdio.c b/drivers/net/mdio/fwnode_mdio.c
index 1183ef5e203e..8fdf1293f447 100644
--- a/drivers/net/mdio/fwnode_mdio.c
+++ b/drivers/net/mdio/fwnode_mdio.c
@@ -11,6 +11,7 @@
 #include <linux/of.h>
 #include <linux/phy.h>
 #include <linux/pse-pd/pse.h>
+#include <linux/of_gpio.h>
 
 MODULE_AUTHOR("Calvin Johnson <calvin.johnson@....nxp.com>");
 MODULE_LICENSE("GPL");
@@ -57,6 +58,32 @@ fwnode_find_mii_timestamper(struct fwnode_handle *fwnode)
 	return register_mii_timestamper(arg.np, arg.args[0]);
 }
 
+static void fwnode_mdiobus_deassert_reset_phy(struct fwnode_handle *fwnode)
+{
+	struct device_node *np;
+	int reset;
+	int rc;
+
+	np = to_of_node(fwnode);
+	if (!np)
+		return;
+	reset = of_get_named_gpio(np, "reset-gpios", 0);
+	if (gpio_is_valid(reset)) {
+		rc = gpio_request(reset, NULL);
+		if (rc < 0) {
+			pr_err("The currunt state of the reset pin is %s ",
+				rc == -EBUSY ? "busy" : "error");
+		} else {
+			gpio_direction_output(reset, 0);
+			usleep_range(1000, 2000);
+			gpio_direction_output(reset, 1);
+			/*Release the reset pin,it needs to be registeredwith the PHY.*/
+			gpio_free(reset);
+		}
+	}
+
+}
+
 int fwnode_mdiobus_phy_device_register(struct mii_bus *mdio,
 				       struct phy_device *phy,
 				       struct fwnode_handle *child, u32 addr)
@@ -129,6 +156,8 @@ int fwnode_mdiobus_register_phy(struct mii_bus *bus,
 		goto clean_pse;
 	}
 
+	fwnode_mdiobus_deassert_reset_phy(child);
+
 	is_c45 = fwnode_device_is_compatible(child, "ethernet-phy-ieee802.3-c45");
 	if (is_c45 || fwnode_get_phy_id(child, &phy_id))
 		phy = get_phy_device(bus, addr, is_c45);
-- 
2.17.1


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ