/* asm/dma.h: Defines for using and allocating dma channels.1* Written by Hennus Bergman, 1992.2* High DMA channel support & info by Hannu Savolainen3* and John Boyd, Nov. 1992.4* (c) Copyright 2000, Grant Grundler5*/67#ifndef _ASM_DMA_H8#define _ASM_DMA_H910#include <asm/io.h> /* need byte IO */11#include <asm/system.h>1213#define dma_outb outb14#define dma_inb inb1516/*17** DMA_CHUNK_SIZE is used by the SCSI mid-layer to break up18** (or rather not merge) DMAs into manageable chunks.19** On parisc, this is more of the software/tuning constraint20** rather than the HW. I/O MMU allocation algorithms can be21** faster with smaller sizes (to some degree).22*/23#define DMA_CHUNK_SIZE (BITS_PER_LONG*PAGE_SIZE)2425/* The maximum address that we can perform a DMA transfer to on this platform26** New dynamic DMA interfaces should obsolete this....27*/28#define MAX_DMA_ADDRESS (~0UL)2930/*31** We don't have DMA channels... well V-class does but the32** Dynamic DMA Mapping interface will support them... right? :^)33** Note: this is not relevant right now for PA-RISC, but we cannot34** leave this as undefined because some things (e.g. sound)35** won't compile :-(36*/37#define MAX_DMA_CHANNELS 838#define DMA_MODE_READ 0x44 /* I/O to memory, no autoinit, increment, single mode */39#define DMA_MODE_WRITE 0x48 /* memory to I/O, no autoinit, increment, single mode */40#define DMA_MODE_CASCADE 0xC0 /* pass thru DREQ->HRQ, DACK<-HLDA only */4142#define DMA_AUTOINIT 0x104344/* 8237 DMA controllers */45#define IO_DMA1_BASE 0x00 /* 8 bit slave DMA, channels 0..3 */46#define IO_DMA2_BASE 0xC0 /* 16 bit master DMA, ch 4(=slave input)..7 */4748/* DMA controller registers */49#define DMA1_CMD_REG 0x08 /* command register (w) */50#define DMA1_STAT_REG 0x08 /* status register (r) */51#define DMA1_REQ_REG 0x09 /* request register (w) */52#define DMA1_MASK_REG 0x0A /* single-channel mask (w) */53#define DMA1_MODE_REG 0x0B /* mode register (w) */54#define DMA1_CLEAR_FF_REG 0x0C /* clear pointer flip-flop (w) */55#define DMA1_TEMP_REG 0x0D /* Temporary Register (r) */56#define DMA1_RESET_REG 0x0D /* Master Clear (w) */57#define DMA1_CLR_MASK_REG 0x0E /* Clear Mask */58#define DMA1_MASK_ALL_REG 0x0F /* all-channels mask (w) */59#define DMA1_EXT_MODE_REG (0x400 | DMA1_MODE_REG)6061#define DMA2_CMD_REG 0xD0 /* command register (w) */62#define DMA2_STAT_REG 0xD0 /* status register (r) */63#define DMA2_REQ_REG 0xD2 /* request register (w) */64#define DMA2_MASK_REG 0xD4 /* single-channel mask (w) */65#define DMA2_MODE_REG 0xD6 /* mode register (w) */66#define DMA2_CLEAR_FF_REG 0xD8 /* clear pointer flip-flop (w) */67#define DMA2_TEMP_REG 0xDA /* Temporary Register (r) */68#define DMA2_RESET_REG 0xDA /* Master Clear (w) */69#define DMA2_CLR_MASK_REG 0xDC /* Clear Mask */70#define DMA2_MASK_ALL_REG 0xDE /* all-channels mask (w) */71#define DMA2_EXT_MODE_REG (0x400 | DMA2_MODE_REG)7273static __inline__ unsigned long claim_dma_lock(void)74{75return 0;76}7778static __inline__ void release_dma_lock(unsigned long flags)79{80}818283/* Get DMA residue count. After a DMA transfer, this84* should return zero. Reading this while a DMA transfer is85* still in progress will return unpredictable results.86* If called before the channel has been used, it may return 1.87* Otherwise, it returns the number of _bytes_ left to transfer.88*89* Assumes DMA flip-flop is clear.90*/91static __inline__ int get_dma_residue(unsigned int dmanr)92{93unsigned int io_port = (dmanr<=3)? ((dmanr&3)<<1) + 1 + IO_DMA1_BASE94: ((dmanr&3)<<2) + 2 + IO_DMA2_BASE;9596/* using short to get 16-bit wrap around */97unsigned short count;9899count = 1 + dma_inb(io_port);100count += dma_inb(io_port) << 8;101102return (dmanr<=3)? count : (count<<1);103}104105/* enable/disable a specific DMA channel */106static __inline__ void enable_dma(unsigned int dmanr)107{108#ifdef CONFIG_SUPERIO109if (dmanr<=3)110dma_outb(dmanr, DMA1_MASK_REG);111else112dma_outb(dmanr & 3, DMA2_MASK_REG);113#endif114}115116static __inline__ void disable_dma(unsigned int dmanr)117{118#ifdef CONFIG_SUPERIO119if (dmanr<=3)120dma_outb(dmanr | 4, DMA1_MASK_REG);121else122dma_outb((dmanr & 3) | 4, DMA2_MASK_REG);123#endif124}125126/* reserve a DMA channel */127#define request_dma(dmanr, device_id) (0)128129/* Clear the 'DMA Pointer Flip Flop'.130* Write 0 for LSB/MSB, 1 for MSB/LSB access.131* Use this once to initialize the FF to a known state.132* After that, keep track of it. :-)133* --- In order to do that, the DMA routines below should ---134* --- only be used while holding the DMA lock ! ---135*/136static __inline__ void clear_dma_ff(unsigned int dmanr)137{138}139140/* set mode (above) for a specific DMA channel */141static __inline__ void set_dma_mode(unsigned int dmanr, char mode)142{143}144145/* Set only the page register bits of the transfer address.146* This is used for successive transfers when we know the contents of147* the lower 16 bits of the DMA current address register, but a 64k boundary148* may have been crossed.149*/150static __inline__ void set_dma_page(unsigned int dmanr, char pagenr)151{152}153154155/* Set transfer address & page bits for specific DMA channel.156* Assumes dma flipflop is clear.157*/158static __inline__ void set_dma_addr(unsigned int dmanr, unsigned int a)159{160}161162163/* Set transfer size (max 64k for DMA1..3, 128k for DMA5..7) for164* a specific DMA channel.165* You must ensure the parameters are valid.166* NOTE: from a manual: "the number of transfers is one more167* than the initial word count"! This is taken into account.168* Assumes dma flip-flop is clear.169* NOTE 2: "count" represents _bytes_ and must be even for channels 5-7.170*/171static __inline__ void set_dma_count(unsigned int dmanr, unsigned int count)172{173}174175176#define free_dma(dmanr)177178#ifdef CONFIG_PCI179extern int isa_dma_bridge_buggy;180#else181#define isa_dma_bridge_buggy (0)182#endif183184#endif /* _ASM_DMA_H */185186187