/* SPDX-License-Identifier: GPL-2.0 */1#ifndef __ASM_ARM_DMA_H2#define __ASM_ARM_DMA_H34/*5* This is the maximum virtual address which can be DMA'd from.6*/7#ifndef CONFIG_ZONE_DMA8#define MAX_DMA_ADDRESS 0xffffffffUL9#else10#define MAX_DMA_ADDRESS ({ \11extern phys_addr_t arm_dma_zone_size; \12arm_dma_zone_size && arm_dma_zone_size < (0x100000000ULL - PAGE_OFFSET) ? \13(PAGE_OFFSET + arm_dma_zone_size) : 0xffffffffUL; })1415extern phys_addr_t arm_dma_limit;16#define ARCH_LOW_ADDRESS_LIMIT arm_dma_limit17#endif1819#ifdef CONFIG_ISA_DMA_API20/*21* This is used to support drivers written for the x86 ISA DMA API.22* It should not be re-used except for that purpose.23*/24#include <linux/spinlock.h>25#include <linux/scatterlist.h>2627#include <mach/isa-dma.h>2829/*30* The DMA modes reflect the settings for the ISA DMA controller31*/32#define DMA_MODE_MASK 0xcc3334#define DMA_MODE_READ 0x4435#define DMA_MODE_WRITE 0x4836#define DMA_MODE_CASCADE 0xc037#define DMA_AUTOINIT 0x103839extern raw_spinlock_t dma_spin_lock;4041static inline unsigned long claim_dma_lock(void)42{43unsigned long flags;44raw_spin_lock_irqsave(&dma_spin_lock, flags);45return flags;46}4748static inline void release_dma_lock(unsigned long flags)49{50raw_spin_unlock_irqrestore(&dma_spin_lock, flags);51}5253/* Clear the 'DMA Pointer Flip Flop'.54* Write 0 for LSB/MSB, 1 for MSB/LSB access.55*/56#define clear_dma_ff(chan)5758/* Set only the page register bits of the transfer address.59*60* NOTE: This is an architecture specific function, and should61* be hidden from the drivers62*/63extern void set_dma_page(unsigned int chan, char pagenr);6465/* Request a DMA channel66*67* Some architectures may need to do allocate an interrupt68*/69extern int request_dma(unsigned int chan, const char * device_id);7071/* Free a DMA channel72*73* Some architectures may need to do free an interrupt74*/75extern void free_dma(unsigned int chan);7677/* Enable DMA for this channel78*79* On some architectures, this may have other side effects like80* enabling an interrupt and setting the DMA registers.81*/82extern void enable_dma(unsigned int chan);8384/* Disable DMA for this channel85*86* On some architectures, this may have other side effects like87* disabling an interrupt or whatever.88*/89extern void disable_dma(unsigned int chan);9091/* Test whether the specified channel has an active DMA transfer92*/93extern int dma_channel_active(unsigned int chan);9495/* Set the DMA scatter gather list for this channel96*97* This should not be called if a DMA channel is enabled,98* especially since some DMA architectures don't update the99* DMA address immediately, but defer it to the enable_dma().100*/101extern void set_dma_sg(unsigned int chan, struct scatterlist *sg, int nr_sg);102103/* Set the DMA address for this channel104*105* This should not be called if a DMA channel is enabled,106* especially since some DMA architectures don't update the107* DMA address immediately, but defer it to the enable_dma().108*/109extern void __set_dma_addr(unsigned int chan, void *addr);110#define set_dma_addr(chan, addr) \111__set_dma_addr(chan, (void *)isa_bus_to_virt(addr))112113/* Set the DMA byte count for this channel114*115* This should not be called if a DMA channel is enabled,116* especially since some DMA architectures don't update the117* DMA count immediately, but defer it to the enable_dma().118*/119extern void set_dma_count(unsigned int chan, unsigned long count);120121/* Set the transfer direction for this channel122*123* This should not be called if a DMA channel is enabled,124* especially since some DMA architectures don't update the125* DMA transfer direction immediately, but defer it to the126* enable_dma().127*/128extern void set_dma_mode(unsigned int chan, unsigned int mode);129130/* Set the transfer speed for this channel131*/132extern void set_dma_speed(unsigned int chan, int cycle_ns);133134/* Get DMA residue count. After a DMA transfer, this135* should return zero. Reading this while a DMA transfer is136* still in progress will return unpredictable results.137* If called before the channel has been used, it may return 1.138* Otherwise, it returns the number of _bytes_ left to transfer.139*/140extern int get_dma_residue(unsigned int chan);141142#ifndef NO_DMA143#define NO_DMA 255144#endif145146#endif /* CONFIG_ISA_DMA_API */147148#endif /* __ASM_ARM_DMA_H */149150151