drivers/clk/hisilicon/clk.c
Source file repositories/reference/linux-study-clean/drivers/clk/hisilicon/clk.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/clk/hisilicon/clk.c- Extension
.c- Size
- 7769 bytes
- Lines
- 344
- 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/kernel.hlinux/clkdev.hlinux/clk-provider.hlinux/delay.hlinux/io.hlinux/of.hlinux/of_address.hlinux/platform_device.hlinux/slab.hclk.h
Detected Declarations
function hisi_clk_register_fixed_ratefunction hisi_clk_register_fixed_factorfunction hisi_clk_register_muxfunction hisi_clk_register_phasefunction hisi_clk_register_dividerfunction hisi_clk_register_gatefunction hisi_clk_register_gate_sepfunction hi6220_clk_register_dividerexport hisi_clk_allocexport hisi_clk_initexport hisi_clk_register_fixed_rateexport hisi_clk_register_fixed_factorexport hisi_clk_register_muxexport hisi_clk_register_phaseexport hisi_clk_register_dividerexport hisi_clk_register_gateexport hisi_clk_register_gate_sep
Annotated Snippet
if (IS_ERR(clk)) {
pr_err("%s: failed to register clock %s\n",
__func__, clks[i].name);
goto err;
}
data->clk_data.clks[clks[i].id] = clk;
}
return 0;
err:
while (i--)
clk_unregister_fixed_rate(data->clk_data.clks[clks[i].id]);
return PTR_ERR(clk);
}
EXPORT_SYMBOL_GPL(hisi_clk_register_fixed_rate);
int hisi_clk_register_fixed_factor(const struct hisi_fixed_factor_clock *clks,
int nums,
struct hisi_clock_data *data)
{
struct clk *clk;
int i;
for (i = 0; i < nums; i++) {
clk = clk_register_fixed_factor(NULL, clks[i].name,
clks[i].parent_name,
clks[i].flags, clks[i].mult,
clks[i].div);
if (IS_ERR(clk)) {
pr_err("%s: failed to register clock %s\n",
__func__, clks[i].name);
goto err;
}
data->clk_data.clks[clks[i].id] = clk;
}
return 0;
err:
while (i--)
clk_unregister_fixed_factor(data->clk_data.clks[clks[i].id]);
return PTR_ERR(clk);
}
EXPORT_SYMBOL_GPL(hisi_clk_register_fixed_factor);
int hisi_clk_register_mux(const struct hisi_mux_clock *clks,
int nums, struct hisi_clock_data *data)
{
struct clk *clk;
void __iomem *base = data->base;
int i;
for (i = 0; i < nums; i++) {
u32 mask = BIT(clks[i].width) - 1;
clk = clk_register_mux_table(NULL, clks[i].name,
clks[i].parent_names,
clks[i].num_parents, clks[i].flags,
base + clks[i].offset, clks[i].shift,
mask, clks[i].mux_flags,
clks[i].table, &hisi_clk_lock);
if (IS_ERR(clk)) {
pr_err("%s: failed to register clock %s\n",
__func__, clks[i].name);
goto err;
}
if (clks[i].alias)
clk_register_clkdev(clk, clks[i].alias, NULL);
data->clk_data.clks[clks[i].id] = clk;
}
return 0;
err:
while (i--)
clk_unregister_mux(data->clk_data.clks[clks[i].id]);
return PTR_ERR(clk);
}
EXPORT_SYMBOL_GPL(hisi_clk_register_mux);
int hisi_clk_register_phase(struct device *dev,
const struct hisi_phase_clock *clks,
int nums, struct hisi_clock_data *data)
{
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/clkdev.h`, `linux/clk-provider.h`, `linux/delay.h`, `linux/io.h`, `linux/of.h`, `linux/of_address.h`, `linux/platform_device.h`.
- Detected declarations: `function hisi_clk_register_fixed_rate`, `function hisi_clk_register_fixed_factor`, `function hisi_clk_register_mux`, `function hisi_clk_register_phase`, `function hisi_clk_register_divider`, `function hisi_clk_register_gate`, `function hisi_clk_register_gate_sep`, `function hi6220_clk_register_divider`, `export hisi_clk_alloc`, `export hisi_clk_init`.
- 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.