linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] net: stmmac: Support gpio high-level reset for devices requiring it
@ 2025-07-08 16:50 Lizhe
  2025-07-08 17:34 ` Andrew Lunn
  2025-07-08 17:40 ` Russell King (Oracle)
  0 siblings, 2 replies; 10+ messages in thread
From: Lizhe @ 2025-07-08 16:50 UTC (permalink / raw)
  To: andrew+netdev, davem, edumazet, kuba, pabeni, mcoquelin.stm32,
	alexandre.torgue, rmk+kernel, vladimir.oltean, maxime.chevallier,
	sensor1010
  Cc: netdev, linux-stm32, linux-arm-kernel, linux-kernel

some devices only reset when the GPIO is at a high level, but the
current function lacks support for such devices. add high-level
reset functionality to the function to support devices that require
high-level triggering for reset

Signed-off-by: Lizhe <sensor1010@163.com>
---
 drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c
index 836f2848dfeb..cb989e6d7eac 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c
@@ -458,6 +458,7 @@ int stmmac_mdio_reset(struct mii_bus *bus)
 
 #ifdef CONFIG_OF
 	if (priv->device->of_node) {
+		int active_low = 0;
 		struct gpio_desc *reset_gpio;
 		u32 delays[3] = { 0, 0, 0 };
 
@@ -467,6 +468,9 @@ int stmmac_mdio_reset(struct mii_bus *bus)
 		if (IS_ERR(reset_gpio))
 			return PTR_ERR(reset_gpio);
 
+		if (reset_gpio)
+			active_low = gpiod_is_active_low(reset_gpio);
+
 		device_property_read_u32_array(priv->device,
 					       "snps,reset-delays-us",
 					       delays, ARRAY_SIZE(delays));
@@ -474,11 +478,11 @@ int stmmac_mdio_reset(struct mii_bus *bus)
 		if (delays[0])
 			msleep(DIV_ROUND_UP(delays[0], 1000));
 
-		gpiod_set_value_cansleep(reset_gpio, 1);
+		gpiod_set_value_cansleep(reset_gpio, active_low ? 1 : 0);
 		if (delays[1])
 			msleep(DIV_ROUND_UP(delays[1], 1000));
 
-		gpiod_set_value_cansleep(reset_gpio, 0);
+		gpiod_set_value_cansleep(reset_gpio, active_low ? 0 : 1);
 		if (delays[2])
 			msleep(DIV_ROUND_UP(delays[2], 1000));
 	}
-- 
2.17.1



^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2025-07-09 21:58 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-08 16:50 [PATCH] net: stmmac: Support gpio high-level reset for devices requiring it Lizhe
2025-07-08 17:34 ` Andrew Lunn
     [not found]   ` <5c7adfef.1876.197ece74c25.Coremail.sensor1010@163.com>
2025-07-09  4:26     ` Russell King (Oracle)
     [not found]       ` <5bb49dc0.6933.197ee28444e.Coremail.sensor1010@163.com>
2025-07-09 11:11         ` Russell King (Oracle)
     [not found]           ` <4cfb4aab.9588.197eefef55f.Coremail.sensor1010@163.com>
2025-07-09 14:29             ` Russell King (Oracle)
     [not found]               ` <2352b745.a454.197efeef829.Coremail.sensor1010@163.com>
2025-07-09 17:01                 ` Andrew Lunn
2025-07-09 17:41                 ` Russell King (Oracle)
2025-07-09 12:54     ` Andrew Lunn
2025-07-08 17:40 ` Russell King (Oracle)
     [not found]   ` <2588871d.189d.197ece7c486.Coremail.sensor1010@163.com>
2025-07-09  4:25     ` Russell King (Oracle)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).