drivers/dma/loongson/loongson1-apb-dma.c
Source file repositories/reference/linux-study-clean/drivers/dma/loongson/loongson1-apb-dma.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/dma/loongson/loongson1-apb-dma.c- Extension
.c- Size
- 16587 bytes
- Lines
- 661
- 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/dmapool.hlinux/dma-mapping.hlinux/init.hlinux/interrupt.hlinux/iopoll.hlinux/module.hlinux/of.hlinux/of_dma.hlinux/platform_device.hlinux/slab.h../dmaengine.h../virt-dma.h
Detected Declarations
struct ls1x_dma_llistruct ls1x_dma_descstruct ls1x_dma_chanstruct ls1x_dmaenum ls1x_dmadesc_offsetsfunction ls1x_dma_queryfunction ls1x_dma_startfunction ls1x_dma_stopfunction ls1x_dma_free_chan_resourcesfunction ls1x_dma_alloc_chan_resourcesfunction ls1x_dma_free_descfunction list_for_each_entry_safefunction ls1x_dma_prep_llifunction for_each_sgfunction list_for_eachfunction ls1x_dma_prep_slave_sgfunction ls1x_dma_prep_dma_cyclicfunction ls1x_dma_slave_configfunction ls1x_dma_pausefunction ls1x_dma_resumefunction ls1x_dma_terminate_allfunction scoped_guardfunction ls1x_dma_synchronizefunction ls1x_dma_tx_statusfunction scoped_guardfunction ls1x_dma_issue_pendingfunction ls1x_dma_irq_handlerfunction scoped_guardfunction ls1x_dma_chan_probefunction ls1x_dma_chan_removefunction ls1x_dma_probefunction ls1x_dma_remove
Annotated Snippet
struct ls1x_dma_lli {
unsigned int hw[LS1X_DMADESC_SIZE];
dma_addr_t phys;
struct list_head node;
} __aligned(LS1X_DMA_LLI_ALIGNMENT);
struct ls1x_dma_desc {
struct virt_dma_desc vd;
struct list_head lli_list;
};
struct ls1x_dma_chan {
struct virt_dma_chan vc;
struct dma_pool *lli_pool;
phys_addr_t src_addr;
phys_addr_t dst_addr;
enum dma_slave_buswidth src_addr_width;
enum dma_slave_buswidth dst_addr_width;
unsigned int bus_width;
void __iomem *reg_base;
int irq;
bool is_cyclic;
struct ls1x_dma_lli *curr_lli;
};
struct ls1x_dma {
struct dma_device ddev;
unsigned int nr_chans;
struct ls1x_dma_chan chan[];
};
static irqreturn_t ls1x_dma_irq_handler(int irq, void *data);
#define to_ls1x_dma_chan(dchan) \
container_of(dchan, struct ls1x_dma_chan, vc.chan)
#define to_ls1x_dma_desc(d) \
container_of(d, struct ls1x_dma_desc, vd)
static inline struct device *chan2dev(struct dma_chan *chan)
{
return &chan->dev->device;
}
static inline int ls1x_dma_query(struct ls1x_dma_chan *chan,
dma_addr_t *lli_phys)
{
struct dma_chan *dchan = &chan->vc.chan;
int val, ret;
val = *lli_phys & LS1X_DMA_LLI_ADDR_MASK;
val |= LS1X_DMA_ASK_VALID;
val |= dchan->chan_id;
writel(val, chan->reg_base + LS1X_DMA_CTRL);
ret = readl_poll_timeout_atomic(chan->reg_base + LS1X_DMA_CTRL, val,
!(val & LS1X_DMA_ASK_VALID), 0, 3000);
if (ret)
dev_err(chan2dev(dchan), "failed to query DMA\n");
return ret;
}
static inline int ls1x_dma_start(struct ls1x_dma_chan *chan,
dma_addr_t *lli_phys)
{
struct dma_chan *dchan = &chan->vc.chan;
struct device *dev = chan2dev(dchan);
int val, ret;
val = *lli_phys & LS1X_DMA_LLI_ADDR_MASK;
val |= LS1X_DMA_START;
val |= dchan->chan_id;
writel(val, chan->reg_base + LS1X_DMA_CTRL);
ret = readl_poll_timeout(chan->reg_base + LS1X_DMA_CTRL, val,
!(val & LS1X_DMA_START), 0, 1000);
if (!ret)
dev_dbg(dev, "start DMA with lli_phys=%pad\n", lli_phys);
else
dev_err(dev, "failed to start DMA\n");
return ret;
}
static inline void ls1x_dma_stop(struct ls1x_dma_chan *chan)
{
int val = readl(chan->reg_base + LS1X_DMA_CTRL);
writel(val | LS1X_DMA_STOP, chan->reg_base + LS1X_DMA_CTRL);
}
Annotation
- Immediate include surface: `linux/dmapool.h`, `linux/dma-mapping.h`, `linux/init.h`, `linux/interrupt.h`, `linux/iopoll.h`, `linux/module.h`, `linux/of.h`, `linux/of_dma.h`.
- Detected declarations: `struct ls1x_dma_lli`, `struct ls1x_dma_desc`, `struct ls1x_dma_chan`, `struct ls1x_dma`, `enum ls1x_dmadesc_offsets`, `function ls1x_dma_query`, `function ls1x_dma_start`, `function ls1x_dma_stop`, `function ls1x_dma_free_chan_resources`, `function ls1x_dma_alloc_chan_resources`.
- 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.