summaryrefslogtreecommitdiffstats
path: root/drivers/net
diff options
context:
space:
mode:
authorOleksij Rempel <o.rempel@pengutronix.de>2019-07-16 12:35:56 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2019-07-17 11:23:02 +0200
commit582b8089dff0c4c3800505eb0a1854d1e89a84f2 (patch)
tree7a332904441656d856b90b72a56d3690ad887d4e /drivers/net
parent78c1f6de3c65504645170eaf244d705c9ada88c3 (diff)
downloadbarebox-582b8089dff0c4c3800505eb0a1854d1e89a84f2.tar.gz
net: fec_imx: add regulator support
at least imx28-evk need it to work with devicetree Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'drivers/net')
-rw-r--r--drivers/net/fec_imx.c19
-rw-r--r--drivers/net/fec_imx.h1
2 files changed, 20 insertions, 0 deletions
diff --git a/drivers/net/fec_imx.c b/drivers/net/fec_imx.c
index 38a29fc..31c9102 100644
--- a/drivers/net/fec_imx.c
+++ b/drivers/net/fec_imx.c
@@ -19,6 +19,7 @@
#include <linux/err.h>
#include <of_net.h>
#include <of_gpio.h>
+#include <regulator.h>
#include <gpio.h>
#include <linux/iopoll.h>
@@ -776,6 +777,21 @@ static int fec_probe(struct device_d *dev)
}
fec->regs = IOMEM(iores->start);
+ fec->reg_phy = regulator_get(dev, "phy");
+ if (IS_ERR(fec->reg_phy)) {
+ if (PTR_ERR(fec->reg_phy) == -EPROBE_DEFER) {
+ ret = -EPROBE_DEFER;
+ goto disable_clk;
+ }
+ fec->reg_phy = NULL;
+ }
+
+ ret = regulator_enable(fec->reg_phy);
+ if (ret) {
+ dev_err(dev, "Failed to enable phy regulator: %d\n", ret);
+ goto disable_clk;
+ }
+
phy_reset = of_get_named_gpio(dev->device_node, "phy-reset-gpios", 0);
if (gpio_is_valid(phy_reset)) {
of_property_read_u32(dev->device_node, "phy-reset-duration", &msec);
@@ -868,6 +884,9 @@ free_gpio:
if (gpio_is_valid(phy_reset))
gpio_free(phy_reset);
release_res:
+ if (fec->reg_phy)
+ regulator_disable(fec->reg_phy);
+
release_region(iores);
disable_clk:
fec_clk_disable(fec);
diff --git a/drivers/net/fec_imx.h b/drivers/net/fec_imx.h
index 1a1fbc9..d1ac92f 100644
--- a/drivers/net/fec_imx.h
+++ b/drivers/net/fec_imx.h
@@ -152,6 +152,7 @@ struct fec_priv {
struct clk *clk[FEC_CLK_NUM];
struct clk *opt_clk[FEC_OPT_CLK_NUM];
enum fec_type type;
+ struct regulator *reg_phy;
};
static inline int fec_is_imx27(struct fec_priv *priv)