drivers/clk/clk-rp1.c

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

File Facts

System
Linux kernel
Corpus path
drivers/clk/clk-rp1.c
Extension
.c
Size
68620 bytes
Lines
2463
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 rp1_clockman {
	struct device *dev;
	void __iomem *regs;
	struct regmap *regmap;
	spinlock_t regs_lock; /* spinlock for all clocks */

	/* Must be last */
	struct clk_hw_onecell_data onecell;
};

struct rp1_pll_core_data {
	u32 cs_reg;
	u32 pwr_reg;
	u32 fbdiv_int_reg;
	u32 fbdiv_frac_reg;
	u32 fc0_src;
};

struct rp1_pll_data {
	u32 ctrl_reg;
	u32 fc0_src;
};

struct rp1_pll_ph_data {
	unsigned int phase;
	unsigned int fixed_divider;
	u32 ph_reg;
	u32 fc0_src;
};

struct rp1_pll_divider_data {
	u32 sec_reg;
	u32 fc0_src;
};

struct rp1_clock_data {
	int num_std_parents;
	int num_aux_parents;
	u32 oe_mask;
	u32 clk_src_mask;
	u32 ctrl_reg;
	u32 div_int_reg;
	u32 div_frac_reg;
	u32 sel_reg;
	u32 div_int_max;
	unsigned long max_freq;
	u32 fc0_src;
};

struct rp1_clk_desc {
	struct clk_hw *(*clk_register)(struct rp1_clockman *clockman,
				       struct rp1_clk_desc *desc);
	const void *data;
	struct clk_hw hw;
	struct rp1_clockman *clockman;
	unsigned long cached_rate;
	struct clk_divider div;
};

static struct rp1_clk_desc *clk_audio_core;
static struct rp1_clk_desc *clk_audio;
static struct rp1_clk_desc *clk_i2s;
static struct clk_hw *clk_xosc;

static inline
void clockman_write(struct rp1_clockman *clockman, u32 reg, u32 val)
{
	regmap_write(clockman->regmap, reg, val);
}

static inline u32 clockman_read(struct rp1_clockman *clockman, u32 reg)
{
	u32 val;

	regmap_read(clockman->regmap, reg, &val);

	return val;
}

static int rp1_pll_core_is_on(struct clk_hw *hw)
{
	struct rp1_clk_desc *pll_core = container_of(hw, struct rp1_clk_desc, hw);
	struct rp1_clockman *clockman = pll_core->clockman;
	const struct rp1_pll_core_data *data = pll_core->data;
	u32 pwr = clockman_read(clockman, data->pwr_reg);

	return (pwr & PLL_PWR_PD) || (pwr & PLL_PWR_POSTDIVPD);
}

static int rp1_pll_core_on(struct clk_hw *hw)

Annotation

Implementation Notes