drivers/spi/spi-pxa2xx-dma.c
Source file repositories/reference/linux-study-clean/drivers/spi/spi-pxa2xx-dma.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/spi/spi-pxa2xx-dma.c- Extension
.c- Size
- 5817 bytes
- Lines
- 226
- Domain
- Driver Families
- Bucket
- drivers/spi
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/atomic.hlinux/dev_printk.hlinux/dma-mapping.hlinux/dmaengine.hlinux/errno.hlinux/irqreturn.hlinux/scatterlist.hlinux/string.hlinux/types.hlinux/spi/spi.hspi-pxa2xx.h
Detected Declarations
struct devicefunction pxa2xx_spi_dma_transfer_completefunction pxa2xx_spi_dma_callbackfunction pxa2xx_spi_dma_prepare_onefunction pxa2xx_spi_dma_transferfunction pxa2xx_spi_dma_preparefunction pxa2xx_spi_dma_startfunction pxa2xx_spi_dma_stopfunction pxa2xx_spi_dma_setupfunction pxa2xx_spi_dma_release
Annotated Snippet
if (error) {
/* In case we got an error we disable the SSP now */
pxa_ssp_disable(drv_data->ssp);
msg->status = -EIO;
}
spi_finalize_current_transfer(drv_data->controller);
}
}
static void pxa2xx_spi_dma_callback(void *data)
{
pxa2xx_spi_dma_transfer_complete(data, false);
}
static struct dma_async_tx_descriptor *
pxa2xx_spi_dma_prepare_one(struct driver_data *drv_data,
enum dma_transfer_direction dir,
struct spi_transfer *xfer)
{
enum dma_slave_buswidth width;
struct dma_slave_config cfg;
struct dma_chan *chan;
struct sg_table *sgt;
int ret;
switch (drv_data->n_bytes) {
case 1:
width = DMA_SLAVE_BUSWIDTH_1_BYTE;
break;
case 2:
width = DMA_SLAVE_BUSWIDTH_2_BYTES;
break;
default:
width = DMA_SLAVE_BUSWIDTH_4_BYTES;
break;
}
memset(&cfg, 0, sizeof(cfg));
cfg.direction = dir;
if (dir == DMA_MEM_TO_DEV) {
cfg.dst_addr = drv_data->ssp->phys_base + SSDR;
cfg.dst_addr_width = width;
cfg.dst_maxburst = drv_data->controller_info->dma_burst_size;
sgt = &xfer->tx_sg;
chan = drv_data->controller->dma_tx;
} else {
cfg.src_addr = drv_data->ssp->phys_base + SSDR;
cfg.src_addr_width = width;
cfg.src_maxburst = drv_data->controller_info->dma_burst_size;
sgt = &xfer->rx_sg;
chan = drv_data->controller->dma_rx;
}
ret = dmaengine_slave_config(chan, &cfg);
if (ret) {
dev_warn(drv_data->ssp->dev, "DMA slave config failed\n");
return NULL;
}
return dmaengine_prep_slave_sg(chan, sgt->sgl, sgt->nents, dir,
DMA_PREP_INTERRUPT | DMA_CTRL_ACK);
}
irqreturn_t pxa2xx_spi_dma_transfer(struct driver_data *drv_data)
{
u32 status;
status = read_SSSR_bits(drv_data, drv_data->mask_sr);
if (status & SSSR_ROR) {
dev_err(drv_data->ssp->dev, "FIFO overrun\n");
dmaengine_terminate_async(drv_data->controller->dma_rx);
dmaengine_terminate_async(drv_data->controller->dma_tx);
pxa2xx_spi_dma_transfer_complete(drv_data, true);
return IRQ_HANDLED;
}
return IRQ_NONE;
}
int pxa2xx_spi_dma_prepare(struct driver_data *drv_data,
struct spi_transfer *xfer)
{
struct dma_async_tx_descriptor *tx_desc, *rx_desc;
int err;
Annotation
- Immediate include surface: `linux/atomic.h`, `linux/dev_printk.h`, `linux/dma-mapping.h`, `linux/dmaengine.h`, `linux/errno.h`, `linux/irqreturn.h`, `linux/scatterlist.h`, `linux/string.h`.
- Detected declarations: `struct device`, `function pxa2xx_spi_dma_transfer_complete`, `function pxa2xx_spi_dma_callback`, `function pxa2xx_spi_dma_prepare_one`, `function pxa2xx_spi_dma_transfer`, `function pxa2xx_spi_dma_prepare`, `function pxa2xx_spi_dma_start`, `function pxa2xx_spi_dma_stop`, `function pxa2xx_spi_dma_setup`, `function pxa2xx_spi_dma_release`.
- Atlas domain: Driver Families / drivers/spi.
- 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.