drivers/dma/loongson/loongson2-apb-dma.c

Source file repositories/reference/linux-study-clean/drivers/dma/loongson/loongson2-apb-dma.c

File Facts

System
Linux kernel
Corpus path
drivers/dma/loongson/loongson2-apb-dma.c
Extension
.c
Size
18904 bytes
Lines
687
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 ls2x_dma_hw_desc {
	u32 ndesc_addr;
	u32 mem_addr;
	u32 apb_addr;
	u32 len;
	u32 step_len;
	u32 step_times;
	u32 cmd;
	u32 stats;
	u32 high_ndesc_addr;
	u32 high_mem_addr;
	u32 reserved[2];
} __packed;

/*
 * struct ls2x_dma_sg - ls2x dma scatter gather entry
 * @hw: the pointer to DMA HW descriptor.
 * @llp: physical address of the DMA HW descriptor.
 * @phys: destination or source address(mem).
 * @len: number of Bytes to read.
 */
struct ls2x_dma_sg {
	struct ls2x_dma_hw_desc	*hw;
	dma_addr_t		llp;
	dma_addr_t		phys;
	u32			len;
};

/*
 * struct ls2x_dma_desc - software descriptor
 * @vdesc: pointer to the virtual dma descriptor.
 * @cyclic: flag to dma cyclic
 * @burst_size: burst size of transaction, in words.
 * @desc_num: number of sg entries.
 * @direction: transfer direction, to or from device.
 * @status: dma controller status.
 * @sg: array of sgs.
 */
struct ls2x_dma_desc {
	struct virt_dma_desc		vdesc;
	bool				cyclic;
	size_t				burst_size;
	u32				desc_num;
	enum dma_transfer_direction	direction;
	enum dma_status			status;
	struct ls2x_dma_sg		sg[] __counted_by(desc_num);
};

/*--  Channels  --------------------------------------------------------*/

/*
 * struct ls2x_dma_chan - internal representation of an LS2X APB DMA channel
 * @vchan: virtual dma channel entry.
 * @desc: pointer to the ls2x sw dma descriptor.
 * @pool: hw desc table
 * @irq: irq line
 * @sconfig: configuration for slave transfers, passed via .device_config
 */
struct ls2x_dma_chan {
	struct virt_dma_chan	vchan;
	struct ls2x_dma_desc	*desc;
	void			*pool;
	int			irq;
	struct dma_slave_config	sconfig;
};

/*--  Controller  ------------------------------------------------------*/

/*
 * struct ls2x_dma_priv - LS2X APB DMAC specific information
 * @ddev: dmaengine dma_device object members
 * @dma_clk: DMAC clock source
 * @regs: memory mapped register base
 * @lchan: channel to store ls2x_dma_chan structures
 */
struct ls2x_dma_priv {
	struct dma_device	ddev;
	struct clk		*dma_clk;
	void __iomem		*regs;
	struct ls2x_dma_chan	lchan;
};

/*--  Helper functions  ------------------------------------------------*/

static inline struct ls2x_dma_desc *to_ldma_desc(struct virt_dma_desc *vdesc)
{
	return container_of(vdesc, struct ls2x_dma_desc, vdesc);
}

static inline struct ls2x_dma_chan *to_ldma_chan(struct dma_chan *chan)

Annotation

Implementation Notes