162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 262306a36Sopenharmony_ci#ifndef _ASM_POWERPC_DMA_H 362306a36Sopenharmony_ci#define _ASM_POWERPC_DMA_H 462306a36Sopenharmony_ci#ifdef __KERNEL__ 562306a36Sopenharmony_ci 662306a36Sopenharmony_ci/* 762306a36Sopenharmony_ci * Defines for using and allocating dma channels. 862306a36Sopenharmony_ci * Written by Hennus Bergman, 1992. 962306a36Sopenharmony_ci * High DMA channel support & info by Hannu Savolainen 1062306a36Sopenharmony_ci * and John Boyd, Nov. 1992. 1162306a36Sopenharmony_ci * Changes for ppc sound by Christoph Nadig 1262306a36Sopenharmony_ci */ 1362306a36Sopenharmony_ci 1462306a36Sopenharmony_ci/* 1562306a36Sopenharmony_ci * Note: Adapted for PowerPC by Gary Thomas 1662306a36Sopenharmony_ci * Modified by Cort Dougan <cort@cs.nmt.edu> 1762306a36Sopenharmony_ci * 1862306a36Sopenharmony_ci * None of this really applies for Power Macintoshes. There is 1962306a36Sopenharmony_ci * basically just enough here to get kernel/dma.c to compile. 2062306a36Sopenharmony_ci */ 2162306a36Sopenharmony_ci 2262306a36Sopenharmony_ci#include <asm/io.h> 2362306a36Sopenharmony_ci#include <linux/spinlock.h> 2462306a36Sopenharmony_ci 2562306a36Sopenharmony_ci#ifndef MAX_DMA_CHANNELS 2662306a36Sopenharmony_ci#define MAX_DMA_CHANNELS 8 2762306a36Sopenharmony_ci#endif 2862306a36Sopenharmony_ci 2962306a36Sopenharmony_ci/* The maximum address that we can perform a DMA transfer to on this platform */ 3062306a36Sopenharmony_ci/* Doesn't really apply... */ 3162306a36Sopenharmony_ci#define MAX_DMA_ADDRESS (~0UL) 3262306a36Sopenharmony_ci 3362306a36Sopenharmony_ci#ifdef HAVE_REALLY_SLOW_DMA_CONTROLLER 3462306a36Sopenharmony_ci#define dma_outb outb_p 3562306a36Sopenharmony_ci#else 3662306a36Sopenharmony_ci#define dma_outb outb 3762306a36Sopenharmony_ci#endif 3862306a36Sopenharmony_ci 3962306a36Sopenharmony_ci#define dma_inb inb 4062306a36Sopenharmony_ci 4162306a36Sopenharmony_ci/* 4262306a36Sopenharmony_ci * NOTES about DMA transfers: 4362306a36Sopenharmony_ci * 4462306a36Sopenharmony_ci * controller 1: channels 0-3, byte operations, ports 00-1F 4562306a36Sopenharmony_ci * controller 2: channels 4-7, word operations, ports C0-DF 4662306a36Sopenharmony_ci * 4762306a36Sopenharmony_ci * - ALL registers are 8 bits only, regardless of transfer size 4862306a36Sopenharmony_ci * - channel 4 is not used - cascades 1 into 2. 4962306a36Sopenharmony_ci * - channels 0-3 are byte - addresses/counts are for physical bytes 5062306a36Sopenharmony_ci * - channels 5-7 are word - addresses/counts are for physical words 5162306a36Sopenharmony_ci * - transfers must not cross physical 64K (0-3) or 128K (5-7) boundaries 5262306a36Sopenharmony_ci * - transfer count loaded to registers is 1 less than actual count 5362306a36Sopenharmony_ci * - controller 2 offsets are all even (2x offsets for controller 1) 5462306a36Sopenharmony_ci * - page registers for 5-7 don't use data bit 0, represent 128K pages 5562306a36Sopenharmony_ci * - page registers for 0-3 use bit 0, represent 64K pages 5662306a36Sopenharmony_ci * 5762306a36Sopenharmony_ci * On CHRP, the W83C553F (and VLSI Tollgate?) support full 32 bit addressing. 5862306a36Sopenharmony_ci * Note that addresses loaded into registers must be _physical_ addresses, 5962306a36Sopenharmony_ci * not logical addresses (which may differ if paging is active). 6062306a36Sopenharmony_ci * 6162306a36Sopenharmony_ci * Address mapping for channels 0-3: 6262306a36Sopenharmony_ci * 6362306a36Sopenharmony_ci * A23 ... A16 A15 ... A8 A7 ... A0 (Physical addresses) 6462306a36Sopenharmony_ci * | ... | | ... | | ... | 6562306a36Sopenharmony_ci * | ... | | ... | | ... | 6662306a36Sopenharmony_ci * | ... | | ... | | ... | 6762306a36Sopenharmony_ci * P7 ... P0 A7 ... A0 A7 ... A0 6862306a36Sopenharmony_ci * | Page | Addr MSB | Addr LSB | (DMA registers) 6962306a36Sopenharmony_ci * 7062306a36Sopenharmony_ci * Address mapping for channels 5-7: 7162306a36Sopenharmony_ci * 7262306a36Sopenharmony_ci * A23 ... A17 A16 A15 ... A9 A8 A7 ... A1 A0 (Physical addresses) 7362306a36Sopenharmony_ci * | ... | \ \ ... \ \ \ ... \ \ 7462306a36Sopenharmony_ci * | ... | \ \ ... \ \ \ ... \ (not used) 7562306a36Sopenharmony_ci * | ... | \ \ ... \ \ \ ... \ 7662306a36Sopenharmony_ci * P7 ... P1 (0) A7 A6 ... A0 A7 A6 ... A0 7762306a36Sopenharmony_ci * | Page | Addr MSB | Addr LSB | (DMA registers) 7862306a36Sopenharmony_ci * 7962306a36Sopenharmony_ci * Again, channels 5-7 transfer _physical_ words (16 bits), so addresses 8062306a36Sopenharmony_ci * and counts _must_ be word-aligned (the lowest address bit is _ignored_ at 8162306a36Sopenharmony_ci * the hardware level, so odd-byte transfers aren't possible). 8262306a36Sopenharmony_ci * 8362306a36Sopenharmony_ci * Transfer count (_not # bytes_) is limited to 64K, represented as actual 8462306a36Sopenharmony_ci * count - 1 : 64K => 0xFFFF, 1 => 0x0000. Thus, count is always 1 or more, 8562306a36Sopenharmony_ci * and up to 128K bytes may be transferred on channels 5-7 in one operation. 8662306a36Sopenharmony_ci * 8762306a36Sopenharmony_ci */ 8862306a36Sopenharmony_ci 8962306a36Sopenharmony_ci/* 8237 DMA controllers */ 9062306a36Sopenharmony_ci#define IO_DMA1_BASE 0x00 /* 8 bit slave DMA, channels 0..3 */ 9162306a36Sopenharmony_ci#define IO_DMA2_BASE 0xC0 /* 16 bit master DMA, ch 4(=slave input)..7 */ 9262306a36Sopenharmony_ci 9362306a36Sopenharmony_ci/* DMA controller registers */ 9462306a36Sopenharmony_ci#define DMA1_CMD_REG 0x08 /* command register (w) */ 9562306a36Sopenharmony_ci#define DMA1_STAT_REG 0x08 /* status register (r) */ 9662306a36Sopenharmony_ci#define DMA1_REQ_REG 0x09 /* request register (w) */ 9762306a36Sopenharmony_ci#define DMA1_MASK_REG 0x0A /* single-channel mask (w) */ 9862306a36Sopenharmony_ci#define DMA1_MODE_REG 0x0B /* mode register (w) */ 9962306a36Sopenharmony_ci#define DMA1_CLEAR_FF_REG 0x0C /* clear pointer flip-flop (w) */ 10062306a36Sopenharmony_ci#define DMA1_TEMP_REG 0x0D /* Temporary Register (r) */ 10162306a36Sopenharmony_ci#define DMA1_RESET_REG 0x0D /* Master Clear (w) */ 10262306a36Sopenharmony_ci#define DMA1_CLR_MASK_REG 0x0E /* Clear Mask */ 10362306a36Sopenharmony_ci#define DMA1_MASK_ALL_REG 0x0F /* all-channels mask (w) */ 10462306a36Sopenharmony_ci 10562306a36Sopenharmony_ci#define DMA2_CMD_REG 0xD0 /* command register (w) */ 10662306a36Sopenharmony_ci#define DMA2_STAT_REG 0xD0 /* status register (r) */ 10762306a36Sopenharmony_ci#define DMA2_REQ_REG 0xD2 /* request register (w) */ 10862306a36Sopenharmony_ci#define DMA2_MASK_REG 0xD4 /* single-channel mask (w) */ 10962306a36Sopenharmony_ci#define DMA2_MODE_REG 0xD6 /* mode register (w) */ 11062306a36Sopenharmony_ci#define DMA2_CLEAR_FF_REG 0xD8 /* clear pointer flip-flop (w) */ 11162306a36Sopenharmony_ci#define DMA2_TEMP_REG 0xDA /* Temporary Register (r) */ 11262306a36Sopenharmony_ci#define DMA2_RESET_REG 0xDA /* Master Clear (w) */ 11362306a36Sopenharmony_ci#define DMA2_CLR_MASK_REG 0xDC /* Clear Mask */ 11462306a36Sopenharmony_ci#define DMA2_MASK_ALL_REG 0xDE /* all-channels mask (w) */ 11562306a36Sopenharmony_ci 11662306a36Sopenharmony_ci#define DMA_ADDR_0 0x00 /* DMA address registers */ 11762306a36Sopenharmony_ci#define DMA_ADDR_1 0x02 11862306a36Sopenharmony_ci#define DMA_ADDR_2 0x04 11962306a36Sopenharmony_ci#define DMA_ADDR_3 0x06 12062306a36Sopenharmony_ci#define DMA_ADDR_4 0xC0 12162306a36Sopenharmony_ci#define DMA_ADDR_5 0xC4 12262306a36Sopenharmony_ci#define DMA_ADDR_6 0xC8 12362306a36Sopenharmony_ci#define DMA_ADDR_7 0xCC 12462306a36Sopenharmony_ci 12562306a36Sopenharmony_ci#define DMA_CNT_0 0x01 /* DMA count registers */ 12662306a36Sopenharmony_ci#define DMA_CNT_1 0x03 12762306a36Sopenharmony_ci#define DMA_CNT_2 0x05 12862306a36Sopenharmony_ci#define DMA_CNT_3 0x07 12962306a36Sopenharmony_ci#define DMA_CNT_4 0xC2 13062306a36Sopenharmony_ci#define DMA_CNT_5 0xC6 13162306a36Sopenharmony_ci#define DMA_CNT_6 0xCA 13262306a36Sopenharmony_ci#define DMA_CNT_7 0xCE 13362306a36Sopenharmony_ci 13462306a36Sopenharmony_ci#define DMA_LO_PAGE_0 0x87 /* DMA page registers */ 13562306a36Sopenharmony_ci#define DMA_LO_PAGE_1 0x83 13662306a36Sopenharmony_ci#define DMA_LO_PAGE_2 0x81 13762306a36Sopenharmony_ci#define DMA_LO_PAGE_3 0x82 13862306a36Sopenharmony_ci#define DMA_LO_PAGE_5 0x8B 13962306a36Sopenharmony_ci#define DMA_LO_PAGE_6 0x89 14062306a36Sopenharmony_ci#define DMA_LO_PAGE_7 0x8A 14162306a36Sopenharmony_ci 14262306a36Sopenharmony_ci#define DMA_HI_PAGE_0 0x487 /* DMA page registers */ 14362306a36Sopenharmony_ci#define DMA_HI_PAGE_1 0x483 14462306a36Sopenharmony_ci#define DMA_HI_PAGE_2 0x481 14562306a36Sopenharmony_ci#define DMA_HI_PAGE_3 0x482 14662306a36Sopenharmony_ci#define DMA_HI_PAGE_5 0x48B 14762306a36Sopenharmony_ci#define DMA_HI_PAGE_6 0x489 14862306a36Sopenharmony_ci#define DMA_HI_PAGE_7 0x48A 14962306a36Sopenharmony_ci 15062306a36Sopenharmony_ci#define DMA1_EXT_REG 0x40B 15162306a36Sopenharmony_ci#define DMA2_EXT_REG 0x4D6 15262306a36Sopenharmony_ci 15362306a36Sopenharmony_ci#ifndef __powerpc64__ 15462306a36Sopenharmony_ci /* in arch/powerpc/kernel/setup_32.c -- Cort */ 15562306a36Sopenharmony_ci extern unsigned int DMA_MODE_WRITE; 15662306a36Sopenharmony_ci extern unsigned int DMA_MODE_READ; 15762306a36Sopenharmony_ci#else 15862306a36Sopenharmony_ci #define DMA_MODE_READ 0x44 /* I/O to memory, no autoinit, increment, single mode */ 15962306a36Sopenharmony_ci #define DMA_MODE_WRITE 0x48 /* memory to I/O, no autoinit, increment, single mode */ 16062306a36Sopenharmony_ci#endif 16162306a36Sopenharmony_ci 16262306a36Sopenharmony_ci#define DMA_MODE_CASCADE 0xC0 /* pass thru DREQ->HRQ, DACK<-HLDA only */ 16362306a36Sopenharmony_ci 16462306a36Sopenharmony_ci#define DMA_AUTOINIT 0x10 16562306a36Sopenharmony_ci 16662306a36Sopenharmony_ciextern spinlock_t dma_spin_lock; 16762306a36Sopenharmony_ci 16862306a36Sopenharmony_cistatic __inline__ unsigned long claim_dma_lock(void) 16962306a36Sopenharmony_ci{ 17062306a36Sopenharmony_ci unsigned long flags; 17162306a36Sopenharmony_ci spin_lock_irqsave(&dma_spin_lock, flags); 17262306a36Sopenharmony_ci return flags; 17362306a36Sopenharmony_ci} 17462306a36Sopenharmony_ci 17562306a36Sopenharmony_cistatic __inline__ void release_dma_lock(unsigned long flags) 17662306a36Sopenharmony_ci{ 17762306a36Sopenharmony_ci spin_unlock_irqrestore(&dma_spin_lock, flags); 17862306a36Sopenharmony_ci} 17962306a36Sopenharmony_ci 18062306a36Sopenharmony_ci/* enable/disable a specific DMA channel */ 18162306a36Sopenharmony_cistatic __inline__ void enable_dma(unsigned int dmanr) 18262306a36Sopenharmony_ci{ 18362306a36Sopenharmony_ci unsigned char ucDmaCmd = 0x00; 18462306a36Sopenharmony_ci 18562306a36Sopenharmony_ci if (dmanr != 4) { 18662306a36Sopenharmony_ci dma_outb(0, DMA2_MASK_REG); /* This may not be enabled */ 18762306a36Sopenharmony_ci dma_outb(ucDmaCmd, DMA2_CMD_REG); /* Enable group */ 18862306a36Sopenharmony_ci } 18962306a36Sopenharmony_ci if (dmanr <= 3) { 19062306a36Sopenharmony_ci dma_outb(dmanr, DMA1_MASK_REG); 19162306a36Sopenharmony_ci dma_outb(ucDmaCmd, DMA1_CMD_REG); /* Enable group */ 19262306a36Sopenharmony_ci } else { 19362306a36Sopenharmony_ci dma_outb(dmanr & 3, DMA2_MASK_REG); 19462306a36Sopenharmony_ci } 19562306a36Sopenharmony_ci} 19662306a36Sopenharmony_ci 19762306a36Sopenharmony_cistatic __inline__ void disable_dma(unsigned int dmanr) 19862306a36Sopenharmony_ci{ 19962306a36Sopenharmony_ci if (dmanr <= 3) 20062306a36Sopenharmony_ci dma_outb(dmanr | 4, DMA1_MASK_REG); 20162306a36Sopenharmony_ci else 20262306a36Sopenharmony_ci dma_outb((dmanr & 3) | 4, DMA2_MASK_REG); 20362306a36Sopenharmony_ci} 20462306a36Sopenharmony_ci 20562306a36Sopenharmony_ci/* Clear the 'DMA Pointer Flip Flop'. 20662306a36Sopenharmony_ci * Write 0 for LSB/MSB, 1 for MSB/LSB access. 20762306a36Sopenharmony_ci * Use this once to initialize the FF to a known state. 20862306a36Sopenharmony_ci * After that, keep track of it. :-) 20962306a36Sopenharmony_ci * --- In order to do that, the DMA routines below should --- 21062306a36Sopenharmony_ci * --- only be used while interrupts are disabled! --- 21162306a36Sopenharmony_ci */ 21262306a36Sopenharmony_cistatic __inline__ void clear_dma_ff(unsigned int dmanr) 21362306a36Sopenharmony_ci{ 21462306a36Sopenharmony_ci if (dmanr <= 3) 21562306a36Sopenharmony_ci dma_outb(0, DMA1_CLEAR_FF_REG); 21662306a36Sopenharmony_ci else 21762306a36Sopenharmony_ci dma_outb(0, DMA2_CLEAR_FF_REG); 21862306a36Sopenharmony_ci} 21962306a36Sopenharmony_ci 22062306a36Sopenharmony_ci/* set mode (above) for a specific DMA channel */ 22162306a36Sopenharmony_cistatic __inline__ void set_dma_mode(unsigned int dmanr, char mode) 22262306a36Sopenharmony_ci{ 22362306a36Sopenharmony_ci if (dmanr <= 3) 22462306a36Sopenharmony_ci dma_outb(mode | dmanr, DMA1_MODE_REG); 22562306a36Sopenharmony_ci else 22662306a36Sopenharmony_ci dma_outb(mode | (dmanr & 3), DMA2_MODE_REG); 22762306a36Sopenharmony_ci} 22862306a36Sopenharmony_ci 22962306a36Sopenharmony_ci/* Set only the page register bits of the transfer address. 23062306a36Sopenharmony_ci * This is used for successive transfers when we know the contents of 23162306a36Sopenharmony_ci * the lower 16 bits of the DMA current address register, but a 64k boundary 23262306a36Sopenharmony_ci * may have been crossed. 23362306a36Sopenharmony_ci */ 23462306a36Sopenharmony_cistatic __inline__ void set_dma_page(unsigned int dmanr, int pagenr) 23562306a36Sopenharmony_ci{ 23662306a36Sopenharmony_ci switch (dmanr) { 23762306a36Sopenharmony_ci case 0: 23862306a36Sopenharmony_ci dma_outb(pagenr, DMA_LO_PAGE_0); 23962306a36Sopenharmony_ci dma_outb(pagenr >> 8, DMA_HI_PAGE_0); 24062306a36Sopenharmony_ci break; 24162306a36Sopenharmony_ci case 1: 24262306a36Sopenharmony_ci dma_outb(pagenr, DMA_LO_PAGE_1); 24362306a36Sopenharmony_ci dma_outb(pagenr >> 8, DMA_HI_PAGE_1); 24462306a36Sopenharmony_ci break; 24562306a36Sopenharmony_ci case 2: 24662306a36Sopenharmony_ci dma_outb(pagenr, DMA_LO_PAGE_2); 24762306a36Sopenharmony_ci dma_outb(pagenr >> 8, DMA_HI_PAGE_2); 24862306a36Sopenharmony_ci break; 24962306a36Sopenharmony_ci case 3: 25062306a36Sopenharmony_ci dma_outb(pagenr, DMA_LO_PAGE_3); 25162306a36Sopenharmony_ci dma_outb(pagenr >> 8, DMA_HI_PAGE_3); 25262306a36Sopenharmony_ci break; 25362306a36Sopenharmony_ci case 5: 25462306a36Sopenharmony_ci dma_outb(pagenr & 0xfe, DMA_LO_PAGE_5); 25562306a36Sopenharmony_ci dma_outb(pagenr >> 8, DMA_HI_PAGE_5); 25662306a36Sopenharmony_ci break; 25762306a36Sopenharmony_ci case 6: 25862306a36Sopenharmony_ci dma_outb(pagenr & 0xfe, DMA_LO_PAGE_6); 25962306a36Sopenharmony_ci dma_outb(pagenr >> 8, DMA_HI_PAGE_6); 26062306a36Sopenharmony_ci break; 26162306a36Sopenharmony_ci case 7: 26262306a36Sopenharmony_ci dma_outb(pagenr & 0xfe, DMA_LO_PAGE_7); 26362306a36Sopenharmony_ci dma_outb(pagenr >> 8, DMA_HI_PAGE_7); 26462306a36Sopenharmony_ci break; 26562306a36Sopenharmony_ci } 26662306a36Sopenharmony_ci} 26762306a36Sopenharmony_ci 26862306a36Sopenharmony_ci/* Set transfer address & page bits for specific DMA channel. 26962306a36Sopenharmony_ci * Assumes dma flipflop is clear. 27062306a36Sopenharmony_ci */ 27162306a36Sopenharmony_cistatic __inline__ void set_dma_addr(unsigned int dmanr, unsigned int phys) 27262306a36Sopenharmony_ci{ 27362306a36Sopenharmony_ci if (dmanr <= 3) { 27462306a36Sopenharmony_ci dma_outb(phys & 0xff, 27562306a36Sopenharmony_ci ((dmanr & 3) << 1) + IO_DMA1_BASE); 27662306a36Sopenharmony_ci dma_outb((phys >> 8) & 0xff, 27762306a36Sopenharmony_ci ((dmanr & 3) << 1) + IO_DMA1_BASE); 27862306a36Sopenharmony_ci } else { 27962306a36Sopenharmony_ci dma_outb((phys >> 1) & 0xff, 28062306a36Sopenharmony_ci ((dmanr & 3) << 2) + IO_DMA2_BASE); 28162306a36Sopenharmony_ci dma_outb((phys >> 9) & 0xff, 28262306a36Sopenharmony_ci ((dmanr & 3) << 2) + IO_DMA2_BASE); 28362306a36Sopenharmony_ci } 28462306a36Sopenharmony_ci set_dma_page(dmanr, phys >> 16); 28562306a36Sopenharmony_ci} 28662306a36Sopenharmony_ci 28762306a36Sopenharmony_ci 28862306a36Sopenharmony_ci/* Set transfer size (max 64k for DMA1..3, 128k for DMA5..7) for 28962306a36Sopenharmony_ci * a specific DMA channel. 29062306a36Sopenharmony_ci * You must ensure the parameters are valid. 29162306a36Sopenharmony_ci * NOTE: from a manual: "the number of transfers is one more 29262306a36Sopenharmony_ci * than the initial word count"! This is taken into account. 29362306a36Sopenharmony_ci * Assumes dma flip-flop is clear. 29462306a36Sopenharmony_ci * NOTE 2: "count" represents _bytes_ and must be even for channels 5-7. 29562306a36Sopenharmony_ci */ 29662306a36Sopenharmony_cistatic __inline__ void set_dma_count(unsigned int dmanr, unsigned int count) 29762306a36Sopenharmony_ci{ 29862306a36Sopenharmony_ci count--; 29962306a36Sopenharmony_ci if (dmanr <= 3) { 30062306a36Sopenharmony_ci dma_outb(count & 0xff, 30162306a36Sopenharmony_ci ((dmanr & 3) << 1) + 1 + IO_DMA1_BASE); 30262306a36Sopenharmony_ci dma_outb((count >> 8) & 0xff, 30362306a36Sopenharmony_ci ((dmanr & 3) << 1) + 1 + IO_DMA1_BASE); 30462306a36Sopenharmony_ci } else { 30562306a36Sopenharmony_ci dma_outb((count >> 1) & 0xff, 30662306a36Sopenharmony_ci ((dmanr & 3) << 2) + 2 + IO_DMA2_BASE); 30762306a36Sopenharmony_ci dma_outb((count >> 9) & 0xff, 30862306a36Sopenharmony_ci ((dmanr & 3) << 2) + 2 + IO_DMA2_BASE); 30962306a36Sopenharmony_ci } 31062306a36Sopenharmony_ci} 31162306a36Sopenharmony_ci 31262306a36Sopenharmony_ci 31362306a36Sopenharmony_ci/* Get DMA residue count. After a DMA transfer, this 31462306a36Sopenharmony_ci * should return zero. Reading this while a DMA transfer is 31562306a36Sopenharmony_ci * still in progress will return unpredictable results. 31662306a36Sopenharmony_ci * If called before the channel has been used, it may return 1. 31762306a36Sopenharmony_ci * Otherwise, it returns the number of _bytes_ left to transfer. 31862306a36Sopenharmony_ci * 31962306a36Sopenharmony_ci * Assumes DMA flip-flop is clear. 32062306a36Sopenharmony_ci */ 32162306a36Sopenharmony_cistatic __inline__ int get_dma_residue(unsigned int dmanr) 32262306a36Sopenharmony_ci{ 32362306a36Sopenharmony_ci unsigned int io_port = (dmanr <= 3) 32462306a36Sopenharmony_ci ? ((dmanr & 3) << 1) + 1 + IO_DMA1_BASE 32562306a36Sopenharmony_ci : ((dmanr & 3) << 2) + 2 + IO_DMA2_BASE; 32662306a36Sopenharmony_ci 32762306a36Sopenharmony_ci /* using short to get 16-bit wrap around */ 32862306a36Sopenharmony_ci unsigned short count; 32962306a36Sopenharmony_ci 33062306a36Sopenharmony_ci count = 1 + dma_inb(io_port); 33162306a36Sopenharmony_ci count += dma_inb(io_port) << 8; 33262306a36Sopenharmony_ci 33362306a36Sopenharmony_ci return (dmanr <= 3) ? count : (count << 1); 33462306a36Sopenharmony_ci} 33562306a36Sopenharmony_ci 33662306a36Sopenharmony_ci/* These are in kernel/dma.c: */ 33762306a36Sopenharmony_ci 33862306a36Sopenharmony_ci/* reserve a DMA channel */ 33962306a36Sopenharmony_ciextern int request_dma(unsigned int dmanr, const char *device_id); 34062306a36Sopenharmony_ci/* release it again */ 34162306a36Sopenharmony_ciextern void free_dma(unsigned int dmanr); 34262306a36Sopenharmony_ci 34362306a36Sopenharmony_ci#endif /* __KERNEL__ */ 34462306a36Sopenharmony_ci#endif /* _ASM_POWERPC_DMA_H */ 345