diff options
author | Max Krummenacher <max.krummenacher@toradex.com> | 2020-11-24 20:19:43 +0100 |
---|---|---|
committer | Max Krummenacher <max.krummenacher@toradex.com> | 2020-11-25 10:44:03 +0100 |
commit | ca8811172bdc2a8afc5ab62b0695a32baf6b5788 (patch) | |
tree | ff129eb4c1dc3457268d828802477ddb342bdca2 | |
parent | b65b3544884ebd962ad0cbecef977061a07ca9d6 (diff) |
net: stmmac: dwmac-imx: add phy-supply
Add an support for an optional regulator which powers an attached phy.
Signed-off-by: Max Krummenacher <max.krummenacher@toradex.com>
-rw-r--r-- | Documentation/devicetree/bindings/net/imx-dwmac.txt | 1 | ||||
-rw-r--r-- | drivers/net/ethernet/stmicro/stmmac/dwmac-imx.c | 25 |
2 files changed, 25 insertions, 1 deletions
diff --git a/Documentation/devicetree/bindings/net/imx-dwmac.txt b/Documentation/devicetree/bindings/net/imx-dwmac.txt index 402885fc0992..4a1cd825d676 100644 --- a/Documentation/devicetree/bindings/net/imx-dwmac.txt +++ b/Documentation/devicetree/bindings/net/imx-dwmac.txt @@ -27,6 +27,7 @@ Required properties: Optional properties: - intf_mode: is optional for imx8dxl platform. +- phy-supply: regulator that powers the Ethernet PHY. - snps,rmii_refclk_ext: to select RMII reference clock from external. Example: diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-imx.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-imx.c index f86d24af34c4..f79dcca08806 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-imx.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-imx.c @@ -19,6 +19,7 @@ #include <linux/pm_runtime.h> #include <linux/pm_wakeirq.h> #include <linux/regmap.h> +#include <linux/regulator/consumer.h> #include <linux/slab.h> #include <linux/stmmac.h> @@ -50,6 +51,7 @@ struct imx_priv_data { struct clk *clk_tx; struct clk *clk_mem; struct regmap *intf_regmap; + struct regulator *regulator; u32 intf_reg_off; bool rmii_refclk_ext; @@ -176,6 +178,12 @@ static int imx_dwmac_init(struct platform_device *pdev, void *priv) goto intf_mode_failed; } + ret = regulator_enable(dwmac->regulator); + if (ret) { + dev_err(dwmac->dev, "fail to enable phy-supply\n"); + goto intf_mode_failed; + } + return 0; intf_mode_failed: @@ -205,6 +213,11 @@ static void imx_dwmac_exit(struct platform_device *pdev, void *priv) if (dwmac->clk_tx) clk_disable_unprepare(dwmac->clk_tx); clk_disable_unprepare(dwmac->clk_mem); + + ret = regulator_disable(dwmac->regulator); + if (ret) + dev_err(dwmac->dev, "fail to disable phy-supply\n"); + pm_runtime_put(&pdev->dev); } @@ -280,6 +293,15 @@ imx_dwmac_parse_dt(struct imx_priv_data *dwmac, struct device *dev) } } + dwmac->regulator = devm_regulator_get_optional(dev, "phy"); + if (IS_ERR(dwmac->regulator)) { + if (PTR_ERR(dwmac->regulator) == -EPROBE_DEFER) { + return -EPROBE_DEFER; + } + dev_err(dev, "no regulator found\n"); + dwmac->regulator = NULL; + } + return err; } @@ -315,7 +337,8 @@ static int imx_dwmac_probe(struct platform_device *pdev) ret = imx_dwmac_parse_dt(dwmac, &pdev->dev); if (ret) { - dev_err(&pdev->dev, "failed to parse OF data\n"); + if (ret != -EPROBE_DEFER) + dev_err(&pdev->dev, "failed to parse OF data\n"); goto err_parse_dt; } |