/* * Copyright 1991-1998 by Open Software Foundation, Inc. * All Rights Reserved * * Permission to use, copy, modify, and distribute this software and * its documentation for any purpose and without fee is hereby granted, * provided that the above copyright notice appears in all copies and * that both the copyright notice and this permission notice appear in * supporting documentation. * * OSF DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS * FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL OSF BE LIABLE FOR ANY SPECIAL, INDIRECT, OR * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM * LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT, * NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * * from: OpenBSD: dbdma.h,v 1.2.6.1 2002/10/29 00:28:06 ar * $FreeBSD$ */ #ifndef _POWERPC_POWERMAC_DBDMA_H_ #define _POWERPC_POWERMAC_DBDMA_H_ /* * Format of DBDMA commands * * NOTE - this is in little-endian */ struct dbdma_command { uint16_t d_count; uint16_t d_command; uint32_t d_address; uint32_t d_cmddep; uint16_t d_resid; uint16_t d_status; }; /* * Command.cmd - type of data transfer */ #define DBDMA_CMD_OUT_MORE 0 #define DBDMA_CMD_OUT_LAST 1 #define DBDMA_CMD_IN_MORE 2 #define DBDMA_CMD_IN_LAST 3 #define DBDMA_CMD_STORE_QUAD 4 #define DBDMA_CMD_LOAD_QUAD 5 #define DBDMA_CMD_NOP 6 #define DBDMA_CMD_STOP 7 /* * Command.key - which device access port will be used. * STREAM0-3 are dev-dependent. */ #define DBDMA_KEY_STREAM0 0 #define DBDMA_KEY_STREAM1 1 #define DBDMA_KEY_STREAM2 2 #define DBDMA_KEY_STREAM3 3 #define DBDMA_KEY_RESERVED4 4 #define DBDMA_KEY_REGS 5 #define DBDMA_KEY_SYSTEM 6 #define DBDMA_KEY_DEVICE 7 /* * Command.i interrupt-on-completion conditions */ #define DBDMA_INT_NEVER 0 #define DBDMA_INT_IF_TRUE 1 #define DBDMA_INT_IF_FALSE 2 #define DBDMA_INT_ALWAYS 3 /* * Command.b branch condition */ #define DBDMA_BRANCH_NEVER 0 #define DBDMA_BRANCH_IF_TRUE 1 #define DBDMA_BRANCH_IF_FALSE 2 #define DBDMA_BRANCH_ALWAYS 3 /* * Command.w fetch-next-command wait condition */ #define DBDMA_WAIT_NEVER 0 #define DBDMA_WAIT_IF_TRUE 1 #define DBDMA_WAIT_IF_FALSE 2 #define DBDMA_WAIT_ALWAYS 3 /* * DBDMA Channel layout */ #define DBDMA_CREG_CNTRL 0x00 /* control register */ #define DBDMA_CREG_STATUS 0x04 /* DBDMA status register */ #define DBDMA_CREG_CMDPTR_HI 0x08 /* command pointer MSB */ #define DBDMA_CREG_CMDPTR_LO 0x0c /* command pointer LSB */ #define DBDMA_CREG_INTSEL 0x10 /* interrupt select */ #define DBDMA_CREG_BRANCH 0x14 /* branch select */ #define DBDMA_CREG_WAIT 0x18 /* wait select */ #define DBDMA_CREG_TMODE 0x1c /* transfer modes */ #define DBDMA_CREG_DPTR_HI 0x20 /* data pointer MSB */ #define DBDMA_CREG_DPTR_LO 0x24 /* data pointer LSB */ /* offset 0x28 unused */ #define DBDMA_CREG_BPTR_HI 0x2c /* branch pointer MSB */ #define DBDMA_CREG_BPTR_LO 0x30 /* branch pointer LSB */ /* * Control register values */ #define DBDMA_STATUS_MASK 0x000000ff /* Status Mask */ #define DBDMA_CNTRL_BRANCH 0x00000100 /* 0x200 reserved */ #define DBDMA_CNTRL_ACTIVE 0x00000400 #define DBDMA_CNTRL_DEAD 0x00000800 #define DBDMA_CNTRL_WAKE 0x00001000 #define DBDMA_CNTRL_FLUSH 0x00002000 #define DBDMA_CNTRL_PAUSE 0x00004000 #define DBDMA_CNTRL_RUN 0x00008000 #define DBDMA_SET_CNTRL(x) ( ((x) | (x) << 16) ) #define DBDMA_CLEAR_CNTRL(x) ( (x) << 16) #define DBDMA_COUNT_MAX 0x8000 /* * DBDMA routines */ /* * dbdma_desc: passed the SYS_MEMORY resource for the dbdma channel memory, * and the number of desired dbdma commands in the command array. Returns * an opaque descriptor structure that is used for all subsequent api calls. * NULL will be returned if system dma memory could not be allocated. */ struct dbdma_desc; struct dbdma_desc *dbdma_alloc(device_t dev, struct resource *, int); void dbdma_free(struct dbdma_desc *dsc); /* Dispose command structures */ /* * Command scheduling routines */ void dbdma_start(struct dbdma_desc *dsc); void dbdma_stop(struct dbdma_desc *dsc); void dbdma_flush(struct dbdma_desc *dsc); void dbdma_reset(struct dbdma_desc *dsc); void dbdma_continue(struct dbdma_desc *dsc); void dbdma_pause(struct dbdma_desc *dsc); /* * Build a short-form and long-form command at a given index * in the command array */ void dbdma_build_cmd(struct dbdma_desc *dsc, int cmdidx, int cmd, int key, int interrupt, int wait, int branch); void dbdma_build(struct dbdma_desc *dsc, int cmdidx, int cmd, int key, int interrupt, int wait, int branch, int count, int address); /* * Extract a field from a command at a given index */ /* e.g. uint16_t dbdma_get_count(struct dbdma_desc *, int cmdidx) */ /* * High 16 bits of resid to identify dbdma channel register * memory resources */ #define DBDMA_RESID 0xdbda0000 #endif /* _POWERPC_POWERMAC_DBDMA_H_ */