drivers/soc/sunxi/sunxi_sram.c

Source file repositories/reference/linux-study-clean/drivers/soc/sunxi/sunxi_sram.c

File Facts

System
Linux kernel
Corpus path
drivers/soc/sunxi/sunxi_sram.c
Extension
.c
Size
11649 bytes
Lines
503
Domain
Driver Families
Bucket
drivers/soc
Inferred role
Driver Families: exported/initcall integration point
Status
integration 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 sunxi_sram_func {
	char	*func;
	u8	val;
	u32	reg_val;
};

struct sunxi_sram_data {
	char				*name;
	u8				reg;
	u8				offset;
	u8				width;
	const struct sunxi_sram_func	*func;
};

struct sunxi_sram_desc {
	struct sunxi_sram_data	data;
	u8			claim_cnt;
};

#define SUNXI_SRAM_MAP(_reg_val, _val, _func)			\
	{							\
		.func = _func,					\
		.val = _val,					\
		.reg_val = _reg_val,				\
	}

#define SUNXI_SRAM_DATA(_name, _reg, _off, _width, ...)		\
	{							\
		.name = _name,					\
		.reg = _reg,					\
		.offset = _off,					\
		.width = _width,				\
		.func = (const struct sunxi_sram_func[]){	\
			__VA_ARGS__, { } },			\
	}

static struct sunxi_sram_desc sun4i_a10_sram_a3_a4 = {
	.data	= SUNXI_SRAM_DATA("A3-A4", 0x4, 0x4, 2,
				  SUNXI_SRAM_MAP(0, 0, "cpu"),
				  SUNXI_SRAM_MAP(1, 1, "emac")),
};

static struct sunxi_sram_desc sun4i_a10_sram_c1 = {
	.data	= SUNXI_SRAM_DATA("C1", 0x0, 0x0, 31,
				  SUNXI_SRAM_MAP(0, 0, "cpu"),
				  SUNXI_SRAM_MAP(0x7fffffff, 1, "ve")),
};

static struct sunxi_sram_desc sun4i_a10_sram_d = {
	.data	= SUNXI_SRAM_DATA("D", 0x4, 0x0, 1,
				  SUNXI_SRAM_MAP(0, 0, "cpu"),
				  SUNXI_SRAM_MAP(1, 1, "usb-otg")),
};

static struct sunxi_sram_desc sun50i_a64_sram_c = {
	.data	= SUNXI_SRAM_DATA("C", 0x4, 24, 1,
				  SUNXI_SRAM_MAP(1, 0, "cpu"),
				  SUNXI_SRAM_MAP(0, 1, "de2")),
};

static struct sunxi_sram_desc sun50i_h616_ve_sram = {
	.data	= SUNXI_SRAM_DATA("VE", 0x0, 0, 1,
				  SUNXI_SRAM_MAP(1, 0, "cpu"),
				  SUNXI_SRAM_MAP(0, 1, "ve")),
};

static const struct of_device_id sunxi_sram_dt_ids[] = {
	{
		.compatible	= "allwinner,sun4i-a10-sram-a3-a4",
		.data		= &sun4i_a10_sram_a3_a4.data,
	},
	{
		.compatible	= "allwinner,sun4i-a10-sram-c1",
		.data		= &sun4i_a10_sram_c1.data,
	},
	{
		.compatible	= "allwinner,sun4i-a10-sram-d",
		.data		= &sun4i_a10_sram_d.data,
	},
	{
		.compatible	= "allwinner,sun50i-a64-sram-c",
		.data		= &sun50i_a64_sram_c.data,
	},
	{
		.compatible	= "allwinner,sun50i-h616-ve-sram",
		.data		= &sun50i_h616_ve_sram.data,
	},
	{}
};

Annotation

Implementation Notes