From 881d01e586f1433884e2d75a1c9ffb66df6f3eb3 Mon Sep 17 00:00:00 2001 From: Marcel Ziswiler Date: Sun, 13 Dec 2020 22:34:23 +0100 Subject: net: dm: dwc_eth_qos: support the phy-supply binding Configure the PHY regulator if defined by the "phy-supply" device tree phandle. Signed-off-by: Marcel Ziswiler --- drivers/net/dwc_eth_qos.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/drivers/net/dwc_eth_qos.c b/drivers/net/dwc_eth_qos.c index d8c21be5eb..d1d1f2aa95 100644 --- a/drivers/net/dwc_eth_qos.c +++ b/drivers/net/dwc_eth_qos.c @@ -38,6 +38,7 @@ #include #include #include +#include #include #include #include @@ -325,6 +326,7 @@ struct eqos_priv { struct clk clk_slave_bus; struct mii_dev *mii; struct phy_device *phy; + struct udevice *phy_supply; void *descs; struct eqos_desc *tx_descs; struct eqos_desc *rx_descs; @@ -1693,6 +1695,16 @@ static int eqos_probe_resources_core(struct udevice *dev) } debug("%s: rx_pkt=%p\n", __func__, eqos->rx_pkt); +#ifdef CONFIG_DM_REGULATOR + if (eqos->phy_supply) { + ret = regulator_set_enable(eqos->phy_supply, true); + if (ret) { + printf("%s: Error enabling phy supply\n", dev->name); + goto err_free_rx_dma_buf; + } + } +#endif + debug("%s: OK\n", __func__); return 0; @@ -1714,6 +1726,11 @@ static int eqos_remove_resources_core(struct udevice *dev) debug("%s(dev=%p):\n", __func__, dev); +#ifdef CONFIG_DM_REGULATOR + if (eqos->phy_supply) + regulator_set_enable(eqos->phy_supply, false); +#endif + free(eqos->rx_pkt); free(eqos->rx_dma_buf); free(eqos->tx_dma_buf); @@ -2057,6 +2074,10 @@ static int eqos_probe(struct udevice *dev) eqos->dma_regs = (void *)(eqos->regs + EQOS_DMA_REGS_BASE); eqos->tegra186_regs = (void *)(eqos->regs + EQOS_TEGRA186_REGS_BASE); +#ifdef CONFIG_DM_REGULATOR + device_get_supply_regulator(dev, "phy-supply", &eqos->phy_supply); +#endif + ret = eqos_probe_resources_core(dev); if (ret < 0) { pr_err("eqos_probe_resources_core() failed: %d", ret); -- cgit v1.2.3