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.
- 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.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/clk.hlinux/dma-mapping.hlinux/dmapool.hlinux/interrupt.hlinux/io.hlinux/io-64-nonatomic-lo-hi.hlinux/module.hlinux/of.hlinux/of_dma.hlinux/platform_device.hlinux/slab.h../dmaengine.h../virt-dma.h
Detected Declarations
struct ls2x_dma_hw_descstruct ls2x_dma_sgstruct ls2x_dma_descstruct ls2x_dma_chanstruct ls2x_dma_privfunction ls2x_dma_desc_freefunction ls2x_dma_write_cmdfunction ls2x_dma_start_transferfunction ls2x_dmac_detect_burstfunction ls2x_dma_fill_descfunction ls2x_dma_alloc_chan_resourcesfunction ls2x_dma_free_chan_resourcesfunction ls2x_dma_prep_slave_sgfunction for_each_sgfunction ls2x_dma_prep_dma_cyclicfunction ls2x_dma_slave_configfunction ls2x_dma_issue_pendingfunction ls2x_dma_terminate_allfunction scoped_guardfunction ls2x_dma_synchronizefunction ls2x_dma_pausefunction ls2x_dma_resumefunction ls2x_dma_isrfunction scoped_guardfunction ls2x_dma_chan_initfunction ls2x_dma_probefunction ls2x_dma_remove
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
- Immediate include surface: `linux/clk.h`, `linux/dma-mapping.h`, `linux/dmapool.h`, `linux/interrupt.h`, `linux/io.h`, `linux/io-64-nonatomic-lo-hi.h`, `linux/module.h`, `linux/of.h`.
- Detected declarations: `struct ls2x_dma_hw_desc`, `struct ls2x_dma_sg`, `struct ls2x_dma_desc`, `struct ls2x_dma_chan`, `struct ls2x_dma_priv`, `function ls2x_dma_desc_free`, `function ls2x_dma_write_cmd`, `function ls2x_dma_start_transfer`, `function ls2x_dmac_detect_burst`, `function ls2x_dma_fill_desc`.
- Atlas domain: Driver Families / drivers/dma.
- Implementation status: source implementation candidate.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.