drivers/clk/mediatek/clk-mtk.c
Source file repositories/reference/linux-study-clean/drivers/clk/mediatek/clk-mtk.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/clk/mediatek/clk-mtk.c- Extension
.c- Size
- 16200 bytes
- Lines
- 707
- Domain
- Driver Families
- Bucket
- drivers/clk
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- 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/bitops.hlinux/clk-provider.hlinux/err.hlinux/io.hlinux/mfd/syscon.hlinux/module.hlinux/of.hlinux/of_address.hlinux/platform_device.hlinux/pm_runtime.hlinux/slab.hclk-mtk.hclk-gate.hclk-mux.h
Detected Declarations
function mtk_clk_dummy_enablefunction mtk_clk_dummy_disablefunction mtk_init_clk_datafunction mtk_free_clk_datafunction mtk_clk_register_fixed_clksfunction mtk_clk_unregister_fixed_clksfunction mtk_clk_register_factorsfunction mtk_clk_unregister_factorsfunction mtk_clk_unregister_compositefunction mtk_clk_register_compositesfunction mtk_clk_unregister_compositesfunction mtk_clk_register_dividersfunction mtk_clk_unregister_dividersfunction __mtk_clk_simple_probefunction __mtk_clk_simple_removefunction mtk_clk_pdev_probefunction mtk_clk_simple_probefunction mtk_clk_pdev_removefunction mtk_clk_simple_removeexport cg_regs_dummyexport mtk_clk_dummy_opsexport mtk_devm_alloc_clk_dataexport mtk_alloc_clk_dataexport mtk_free_clk_dataexport mtk_clk_register_fixed_clksexport mtk_clk_unregister_fixed_clksexport mtk_clk_register_factorsexport mtk_clk_unregister_factorsexport mtk_clk_register_compositesexport mtk_clk_unregister_compositesexport mtk_clk_register_dividersexport mtk_clk_unregister_dividersexport mtk_clk_pdev_probeexport mtk_clk_simple_probeexport mtk_clk_pdev_removeexport mtk_clk_simple_removeexport mtk_clk_get_hwv_regmap
Annotated Snippet
static void mtk_clk_dummy_disable(struct clk_hw *hw) { }
const struct clk_ops mtk_clk_dummy_ops = {
.enable = mtk_clk_dummy_enable,
.disable = mtk_clk_dummy_disable,
};
EXPORT_SYMBOL_GPL(mtk_clk_dummy_ops);
static void mtk_init_clk_data(struct clk_hw_onecell_data *clk_data,
unsigned int clk_num)
{
int i;
clk_data->num = clk_num;
for (i = 0; i < clk_num; i++)
clk_data->hws[i] = ERR_PTR(-ENOENT);
}
struct clk_hw_onecell_data *mtk_devm_alloc_clk_data(struct device *dev,
unsigned int clk_num)
{
struct clk_hw_onecell_data *clk_data;
clk_data = devm_kzalloc(dev, struct_size(clk_data, hws, clk_num),
GFP_KERNEL);
if (!clk_data)
return NULL;
mtk_init_clk_data(clk_data, clk_num);
return clk_data;
}
EXPORT_SYMBOL_GPL(mtk_devm_alloc_clk_data);
struct clk_hw_onecell_data *mtk_alloc_clk_data(unsigned int clk_num)
{
struct clk_hw_onecell_data *clk_data;
clk_data = kzalloc_flex(*clk_data, hws, clk_num);
if (!clk_data)
return NULL;
mtk_init_clk_data(clk_data, clk_num);
return clk_data;
}
EXPORT_SYMBOL_GPL(mtk_alloc_clk_data);
void mtk_free_clk_data(struct clk_hw_onecell_data *clk_data)
{
kfree(clk_data);
}
EXPORT_SYMBOL_GPL(mtk_free_clk_data);
int mtk_clk_register_fixed_clks(const struct mtk_fixed_clk *clks, int num,
struct clk_hw_onecell_data *clk_data)
{
int i;
struct clk_hw *hw;
if (!clk_data)
return -ENOMEM;
for (i = 0; i < num; i++) {
const struct mtk_fixed_clk *rc = &clks[i];
if (!IS_ERR_OR_NULL(clk_data->hws[rc->id])) {
pr_warn("Trying to register duplicate clock ID: %d\n", rc->id);
continue;
}
hw = clk_hw_register_fixed_rate(NULL, rc->name, rc->parent, 0,
rc->rate);
if (IS_ERR(hw)) {
pr_err("Failed to register clk %s: %pe\n", rc->name,
hw);
goto err;
}
clk_data->hws[rc->id] = hw;
}
return 0;
err:
while (--i >= 0) {
const struct mtk_fixed_clk *rc = &clks[i];
Annotation
- Immediate include surface: `linux/bitops.h`, `linux/clk-provider.h`, `linux/err.h`, `linux/io.h`, `linux/mfd/syscon.h`, `linux/module.h`, `linux/of.h`, `linux/of_address.h`.
- Detected declarations: `function mtk_clk_dummy_enable`, `function mtk_clk_dummy_disable`, `function mtk_init_clk_data`, `function mtk_free_clk_data`, `function mtk_clk_register_fixed_clks`, `function mtk_clk_unregister_fixed_clks`, `function mtk_clk_register_factors`, `function mtk_clk_unregister_factors`, `function mtk_clk_unregister_composite`, `function mtk_clk_register_composites`.
- Atlas domain: Driver Families / drivers/clk.
- Implementation status: integration 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.