STRUCT CLK_CORE(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… NAME

struct clk_core β€” okay so real talk, this is the internal state of a clk in the clk tree, and it is lowkey the main character of the whole clock framework πŸ•°οΈβœ¨ (also hiii, you're reading the struct clk_core(9) page from the Kernel API Manual, welcome bestie 🫢)

πŸŽ€ SYNOPSIS

struct clk_core {
    const char              *name;
    const struct clk_ops    *ops;
    struct clk_hw           *hw;
    struct module           *owner;
    struct device           *dev;
    struct hlist_node       rpm_node;
    struct device_node      *of_node;
    struct clk_core         *parent;
    struct clk_parent_map   *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;
    bool rpm_enabled;
    unsigned int            enable_count;
    unsigned int            prepare_count;
    unsigned int            protect_count;
    unsigned long           min_rate;
    unsigned long           max_rate;
    unsigned long           accuracy;
    int phase;
    struct clk_duty         duty;
    struct hlist_head       children;
    struct hlist_node       child_node;
    struct hlist_node       hashtable_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;
 };

πŸ¦‹ Members

  • name β€” the unique name of the clk, for identification. it's how the framework knows which clock you're talking about, no cap πŸ’–
  • ops β€” pointer to the hardware-specific operations for this clk. the actual "how do I do the thing" instructions πŸ”§
  • hw β€” pointer used for traversing from a struct clk to its corresponding hardware-specific structure. your little bridge between worlds πŸŒ‰
  • owner β€” the kernel module that owns this clk (for reference counting). keeping the module alive so it doesn't ghost you πŸ’€
  • dev β€” the device associated with this clk (optional)
  • rpm_node β€” node for runtime power management list management ⚑
  • of_node β€” the device tree node associated with this clk (if applicable) 🌳
  • parent β€” pointer to the current parent in the clock tree. family tree moment πŸ‘‘
  • parents β€” array of possible parents (for muxes/selectable parents). the whole roster, not just the current fave ✨
  • num_parents β€” number of possible parents.
  • new_parent_index β€” index of the new parent during parent change operations. mid-switch era πŸ”„
  • rate β€” current cached clock rate (Hz). the vibe, numerically 🎡
  • req_rate β€” the last rate requested by a call to clk_set_rate. It's initialized to clk_core->rate. It's also updated to clk_core->rate every time the clock is reparented, and when we're doing the orphan -> !orphan transition. so it's the receipts of what was asked for πŸ“
  • new_rate β€” new rate to be set during a rate change operation.
  • new_parent β€” pointer to new parent during parent change. This is also used when a clk's rate is changed.
  • new_child β€” pointer to new child during reparenting. This is also used when a clk's rate is changed.
  • flags β€” clock property and capability flags. See clk framework flags 🚩
  • orphan β€” true if this clk is currently orphaned. it has no parent and it's going through it 😭
  • rpm_enabled β€” true if runtime power management is enabled for this clk.
  • enable_count β€” reference count of enables.
  • prepare_count β€” reference count of prepares.
  • protect_count β€” protection reference count against disable. iykyk, this one keeps it from getting shut off against its will πŸ›‘οΈ
  • min_rate β€” minimum supported clock rate (Hz).
  • max_rate β€” maximum supported clock rate (Hz).
  • accuracy β€” accuracy of the clock rate (parts per billion). how precise bestie is 🎯
  • phase β€” current phase (degrees).
  • duty β€” current duty cycle configuration (as ratio: num/den). πŸ“
  • children β€” all of the children of this clk. the whole squad πŸ‘―
  • child_node β€” node for linking as a child in the parent's list.
  • hashtable_node β€” node for hash table that allows fast clk lookup by name. speed βœ¨πŸ’¨
  • clks β€” all of the clk consumers registered.
  • notifier_count β€” number of notifiers registered for this clk. πŸ””
  • dentry β€” DebugFS entry for this clk. (this one lives behind CONFIG_DEBUG_FS πŸ’…)
  • debug_node β€” DebugFS node for this clk. (also a CONFIG_DEBUG_FS girlie πŸ’…)
  • ref β€” reference count for structure lifetime management. keeps the whole thing from evaporating 🫢

🌈 Description

Managed by the clk framework. Clk providers and consumers do not interact with this structure directly β€” like, do not touch, it's not for you bestie πŸ™ˆ. Instead, clk operations flow through the framework, and the framework manipulates this structure to keep track of parent/child relationships, rate, enable state, etc. it's the framework's private lil notebook, periodt πŸ““βœ¨


πŸ‘‘ SEE ALSO

Kernel file ./drivers/clk/clk.c plus, in order: clk_pm_runtime_get_all(9), clk_pm_runtime_put_all(9), clk_core_get(9), clk_determine_rate_noop(9), clk_rate_exclusive_put(9), clk_rate_exclusive_get(9), clk_unprepare(9), clk_prepare(9), clk_disable(9), clk_gate_restore_context(9), clk_save_context(9), clk_restore_context(9), clk_enable(9), clk_is_enabled_when_prepared(9), clk_hw_init_rate_request(9), clk_hw_forward_rate_request(9), __clk_determine_rate(9), clk_hw_round_rate(9), clk_round_rate(9), __clk_notify(9), __clk_recalc_accuracies(9), clk_get_accuracy(9), __clk_recalc_rates(9), clk_get_rate(9), clk_hw_get_parent_index(9), __clk_speculate_rates(9), clk_set_rate(9), clk_set_rate_exclusive(9), clk_set_rate_range(9), clk_set_min_rate(9), clk_set_max_rate(9), clk_get_parent(9), clk_has_parent(9), clk_set_parent(9), clk_set_phase(9), clk_get_phase(9), clk_set_duty_cycle(9), clk_get_scaled_duty_cycle(9), clk_is_match(9), clk_debug_register(9), clk_debug_init(9), __clk_core_init(9), clk_core_link_consumer(9), clk_core_unlink_consumer(9), alloc_clk(9), free_clk(9), clk_hw_create_clk(9), clk_hw_get_clk(9), dev_or_parent_of_node(9), clk_register(9), clk_hw_register(9), clk_unregister(9), clk_hw_unregister(9), devm_clk_register(9), devm_clk_hw_register(9), devm_clk_hw_get_clk(9), clk_notifier_register(9), clk_notifier_unregister(9), struct of_clk_provider(9), of_clk_add_provider(9), of_clk_add_hw_provider(9), devm_of_clk_add_hw_provider(9), of_clk_del_provider(9), of_parse_clkspec(9), of_clk_get_from_provider(9), of_clk_get_by_name(9), of_clk_get_parent_count(9), of_clk_parent_fill(9), of_clk_detect_critical(9), of_clk_init(9).


and that's the page bestie!! 🫢 it ships from ./drivers/clk, dated October 2026, and it goes out under the name struct clk_core(9) β€” slay, go read clk.c πŸ’–βœ¨

πŸ“¦ where this page comes from