drivers/clk/renesas/clk-vbattb.c
Source file repositories/reference/linux-study-clean/drivers/clk/renesas/clk-vbattb.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/clk/renesas/clk-vbattb.c- Extension
.c- Size
- 5177 bytes
- Lines
- 206
- 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- 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-provider.hlinux/device.hlinux/io.hlinux/mod_devicetable.hlinux/of.hlinux/platform_device.hlinux/pm_runtime.hlinux/reset.hdt-bindings/clock/renesas,r9a08g045-vbattb.h
Detected Declarations
struct vbattb_clkfunction vbattb_clk_validate_load_capacitancefunction vbattb_clk_actionfunction vbattb_clk_probe
Annotated Snippet
struct vbattb_clk {
void __iomem *base;
spinlock_t lock;
};
static int vbattb_clk_validate_load_capacitance(u32 *reg_lc, u32 of_lc)
{
switch (of_lc) {
case 4000:
*reg_lc = VBATTB_XOSCCR_XSEL_4_PF;
break;
case 7000:
*reg_lc = VBATTB_XOSCCR_XSEL_7_PF;
break;
case 9000:
*reg_lc = VBATTB_XOSCCR_XSEL_9_PF;
break;
case 12500:
*reg_lc = VBATTB_XOSCCR_XSEL_12_5_PF;
break;
default:
return -EINVAL;
}
return 0;
}
static void vbattb_clk_action(void *data)
{
struct device *dev = data;
struct reset_control *rstc = dev_get_drvdata(dev);
int ret;
ret = reset_control_assert(rstc);
if (ret)
dev_err(dev, "Failed to de-assert reset!\n");
ret = pm_runtime_put_sync(dev);
if (ret < 0)
dev_err(dev, "Failed to runtime suspend!\n");
of_clk_del_provider(dev->of_node);
}
static int vbattb_clk_probe(struct platform_device *pdev)
{
struct device_node *np = pdev->dev.of_node;
struct clk_parent_data parent_data = {};
struct clk_hw_onecell_data *clk_data;
const struct clk_hw *parent_hws[2];
struct device *dev = &pdev->dev;
struct reset_control *rstc;
struct vbattb_clk *vbclk;
u32 of_lc, reg_lc;
struct clk_hw *hw;
/* 4 clocks are exported: VBATTB_XC, VBATTB_XBYP, VBATTB_MUX, VBATTB_VBATTCLK. */
u8 num_clks = 4;
int ret;
/* Default to 4pF as this is not needed if external clock device is connected. */
of_lc = 4000;
of_property_read_u32(np, "quartz-load-femtofarads", &of_lc);
ret = vbattb_clk_validate_load_capacitance(®_lc, of_lc);
if (ret)
return ret;
vbclk = devm_kzalloc(dev, sizeof(*vbclk), GFP_KERNEL);
if (!vbclk)
return -ENOMEM;
clk_data = devm_kzalloc(dev, struct_size(clk_data, hws, num_clks), GFP_KERNEL);
if (!clk_data)
return -ENOMEM;
clk_data->num = num_clks;
vbclk->base = devm_platform_ioremap_resource(pdev, 0);
if (IS_ERR(vbclk->base))
return PTR_ERR(vbclk->base);
ret = devm_pm_runtime_enable(dev);
if (ret)
return ret;
rstc = devm_reset_control_get_shared(dev, NULL);
if (IS_ERR(rstc))
return PTR_ERR(rstc);
ret = pm_runtime_resume_and_get(dev);
if (ret)
Annotation
- Immediate include surface: `linux/cleanup.h`, `linux/clk-provider.h`, `linux/device.h`, `linux/io.h`, `linux/mod_devicetable.h`, `linux/of.h`, `linux/platform_device.h`, `linux/pm_runtime.h`.
- Detected declarations: `struct vbattb_clk`, `function vbattb_clk_validate_load_capacitance`, `function vbattb_clk_action`, `function vbattb_clk_probe`.
- Atlas domain: Driver Families / drivers/clk.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
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.