drivers/dma/sun4i-dma.c

Source file repositories/reference/linux-study-clean/drivers/dma/sun4i-dma.c

File Facts

System
Linux kernel
Corpus path
drivers/dma/sun4i-dma.c
Extension
.c
Size
40882 bytes
Lines
1431
Domain
Driver Families
Bucket
drivers/dma
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 sun4i_dma_config {
	u32 ndma_nr_max_channels;
	u32 ndma_nr_max_vchans;

	u32 ddma_nr_max_channels;
	u32 ddma_nr_max_vchans;

	u32 dma_nr_max_channels;

	void (*set_dst_data_width)(u32 *p_cfg, s8 data_width);
	void (*set_src_data_width)(u32 *p_cfg, s8 data_width);
	int (*convert_burst)(u32 maxburst);

	u8 ndma_drq_sdram;
	u8 ddma_drq_sdram;

	u8 max_burst;
	bool has_reset;
};

struct sun4i_dma_pchan {
	/* Register base of channel */
	void __iomem			*base;
	/* vchan currently being serviced */
	struct sun4i_dma_vchan		*vchan;
	/* Is this a dedicated pchan? */
	int				is_dedicated;
};

struct sun4i_dma_vchan {
	struct virt_dma_chan		vc;
	struct dma_slave_config		cfg;
	struct sun4i_dma_pchan		*pchan;
	struct sun4i_dma_promise	*processing;
	struct sun4i_dma_contract	*contract;
	u8				endpoint;
	int				is_dedicated;
};

struct sun4i_dma_promise {
	u32				cfg;
	u32				para;
	dma_addr_t			src;
	dma_addr_t			dst;
	size_t				len;
	struct list_head		list;
};

/* A contract is a set of promises */
struct sun4i_dma_contract {
	struct virt_dma_desc		vd;
	struct list_head		demands;
	struct list_head		completed_demands;
	bool				is_cyclic : 1;
	bool				use_half_int : 1;
};

struct sun4i_dma_dev {
	unsigned long *pchans_used;
	struct dma_device		slave;
	struct sun4i_dma_pchan		*pchans;
	struct sun4i_dma_vchan		*vchans;
	void __iomem			*base;
	struct clk			*clk;
	int				irq;
	spinlock_t			lock;
	const struct sun4i_dma_config *cfg;
	struct reset_control *rst;
};

static struct sun4i_dma_dev *to_sun4i_dma_dev(struct dma_device *dev)
{
	return container_of(dev, struct sun4i_dma_dev, slave);
}

static struct sun4i_dma_vchan *to_sun4i_dma_vchan(struct dma_chan *chan)
{
	return container_of(chan, struct sun4i_dma_vchan, vc.chan);
}

static struct sun4i_dma_contract *to_sun4i_dma_contract(struct virt_dma_desc *vd)
{
	return container_of(vd, struct sun4i_dma_contract, vd);
}

static struct device *chan2dev(struct dma_chan *chan)
{
	return &chan->dev->device;
}

Annotation

Implementation Notes