aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/ethernet
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/ethernet')
-rw-r--r--drivers/net/ethernet/freescale/fec.h1
-rw-r--r--drivers/net/ethernet/freescale/fec_main.c37
2 files changed, 27 insertions, 11 deletions
diff --git a/drivers/net/ethernet/freescale/fec.h b/drivers/net/ethernet/freescale/fec.h
index 9ce5b7185fda..b11cdbcc04ff 100644
--- a/drivers/net/ethernet/freescale/fec.h
+++ b/drivers/net/ethernet/freescale/fec.h
@@ -272,6 +272,7 @@ struct fec_enet_private {
272 int hwts_tx_en; 272 int hwts_tx_en;
273 struct timer_list time_keep; 273 struct timer_list time_keep;
274 struct fec_enet_delayed_work delay_work; 274 struct fec_enet_delayed_work delay_work;
275 struct regulator *reg_phy;
275}; 276};
276 277
277void fec_ptp_init(struct net_device *ndev, struct platform_device *pdev); 278void fec_ptp_init(struct net_device *ndev, struct platform_device *pdev);
diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c
index 0936b26b5e1e..866b92220c15 100644
--- a/drivers/net/ethernet/freescale/fec_main.c
+++ b/drivers/net/ethernet/freescale/fec_main.c
@@ -1840,7 +1840,6 @@ fec_probe(struct platform_device *pdev)
1840 struct resource *r; 1840 struct resource *r;
1841 const struct of_device_id *of_id; 1841 const struct of_device_id *of_id;
1842 static int dev_id; 1842 static int dev_id;
1843 struct regulator *reg_phy;
1844 1843
1845 of_id = of_match_device(fec_dt_ids, &pdev->dev); 1844 of_id = of_match_device(fec_dt_ids, &pdev->dev);
1846 if (of_id) 1845 if (of_id)
@@ -1919,14 +1918,16 @@ fec_probe(struct platform_device *pdev)
1919 clk_prepare_enable(fep->clk_enet_out); 1918 clk_prepare_enable(fep->clk_enet_out);
1920 clk_prepare_enable(fep->clk_ptp); 1919 clk_prepare_enable(fep->clk_ptp);
1921 1920
1922 reg_phy = devm_regulator_get(&pdev->dev, "phy"); 1921 fep->reg_phy = devm_regulator_get(&pdev->dev, "phy");
1923 if (!IS_ERR(reg_phy)) { 1922 if (!IS_ERR(fep->reg_phy)) {
1924 ret = regulator_enable(reg_phy); 1923 ret = regulator_enable(fep->reg_phy);
1925 if (ret) { 1924 if (ret) {
1926 dev_err(&pdev->dev, 1925 dev_err(&pdev->dev,
1927 "Failed to enable phy regulator: %d\n", ret); 1926 "Failed to enable phy regulator: %d\n", ret);
1928 goto failed_regulator; 1927 goto failed_regulator;
1929 } 1928 }
1929 } else {
1930 fep->reg_phy = NULL;
1930 } 1931 }
1931 1932
1932 fec_reset_phy(pdev); 1933 fec_reset_phy(pdev);
@@ -1976,13 +1977,15 @@ fec_probe(struct platform_device *pdev)
1976failed_register: 1977failed_register:
1977 fec_enet_mii_remove(fep); 1978 fec_enet_mii_remove(fep);
1978failed_mii_init: 1979failed_mii_init:
1979failed_init: 1980failed_irq:
1980 for (i = 0; i < FEC_IRQ_NUM; i++) { 1981 for (i = 0; i < FEC_IRQ_NUM; i++) {
1981 irq = platform_get_irq(pdev, i); 1982 irq = platform_get_irq(pdev, i);
1982 if (irq > 0) 1983 if (irq > 0)
1983 free_irq(irq, ndev); 1984 free_irq(irq, ndev);
1984 } 1985 }
1985failed_irq: 1986failed_init:
1987 if (fep->reg_phy)
1988 regulator_disable(fep->reg_phy);
1986failed_regulator: 1989failed_regulator:
1987 clk_disable_unprepare(fep->clk_ahb); 1990 clk_disable_unprepare(fep->clk_ahb);
1988 clk_disable_unprepare(fep->clk_ipg); 1991 clk_disable_unprepare(fep->clk_ipg);
@@ -2006,17 +2009,19 @@ fec_drv_remove(struct platform_device *pdev)
2006 unregister_netdev(ndev); 2009 unregister_netdev(ndev);
2007 fec_enet_mii_remove(fep); 2010 fec_enet_mii_remove(fep);
2008 del_timer_sync(&fep->time_keep); 2011 del_timer_sync(&fep->time_keep);
2012 for (i = 0; i < FEC_IRQ_NUM; i++) {
2013 int irq = platform_get_irq(pdev, i);
2014 if (irq > 0)
2015 free_irq(irq, ndev);
2016 }
2017 if (fep->reg_phy)
2018 regulator_disable(fep->reg_phy);
2009 clk_disable_unprepare(fep->clk_ptp); 2019 clk_disable_unprepare(fep->clk_ptp);
2010 if (fep->ptp_clock) 2020 if (fep->ptp_clock)
2011 ptp_clock_unregister(fep->ptp_clock); 2021 ptp_clock_unregister(fep->ptp_clock);
2012 clk_disable_unprepare(fep->clk_enet_out); 2022 clk_disable_unprepare(fep->clk_enet_out);
2013 clk_disable_unprepare(fep->clk_ahb); 2023 clk_disable_unprepare(fep->clk_ahb);
2014 clk_disable_unprepare(fep->clk_ipg); 2024 clk_disable_unprepare(fep->clk_ipg);
2015 for (i = 0; i < FEC_IRQ_NUM; i++) {
2016 int irq = platform_get_irq(pdev, i);
2017 if (irq > 0)
2018 free_irq(irq, ndev);
2019 }
2020 free_netdev(ndev); 2025 free_netdev(ndev);
2021 2026
2022 platform_set_drvdata(pdev, NULL); 2027 platform_set_drvdata(pdev, NULL);
@@ -2039,6 +2044,9 @@ fec_suspend(struct device *dev)
2039 clk_disable_unprepare(fep->clk_ahb); 2044 clk_disable_unprepare(fep->clk_ahb);
2040 clk_disable_unprepare(fep->clk_ipg); 2045 clk_disable_unprepare(fep->clk_ipg);
2041 2046
2047 if (fep->reg_phy)
2048 regulator_disable(fep->reg_phy);
2049
2042 return 0; 2050 return 0;
2043} 2051}
2044 2052
@@ -2047,6 +2055,13 @@ fec_resume(struct device *dev)
2047{ 2055{
2048 struct net_device *ndev = dev_get_drvdata(dev); 2056 struct net_device *ndev = dev_get_drvdata(dev);
2049 struct fec_enet_private *fep = netdev_priv(ndev); 2057 struct fec_enet_private *fep = netdev_priv(ndev);
2058 int ret;
2059
2060 if (fep->reg_phy) {
2061 ret = regulator_enable(fep->reg_phy);
2062 if (ret)
2063 return ret;
2064 }
2050 2065
2051 clk_prepare_enable(fep->clk_enet_out); 2066 clk_prepare_enable(fep->clk_enet_out);
2052 clk_prepare_enable(fep->clk_ahb); 2067 clk_prepare_enable(fep->clk_ahb);