drivers/clk/ralink/clk-mtmips.c

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

File Facts

System
Linux kernel
Corpus path
drivers/clk/ralink/clk-mtmips.c
Extension
.c
Size
29646 bytes
Lines
1133
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 mtmips_clk_data {
	struct mtmips_clk *clk_base;
	size_t num_clk_base;
	struct mtmips_clk_fixed *clk_fixed;
	size_t num_clk_fixed;
	struct mtmips_clk_factor *clk_factor;
	size_t num_clk_factor;
	struct mtmips_clk *clk_periph;
	size_t num_clk_periph;
};

struct mtmips_clk_priv {
	struct regmap *sysc;
	const struct mtmips_clk_data *data;
};

struct mtmips_clk {
	struct clk_hw hw;
	struct mtmips_clk_priv *priv;
};

struct mtmips_clk_fixed {
	const char *name;
	const char *parent;
	unsigned long rate;
	struct clk_hw *hw;
};

struct mtmips_clk_factor {
	const char *name;
	const char *parent;
	int mult;
	int div;
	unsigned long flags;
	struct clk_hw *hw;
};

static unsigned long mtmips_pherip_clk_rate(struct clk_hw *hw,
					    unsigned long parent_rate)
{
	return parent_rate;
}

static const struct clk_ops mtmips_periph_clk_ops = {
	.recalc_rate = mtmips_pherip_clk_rate,
};

#define CLK_PERIPH(_name, _parent) {				\
	.init = &(const struct clk_init_data) {			\
		.name = _name,					\
		.ops = &mtmips_periph_clk_ops,			\
		.parent_data = &(const struct clk_parent_data) {\
			.name = _parent,			\
			.fw_name = _parent			\
		},						\
		.num_parents = 1,				\
		/*						\
		 * There are drivers for these SoCs that are	\
		 * older than clock driver and are not prepared \
		 * for the clock. We don't want the kernel to   \
		 * disable anything so we add CLK_IS_CRITICAL	\
		 * flag here.					\
		 */						\
		.flags = CLK_SET_RATE_PARENT | CLK_IS_CRITICAL	\
	},							\
}

static struct mtmips_clk rt2880_pherip_clks[] = {
	{ CLK_PERIPH("300100.timer", "bus") },
	{ CLK_PERIPH("300120.watchdog", "bus") },
	{ CLK_PERIPH("300500.uart", "bus") },
	{ CLK_PERIPH("300900.i2c", "bus") },
	{ CLK_PERIPH("300c00.uartlite", "bus") },
	{ CLK_PERIPH("400000.ethernet", "bus") },
	{ CLK_PERIPH("480000.wmac", "xtal") }
};

static struct mtmips_clk rt305x_pherip_clks[] = {
	{ CLK_PERIPH("10000100.timer", "bus") },
	{ CLK_PERIPH("10000120.watchdog", "bus") },
	{ CLK_PERIPH("10000500.uart", "bus") },
	{ CLK_PERIPH("10000900.i2c", "bus") },
	{ CLK_PERIPH("10000a00.i2s", "bus") },
	{ CLK_PERIPH("10000b00.spi", "bus") },
	{ CLK_PERIPH("10000b40.spi", "bus") },
	{ CLK_PERIPH("10000c00.uartlite", "bus") },
	{ CLK_PERIPH("10100000.ethernet", "bus") },
	{ CLK_PERIPH("10180000.wmac", "xtal") }
};

Annotation

Implementation Notes