Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net: fec: enable regulator for fec phy

If bootloader or platform initialization code does not enable the
power supply to fec phy, we need to do it in fec driver before calling
fec_reset_phy to have the phy powered on.

Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Shawn Guo and committed by
David S. Miller
5fa9c0fe 2ca9b2aa

+13
+13
drivers/net/ethernet/freescale/fec.c
··· 49 49 #include <linux/of_gpio.h> 50 50 #include <linux/of_net.h> 51 51 #include <linux/pinctrl/consumer.h> 52 + #include <linux/regulator/consumer.h> 52 53 53 54 #include <asm/cacheflush.h> 54 55 ··· 1547 1546 const struct of_device_id *of_id; 1548 1547 static int dev_id; 1549 1548 struct pinctrl *pinctrl; 1549 + struct regulator *reg_phy; 1550 1550 1551 1551 of_id = of_match_device(fec_dt_ids, &pdev->dev); 1552 1552 if (of_id) ··· 1634 1632 clk_prepare_enable(fep->clk_ahb); 1635 1633 clk_prepare_enable(fep->clk_ipg); 1636 1634 1635 + reg_phy = devm_regulator_get(&pdev->dev, "phy"); 1636 + if (!IS_ERR(reg_phy)) { 1637 + ret = regulator_enable(reg_phy); 1638 + if (ret) { 1639 + dev_err(&pdev->dev, 1640 + "Failed to enable phy regulator: %d\n", ret); 1641 + goto failed_regulator; 1642 + } 1643 + } 1644 + 1637 1645 fec_reset_phy(pdev); 1638 1646 1639 1647 ret = fec_enet_init(ndev); ··· 1667 1655 fec_enet_mii_remove(fep); 1668 1656 failed_mii_init: 1669 1657 failed_init: 1658 + failed_regulator: 1670 1659 clk_disable_unprepare(fep->clk_ahb); 1671 1660 clk_disable_unprepare(fep->clk_ipg); 1672 1661 failed_pin: