aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/ethernet/freescale/fec.c
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2012-03-07 03:30:49 -0500
committerSascha Hauer <s.hauer@pengutronix.de>2012-04-25 11:03:37 -0400
commitf4d40de39a23f0c39cca55ac63e1175c69c3d2f7 (patch)
tree78f58dceae9eb0f0f0ac0d87810cdd400030f524 /drivers/net/ethernet/freescale/fec.c
parent13aaea03b9e33af420a327b7ab800332d6fbabf5 (diff)
net fec: do not depend on grouped clocks
the current i.MX clock support groups together unrelated clocks to a single clock which is then used by the driver. This can't be accomplished with the generic clock framework so we instead request the individual clocks in the driver. For i.MX there are generally three different clocks: ipg: bus clock (needed to access registers) ahb: dma relevant clock, sometimes referred to as hclk in the datasheet per: bit clock, pixel clock This patch changes the driver to request the individual clocks. Currently all clk_get will get the same clock until the SoCs are converted to the generic clock framework Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'drivers/net/ethernet/freescale/fec.c')
-rw-r--r--drivers/net/ethernet/freescale/fec.c35
1 files changed, 23 insertions, 12 deletions
diff --git a/drivers/net/ethernet/freescale/fec.c b/drivers/net/ethernet/freescale/fec.c
index a12b3f5bc025..b2494637cb60 100644
--- a/drivers/net/ethernet/freescale/fec.c
+++ b/drivers/net/ethernet/freescale/fec.c
@@ -206,7 +206,8 @@ struct fec_enet_private {
206 206
207 struct net_device *netdev; 207 struct net_device *netdev;
208 208
209 struct clk *clk; 209 struct clk *clk_ipg;
210 struct clk *clk_ahb;
210 211
211 /* The saved address of a sent-in-place packet/buffer, for skfree(). */ 212 /* The saved address of a sent-in-place packet/buffer, for skfree(). */
212 unsigned char *tx_bounce[TX_RING_SIZE]; 213 unsigned char *tx_bounce[TX_RING_SIZE];
@@ -1064,7 +1065,7 @@ static int fec_enet_mii_init(struct platform_device *pdev)
1064 * Reference Manual has an error on this, and gets fixed on i.MX6Q 1065 * Reference Manual has an error on this, and gets fixed on i.MX6Q
1065 * document. 1066 * document.
1066 */ 1067 */
1067 fep->phy_speed = DIV_ROUND_UP(clk_get_rate(fep->clk), 5000000); 1068 fep->phy_speed = DIV_ROUND_UP(clk_get_rate(fep->clk_ahb), 5000000);
1068 if (id_entry->driver_data & FEC_QUIRK_ENET_MAC) 1069 if (id_entry->driver_data & FEC_QUIRK_ENET_MAC)
1069 fep->phy_speed--; 1070 fep->phy_speed--;
1070 fep->phy_speed <<= 1; 1071 fep->phy_speed <<= 1;
@@ -1609,12 +1610,20 @@ fec_probe(struct platform_device *pdev)
1609 } 1610 }
1610 } 1611 }
1611 1612
1612 fep->clk = clk_get(&pdev->dev, NULL); 1613 fep->clk_ipg = devm_clk_get(&pdev->dev, "ipg");
1613 if (IS_ERR(fep->clk)) { 1614 if (IS_ERR(fep->clk_ipg)) {
1614 ret = PTR_ERR(fep->clk); 1615 ret = PTR_ERR(fep->clk_ipg);
1615 goto failed_clk; 1616 goto failed_clk;
1616 } 1617 }
1617 clk_prepare_enable(fep->clk); 1618
1619 fep->clk_ahb = devm_clk_get(&pdev->dev, "ahb");
1620 if (IS_ERR(fep->clk_ahb)) {
1621 ret = PTR_ERR(fep->clk_ahb);
1622 goto failed_clk;
1623 }
1624
1625 clk_prepare_enable(fep->clk_ahb);
1626 clk_prepare_enable(fep->clk_ipg);
1618 1627
1619 ret = fec_enet_init(ndev); 1628 ret = fec_enet_init(ndev);
1620 if (ret) 1629 if (ret)
@@ -1637,8 +1646,8 @@ failed_register:
1637 fec_enet_mii_remove(fep); 1646 fec_enet_mii_remove(fep);
1638failed_mii_init: 1647failed_mii_init:
1639failed_init: 1648failed_init:
1640 clk_disable_unprepare(fep->clk); 1649 clk_disable_unprepare(fep->clk_ahb);
1641 clk_put(fep->clk); 1650 clk_disable_unprepare(fep->clk_ipg);
1642failed_clk: 1651failed_clk:
1643 for (i = 0; i < FEC_IRQ_NUM; i++) { 1652 for (i = 0; i < FEC_IRQ_NUM; i++) {
1644 irq = platform_get_irq(pdev, i); 1653 irq = platform_get_irq(pdev, i);
@@ -1670,8 +1679,8 @@ fec_drv_remove(struct platform_device *pdev)
1670 if (irq > 0) 1679 if (irq > 0)
1671 free_irq(irq, ndev); 1680 free_irq(irq, ndev);
1672 } 1681 }
1673 clk_disable_unprepare(fep->clk); 1682 clk_disable_unprepare(fep->clk_ahb);
1674 clk_put(fep->clk); 1683 clk_disable_unprepare(fep->clk_ipg);
1675 iounmap(fep->hwp); 1684 iounmap(fep->hwp);
1676 free_netdev(ndev); 1685 free_netdev(ndev);
1677 1686
@@ -1695,7 +1704,8 @@ fec_suspend(struct device *dev)
1695 fec_stop(ndev); 1704 fec_stop(ndev);
1696 netif_device_detach(ndev); 1705 netif_device_detach(ndev);
1697 } 1706 }
1698 clk_disable_unprepare(fep->clk); 1707 clk_disable_unprepare(fep->clk_ahb);
1708 clk_disable_unprepare(fep->clk_ipg);
1699 1709
1700 return 0; 1710 return 0;
1701} 1711}
@@ -1706,7 +1716,8 @@ fec_resume(struct device *dev)
1706 struct net_device *ndev = dev_get_drvdata(dev); 1716 struct net_device *ndev = dev_get_drvdata(dev);
1707 struct fec_enet_private *fep = netdev_priv(ndev); 1717 struct fec_enet_private *fep = netdev_priv(ndev);
1708 1718
1709 clk_prepare_enable(fep->clk); 1719 clk_prepare_enable(fep->clk_ahb);
1720 clk_prepare_enable(fep->clk_ipg);
1710 if (netif_running(ndev)) { 1721 if (netif_running(ndev)) {
1711 fec_restart(ndev, fep->full_duplex); 1722 fec_restart(ndev, fep->full_duplex);
1712 netif_device_attach(ndev); 1723 netif_device_attach(ndev);