152890Sbostic /*- 2*63205Sbostic * Copyright (c) 1992, 1993 3*63205Sbostic * The Regents of the University of California. All rights reserved. 452890Sbostic * 552890Sbostic * This code is derived from software contributed to Berkeley by 656819Sralph * Ralph Campbell and Rick Macklem. 752890Sbostic * 852890Sbostic * %sccs.include.redist.c% 952890Sbostic * 10*63205Sbostic * @(#)ascreg.h 8.1 (Berkeley) 06/10/93 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 7357234Sralph #define ASC_OFFSET_53C94 0x0 /* from module base */ 7457234Sralph #define ASC_OFFSET_DMAR 0x40000 /* DMA Address Register */ 7557234Sralph #define ASC_OFFSET_RAM 0x80000 /* SRAM Buffer */ 7657234Sralph #define ASC_OFFSET_ROM 0xc0000 /* Diagnostic ROM */ 7757234Sralph 7857234Sralph #define ASC_RAM_SIZE 0x20000 /* 128k (32k*32) */ 7957234Sralph #define PER_TGT_DMA_SIZE ((ASC_RAM_SIZE/7) & ~(sizeof(int)-1)) 8057234Sralph #define ASC_NCMD 7 8157234Sralph 8252890Sbostic /* 8357234Sralph * DMA Address Register 8457234Sralph */ 8557234Sralph #define ASC_DMAR_MASK 0x1ffff /* 17 bits, 128k */ 8657234Sralph #define ASC_DMAR_WRITE 0x80000000 /* DMA direction bit */ 8757234Sralph #define ASC_DMA_ADDR(x) ((unsigned)(x) & ASC_DMAR_MASK) 8857234Sralph 8957234Sralph /* 9057234Sralph * Synch xfer parameters, and timing conversions 9157234Sralph */ 9257234Sralph #define SCSI_MIN_PERIOD 50 /* in 4 nsecs units */ 9357234Sralph #define ASC_MIN_PERIOD25 5 /* in CLKS/BYTE, 1 CLK = 40nsecs */ 9457234Sralph #define ASC_MIN_PERIOD12 3 /* in CLKS/BYTE, 1 CLK = 80nsecs */ 9557234Sralph #define ASC_MAX_PERIOD25 35 /* in CLKS/BYTE, 1 CLK = 40nsecs */ 9657234Sralph #define ASC_MAX_PERIOD12 18 /* in CLKS/BYTE, 1 CLK = 80nsecs */ 9757234Sralph #define ASC_MAX_OFFSET 15 /* pure number */ 9857234Sralph /* 9952890Sbostic * Register map, padded as needed 10052890Sbostic */ 10152890Sbostic 10252890Sbostic typedef volatile struct { 10352890Sbostic u_char asc_tc_lsb; /* rw: Transfer Counter LSB */ 10452890Sbostic char pad0[3]; 10552890Sbostic u_char asc_tc_msb; /* rw: Transfer Counter MSB */ 10652890Sbostic char pad1[3]; 10752890Sbostic u_char asc_fifo; /* rw: FIFO top */ 10852890Sbostic char pad2[3]; 10952890Sbostic u_char asc_cmd; /* rw: Command */ 11052890Sbostic char pad3[3]; 11152890Sbostic u_char asc_status; /* r: Status */ 11252890Sbostic #define asc_dbus_id asc_status /* w: Destination Bus ID */ 11352890Sbostic char pad4[3]; 11452890Sbostic u_char asc_intr; /* r: Interrupt */ 11552890Sbostic #define asc_sel_timo asc_intr /* w: (re)select timeout */ 11652890Sbostic char pad5[3]; 11752890Sbostic u_char asc_ss; /* r: Sequence Step */ 11852890Sbostic #define asc_syn_p asc_ss /* w: synchronous period */ 11952890Sbostic char pad6[3]; 12052890Sbostic u_char asc_flags; /* r: FIFO flags + seq step */ 12152890Sbostic #define asc_syn_o asc_flags /* w: synchronous offset */ 12252890Sbostic char pad7[3]; 12352890Sbostic u_char asc_cnfg1; /* rw: Configuration 1 */ 12452890Sbostic char pad8[3]; 12552890Sbostic u_char asc_ccf; /* w: Clock Conv. Factor */ 12652890Sbostic char pad9[3]; 12752890Sbostic u_char asc_test; /* w: Test Mode */ 12852890Sbostic char pad10[3]; 12952890Sbostic u_char asc_cnfg2; /* rw: Configuration 2 */ 13052890Sbostic char pad11[3]; 13152890Sbostic u_char asc_cnfg3; /* rw: Configuration 3 */ 13252890Sbostic char pad12[3]; 13352890Sbostic u_char asc_res_fifo; /* w: Reserve FIFO byte */ 13452890Sbostic } asc_regmap_t; 13552890Sbostic 13652890Sbostic /* 13752890Sbostic * Transfer Count: access macros 13852890Sbostic * That a NOP is required after loading the dma counter 13952890Sbostic * I learned on the NCR test code. Sic. 14052890Sbostic */ 14152890Sbostic 14252890Sbostic #define ASC_TC_MAX 0x10000 14352890Sbostic 14452890Sbostic #define ASC_TC_GET(ptr, val) \ 14552890Sbostic val = (ptr)->asc_tc_lsb | ((ptr)->asc_tc_msb << 8) 14652890Sbostic #define ASC_TC_PUT(ptr, val) \ 14752890Sbostic (ptr)->asc_tc_lsb = (val); \ 14852890Sbostic (ptr)->asc_tc_msb = (val) >> 8; \ 14956819Sralph (ptr)->asc_cmd = ASC_CMD_NOP | ASC_CMD_DMA; 15052890Sbostic 15152890Sbostic /* 15252890Sbostic * Command register (command codes) 15352890Sbostic */ 15452890Sbostic 15552890Sbostic #define ASC_CMD_DMA 0x80 15652890Sbostic /* Miscellaneous */ 15752890Sbostic #define ASC_CMD_NOP 0x00 15852890Sbostic #define ASC_CMD_FLUSH 0x01 15952890Sbostic #define ASC_CMD_RESET 0x02 16052890Sbostic #define ASC_CMD_BUS_RESET 0x03 16152890Sbostic /* Initiator state */ 16252890Sbostic #define ASC_CMD_XFER_INFO 0x10 16352890Sbostic #define ASC_CMD_I_COMPLETE 0x11 16452890Sbostic #define ASC_CMD_MSG_ACPT 0x12 16552890Sbostic #define ASC_CMD_XFER_PAD 0x18 16652890Sbostic #define ASC_CMD_SET_ATN 0x1a 16752890Sbostic #define ASC_CMD_CLR_ATN 0x1b 16852890Sbostic /* Target state */ 16952890Sbostic #define ASC_CMD_SND_MSG 0x20 17052890Sbostic #define ASC_CMD_SND_STATUS 0x21 17152890Sbostic #define ASC_CMD_SND_DATA 0x22 17252890Sbostic #define ASC_CMD_DISC_SEQ 0x23 17352890Sbostic #define ASC_CMD_TERM 0x24 17452890Sbostic #define ASC_CMD_T_COMPLETE 0x25 17552890Sbostic #define ASC_CMD_DISC 0x27 17652890Sbostic #define ASC_CMD_RCV_MSG 0x28 17752890Sbostic #define ASC_CMD_RCV_CDB 0x29 17852890Sbostic #define ASC_CMD_RCV_DATA 0x2a 17952890Sbostic #define ASC_CMD_RCV_CMD 0x2b 18052890Sbostic #define ASC_CMD_ABRT_DMA 0x04 18152890Sbostic /* Disconnected state */ 18252890Sbostic #define ASC_CMD_RESELECT 0x40 18352890Sbostic #define ASC_CMD_SEL 0x41 18452890Sbostic #define ASC_CMD_SEL_ATN 0x42 18552890Sbostic #define ASC_CMD_SEL_ATN_STOP 0x43 18652890Sbostic #define ASC_CMD_ENABLE_SEL 0x44 18752890Sbostic #define ASC_CMD_DISABLE_SEL 0x45 18852890Sbostic #define ASC_CMD_SEL_ATN3 0x46 18952890Sbostic 19052890Sbostic /* 19152890Sbostic * Status register, and phase encoding 19252890Sbostic */ 19352890Sbostic 19452890Sbostic #define ASC_CSR_INT 0x80 19552890Sbostic #define ASC_CSR_GE 0x40 19652890Sbostic #define ASC_CSR_PE 0x20 19752890Sbostic #define ASC_CSR_TC 0x10 19852890Sbostic #define ASC_CSR_VGC 0x08 19952890Sbostic #define ASC_CSR_MSG 0x04 20052890Sbostic #define ASC_CSR_CD 0x02 20152890Sbostic #define ASC_CSR_IO 0x01 20252890Sbostic 20352890Sbostic #define ASC_PHASE(csr) ((csr) & 0x7) 20452890Sbostic #define ASC_PHASE_DATAO 0x0 20552890Sbostic #define ASC_PHASE_DATAI 0x1 20652890Sbostic #define ASC_PHASE_COMMAND 0x2 20752890Sbostic #define ASC_PHASE_STATUS 0x3 20852890Sbostic /* 4..5 ANSI reserved */ 20952890Sbostic #define ASC_PHASE_MSG_OUT 0x6 21052890Sbostic #define ASC_PHASE_MSG_IN 0x7 21152890Sbostic 21252890Sbostic /* 21352890Sbostic * Destination Bus ID 21452890Sbostic */ 21552890Sbostic 21652890Sbostic #define ASC_DEST_ID_MASK 0x07 21752890Sbostic 21852890Sbostic /* 21952890Sbostic * Interrupt register 22052890Sbostic */ 22152890Sbostic 22252890Sbostic #define ASC_INT_RESET 0x80 22352890Sbostic #define ASC_INT_ILL 0x40 22452890Sbostic #define ASC_INT_DISC 0x20 22552890Sbostic #define ASC_INT_BS 0x10 22652890Sbostic #define ASC_INT_FC 0x08 22752890Sbostic #define ASC_INT_RESEL 0x04 22852890Sbostic #define ASC_INT_SEL_ATN 0x02 22952890Sbostic #define ASC_INT_SEL 0x01 23052890Sbostic 23152890Sbostic /* 23252890Sbostic * Timeout register: 23352890Sbostic * 23452890Sbostic * val = (timeout * CLK_freq) / (8192 * CCF); 23552890Sbostic */ 23652890Sbostic 23756819Sralph #define ASC_TIMEOUT_250(clk, ccf) (((clk) * 31) / (ccf)) 23852890Sbostic 23952890Sbostic /* 24052890Sbostic * Sequence Step register 24152890Sbostic */ 24252890Sbostic 24352890Sbostic #define ASC_SS_RESERVED 0xf0 24452890Sbostic #define ASC_SS_SOM 0x08 24552890Sbostic #define ASC_SS_MASK 0x07 24652890Sbostic #define ASC_SS(ss) ((ss) & ASC_SS_MASK) 24752890Sbostic 24852890Sbostic /* 24952890Sbostic * Synchronous Transfer Period 25052890Sbostic */ 25152890Sbostic 25252890Sbostic #define ASC_STP_MASK 0x1f 25352890Sbostic #define ASC_STP_MIN 0x05 /* 5 clk per byte */ 25452890Sbostic #define ASC_STP_MAX 0x04 /* after ovfl, 35 clk/byte */ 25552890Sbostic 25652890Sbostic /* 25752890Sbostic * FIFO flags 25852890Sbostic */ 25952890Sbostic 26052890Sbostic #define ASC_FLAGS_SEQ_STEP 0xe0 26152890Sbostic #define ASC_FLAGS_FIFO_CNT 0x1f 26252890Sbostic 26352890Sbostic /* 26452890Sbostic * Synchronous offset 26552890Sbostic */ 26652890Sbostic 26752890Sbostic #define ASC_SYNO_MASK 0x0f /* 0 -> asyn */ 26852890Sbostic 26952890Sbostic /* 27052890Sbostic * Configuration 1 27152890Sbostic */ 27252890Sbostic 27352890Sbostic #define ASC_CNFG1_SLOW 0x80 27452890Sbostic #define ASC_CNFG1_SRD 0x40 27552890Sbostic #define ASC_CNFG1_P_TEST 0x20 27652890Sbostic #define ASC_CNFG1_P_CHECK 0x10 27752890Sbostic #define ASC_CNFG1_TEST 0x08 27852890Sbostic #define ASC_CNFG1_MY_BUS_ID 0x07 27952890Sbostic 28052890Sbostic /* 28152890Sbostic * CCF register 28252890Sbostic */ 28352890Sbostic 28456819Sralph #define ASC_CCF(clk) ((((clk) - 1) / 5) + 1) 28552890Sbostic 28652890Sbostic /* 28752890Sbostic * Test register 28852890Sbostic */ 28952890Sbostic 29052890Sbostic #define ASC_TEST_XXXX 0xf8 29152890Sbostic #define ASC_TEST_HI_Z 0x04 29252890Sbostic #define ASC_TEST_I 0x02 29352890Sbostic #define ASC_TEST_T 0x01 29452890Sbostic 29552890Sbostic /* 29652890Sbostic * Configuration 2 29752890Sbostic */ 29852890Sbostic 29952890Sbostic #define ASC_CNFG2_RFB 0x80 30052890Sbostic #define ASC_CNFG2_EPL 0x40 30152890Sbostic #define ASC_CNFG2_EBC 0x20 30252890Sbostic #define ASC_CNFG2_DREQ_HIZ 0x10 30352890Sbostic #define ASC_CNFG2_SCSI2 0x08 30452890Sbostic #define ASC_CNFG2_BPA 0x04 30552890Sbostic #define ASC_CNFG2_RPE 0x02 30652890Sbostic #define ASC_CNFG2_DPE 0x01 30752890Sbostic 30852890Sbostic /* 30952890Sbostic * Configuration 3 31052890Sbostic */ 31152890Sbostic 31252890Sbostic #define ASC_CNFG3_RESERVED 0xf8 31352890Sbostic #define ASC_CNFG3_SRB 0x04 31452890Sbostic #define ASC_CNFG3_ALT_DMA 0x02 31552890Sbostic #define ASC_CNFG3_T8 0x01 316