struct clk_ops - Callback operations for hardware clocks; these are to be provided by the clock implementation, and will be called by drivers through the clk_* api.
- Parameters
-
enable | Enable the clock atomically. This must not return until the clock is generating a valid clock signal, usable by consumer devices. Called with enable_lock held. This function must not sleep. |
disable | Disable the clock atomically. Called with enable_lock held. This function must not sleep. |
recalc_rate | Recalculate the rate of this clock, by querying hardware. The parent rate is an input parameter. It is up to the caller to ensure that the prepare_mutex is held across this call. Returns the calculated rate. Optional, but recommended - if this op is not set then clock rate will be initialized to 0. |
round_rate | Given a target rate as input, returns the closest rate actually supported by the clock. The parent rate is an input/output parameter. |
set_rate | Change the rate of this clock. The requested rate is specified by the second argument, which should typically be the return of .round_rate call. The third argument gives the parent rate which is likely helpful for most .set_rate implementation. Returns 0 on success, -EERROR otherwise. |
The clk_enable/clk_disable and clk_prepare/clk_unprepare pairs allow implementations to split any work between atomic (enable) and sleepable (prepare) contexts. If enabling a clock requires code that might sleep, this must be done in clk_prepare. Clock enable code that will never be called in a sleepable context may be implemented in clk_enable.
Typically, drivers will call clk_prepare when a clock may be needed later (eg. when a device is opened), and clk_enable when the clock is actually required (eg. from an interrupt). Note that clk_prepare MUST have been called before clk_enable.