Path: blob/master/arch/powerpc/include/asm/dbdma.h
15117 views
/*1* Definitions for using the Apple Descriptor-Based DMA controller2* in Power Macintosh computers.3*4* Copyright (C) 1996 Paul Mackerras.5*/67#ifdef __KERNEL__8#ifndef _ASM_DBDMA_H_9#define _ASM_DBDMA_H_10/*11* DBDMA control/status registers. All little-endian.12*/13struct dbdma_regs {14unsigned int control; /* lets you change bits in status */15unsigned int status; /* DMA and device status bits (see below) */16unsigned int cmdptr_hi; /* upper 32 bits of command address */17unsigned int cmdptr; /* (lower 32 bits of) command address (phys) */18unsigned int intr_sel; /* select interrupt condition bit */19unsigned int br_sel; /* select branch condition bit */20unsigned int wait_sel; /* select wait condition bit */21unsigned int xfer_mode;22unsigned int data2ptr_hi;23unsigned int data2ptr;24unsigned int res1;25unsigned int address_hi;26unsigned int br_addr_hi;27unsigned int res2[3];28};2930/* Bits in control and status registers */31#define RUN 0x800032#define PAUSE 0x400033#define FLUSH 0x200034#define WAKE 0x100035#define DEAD 0x080036#define ACTIVE 0x040037#define BT 0x010038#define DEVSTAT 0x00ff3940/*41* DBDMA command structure. These fields are all little-endian!42*/43struct dbdma_cmd {44unsigned short req_count; /* requested byte transfer count */45unsigned short command; /* command word (has bit-fields) */46unsigned int phy_addr; /* physical data address */47unsigned int cmd_dep; /* command-dependent field */48unsigned short res_count; /* residual count after completion */49unsigned short xfer_status; /* transfer status */50};5152/* DBDMA command values in command field */53#define OUTPUT_MORE 0 /* transfer memory data to stream */54#define OUTPUT_LAST 0x1000 /* ditto followed by end marker */55#define INPUT_MORE 0x2000 /* transfer stream data to memory */56#define INPUT_LAST 0x3000 /* ditto, expect end marker */57#define STORE_WORD 0x4000 /* write word (4 bytes) to device reg */58#define LOAD_WORD 0x5000 /* read word (4 bytes) from device reg */59#define DBDMA_NOP 0x6000 /* do nothing */60#define DBDMA_STOP 0x7000 /* suspend processing */6162/* Key values in command field */63#define KEY_STREAM0 0 /* usual data stream */64#define KEY_STREAM1 0x100 /* control/status stream */65#define KEY_STREAM2 0x200 /* device-dependent stream */66#define KEY_STREAM3 0x300 /* device-dependent stream */67#define KEY_REGS 0x500 /* device register space */68#define KEY_SYSTEM 0x600 /* system memory-mapped space */69#define KEY_DEVICE 0x700 /* device memory-mapped space */7071/* Interrupt control values in command field */72#define INTR_NEVER 0 /* don't interrupt */73#define INTR_IFSET 0x10 /* intr if condition bit is 1 */74#define INTR_IFCLR 0x20 /* intr if condition bit is 0 */75#define INTR_ALWAYS 0x30 /* always interrupt */7677/* Branch control values in command field */78#define BR_NEVER 0 /* don't branch */79#define BR_IFSET 0x4 /* branch if condition bit is 1 */80#define BR_IFCLR 0x8 /* branch if condition bit is 0 */81#define BR_ALWAYS 0xc /* always branch */8283/* Wait control values in command field */84#define WAIT_NEVER 0 /* don't wait */85#define WAIT_IFSET 1 /* wait if condition bit is 1 */86#define WAIT_IFCLR 2 /* wait if condition bit is 0 */87#define WAIT_ALWAYS 3 /* always wait */8889/* Align an address for a DBDMA command structure */90#define DBDMA_ALIGN(x) (((unsigned long)(x) + sizeof(struct dbdma_cmd) - 1) \91& -sizeof(struct dbdma_cmd))9293/* Useful macros */94#define DBDMA_DO_STOP(regs) do { \95out_le32(&((regs)->control), (RUN|FLUSH)<<16); \96while(in_le32(&((regs)->status)) & (ACTIVE|FLUSH)) \97; \98} while(0)99100#define DBDMA_DO_RESET(regs) do { \101out_le32(&((regs)->control), (ACTIVE|DEAD|WAKE|FLUSH|PAUSE|RUN)<<16);\102while(in_le32(&((regs)->status)) & (RUN)) \103; \104} while(0)105106#endif /* _ASM_DBDMA_H_ */107#endif /* __KERNEL__ */108109110