Linux 内核clk ops

/**
 * 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.
 *
 * @prepare: Prepare the clock for enabling. This must not return until
 *  the clock is fully prepared, and it's safe to call clk_enable.
 *  This callback is intended to allow clock implementations to
 *  do any initialisation that may sleep. Called with
 *  prepare_lock held.
 *
 * @unprepare: Release the clock from its prepared state. This will typically
 *  undo any work done in the @prepare callback. Called with
 *  prepare_lock held.
 *
 * @is_prepared: Queries the hardware to determine if the clock is prepared.
 *  This function is allowed to sleep. Optional, if this op is not
 *  set then the prepare count will be used.
 *
 * @unprepare_unused: Unprepare the clock atomically.  Only called from
 *  clk_disable_unused for prepare clocks with special needs.
 *  Called with prepare mutex held. This function may sleep.
 *
 * @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.
 *
 * @is_enabled: Queries the hardware to determine if the clock is enabled.
 *  This function must not sleep. Optional, if this op is not
 *  set then the enable count will be used.
 *
 * @disable_unused: Disable the clock atomically.  Only called from
 *  clk_disable_unused for gate clocks with special needs.
 *  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.
 *
 * @determine_rate: Given a target rate as input, returns the closest rate
 *  actually supported by the clock, and optionally the parent clock
 *  that should be used to provide the clock rate.
 *
 * @set_parent: Change the input source of this clock; for clocks with multiple
 *  possible parents specify a new parent by passing in the index
 *  as a u8 corresponding to the parent in either the .parent_names
 *  or .parents arrays.  This function in affect translates an
 *  array index into the value programmed into the hardware.
 *  Returns 0 on success, -EERROR otherwise.
 *
 * @get_parent: Queries the hardware to determine the parent of a clock.  The
 *  return value is a u8 which specifies the index corresponding to
 *  the parent clock.  This index can be applied to either the
 *  .parent_names or .parents arrays.  In short, this function
 *  translates the parent value read from hardware into an array
 *  index.  Currently only called when the clock is initialized by
 *  __clk_init.  This callback is mandatory for clocks with
 *  multiple parents.  It is optional (and unnecessary) for clocks
 *  with 0 or 1 parents.
 *
 * @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.
 *
 * @set_rate_and_parent: Change the rate and the parent 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_and_parent implementation. The fourth
 *  argument gives the parent index. This callback is optional (and
 *  unnecessary) for clocks with 0 or 1 parents as well as
 *  for clocks that can tolerate switching the rate and the parent
 *  separately via calls to .set_parent and .set_rate.
 *  Returns 0 on success, -EERROR otherwise.
 *
 * @recalc_accuracy: Recalculate the accuracy of this clock. The clock accuracy
 *  is expressed in ppb (parts per billion). The parent accuracy is
 *  an input parameter.
 *  Returns the calculated accuracy.  Optional - if this op is not
 *  set then clock accuracy will be initialized to parent accuracy
 *  or 0 (perfect clock) if clock has no parent.
 *
 * @get_phase: Queries the hardware to get the current phase of a clock.
 *  Returned values are 0-359 degrees on success, negative
 *  error codes on failure.
 *
 * @set_phase: Shift the phase this clock signal in degrees specified
 *  by the second argument. Valid values for degrees are
 *  0-359. Return 0 on success, otherwise -EERROR.
 *
 * @init: Perform platform-specific initialization magic.
 *  This is not not used by any of the basic clock types.
 *  Please consider other ways of solving initialization problems
 *  before using this callback, as its use is discouraged.
 *
 * @debug_init: Set up type-specific debugfs entries for this clock.  This
 *  is called once, after the debugfs directory entry for this
 *  clock has been created.  The dentry pointer representing that
 *  directory is provided as an argument.  Called with
 *  prepare_lock held.  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.
 */
struct clk_ops {
 int  (*prepare)(struct clk_hw *hw);
 void  (*unprepare)(struct clk_hw *hw);
 int  (*is_prepared)(struct clk_hw *hw);
 void  (*unprepare_unused)(struct clk_hw *hw);
 int  (*enable)(struct clk_hw *hw);
 void  (*disable)(struct clk_hw *hw);
 int  (*is_enabled)(struct clk_hw *hw);
 void  (*disable_unused)(struct clk_hw *hw);
 unsigned long (*recalc_rate)(struct clk_hw *hw,
     unsigned long parent_rate);
 long  (*round_rate)(struct clk_hw *hw, unsigned long rate,
     unsigned long *parent_rate);
 int  (*determine_rate)(struct clk_hw *hw,
       struct clk_rate_request *req);
 int  (*set_parent)(struct clk_hw *hw, u8 index);
 u8  (*get_parent)(struct clk_hw *hw);
 int  (*set_rate)(struct clk_hw *hw, unsigned long rate,
        unsigned long parent_rate);
 int  (*set_rate_and_parent)(struct clk_hw *hw,
        unsigned long rate,
        unsigned long parent_rate, u8 index);
 unsigned long (*recalc_accuracy)(struct clk_hw *hw,
        unsigned long parent_accuracy);
 int  (*get_phase)(struct clk_hw *hw);
 int  (*set_phase)(struct clk_hw *hw, int degrees);
 void  (*init)(struct clk_hw *hw);
 int  (*debug_init)(struct clk_hw *hw, struct dentry *dentry);
};
 
 
 
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值