[PATCH v2 2/4] net: ravb: Add optional reset deassertion

Paul Barker paul.barker.ct at bp.renesas.com
Wed Mar 19 13:03:58 CET 2025


In order to add support for the Renesas RZ/G2L Ethernet IP in a
subsequent patch, we introduce optional de-assertion and re-assertion of
a reset signal in ravb_probe() and ravb_remove().

Signed-off-by: Paul Barker <paul.barker.ct at bp.renesas.com>
---
 drivers/net/ravb.c | 31 +++++++++++++++++++++++++++++--
 1 file changed, 29 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ravb.c b/drivers/net/ravb.c
index b433e5dfbdd3..ecf6e05f47eb 100644
--- a/drivers/net/ravb.c
+++ b/drivers/net/ravb.c
@@ -23,6 +23,7 @@
 #include <asm/io.h>
 #include <asm/global_data.h>
 #include <asm/gpio.h>
+#include <reset.h>
 
 /* Registers */
 #define RAVB_REG_CCC		0x000
@@ -111,6 +112,7 @@ struct ravb_device_ops {
 	void (*mac_init)(struct udevice *dev);
 	void (*dmac_init)(struct udevice *dev);
 	void (*config)(struct udevice *dev);
+	bool has_reset;
 };
 
 struct ravb_desc {
@@ -136,6 +138,7 @@ struct ravb_priv {
 	struct mii_dev		*bus;
 	void __iomem		*iobase;
 	struct clk_bulk		clks;
+	struct reset_ctl	rst;
 };
 
 static inline void ravb_flush_dcache(u32 addr, u32 len)
@@ -613,6 +616,8 @@ static int ravb_bb_miiphy_write(struct mii_dev *miidev, int addr,
 
 static int ravb_probe(struct udevice *dev)
 {
+	struct ravb_device_ops *device_ops =
+		(struct ravb_device_ops *)dev_get_driver_data(dev);
 	struct eth_pdata *pdata = dev_get_plat(dev);
 	struct ravb_priv *eth = dev_get_priv(dev);
 	struct mii_dev *mdiodev;
@@ -648,16 +653,32 @@ static int ravb_probe(struct udevice *dev)
 	if (ret)
 		goto err_clk_enable;
 
+	if (device_ops->has_reset) {
+		ret = reset_get_by_index(dev, 0, &eth->rst);
+		if (ret < 0)
+			goto err_clk_enable;
+
+		ret = reset_deassert(&eth->rst);
+		if (ret < 0)
+			goto err_reset_deassert;
+	}
+
 	ret = ravb_reset(dev);
 	if (ret)
-		goto err_clk_enable;
+		goto err_ravb_reset;
 
 	ret = ravb_phy_config(dev);
 	if (ret)
-		goto err_clk_enable;
+		goto err_ravb_reset;
 
 	return 0;
 
+err_ravb_reset:
+	if (device_ops->has_reset)
+		reset_assert(&eth->rst);
+err_reset_deassert:
+	if (device_ops->has_reset)
+		reset_free(&eth->rst);
 err_clk_enable:
 	mdio_unregister(mdiodev);
 err_mdio_register:
@@ -671,8 +692,14 @@ err_clk_get:
 
 static int ravb_remove(struct udevice *dev)
 {
+	struct ravb_device_ops *device_ops =
+		(struct ravb_device_ops *)dev_get_driver_data(dev);
 	struct ravb_priv *eth = dev_get_priv(dev);
 
+	if (device_ops->has_reset) {
+		reset_assert(&eth->rst);
+		reset_free(&eth->rst);
+	}
 	clk_release_bulk(&eth->clks);
 
 	free(eth->phydev);
-- 
2.43.0



More information about the U-Boot mailing list