drivers/dma/sprd-dma.c
Source file repositories/reference/linux-study-clean/drivers/dma/sprd-dma.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/dma/sprd-dma.c- Extension
.c- Size
- 35921 bytes
- Lines
- 1314
- 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- 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/dma/sprd-dma.hlinux/errno.hlinux/init.hlinux/interrupt.hlinux/io.hlinux/kernel.hlinux/module.hlinux/of.hlinux/of_dma.hlinux/platform_device.hlinux/pm_runtime.hlinux/slab.hvirt-dma.h
Detected Declarations
struct sprd_dma_chn_hwstruct sprd_dma_descstruct sprd_dma_chnstruct sprd_dma_devenum sprd_dma_datawidthfunction sprd_dma_glb_updatefunction sprd_dma_chn_updatefunction sprd_dma_enablefunction sprd_dma_disablefunction sprd_dma_set_uidfunction sprd_dma_unset_uidfunction sprd_dma_clear_intfunction sprd_dma_enable_chnfunction sprd_dma_disable_chnfunction sprd_dma_soft_requestfunction sprd_dma_pause_resumefunction sprd_dma_stop_and_disablefunction sprd_dma_get_src_addrfunction sprd_dma_get_dst_addrfunction sprd_dma_get_int_typefunction sprd_dma_get_req_typefunction sprd_dma_set_2stage_configfunction sprd_dma_set_pendingfunction sprd_dma_set_chn_configfunction sprd_dma_startfunction sprd_dma_stopfunction sprd_dma_check_trans_donefunction dma_irq_handlefunction sprd_dma_alloc_chan_resourcesfunction sprd_dma_free_chan_resourcesfunction sprd_dma_tx_statusfunction sprd_dma_issue_pendingfunction sprd_dma_get_datawidthfunction sprd_dma_get_stepfunction sprd_dma_fill_descfunction sprd_dma_fill_linklist_descfunction sprd_dma_prep_dma_memcpyfunction sprd_dma_prep_slave_sgfunction for_each_sgfunction sprd_dma_slave_configfunction sprd_dma_pausefunction sprd_dma_resumefunction sprd_dma_terminate_allfunction sprd_dma_free_descfunction sprd_dma_filter_fnfunction sprd_dma_probefunction sprd_dma_removefunction list_for_each_entry_safe
Annotated Snippet
struct sprd_dma_chn_hw {
u32 pause;
u32 req;
u32 cfg;
u32 intc;
u32 src_addr;
u32 des_addr;
u32 frg_len;
u32 blk_len;
u32 trsc_len;
u32 trsf_step;
u32 wrap_ptr;
u32 wrap_to;
u32 llist_ptr;
u32 frg_step;
u32 src_blk_step;
u32 des_blk_step;
};
/* dma request description */
struct sprd_dma_desc {
struct virt_dma_desc vd;
struct sprd_dma_chn_hw chn_hw;
enum dma_transfer_direction dir;
};
/* dma channel description */
struct sprd_dma_chn {
struct virt_dma_chan vc;
void __iomem *chn_base;
struct sprd_dma_linklist linklist;
struct dma_slave_config slave_cfg;
u32 chn_num;
u32 dev_id;
enum sprd_dma_chn_mode chn_mode;
enum sprd_dma_trg_mode trg_mode;
enum sprd_dma_int_type int_type;
struct sprd_dma_desc *cur_desc;
};
/* SPRD dma device */
struct sprd_dma_dev {
struct dma_device dma_dev;
void __iomem *glb_base;
struct clk *clk;
struct clk *ashb_clk;
int irq;
u32 total_chns;
struct sprd_dma_chn channels[] __counted_by(total_chns);
};
static void sprd_dma_free_desc(struct virt_dma_desc *vd);
static bool sprd_dma_filter_fn(struct dma_chan *chan, void *param);
static struct of_dma_filter_info sprd_dma_info = {
.filter_fn = sprd_dma_filter_fn,
};
static inline struct sprd_dma_chn *to_sprd_dma_chan(struct dma_chan *c)
{
return container_of(c, struct sprd_dma_chn, vc.chan);
}
static inline struct sprd_dma_dev *to_sprd_dma_dev(struct dma_chan *c)
{
struct sprd_dma_chn *schan = to_sprd_dma_chan(c);
return container_of(schan, struct sprd_dma_dev, channels[c->chan_id]);
}
static inline struct sprd_dma_desc *to_sprd_dma_desc(struct virt_dma_desc *vd)
{
return container_of(vd, struct sprd_dma_desc, vd);
}
static void sprd_dma_glb_update(struct sprd_dma_dev *sdev, u32 reg,
u32 mask, u32 val)
{
u32 orig = readl(sdev->glb_base + reg);
u32 tmp;
tmp = (orig & ~mask) | val;
writel(tmp, sdev->glb_base + reg);
}
static void sprd_dma_chn_update(struct sprd_dma_chn *schan, u32 reg,
u32 mask, u32 val)
{
u32 orig = readl(schan->chn_base + reg);
u32 tmp;
Annotation
- Immediate include surface: `linux/clk.h`, `linux/dma-mapping.h`, `linux/dma/sprd-dma.h`, `linux/errno.h`, `linux/init.h`, `linux/interrupt.h`, `linux/io.h`, `linux/kernel.h`.
- Detected declarations: `struct sprd_dma_chn_hw`, `struct sprd_dma_desc`, `struct sprd_dma_chn`, `struct sprd_dma_dev`, `enum sprd_dma_datawidth`, `function sprd_dma_glb_update`, `function sprd_dma_chn_update`, `function sprd_dma_enable`, `function sprd_dma_disable`, `function sprd_dma_set_uid`.
- Atlas domain: Driver Families / drivers/dma.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
- 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.