对Linux内核整个clk框架来说,clk框架层看到的核心数据结构为struct clk,并且每个clk都有一个这样
的对象。平台需要向clk框架层注册这些clk,但是平台或者硬件相关的是struct clk_hw,以及对应的ops对象
struct clk_ops。
drivers/clk/clk.c
struct clk { struct clk_core *core; const char *dev_id; const char *con_id; unsigned long min_rate; unsigned long max_rate; struct hlist_node clks_node; };
/***private data structures***/
struct clk_core { const char *name; const struct clk_ops *ops; struct clk_hw *hw; struct module *owner; struct clk_core *parent; const char **parent_names; struct clk_core **parents; u8 num_parents; u8 new_parent_index; unsigned long rate; unsigned long req_rate; unsigned long new_rate; struct clk_core *new_parent; struct clk_core *new_child; unsigned long flags; bool orphan; unsigned int enable_count; unsigned int prepare_count; unsigned long min_rate; unsigned long max_rate; unsigned long accuracy; int phase; struct hlist_head children; struct hlist_node child_node; struct hlist_head clks; unsigned int notifier_count; #ifdef CONFIG_DEBUG_FS struct dentry *dentry; struct hlist_node debug_node; #endif struct kref ref; };
驱动实现 私有数据块 clk框架层实现,接口 clk_register clk_priv | |________struct clk_hw | core |----------------------------------------------->struct clk_core |------| |name | | clk |-------------------------->struct clk____ |ops | |------| | core | |hw | | init | | dev_id | |owner | |_____ |-->_____________________ | con_id | |parent | | name | |min_rate | |parent_names | |--------------------- |max_rate | |parents | 驱动<------------- |struct clk_ops *ops | |clks_node | | | 实现 |--------------------- |------------ |---------------- | parent_names | |--------------------- | num_parents | |--------------------- | flags | ----------------------