// SPDX-License-Identifier: GPL-2.0-only /* * linux/arch/arm/kernel/dma.c * * Copyright (C) 1995-2000 Russell King * * Front-end to the DMA handling. This handles the allocation/freeing * of DMA channels, and provides a unified interface to the machines * DMA facilities.
*/ #include <linux/module.h> #include <linux/init.h> #include <linux/spinlock.h> #include <linux/errno.h> #include <linux/scatterlist.h> #include <linux/seq_file.h> #include <linux/proc_fs.h>
int __init isa_dma_add(unsignedint chan, dma_t *dma)
{ if (!dma->d_ops) return -EINVAL;
sg_init_table(&dma->buf, 1);
if (dma_chan[chan]) return -EBUSY;
dma_chan[chan] = dma; return 0;
}
/* * Request DMA channel * * On certain platforms, we have to allocate an interrupt as well...
*/ int request_dma(unsignedint chan, constchar *device_id)
{
dma_t *dma = dma_channel(chan); int ret;
/* * Free DMA channel * * On certain platforms, we have to free interrupt as well...
*/ void free_dma(unsignedint chan)
{
dma_t *dma = dma_channel(chan);
if (!dma) goto bad_dma;
if (dma->active) {
pr_err("dma%d: freeing active DMA\n", chan);
dma->d_ops->disable(chan, dma);
dma->active = 0;
}
if (xchg(&dma->lock, 0) != 0) { if (dma->d_ops->free)
dma->d_ops->free(chan, dma); return;
}
pr_err("dma%d: trying to free free DMA\n", chan); return;
bad_dma:
pr_err("dma: trying to free DMA%d\n", chan);
}
EXPORT_SYMBOL(free_dma);
/* Set DMA Scatter-Gather list
*/ void set_dma_sg (unsignedint chan, struct scatterlist *sg, int nr_sg)
{
dma_t *dma = dma_channel(chan);
if (dma->active)
pr_err("dma%d: altering DMA SG while DMA active\n", chan);
/* Set DMA address * * Copy address to the structure, and set the invalid bit
*/ void __set_dma_addr (unsignedint chan, void *addr)
{
dma_t *dma = dma_channel(chan);
if (dma->active)
pr_err("dma%d: altering DMA address while DMA active\n", chan);
/* Set DMA byte count * * Copy address to the structure, and set the invalid bit
*/ void set_dma_count (unsignedint chan, unsignedlong count)
{
dma_t *dma = dma_channel(chan);
if (dma->active)
pr_err("dma%d: altering DMA count while DMA active\n", chan);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.