drivers/clk/imx/clk-busy.c
Source file repositories/reference/linux-study-clean/drivers/clk/imx/clk-busy.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/clk/imx/clk-busy.c- Extension
.c- Size
- 4410 bytes
- Lines
- 196
- Domain
- Driver Families
- Bucket
- drivers/clk
- Inferred role
- Driver Families: implementation source
- Status
- source implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/bits.hlinux/clk.hlinux/clk-provider.hlinux/io.hlinux/slab.hlinux/jiffies.hlinux/err.hclk.h
Detected Declarations
struct clk_busy_dividerstruct clk_busy_muxfunction clk_busy_waitfunction clk_busy_divider_recalc_ratefunction clk_busy_divider_determine_ratefunction clk_busy_divider_set_ratefunction clk_busy_mux_get_parentfunction clk_busy_mux_set_parent
Annotated Snippet
struct clk_busy_divider {
struct clk_divider div;
const struct clk_ops *div_ops;
void __iomem *reg;
u8 shift;
};
static inline struct clk_busy_divider *to_clk_busy_divider(struct clk_hw *hw)
{
struct clk_divider *div = to_clk_divider(hw);
return container_of(div, struct clk_busy_divider, div);
}
static unsigned long clk_busy_divider_recalc_rate(struct clk_hw *hw,
unsigned long parent_rate)
{
struct clk_busy_divider *busy = to_clk_busy_divider(hw);
return busy->div_ops->recalc_rate(&busy->div.hw, parent_rate);
}
static int clk_busy_divider_determine_rate(struct clk_hw *hw,
struct clk_rate_request *req)
{
struct clk_busy_divider *busy = to_clk_busy_divider(hw);
return busy->div_ops->determine_rate(&busy->div.hw, req);
}
static int clk_busy_divider_set_rate(struct clk_hw *hw, unsigned long rate,
unsigned long parent_rate)
{
struct clk_busy_divider *busy = to_clk_busy_divider(hw);
int ret;
ret = busy->div_ops->set_rate(&busy->div.hw, rate, parent_rate);
if (!ret)
ret = clk_busy_wait(busy->reg, busy->shift);
return ret;
}
static const struct clk_ops clk_busy_divider_ops = {
.recalc_rate = clk_busy_divider_recalc_rate,
.determine_rate = clk_busy_divider_determine_rate,
.set_rate = clk_busy_divider_set_rate,
};
struct clk_hw *imx_clk_hw_busy_divider(const char *name, const char *parent_name,
void __iomem *reg, u8 shift, u8 width,
void __iomem *busy_reg, u8 busy_shift)
{
struct clk_busy_divider *busy;
struct clk_hw *hw;
struct clk_init_data init;
int ret;
busy = kzalloc_obj(*busy);
if (!busy)
return ERR_PTR(-ENOMEM);
busy->reg = busy_reg;
busy->shift = busy_shift;
busy->div.reg = reg;
busy->div.shift = shift;
busy->div.width = width;
busy->div.lock = &imx_ccm_lock;
busy->div_ops = &clk_divider_ops;
init.name = name;
init.ops = &clk_busy_divider_ops;
init.flags = CLK_SET_RATE_PARENT | CLK_IS_CRITICAL;
init.parent_names = &parent_name;
init.num_parents = 1;
busy->div.hw.init = &init;
hw = &busy->div.hw;
ret = clk_hw_register(NULL, hw);
if (ret) {
kfree(busy);
return ERR_PTR(ret);
}
return hw;
}
Annotation
- Immediate include surface: `linux/bits.h`, `linux/clk.h`, `linux/clk-provider.h`, `linux/io.h`, `linux/slab.h`, `linux/jiffies.h`, `linux/err.h`, `clk.h`.
- Detected declarations: `struct clk_busy_divider`, `struct clk_busy_mux`, `function clk_busy_wait`, `function clk_busy_divider_recalc_rate`, `function clk_busy_divider_determine_rate`, `function clk_busy_divider_set_rate`, `function clk_busy_mux_get_parent`, `function clk_busy_mux_set_parent`.
- Atlas domain: Driver Families / drivers/clk.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.