summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Fuzzey <martin.fuzzey@flowbird.group>2018-10-04 19:59:20 +0200
committerMarcel Ziswiler <marcel.ziswiler@toradex.com>2019-11-27 17:40:45 +0100
commitc8452086984a3a5cbde37fcf449eb9128cbb6186 (patch)
treecc53dfc8e0dfa7bd023cbec71ef7bbb36d5fa45b
parent5e2eebf2a8fc766fdda2325a90d3cbad9c345d49 (diff)
net: dm: fec: Support the phy-supply binding
Configure the phy regulator if defined by the "phy-supply" DT phandle. Signed-off-by: Martin Fuzzey <martin.fuzzey@flowbird.group> Acked-by: Joe Hershberger <joe.hershberger@ni.com> (cherry picked from commit ad8c43cbcafbbb21efc9e26bda7a6b1e37428adc)
-rw-r--r--drivers/net/fec_mxc.c20
-rw-r--r--drivers/net/fec_mxc.h3
2 files changed, 23 insertions, 0 deletions
diff --git a/drivers/net/fec_mxc.c b/drivers/net/fec_mxc.c
index 5e4ad1c6ad..10df6dda59 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>
@@ -1294,6 +1295,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
@@ -1349,6 +1360,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;
}
@@ -1372,6 +1388,10 @@ static int fecmxc_ofdata_to_platdata(struct udevice *dev)
return -EINVAL;
}
+#ifdef CONFIG_DM_REGULATOR
+ device_get_supply_regulator(dev, "phy-supply", &priv->phy_supply);
+#endif
+
#ifdef CONFIG_DM_GPIO
ret = gpio_request_by_name(dev, "phy-reset-gpios", 0,
&priv->phy_reset_gpio, GPIOD_IS_OUT);
diff --git a/drivers/net/fec_mxc.h b/drivers/net/fec_mxc.h
index 3e7b833968..d7d2f0d3aa 100644
--- a/drivers/net/fec_mxc.h
+++ b/drivers/net/fec_mxc.h
@@ -251,6 +251,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;