[U-Boot] [PATCH 3/4] net: dm: fec: Support the phy-supply binding

Martin Fuzzey martin.fuzzey at flowbird.group
Thu Oct 4 17:59:20 UTC 2018


Configure the phy regulator if defined by the "phy-supply" DT phandle.

Signed-off-by: Martin Fuzzey <martin.fuzzey at flowbird.group>
---
 drivers/net/fec_mxc.c | 20 ++++++++++++++++++++
 drivers/net/fec_mxc.h |  3 +++
 2 files changed, 23 insertions(+)

diff --git a/drivers/net/fec_mxc.c b/drivers/net/fec_mxc.c
index 163ae4c..4a5555e 100644
--- a/drivers/net/fec_mxc.c
+++ b/drivers/net/fec_mxc.c
@@ -15,6 +15,7 @@
 #include <miiphy.h>
 #include <net.h>
 #include <netdev.h>
+#include <power/regulator.h>
 
 #include <asm/io.h>
 #include <linux/errno.h>
@@ -1272,6 +1273,16 @@ static int fecmxc_probe(struct udevice *dev)
 	if (ret)
 		return ret;
 
+#ifdef CONFIG_DM_REGULATOR
+	if (priv->phy_supply) {
+		ret = regulator_autoset(priv->phy_supply);
+		if (ret) {
+			printf("%s: Error enabling phy supply\n", dev->name);
+			return ret;
+		}
+	}
+#endif
+
 #ifdef CONFIG_DM_GPIO
 	fec_gpio_reset(priv);
 #endif
@@ -1327,6 +1338,11 @@ static int fecmxc_remove(struct udevice *dev)
 	mdio_unregister(priv->bus);
 	mdio_free(priv->bus);
 
+#ifdef CONFIG_DM_REGULATOR
+	if (priv->phy_supply)
+		regulator_set_enable(priv->phy_supply, false);
+#endif
+
 	return 0;
 }
 
@@ -1364,6 +1380,10 @@ static int fecmxc_ofdata_to_platdata(struct udevice *dev)
 	}
 #endif
 
+#ifdef CONFIG_DM_REGULATOR
+	device_get_supply_regulator(dev, "phy-supply", &priv->phy_supply);
+#endif
+
 	return 0;
 }
 
diff --git a/drivers/net/fec_mxc.h b/drivers/net/fec_mxc.h
index fd89443..848cd7c 100644
--- a/drivers/net/fec_mxc.h
+++ b/drivers/net/fec_mxc.h
@@ -250,6 +250,9 @@ struct fec_priv {
 	int phy_id;
 	int (*mii_postcall)(int);
 #endif
+#ifdef CONFIG_DM_REGULATOR
+	struct udevice *phy_supply;
+#endif
 #ifdef CONFIG_DM_GPIO
 	struct gpio_desc phy_reset_gpio;
 	uint32_t reset_delay;
-- 
1.9.1



More information about the U-Boot mailing list