drivers/clk/clk-lan966x.c

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

File Facts

System
Linux kernel
Corpus path
drivers/clk/clk-lan966x.c
Extension
.c
Size
7529 bytes
Lines
321
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 lan966x_gck {
	struct clk_hw hw;
	void __iomem *reg;
};
#define to_lan966x_gck(hw) container_of(hw, struct lan966x_gck, hw)

static const struct clk_parent_data lan966x_gck_pdata[] = {
	{ .fw_name = "cpu", },
	{ .fw_name = "ddr", },
	{ .fw_name = "sys", },
};

static struct clk_init_data init = {
	.parent_data = lan966x_gck_pdata,
	.num_parents = ARRAY_SIZE(lan966x_gck_pdata),
};

struct clk_gate_soc_desc {
	const char *name;
	int bit_idx;
};

static const struct clk_gate_soc_desc lan966x_clk_gate_desc[] = {
	{ "uhphs", 11 },
	{ "udphs", 10 },
	{ "mcramc", 9 },
	{ "hmatrix", 8 },
	{ }
};

static const struct clk_gate_soc_desc lan969x_clk_gate_desc[] = {
	{ "usb_drd", 10 },
	{ "mcramc", 9 },
	{ "hmatrix", 8 },
	{ }
};

struct lan966x_match_data {
	char *name;
	const char * const *clk_name;
	const struct clk_gate_soc_desc *clk_gate_desc;
	u8 num_generic_clks;
	u8 num_total_clks;
};

static struct lan966x_match_data lan966x_desc = {
	.name = "lan966x",
	.clk_name = lan966x_clk_names,
	.clk_gate_desc = lan966x_clk_gate_desc,
	.num_total_clks = 18,
	.num_generic_clks = 14,
};

static struct lan966x_match_data lan969x_desc = {
	.name = "lan969x",
	.clk_name = lan969x_clk_names,
	.clk_gate_desc = lan969x_clk_gate_desc,
	.num_total_clks = 15,
	.num_generic_clks = 12,
};

static DEFINE_SPINLOCK(clk_gate_lock);
static void __iomem *base;

static int lan966x_gck_enable(struct clk_hw *hw)
{
	struct lan966x_gck *gck = to_lan966x_gck(hw);
	u32 val = readl(gck->reg);

	val |= GCK_ENA;
	writel(val, gck->reg);

	return 0;
}

static void lan966x_gck_disable(struct clk_hw *hw)
{
	struct lan966x_gck *gck = to_lan966x_gck(hw);
	u32 val = readl(gck->reg);

	val &= ~GCK_ENA;
	writel(val, gck->reg);
}

static int lan966x_gck_set_rate(struct clk_hw *hw,
				unsigned long rate,
				unsigned long parent_rate)
{
	struct lan966x_gck *gck = to_lan966x_gck(hw);
	u32 div, val = readl(gck->reg);

Annotation

Implementation Notes