drivers/staging/axis-fifo/axis-fifo.c

Source file repositories/reference/linux-study-clean/drivers/staging/axis-fifo/axis-fifo.c

File Facts

System
Linux kernel
Corpus path
drivers/staging/axis-fifo/axis-fifo.c
Extension
.c
Size
13881 bytes
Lines
543
Domain
Driver Families
Bucket
drivers/staging
Inferred role
Driver Families: operation-table or driver-model contract
Status
pattern 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

static const struct file_operations fops = {
	.owner = THIS_MODULE,
	.open = axis_fifo_open,
	.read = axis_fifo_read,
	.write = axis_fifo_write,
	.poll = axis_fifo_poll,
};

static int axis_fifo_debugfs_regs_show(struct seq_file *m, void *p)
{
	static const struct axis_fifo_debug_reg regs[] = {
		{"isr", XLLF_ISR_OFFSET},
		{"ier", XLLF_IER_OFFSET},
		{"tdfv", XLLF_TDFV_OFFSET},
		{"rdfo", XLLF_RDFO_OFFSET},
		{ /* Sentinel */ },
	};
	const struct axis_fifo_debug_reg *reg;
	struct axis_fifo *fifo = m->private;

	for (reg = regs; reg->name; ++reg) {
		u32 val = ioread32(fifo->base_addr + reg->offset);

		seq_printf(m, "%*s: 0x%08x\n", AXIS_FIFO_DEBUG_REG_NAME_MAX_LEN,
			   reg->name, val);
	}

	return 0;
}
DEFINE_SHOW_ATTRIBUTE(axis_fifo_debugfs_regs);

static void axis_fifo_debugfs_init(struct axis_fifo *fifo)
{
	fifo->debugfs_dir = debugfs_create_dir(dev_name(fifo->dt_device), NULL);

	debugfs_create_file("regs", 0444, fifo->debugfs_dir, fifo,
			    &axis_fifo_debugfs_regs_fops);
}

static int axis_fifo_parse_dt(struct axis_fifo *fifo)
{
	int ret;
	unsigned int value;
	struct device_node *node = fifo->dt_device->of_node;

	ret = of_property_read_u32(node, "xlnx,axi-str-rxd-tdata-width",
				   &value);
	if (ret)
		return ret;
	if (value != 32)
		return -EINVAL;

	ret = of_property_read_u32(node, "xlnx,axi-str-txd-tdata-width",
				   &value);
	if (ret)
		return ret;
	if (value != 32)
		return -EINVAL;

	ret = of_property_read_u32(node, "xlnx,rx-fifo-depth",
				   &fifo->rx_fifo_depth);
	if (ret)
		return ret;

	ret = of_property_read_u32(node, "xlnx,tx-fifo-depth",
				   &fifo->tx_fifo_depth);
	if (ret)
		return ret;

	ret = of_property_read_u32(node, "xlnx,use-rx-data",
				   &fifo->has_rx_fifo);
	if (ret)
		return ret;

	ret = of_property_read_u32(node, "xlnx,use-tx-data",
				   &fifo->has_tx_fifo);
	if (ret)
		return ret;

	return 0;
}

static int axis_fifo_probe(struct platform_device *pdev)
{
	struct resource *r_mem;
	struct device *dev = &pdev->dev;
	struct axis_fifo *fifo = NULL;
	int rc = 0; /* error return value */
	int irq;

Annotation

Implementation Notes