drivers/clk/ti/clk.c
Source file repositories/reference/linux-study-clean/drivers/clk/ti/clk.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/clk/ti/clk.c- Extension
.c- Size
- 16717 bytes
- Lines
- 691
- 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/cleanup.hlinux/clk.hlinux/clk-provider.hlinux/clkdev.hlinux/clk/ti.hlinux/io.hlinux/of.hlinux/of_address.hlinux/list.hlinux/minmax.hlinux/regmap.hlinux/string_helpers.hlinux/memblock.hlinux/device.hclock.h
Detected Declarations
struct clk_iomapstruct clk_init_itemfunction clk_memmap_writelfunction _clk_rmwfunction clk_memmap_rmwfunction clk_memmap_readlfunction ti_clk_setup_ll_opsfunction ti_dt_clocks_registerfunction ti_clk_retry_initfunction ti_clk_get_reg_addrfunction ti_clk_get_legacy_bit_shiftfunction ti_clk_latchfunction omap2_clk_provider_initfunction omap2_clk_legacy_provider_initfunction nodefunction ti_clk_add_aliasesfunction for_each_matching_nodefunction ti_clk_setup_featuresfunction omap2_clk_enable_init_clocksfunction ti_clk_add_aliasfunction omap2_clk_for_eachfunction list_for_each_entryfunction omap2_clk_is_hw_omapfunction list_for_each_entry
Annotated Snippet
struct clk_iomap {
struct regmap *regmap;
void __iomem *mem;
};
static struct clk_iomap *clk_memmaps[CLK_MAX_MEMMAPS];
static void clk_memmap_writel(u32 val, const struct clk_omap_reg *reg)
{
struct clk_iomap *io = clk_memmaps[reg->index];
if (reg->ptr)
writel_relaxed(val, reg->ptr);
else if (io->regmap)
regmap_write(io->regmap, reg->offset, val);
else
writel_relaxed(val, io->mem + reg->offset);
}
static void _clk_rmw(u32 val, u32 mask, void __iomem *ptr)
{
u32 v;
v = readl_relaxed(ptr);
v &= ~mask;
v |= val;
writel_relaxed(v, ptr);
}
static void clk_memmap_rmw(u32 val, u32 mask, const struct clk_omap_reg *reg)
{
struct clk_iomap *io = clk_memmaps[reg->index];
if (reg->ptr) {
_clk_rmw(val, mask, reg->ptr);
} else if (io->regmap) {
regmap_update_bits(io->regmap, reg->offset, mask, val);
} else {
_clk_rmw(val, mask, io->mem + reg->offset);
}
}
static u32 clk_memmap_readl(const struct clk_omap_reg *reg)
{
u32 val;
struct clk_iomap *io = clk_memmaps[reg->index];
if (reg->ptr)
val = readl_relaxed(reg->ptr);
else if (io->regmap)
regmap_read(io->regmap, reg->offset, &val);
else
val = readl_relaxed(io->mem + reg->offset);
return val;
}
/**
* ti_clk_setup_ll_ops - setup low level clock operations
* @ops: low level clock ops descriptor
*
* Sets up low level clock operations for TI clock driver. This is used
* to provide various callbacks for the clock driver towards platform
* specific code. Returns 0 on success, -EBUSY if ll_ops have been
* registered already.
*/
int ti_clk_setup_ll_ops(struct ti_clk_ll_ops *ops)
{
if (ti_clk_ll_ops) {
pr_err("Attempt to register ll_ops multiple times.\n");
return -EBUSY;
}
ti_clk_ll_ops = ops;
ops->clk_readl = clk_memmap_readl;
ops->clk_writel = clk_memmap_writel;
ops->clk_rmw = clk_memmap_rmw;
return 0;
}
/*
* Eventually we could standardize to using '_' for clk-*.c files to follow the
* TRM naming.
*/
static struct device_node *ti_find_clock_provider(const char *name)
{
char *tmp __free(kfree) = NULL;
struct device_node *np;
char *p;
Annotation
- Immediate include surface: `linux/cleanup.h`, `linux/clk.h`, `linux/clk-provider.h`, `linux/clkdev.h`, `linux/clk/ti.h`, `linux/io.h`, `linux/of.h`, `linux/of_address.h`.
- Detected declarations: `struct clk_iomap`, `struct clk_init_item`, `function clk_memmap_writel`, `function _clk_rmw`, `function clk_memmap_rmw`, `function clk_memmap_readl`, `function ti_clk_setup_ll_ops`, `function ti_dt_clocks_register`, `function ti_clk_retry_init`, `function ti_clk_get_reg_addr`.
- 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.