Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Linux Kernel - Clock Framework - What is role of clk_prepare/unprepare?

I am reading up the following article about the new Clock Framework present in the Linux Kernel..

http://lwn.net/Articles/489668/

  • What is unclear to me, is the usage of the new API's clk_prepare/unprepare, which complement the clk_enable/disable API's.
  • Also it is mentioned that while the API's clk_enable/disable can be called from an atomic context, this does not apply for clk_prepare/unprepare (which can sleep). Why is there this separation of functionality and behavior ?
  • I am keen to understand as to what is it about clocks that we need to prepare/unprepare them ?

Thanks,

~vj

like image 890
TheLoneJoker Avatar asked Jun 23 '13 15:06

TheLoneJoker


1 Answers

Clocks may need PLLs to be set up and locked, voltage OPP to be set, or other prerequisite actions before clk_enable. For example: drivers/clk/clk-highbank.c clk_pll_prepare()

This routine has wait loops that spin until the hardware PLL shows lock. Can't do that from an atomic context. Another LWN article speaks a bit to the prepare() vs enable() separation.

PLL and clock details are specific to the processor / SoC in question. Block diagrams would show clock tree of SoC input pins leading to various PLLs, then various clocks driven from each PLL (may also have power domains that can be turned on/off), and clocks individually enabled once the "prepare" is done. Long story, but I hope the above may be helpful.

like image 164
Joe Kul Avatar answered Nov 08 '22 05:11

Joe Kul