Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net
[firefly-linux-kernel-4.4.55.git] / drivers / net / ethernet / cadence / macb.c
index 2747a7f595285ca37227d26baea44b28c1ab8a10..6be513deb17f69b73be4b321821e99d3ec7a17cd 100644 (file)
@@ -1476,41 +1476,7 @@ static const struct of_device_id macb_dt_ids[] = {
        { .compatible = "cdns,gem" },
        { /* sentinel */ }
 };
-
 MODULE_DEVICE_TABLE(of, macb_dt_ids);
-
-static int macb_get_phy_mode_dt(struct platform_device *pdev)
-{
-       struct device_node *np = pdev->dev.of_node;
-
-       if (np)
-               return of_get_phy_mode(np);
-
-       return -ENODEV;
-}
-
-static int macb_get_hwaddr_dt(struct macb *bp)
-{
-       struct device_node *np = bp->pdev->dev.of_node;
-       if (np) {
-               const char *mac = of_get_mac_address(np);
-               if (mac) {
-                       memcpy(bp->dev->dev_addr, mac, ETH_ALEN);
-                       return 0;
-               }
-       }
-
-       return -ENODEV;
-}
-#else
-static int macb_get_phy_mode_dt(struct platform_device *pdev)
-{
-       return -ENODEV;
-}
-static int macb_get_hwaddr_dt(struct macb *bp)
-{
-       return -ENODEV;
-}
 #endif
 
 static int __init macb_probe(struct platform_device *pdev)
@@ -1523,6 +1489,7 @@ static int __init macb_probe(struct platform_device *pdev)
        u32 config;
        int err = -ENXIO;
        struct pinctrl *pinctrl;
+       const char *mac;
 
        regs = platform_get_resource(pdev, IORESOURCE_MEM, 0);
        if (!regs) {
@@ -1561,14 +1528,14 @@ static int __init macb_probe(struct platform_device *pdev)
                dev_err(&pdev->dev, "failed to get macb_clk\n");
                goto err_out_free_dev;
        }
-       clk_enable(bp->pclk);
+       clk_prepare_enable(bp->pclk);
 
        bp->hclk = clk_get(&pdev->dev, "hclk");
        if (IS_ERR(bp->hclk)) {
                dev_err(&pdev->dev, "failed to get hclk\n");
                goto err_out_put_pclk;
        }
-       clk_enable(bp->hclk);
+       clk_prepare_enable(bp->hclk);
 
        bp->regs = ioremap(regs->start, resource_size(regs));
        if (!bp->regs) {
@@ -1596,11 +1563,13 @@ static int __init macb_probe(struct platform_device *pdev)
        config |= macb_dbw(bp);
        macb_writel(bp, NCFGR, config);
 
-       err = macb_get_hwaddr_dt(bp);
-       if (err < 0)
+       mac = of_get_mac_address(pdev->dev.of_node);
+       if (mac)
+               memcpy(bp->dev->dev_addr, mac, ETH_ALEN);
+       else
                macb_get_hwaddr(bp);
 
-       err = macb_get_phy_mode_dt(pdev);
+       err = of_get_phy_mode(pdev->dev.of_node);
        if (err < 0) {
                pdata = pdev->dev.platform_data;
                if (pdata && pdata->is_rmii)
@@ -1633,9 +1602,9 @@ static int __init macb_probe(struct platform_device *pdev)
                goto err_out_free_irq;
        }
 
-       if (macb_mii_init(bp) != 0) {
+       err = macb_mii_init(bp);
+       if (err)
                goto err_out_unregister_netdev;
-       }
 
        platform_set_drvdata(pdev, dev);
 
@@ -1658,9 +1627,9 @@ err_out_free_irq:
 err_out_iounmap:
        iounmap(bp->regs);
 err_out_disable_clocks:
-       clk_disable(bp->hclk);
+       clk_disable_unprepare(bp->hclk);
        clk_put(bp->hclk);
-       clk_disable(bp->pclk);
+       clk_disable_unprepare(bp->pclk);
 err_out_put_pclk:
        clk_put(bp->pclk);
 err_out_free_dev:
@@ -1687,9 +1656,9 @@ static int __exit macb_remove(struct platform_device *pdev)
                unregister_netdev(dev);
                free_irq(dev->irq, dev);
                iounmap(bp->regs);
-               clk_disable(bp->hclk);
+               clk_disable_unprepare(bp->hclk);
                clk_put(bp->hclk);
-               clk_disable(bp->pclk);
+               clk_disable_unprepare(bp->pclk);
                clk_put(bp->pclk);
                free_netdev(dev);
                platform_set_drvdata(pdev, NULL);
@@ -1707,8 +1676,8 @@ static int macb_suspend(struct platform_device *pdev, pm_message_t state)
        netif_carrier_off(netdev);
        netif_device_detach(netdev);
 
-       clk_disable(bp->hclk);
-       clk_disable(bp->pclk);
+       clk_disable_unprepare(bp->hclk);
+       clk_disable_unprepare(bp->pclk);
 
        return 0;
 }
@@ -1718,8 +1687,8 @@ static int macb_resume(struct platform_device *pdev)
        struct net_device *netdev = platform_get_drvdata(pdev);
        struct macb *bp = netdev_priv(netdev);
 
-       clk_enable(bp->pclk);
-       clk_enable(bp->hclk);
+       clk_prepare_enable(bp->pclk);
+       clk_prepare_enable(bp->hclk);
 
        netif_device_attach(netdev);