net: axienet: Enable more clocks
[linux-2.6-microblaze.git] / drivers / net / ethernet / xilinx / xilinx_axienet_main.c
index 5d677db..9635101 100644 (file)
@@ -1863,17 +1863,35 @@ static int axienet_probe(struct platform_device *pdev)
        lp->rx_bd_num = RX_BD_NUM_DEFAULT;
        lp->tx_bd_num = TX_BD_NUM_DEFAULT;
 
-       lp->clk = devm_clk_get_optional(&pdev->dev, NULL);
-       if (IS_ERR(lp->clk)) {
-               ret = PTR_ERR(lp->clk);
+       lp->axi_clk = devm_clk_get_optional(&pdev->dev, "s_axi_lite_clk");
+       if (!lp->axi_clk) {
+               /* For backward compatibility, if named AXI clock is not present,
+                * treat the first clock specified as the AXI clock.
+                */
+               lp->axi_clk = devm_clk_get_optional(&pdev->dev, NULL);
+       }
+       if (IS_ERR(lp->axi_clk)) {
+               ret = PTR_ERR(lp->axi_clk);
                goto free_netdev;
        }
-       ret = clk_prepare_enable(lp->clk);
+       ret = clk_prepare_enable(lp->axi_clk);
        if (ret) {
-               dev_err(&pdev->dev, "Unable to enable clock: %d\n", ret);
+               dev_err(&pdev->dev, "Unable to enable AXI clock: %d\n", ret);
                goto free_netdev;
        }
 
+       lp->misc_clks[0].id = "axis_clk";
+       lp->misc_clks[1].id = "ref_clk";
+       lp->misc_clks[2].id = "mgt_clk";
+
+       ret = devm_clk_bulk_get_optional(&pdev->dev, XAE_NUM_MISC_CLOCKS, lp->misc_clks);
+       if (ret)
+               goto cleanup_clk;
+
+       ret = clk_bulk_prepare_enable(XAE_NUM_MISC_CLOCKS, lp->misc_clks);
+       if (ret)
+               goto cleanup_clk;
+
        /* Map device registers */
        ethres = platform_get_resource(pdev, IORESOURCE_MEM, 0);
        lp->regs = devm_ioremap_resource(&pdev->dev, ethres);
@@ -2109,7 +2127,8 @@ cleanup_mdio:
        of_node_put(lp->phy_node);
 
 cleanup_clk:
-       clk_disable_unprepare(lp->clk);
+       clk_bulk_disable_unprepare(XAE_NUM_MISC_CLOCKS, lp->misc_clks);
+       clk_disable_unprepare(lp->axi_clk);
 
 free_netdev:
        free_netdev(ndev);
@@ -2132,7 +2151,8 @@ static int axienet_remove(struct platform_device *pdev)
 
        axienet_mdio_teardown(lp);
 
-       clk_disable_unprepare(lp->clk);
+       clk_bulk_disable_unprepare(XAE_NUM_MISC_CLOCKS, lp->misc_clks);
+       clk_disable_unprepare(lp->axi_clk);
 
        of_node_put(lp->phy_node);
        lp->phy_node = NULL;