drivers/dma/loongson/loongson2-apb-cmc-dma.c
Source file repositories/reference/linux-study-clean/drivers/dma/loongson/loongson2-apb-cmc-dma.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/dma/loongson/loongson2-apb-cmc-dma.c- Extension
.c- Size
- 22046 bytes
- Lines
- 731
- 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/acpi.hlinux/acpi_dma.hlinux/bitfield.hlinux/clk.hlinux/dma-mapping.hlinux/dmapool.hlinux/interrupt.hlinux/io.hlinux/module.hlinux/of.hlinux/of_dma.hlinux/platform_device.hlinux/slab.h../dmaengine.h../virt-dma.h
Detected Declarations
struct loongson2_cmc_dma_chan_regstruct loongson2_cmc_dma_sg_reqstruct loongson2_cmc_dma_descstruct loongson2_cmc_dma_chanstruct loongson2_cmc_dma_devstruct loongson2_cmc_dma_configfunction loongson2_cmc_dma_readfunction loongson2_cmc_dma_writefunction loongson2_cmc_dma_get_widthfunction loongson2_cmc_dma_slave_configfunction loongson2_cmc_dma_irq_clearfunction loongson2_cmc_dma_stopfunction loongson2_cmc_dma_terminate_allfunction scoped_guardfunction loongson2_cmc_dma_synchronizefunction loongson2_cmc_dma_start_transferfunction loongson2_cmc_dma_configure_next_sgfunction loongson2_cmc_dma_handle_chan_donefunction loongson2_cmc_dma_chan_irqfunction scoped_guardfunction loongson2_cmc_dma_issue_pendingfunction loongson2_cmc_dma_set_xfer_paramfunction loongson2_cmc_dma_prep_slave_sgfunction for_each_sgfunction loongson2_cmc_dma_prep_dma_cyclicfunction loongson2_cmc_dma_desc_residuefunction loongson2_cmc_dma_tx_statusfunction scoped_guardfunction loongson2_cmc_dma_free_chan_resourcesfunction loongson2_cmc_dma_desc_freefunction loongson2_cmc_dma_acpi_filterfunction loongson2_cmc_dma_acpi_controller_registerfunction loongson2_cmc_dma_of_controller_registerfunction loongson2_cmc_dma_probefunction loongson2_cmc_dma_remove
Annotated Snippet
struct loongson2_cmc_dma_chan_reg {
u32 ccr;
u32 cndtr;
u32 cpar;
u32 cmar;
};
struct loongson2_cmc_dma_sg_req {
u32 len;
struct loongson2_cmc_dma_chan_reg chan_reg;
};
struct loongson2_cmc_dma_desc {
struct virt_dma_desc vdesc;
bool cyclic;
u32 num_sgs;
struct loongson2_cmc_dma_sg_req sg_req[] __counted_by(num_sgs);
};
struct loongson2_cmc_dma_chan {
struct virt_dma_chan vchan;
struct dma_slave_config dma_sconfig;
struct loongson2_cmc_dma_desc *desc;
u32 id;
u32 irq;
u32 next_sg;
struct loongson2_cmc_dma_chan_reg chan_reg;
};
struct loongson2_cmc_dma_dev {
struct dma_device ddev;
struct clk *dma_clk;
void __iomem *base;
u32 nr_channels;
u32 chan_reg_offset;
struct loongson2_cmc_dma_chan chan[] __counted_by(nr_channels);
};
struct loongson2_cmc_dma_config {
u32 max_channels;
u32 chan_reg_offset;
};
static const struct loongson2_cmc_dma_config ls2k0300_cmc_dma_config = {
.max_channels = 8,
.chan_reg_offset = 0x14,
};
static const struct loongson2_cmc_dma_config ls2k3000_cmc_dma_config = {
.max_channels = 4,
.chan_reg_offset = 0x18,
};
static struct loongson2_cmc_dma_dev *lmdma_get_dev(struct loongson2_cmc_dma_chan *lchan)
{
return container_of(lchan->vchan.chan.device, struct loongson2_cmc_dma_dev, ddev);
}
static struct loongson2_cmc_dma_chan *to_lmdma_chan(struct dma_chan *chan)
{
return container_of(chan, struct loongson2_cmc_dma_chan, vchan.chan);
}
static struct loongson2_cmc_dma_desc *to_lmdma_desc(struct virt_dma_desc *vdesc)
{
return container_of(vdesc, struct loongson2_cmc_dma_desc, vdesc);
}
static struct device *chan2dev(struct loongson2_cmc_dma_chan *lchan)
{
return &lchan->vchan.chan.dev->device;
}
static u32 loongson2_cmc_dma_read(struct loongson2_cmc_dma_dev *lddev, u32 reg, u32 id)
{
return readl(lddev->base + (reg + lddev->chan_reg_offset * id));
}
static void loongson2_cmc_dma_write(struct loongson2_cmc_dma_dev *lddev, u32 reg, u32 id, u32 val)
{
writel(val, lddev->base + (reg + lddev->chan_reg_offset * id));
}
static int loongson2_cmc_dma_get_width(enum dma_slave_buswidth width)
{
switch (width) {
case DMA_SLAVE_BUSWIDTH_1_BYTE:
case DMA_SLAVE_BUSWIDTH_2_BYTES:
case DMA_SLAVE_BUSWIDTH_4_BYTES:
return ffs(width) - 1;
Annotation
- Immediate include surface: `linux/acpi.h`, `linux/acpi_dma.h`, `linux/bitfield.h`, `linux/clk.h`, `linux/dma-mapping.h`, `linux/dmapool.h`, `linux/interrupt.h`, `linux/io.h`.
- Detected declarations: `struct loongson2_cmc_dma_chan_reg`, `struct loongson2_cmc_dma_sg_req`, `struct loongson2_cmc_dma_desc`, `struct loongson2_cmc_dma_chan`, `struct loongson2_cmc_dma_dev`, `struct loongson2_cmc_dma_config`, `function loongson2_cmc_dma_read`, `function loongson2_cmc_dma_write`, `function loongson2_cmc_dma_get_width`, `function loongson2_cmc_dma_slave_config`.
- 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.