drivers/clk/versatile/clk-vexpress-osc.c
Source file repositories/reference/linux-study-clean/drivers/clk/versatile/clk-vexpress-osc.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/clk/versatile/clk-vexpress-osc.c- Extension
.c- Size
- 2903 bytes
- Lines
- 124
- 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/clkdev.hlinux/clk-provider.hlinux/err.hlinux/module.hlinux/of.hlinux/platform_device.hlinux/slab.hlinux/vexpress.h
Detected Declarations
struct vexpress_oscfunction vexpress_osc_recalc_ratefunction vexpress_osc_determine_ratefunction vexpress_osc_set_ratefunction vexpress_osc_probe
Annotated Snippet
struct vexpress_osc {
struct regmap *reg;
struct clk_hw hw;
unsigned long rate_min;
unsigned long rate_max;
};
#define to_vexpress_osc(osc) container_of(osc, struct vexpress_osc, hw)
static unsigned long vexpress_osc_recalc_rate(struct clk_hw *hw,
unsigned long parent_rate)
{
struct vexpress_osc *osc = to_vexpress_osc(hw);
u32 rate;
regmap_read(osc->reg, 0, &rate);
return rate;
}
static int vexpress_osc_determine_rate(struct clk_hw *hw,
struct clk_rate_request *req)
{
struct vexpress_osc *osc = to_vexpress_osc(hw);
if (osc->rate_min && req->rate < osc->rate_min)
req->rate = osc->rate_min;
if (osc->rate_max && req->rate > osc->rate_max)
req->rate = osc->rate_max;
return 0;
}
static int vexpress_osc_set_rate(struct clk_hw *hw, unsigned long rate,
unsigned long parent_rate)
{
struct vexpress_osc *osc = to_vexpress_osc(hw);
return regmap_write(osc->reg, 0, rate);
}
static const struct clk_ops vexpress_osc_ops = {
.recalc_rate = vexpress_osc_recalc_rate,
.determine_rate = vexpress_osc_determine_rate,
.set_rate = vexpress_osc_set_rate,
};
static int vexpress_osc_probe(struct platform_device *pdev)
{
struct clk_init_data init;
struct vexpress_osc *osc;
u32 range[2];
int ret;
osc = devm_kzalloc(&pdev->dev, sizeof(*osc), GFP_KERNEL);
if (!osc)
return -ENOMEM;
osc->reg = devm_regmap_init_vexpress_config(&pdev->dev);
if (IS_ERR(osc->reg))
return PTR_ERR(osc->reg);
if (of_property_read_u32_array(pdev->dev.of_node, "freq-range", range,
ARRAY_SIZE(range)) == 0) {
osc->rate_min = range[0];
osc->rate_max = range[1];
}
if (of_property_read_string(pdev->dev.of_node, "clock-output-names",
&init.name) != 0)
init.name = dev_name(&pdev->dev);
init.ops = &vexpress_osc_ops;
init.flags = 0;
init.num_parents = 0;
osc->hw.init = &init;
ret = devm_clk_hw_register(&pdev->dev, &osc->hw);
if (ret < 0)
return ret;
devm_of_clk_add_hw_provider(&pdev->dev, of_clk_hw_simple_get, &osc->hw);
clk_hw_set_rate_range(&osc->hw, osc->rate_min, osc->rate_max);
dev_dbg(&pdev->dev, "Registered clock '%s'\n", init.name);
return 0;
Annotation
- Immediate include surface: `linux/clkdev.h`, `linux/clk-provider.h`, `linux/err.h`, `linux/module.h`, `linux/of.h`, `linux/platform_device.h`, `linux/slab.h`, `linux/vexpress.h`.
- Detected declarations: `struct vexpress_osc`, `function vexpress_osc_recalc_rate`, `function vexpress_osc_determine_rate`, `function vexpress_osc_set_rate`, `function vexpress_osc_probe`.
- 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.