Amit Singh Tomar
Amit Singh Tomar

Reputation: 8610

Why it is required to get clock information of system bus in linux Network driver?

I am going through network driver source and find this in probe function

    priv->busclk = devm_clk_get(&pdev->dev, "ahb2_gmac");
    if (IS_ERR(priv->busclk)) {
            ret = PTR_ERR(priv->busclk);
            dev_err(&pdev->dev, "Cannot get AHB clock err=%d\n", ret);
            return ret;
    }
    ret = clk_prepare_enable(priv->busclk);
    if (ret != 0) {
            dev_err(&pdev->dev, "Cannot prepare_enable busclk\n");
            return ret;
    }

    cr = clk_get_rate(priv->miiclk);
    dev_info(&pdev->dev, "Current MII clkrate %lu\n", cr);

    ret = clk_set_rate(priv->miiclk, cr / 4); 

In first statement devm_clk_get(&pdev->dev, "ahb2_gmac"), we are getting Bus(AHB2) clock and here clk_get_rate(priv->miiclk), we are getting the mii interterface clock

What purpore it serves (getting the bus and mii clock), how it helps in proper emac operations?

Upvotes: -1

Views: 709

Answers (1)

subin
subin

Reputation: 490

It is getting the device clock settings specified in the DTB and enabling and setting the device clock rate to the same. Without enabling the clocks, the peripheral will not function. For details of the final clock rate setting, you might need to have a look at the data sheet

Upvotes: 0

Related Questions