drivers/clk/clk-versaclock5.c
Source file repositories/reference/linux-study-clean/drivers/clk/clk-versaclock5.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/clk/clk-versaclock5.c- Extension
.c- Size
- 37790 bytes
- Lines
- 1356
- 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/clk.hlinux/clk-provider.hlinux/delay.hlinux/i2c.hlinux/interrupt.hlinux/mod_devicetable.hlinux/module.hlinux/of.hlinux/property.hlinux/regmap.hlinux/slab.hdt-bindings/clock/versaclock.h
Detected Declarations
struct vc5_chip_infostruct vc5_driver_datastruct vc5_hw_datastruct vc5_out_datastruct vc5_driver_dataenum vc5_modelfunction vc5_regmap_is_writeablefunction vc5_mux_get_parentfunction vc5_mux_set_parentfunction vc5_dbl_recalc_ratefunction vc5_dbl_determine_ratefunction vc5_dbl_set_ratefunction vc5_pfd_recalc_ratefunction vc5_pfd_determine_ratefunction vc5_pfd_set_ratefunction vc5_pll_recalc_ratefunction vc5_pll_determine_ratefunction vc5_pll_set_ratefunction vc5_fod_recalc_ratefunction vc5_fod_determine_ratefunction vc5_fod_set_ratefunction vc5_clk_out_preparefunction vc5_clk_out_unpreparefunction vc5_clk_out_get_parentfunction vc5_clk_out_set_parentfunction vc5_map_index_to_outputfunction vc5_update_modefunction vc5_update_powerfunction vc5_map_cap_valuefunction vc5_update_cap_loadfunction vc5_update_slewfunction vc5_get_output_configfunction vc5_probefunction vc5_removefunction vc5_suspendfunction vc5_resume
Annotated Snippet
struct vc5_chip_info {
const enum vc5_model model;
const unsigned int clk_fod_cnt;
const unsigned int clk_out_cnt;
const u32 flags;
const unsigned long vco_max;
};
struct vc5_driver_data;
struct vc5_hw_data {
struct clk_hw hw;
struct vc5_driver_data *vc5;
u32 div_int;
u32 div_frc;
unsigned int num;
};
struct vc5_out_data {
struct clk_hw hw;
struct vc5_driver_data *vc5;
unsigned int num;
unsigned int clk_output_cfg0;
unsigned int clk_output_cfg0_mask;
};
struct vc5_driver_data {
struct i2c_client *client;
struct regmap *regmap;
const struct vc5_chip_info *chip_info;
struct clk *pin_xin;
struct clk *pin_clkin;
unsigned char clk_mux_ins;
struct clk_hw clk_mux;
struct clk_hw clk_mul;
struct clk_hw clk_pfd;
struct vc5_hw_data clk_pll;
struct vc5_hw_data clk_fod[VC5_MAX_FOD_NUM];
struct vc5_out_data clk_out[VC5_MAX_CLK_OUT_NUM];
};
/*
* VersaClock5 i2c regmap
*/
static bool vc5_regmap_is_writeable(struct device *dev, unsigned int reg)
{
/* Factory reserved regs, make them read-only */
if (reg <= 0xf)
return false;
/* Factory reserved regs, make them read-only */
if (reg == 0x14 || reg == 0x1c || reg == 0x1d)
return false;
return true;
}
static const struct regmap_config vc5_regmap_config = {
.reg_bits = 8,
.val_bits = 8,
.cache_type = REGCACHE_MAPLE,
.max_register = 0x76,
.writeable_reg = vc5_regmap_is_writeable,
};
/*
* VersaClock5 input multiplexer between XTAL and CLKIN divider
*/
static unsigned char vc5_mux_get_parent(struct clk_hw *hw)
{
struct vc5_driver_data *vc5 =
container_of(hw, struct vc5_driver_data, clk_mux);
const u8 mask = VC5_PRIM_SRC_SHDN_EN_XTAL | VC5_PRIM_SRC_SHDN_EN_CLKIN;
unsigned int src;
int ret;
ret = regmap_read(vc5->regmap, VC5_PRIM_SRC_SHDN, &src);
if (ret)
return 0;
src &= mask;
if (src == VC5_PRIM_SRC_SHDN_EN_XTAL)
return 0;
if (src == VC5_PRIM_SRC_SHDN_EN_CLKIN)
return 1;
dev_warn(&vc5->client->dev,
Annotation
- Immediate include surface: `linux/clk.h`, `linux/clk-provider.h`, `linux/delay.h`, `linux/i2c.h`, `linux/interrupt.h`, `linux/mod_devicetable.h`, `linux/module.h`, `linux/of.h`.
- Detected declarations: `struct vc5_chip_info`, `struct vc5_driver_data`, `struct vc5_hw_data`, `struct vc5_out_data`, `struct vc5_driver_data`, `enum vc5_model`, `function vc5_regmap_is_writeable`, `function vc5_mux_get_parent`, `function vc5_mux_set_parent`, `function vc5_dbl_recalc_rate`.
- 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.