drivers/clk/ti/autoidle.c
Source file repositories/reference/linux-study-clean/drivers/clk/ti/autoidle.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/clk/ti/autoidle.c- Extension
.c- Size
- 5454 bytes
- Lines
- 258
- 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- 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/clk-provider.hlinux/slab.hlinux/io.hlinux/of.hlinux/of_address.hlinux/clk/ti.hclock.h
Detected Declarations
struct clk_ti_autoidlefunction _omap2_clk_deny_idlefunction _omap2_clk_allow_idlefunction omap2_clk_deny_idlefunction omap2_clk_allow_idlefunction _allow_autoidlefunction _deny_autoidlefunction _clk_generic_allow_autoidle_allfunction _clk_generic_deny_autoidle_allfunction notfunction omap2_clk_enable_autoidle_allfunction omap2_clk_disable_autoidle_all
Annotated Snippet
struct clk_ti_autoidle {
struct clk_omap_reg reg;
u8 shift;
u8 flags;
const char *name;
struct list_head node;
};
#define AUTOIDLE_LOW 0x1
static LIST_HEAD(autoidle_clks);
/*
* we have some non-atomic read/write
* operations behind it, so let's
* take one lock for handling autoidle
* of all clocks
*/
static DEFINE_SPINLOCK(autoidle_spinlock);
static int _omap2_clk_deny_idle(struct clk_hw_omap *clk)
{
if (clk->ops && clk->ops->deny_idle) {
unsigned long irqflags;
spin_lock_irqsave(&autoidle_spinlock, irqflags);
clk->autoidle_count++;
if (clk->autoidle_count == 1)
clk->ops->deny_idle(clk);
spin_unlock_irqrestore(&autoidle_spinlock, irqflags);
}
return 0;
}
static int _omap2_clk_allow_idle(struct clk_hw_omap *clk)
{
if (clk->ops && clk->ops->allow_idle) {
unsigned long irqflags;
spin_lock_irqsave(&autoidle_spinlock, irqflags);
clk->autoidle_count--;
if (clk->autoidle_count == 0)
clk->ops->allow_idle(clk);
spin_unlock_irqrestore(&autoidle_spinlock, irqflags);
}
return 0;
}
/**
* omap2_clk_deny_idle - disable autoidle on an OMAP clock
* @clk: struct clk * to disable autoidle for
*
* Disable autoidle on an OMAP clock.
*/
int omap2_clk_deny_idle(struct clk *clk)
{
struct clk_hw *hw;
if (!clk)
return -EINVAL;
hw = __clk_get_hw(clk);
if (omap2_clk_is_hw_omap(hw)) {
struct clk_hw_omap *c = to_clk_hw_omap(hw);
return _omap2_clk_deny_idle(c);
}
return -EINVAL;
}
/**
* omap2_clk_allow_idle - enable autoidle on an OMAP clock
* @clk: struct clk * to enable autoidle for
*
* Enable autoidle on an OMAP clock.
*/
int omap2_clk_allow_idle(struct clk *clk)
{
struct clk_hw *hw;
if (!clk)
return -EINVAL;
hw = __clk_get_hw(clk);
if (omap2_clk_is_hw_omap(hw)) {
Annotation
- Immediate include surface: `linux/clk-provider.h`, `linux/slab.h`, `linux/io.h`, `linux/of.h`, `linux/of_address.h`, `linux/clk/ti.h`, `clock.h`.
- Detected declarations: `struct clk_ti_autoidle`, `function _omap2_clk_deny_idle`, `function _omap2_clk_allow_idle`, `function omap2_clk_deny_idle`, `function omap2_clk_allow_idle`, `function _allow_autoidle`, `function _deny_autoidle`, `function _clk_generic_allow_autoidle_all`, `function _clk_generic_deny_autoidle_all`, `function not`.
- Atlas domain: Driver Families / drivers/clk.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
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.