1*7c478bd9Sstevel@tonic-gate /* 2*7c478bd9Sstevel@tonic-gate * CDDL HEADER START 3*7c478bd9Sstevel@tonic-gate * 4*7c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*7c478bd9Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 6*7c478bd9Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 7*7c478bd9Sstevel@tonic-gate * with the License. 8*7c478bd9Sstevel@tonic-gate * 9*7c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*7c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 11*7c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 12*7c478bd9Sstevel@tonic-gate * and limitations under the License. 13*7c478bd9Sstevel@tonic-gate * 14*7c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 15*7c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*7c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 17*7c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 18*7c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 19*7c478bd9Sstevel@tonic-gate * 20*7c478bd9Sstevel@tonic-gate * CDDL HEADER END 21*7c478bd9Sstevel@tonic-gate */ 22*7c478bd9Sstevel@tonic-gate /* 23*7c478bd9Sstevel@tonic-gate * Copyright (c) 1996-1998 by Sun Microsystems, Inc. 24*7c478bd9Sstevel@tonic-gate * All rights reserved. 25*7c478bd9Sstevel@tonic-gate */ 26*7c478bd9Sstevel@tonic-gate 27*7c478bd9Sstevel@tonic-gate #ifndef _SYS_SCSI_ADAPTERS_FASREG_H 28*7c478bd9Sstevel@tonic-gate #define _SYS_SCSI_ADAPTERS_FASREG_H 29*7c478bd9Sstevel@tonic-gate 30*7c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 31*7c478bd9Sstevel@tonic-gate 32*7c478bd9Sstevel@tonic-gate #include <sys/note.h> 33*7c478bd9Sstevel@tonic-gate 34*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus 35*7c478bd9Sstevel@tonic-gate extern "C" { 36*7c478bd9Sstevel@tonic-gate #endif 37*7c478bd9Sstevel@tonic-gate 38*7c478bd9Sstevel@tonic-gate /* 39*7c478bd9Sstevel@tonic-gate * FAS register definitions. 40*7c478bd9Sstevel@tonic-gate */ 41*7c478bd9Sstevel@tonic-gate 42*7c478bd9Sstevel@tonic-gate /* 43*7c478bd9Sstevel@tonic-gate * All current Sun implementations use the following layout. 44*7c478bd9Sstevel@tonic-gate * That is, the FAS registers are always byte-wide, but are 45*7c478bd9Sstevel@tonic-gate * accessed longwords apart. Notice also that the byte-ordering 46*7c478bd9Sstevel@tonic-gate * is big-endian. 47*7c478bd9Sstevel@tonic-gate */ 48*7c478bd9Sstevel@tonic-gate 49*7c478bd9Sstevel@tonic-gate struct fasreg { 50*7c478bd9Sstevel@tonic-gate uint8_t fas_xcnt_lo; /* RW: transfer counter (low byte) */ 51*7c478bd9Sstevel@tonic-gate uint8_t _pad1, _pad2, _pad3; 52*7c478bd9Sstevel@tonic-gate 53*7c478bd9Sstevel@tonic-gate uint8_t fas_xcnt_mid; /* RW: transfer counter (mid byte) */ 54*7c478bd9Sstevel@tonic-gate uint8_t _pad5, _pad6, _pad7; 55*7c478bd9Sstevel@tonic-gate 56*7c478bd9Sstevel@tonic-gate uint8_t fas_fifo_data; /* RW: fifo data buffer */ 57*7c478bd9Sstevel@tonic-gate uint8_t _pad9, _pad10, _pad11; 58*7c478bd9Sstevel@tonic-gate 59*7c478bd9Sstevel@tonic-gate uint8_t fas_cmd; /* RW: command register */ 60*7c478bd9Sstevel@tonic-gate uint8_t _pad13, _pad14, _pad15; 61*7c478bd9Sstevel@tonic-gate 62*7c478bd9Sstevel@tonic-gate uint8_t fas_stat; /* R: status register */ 63*7c478bd9Sstevel@tonic-gate #define fas_busid fas_stat /* W: bus id for sel/resel */ 64*7c478bd9Sstevel@tonic-gate uint8_t _pad17, _pad18, _pad19; 65*7c478bd9Sstevel@tonic-gate 66*7c478bd9Sstevel@tonic-gate 67*7c478bd9Sstevel@tonic-gate uint8_t fas_intr; /* R: interrupt status register */ 68*7c478bd9Sstevel@tonic-gate #define fas_timeout fas_intr /* W: sel/resel timeout */ 69*7c478bd9Sstevel@tonic-gate uint8_t _pad21, _pad22, _pad23; 70*7c478bd9Sstevel@tonic-gate 71*7c478bd9Sstevel@tonic-gate 72*7c478bd9Sstevel@tonic-gate uint8_t fas_step; /* R: sequence step register */ 73*7c478bd9Sstevel@tonic-gate #define fas_sync_period fas_step /* W: synchronous period */ 74*7c478bd9Sstevel@tonic-gate uint8_t _pad25, _pad26, _pad27; 75*7c478bd9Sstevel@tonic-gate 76*7c478bd9Sstevel@tonic-gate 77*7c478bd9Sstevel@tonic-gate uint8_t fas_fifo_flag; /* R: fifo flag register */ 78*7c478bd9Sstevel@tonic-gate #define fas_sync_offset fas_fifo_flag /* W: synchronous offset */ 79*7c478bd9Sstevel@tonic-gate uint8_t _pad29, _pad30, _pad31; 80*7c478bd9Sstevel@tonic-gate 81*7c478bd9Sstevel@tonic-gate 82*7c478bd9Sstevel@tonic-gate uint8_t fas_conf; /* RW: configuration register */ 83*7c478bd9Sstevel@tonic-gate uint8_t _pad33, _pad34, _pad35; 84*7c478bd9Sstevel@tonic-gate 85*7c478bd9Sstevel@tonic-gate 86*7c478bd9Sstevel@tonic-gate uint8_t fas_clock_conv; /* W: clock conversion register */ 87*7c478bd9Sstevel@tonic-gate uint8_t _pad37, _pad38, _pad39; 88*7c478bd9Sstevel@tonic-gate #define fas_stat2 fas_clock_conv 89*7c478bd9Sstevel@tonic-gate 90*7c478bd9Sstevel@tonic-gate 91*7c478bd9Sstevel@tonic-gate uint8_t fas_test; /* RW: test register */ 92*7c478bd9Sstevel@tonic-gate uint8_t _pad41, _pad42, _pad43; 93*7c478bd9Sstevel@tonic-gate #define fas_conf4 fas_test 94*7c478bd9Sstevel@tonic-gate 95*7c478bd9Sstevel@tonic-gate 96*7c478bd9Sstevel@tonic-gate uint8_t fas_conf2; /* FAS-II configuration register */ 97*7c478bd9Sstevel@tonic-gate uint8_t _pad45, _pad46, _pad47; 98*7c478bd9Sstevel@tonic-gate 99*7c478bd9Sstevel@tonic-gate 100*7c478bd9Sstevel@tonic-gate uint8_t fas_conf3; /* FAS-III configuration register */ 101*7c478bd9Sstevel@tonic-gate uint8_t _pad49, _pad50, _pad51; 102*7c478bd9Sstevel@tonic-gate uint8_t _pad_reserved[4]; 103*7c478bd9Sstevel@tonic-gate 104*7c478bd9Sstevel@tonic-gate uint8_t fas_recmd_lo; /* RW: fifo recmd counter lo */ 105*7c478bd9Sstevel@tonic-gate #define fas_id_code fas_recmd_lo /* R: part-unique id code */ 106*7c478bd9Sstevel@tonic-gate uint8_t _pad52, _pad53, _pad54; 107*7c478bd9Sstevel@tonic-gate 108*7c478bd9Sstevel@tonic-gate uint8_t fas_recmd_hi; /* RW: fifo recmd counter lo */ 109*7c478bd9Sstevel@tonic-gate uint8_t _pad55, _pad56, _pad57; 110*7c478bd9Sstevel@tonic-gate }; 111*7c478bd9Sstevel@tonic-gate 112*7c478bd9Sstevel@tonic-gate 113*7c478bd9Sstevel@tonic-gate /* 114*7c478bd9Sstevel@tonic-gate * FAS command register definitions 115*7c478bd9Sstevel@tonic-gate */ 116*7c478bd9Sstevel@tonic-gate 117*7c478bd9Sstevel@tonic-gate /* 118*7c478bd9Sstevel@tonic-gate * These commands may be used at any time with the FAS chip. 119*7c478bd9Sstevel@tonic-gate * None generate an interrupt, per se, although if you have 120*7c478bd9Sstevel@tonic-gate * enabled detection of SCSI reset in setting the configuration 121*7c478bd9Sstevel@tonic-gate * register, a CMD_RESET_SCSI will generate an interrupt. 122*7c478bd9Sstevel@tonic-gate * Therefore, it is recommended that if you use the CMD_RESET_SCSI 123*7c478bd9Sstevel@tonic-gate * command, you at least temporarily disable recognition of 124*7c478bd9Sstevel@tonic-gate * SCSI reset in the configuration register. 125*7c478bd9Sstevel@tonic-gate */ 126*7c478bd9Sstevel@tonic-gate #define CMD_NOP 0x0 127*7c478bd9Sstevel@tonic-gate #define CMD_FLUSH 0x1 128*7c478bd9Sstevel@tonic-gate #define CMD_RESET_FAS 0x2 129*7c478bd9Sstevel@tonic-gate #define CMD_RESET_SCSI 0x3 130*7c478bd9Sstevel@tonic-gate 131*7c478bd9Sstevel@tonic-gate /* 132*7c478bd9Sstevel@tonic-gate * These commands will only work if the FAS is in the 133*7c478bd9Sstevel@tonic-gate * 'disconnected' state: 134*7c478bd9Sstevel@tonic-gate */ 135*7c478bd9Sstevel@tonic-gate #define CMD_RESEL_SEQ 0x40 136*7c478bd9Sstevel@tonic-gate #define CMD_SEL_NOATN 0x41 137*7c478bd9Sstevel@tonic-gate #define CMD_SEL_ATN 0x42 138*7c478bd9Sstevel@tonic-gate #define CMD_SEL_STOP 0x43 139*7c478bd9Sstevel@tonic-gate #define CMD_EN_RESEL 0x44 /* (no interrupt generated) */ 140*7c478bd9Sstevel@tonic-gate #define CMD_DIS_RESEL 0x45 141*7c478bd9Sstevel@tonic-gate #define CMD_SEL_ATN3 0x46 142*7c478bd9Sstevel@tonic-gate 143*7c478bd9Sstevel@tonic-gate /* 144*7c478bd9Sstevel@tonic-gate * These commands will only work if the FAS is connected as 145*7c478bd9Sstevel@tonic-gate * an initiator to a target: 146*7c478bd9Sstevel@tonic-gate */ 147*7c478bd9Sstevel@tonic-gate #define CMD_TRAN_INFO 0x10 148*7c478bd9Sstevel@tonic-gate #define CMD_COMP_SEQ 0x11 149*7c478bd9Sstevel@tonic-gate #define CMD_MSG_ACPT 0x12 150*7c478bd9Sstevel@tonic-gate #define CMD_TRAN_PAD 0x18 151*7c478bd9Sstevel@tonic-gate #define CMD_SET_ATN 0x1a /* (no interrupt generated) */ 152*7c478bd9Sstevel@tonic-gate #define CMD_CLR_ATN 0x1b /* (no interrupt generated) */ 153*7c478bd9Sstevel@tonic-gate 154*7c478bd9Sstevel@tonic-gate /* 155*7c478bd9Sstevel@tonic-gate * These commands will only work if the FAS is connected as 156*7c478bd9Sstevel@tonic-gate * a target to an initiator: 157*7c478bd9Sstevel@tonic-gate */ 158*7c478bd9Sstevel@tonic-gate #define CMD_DISCONNECT 0x27 /* (no interrupt generated) */ 159*7c478bd9Sstevel@tonic-gate 160*7c478bd9Sstevel@tonic-gate /* 161*7c478bd9Sstevel@tonic-gate * DMA enable bit 162*7c478bd9Sstevel@tonic-gate */ 163*7c478bd9Sstevel@tonic-gate #define CMD_DMA 0x80 164*7c478bd9Sstevel@tonic-gate 165*7c478bd9Sstevel@tonic-gate /* 166*7c478bd9Sstevel@tonic-gate * FAS fifo register definitions (read only) 167*7c478bd9Sstevel@tonic-gate */ 168*7c478bd9Sstevel@tonic-gate #define FIFOSIZE 16 169*7c478bd9Sstevel@tonic-gate #define MAX_FIFO_FLAG (FIFOSIZE-1) 170*7c478bd9Sstevel@tonic-gate #define FAS_FIFO_ONZ 0x20 171*7c478bd9Sstevel@tonic-gate #define FIFO_CNT_MASK 0x1f 172*7c478bd9Sstevel@tonic-gate 173*7c478bd9Sstevel@tonic-gate /* 174*7c478bd9Sstevel@tonic-gate * FAS status register definitions (read only) 175*7c478bd9Sstevel@tonic-gate */ 176*7c478bd9Sstevel@tonic-gate #define FAS_STAT_IPEND 0x80 /* interrupt pending */ 177*7c478bd9Sstevel@tonic-gate #define FAS_STAT_GERR 0x40 /* gross error */ 178*7c478bd9Sstevel@tonic-gate #define FAS_STAT_PERR 0x20 /* parity error */ 179*7c478bd9Sstevel@tonic-gate #define FAS_STAT_XZERO 0x10 /* transfer counter zero */ 180*7c478bd9Sstevel@tonic-gate #define FAS_STAT_XCMP 0x8 /* transfer completed (target mode only) */ 181*7c478bd9Sstevel@tonic-gate #define FAS_STAT_MSG 0x4 /* scsi phase bit: MSG */ 182*7c478bd9Sstevel@tonic-gate #define FAS_STAT_CD 0x2 /* scsi phase bit: CD */ 183*7c478bd9Sstevel@tonic-gate #define FAS_STAT_IO 0x1 /* scsi phase bit: IO */ 184*7c478bd9Sstevel@tonic-gate 185*7c478bd9Sstevel@tonic-gate #define FAS_STAT_BITS \ 186*7c478bd9Sstevel@tonic-gate "\20\10IPND\07GERR\06PERR\05XZERO\04XCMP\03MSG\02CD\01IO" 187*7c478bd9Sstevel@tonic-gate 188*7c478bd9Sstevel@tonic-gate /* 189*7c478bd9Sstevel@tonic-gate * settings of status to reflect different information transfer phases 190*7c478bd9Sstevel@tonic-gate */ 191*7c478bd9Sstevel@tonic-gate #define FAS_PHASE_MASK (FAS_STAT_MSG | FAS_STAT_CD | FAS_STAT_IO) 192*7c478bd9Sstevel@tonic-gate #define FAS_PHASE_DATA_OUT 0 193*7c478bd9Sstevel@tonic-gate #define FAS_PHASE_DATA_IN (FAS_STAT_IO) 194*7c478bd9Sstevel@tonic-gate #define FAS_PHASE_COMMAND (FAS_STAT_CD) 195*7c478bd9Sstevel@tonic-gate #define FAS_PHASE_STATUS (FAS_STAT_CD | FAS_STAT_IO) 196*7c478bd9Sstevel@tonic-gate #define FAS_PHASE_MSG_OUT (FAS_STAT_MSG | FAS_STAT_CD) 197*7c478bd9Sstevel@tonic-gate #define FAS_PHASE_MSG_IN (FAS_STAT_MSG | FAS_STAT_CD | FAS_STAT_IO) 198*7c478bd9Sstevel@tonic-gate 199*7c478bd9Sstevel@tonic-gate /* 200*7c478bd9Sstevel@tonic-gate * FAS interrupt status register definitions (read only) 201*7c478bd9Sstevel@tonic-gate */ 202*7c478bd9Sstevel@tonic-gate 203*7c478bd9Sstevel@tonic-gate #define FAS_INT_RESET 0x80 /* SCSI reset detected */ 204*7c478bd9Sstevel@tonic-gate #define FAS_INT_ILLEGAL 0x40 /* illegal cmd */ 205*7c478bd9Sstevel@tonic-gate #define FAS_INT_DISCON 0x20 /* disconnect */ 206*7c478bd9Sstevel@tonic-gate #define FAS_INT_BUS 0x10 /* bus service */ 207*7c478bd9Sstevel@tonic-gate #define FAS_INT_FCMP 0x8 /* function completed */ 208*7c478bd9Sstevel@tonic-gate #define FAS_INT_RESEL 0x4 /* reselected */ 209*7c478bd9Sstevel@tonic-gate #define FAS_INT_SELATN 0x2 /* selected with ATN */ 210*7c478bd9Sstevel@tonic-gate #define FAS_INT_SEL 0x1 /* selected without ATN */ 211*7c478bd9Sstevel@tonic-gate 212*7c478bd9Sstevel@tonic-gate #define FAS_INT_BITS \ 213*7c478bd9Sstevel@tonic-gate "\20\10RST\07ILL\06DISC\05BUS\04FCMP\03RESEL\02SATN\01SEL" 214*7c478bd9Sstevel@tonic-gate 215*7c478bd9Sstevel@tonic-gate /* 216*7c478bd9Sstevel@tonic-gate * FAS step register- only the least significant 3 bits are valid 217*7c478bd9Sstevel@tonic-gate */ 218*7c478bd9Sstevel@tonic-gate #define FAS_STEP_MASK 0x7 219*7c478bd9Sstevel@tonic-gate 220*7c478bd9Sstevel@tonic-gate #define FAS_STEP_ARBSEL 0 /* Arbitration and select completed. */ 221*7c478bd9Sstevel@tonic-gate /* Not MESSAGE OUT phase. ATN* asserted. */ 222*7c478bd9Sstevel@tonic-gate 223*7c478bd9Sstevel@tonic-gate #define FAS_STEP_SENTID 1 /* Sent one message byte. ATN* asserted. */ 224*7c478bd9Sstevel@tonic-gate /* (SELECT AND STOP command only). */ 225*7c478bd9Sstevel@tonic-gate 226*7c478bd9Sstevel@tonic-gate #define FAS_STEP_NOTCMD 2 /* For SELECT WITH ATN command: */ 227*7c478bd9Sstevel@tonic-gate /* Sent one message byte. ATN* off. */ 228*7c478bd9Sstevel@tonic-gate /* Not COMMAND phase. */ 229*7c478bd9Sstevel@tonic-gate /* For SELECT WITHOUT ATN command: */ 230*7c478bd9Sstevel@tonic-gate /* Not COMMAND phase. */ 231*7c478bd9Sstevel@tonic-gate /* For SELECT WITH ATN3 command: */ 232*7c478bd9Sstevel@tonic-gate /* Sent one to three message bytes. */ 233*7c478bd9Sstevel@tonic-gate /* Stopped due to unexpected phase */ 234*7c478bd9Sstevel@tonic-gate /* change. If third message byte */ 235*7c478bd9Sstevel@tonic-gate /* not sent, ATN* asserted. */ 236*7c478bd9Sstevel@tonic-gate 237*7c478bd9Sstevel@tonic-gate #define FAS_STEP_PCMD 3 /* Not all of command bytes transferred */ 238*7c478bd9Sstevel@tonic-gate /* due to premature phase change. */ 239*7c478bd9Sstevel@tonic-gate 240*7c478bd9Sstevel@tonic-gate #define FAS_STEP_DONE 4 /* Complete sequence. */ 241*7c478bd9Sstevel@tonic-gate 242*7c478bd9Sstevel@tonic-gate /* 243*7c478bd9Sstevel@tonic-gate * FAS configuration register definitions (read/write) 244*7c478bd9Sstevel@tonic-gate */ 245*7c478bd9Sstevel@tonic-gate #define FAS_CONF_SLOWMODE 0x80 /* slow cable mode */ 246*7c478bd9Sstevel@tonic-gate #define FAS_CONF_DISRINT 0x40 /* disable reset int */ 247*7c478bd9Sstevel@tonic-gate #define FAS_CONF_PARTEST 0x20 /* parity test mode */ 248*7c478bd9Sstevel@tonic-gate #define FAS_CONF_PAREN 0x10 /* enable parity */ 249*7c478bd9Sstevel@tonic-gate #define FAS_CONF_CHIPTEST 0x8 /* chip test mode */ 250*7c478bd9Sstevel@tonic-gate #define FAS_CONF_BUSID 0x7 /* last 3 bits to be host id */ 251*7c478bd9Sstevel@tonic-gate 252*7c478bd9Sstevel@tonic-gate #define DEFAULT_HOSTID 7 253*7c478bd9Sstevel@tonic-gate 254*7c478bd9Sstevel@tonic-gate /* 255*7c478bd9Sstevel@tonic-gate * FAS test register definitions (read/write) 256*7c478bd9Sstevel@tonic-gate */ 257*7c478bd9Sstevel@tonic-gate #define FAS_TEST_TGT 0x1 /* target test mode */ 258*7c478bd9Sstevel@tonic-gate #define FAS_TEST_INI 0x2 /* initiator test mode */ 259*7c478bd9Sstevel@tonic-gate #define FAS_TEST_TRI 0x4 /* tristate test mode */ 260*7c478bd9Sstevel@tonic-gate 261*7c478bd9Sstevel@tonic-gate /* 262*7c478bd9Sstevel@tonic-gate * FAS configuration register #2 definitions (read/write) 263*7c478bd9Sstevel@tonic-gate */ 264*7c478bd9Sstevel@tonic-gate #define FAS_CONF2_XL32 0x80 265*7c478bd9Sstevel@tonic-gate #define FAS_CONF2_MKDONE 0x40 266*7c478bd9Sstevel@tonic-gate #define FAS_CONF2_PAUSE_INTR_DISABLE 0x20 267*7c478bd9Sstevel@tonic-gate #define FAS_CONF2_FENABLE 0x10 /* Features Enable */ 268*7c478bd9Sstevel@tonic-gate #define FAS_CONF2_SCSI2 0x8 /* SCSI-2 mode (target mode only) */ 269*7c478bd9Sstevel@tonic-gate #define FAS_CONF2_TGT_BAD_PRTY_ABORT 0x4 270*7c478bd9Sstevel@tonic-gate #define FAS_CONF2_DMA_PRTY_ENABLE 0x1 271*7c478bd9Sstevel@tonic-gate 272*7c478bd9Sstevel@tonic-gate /* 273*7c478bd9Sstevel@tonic-gate * FAS configuration #3 register definitions (read/write) 274*7c478bd9Sstevel@tonic-gate */ 275*7c478bd9Sstevel@tonic-gate #define FAS_CONF3_ODDBYTE_AUTO 0x80 /* auto push an odd-byte to dma */ 276*7c478bd9Sstevel@tonic-gate #define FAS_CONF3_WIDE 0x40 /* enables wide */ 277*7c478bd9Sstevel@tonic-gate #define FAS_CONF3_IDBIT3 0x20 /* extends scsi bus ID to 4 bits */ 278*7c478bd9Sstevel@tonic-gate #define FAS_CONF3_IDRESCHK 0x10 /* ID message checking */ 279*7c478bd9Sstevel@tonic-gate #define FAS_CONF3_QUENB 0x8 /* 3-byte msg support */ 280*7c478bd9Sstevel@tonic-gate #define FAS_CONF3_CDB10 0x4 /* group 2 scsi-2 support */ 281*7c478bd9Sstevel@tonic-gate #define FAS_CONF3_FASTSCSI 0x2 /* 10 MB/S fast scsi mode */ 282*7c478bd9Sstevel@tonic-gate #define FAS_CONF3_FASTCLK 0x1 /* fast clock mode */ 283*7c478bd9Sstevel@tonic-gate 284*7c478bd9Sstevel@tonic-gate /* 285*7c478bd9Sstevel@tonic-gate * FAS configuration #4 register definitions 286*7c478bd9Sstevel@tonic-gate */ 287*7c478bd9Sstevel@tonic-gate #define FAS_CONF4_PADMSGS 0x20 288*7c478bd9Sstevel@tonic-gate 289*7c478bd9Sstevel@tonic-gate /* 290*7c478bd9Sstevel@tonic-gate * FAS part-unique id code definitions (read only) 291*7c478bd9Sstevel@tonic-gate */ 292*7c478bd9Sstevel@tonic-gate #define FAS_REV_MASK 0x7 /* revision level mask */ 293*7c478bd9Sstevel@tonic-gate #define FAS_FCODE_MASK 0xf8 /* revision family code mask */ 294*7c478bd9Sstevel@tonic-gate 295*7c478bd9Sstevel@tonic-gate /* 296*7c478bd9Sstevel@tonic-gate * Macros to get/set an integer word into the 4 8-bit 297*7c478bd9Sstevel@tonic-gate * registers that constitute the FAS's counter register. 298*7c478bd9Sstevel@tonic-gate */ 299*7c478bd9Sstevel@tonic-gate #define SET_FAS_COUNT(fasreg, val) { \ 300*7c478bd9Sstevel@tonic-gate fas_reg_write(fas, &fasreg->fas_xcnt_lo, (uint8_t)val); \ 301*7c478bd9Sstevel@tonic-gate fas_reg_write(fas, &fasreg->fas_xcnt_mid, \ 302*7c478bd9Sstevel@tonic-gate (uint8_t)(val >> 8)); \ 303*7c478bd9Sstevel@tonic-gate fas_reg_write(fas, &fasreg->fas_recmd_lo, \ 304*7c478bd9Sstevel@tonic-gate ((uint8_t)(val >> 16))); \ 305*7c478bd9Sstevel@tonic-gate fas_reg_write(fas, &fasreg->fas_recmd_hi, 0); \ 306*7c478bd9Sstevel@tonic-gate } 307*7c478bd9Sstevel@tonic-gate 308*7c478bd9Sstevel@tonic-gate /* 309*7c478bd9Sstevel@tonic-gate * to save time, read back 3 registers 310*7c478bd9Sstevel@tonic-gate */ 311*7c478bd9Sstevel@tonic-gate #define GET_FAS_COUNT(fasreg, val) { \ 312*7c478bd9Sstevel@tonic-gate uint8_t lo, mid, r_lo; \ 313*7c478bd9Sstevel@tonic-gate lo = fas_reg_read(fas, &fasreg->fas_xcnt_lo); \ 314*7c478bd9Sstevel@tonic-gate mid = fas_reg_read(fas, &fasreg->fas_xcnt_mid); \ 315*7c478bd9Sstevel@tonic-gate r_lo = fas_reg_read(fas, &fasreg->fas_recmd_lo); \ 316*7c478bd9Sstevel@tonic-gate (val) = (uint32_t)(lo | (mid << 8) | ((r_lo) << 16)); \ 317*7c478bd9Sstevel@tonic-gate } 318*7c478bd9Sstevel@tonic-gate 319*7c478bd9Sstevel@tonic-gate 320*7c478bd9Sstevel@tonic-gate 321*7c478bd9Sstevel@tonic-gate /* 322*7c478bd9Sstevel@tonic-gate * FAS Clock constants 323*7c478bd9Sstevel@tonic-gate */ 324*7c478bd9Sstevel@tonic-gate 325*7c478bd9Sstevel@tonic-gate /* 326*7c478bd9Sstevel@tonic-gate * The probe routine will select amongst these values 327*7c478bd9Sstevel@tonic-gate * and stuff it into the tag f_clock_conv in the private host 328*7c478bd9Sstevel@tonic-gate * adapter structure (see below) (as well as the the register fas_clock_conv 329*7c478bd9Sstevel@tonic-gate * on the chip) 330*7c478bd9Sstevel@tonic-gate */ 331*7c478bd9Sstevel@tonic-gate #define CLOCK_10MHZ 2 332*7c478bd9Sstevel@tonic-gate #define CLOCK_15MHZ 3 333*7c478bd9Sstevel@tonic-gate #define CLOCK_20MHZ 4 334*7c478bd9Sstevel@tonic-gate #define CLOCK_25MHZ 5 335*7c478bd9Sstevel@tonic-gate #define CLOCK_30MHZ 6 336*7c478bd9Sstevel@tonic-gate #define CLOCK_35MHZ 7 337*7c478bd9Sstevel@tonic-gate #define CLOCK_40MHZ 8 /* really 0 */ 338*7c478bd9Sstevel@tonic-gate #define CLOCK_MASK 0x7 339*7c478bd9Sstevel@tonic-gate 340*7c478bd9Sstevel@tonic-gate /* 341*7c478bd9Sstevel@tonic-gate * This yields nanoseconds per input clock tick 342*7c478bd9Sstevel@tonic-gate */ 343*7c478bd9Sstevel@tonic-gate 344*7c478bd9Sstevel@tonic-gate #define CLOCK_PERIOD(mhz) (1000 * MEG) / (mhz / 1000) 345*7c478bd9Sstevel@tonic-gate #define CONVERT_PERIOD(time) ((time) + 3) >> 2 346*7c478bd9Sstevel@tonic-gate 347*7c478bd9Sstevel@tonic-gate /* 348*7c478bd9Sstevel@tonic-gate * Formula to compute the select/reselect timeout register value: 349*7c478bd9Sstevel@tonic-gate * 350*7c478bd9Sstevel@tonic-gate * Time_unit = 7682 * CCF * Input_Clock_Period 351*7c478bd9Sstevel@tonic-gate * 352*7c478bd9Sstevel@tonic-gate * where Time_unit && Input_Clock_Period should be in the same units. 353*7c478bd9Sstevel@tonic-gate * CCF = Clock Conversion Factor from CLOCK_XMHZ above. 354*7c478bd9Sstevel@tonic-gate * Desired_Timeout_Period = 250 ms. 355*7c478bd9Sstevel@tonic-gate * 356*7c478bd9Sstevel@tonic-gate */ 357*7c478bd9Sstevel@tonic-gate #define FAS_CLOCK_DELAY 7682 358*7c478bd9Sstevel@tonic-gate #define FAS_CLOCK_TICK(fas) \ 359*7c478bd9Sstevel@tonic-gate ((uint_t)FAS_CLOCK_DELAY * (uint_t)(fas)->f_clock_conv * \ 360*7c478bd9Sstevel@tonic-gate (uint_t)(fas)->f_clock_cycle) / (uint_t)1000 361*7c478bd9Sstevel@tonic-gate #define FAS_SEL_TIMEOUT (250 * MEG) 362*7c478bd9Sstevel@tonic-gate #define FAS_CLOCK_TIMEOUT(tick, selection_timeout) \ 363*7c478bd9Sstevel@tonic-gate (((selection_timeout) * MEG) + (tick) - 1) / (tick) 364*7c478bd9Sstevel@tonic-gate 365*7c478bd9Sstevel@tonic-gate /* 366*7c478bd9Sstevel@tonic-gate * Max/Min number of clock cycles for synchronous period 367*7c478bd9Sstevel@tonic-gate */ 368*7c478bd9Sstevel@tonic-gate #define MIN_SYNC_FAST(fas) 4 369*7c478bd9Sstevel@tonic-gate #define MIN_SYNC_SLOW(fas) \ 370*7c478bd9Sstevel@tonic-gate (((fas)->e_fasconf & FAS_CONF_SLOWMODE) ? 6 : 5) 371*7c478bd9Sstevel@tonic-gate #define MIN_SYNC(fas) (MIN_SYNC_FAST((fas))) 372*7c478bd9Sstevel@tonic-gate #define MAX_SYNC(fas) 35 373*7c478bd9Sstevel@tonic-gate #define SYNC_PERIOD_MASK 0x1F 374*7c478bd9Sstevel@tonic-gate 375*7c478bd9Sstevel@tonic-gate /* 376*7c478bd9Sstevel@tonic-gate * Max/Min time (in nanoseconds) between successive Req/Ack 377*7c478bd9Sstevel@tonic-gate */ 378*7c478bd9Sstevel@tonic-gate #define MIN_SYNC_TIME(fas) \ 379*7c478bd9Sstevel@tonic-gate ((uint_t)MIN_SYNC((fas)) * (uint_t)((fas)->f_clock_cycle)) / \ 380*7c478bd9Sstevel@tonic-gate (uint_t)1000 381*7c478bd9Sstevel@tonic-gate #define MAX_SYNC_TIME(fas) \ 382*7c478bd9Sstevel@tonic-gate ((uint_t)MAX_SYNC((fas)) * (uint_t)((fas)->f_clock_cycle)) / \ 383*7c478bd9Sstevel@tonic-gate (uint_t)1000 384*7c478bd9Sstevel@tonic-gate 385*7c478bd9Sstevel@tonic-gate /* 386*7c478bd9Sstevel@tonic-gate * Max/Min Period values (appropriate for SYNCHRONOUS message). 387*7c478bd9Sstevel@tonic-gate * We round up here to make sure that we are always slower 388*7c478bd9Sstevel@tonic-gate * (longer time period). 389*7c478bd9Sstevel@tonic-gate */ 390*7c478bd9Sstevel@tonic-gate #define MIN_SYNC_PERIOD(fas) (CONVERT_PERIOD(MIN_SYNC_TIME((fas)))) 391*7c478bd9Sstevel@tonic-gate #define MAX_SYNC_PERIOD(fas) (CONVERT_PERIOD(MAX_SYNC_TIME((fas)))) 392*7c478bd9Sstevel@tonic-gate 393*7c478bd9Sstevel@tonic-gate /* 394*7c478bd9Sstevel@tonic-gate * According to the Emulex application notes for this part, 395*7c478bd9Sstevel@tonic-gate * the ability to receive synchronous data is independent 396*7c478bd9Sstevel@tonic-gate * of the FAS chip's input clock rate, and is fixed at 397*7c478bd9Sstevel@tonic-gate * a maximum 5.6 mb/s (180 ns/byte). 398*7c478bd9Sstevel@tonic-gate * 399*7c478bd9Sstevel@tonic-gate * Therefore, we could tell targets that we can *receive* 400*7c478bd9Sstevel@tonic-gate * synchronous data this fast. 401*7c478bd9Sstevel@tonic-gate * However, the rest of the transfer is still at 5.0 MB/sec so to keep it 402*7c478bd9Sstevel@tonic-gate * simple, we negotiate 200 ns 403*7c478bd9Sstevel@tonic-gate * On a c2, a period of 45 and 50 result in the same register value (8) and 404*7c478bd9Sstevel@tonic-gate * consequently 5 MB/sec. 405*7c478bd9Sstevel@tonic-gate */ 406*7c478bd9Sstevel@tonic-gate #define DEFAULT_SYNC_PERIOD 200 /* 5.0 MB/s */ 407*7c478bd9Sstevel@tonic-gate #define DEFAULT_FASTSYNC_PERIOD 100 /* 10.0 MB/s */ 408*7c478bd9Sstevel@tonic-gate #define FASTSCSI_THRESHOLD 50 /* 5.0 MB/s */ 409*7c478bd9Sstevel@tonic-gate 410*7c478bd9Sstevel@tonic-gate /* 411*7c478bd9Sstevel@tonic-gate * Short hand macro convert parameter in 412*7c478bd9Sstevel@tonic-gate * nanoseconds/byte into k-bytes/second. 413*7c478bd9Sstevel@tonic-gate */ 414*7c478bd9Sstevel@tonic-gate #define FAS_SYNC_KBPS(ns) ((((1000 * MEG) / (ns)) + 999) / 1000) 415*7c478bd9Sstevel@tonic-gate 416*7c478bd9Sstevel@tonic-gate /* 417*7c478bd9Sstevel@tonic-gate * Default Synchronous offset. 418*7c478bd9Sstevel@tonic-gate * (max # of allowable outstanding REQ) 419*7c478bd9Sstevel@tonic-gate * IBS allows only 11 bytes offset 420*7c478bd9Sstevel@tonic-gate */ 421*7c478bd9Sstevel@tonic-gate #define DEFAULT_OFFSET 15 422*7c478bd9Sstevel@tonic-gate 423*7c478bd9Sstevel@tonic-gate /* 424*7c478bd9Sstevel@tonic-gate * Chip type defines && macros 425*7c478bd9Sstevel@tonic-gate */ 426*7c478bd9Sstevel@tonic-gate #define FAS366 0 427*7c478bd9Sstevel@tonic-gate #define FAST 5 428*7c478bd9Sstevel@tonic-gate 429*7c478bd9Sstevel@tonic-gate /* status register #2 definitions (read only) */ 430*7c478bd9Sstevel@tonic-gate #define FAS_STAT2_SEQCNT 0x01 /* Sequence counter bit 7-3 enabled */ 431*7c478bd9Sstevel@tonic-gate #define FAS_STAT2_FLATCHED 0x02 /* FIFO flags register latched */ 432*7c478bd9Sstevel@tonic-gate #define FAS_STAT2_CLATCHED 0x04 /* Xfer cntr & recommand ctr latched */ 433*7c478bd9Sstevel@tonic-gate #define FAS_STAT2_CACTIVE 0x08 /* Command register is active */ 434*7c478bd9Sstevel@tonic-gate #define FAS_STAT2_SCSI16 0x10 /* SCSI interface is wide */ 435*7c478bd9Sstevel@tonic-gate #define FAS_STAT2_ISHUTTLE 0x20 /* FIFO Top register contains 1 byte */ 436*7c478bd9Sstevel@tonic-gate #define FAS_STAT2_OSHUTTLE 0x40 /* next byte from FIFO is MSB */ 437*7c478bd9Sstevel@tonic-gate #define FAS_STAT2_EMPTY 0x80 /* FIFO is empty */ 438*7c478bd9Sstevel@tonic-gate 439*7c478bd9Sstevel@tonic-gate /* 440*7c478bd9Sstevel@tonic-gate * select/reselect bus id register 441*7c478bd9Sstevel@tonic-gate */ 442*7c478bd9Sstevel@tonic-gate #define FAS_BUSID_ENCODID 0x10 /* encode reselection ID */ 443*7c478bd9Sstevel@tonic-gate #define FAS_BUSID_32BIT_COUNTER 0x40 /* xfer counter is 32 bit */ 444*7c478bd9Sstevel@tonic-gate 445*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus 446*7c478bd9Sstevel@tonic-gate } 447*7c478bd9Sstevel@tonic-gate #endif 448*7c478bd9Sstevel@tonic-gate 449*7c478bd9Sstevel@tonic-gate #endif /* _SYS_SCSI_ADAPTERS_FASREG_H */ 450