152890Sbostic /*- 252890Sbostic * Copyright (c) 1992 The Regents of the University of California. 352890Sbostic * All rights reserved. 452890Sbostic * 552890Sbostic * This code is derived from software contributed to Berkeley by 6*56819Sralph * Ralph Campbell and Rick Macklem. 752890Sbostic * 852890Sbostic * %sccs.include.redist.c% 952890Sbostic * 10*56819Sralph * @(#)ascreg.h 7.2 (Berkeley) 11/15/92 1152890Sbostic */ 1252890Sbostic 1352890Sbostic /* 1452890Sbostic * Mach Operating System 1552890Sbostic * Copyright (c) 1991,1990,1989 Carnegie Mellon University 1652890Sbostic * All Rights Reserved. 1752890Sbostic * 1852890Sbostic * Permission to use, copy, modify and distribute this software and its 1952890Sbostic * documentation is hereby granted, provided that both the copyright 2052890Sbostic * notice and this permission notice appear in all copies of the 2152890Sbostic * software, derivative works or modified versions, and any portions 2252890Sbostic * thereof, and that both notices appear in supporting documentation. 2352890Sbostic * 2452890Sbostic * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS 2552890Sbostic * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR 2652890Sbostic * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. 2752890Sbostic * 2852890Sbostic * Carnegie Mellon requests users of this software to return to 2952890Sbostic * 3052890Sbostic * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU 3152890Sbostic * School of Computer Science 3252890Sbostic * Carnegie Mellon University 3352890Sbostic * Pittsburgh PA 15213-3890 3452890Sbostic * 3552890Sbostic * any improvements or extensions that they make and grant Carnegie the 3652890Sbostic * rights to redistribute these changes. 3752890Sbostic */ 3852890Sbostic 3952890Sbostic /* 4052890Sbostic * HISTORY 4152890Sbostic * $Log: scsi_53C94.h,v $ 4252890Sbostic * Revision 2.4 91/02/05 17:44:59 mrt 4352890Sbostic * Added author notices 4452890Sbostic * [91/02/04 11:18:32 mrt] 4552890Sbostic * 4652890Sbostic * Changed to use new Mach copyright 4752890Sbostic * [91/02/02 12:17:11 mrt] 4852890Sbostic * 4952890Sbostic * Revision 2.3 90/12/05 23:34:46 af 5052890Sbostic * Documented max DMA xfer size. 5152890Sbostic * [90/12/03 23:39:36 af] 5252890Sbostic * 5352890Sbostic * Revision 2.1.1.1 90/11/01 03:38:54 af 5452890Sbostic * Created, from the DEC specs: 5552890Sbostic * "PMAZ-AA TURBOchannel SCSI Module Functional Specification" 5652890Sbostic * Workstation Systems Engineering, Palo Alto, CA. Aug 27, 1990. 5752890Sbostic * And from the NCR data sheets 5852890Sbostic * "NCR 53C94, 53C95, 53C96 Advanced SCSI Controller" 5952890Sbostic * [90/09/03 af] 6052890Sbostic */ 6152890Sbostic 6252890Sbostic /* 6352890Sbostic * File: scsi_53C94.h 6452890Sbostic * Author: Alessandro Forin, Carnegie Mellon University 6552890Sbostic * Date: 9/90 6652890Sbostic * 6752890Sbostic * Defines for the NCR 53C94 ASC (SCSI interface) 6852890Sbostic * Some gotcha came from the "86C01/53C94 DMA lab work" written 6952890Sbostic * by Ken Stewart (NCR MED Logic Products Applications Engineer) 7052890Sbostic * courtesy of NCR. Thanks Ken ! 7152890Sbostic */ 7252890Sbostic 7352890Sbostic /* 7452890Sbostic * Register map, padded as needed 7552890Sbostic */ 7652890Sbostic 7752890Sbostic typedef volatile struct { 7852890Sbostic u_char asc_tc_lsb; /* rw: Transfer Counter LSB */ 7952890Sbostic char pad0[3]; 8052890Sbostic u_char asc_tc_msb; /* rw: Transfer Counter MSB */ 8152890Sbostic char pad1[3]; 8252890Sbostic u_char asc_fifo; /* rw: FIFO top */ 8352890Sbostic char pad2[3]; 8452890Sbostic u_char asc_cmd; /* rw: Command */ 8552890Sbostic char pad3[3]; 8652890Sbostic u_char asc_status; /* r: Status */ 8752890Sbostic #define asc_dbus_id asc_status /* w: Destination Bus ID */ 8852890Sbostic char pad4[3]; 8952890Sbostic u_char asc_intr; /* r: Interrupt */ 9052890Sbostic #define asc_sel_timo asc_intr /* w: (re)select timeout */ 9152890Sbostic char pad5[3]; 9252890Sbostic u_char asc_ss; /* r: Sequence Step */ 9352890Sbostic #define asc_syn_p asc_ss /* w: synchronous period */ 9452890Sbostic char pad6[3]; 9552890Sbostic u_char asc_flags; /* r: FIFO flags + seq step */ 9652890Sbostic #define asc_syn_o asc_flags /* w: synchronous offset */ 9752890Sbostic char pad7[3]; 9852890Sbostic u_char asc_cnfg1; /* rw: Configuration 1 */ 9952890Sbostic char pad8[3]; 10052890Sbostic u_char asc_ccf; /* w: Clock Conv. Factor */ 10152890Sbostic char pad9[3]; 10252890Sbostic u_char asc_test; /* w: Test Mode */ 10352890Sbostic char pad10[3]; 10452890Sbostic u_char asc_cnfg2; /* rw: Configuration 2 */ 10552890Sbostic char pad11[3]; 10652890Sbostic u_char asc_cnfg3; /* rw: Configuration 3 */ 10752890Sbostic char pad12[3]; 10852890Sbostic u_char asc_res_fifo; /* w: Reserve FIFO byte */ 10952890Sbostic } asc_regmap_t; 11052890Sbostic 11152890Sbostic /* 11252890Sbostic * Transfer Count: access macros 11352890Sbostic * That a NOP is required after loading the dma counter 11452890Sbostic * I learned on the NCR test code. Sic. 11552890Sbostic */ 11652890Sbostic 11752890Sbostic #define ASC_TC_MAX 0x10000 11852890Sbostic 11952890Sbostic #define ASC_TC_GET(ptr, val) \ 12052890Sbostic val = (ptr)->asc_tc_lsb | ((ptr)->asc_tc_msb << 8) 12152890Sbostic #define ASC_TC_PUT(ptr, val) \ 12252890Sbostic (ptr)->asc_tc_lsb = (val); \ 12352890Sbostic (ptr)->asc_tc_msb = (val) >> 8; \ 124*56819Sralph (ptr)->asc_cmd = ASC_CMD_NOP | ASC_CMD_DMA; 12552890Sbostic 12652890Sbostic /* 12752890Sbostic * Command register (command codes) 12852890Sbostic */ 12952890Sbostic 13052890Sbostic #define ASC_CMD_DMA 0x80 13152890Sbostic /* Miscellaneous */ 13252890Sbostic #define ASC_CMD_NOP 0x00 13352890Sbostic #define ASC_CMD_FLUSH 0x01 13452890Sbostic #define ASC_CMD_RESET 0x02 13552890Sbostic #define ASC_CMD_BUS_RESET 0x03 13652890Sbostic /* Initiator state */ 13752890Sbostic #define ASC_CMD_XFER_INFO 0x10 13852890Sbostic #define ASC_CMD_I_COMPLETE 0x11 13952890Sbostic #define ASC_CMD_MSG_ACPT 0x12 14052890Sbostic #define ASC_CMD_XFER_PAD 0x18 14152890Sbostic #define ASC_CMD_SET_ATN 0x1a 14252890Sbostic #define ASC_CMD_CLR_ATN 0x1b 14352890Sbostic /* Target state */ 14452890Sbostic #define ASC_CMD_SND_MSG 0x20 14552890Sbostic #define ASC_CMD_SND_STATUS 0x21 14652890Sbostic #define ASC_CMD_SND_DATA 0x22 14752890Sbostic #define ASC_CMD_DISC_SEQ 0x23 14852890Sbostic #define ASC_CMD_TERM 0x24 14952890Sbostic #define ASC_CMD_T_COMPLETE 0x25 15052890Sbostic #define ASC_CMD_DISC 0x27 15152890Sbostic #define ASC_CMD_RCV_MSG 0x28 15252890Sbostic #define ASC_CMD_RCV_CDB 0x29 15352890Sbostic #define ASC_CMD_RCV_DATA 0x2a 15452890Sbostic #define ASC_CMD_RCV_CMD 0x2b 15552890Sbostic #define ASC_CMD_ABRT_DMA 0x04 15652890Sbostic /* Disconnected state */ 15752890Sbostic #define ASC_CMD_RESELECT 0x40 15852890Sbostic #define ASC_CMD_SEL 0x41 15952890Sbostic #define ASC_CMD_SEL_ATN 0x42 16052890Sbostic #define ASC_CMD_SEL_ATN_STOP 0x43 16152890Sbostic #define ASC_CMD_ENABLE_SEL 0x44 16252890Sbostic #define ASC_CMD_DISABLE_SEL 0x45 16352890Sbostic #define ASC_CMD_SEL_ATN3 0x46 16452890Sbostic 16552890Sbostic /* 16652890Sbostic * Status register, and phase encoding 16752890Sbostic */ 16852890Sbostic 16952890Sbostic #define ASC_CSR_INT 0x80 17052890Sbostic #define ASC_CSR_GE 0x40 17152890Sbostic #define ASC_CSR_PE 0x20 17252890Sbostic #define ASC_CSR_TC 0x10 17352890Sbostic #define ASC_CSR_VGC 0x08 17452890Sbostic #define ASC_CSR_MSG 0x04 17552890Sbostic #define ASC_CSR_CD 0x02 17652890Sbostic #define ASC_CSR_IO 0x01 17752890Sbostic 17852890Sbostic #define ASC_PHASE(csr) ((csr) & 0x7) 17952890Sbostic #define ASC_PHASE_DATAO 0x0 18052890Sbostic #define ASC_PHASE_DATAI 0x1 18152890Sbostic #define ASC_PHASE_COMMAND 0x2 18252890Sbostic #define ASC_PHASE_STATUS 0x3 18352890Sbostic /* 4..5 ANSI reserved */ 18452890Sbostic #define ASC_PHASE_MSG_OUT 0x6 18552890Sbostic #define ASC_PHASE_MSG_IN 0x7 18652890Sbostic 18752890Sbostic /* 18852890Sbostic * Destination Bus ID 18952890Sbostic */ 19052890Sbostic 19152890Sbostic #define ASC_DEST_ID_MASK 0x07 19252890Sbostic 19352890Sbostic /* 19452890Sbostic * Interrupt register 19552890Sbostic */ 19652890Sbostic 19752890Sbostic #define ASC_INT_RESET 0x80 19852890Sbostic #define ASC_INT_ILL 0x40 19952890Sbostic #define ASC_INT_DISC 0x20 20052890Sbostic #define ASC_INT_BS 0x10 20152890Sbostic #define ASC_INT_FC 0x08 20252890Sbostic #define ASC_INT_RESEL 0x04 20352890Sbostic #define ASC_INT_SEL_ATN 0x02 20452890Sbostic #define ASC_INT_SEL 0x01 20552890Sbostic 20652890Sbostic /* 20752890Sbostic * Timeout register: 20852890Sbostic * 20952890Sbostic * val = (timeout * CLK_freq) / (8192 * CCF); 21052890Sbostic */ 21152890Sbostic 212*56819Sralph #define ASC_TIMEOUT_250(clk, ccf) (((clk) * 31) / (ccf)) 21352890Sbostic 21452890Sbostic /* 21552890Sbostic * Sequence Step register 21652890Sbostic */ 21752890Sbostic 21852890Sbostic #define ASC_SS_RESERVED 0xf0 21952890Sbostic #define ASC_SS_SOM 0x08 22052890Sbostic #define ASC_SS_MASK 0x07 22152890Sbostic #define ASC_SS(ss) ((ss) & ASC_SS_MASK) 22252890Sbostic 22352890Sbostic /* 22452890Sbostic * Synchronous Transfer Period 22552890Sbostic */ 22652890Sbostic 22752890Sbostic #define ASC_STP_MASK 0x1f 22852890Sbostic #define ASC_STP_MIN 0x05 /* 5 clk per byte */ 22952890Sbostic #define ASC_STP_MAX 0x04 /* after ovfl, 35 clk/byte */ 23052890Sbostic 23152890Sbostic /* 23252890Sbostic * FIFO flags 23352890Sbostic */ 23452890Sbostic 23552890Sbostic #define ASC_FLAGS_SEQ_STEP 0xe0 23652890Sbostic #define ASC_FLAGS_FIFO_CNT 0x1f 23752890Sbostic 23852890Sbostic /* 23952890Sbostic * Synchronous offset 24052890Sbostic */ 24152890Sbostic 24252890Sbostic #define ASC_SYNO_MASK 0x0f /* 0 -> asyn */ 24352890Sbostic 24452890Sbostic /* 24552890Sbostic * Configuration 1 24652890Sbostic */ 24752890Sbostic 24852890Sbostic #define ASC_CNFG1_SLOW 0x80 24952890Sbostic #define ASC_CNFG1_SRD 0x40 25052890Sbostic #define ASC_CNFG1_P_TEST 0x20 25152890Sbostic #define ASC_CNFG1_P_CHECK 0x10 25252890Sbostic #define ASC_CNFG1_TEST 0x08 25352890Sbostic #define ASC_CNFG1_MY_BUS_ID 0x07 25452890Sbostic 25552890Sbostic /* 25652890Sbostic * CCF register 25752890Sbostic */ 25852890Sbostic 259*56819Sralph #define ASC_CCF(clk) ((((clk) - 1) / 5) + 1) 26052890Sbostic 26152890Sbostic /* 26252890Sbostic * Test register 26352890Sbostic */ 26452890Sbostic 26552890Sbostic #define ASC_TEST_XXXX 0xf8 26652890Sbostic #define ASC_TEST_HI_Z 0x04 26752890Sbostic #define ASC_TEST_I 0x02 26852890Sbostic #define ASC_TEST_T 0x01 26952890Sbostic 27052890Sbostic /* 27152890Sbostic * Configuration 2 27252890Sbostic */ 27352890Sbostic 27452890Sbostic #define ASC_CNFG2_RFB 0x80 27552890Sbostic #define ASC_CNFG2_EPL 0x40 27652890Sbostic #define ASC_CNFG2_EBC 0x20 27752890Sbostic #define ASC_CNFG2_DREQ_HIZ 0x10 27852890Sbostic #define ASC_CNFG2_SCSI2 0x08 27952890Sbostic #define ASC_CNFG2_BPA 0x04 28052890Sbostic #define ASC_CNFG2_RPE 0x02 28152890Sbostic #define ASC_CNFG2_DPE 0x01 28252890Sbostic 28352890Sbostic /* 28452890Sbostic * Configuration 3 28552890Sbostic */ 28652890Sbostic 28752890Sbostic #define ASC_CNFG3_RESERVED 0xf8 28852890Sbostic #define ASC_CNFG3_SRB 0x04 28952890Sbostic #define ASC_CNFG3_ALT_DMA 0x02 29052890Sbostic #define ASC_CNFG3_T8 0x01 291