drivers/clk/sifive/sifive-prci.c
Source file repositories/reference/linux-study-clean/drivers/clk/sifive/sifive-prci.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/clk/sifive/sifive-prci.c- Extension
.c- Size
- 16644 bytes
- Lines
- 621
- 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/delay.hlinux/io.hlinux/module.hlinux/of.hsifive-prci.hfu540-prci.hfu740-prci.h
Detected Declarations
function Copyrightfunction __prci_writelfunction __prci_wrpll_unpackfunction __prci_wrpll_packfunction __prci_wrpll_read_cfg0function __prci_wrpll_write_cfg0function __prci_wrpll_write_cfg1function sifive_prci_wrpll_recalc_ratefunction sifive_prci_wrpll_determine_ratefunction sifive_prci_wrpll_set_ratefunction sifive_clk_is_enabledfunction sifive_prci_clock_enablefunction sifive_prci_clock_disablefunction sifive_prci_tlclksel_recalc_ratefunction sifive_prci_hfpclkplldiv_recalc_ratefunction sifive_prci_coreclksel_use_hfclkfunction sifive_prci_coreclksel_use_corepllfunction sifive_prci_coreclksel_use_final_corepllfunction sifive_prci_corepllsel_use_dvfscorepllfunction sifive_prci_corepllsel_use_corepllfunction sifive_prci_hfpclkpllsel_use_hfclkfunction sifive_prci_hfpclkpllsel_use_hfpclkpllfunction sifive_prci_pcie_aux_clock_is_enabledfunction sifive_prci_pcie_aux_clock_enablefunction sifive_prci_pcie_aux_clock_disablefunction __prci_register_clocksfunction sifive_prci_probe
Annotated Snippet
if (r) {
dev_warn(dev, "Failed to register clock %s: %d\n",
init.name, r);
return r;
}
pd->hw_clks.hws[i] = &pic->hw;
}
pd->hw_clks.num = i;
r = devm_of_clk_add_hw_provider(dev, of_clk_hw_onecell_get,
&pd->hw_clks);
if (r) {
dev_err(dev, "could not add hw_provider: %d\n", r);
return r;
}
return 0;
}
/**
* sifive_prci_probe() - initialize prci data and check parent count
* @pdev: platform device pointer for the prci
*
* Return: 0 upon success or a negative error code upon failure.
*/
static int sifive_prci_probe(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
struct __prci_data *pd;
const struct prci_clk_desc *desc;
int r;
desc = of_device_get_match_data(&pdev->dev);
pd = devm_kzalloc(dev, struct_size(pd, hw_clks.hws, desc->num_clks), GFP_KERNEL);
if (!pd)
return -ENOMEM;
pd->va = devm_platform_ioremap_resource(pdev, 0);
if (IS_ERR(pd->va))
return PTR_ERR(pd->va);
pd->reset.rcdev.owner = THIS_MODULE;
pd->reset.rcdev.nr_resets = PRCI_RST_NR;
pd->reset.rcdev.ops = &reset_simple_ops;
pd->reset.rcdev.of_node = pdev->dev.of_node;
pd->reset.active_low = true;
pd->reset.membase = pd->va + PRCI_DEVICESRESETREG_OFFSET;
spin_lock_init(&pd->reset.lock);
r = devm_reset_controller_register(&pdev->dev, &pd->reset.rcdev);
if (r) {
dev_err(dev, "could not register reset controller: %d\n", r);
return r;
}
r = __prci_register_clocks(dev, pd, desc);
if (r) {
dev_err(dev, "could not register clocks: %d\n", r);
return r;
}
dev_dbg(dev, "SiFive PRCI probed\n");
return 0;
}
static const struct of_device_id sifive_prci_of_match[] = {
{.compatible = "sifive,fu540-c000-prci", .data = &prci_clk_fu540},
{.compatible = "sifive,fu740-c000-prci", .data = &prci_clk_fu740},
{}
};
MODULE_DEVICE_TABLE(of, sifive_prci_of_match);
static struct platform_driver sifive_prci_driver = {
.driver = {
.name = "sifive-clk-prci",
.of_match_table = sifive_prci_of_match,
},
.probe = sifive_prci_probe,
};
module_platform_driver(sifive_prci_driver);
MODULE_AUTHOR("Paul Walmsley <paul.walmsley@sifive.com>");
MODULE_DESCRIPTION("SiFive Power Reset Clock Interface (PRCI) driver");
MODULE_LICENSE("GPL");
Annotation
- Immediate include surface: `linux/delay.h`, `linux/io.h`, `linux/module.h`, `linux/of.h`, `sifive-prci.h`, `fu540-prci.h`, `fu740-prci.h`.
- Detected declarations: `function Copyright`, `function __prci_writel`, `function __prci_wrpll_unpack`, `function __prci_wrpll_pack`, `function __prci_wrpll_read_cfg0`, `function __prci_wrpll_write_cfg0`, `function __prci_wrpll_write_cfg1`, `function sifive_prci_wrpll_recalc_rate`, `function sifive_prci_wrpll_determine_rate`, `function sifive_prci_wrpll_set_rate`.
- 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.