简体   繁体   中英

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?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM