drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c
Source file repositories/reference/linux-study-clean/drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c- Extension
.c- Size
- 45400 bytes
- Lines
- 1705
- 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/bitops.hlinux/delay.hlinux/device.hlinux/dmaengine.hlinux/dmapool.hlinux/dma-mapping.hlinux/err.hlinux/interrupt.hlinux/io.hlinux/iopoll.hlinux/io-64-nonatomic-lo-hi.hlinux/kernel.hlinux/module.hlinux/of.hlinux/of_dma.hlinux/platform_device.hlinux/pm_runtime.hlinux/property.hlinux/reset.hlinux/slab.hlinux/types.hdw-axi-dmac.h../dmaengine.h../virt-dma.h
Detected Declarations
function bitsfunction axi_dma_ioread32function axi_dma_iowrite64function axi_dma_ioread64function axi_chan_iowrite32function axi_chan_ioread32function axi_chan_iowrite64function axi_chan_config_writefunction axi_dma_disablefunction axi_dma_enablefunction axi_dma_irq_disablefunction axi_dma_irq_enablefunction axi_chan_irq_disablefunction axi_chan_irq_setfunction axi_chan_irq_sig_setfunction axi_chan_irq_clearfunction axi_chan_irq_readfunction axi_chan_disablefunction axi_chan_enablefunction axi_chan_is_hw_enablefunction axi_dma_hw_initfunction axi_chan_get_xfer_widthfunction axi_desc_putfunction vchan_desc_putfunction dma_chan_tx_statusfunction write_desc_llpfunction write_chan_llpfunction dw_axi_dma_set_byte_halfwordfunction axi_chan_block_xfer_startfunction axi_chan_start_first_queuedfunction dma_chan_issue_pendingfunction dw_axi_dma_synchronizefunction dma_chan_alloc_chan_resourcesfunction dma_chan_free_chan_resourcesfunction dw_axi_dma_set_hw_channelfunction set_desc_lastfunction write_desc_sarfunction write_desc_darfunction set_desc_src_masterfunction set_desc_dest_masterfunction dw_axi_dma_set_hw_descfunction calculate_block_lenfunction dw_axi_dma_chan_prep_cyclicfunction dw_axi_dma_chan_prep_slave_sgfunction for_each_sgfunction dma_chan_prep_dma_memcpyfunction dw_axi_dma_chan_slave_configfunction axi_chan_dump_lli
Annotated Snippet
if (chan->id >= DMAC_CHAN_16) {
val &= ~((u64)(BIT(chan->id) >> DMAC_CHAN_16)
<< (DMAC_CHAN_EN_SHIFT + DMAC_CHAN_BLOCK_SHIFT));
val |= (u64)(BIT(chan->id) >> DMAC_CHAN_16)
<< (DMAC_CHAN_EN2_WE_SHIFT + DMAC_CHAN_BLOCK_SHIFT);
} else {
val &= ~(BIT(chan->id) << DMAC_CHAN_EN_SHIFT);
val |= BIT(chan->id) << DMAC_CHAN_EN2_WE_SHIFT;
}
axi_dma_iowrite64(chan->chip, DMAC_CHEN, val);
} else {
val = axi_dma_ioread32(chan->chip, DMAC_CHEN);
val &= ~(BIT(chan->id) << DMAC_CHAN_EN_SHIFT);
if (chan->chip->dw->hdata->reg_map_8_channels)
val |= BIT(chan->id) << DMAC_CHAN_EN_WE_SHIFT;
else
val |= BIT(chan->id) << DMAC_CHAN_EN2_WE_SHIFT;
axi_dma_iowrite32(chan->chip, DMAC_CHEN, (u32)val);
}
}
static inline void axi_chan_enable(struct axi_dma_chan *chan)
{
u64 val;
if (chan->chip->dw->hdata->nr_channels >= DMAC_CHAN_16) {
val = axi_dma_ioread64(chan->chip, DMAC_CHEN);
if (chan->id >= DMAC_CHAN_16) {
val |= (u64)(BIT(chan->id) >> DMAC_CHAN_16)
<< (DMAC_CHAN_EN_SHIFT + DMAC_CHAN_BLOCK_SHIFT) |
(u64)(BIT(chan->id) >> DMAC_CHAN_16)
<< (DMAC_CHAN_EN2_WE_SHIFT + DMAC_CHAN_BLOCK_SHIFT);
} else {
val |= BIT(chan->id) << DMAC_CHAN_EN_SHIFT |
BIT(chan->id) << DMAC_CHAN_EN2_WE_SHIFT;
}
axi_dma_iowrite64(chan->chip, DMAC_CHEN, val);
} else {
val = axi_dma_ioread32(chan->chip, DMAC_CHEN);
if (chan->chip->dw->hdata->reg_map_8_channels) {
val |= BIT(chan->id) << DMAC_CHAN_EN_SHIFT |
BIT(chan->id) << DMAC_CHAN_EN_WE_SHIFT;
} else {
val |= BIT(chan->id) << DMAC_CHAN_EN_SHIFT |
BIT(chan->id) << DMAC_CHAN_EN2_WE_SHIFT;
}
axi_dma_iowrite32(chan->chip, DMAC_CHEN, (u32)val);
}
}
static inline bool axi_chan_is_hw_enable(struct axi_dma_chan *chan)
{
u64 val;
if (chan->chip->dw->hdata->nr_channels >= DMAC_CHAN_16)
val = axi_dma_ioread64(chan->chip, DMAC_CHEN);
else
val = axi_dma_ioread32(chan->chip, DMAC_CHEN);
if (chan->id >= DMAC_CHAN_16)
return !!(val & ((u64)(BIT(chan->id) >> DMAC_CHAN_16) << DMAC_CHAN_BLOCK_SHIFT));
else
return !!(val & (BIT(chan->id) << DMAC_CHAN_EN_SHIFT));
}
static void axi_dma_hw_init(struct axi_dma_chip *chip)
{
int ret;
u32 i;
for (i = 0; i < chip->dw->hdata->nr_channels; i++) {
axi_chan_irq_disable(&chip->dw->chan[i], DWAXIDMAC_IRQ_ALL);
axi_chan_disable(&chip->dw->chan[i]);
}
ret = dma_set_mask_and_coherent(chip->dev, DMA_BIT_MASK(64));
if (ret)
dev_warn(chip->dev, "Unable to set coherent mask\n");
}
static u32 axi_chan_get_xfer_width(struct axi_dma_chan *chan, dma_addr_t src,
dma_addr_t dst, size_t len)
{
u32 max_width = chan->chip->dw->hdata->m_data_width;
return __ffs(src | dst | len | BIT(max_width));
}
static inline const char *axi_chan_name(struct axi_dma_chan *chan)
{
return dma_chan_name(&chan->vc.chan);
Annotation
- Immediate include surface: `linux/bitops.h`, `linux/delay.h`, `linux/device.h`, `linux/dmaengine.h`, `linux/dmapool.h`, `linux/dma-mapping.h`, `linux/err.h`, `linux/interrupt.h`.
- Detected declarations: `function bits`, `function axi_dma_ioread32`, `function axi_dma_iowrite64`, `function axi_dma_ioread64`, `function axi_chan_iowrite32`, `function axi_chan_ioread32`, `function axi_chan_iowrite64`, `function axi_chan_config_write`, `function axi_dma_disable`, `function axi_dma_enable`.
- 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.