drivers/clk/mediatek/clk-pll.c
Source file repositories/reference/linux-study-clean/drivers/clk/mediatek/clk-pll.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/clk/mediatek/clk-pll.c- Extension
.c- Size
- 11627 bytes
- Lines
- 504
- 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/clk-provider.hlinux/container_of.hlinux/delay.hlinux/err.hlinux/io.hlinux/module.hlinux/of_address.hlinux/platform_device.hlinux/slab.hclk-pll.h
Detected Declarations
function Copyrightfunction mtk_pll_fenc_is_preparedfunction __mtk_pll_recalc_ratefunction __mtk_pll_tuner_enablefunction __mtk_pll_tuner_disablefunction mtk_pll_set_rate_regsfunction mtk_pll_calc_valuesfunction mtk_pll_set_ratefunction mtk_pll_recalc_ratefunction mtk_pll_determine_ratefunction mtk_pll_preparefunction mtk_pll_unpreparefunction mtk_pll_prepare_setclrfunction mtk_pll_unprepare_setclrfunction mtk_clk_unregister_pllfunction mtk_clk_register_pllsfunction mtk_clk_unregister_pllsexport mtk_pll_fenc_clr_set_opsexport mtk_clk_register_pllsexport mtk_clk_unregister_plls
Annotated Snippet
if (!IS_ERR_OR_NULL(clk_data->hws[pll->id])) {
pr_warn("%pOF: Trying to register duplicate clock ID: %d\n",
dev->of_node, pll->id);
continue;
}
hw = mtk_clk_register_pll(dev, pll, base);
if (IS_ERR(hw)) {
pr_err("Failed to register clk %s: %pe\n", pll->name,
hw);
goto err;
}
clk_data->hws[pll->id] = hw;
}
return 0;
err:
while (--i >= 0) {
const struct mtk_pll_data *pll = &plls[i];
mtk_clk_unregister_pll(clk_data->hws[pll->id]);
clk_data->hws[pll->id] = ERR_PTR(-ENOENT);
}
iounmap(base);
return PTR_ERR(hw);
}
EXPORT_SYMBOL_GPL(mtk_clk_register_plls);
__iomem void *mtk_clk_pll_get_base(struct clk_hw *hw,
const struct mtk_pll_data *data)
{
struct mtk_clk_pll *pll = to_mtk_clk_pll(hw);
return pll->base_addr - data->reg;
}
void mtk_clk_unregister_plls(const struct mtk_pll_data *plls, int num_plls,
struct clk_hw_onecell_data *clk_data)
{
__iomem void *base = NULL;
int i;
if (!clk_data)
return;
for (i = num_plls; i > 0; i--) {
const struct mtk_pll_data *pll = &plls[i - 1];
if (IS_ERR_OR_NULL(clk_data->hws[pll->id]))
continue;
/*
* This is quite ugly but unfortunately the clks don't have
* any device tied to them, so there's no place to store the
* pointer to the I/O region base address. We have to fetch
* it from one of the registered clks.
*/
base = mtk_clk_pll_get_base(clk_data->hws[pll->id], pll);
mtk_clk_unregister_pll(clk_data->hws[pll->id]);
clk_data->hws[pll->id] = ERR_PTR(-ENOENT);
}
iounmap(base);
}
EXPORT_SYMBOL_GPL(mtk_clk_unregister_plls);
MODULE_LICENSE("GPL");
Annotation
- Immediate include surface: `linux/clk-provider.h`, `linux/container_of.h`, `linux/delay.h`, `linux/err.h`, `linux/io.h`, `linux/module.h`, `linux/of_address.h`, `linux/platform_device.h`.
- Detected declarations: `function Copyright`, `function mtk_pll_fenc_is_prepared`, `function __mtk_pll_recalc_rate`, `function __mtk_pll_tuner_enable`, `function __mtk_pll_tuner_disable`, `function mtk_pll_set_rate_regs`, `function mtk_pll_calc_values`, `function mtk_pll_set_rate`, `function mtk_pll_recalc_rate`, `function mtk_pll_determine_rate`.
- 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.