drivers/clk/clk-lmk04832.c

Source file repositories/reference/linux-study-clean/drivers/clk/clk-lmk04832.c

File Facts

System
Linux kernel
Corpus path
drivers/clk/clk-lmk04832.c
Extension
.c
Size
44430 bytes
Lines
1580
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.

Dependency Surface

Detected Declarations

Annotated Snippet

struct lmk04832_device_info {
	u16 pid;
	u8 maskrev;
	size_t num_channels;
	unsigned int vco0_range[2];
	unsigned int vco1_range[2];
};

static const struct lmk04832_device_info lmk04832_device_info[] = {
	[LMK04832] = {
		.pid = 0x63d1, /* WARNING PROD_ID is inverted in the datasheet */
		.maskrev = 0x70,
		.num_channels = 14,
		.vco0_range = { 2440, 2580 },
		.vco1_range = { 2945, 3255 },
	},
};

enum lmk04832_rdbk_type {
	RDBK_CLKIN_SEL0,
	RDBK_CLKIN_SEL1,
	RDBK_RESET,
	RDBK_PLL1_LD,
};

struct lmk_dclk {
	struct lmk04832 *lmk;
	struct clk_hw hw;
	u8 id;
};

struct lmk_clkout {
	struct lmk04832 *lmk;
	struct clk_hw hw;
	bool sysref;
	u32 format;
	u8 id;
};

/**
 * struct lmk04832 - The LMK04832 device structure
 *
 * @dev: reference to a struct device, linked to the spi_device
 * @regmap: struct regmap instance use to access the chip
 * @sync_mode: operational mode for SYNC signal
 * @sysref_mux: select SYSREF source
 * @sysref_pulse_cnt: number of SYSREF pulses generated while not in continuous
 *                    mode.
 * @sysref_ddly: SYSREF digital delay value
 * @oscin: PLL2 input clock
 * @vco: reference to the internal VCO clock
 * @sclk: reference to the internal sysref clock (SCLK)
 * @vco_rate: user provided VCO rate
 * @reset_gpio: reference to the reset GPIO
 * @dclk: list of internal device clock references.
 *        Each pair of clkout clocks share a single device clock (DCLKX_Y)
 * @clkout: list of output clock references
 * @clk_data: holds clkout related data like clk_hw* and number of clocks
 */
struct lmk04832 {
	struct device *dev;
	struct regmap *regmap;

	unsigned int sync_mode;
	unsigned int sysref_mux;
	unsigned int sysref_pulse_cnt;
	unsigned int sysref_ddly;

	struct clk *oscin;
	struct clk_hw vco;
	struct clk_hw sclk;
	unsigned int vco_rate;

	struct gpio_desc *reset_gpio;

	struct lmk_dclk *dclk;
	struct lmk_clkout *clkout;
	struct clk_hw_onecell_data *clk_data;
};

static bool lmk04832_regmap_rd_regs(struct device *dev, unsigned int reg)
{
	switch (reg) {
	case LMK04832_REG_RST3W ... LMK04832_REG_ID_MASKREV:
	case LMK04832_REG_ID_VNDR_MSB:
	case LMK04832_REG_ID_VNDR_LSB:
	case LMK04832_REG_CLKOUT_CTRL0(0) ... LMK04832_REG_PLL2_DLD_CNT_LSB:
	case LMK04832_REG_PLL2_LD:
	case LMK04832_REG_PLL2_PD:
	case LMK04832_REG_PLL1R_RST:

Annotation

Implementation Notes