drivers/dma/milbeaut-hdmac.c
Source file repositories/reference/linux-study-clean/drivers/dma/milbeaut-hdmac.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/dma/milbeaut-hdmac.c- Extension
.c- Size
- 14531 bytes
- Lines
- 584
- 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/bits.hlinux/clk.hlinux/dma-mapping.hlinux/interrupt.hlinux/iopoll.hlinux/list.hlinux/module.hlinux/of_dma.hlinux/platform_device.hlinux/slab.hlinux/types.hlinux/bitfield.hvirt-dma.h
Detected Declarations
struct milbeaut_hdmac_descstruct milbeaut_hdmac_chanstruct milbeaut_hdmac_devicefunction to_milbeaut_hdmac_chanfunction to_milbeaut_hdmac_descfunction milbeaut_hdmac_next_descfunction milbeaut_chan_startfunction milbeaut_hdmac_startfunction milbeaut_hdmac_interruptfunction milbeaut_hdmac_free_chan_resourcesfunction milbeaut_hdmac_chan_configfunction milbeaut_hdmac_chan_pausefunction milbeaut_hdmac_chan_resumefunction milbeaut_hdmac_prep_slave_sgfunction milbeaut_hdmac_terminate_allfunction milbeaut_hdmac_synchronizefunction milbeaut_hdmac_tx_statusfunction milbeaut_hdmac_issue_pendingfunction milbeaut_hdmac_desc_freefunction milbeaut_hdmac_xlatefunction milbeaut_hdmac_chan_initfunction milbeaut_hdmac_probefunction milbeaut_hdmac_remove
Annotated Snippet
struct milbeaut_hdmac_desc {
struct virt_dma_desc vd;
struct scatterlist *sgl;
unsigned int sg_len;
unsigned int sg_cur;
enum dma_transfer_direction dir;
};
struct milbeaut_hdmac_chan {
struct virt_dma_chan vc;
struct milbeaut_hdmac_device *mdev;
struct milbeaut_hdmac_desc *md;
void __iomem *reg_ch_base;
unsigned int slave_id;
struct dma_slave_config cfg;
};
struct milbeaut_hdmac_device {
struct dma_device ddev;
struct clk *clk;
void __iomem *reg_base;
struct milbeaut_hdmac_chan channels[];
};
static struct milbeaut_hdmac_chan *
to_milbeaut_hdmac_chan(struct virt_dma_chan *vc)
{
return container_of(vc, struct milbeaut_hdmac_chan, vc);
}
static struct milbeaut_hdmac_desc *
to_milbeaut_hdmac_desc(struct virt_dma_desc *vd)
{
return container_of(vd, struct milbeaut_hdmac_desc, vd);
}
/* mc->vc.lock must be held by caller */
static struct milbeaut_hdmac_desc *
milbeaut_hdmac_next_desc(struct milbeaut_hdmac_chan *mc)
{
struct virt_dma_desc *vd;
vd = vchan_next_desc(&mc->vc);
if (!vd) {
mc->md = NULL;
return NULL;
}
list_del(&vd->node);
mc->md = to_milbeaut_hdmac_desc(vd);
return mc->md;
}
/* mc->vc.lock must be held by caller */
static void milbeaut_chan_start(struct milbeaut_hdmac_chan *mc,
struct milbeaut_hdmac_desc *md)
{
struct scatterlist *sg;
u32 cb, ca, src_addr, dest_addr, len;
u32 width, burst;
sg = &md->sgl[md->sg_cur];
len = sg_dma_len(sg);
cb = MLB_HDMAC_CI | MLB_HDMAC_EI;
if (md->dir == DMA_MEM_TO_DEV) {
cb |= MLB_HDMAC_FD;
width = mc->cfg.dst_addr_width;
burst = mc->cfg.dst_maxburst;
src_addr = sg_dma_address(sg);
dest_addr = mc->cfg.dst_addr;
} else {
cb |= MLB_HDMAC_FS;
width = mc->cfg.src_addr_width;
burst = mc->cfg.src_maxburst;
src_addr = mc->cfg.src_addr;
dest_addr = sg_dma_address(sg);
}
cb |= FIELD_PREP(MLB_HDMAC_TW, (width >> 1));
cb |= FIELD_PREP(MLB_HDMAC_MS, 2);
writel_relaxed(MLB_HDMAC_DE, mc->mdev->reg_base + MLB_HDMAC_DMACR);
writel_relaxed(src_addr, mc->reg_ch_base + MLB_HDMAC_DMACSA);
writel_relaxed(dest_addr, mc->reg_ch_base + MLB_HDMAC_DMACDA);
writel_relaxed(cb, mc->reg_ch_base + MLB_HDMAC_DMACB);
ca = FIELD_PREP(MLB_HDMAC_IS, mc->slave_id);
if (burst == 16)
Annotation
- Immediate include surface: `linux/bits.h`, `linux/clk.h`, `linux/dma-mapping.h`, `linux/interrupt.h`, `linux/iopoll.h`, `linux/list.h`, `linux/module.h`, `linux/of_dma.h`.
- Detected declarations: `struct milbeaut_hdmac_desc`, `struct milbeaut_hdmac_chan`, `struct milbeaut_hdmac_device`, `function to_milbeaut_hdmac_chan`, `function to_milbeaut_hdmac_desc`, `function milbeaut_hdmac_next_desc`, `function milbeaut_chan_start`, `function milbeaut_hdmac_start`, `function milbeaut_hdmac_interrupt`, `function milbeaut_hdmac_free_chan_resources`.
- 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.