Home | History | Annotate | Line # | Download | only in ic
adwlib.h revision 1.8
      1  1.8    dante /*      $NetBSD: adwlib.h,v 1.8 2000/04/30 18:52:15 dante Exp $        */
      2  1.1    dante 
      3  1.1    dante /*
      4  1.1    dante  * Definitions for low level routines and data structures
      5  1.1    dante  * for the Advanced Systems Inc. SCSI controllers chips.
      6  1.1    dante  *
      7  1.7    dante  * Copyright (c) 1998, 1999, 2000 The NetBSD Foundation, Inc.
      8  1.1    dante  * All rights reserved.
      9  1.1    dante  *
     10  1.1    dante  * Author: Baldassare Dante Profeta <dante (at) mclink.it>
     11  1.1    dante  *
     12  1.1    dante  * Redistribution and use in source and binary forms, with or without
     13  1.1    dante  * modification, are permitted provided that the following conditions
     14  1.1    dante  * are met:
     15  1.1    dante  * 1. Redistributions of source code must retain the above copyright
     16  1.1    dante  *    notice, this list of conditions and the following disclaimer.
     17  1.1    dante  * 2. Redistributions in binary form must reproduce the above copyright
     18  1.1    dante  *    notice, this list of conditions and the following disclaimer in the
     19  1.1    dante  *    documentation and/or other materials provided with the distribution.
     20  1.1    dante  * 3. All advertising materials mentioning features or use of this software
     21  1.1    dante  *    must display the following acknowledgement:
     22  1.1    dante  *        This product includes software developed by the NetBSD
     23  1.1    dante  *        Foundation, Inc. and its contributors.
     24  1.1    dante  * 4. Neither the name of The NetBSD Foundation nor the names of its
     25  1.1    dante  *    contributors may be used to endorse or promote products derived
     26  1.1    dante  *    from this software without specific prior written permission.
     27  1.1    dante  *
     28  1.1    dante  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     29  1.1    dante  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     30  1.1    dante  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     31  1.1    dante  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     32  1.1    dante  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     33  1.1    dante  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     34  1.1    dante  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     35  1.1    dante  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     36  1.1    dante  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     37  1.1    dante  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     38  1.1    dante  * POSSIBILITY OF SUCH DAMAGE.
     39  1.1    dante  */
     40  1.1    dante /*
     41  1.1    dante  * Ported from:
     42  1.1    dante  */
     43  1.1    dante /*
     44  1.1    dante  * advansys.c - Linux Host Driver for AdvanSys SCSI Adapters
     45  1.8    dante  *
     46  1.8    dante  * Copyright (c) 1995-2000 Advanced System Products, Inc.
     47  1.1    dante  * All Rights Reserved.
     48  1.8    dante  *
     49  1.1    dante  * Redistribution and use in source and binary forms, with or without
     50  1.1    dante  * modification, are permitted provided that redistributions of source
     51  1.1    dante  * code retain the above copyright notice and this comment without
     52  1.1    dante  * modification.
     53  1.1    dante  */
     54  1.1    dante 
     55  1.1    dante #ifndef	_ADVANSYS_WIDE_LIBRARY_H_
     56  1.1    dante #define	_ADVANSYS_WIDE_LIBRARY_H_
     57  1.1    dante 
     58  1.1    dante 
     59  1.1    dante /*
     60  1.1    dante  * --- Adv Library Constants and Macros
     61  1.1    dante  */
     62  1.1    dante 
     63  1.7    dante #define ADW_LIB_VERSION_MAJOR	5
     64  1.8    dante #define ADW_LIB_VERSION_MINOR	8
     65  1.1    dante 
     66  1.1    dante /*
     67  1.1    dante  * Define Adv Reset Hold Time grater than 25 uSec.
     68  1.1    dante  * See AdvResetSCSIBus() for more info.
     69  1.1    dante  */
     70  1.1    dante #define ASC_SCSI_RESET_HOLD_TIME_US  60
     71  1.1    dante 
     72  1.1    dante /*
     73  1.1    dante  * Define Adv EEPROM constants.
     74  1.1    dante  */
     75  1.1    dante 
     76  1.1    dante #define ASC_EEP_DVC_CFG_BEGIN           (0x00)
     77  1.1    dante #define ASC_EEP_DVC_CFG_END             (0x15)
     78  1.1    dante #define ASC_EEP_DVC_CTL_BEGIN           (0x16)  /* location of OEM name */
     79  1.1    dante #define ASC_EEP_MAX_WORD_ADDR           (0x1E)
     80  1.1    dante 
     81  1.1    dante #define ASC_EEP_DELAY_MS                100
     82  1.1    dante 
     83  1.1    dante /*
     84  1.1    dante  * EEPROM bits reference by the RISC after initialization.
     85  1.1    dante  */
     86  1.1    dante #define ADW_EEPROM_BIG_ENDIAN          0x8000   /* EEPROM Bit 15 */
     87  1.1    dante #define ADW_EEPROM_BIOS_ENABLE         0x4000   /* EEPROM Bit 14 */
     88  1.1    dante #define ADW_EEPROM_TERM_POL            0x2000   /* EEPROM Bit 13 */
     89  1.1    dante 
     90  1.1    dante /*
     91  1.1    dante  * EEPROM configuration format
     92  1.1    dante  *
     93  1.1    dante  * Field naming convention:
     94  1.1    dante  *
     95  1.1    dante  *  *_enable indicates the field enables or disables the feature. The
     96  1.1    dante  *  value is never reset.
     97  1.1    dante  *
     98  1.1    dante  *  *_able indicates both whether a feature should be enabled or disabled
     99  1.1    dante  *  and whether a device isi capable of the feature. At initialization
    100  1.1    dante  *  this field may be set, but later if a device is found to be incapable
    101  1.1    dante  *  of the feature, the field is cleared.
    102  1.1    dante  *
    103  1.8    dante  * Default values are maintained in the structure Default_EEPROM_Config.
    104  1.1    dante  */
    105  1.7    dante #define ADV_EEPROM_BIG_ENDIAN          0x8000   /* EEPROM Bit 15 */
    106  1.7    dante #define ADV_EEPROM_BIOS_ENABLE         0x4000   /* EEPROM Bit 14 */
    107  1.7    dante /*
    108  1.7    dante  * For the ASC3550 Bit 13 is Termination Polarity control bit.
    109  1.7    dante  * For later ICs Bit 13 controls whether the CIS (Card Information
    110  1.7    dante  * Service Section) is loaded from EEPROM.
    111  1.7    dante  */
    112  1.7    dante #define ADV_EEPROM_TERM_POL            0x2000   /* EEPROM Bit 13 */
    113  1.7    dante #define ADV_EEPROM_CIS_LD              0x2000   /* EEPROM Bit 13 */
    114  1.7    dante 
    115  1.8    dante /*
    116  1.8    dante  * ASC38C1600 Bit 11
    117  1.8    dante  *
    118  1.8    dante  * If EEPROM Bit 11 is 0 for Function 0, then Function 0 will specify
    119  1.8    dante  * INT A in the PCI Configuration Space Int Pin field. If it is 1, then
    120  1.8    dante  * Function 0 will specify INT B.
    121  1.8    dante  *
    122  1.8    dante  * If EEPROM Bit 11 is 0 for Function 1, then Function 1 will specify
    123  1.8    dante  * INT B in the PCI Configuration Space Int Pin field. If it is 1, then
    124  1.8    dante  * Function 1 will specify INT A.
    125  1.8    dante  */
    126  1.8    dante #define ADW_EEPROM_INTAB               0x0800   /* EEPROM Bit 11 */
    127  1.8    dante 
    128  1.7    dante typedef struct adw_eep_3550_config
    129  1.1    dante {
    130  1.1    dante 						/* Word Offset, Description */
    131  1.1    dante 
    132  1.1    dante 	u_int16_t	cfg_lsw;		/* 00 power up initialization */
    133  1.1    dante 						/*  bit 13 set - Term Polarity Control */
    134  1.1    dante 						/*  bit 14 set - BIOS Enable */
    135  1.1    dante 						/*  bit 15 set - Big Endian Mode */
    136  1.8    dante 	u_int16_t	cfg_msw;		/* 01 unused	*/
    137  1.1    dante 	u_int16_t	disc_enable;		/* 02 disconnect enable */
    138  1.1    dante 	u_int16_t	wdtr_able;		/* 03 Wide DTR able */
    139  1.1    dante 	u_int16_t	sdtr_able;		/* 04 Synchronous DTR able */
    140  1.1    dante 	u_int16_t	start_motor;		/* 05 send start up motor */
    141  1.1    dante 	u_int16_t	tagqng_able;		/* 06 tag queuing able */
    142  1.1    dante 	u_int16_t	bios_scan;		/* 07 BIOS device control */
    143  1.1    dante 	u_int16_t	scam_tolerant;		/* 08 no scam */
    144  1.1    dante 
    145  1.1    dante 	u_int8_t	adapter_scsi_id;	/* 09 Host Adapter ID */
    146  1.1    dante 	u_int8_t	bios_boot_delay;	/*    power up wait */
    147  1.1    dante 
    148  1.1    dante 	u_int8_t	scsi_reset_delay;	/* 10 reset delay */
    149  1.1    dante 	u_int8_t	bios_id_lun;		/*    first boot device scsi id & lun */
    150  1.1    dante 						/*    high nibble is lun */
    151  1.1    dante 						/*    low nibble is scsi id */
    152  1.1    dante 
    153  1.8    dante 	u_int8_t	termination;		/* 11 0 - automatic */
    154  1.1    dante 						/*    1 - low off / high off */
    155  1.1    dante 						/*    2 - low off / high on */
    156  1.1    dante 						/*    3 - low on  / high on */
    157  1.1    dante 						/*    There is no low on  / high off */
    158  1.1    dante 
    159  1.1    dante 	u_int8_t	reserved1;		/*    reserved byte (not used) */
    160  1.1    dante 
    161  1.1    dante 	u_int16_t	bios_ctrl;		/* 12 BIOS control bits */
    162  1.8    dante 						  	  /*  bit 0  BIOS don't act as initiator. */
    163  1.8    dante 						/*  bit 1  BIOS > 1 GB support */
    164  1.8    dante 						/*  bit 2  BIOS > 2 Disk Support */
    165  1.8    dante 						/*  bit 3  BIOS don't support removables */
    166  1.8    dante 						/*  bit 4  BIOS support bootable CD */
    167  1.8    dante 						/*  bit 5  BIOS scan enabled */
    168  1.8    dante 						/*  bit 6  BIOS support multiple LUNs */
    169  1.8    dante 						/*  bit 7  BIOS display of message */
    170  1.8    dante 						/*  bit 8  SCAM disabled */
    171  1.8    dante 						/*  bit 9  Reset SCSI bus during init. */
    172  1.8    dante 						/*  bit 10 */
    173  1.8    dante 						/*  bit 11 No verbose initialization. */
    174  1.8    dante 						/*  bit 12 SCSI parity enabled */
    175  1.8    dante 						/*  bit 13 */
    176  1.8    dante 						/*  bit 14 */
    177  1.8    dante 						/*  bit 15 */
    178  1.1    dante 	u_int16_t	ultra_able;		/* 13 ULTRA speed able */
    179  1.1    dante 	u_int16_t	reserved2;		/* 14 reserved */
    180  1.1    dante 	u_int8_t	max_host_qng;		/* 15 maximum host queuing */
    181  1.1    dante 	u_int8_t	max_dvc_qng;		/*    maximum per device queuing */
    182  1.1    dante 	u_int16_t	dvc_cntl;		/* 16 control bit for driver */
    183  1.1    dante 	u_int16_t	bug_fix;		/* 17 control bit for bug fix */
    184  1.1    dante 	u_int16_t	serial_number_word1;	/* 18 Board serial number word 1 */
    185  1.1    dante 	u_int16_t	serial_number_word2;	/* 19 Board serial number word 2 */
    186  1.1    dante 	u_int16_t	serial_number_word3;	/* 20 Board serial number word 3 */
    187  1.1    dante 	u_int16_t	check_sum;		/* 21 EEP check sum */
    188  1.1    dante 	u_int8_t	oem_name[16];		/* 22 OEM name */
    189  1.1    dante 	u_int16_t	dvc_err_code;		/* 30 last device driver error code */
    190  1.1    dante 	u_int16_t	adv_err_code;		/* 31 last uc and Adv Lib error code */
    191  1.1    dante 	u_int16_t	adv_err_addr;		/* 32 last uc error address */
    192  1.8    dante 	u_int16_t	saved_dvc_err_code;	/* 33 saved last dev. driver error code	*/
    193  1.1    dante 	u_int16_t	saved_adv_err_code;	/* 34 saved last uc and Adv Lib error code */
    194  1.8    dante 	u_int16_t	saved_adv_err_addr;	/* 35 saved last uc error address 	*/
    195  1.1    dante 	u_int16_t	num_of_err;		/* 36 number of error */
    196  1.7    dante } ADW_EEP_3550_CONFIG;
    197  1.7    dante 
    198  1.7    dante typedef struct adw_eep_38C0800_config
    199  1.7    dante {
    200  1.7    dante 						/* Word Offset, Description */
    201  1.7    dante 
    202  1.7    dante 	u_int16_t	cfg_lsw;		/* 00 power up initialization */
    203  1.7    dante 						/*  bit 13 set - Load CIS */
    204  1.7    dante 						/*  bit 14 set - BIOS Enable */
    205  1.7    dante 						/*  bit 15 set - Big Endian Mode */
    206  1.8    dante 	u_int16_t	cfg_msw;		/* 01 unused	*/
    207  1.7    dante 	u_int16_t	disc_enable;		/* 02 disconnect enable */
    208  1.7    dante 	u_int16_t	wdtr_able;		/* 03 Wide DTR able */
    209  1.7    dante 	u_int16_t	sdtr_speed1;		/* 04 SDTR Speed TID 0-3 */
    210  1.7    dante 	u_int16_t	start_motor;		/* 05 send start up motor */
    211  1.7    dante 	u_int16_t	tagqng_able;		/* 06 tag queuing able */
    212  1.7    dante 	u_int16_t	bios_scan;		/* 07 BIOS device control */
    213  1.7    dante 	u_int16_t	scam_tolerant;		/* 08 no scam */
    214  1.7    dante 
    215  1.7    dante 	u_int8_t	adapter_scsi_id;	/* 09 Host Adapter ID */
    216  1.7    dante 	u_int8_t	bios_boot_delay;	/*    power up wait */
    217  1.7    dante 
    218  1.7    dante 	u_int8_t	scsi_reset_delay;	/* 10 reset delay */
    219  1.7    dante 	u_int8_t	bios_id_lun;		/*    first boot device scsi id & lun */
    220  1.7    dante 						/*    high nibble is lun */
    221  1.7    dante 						/*    low nibble is scsi id */
    222  1.7    dante 
    223  1.7    dante 	u_int8_t	termination_se;		/* 11 0 - automatic */
    224  1.7    dante 						/*    1 - low off / high off */
    225  1.7    dante 						/*    2 - low off / high on */
    226  1.7    dante 						/*    3 - low on  / high on */
    227  1.7    dante 						/*    There is no low on  / high off */
    228  1.7    dante 
    229  1.7    dante 	u_int8_t	termination_lvd;	/* 11 0 - automatic */
    230  1.7    dante 						/*    1 - low off / high off */
    231  1.7    dante 						/*    2 - low off / high on */
    232  1.7    dante 						/*    3 - low on  / high on */
    233  1.7    dante 						/*    There is no low on  / high off */
    234  1.7    dante 
    235  1.7    dante 	u_int16_t	bios_ctrl;		/* 12 BIOS control bits */
    236  1.8    dante 						/*  bit 0  BIOS don't act as initiator. */
    237  1.8    dante 						/*  bit 1  BIOS > 1 GB support */
    238  1.8    dante 						/*  bit 2  BIOS > 2 Disk Support */
    239  1.8    dante 						/*  bit 3  BIOS don't support removables */
    240  1.8    dante 						/*  bit 4  BIOS support bootable CD */
    241  1.8    dante 						/*  bit 5  BIOS scan enabled */
    242  1.8    dante 						/*  bit 6  BIOS support multiple LUNs */
    243  1.8    dante 						/*  bit 7  BIOS display of message */
    244  1.8    dante 						/*  bit 8  SCAM disabled */
    245  1.8    dante 						/*  bit 9  Reset SCSI bus during init. */
    246  1.8    dante 						/*  bit 10 */
    247  1.8    dante 						/*  bit 11 No verbose initialization. */
    248  1.8    dante 						/*  bit 12 SCSI parity enabled */
    249  1.8    dante 						/*  bit 13 */
    250  1.8    dante 						/*  bit 14 */
    251  1.8    dante 						/*  bit 15 */
    252  1.7    dante 	u_int16_t	sdtr_speed2;		/* 13 SDTR speed TID 4-7 */
    253  1.7    dante 	u_int16_t	sdtr_speed3;		/* 14 SDTR speed TID 8-11 */
    254  1.7    dante 	u_int8_t	max_host_qng;		/* 15 maximum host queueing */
    255  1.7    dante 	u_int8_t	max_dvc_qng;		/*    maximum per device queuing */
    256  1.7    dante 	u_int16_t	dvc_cntl;		/* 16 control bit for driver */
    257  1.7    dante 	u_int16_t	sdtr_speed4;		/* 17 SDTR speed 4 TID 12-15 */
    258  1.8    dante 	u_int16_t	serial_number_word1;	/* 18 Board serial number word 1 */
    259  1.8    dante 	u_int16_t	serial_number_word2;	/* 19 Board serial number word 2 */
    260  1.8    dante 	u_int16_t	serial_number_word3;	/* 20 Board serial number word 3 */
    261  1.8    dante 	u_int16_t	check_sum;		/* 21 EEP check sum */
    262  1.8    dante 	u_int8_t	oem_name[16];		/* 22 OEM name */
    263  1.8    dante 	u_int16_t	dvc_err_code;		/* 30 last device driver error code */
    264  1.8    dante 	u_int16_t	adv_err_code;		/* 31 last uc and Adv Lib error code */
    265  1.8    dante 	u_int16_t	adv_err_addr;		/* 32 last uc error address */
    266  1.8    dante 	u_int16_t	saved_dvc_err_code;	/* 33 saved last dev. driver error code	*/
    267  1.8    dante 	u_int16_t	saved_adv_err_code;	/* 34 saved last uc and Adv Lib error code */
    268  1.8    dante 	u_int16_t	saved_adv_err_addr;	/* 35 saved last uc error address 	*/
    269  1.8    dante 	u_int16_t	reserved36;		/* 36 reserved */
    270  1.8    dante 	u_int16_t	reserved37;		/* 37 reserved */
    271  1.8    dante 	u_int16_t	reserved38;		/* 38 reserved */
    272  1.8    dante 	u_int16_t	reserved39;		/* 39 reserved */
    273  1.8    dante 	u_int16_t	reserved40;		/* 40 reserved */
    274  1.8    dante 	u_int16_t	reserved41;		/* 41 reserved */
    275  1.8    dante 	u_int16_t	reserved42;		/* 42 reserved */
    276  1.8    dante 	u_int16_t	reserved43;		/* 43 reserved */
    277  1.8    dante 	u_int16_t	reserved44;		/* 44 reserved */
    278  1.8    dante 	u_int16_t	reserved45;		/* 45 reserved */
    279  1.8    dante 	u_int16_t	reserved46;		/* 46 reserved */
    280  1.8    dante 	u_int16_t	reserved47;		/* 47 reserved */
    281  1.8    dante 	u_int16_t	reserved48;		/* 48 reserved */
    282  1.8    dante 	u_int16_t	reserved49;		/* 49 reserved */
    283  1.8    dante 	u_int16_t	reserved50;		/* 50 reserved */
    284  1.8    dante 	u_int16_t	reserved51;		/* 51 reserved */
    285  1.8    dante 	u_int16_t	reserved52;		/* 52 reserved */
    286  1.8    dante 	u_int16_t	reserved53;		/* 53 reserved */
    287  1.8    dante 	u_int16_t	reserved54;		/* 54 reserved */
    288  1.8    dante 	u_int16_t	reserved55;		/* 55 reserved */
    289  1.8    dante 	u_int16_t	cisptr_lsw;		/* 56 CIS PTR LSW */
    290  1.8    dante 	u_int16_t	cisprt_msw;		/* 57 CIS PTR MSW */
    291  1.8    dante 	u_int16_t	subsysvid;		/* 58 SubSystem Vendor ID */
    292  1.8    dante 	u_int16_t	subsysid;		/* 59 SubSystem ID */
    293  1.8    dante 	u_int16_t	reserved60;		/* 60 reserved */
    294  1.8    dante 	u_int16_t	reserved61;		/* 61 reserved */
    295  1.8    dante 	u_int16_t	reserved62;		/* 62 reserved */
    296  1.8    dante 	u_int16_t	reserved63;		/* 63 reserved */
    297  1.8    dante } ADW_EEP_38C0800_CONFIG;
    298  1.8    dante 
    299  1.8    dante typedef struct adw_eep_38C1600_config
    300  1.8    dante {
    301  1.8    dante 						/* Word Offset, Description */
    302  1.8    dante 
    303  1.8    dante 	u_int16_t	cfg_lsw;		/* 00 power up initialization */
    304  1.8    dante 						/*  bit 11 set - Func. 0 INTB, Func. 1 INTA */
    305  1.8    dante 						/*	 clear - Func. 0 INTA, Func. 1 INTB */
    306  1.8    dante 						/*  bit 13 set - Load CIS */
    307  1.8    dante 						/*  bit 14 set - BIOS Enable */
    308  1.8    dante 						/*  bit 15 set - Big Endian Mode */
    309  1.8    dante 	u_int16_t	cfg_msw;		/* 01 unused */
    310  1.8    dante 	u_int16_t	disc_enable;		/* 02 disconnect enable */
    311  1.8    dante 	u_int16_t	wdtr_able;		/* 03 Wide DTR able */
    312  1.8    dante 	u_int16_t	sdtr_speed1;		/* 04 SDTR Speed TID 0-3 */
    313  1.8    dante 	u_int16_t	start_motor;		/* 05 send start up motor */
    314  1.8    dante 	u_int16_t	tagqng_able;		/* 06 tag queuing able */
    315  1.8    dante 	u_int16_t	bios_scan;		/* 07 BIOS device control */
    316  1.8    dante 	u_int16_t	scam_tolerant;		/* 08 no scam */
    317  1.8    dante 
    318  1.8    dante 	u_int8_t	adapter_scsi_id;	/* 09 Host Adapter ID */
    319  1.8    dante 	u_int8_t	bios_boot_delay;	/*    power up wait */
    320  1.8    dante 
    321  1.8    dante 	u_int8_t	scsi_reset_delay;	/* 10 reset delay */
    322  1.8    dante 	u_int8_t	bios_id_lun;		/*    first boot device scsi id & lun */
    323  1.8    dante 						/*    high nibble is lun */
    324  1.8    dante 						/*    low nibble is scsi id */
    325  1.8    dante 
    326  1.8    dante 	u_int8_t	termination_se;		/* 11 0 - automatic */
    327  1.8    dante 						/*    1 - low off / high off */
    328  1.8    dante 						/*    2 - low off / high on */
    329  1.8    dante 						/*    3 - low on  / high on */
    330  1.8    dante 						/*    There is no low on  / high off */
    331  1.8    dante 
    332  1.8    dante 	u_int8_t	termination_lvd;	/* 11 0 - automatic */
    333  1.8    dante 						/*    1 - low off / high off */
    334  1.8    dante 						/*    2 - low off / high on */
    335  1.8    dante 						/*    3 - low on  / high on */
    336  1.8    dante 						/*    There is no low on  / high off */
    337  1.8    dante 
    338  1.8    dante 	u_int16_t	bios_ctrl;		/* 12 BIOS control bits */
    339  1.8    dante 						/*  bit 0  BIOS don't act as initiator. */
    340  1.8    dante 						/*  bit 1  BIOS > 1 GB support */
    341  1.8    dante 						/*  bit 2  BIOS > 2 Disk Support */
    342  1.8    dante 						/*  bit 3  BIOS don't support removables */
    343  1.8    dante 						/*  bit 4  BIOS support bootable CD */
    344  1.8    dante 						/*  bit 5  BIOS scan enabled */
    345  1.8    dante 						/*  bit 6  BIOS support multiple LUNs */
    346  1.8    dante 						/*  bit 7  BIOS display of message */
    347  1.8    dante 						/*  bit 8  SCAM disabled */
    348  1.8    dante 						/*  bit 9  Reset SCSI bus during init. */
    349  1.8    dante 						/*  bit 10 Basic Integrity Checking disabled */
    350  1.8    dante 						/*  bit 11 No verbose initialization. */
    351  1.8    dante 						/*  bit 12 SCSI parity enabled */
    352  1.8    dante 						/*  bit 13 AIPP (Asyn. Info. Ph. Prot.) dis. */
    353  1.8    dante 						/*  bit 14 */
    354  1.8    dante 						/*  bit 15 */
    355  1.8    dante 	u_int16_t	sdtr_speed2;		/* 13 SDTR speed TID 4-7 */
    356  1.8    dante 	u_int16_t	sdtr_speed3;		/* 14 SDTR speed TID 8-11 */
    357  1.8    dante 	u_int8_t	max_host_qng;		/* 15 maximum host queueing */
    358  1.8    dante 	u_int8_t	max_dvc_qng;		/*    maximum per device queuing */
    359  1.8    dante 	u_int16_t	dvc_cntl;		/* 16 control bit for driver */
    360  1.8    dante 	u_int16_t	sdtr_speed4;		/* 17 SDTR speed 4 TID 12-15 */
    361  1.8    dante 	u_int16_t	serial_number_word1;	/* 18 Board serial number word 1 */
    362  1.7    dante 	u_int16_t	serial_number_word2;	/* 19 Board serial number word 2 */
    363  1.7    dante 	u_int16_t	serial_number_word3;	/* 20 Board serial number word 3 */
    364  1.7    dante 	u_int16_t	check_sum;		/* 21 EEP check sum */
    365  1.7    dante 	u_int8_t	oem_name[16];		/* 22 OEM name */
    366  1.7    dante 	u_int16_t	dvc_err_code;		/* 30 last device driver error code */
    367  1.7    dante 	u_int16_t	adv_err_code;		/* 31 last uc and Adv Lib error code */
    368  1.7    dante 	u_int16_t	adv_err_addr;		/* 32 last uc error address */
    369  1.7    dante 	u_int16_t	saved_dvc_err_code;	/* 33 saved last dev. driver error code   */
    370  1.7    dante 	u_int16_t	saved_adv_err_code;	/* 34 saved last uc and Adv Lib error code */
    371  1.8    dante 	u_int16_t	saved_adv_err_addr;	/* 35 saved last uc error address	  */
    372  1.7    dante 	u_int16_t	reserved36;		/* 36 reserved */
    373  1.7    dante 	u_int16_t	reserved37;		/* 37 reserved */
    374  1.8    dante 	u_int16_t	reserved38;		/* 38 reserved */
    375  1.8    dante 	u_int16_t	reserved39;		/* 39 reserved */
    376  1.8    dante 	u_int16_t	reserved40;		/* 40 reserved */
    377  1.8    dante 	u_int16_t	reserved41;		/* 41 reserved */
    378  1.8    dante 	u_int16_t	reserved42;		/* 42 reserved */
    379  1.8    dante 	u_int16_t	reserved43;		/* 43 reserved */
    380  1.8    dante 	u_int16_t	reserved44;		/* 44 reserved */
    381  1.8    dante 	u_int16_t	reserved45;		/* 45 reserved */
    382  1.8    dante 	u_int16_t	reserved46;		/* 46 reserved */
    383  1.8    dante 	u_int16_t	reserved47;		/* 47 reserved */
    384  1.8    dante 	u_int16_t	reserved48;		/* 48 reserved */
    385  1.8    dante 	u_int16_t	reserved49;		/* 49 reserved */
    386  1.8    dante 	u_int16_t	reserved50;		/* 50 reserved */
    387  1.8    dante 	u_int16_t	reserved51;		/* 51 reserved */
    388  1.8    dante 	u_int16_t	reserved52;		/* 52 reserved */
    389  1.8    dante 	u_int16_t	reserved53;		/* 53 reserved */
    390  1.8    dante 	u_int16_t	reserved54;		/* 54 reserved */
    391  1.8    dante 	u_int16_t	reserved55;		/* 55 reserved */
    392  1.8    dante 	u_int16_t	cisptr_lsw;		/* 56 CIS PTR LSW */
    393  1.8    dante 	u_int16_t	cisprt_msw;		/* 57 CIS PTR MSW */
    394  1.7    dante 	u_int16_t	subsysvid;		/* 58 SubSystem Vendor ID */
    395  1.7    dante 	u_int16_t	subsysid;		/* 59 SubSystem ID */
    396  1.8    dante 	u_int16_t	reserved60;		/* 60 reserved */
    397  1.8    dante 	u_int16_t	reserved61;		/* 61 reserved */
    398  1.8    dante 	u_int16_t	reserved62;		/* 62 reserved */
    399  1.8    dante 	u_int16_t	reserved63;		/* 63 reserved */
    400  1.8    dante } ADW_EEP_38C1600_CONFIG;
    401  1.8    dante 
    402  1.1    dante 
    403  1.1    dante /*
    404  1.1    dante  * EEPROM Commands
    405  1.1    dante  */
    406  1.1    dante #define ASC_EEP_CMD_READ          0x80
    407  1.1    dante #define ASC_EEP_CMD_WRITE         0x40
    408  1.1    dante #define ASC_EEP_CMD_WRITE_ABLE    0x30
    409  1.1    dante #define ASC_EEP_CMD_WRITE_DISABLE 0x00
    410  1.1    dante 
    411  1.1    dante #define ASC_EEP_CMD_DONE             0x0200
    412  1.1    dante #define ASC_EEP_CMD_DONE_ERR         0x0001
    413  1.1    dante 
    414  1.1    dante /* cfg_word */
    415  1.1    dante #define EEP_CFG_WORD_BIG_ENDIAN      0x8000
    416  1.1    dante 
    417  1.1    dante /* bios_ctrl */
    418  1.1    dante #define BIOS_CTRL_BIOS               0x0001
    419  1.1    dante #define BIOS_CTRL_EXTENDED_XLAT      0x0002
    420  1.1    dante #define BIOS_CTRL_GT_2_DISK          0x0004
    421  1.1    dante #define BIOS_CTRL_BIOS_REMOVABLE     0x0008
    422  1.1    dante #define BIOS_CTRL_BOOTABLE_CD        0x0010
    423  1.1    dante #define BIOS_CTRL_MULTIPLE_LUN       0x0040
    424  1.1    dante #define BIOS_CTRL_DISPLAY_MSG        0x0080
    425  1.1    dante #define BIOS_CTRL_NO_SCAM            0x0100
    426  1.1    dante #define BIOS_CTRL_RESET_SCSI_BUS     0x0200
    427  1.1    dante #define BIOS_CTRL_INIT_VERBOSE       0x0800
    428  1.1    dante #define BIOS_CTRL_SCSI_PARITY        0x1000
    429  1.8    dante #define BIOS_CTRL_AIPP_DIS           0x2000
    430  1.1    dante 
    431  1.7    dante #define ADV_3550_MEMSIZE             0x2000	/* 8 KB Internal Memory */
    432  1.7    dante #define ADV_3550_IOLEN               0x40	/* I/O Port Range in bytes */
    433  1.7    dante 
    434  1.7    dante #define ADV_38C0800_MEMSIZE          0x4000	/* 16 KB Internal Memory */
    435  1.7    dante #define ADV_38C0800_IOLEN            0x100	/* I/O Port Range in bytes */
    436  1.1    dante 
    437  1.8    dante #define ADV_38C1600_MEMSIZE          0x8000	/* 32 KB Internal Memory */
    438  1.7    dante #define ADV_38C1600_IOLEN            0x100	/* I/O Port Range 256 bytes */
    439  1.7    dante #define ADV_38C1600_MEMLEN           0x1000	/* Memory Range 4KB bytes */
    440  1.1    dante 
    441  1.1    dante /*
    442  1.1    dante  * Byte I/O register address from base of 'iop_base'.
    443  1.1    dante  */
    444  1.1    dante #define IOPB_INTR_STATUS_REG    0x00
    445  1.1    dante #define IOPB_CHIP_ID_1          0x01
    446  1.1    dante #define IOPB_INTR_ENABLES       0x02
    447  1.1    dante #define IOPB_CHIP_TYPE_REV      0x03
    448  1.1    dante #define IOPB_RES_ADDR_4         0x04
    449  1.1    dante #define IOPB_RES_ADDR_5         0x05
    450  1.1    dante #define IOPB_RAM_DATA           0x06
    451  1.1    dante #define IOPB_RES_ADDR_7         0x07
    452  1.1    dante #define IOPB_FLAG_REG           0x08
    453  1.1    dante #define IOPB_RES_ADDR_9         0x09
    454  1.1    dante #define IOPB_RISC_CSR           0x0A
    455  1.1    dante #define IOPB_RES_ADDR_B         0x0B
    456  1.1    dante #define IOPB_RES_ADDR_C         0x0C
    457  1.1    dante #define IOPB_RES_ADDR_D         0x0D
    458  1.7    dante #define IOPB_SOFT_OVER_WR       0x0E
    459  1.1    dante #define IOPB_RES_ADDR_F         0x0F
    460  1.1    dante #define IOPB_MEM_CFG            0x10
    461  1.1    dante #define IOPB_RES_ADDR_11        0x11
    462  1.7    dante #define IOPB_GPIO_DATA          0x12
    463  1.1    dante #define IOPB_RES_ADDR_13        0x13
    464  1.1    dante #define IOPB_FLASH_PAGE         0x14
    465  1.1    dante #define IOPB_RES_ADDR_15        0x15
    466  1.7    dante #define IOPB_GPIO_CNTL          0x16
    467  1.1    dante #define IOPB_RES_ADDR_17        0x17
    468  1.1    dante #define IOPB_FLASH_DATA         0x18
    469  1.1    dante #define IOPB_RES_ADDR_19        0x19
    470  1.1    dante #define IOPB_RES_ADDR_1A        0x1A
    471  1.1    dante #define IOPB_RES_ADDR_1B        0x1B
    472  1.1    dante #define IOPB_RES_ADDR_1C        0x1C
    473  1.1    dante #define IOPB_RES_ADDR_1D        0x1D
    474  1.1    dante #define IOPB_RES_ADDR_1E        0x1E
    475  1.1    dante #define IOPB_RES_ADDR_1F        0x1F
    476  1.1    dante #define IOPB_DMA_CFG0           0x20
    477  1.1    dante #define IOPB_DMA_CFG1           0x21
    478  1.1    dante #define IOPB_TICKLE             0x22
    479  1.1    dante #define IOPB_DMA_REG_WR         0x23
    480  1.1    dante #define IOPB_SDMA_STATUS        0x24
    481  1.1    dante #define IOPB_SCSI_BYTE_CNT      0x25
    482  1.1    dante #define IOPB_HOST_BYTE_CNT      0x26
    483  1.1    dante #define IOPB_BYTE_LEFT_TO_XFER  0x27
    484  1.1    dante #define IOPB_BYTE_TO_XFER_0     0x28
    485  1.1    dante #define IOPB_BYTE_TO_XFER_1     0x29
    486  1.1    dante #define IOPB_BYTE_TO_XFER_2     0x2A
    487  1.1    dante #define IOPB_BYTE_TO_XFER_3     0x2B
    488  1.1    dante #define IOPB_ACC_GRP            0x2C
    489  1.1    dante #define IOPB_RES_ADDR_2D        0x2D
    490  1.1    dante #define IOPB_DEV_ID             0x2E
    491  1.1    dante #define IOPB_RES_ADDR_2F        0x2F
    492  1.1    dante #define IOPB_SCSI_DATA          0x30
    493  1.1    dante #define IOPB_RES_ADDR_31        0x31
    494  1.1    dante #define IOPB_RES_ADDR_32        0x32
    495  1.1    dante #define IOPB_SCSI_DATA_HSHK     0x33
    496  1.1    dante #define IOPB_SCSI_CTRL          0x34
    497  1.1    dante #define IOPB_RES_ADDR_35        0x35
    498  1.1    dante #define IOPB_RES_ADDR_36        0x36
    499  1.1    dante #define IOPB_RES_ADDR_37        0x37
    500  1.7    dante #define IOPB_RAM_BIST           0x38
    501  1.7    dante #define IOPB_PLL_TEST           0x39
    502  1.7    dante #define IOPB_PCI_INT_CFG        0x3A
    503  1.1    dante #define IOPB_RES_ADDR_3B        0x3B
    504  1.1    dante #define IOPB_RFIFO_CNT          0x3C
    505  1.1    dante #define IOPB_RES_ADDR_3D        0x3D
    506  1.1    dante #define IOPB_RES_ADDR_3E        0x3E
    507  1.1    dante #define IOPB_RES_ADDR_3F        0x3F
    508  1.1    dante 
    509  1.1    dante /*
    510  1.1    dante  * Word I/O register address from base of 'iop_base'.
    511  1.1    dante  */
    512  1.1    dante #define IOPW_CHIP_ID_0          0x00  /* CID0  */
    513  1.1    dante #define IOPW_CTRL_REG           0x02  /* CC    */
    514  1.1    dante #define IOPW_RAM_ADDR           0x04  /* LA    */
    515  1.1    dante #define IOPW_RAM_DATA           0x06  /* LD    */
    516  1.1    dante #define IOPW_RES_ADDR_08        0x08
    517  1.1    dante #define IOPW_RISC_CSR           0x0A  /* CSR   */
    518  1.1    dante #define IOPW_SCSI_CFG0          0x0C  /* CFG0  */
    519  1.1    dante #define IOPW_SCSI_CFG1          0x0E  /* CFG1  */
    520  1.1    dante #define IOPW_RES_ADDR_10        0x10
    521  1.1    dante #define IOPW_SEL_MASK           0x12  /* SM    */
    522  1.1    dante #define IOPW_RES_ADDR_14        0x14
    523  1.1    dante #define IOPW_FLASH_ADDR         0x16  /* FA    */
    524  1.1    dante #define IOPW_RES_ADDR_18        0x18
    525  1.1    dante #define IOPW_EE_CMD             0x1A  /* EC    */
    526  1.1    dante #define IOPW_EE_DATA            0x1C  /* ED    */
    527  1.1    dante #define IOPW_SFIFO_CNT          0x1E  /* SFC   */
    528  1.1    dante #define IOPW_RES_ADDR_20        0x20
    529  1.1    dante #define IOPW_Q_BASE             0x22  /* QB    */
    530  1.1    dante #define IOPW_QP                 0x24  /* QP    */
    531  1.1    dante #define IOPW_IX                 0x26  /* IX    */
    532  1.1    dante #define IOPW_SP                 0x28  /* SP    */
    533  1.1    dante #define IOPW_PC                 0x2A  /* PC    */
    534  1.1    dante #define IOPW_RES_ADDR_2C        0x2C
    535  1.1    dante #define IOPW_RES_ADDR_2E        0x2E
    536  1.1    dante #define IOPW_SCSI_DATA          0x30  /* SD    */
    537  1.1    dante #define IOPW_SCSI_DATA_HSHK     0x32  /* SDH   */
    538  1.1    dante #define IOPW_SCSI_CTRL          0x34  /* SC    */
    539  1.1    dante #define IOPW_HSHK_CFG           0x36  /* HCFG  */
    540  1.1    dante #define IOPW_SXFR_STATUS        0x36  /* SXS   */
    541  1.1    dante #define IOPW_SXFR_CNTL          0x38  /* SXL   */
    542  1.1    dante #define IOPW_SXFR_CNTH          0x3A  /* SXH   */
    543  1.1    dante #define IOPW_RES_ADDR_3C        0x3C
    544  1.1    dante #define IOPW_RFIFO_DATA         0x3E  /* RFD   */
    545  1.1    dante 
    546  1.1    dante /*
    547  1.1    dante  * Doubleword I/O register address from base of 'iop_base'.
    548  1.1    dante  */
    549  1.1    dante #define IOPDW_RES_ADDR_0         0x00
    550  1.1    dante #define IOPDW_RAM_DATA           0x04
    551  1.1    dante #define IOPDW_RES_ADDR_8         0x08
    552  1.1    dante #define IOPDW_RES_ADDR_C         0x0C
    553  1.1    dante #define IOPDW_RES_ADDR_10        0x10
    554  1.7    dante #define IOPDW_COMMA              0x14
    555  1.7    dante #define IOPDW_COMMB              0x18
    556  1.1    dante #define IOPDW_RES_ADDR_1C        0x1C
    557  1.1    dante #define IOPDW_SDMA_ADDR0         0x20
    558  1.1    dante #define IOPDW_SDMA_ADDR1         0x24
    559  1.1    dante #define IOPDW_SDMA_COUNT         0x28
    560  1.1    dante #define IOPDW_SDMA_ERROR         0x2C
    561  1.1    dante #define IOPDW_RDMA_ADDR0         0x30
    562  1.1    dante #define IOPDW_RDMA_ADDR1         0x34
    563  1.1    dante #define IOPDW_RDMA_COUNT         0x38
    564  1.1    dante #define IOPDW_RDMA_ERROR         0x3C
    565  1.1    dante 
    566  1.1    dante #define ADW_CHIP_ID_BYTE         0x25
    567  1.1    dante #define ADW_CHIP_ID_WORD         0x04C1
    568  1.1    dante 
    569  1.1    dante #define ADW_SC_SCSI_BUS_RESET    0x2000
    570  1.1    dante 
    571  1.1    dante #define ADW_INTR_ENABLE_HOST_INTR                   0x01
    572  1.1    dante #define ADW_INTR_ENABLE_SEL_INTR                    0x02
    573  1.1    dante #define ADW_INTR_ENABLE_DPR_INTR                    0x04
    574  1.1    dante #define ADW_INTR_ENABLE_RTA_INTR                    0x08
    575  1.1    dante #define ADW_INTR_ENABLE_RMA_INTR                    0x10
    576  1.1    dante #define ADW_INTR_ENABLE_RST_INTR                    0x20
    577  1.1    dante #define ADW_INTR_ENABLE_DPE_INTR                    0x40
    578  1.1    dante #define ADW_INTR_ENABLE_GLOBAL_INTR                 0x80
    579  1.1    dante 
    580  1.1    dante #define ADW_INTR_STATUS_INTRA            0x01
    581  1.1    dante #define ADW_INTR_STATUS_INTRB            0x02
    582  1.1    dante #define ADW_INTR_STATUS_INTRC            0x04
    583  1.1    dante 
    584  1.1    dante #define ADW_RISC_CSR_STOP           (0x0000)
    585  1.1    dante #define ADW_RISC_TEST_COND          (0x2000)
    586  1.1    dante #define ADW_RISC_CSR_RUN            (0x4000)
    587  1.1    dante #define ADW_RISC_CSR_SINGLE_STEP    (0x8000)
    588  1.1    dante 
    589  1.1    dante #define ADW_CTRL_REG_HOST_INTR      0x0100
    590  1.1    dante #define ADW_CTRL_REG_SEL_INTR       0x0200
    591  1.1    dante #define ADW_CTRL_REG_DPR_INTR       0x0400
    592  1.1    dante #define ADW_CTRL_REG_RTA_INTR       0x0800
    593  1.1    dante #define ADW_CTRL_REG_RMA_INTR       0x1000
    594  1.1    dante #define ADW_CTRL_REG_RES_BIT14      0x2000
    595  1.1    dante #define ADW_CTRL_REG_DPE_INTR       0x4000
    596  1.1    dante #define ADW_CTRL_REG_POWER_DONE     0x8000
    597  1.1    dante #define ADW_CTRL_REG_ANY_INTR       0xFF00
    598  1.1    dante 
    599  1.1    dante #define ADW_CTRL_REG_CMD_RESET             0x00C6
    600  1.1    dante #define ADW_CTRL_REG_CMD_WR_IO_REG         0x00C5
    601  1.1    dante #define ADW_CTRL_REG_CMD_RD_IO_REG         0x00C4
    602  1.1    dante #define ADW_CTRL_REG_CMD_WR_PCI_CFG_SPACE  0x00C3
    603  1.1    dante #define ADW_CTRL_REG_CMD_RD_PCI_CFG_SPACE  0x00C2
    604  1.1    dante 
    605  1.7    dante #define ADV_TICKLE_NOP                      0x00
    606  1.7    dante #define ADV_TICKLE_A                        0x01
    607  1.7    dante #define ADV_TICKLE_B                        0x02
    608  1.7    dante #define ADV_TICKLE_C                        0x03
    609  1.7    dante 
    610  1.1    dante #define ADW_SCSI_CTRL_RSTOUT        0x2000
    611  1.1    dante 
    612  1.1    dante #define ADW_IS_INT_PENDING(iot, ioh)  \
    613  1.1    dante     (ADW_READ_WORD_REGISTER((iot), (ioh), IOPW_CTRL_REG) & ADW_CTRL_REG_HOST_INTR)
    614  1.1    dante 
    615  1.1    dante /*
    616  1.1    dante  * SCSI_CFG0 Register bit definitions
    617  1.1    dante  */
    618  1.1    dante #define ADW_TIMER_MODEAB    0xC000  /* Watchdog, Second, and Select. Timer Ctrl. */
    619  1.1    dante #define ADW_PARITY_EN       0x2000  /* Enable SCSI Parity Error detection */
    620  1.1    dante #define ADW_EVEN_PARITY     0x1000  /* Select Even Parity */
    621  1.1    dante #define ADW_WD_LONG         0x0800  /* Watchdog Interval, 1: 57 min, 0: 13 sec */
    622  1.1    dante #define ADW_QUEUE_128       0x0400  /* Queue Size, 1: 128 byte, 0: 64 byte */
    623  1.1    dante #define ADW_PRIM_MODE       0x0100  /* Primitive SCSI mode */
    624  1.1    dante #define ADW_SCAM_EN         0x0080  /* Enable SCAM selection */
    625  1.1    dante #define ADW_SEL_TMO_LONG    0x0040  /* Sel/Resel Timeout, 1: 400 ms, 0: 1.6 ms */
    626  1.1    dante #define ADW_CFRM_ID         0x0020  /* SCAM id sel. confirm., 1: fast, 0: 6.4 ms */
    627  1.1    dante #define ADW_OUR_ID_EN       0x0010  /* Enable OUR_ID bits */
    628  1.1    dante #define ADW_OUR_ID          0x000F  /* SCSI ID */
    629  1.1    dante 
    630  1.1    dante /*
    631  1.1    dante  * SCSI_CFG1 Register bit definitions
    632  1.1    dante  */
    633  1.1    dante #define ADW_BIG_ENDIAN      0x8000  /* Enable Big Endian Mode MIO:15, EEP:15 */
    634  1.1    dante #define ADW_TERM_POL        0x2000  /* Terminator Polarity Ctrl. MIO:13, EEP:13 */
    635  1.1    dante #define ADW_SLEW_RATE       0x1000  /* SCSI output buffer slew rate */
    636  1.1    dante #define ADW_FILTER_SEL      0x0C00  /* Filter Period Selection */
    637  1.1    dante #define  ADW_FLTR_DISABLE    0x0000  /* Input Filtering Disabled */
    638  1.1    dante #define  ADW_FLTR_11_TO_20NS 0x0800  /* Input Filtering 11ns to 20ns */
    639  1.1    dante #define  ADW_FLTR_21_TO_39NS 0x0C00  /* Input Filtering 21ns to 39ns */
    640  1.1    dante #define ADW_ACTIVE_DBL      0x0200  /* Disable Active Negation */
    641  1.1    dante #define ADW_DIFF_MODE       0x0100  /* SCSI differential Mode (Read-Only) */
    642  1.1    dante #define ADW_DIFF_SENSE      0x0080  /* 1: No SE cables, 0: SE cable (Read-Only) */
    643  1.1    dante #define ADW_TERM_CTL_SEL    0x0040  /* Enable TERM_CTL_H and TERM_CTL_L */
    644  1.1    dante #define ADW_TERM_CTL        0x0030  /* External SCSI Termination Bits */
    645  1.1    dante #define  ADW_TERM_CTL_H      0x0020  /* Enable External SCSI Upper Termination */
    646  1.1    dante #define  ADW_TERM_CTL_L      0x0010  /* Enable External SCSI Lower Termination */
    647  1.1    dante #define ADW_CABLE_DETECT    0x000F  /* External SCSI Cable Connection Status */
    648  1.1    dante 
    649  1.7    dante /*
    650  1.7    dante  * Addendum for ASC-38C0800 Chip
    651  1.8    dante  *
    652  1.8    dante  * The ASC-38C1600 Chip uses the same definitions except that the
    653  1.8    dante  * bus mode override bits [12:10] have been moved to byte register
    654  1.8    dante  * offset 0xE (IOPB_SOFT_OVER_WR) bits [12:10]. The [12:10] bits in
    655  1.8    dante  * SCSI_CFG1 are read-only and always available. Bit 14 (DIS_TERM_DRV)
    656  1.8    dante  * is not needed. The [12:10] bits in IOPB_SOFT_OVER_WR are write-only.
    657  1.8    dante  * Also each ASC-38C1600 function or channel uses only cable bits [5:4]
    658  1.8    dante  * and [1:0]. Bits [14], [7:6], [3:2] are unused.
    659  1.7    dante  */
    660  1.7    dante #define ADW_DIS_TERM_DRV    0x4000  /* 1: Read c_det[3:0], 0: cannot read */
    661  1.7    dante #define ADW_HVD_LVD_SE      0x1C00  /* Device Detect Bits */
    662  1.7    dante #define  ADW_HVD             0x1000  /* HVD Device Detect */
    663  1.7    dante #define  ADW_LVD             0x0800  /* LVD Device Detect */
    664  1.7    dante #define  ADW_SE              0x0400  /* SE Device Detect */
    665  1.7    dante #define ADW_TERM_LVD        0x00C0  /* LVD Termination Bits */
    666  1.7    dante #define  ADW_TERM_LVD_HI     0x0080  /* Enable LVD Upper Termination */
    667  1.7    dante #define  ADW_TERM_LVD_LO     0x0040  /* Enable LVD Lower Termination */
    668  1.7    dante #define ADW_TERM_SE         0x0030  /* SE Termination Bits */
    669  1.7    dante #define  ADW_TERM_SE_HI      0x0020  /* Enable SE Upper Termination */
    670  1.7    dante #define  ADW_TERM_SE_LO      0x0010  /* Enable SE Lower Termination */
    671  1.7    dante #define ADW_C_DET_LVD       0x000C  /* LVD Cable Detect Bits */
    672  1.7    dante #define  ADW_C_DET3          0x0008  /* Cable Detect for LVD External Wide */
    673  1.7    dante #define  ADW_C_DET2          0x0004  /* Cable Detect for LVD Internal Wide */
    674  1.7    dante #define ADW_C_DET_SE        0x0003  /* SE Cable Detect Bits */
    675  1.7    dante #define  ADW_C_DET1          0x0002  /* Cable Detect for SE Internal Wide */
    676  1.7    dante #define  ADW_C_DET0          0x0001  /* Cable Detect for SE Internal Narrow */
    677  1.7    dante 
    678  1.7    dante 
    679  1.1    dante #define CABLE_ILLEGAL_A 0x7
    680  1.1    dante     /* x 0 0 0  | on  on | Illegal (all 3 connectors are used) */
    681  1.1    dante 
    682  1.1    dante #define CABLE_ILLEGAL_B 0xB
    683  1.1    dante     /* 0 x 0 0  | on  on | Illegal (all 3 connectors are used) */
    684  1.1    dante 
    685  1.1    dante /*
    686  1.1    dante    The following table details the SCSI_CFG1 Termination Polarity,
    687  1.1    dante    Termination Control and Cable Detect bits.
    688  1.1    dante 
    689  1.1    dante    Cable Detect | Termination
    690  1.1    dante    Bit 3 2 1 0  | 5   4  | Notes
    691  1.1    dante    _____________|________|____________________
    692  1.1    dante        1 1 1 0  | on  on | Internal wide only
    693  1.1    dante        1 1 0 1  | on  on | Internal narrow only
    694  1.1    dante        1 0 1 1  | on  on | External narrow only
    695  1.1    dante        0 x 1 1  | on  on | External wide only
    696  1.1    dante        1 1 0 0  | on  off| Internal wide and internal narrow
    697  1.1    dante        1 0 1 0  | on  off| Internal wide and external narrow
    698  1.1    dante        0 x 1 0  | off off| Internal wide and external wide
    699  1.1    dante        1 0 0 1  | on  off| Internal narrow and external narrow
    700  1.1    dante        0 x 0 1  | on  off| Internal narrow and external wide
    701  1.1    dante        1 1 1 1  | on  on | No devices are attached
    702  1.1    dante        x 0 0 0  | on  on | Illegal (all 3 connectors are used)
    703  1.1    dante        0 x 0 0  | on  on | Illegal (all 3 connectors are used)
    704  1.1    dante 
    705  1.1    dante        x means don't-care (either '0' or '1')
    706  1.1    dante 
    707  1.1    dante        If term_pol (bit 13) is '0' (active-low terminator enable), then:
    708  1.1    dante            'on' is '0' and 'off' is '1'.
    709  1.1    dante 
    710  1.1    dante        If term_pol bit is '1' (meaning active-hi terminator enable), then:
    711  1.1    dante            'on' is '1' and 'off' is '0'.
    712  1.1    dante  */
    713  1.1    dante 
    714  1.1    dante /*
    715  1.1    dante  * MEM_CFG Register bit definitions
    716  1.1    dante  */
    717  1.7    dante #define ADW_BIOS_EN         0x40    /* BIOS Enable MIO:14,EEP:14 */
    718  1.7    dante #define ADW_FAST_EE_CLK     0x20    /* Diagnostic Bit */
    719  1.7    dante #define ADW_RAM_SZ          0x1C    /* Specify size of RAM to RISC */
    720  1.7    dante #define  ADW_RAM_SZ_2KB      0x00    /* 2 KB */
    721  1.7    dante #define  ADW_RAM_SZ_4KB      0x04    /* 4 KB */
    722  1.7    dante #define  ADW_RAM_SZ_8KB      0x08    /* 8 KB */
    723  1.7    dante #define  ADW_RAM_SZ_16KB     0x0C    /* 16 KB */
    724  1.7    dante #define  ADW_RAM_SZ_32KB     0x10    /* 32 KB */
    725  1.7    dante #define  ADW_RAM_SZ_64KB     0x14    /* 64 KB */
    726  1.1    dante 
    727  1.1    dante /*
    728  1.1    dante  * DMA_CFG0 Register bit definitions
    729  1.1    dante  *
    730  1.1    dante  * This register is only accessible to the host.
    731  1.1    dante  */
    732  1.1    dante #define BC_THRESH_ENB   0x80    /* PCI DMA Start Conditions */
    733  1.1    dante #define FIFO_THRESH     0x70    /* PCI DMA FIFO Threshold */
    734  1.1    dante #define  FIFO_THRESH_16B  0x00   /* 16 bytes */
    735  1.1    dante #define  FIFO_THRESH_32B  0x20   /* 32 bytes */
    736  1.1    dante #define  FIFO_THRESH_48B  0x30   /* 48 bytes */
    737  1.1    dante #define  FIFO_THRESH_64B  0x40   /* 64 bytes */
    738  1.1    dante #define  FIFO_THRESH_80B  0x50   /* 80 bytes (default) */
    739  1.1    dante #define  FIFO_THRESH_96B  0x60   /* 96 bytes */
    740  1.1    dante #define  FIFO_THRESH_112B 0x70   /* 112 bytes */
    741  1.1    dante #define START_CTL       0x0C    /* DMA start conditions */
    742  1.1    dante #define  START_CTL_TH    0x00    /* Wait threshold level (default) */
    743  1.1    dante #define  START_CTL_ID    0x04    /* Wait SDMA/SBUS idle */
    744  1.1    dante #define  START_CTL_THID  0x08    /* Wait threshold and SDMA/SBUS idle */
    745  1.1    dante #define  START_CTL_EMFU  0x0C    /* Wait SDMA FIFO empty/full */
    746  1.1    dante #define READ_CMD        0x03    /* Memory Read Method */
    747  1.1    dante #define  READ_CMD_MR     0x00    /* Memory Read */
    748  1.1    dante #define  READ_CMD_MRL    0x02    /* Memory Read Long */
    749  1.1    dante #define  READ_CMD_MRM    0x03    /* Memory Read Multiple (default) */
    750  1.1    dante 
    751  1.7    dante /*
    752  1.7    dante  * ASC-38C0800 RAM BIST Register bit definitions
    753  1.7    dante  */
    754  1.7    dante #define RAM_TEST_MODE         0x80
    755  1.7    dante #define PRE_TEST_MODE         0x40
    756  1.7    dante #define NORMAL_MODE           0x00
    757  1.7    dante #define RAM_TEST_DONE         0x10
    758  1.7    dante #define RAM_TEST_STATUS       0x0F
    759  1.7    dante #define  RAM_TEST_HOST_ERROR   0x08
    760  1.7    dante #define  RAM_TEST_INTRAM_ERROR 0x04
    761  1.7    dante #define  RAM_TEST_RISC_ERROR   0x02
    762  1.7    dante #define  RAM_TEST_SCSI_ERROR   0x01
    763  1.7    dante #define  RAM_TEST_SUCCESS      0x00
    764  1.7    dante #define PRE_TEST_VALUE        0x05
    765  1.7    dante #define NORMAL_VALUE          0x00
    766  1.7    dante 
    767  1.8    dante /*
    768  1.8    dante  * ASC38C1600 Definitions
    769  1.8    dante  *
    770  1.8    dante  * IOPB_PCI_INT_CFG Bit Field Definitions
    771  1.8    dante  */
    772  1.8    dante 
    773  1.8    dante #define INTAB_LD	0x80    /* Value loaded from EEPROM Bit 11. */
    774  1.8    dante 
    775  1.8    dante /*
    776  1.8    dante  * Bit 1 can be set to change the interrupt for the Function to operate in
    777  1.8    dante  * Totem Pole mode. By default Bit 1 is 0 and the interrupt operates in
    778  1.8    dante  * Open Drain mode. Both functions of the ASC38C1600 must be set to the same
    779  1.8    dante  * mode, otherwise the operating mode is undefined.
    780  1.8    dante  */
    781  1.8    dante #define TOTEMPOLE	0x02
    782  1.8    dante 
    783  1.8    dante /*
    784  1.8    dante  * Bit 0 can be used to change the Int Pin for the Function. The value is
    785  1.8    dante  * 0 by default for both Functions with Function 0 using INT A and Function
    786  1.8    dante  * B using INT B. For Function 0 if set, INT B is used. For Function 1 if set,
    787  1.8    dante  * INT A is used.
    788  1.8    dante  *
    789  1.8    dante  * EEPROM Word 0 Bit 11 for each Function may change the initial Int Pin
    790  1.8    dante  * value specified in the PCI Configuration Space.
    791  1.8    dante  */
    792  1.8    dante #define INTAB		0x01
    793  1.8    dante 
    794  1.1    dante 
    795  1.1    dante /*
    796  1.1    dante  * Adv Library Status Definitions
    797  1.1    dante  */
    798  1.1    dante #define ADW_TRUE        1
    799  1.1    dante #define ADW_FALSE       0
    800  1.1    dante #define ADW_NOERROR     1
    801  1.1    dante #define ADW_SUCCESS     1
    802  1.1    dante #define ADW_BUSY        0
    803  1.1    dante #define ADW_ERROR       (-1)
    804  1.1    dante 
    805  1.1    dante 
    806  1.1    dante /*
    807  1.1    dante  * ASC_DVC_VAR 'warn_code' values
    808  1.1    dante  */
    809  1.7    dante #define ASC_WARN_BUSRESET_ERROR         0x0001 /* SCSI Bus Reset error */
    810  1.1    dante #define ASC_WARN_EEPROM_CHKSUM          0x0002 /* EEP check sum error */
    811  1.1    dante #define ASC_WARN_EEPROM_TERMINATION     0x0004 /* EEP termination bad field */
    812  1.1    dante #define ASC_WARN_SET_PCI_CONFIG_SPACE   0x0080 /* PCI config space set error */
    813  1.1    dante #define ASC_WARN_ERROR                  0xFFFF /* ADW_ERROR return */
    814  1.1    dante 
    815  1.1    dante #define ADW_MAX_TID                     15 /* max. target identifier */
    816  1.1    dante #define ADW_MAX_LUN                     7  /* max. logical unit number */
    817  1.1    dante 
    818  1.1    dante 
    819  1.1    dante /*
    820  1.1    dante  * AscInitGetConfig() and AscInitAsc1000Driver() Definitions
    821  1.1    dante  *
    822  1.1    dante  * Error code values are set in ASC_DVC_VAR 'err_code'.
    823  1.1    dante  */
    824  1.1    dante #define ASC_IERR_WRITE_EEPROM       0x0001 /* write EEPROM error */
    825  1.1    dante #define ASC_IERR_MCODE_CHKSUM       0x0002 /* micro code check sum error */
    826  1.7    dante #define ASC_IERR_NO_CARRIER         0x0004 /* No more carrier memory. */
    827  1.1    dante #define ASC_IERR_START_STOP_CHIP    0x0008 /* start/stop chip failed */
    828  1.1    dante #define ASC_IERR_CHIP_VERSION       0x0040 /* wrong chip version */
    829  1.1    dante #define ASC_IERR_SET_SCSI_ID        0x0080 /* set SCSI ID failed */
    830  1.7    dante #define ASC_IERR_HVD_DEVICE         0x0100 /* HVD attached to LVD connector. */
    831  1.1    dante #define ASC_IERR_BAD_SIGNATURE      0x0200 /* signature not found */
    832  1.1    dante #define ASC_IERR_ILLEGAL_CONNECTION 0x0400 /* Illegal cable connection */
    833  1.1    dante #define ASC_IERR_SINGLE_END_DEVICE  0x0800 /* Single-end used w/differential */
    834  1.1    dante #define ASC_IERR_REVERSED_CABLE     0x1000 /* Narrow flat cable reversed */
    835  1.7    dante #define ASC_IERR_BIST_PRE_TEST      0x2000 /* BIST pre-test error */
    836  1.7    dante #define ASC_IERR_BIST_RAM_TEST      0x4000 /* BIST RAM test error */
    837  1.7    dante #define ASC_IERR_BAD_CHIPTYPE       0x8000 /* Invalid 'chip_type' setting. */
    838  1.1    dante 
    839  1.1    dante /*
    840  1.1    dante  * Fixed locations of microcode operating variables.
    841  1.1    dante  */
    842  1.1    dante #define ASC_MC_CODE_BEGIN_ADDR          0x0028 /* microcode start address */
    843  1.1    dante #define ASC_MC_CODE_END_ADDR            0x002A /* microcode end address */
    844  1.1    dante #define ASC_MC_CODE_CHK_SUM             0x002C /* microcode code checksum */
    845  1.1    dante #define ASC_MC_VERSION_DATE             0x0038 /* microcode version */
    846  1.1    dante #define ASC_MC_VERSION_NUM              0x003A /* microcode number */
    847  1.1    dante #define ASC_MC_BIOSMEM                  0x0040 /* BIOS RISC Memory Start */
    848  1.1    dante #define ASC_MC_BIOSLEN                  0x0050 /* BIOS RISC Memory Length */
    849  1.7    dante #define ASC_MC_BIOS_SIGNATURE           0x0058 /* BIOS Signature 0x55AA */
    850  1.7    dante #define ASC_MC_BIOS_VERSION             0x005A /* BIOS Version (2 bytes) */
    851  1.7    dante #define ASC_MC_SDTR_SPEED1              0x0090 /* SDTR Speed for TID 0-3 */
    852  1.7    dante #define ASC_MC_SDTR_SPEED2              0x0092 /* SDTR Speed for TID 4-7 */
    853  1.7    dante #define ASC_MC_SDTR_SPEED3              0x0094 /* SDTR Speed for TID 8-11 */
    854  1.7    dante #define ASC_MC_SDTR_SPEED4              0x0096 /* SDTR Speed for TID 12-15 */
    855  1.7    dante #define ASC_MC_CHIP_TYPE                0x009A
    856  1.7    dante #define ASC_MC_INTRB_CODE               0x009B
    857  1.7    dante #define ASC_MC_WDTR_ABLE                0x009C
    858  1.7    dante #define ASC_MC_SDTR_ABLE                0x009E
    859  1.1    dante #define ASC_MC_TAGQNG_ABLE              0x00A0
    860  1.1    dante #define ASC_MC_DISC_ENABLE              0x00A2
    861  1.7    dante #define ASC_MC_IDLE_CMD_STATUS          0x00A4
    862  1.1    dante #define ASC_MC_IDLE_CMD                 0x00A6
    863  1.7    dante #define ASC_MC_IDLE_CMD_PARAMETER       0x00A8
    864  1.1    dante #define ASC_MC_DEFAULT_SCSI_CFG0        0x00AC
    865  1.1    dante #define ASC_MC_DEFAULT_SCSI_CFG1        0x00AE
    866  1.1    dante #define ASC_MC_DEFAULT_MEM_CFG          0x00B0
    867  1.1    dante #define ASC_MC_DEFAULT_SEL_MASK         0x00B2
    868  1.1    dante #define ASC_MC_SDTR_DONE                0x00B6
    869  1.1    dante #define ASC_MC_NUMBER_OF_QUEUED_CMD     0x00C0
    870  1.1    dante #define ASC_MC_NUMBER_OF_MAX_CMD        0x00D0
    871  1.1    dante #define ASC_MC_DEVICE_HSHK_CFG_TABLE    0x0100
    872  1.1    dante #define ASC_MC_CONTROL_FLAG             0x0122 /* Microcode control flag. */
    873  1.1    dante #define ASC_MC_WDTR_DONE                0x0124
    874  1.7    dante #define ASC_MC_CAM_MODE_MASK            0x015E /* CAM mode TID bitmask. */
    875  1.7    dante #define ASC_MC_ICQ                      0x0160
    876  1.7    dante #define ASC_MC_IRQ                      0x0164
    877  1.8    dante #define ASC_MC_PPR_ABLE                 0x017A
    878  1.1    dante 
    879  1.1    dante /*
    880  1.1    dante  * BIOS LRAM variable absolute offsets.
    881  1.1    dante  */
    882  1.1    dante #define BIOS_CODESEG    0x54
    883  1.1    dante #define BIOS_CODELEN    0x56
    884  1.1    dante #define BIOS_SIGNATURE  0x58
    885  1.1    dante #define BIOS_VERSION    0x5A
    886  1.1    dante 
    887  1.1    dante /*
    888  1.1    dante  * Microcode Control Flags
    889  1.1    dante  *
    890  1.1    dante  * Flags set by the Adv Library in RISC variable 'control_flag' (0x122)
    891  1.1    dante  * and handled by the microcode.
    892  1.1    dante  */
    893  1.1    dante #define CONTROL_FLAG_IGNORE_PERR        0x0001 /* Ignore DMA Parity Errors */
    894  1.8    dante #define CONTROL_FLAG_ENABLE_AIPP        0x0002 /* Enabled AIPP checking. */
    895  1.1    dante 
    896  1.1    dante /*
    897  1.1    dante  * ASC_MC_DEVICE_HSHK_CFG_TABLE microcode table or HSHK_CFG register format
    898  1.1    dante  */
    899  1.1    dante #define HSHK_CFG_WIDE_XFR       0x8000
    900  1.1    dante #define HSHK_CFG_RATE           0x0F00
    901  1.1    dante #define HSHK_CFG_OFFSET         0x001F
    902  1.1    dante 
    903  1.1    dante #define ASC_DEF_MAX_HOST_QNG    0xFD /* Max. number of host commands (253) */
    904  1.1    dante #define ASC_DEF_MIN_HOST_QNG    0x10 /* Min. number of host commands (16) */
    905  1.1    dante #define ASC_DEF_MAX_DVC_QNG     0x3F /* Max. number commands per device (63) */
    906  1.1    dante #define ASC_DEF_MIN_DVC_QNG     0x04 /* Min. number commands per device (4) */
    907  1.1    dante 
    908  1.7    dante #define ASC_QC_DATA_CHECK  0x01 /* Require ASC_QC_DATA_OUT set or clear. */
    909  1.7    dante #define ASC_QC_DATA_OUT    0x02 /* Data out DMA transfer. */
    910  1.7    dante #define ASC_QC_START_MOTOR 0x04 /* Send auto-start motor before request. */
    911  1.7    dante #define ASC_QC_NO_OVERRUN  0x08 /* Don't report overrun. */
    912  1.7    dante #define ASC_QC_FREEZE_TIDQ 0x10 /* Freeze TID queue after request. XXX TBD */
    913  1.7    dante 
    914  1.7    dante #define ASC_QSC_NO_DISC     0x01 /* Don't allow disconnect for request. */
    915  1.7    dante #define ASC_QSC_NO_TAGMSG   0x02 /* Don't allow tag queuing for request. */
    916  1.7    dante #define ASC_QSC_NO_SYNC     0x04 /* Don't use Synch. transfer on request. */
    917  1.7    dante #define ASC_QSC_NO_WIDE     0x08 /* Don't use Wide transfer on request. */
    918  1.7    dante #define ASC_QSC_REDO_DTR    0x10 /* Renegotiate WDTR/SDTR before request. */
    919  1.7    dante /*
    920  1.7    dante  * Note: If a Tag Message is to be sent and neither ASC_QSC_HEAD_TAG or
    921  1.7    dante  * ASC_QSC_ORDERED_TAG is set, then a Simple Tag Message (0x20) is used.
    922  1.7    dante  */
    923  1.7    dante #define ASC_QSC_HEAD_TAG    0x40 /* Use Head Tag Message (0x21). */
    924  1.7    dante #define ASC_QSC_ORDERED_TAG 0x80 /* Use Ordered Tag Message (0x22). */
    925  1.7    dante 
    926  1.7    dante #define ADV_CHIP_ASC3550          0x01   /* Ultra-Wide IC */
    927  1.7    dante #define ADV_CHIP_ASC38C0800       0x02   /* Ultra2-Wide/LVD IC */
    928  1.7    dante #define ADV_CHIP_ASC38C1600       0x03   /* Ultra3-Wide/LVD2 IC */
    929  1.1    dante 
    930  1.1    dante /*
    931  1.1    dante  * Adapter temporary configuration structure
    932  1.1    dante  *
    933  1.1    dante  * This structure can be discarded after initialization. Don't add
    934  1.1    dante  * fields here needed after initialization.
    935  1.1    dante  *
    936  1.1    dante  * Field naming convention:
    937  1.1    dante  *
    938  1.1    dante  *  *_enable indicates the field enables or disables a feature. The
    939  1.1    dante  *  value of the field is never reset.
    940  1.1    dante  */
    941  1.1    dante typedef struct adw_dvc_cfg {
    942  1.1    dante 	u_int16_t	disc_enable;	/* enable disconnection */
    943  1.1    dante 	u_int8_t	chip_version;	/* chip version */
    944  1.1    dante 	u_int8_t	termination;	/* Term. Ctrl. bits 6-5 of SCSI_CFG1 register */
    945  1.1    dante 	u_int16_t	pci_device_id;	/* PCI device code number */
    946  1.1    dante 	u_int16_t	lib_version;	/* Adv Library version number */
    947  1.1    dante 	u_int16_t	control_flag;	/* Microcode Control Flag */
    948  1.1    dante 	u_int16_t	mcode_date;	/* Microcode date */
    949  1.1    dante 	u_int16_t	mcode_version;	/* Microcode version */
    950  1.1    dante 	u_int16_t	pci_slot_info;	/* high byte device/function number */
    951  1.1    dante 					/* bits 7-3 device num., bits 2-0 function num. */
    952  1.1    dante 					/* low byte bus num. */
    953  1.1    dante 	u_int16_t	serial1;	/* EEPROM serial number word 1 */
    954  1.1    dante 	u_int16_t	serial2;	/* EEPROM serial number word 2 */
    955  1.1    dante 	u_int16_t	serial3;	/* EEPROM serial number word 3 */
    956  1.1    dante } ADW_DVC_CFG;
    957  1.1    dante 
    958  1.7    dante 
    959  1.7    dante #define NO_OF_SG_PER_BLOCK              15
    960  1.7    dante 
    961  1.7    dante typedef struct adw_sg_block {
    962  1.7    dante 	u_int8_t	reserved1;
    963  1.7    dante 	u_int8_t	reserved2;
    964  1.7    dante 	u_int8_t	reserved3;
    965  1.7    dante 	u_int8_t	sg_cnt;			/* Valid entries in block. */
    966  1.7    dante 	u_int32_t	sg_ptr;			/* links to next sg block */
    967  1.7    dante 	struct {
    968  1.7    dante 		u_int32_t sg_addr;		/* SG element address */
    969  1.7    dante 		u_int32_t sg_count;		/* SG element count */
    970  1.7    dante 	} sg_list[NO_OF_SG_PER_BLOCK];
    971  1.7    dante } ADW_SG_BLOCK;
    972  1.7    dante 
    973  1.7    dante 
    974  1.1    dante /*
    975  1.1    dante  * Adapter operation variable structure.
    976  1.1    dante  *
    977  1.1    dante  * One structure is required per host adapter.
    978  1.1    dante  *
    979  1.1    dante  * Field naming convention:
    980  1.1    dante  *
    981  1.1    dante  *  *_able indicates both whether a feature should be enabled or disabled
    982  1.1    dante  *  and whether a device is capable of the feature. At initialization
    983  1.1    dante  *  this field may be set, but later if a device is found to be incapable
    984  1.1    dante  *  of the feature, the field is cleared.
    985  1.1    dante  */
    986  1.4    dante #define	CCB_HASH_SIZE	32	/* hash table size for phystokv */
    987  1.4    dante #define	CCB_HASH_SHIFT	9
    988  1.6  thorpej #define CCB_HASH(x)	((((x)) >> CCB_HASH_SHIFT) & (CCB_HASH_SIZE - 1))
    989  1.4    dante 
    990  1.7    dante #define	CARRIER_HASH_SIZE	32	/* hash table size for phystokv */
    991  1.7    dante #define	CARRIER_HASH_SHIFT	9
    992  1.7    dante #define CARRIER_HASH(x)	((((x)) >> CARRIER_HASH_SHIFT) & (CARRIER_HASH_SIZE - 1))
    993  1.7    dante 
    994  1.5    dante typedef int (* ADW_CALLBACK) (int);
    995  1.5    dante 
    996  1.1    dante typedef struct adw_softc {
    997  1.1    dante 
    998  1.1    dante 	struct device		sc_dev;
    999  1.1    dante 
   1000  1.1    dante 	bus_space_tag_t		sc_iot;
   1001  1.1    dante 	bus_space_handle_t	sc_ioh;
   1002  1.1    dante 	bus_dma_tag_t		sc_dmat;
   1003  1.1    dante 	bus_dmamap_t		sc_dmamap_control; /* maps the control structures */
   1004  1.7    dante 	bus_dmamap_t		sc_dmamap_carrier; /* maps the carrier structures */
   1005  1.1    dante 	void			*sc_ih;
   1006  1.1    dante 
   1007  1.1    dante 	struct adw_control	*sc_control; /* control structures */
   1008  1.4    dante 
   1009  1.7    dante 	struct adw_carrier	*sc_carrhash[CARRIER_HASH_SIZE];
   1010  1.4    dante 	struct adw_ccb		*sc_ccbhash[CCB_HASH_SIZE];
   1011  1.1    dante 	TAILQ_HEAD(, adw_ccb)	sc_free_ccb, sc_waiting_ccb;
   1012  1.1    dante 	struct scsipi_link	sc_link;     /* prototype for devs */
   1013  1.2  thorpej 	struct scsipi_adapter	sc_adapter;
   1014  1.1    dante 
   1015  1.3  thorpej 	TAILQ_HEAD(, scsipi_xfer) sc_queue;
   1016  1.1    dante 
   1017  1.5    dante 	ADW_CALLBACK	isr_callback;	/* pointer to function, called in AdvISR() */
   1018  1.7    dante 	ADW_CALLBACK	async_callback;	/* pointer to function, called in AdvISR() */
   1019  1.1    dante 	u_int16_t	bios_ctrl;	/* BIOS control word, EEPROM word 12 */
   1020  1.1    dante 	u_int16_t	wdtr_able;	/* try WDTR for a device */
   1021  1.1    dante 	u_int16_t	sdtr_able;	/* try SDTR for a device */
   1022  1.1    dante 	u_int16_t	ultra_able;	/* try SDTR Ultra speed for a device */
   1023  1.7    dante 	u_int16_t	sdtr_speed1;	/* EEPROM SDTR Speed for TID 0-3   */
   1024  1.7    dante 	u_int16_t	sdtr_speed2;	/* EEPROM SDTR Speed for TID 4-7   */
   1025  1.7    dante 	u_int16_t	sdtr_speed3;	/* EEPROM SDTR Speed for TID 8-11  */
   1026  1.7    dante 	u_int16_t	sdtr_speed4;	/* EEPROM SDTR Speed for TID 12-15 */
   1027  1.1    dante 	u_int16_t	tagqng_able;	/* try tagged queuing with a device */
   1028  1.8    dante 	u_int16_t	ppr_able;	/* PPR message capable per TID bitmask. */
   1029  1.5    dante 	u_int16_t	start_motor;	/* start motor command allowed */
   1030  1.1    dante 	u_int8_t	max_dvc_qng;	/* maximum number of tagged commands per device */
   1031  1.1    dante 	u_int8_t	scsi_reset_wait; /* delay in seconds after scsi bus reset */
   1032  1.1    dante 	u_int8_t	chip_no; 	/* should be assigned by caller */
   1033  1.1    dante 	u_int8_t	max_host_qng;	/* maximum number of Q'ed command allowed */
   1034  1.1    dante 	u_int8_t	irq_no;  	/* IRQ number */
   1035  1.7    dante 	u_int8_t	chip_type;	/* chip SCSI target ID */
   1036  1.1    dante 	u_int16_t	no_scam; 	/* scam_tolerant of EEPROM */
   1037  1.7    dante 	u_int32_t	drv_ptr; 	/* driver pointer to private structure */
   1038  1.1    dante 	u_int8_t	chip_scsi_id;	/* chip SCSI target ID */
   1039  1.7    dante 	u_int8_t	bist_err_code;
   1040  1.7    dante 	u_int16_t	carr_pending_cnt;  /* Count of pending carriers. */
   1041  1.7    dante 	struct adw_carrier	*carr_freelist;	/* Carrier free list. */
   1042  1.7    dante 	struct adw_carrier	*icq_sp; /* Initiator command queue stopper pointer. */
   1043  1.7    dante 	struct adw_carrier	*irq_sp; /* Initiator response queue stopper pointer. */
   1044  1.1    dante  /*
   1045  1.1    dante   * Note: The following fields will not be used after initialization. The
   1046  1.1    dante   * driver may discard the buffer after initialization is done.
   1047  1.1    dante   */
   1048  1.1    dante   ADW_DVC_CFG cfg; /* temporary configuration structure  */
   1049  1.1    dante } ADW_SOFTC;
   1050  1.1    dante 
   1051  1.1    dante 
   1052  1.1    dante /*
   1053  1.1    dante  * ADW_SCSI_REQ_Q - microcode request structure
   1054  1.1    dante  *
   1055  1.1    dante  * All fields in this structure up to byte 60 are used by the microcode.
   1056  1.1    dante  * The microcode makes assumptions about the size and ordering of fields
   1057  1.1    dante  * in this structure. Do not change the structure definition here without
   1058  1.1    dante  * coordinating the change with the microcode.
   1059  1.1    dante  */
   1060  1.1    dante typedef struct adw_scsi_req_q {
   1061  1.1    dante 	u_int8_t	cntl;		/* Ucode flags and state (ASC_MC_QC_*). */
   1062  1.7    dante 	u_int8_t	target_cmd;
   1063  1.1    dante 	u_int8_t	target_id;	/* Device target identifier. */
   1064  1.1    dante 	u_int8_t	target_lun;	/* Device target logical unit number. */
   1065  1.6  thorpej 	u_int32_t	data_addr;	/* Data buffer physical address. */
   1066  1.1    dante 	u_int32_t	data_cnt;	/* Data count. Ucode sets to residual. */
   1067  1.6  thorpej 	u_int32_t	sense_addr;	/* Sense buffer physical address. */
   1068  1.7    dante 	u_int32_t	carr_pa;	/* Carrier p-address */
   1069  1.7    dante 	u_int8_t	mflag;		/* Adv Library flag field. */
   1070  1.4    dante 	u_int8_t	sense_len;	/* Auto-sense length. uCode sets to residual. */
   1071  1.8    dante 	u_int8_t	cdb_len;	/* SCSI CDB length. Must <= 16 bytes. */
   1072  1.7    dante 	u_int8_t	scsi_cntl;
   1073  1.1    dante 	u_int8_t	done_status;	/* Completion status. */
   1074  1.1    dante 	u_int8_t	scsi_status;	/* SCSI status byte. (see below) */
   1075  1.1    dante 	u_int8_t	host_status;	/* Ucode host status. */
   1076  1.7    dante 	u_int8_t	sg_working_ix;	/* Ucode working SG variable. */
   1077  1.8    dante 	u_int8_t	cdb[12];	/* SCSI CDB bytes 0-11. */
   1078  1.6  thorpej 	u_int32_t	sg_real_addr;	/* SG list physical address. */
   1079  1.7    dante 	u_int32_t	scsiq_rptr;	/* Iternal pointer to ADW_SCSI_REQ_Q */
   1080  1.8    dante 	u_int8_t	cdb16[4];	/* SCSI CDB bytes 12-15. */
   1081  1.7    dante 	u_int32_t	ccb_ptr;	/* CCB Physical Address */
   1082  1.7    dante 	u_int32_t	carr_va;	/* Carrier v-address (unused) */
   1083  1.1    dante 	/*
   1084  1.1    dante 	 * End of microcode structure - 60 bytes. The rest of the structure
   1085  1.1    dante 	 * is used by the Adv Library and ignored by the microcode.
   1086  1.1    dante 	 */
   1087  1.4    dante 	struct scsipi_sense_data *vsense_addr;	/* Sense buffer virtual address. */
   1088  1.4    dante 	u_char		*vdata_addr;	/* Data buffer virtual address. */
   1089  1.1    dante 	u_int8_t	orig_sense_len;	/* Original length of sense buffer. */
   1090  1.1    dante 	u_int8_t	pads[3];	/* padding bytes (align to long) */
   1091  1.1    dante } ADW_SCSI_REQ_Q;
   1092  1.1    dante 
   1093  1.1    dante /*
   1094  1.1    dante  * Microcode idle loop commands
   1095  1.1    dante  */
   1096  1.1    dante #define IDLE_CMD_COMPLETED           0
   1097  1.1    dante #define IDLE_CMD_STOP_CHIP           0x0001
   1098  1.1    dante #define IDLE_CMD_STOP_CHIP_SEND_INT  0x0002
   1099  1.1    dante #define IDLE_CMD_SEND_INT            0x0004
   1100  1.1    dante #define IDLE_CMD_ABORT               0x0008
   1101  1.1    dante #define IDLE_CMD_DEVICE_RESET        0x0010
   1102  1.7    dante #define IDLE_CMD_SCSI_RESET_START    0x0020 /* Assert SCSI Bus Reset */
   1103  1.7    dante #define IDLE_CMD_SCSI_RESET_END      0x0040 /* Deassert SCSI Bus Reset */
   1104  1.7    dante #define IDLE_CMD_SCSIREQ             0x0080
   1105  1.7    dante 
   1106  1.7    dante #define IDLE_CMD_STATUS_SUCCESS      0x0001
   1107  1.7    dante #define IDLE_CMD_STATUS_FAILURE      0x0002
   1108  1.1    dante 
   1109  1.1    dante /*
   1110  1.1    dante  * AdvSendIdleCmd() flag definitions.
   1111  1.1    dante  */
   1112  1.1    dante #define ADW_NOWAIT     0x01
   1113  1.1    dante 
   1114  1.1    dante /*
   1115  1.1    dante  * Wait loop time out values.
   1116  1.1    dante  */
   1117  1.7    dante #define SCSI_WAIT_10_SEC             10UL    /* 10 seconds */
   1118  1.7    dante #define SCSI_WAIT_100_MSEC           100UL   /* 100 milliseconds */
   1119  1.7    dante #define SCSI_US_PER_MSEC             1000    /* microseconds per millisecond */
   1120  1.7    dante #define SCSI_MS_PER_SEC              1000UL  /* milliseconds per second */
   1121  1.7    dante #define SCSI_MAX_RETRY               10      /* retry count */
   1122  1.7    dante 
   1123  1.7    dante #define ADV_ASYNC_RDMA_FAILURE          0x01 /* Fatal RDMA failure. */
   1124  1.7    dante #define ADV_ASYNC_SCSI_BUS_RESET_DET    0x02 /* Detected SCSI Bus Reset. */
   1125  1.7    dante #define ADV_ASYNC_CARRIER_READY_FAILURE 0x03 /* Carrier Ready failure. */
   1126  1.7    dante 
   1127  1.7    dante #define ADV_HOST_SCSI_BUS_RESET      0x80 /* Host Initiated SCSI Bus Reset. */
   1128  1.1    dante 
   1129  1.1    dante 
   1130  1.1    dante /* Read byte from a register. */
   1131  1.1    dante #define ADW_READ_BYTE_REGISTER(iot, ioh, reg_off) \
   1132  1.1    dante 	bus_space_read_1((iot), (ioh), (reg_off))
   1133  1.1    dante 
   1134  1.1    dante /* Write byte to a register. */
   1135  1.1    dante #define ADW_WRITE_BYTE_REGISTER(iot, ioh, reg_off, byte) \
   1136  1.1    dante 	bus_space_write_1((iot), (ioh), (reg_off), (byte))
   1137  1.1    dante 
   1138  1.1    dante /* Read word (2 bytes) from a register. */
   1139  1.1    dante #define ADW_READ_WORD_REGISTER(iot, ioh, reg_off) \
   1140  1.1    dante 	bus_space_read_2((iot), (ioh), (reg_off))
   1141  1.1    dante 
   1142  1.1    dante /* Write word (2 bytes) to a register. */
   1143  1.1    dante #define ADW_WRITE_WORD_REGISTER(iot, ioh, reg_off, word) \
   1144  1.1    dante 	bus_space_write_2((iot), (ioh), (reg_off), (word))
   1145  1.1    dante 
   1146  1.8    dante /* Write double word (4 bytes) to a register. */
   1147  1.8    dante #define ADW_WRITE_DWORD_REGISTER(iot, ioh, reg_off, dword) \
   1148  1.8    dante 	bus_space_write_4((iot), (ioh), (reg_off), (dword))
   1149  1.8    dante 
   1150  1.1    dante /* Read byte from LRAM. */
   1151  1.1    dante #define ADW_READ_BYTE_LRAM(iot, ioh, addr, byte) \
   1152  1.1    dante do { \
   1153  1.1    dante 	bus_space_write_2((iot), (ioh), IOPW_RAM_ADDR, (addr)); \
   1154  1.1    dante 	(byte) = bus_space_read_1((iot), (ioh), IOPB_RAM_DATA); \
   1155  1.1    dante } while (0)
   1156  1.1    dante 
   1157  1.1    dante /* Write byte to LRAM. */
   1158  1.1    dante #define ADW_WRITE_BYTE_LRAM(iot, ioh, addr, byte) \
   1159  1.1    dante do { \
   1160  1.1    dante 	bus_space_write_2((iot), (ioh), IOPW_RAM_ADDR, (addr)); \
   1161  1.1    dante 	bus_space_write_1((iot), (ioh), IOPB_RAM_DATA, (byte)); \
   1162  1.1    dante } while (0)
   1163  1.1    dante 
   1164  1.1    dante /* Read word (2 bytes) from LRAM. */
   1165  1.1    dante #define ADW_READ_WORD_LRAM(iot, ioh, addr, word) \
   1166  1.1    dante do { \
   1167  1.1    dante 	bus_space_write_2((iot), (ioh), IOPW_RAM_ADDR, (addr));  \
   1168  1.1    dante 	(word) = bus_space_read_2((iot), (ioh), IOPW_RAM_DATA); \
   1169  1.1    dante } while (0)
   1170  1.1    dante 
   1171  1.1    dante /* Write word (2 bytes) to LRAM. */
   1172  1.1    dante #define ADW_WRITE_WORD_LRAM(iot, ioh, addr, word) \
   1173  1.1    dante do { \
   1174  1.1    dante 	bus_space_write_2((iot), (ioh), IOPW_RAM_ADDR, (addr)); \
   1175  1.1    dante 	bus_space_write_2((iot), (ioh), IOPW_RAM_DATA, (word)); \
   1176  1.1    dante } while (0)
   1177  1.1    dante 
   1178  1.1    dante /* Write double word (4 bytes) to LRAM */
   1179  1.1    dante /* Because of unspecified C language ordering don't use auto-increment. */
   1180  1.1    dante #define ADW_WRITE_DWORD_LRAM(iot, ioh, addr, dword) \
   1181  1.1    dante do { \
   1182  1.1    dante 	bus_space_write_2((iot), (ioh), IOPW_RAM_ADDR, (addr)); \
   1183  1.1    dante 	bus_space_write_2((iot), (ioh), IOPW_RAM_DATA, \
   1184  1.1    dante 		(ushort) ((dword) & 0xFFFF)); \
   1185  1.1    dante 	bus_space_write_2((iot), (ioh), IOPW_RAM_ADDR, (addr) + 2); \
   1186  1.1    dante 	bus_space_write_2((iot), (ioh), IOPW_RAM_DATA, \
   1187  1.1    dante 			(ushort) ((dword >> 16) & 0xFFFF)); \
   1188  1.1    dante } while (0)
   1189  1.1    dante 
   1190  1.1    dante /* Read word (2 bytes) from LRAM assuming that the address is already set. */
   1191  1.1    dante #define ADW_READ_WORD_AUTO_INC_LRAM(iot, ioh) \
   1192  1.1    dante 	bus_space_read_2((iot), (ioh), IOPW_RAM_DATA) \
   1193  1.1    dante 
   1194  1.1    dante /* Write word (2 bytes) to LRAM assuming that the address is already set. */
   1195  1.1    dante #define ADW_WRITE_WORD_AUTO_INC_LRAM(iot, ioh, word) \
   1196  1.1    dante 	bus_space_write_2((iot), (ioh), IOPW_RAM_DATA, (word))
   1197  1.1    dante 
   1198  1.1    dante /*
   1199  1.1    dante  * Define macro to check for Condor signature.
   1200  1.1    dante  *
   1201  1.1    dante  * Evaluate to ADW_TRUE if a Condor chip is found the specified port
   1202  1.1    dante  * address 'iop_base'. Otherwise evalue to ADW_FALSE.
   1203  1.1    dante  */
   1204  1.1    dante #define ADW_FIND_SIGNATURE(iot, ioh) \
   1205  1.1    dante 	(((ADW_READ_BYTE_REGISTER((iot), (ioh), IOPB_CHIP_ID_1) == \
   1206  1.1    dante 		ADW_CHIP_ID_BYTE) && \
   1207  1.1    dante 		(ADW_READ_WORD_REGISTER((iot), (ioh), IOPW_CHIP_ID_0) == \
   1208  1.1    dante 		ADW_CHIP_ID_WORD)) ?  ADW_TRUE : ADW_FALSE)
   1209  1.1    dante 
   1210  1.1    dante /*
   1211  1.1    dante  * Define macro to Return the version number of the chip at 'iop_base'.
   1212  1.1    dante  *
   1213  1.1    dante  * The second parameter 'bus_type' is currently unused.
   1214  1.1    dante  */
   1215  1.1    dante #define ADW_GET_CHIP_VERSION(iot, ioh, bus_type) \
   1216  1.1    dante 	ADW_READ_BYTE_REGISTER((iot), (ioh), IOPB_CHIP_TYPE_REV)
   1217  1.1    dante 
   1218  1.1    dante /*
   1219  1.1    dante  * Abort an SRB in the chip's RISC Memory. The 'srb_ptr' argument must
   1220  1.1    dante  * match the ASC_SCSI_REQ_Q 'srb_ptr' field.
   1221  1.1    dante  *
   1222  1.1    dante  * If the request has not yet been sent to the device it will simply be
   1223  1.1    dante  * aborted from RISC memory. If the request is disconnected it will be
   1224  1.1    dante  * aborted on reselection by sending an Abort Message to the target ID.
   1225  1.1    dante  *
   1226  1.1    dante  * Return value:
   1227  1.1    dante  *      ADW_TRUE(1) - Queue was successfully aborted.
   1228  1.1    dante  *      ADW_FALSE(0) - Queue was not found on the active queue list.
   1229  1.1    dante  */
   1230  1.1    dante #define ADW_ABORT_CCB(sc, ccb_ptr) \
   1231  1.7    dante 	AdvSendIdleCmd((sc), (u_int16_t) IDLE_CMD_ABORT, (ccb_ptr)->hashkey)
   1232  1.1    dante 
   1233  1.1    dante /*
   1234  1.1    dante  * Send a Bus Device Reset Message to the specified target ID.
   1235  1.1    dante  *
   1236  1.1    dante  * All outstanding commands will be purged if sending the
   1237  1.1    dante  * Bus Device Reset Message is successful.
   1238  1.1    dante  *
   1239  1.1    dante  * Return Value:
   1240  1.1    dante  *      ADW_TRUE(1) - All requests on the target are purged.
   1241  1.1    dante  *      ADW_FALSE(0) - Couldn't issue Bus Device Reset Message; Requests
   1242  1.1    dante  *                     are not purged.
   1243  1.1    dante  */
   1244  1.1    dante #define ADW_RESET_DEVICE(sc, target_id) \
   1245  1.6  thorpej 	AdvSendIdleCmd((sc), (u_int16_t) IDLE_CMD_DEVICE_RESET, (target_id), 0)
   1246  1.1    dante 
   1247  1.1    dante /*
   1248  1.1    dante  * SCSI Wide Type definition.
   1249  1.1    dante  */
   1250  1.7    dante #define ADW_SCSI_BIT_ID_TYPE   u_int16_t
   1251  1.1    dante 
   1252  1.1    dante /*
   1253  1.1    dante  * AdvInitScsiTarget() 'cntl_flag' options.
   1254  1.1    dante  */
   1255  1.1    dante #define ADW_SCAN_LUN           0x01
   1256  1.1    dante #define ADW_CAPINFO_NOLUN      0x02
   1257  1.1    dante 
   1258  1.1    dante /*
   1259  1.1    dante  * Convert target id to target id bit mask.
   1260  1.1    dante  */
   1261  1.1    dante #define ADW_TID_TO_TIDMASK(tid)   (0x01 << ((tid) & ADW_MAX_TID))
   1262  1.1    dante 
   1263  1.1    dante /*
   1264  1.1    dante  * ASC_SCSI_REQ_Q 'done_status' and 'host_status' return values.
   1265  1.1    dante  */
   1266  1.1    dante 
   1267  1.1    dante #define QD_NO_STATUS         0x00       /* Request not completed yet. */
   1268  1.1    dante #define QD_NO_ERROR          0x01
   1269  1.1    dante #define QD_ABORTED_BY_HOST   0x02
   1270  1.1    dante #define QD_WITH_ERROR        0x04
   1271  1.1    dante 
   1272  1.1    dante #define QHSTA_NO_ERROR              0x00
   1273  1.1    dante #define QHSTA_M_SEL_TIMEOUT         0x11
   1274  1.1    dante #define QHSTA_M_DATA_OVER_RUN       0x12
   1275  1.1    dante #define QHSTA_M_UNEXPECTED_BUS_FREE 0x13
   1276  1.1    dante #define QHSTA_M_QUEUE_ABORTED       0x15
   1277  1.1    dante #define QHSTA_M_SXFR_SDMA_ERR       0x16 /* SXFR_STATUS SCSI DMA Error */
   1278  1.1    dante #define QHSTA_M_SXFR_SXFR_PERR      0x17 /* SXFR_STATUS SCSI Bus Parity Error */
   1279  1.1    dante #define QHSTA_M_RDMA_PERR           0x18 /* RISC PCI DMA parity error */
   1280  1.1    dante #define QHSTA_M_SXFR_OFF_UFLW       0x19 /* SXFR_STATUS Offset Underflow */
   1281  1.1    dante #define QHSTA_M_SXFR_OFF_OFLW       0x20 /* SXFR_STATUS Offset Overflow */
   1282  1.1    dante #define QHSTA_M_SXFR_WD_TMO         0x21 /* SXFR_STATUS Watchdog Timeout */
   1283  1.1    dante #define QHSTA_M_SXFR_DESELECTED     0x22 /* SXFR_STATUS Deselected */
   1284  1.1    dante /* Note: QHSTA_M_SXFR_XFR_OFLW is identical to QHSTA_M_DATA_OVER_RUN. */
   1285  1.1    dante #define QHSTA_M_SXFR_XFR_OFLW       0x12 /* SXFR_STATUS Transfer Overflow */
   1286  1.1    dante #define QHSTA_M_SXFR_XFR_PH_ERR     0x24 /* SXFR_STATUS Transfer Phase Error */
   1287  1.1    dante #define QHSTA_M_SXFR_UNKNOWN_ERROR  0x25 /* SXFR_STATUS Unknown Error */
   1288  1.7    dante #define QHSTA_M_SCSI_BUS_RESET      0x30 /* Request aborted from SBR */
   1289  1.7    dante #define QHSTA_M_SCSI_BUS_RESET_UNSOL 0x31 /* Request aborted from unsol. SBR */
   1290  1.7    dante #define QHSTA_M_BUS_DEVICE_RESET    0x32 /* Request aborted from BDR */
   1291  1.7    dante #define QHSTA_M_DIRECTION_ERR       0x35 /* Data Phase mismatch */
   1292  1.7    dante #define QHSTA_M_DIRECTION_ERR_HUNG  0x36 /* Data Phase mismatch and bus hang */
   1293  1.1    dante #define QHSTA_M_WTM_TIMEOUT         0x41
   1294  1.1    dante #define QHSTA_M_BAD_CMPL_STATUS_IN  0x42
   1295  1.1    dante #define QHSTA_M_NO_AUTO_REQ_SENSE   0x43
   1296  1.1    dante #define QHSTA_M_AUTO_REQ_SENSE_FAIL 0x44
   1297  1.1    dante #define QHSTA_M_INVALID_DEVICE      0x45 /* Bad target ID */
   1298  1.7    dante #define QHSTA_M_FROZEN_TIDQ         0x46 /* TID Queue frozen. */
   1299  1.7    dante #define QHSTA_M_SGBACKUP_ERROR      0x47 /* Scatter-Gather backup error */
   1300  1.1    dante 
   1301  1.1    dante /*
   1302  1.1    dante  * SCSI Iquiry structure
   1303  1.1    dante  */
   1304  1.1    dante 
   1305  1.8    dante #define INQ_CLOCKING_ST_ONLY    0x0
   1306  1.8    dante #define INQ_CLOCKING_DT_ONLY    0x1
   1307  1.8    dante #define INQ_CLOCKING_ST_AND_DT  0x3
   1308  1.8    dante 
   1309  1.7    dante typedef struct {
   1310  1.7    dante 	u_int8_t	peri_dvc_type	: 5;	/* peripheral device type */
   1311  1.7    dante 	u_int8_t	peri_qualifier  : 3;	/* peripheral qualifier */
   1312  1.7    dante 	u_int8_t	dvc_type_modifier : 7;	/* device type modifier (for SCSI I) */
   1313  1.7    dante 	u_int8_t	rmb	 : 1;		/* RMB - removable medium bit */
   1314  1.7    dante 	u_int8_t	ansi_apr_ver : 3;	/* ANSI approved version */
   1315  1.7    dante 	u_int8_t	ecma_ver : 3;		/* ECMA version */
   1316  1.7    dante 	u_int8_t	iso_ver  : 2;		/* ISO version */
   1317  1.7    dante 	u_int8_t	rsp_data_fmt : 4;	/* response data format */
   1318  1.7    dante 						/* 0 SCSI 1 */
   1319  1.7    dante 						/* 1 CCS */
   1320  1.7    dante 						/* 2 SCSI-2 */
   1321  1.7    dante 						/* 3-F reserved */
   1322  1.7    dante 	u_int8_t	res1	 : 2;	     	/* reserved */
   1323  1.7    dante 	u_int8_t	TemIOP   : 1;	     	/* terminate I/O process bit (see 5.6.22) */
   1324  1.7    dante 	u_int8_t	aenc	 : 1;	     	/* asynch. event notification (processor) */
   1325  1.7    dante 	u_int8_t	add_len;		/* additional length */
   1326  1.7    dante 	u_int8_t	res2;			/* reserved */
   1327  1.7    dante 	u_int8_t	res3;			/* reserved */
   1328  1.7    dante 	u_int8_t	StfRe	: 1;	    	/* soft reset implemented */
   1329  1.7    dante 	u_int8_t	CmdQue  : 1;	    	/* command queuing */
   1330  1.7    dante 	u_int8_t	res4	: 1;	    	/* reserved */
   1331  1.7    dante 	u_int8_t	Linked  : 1;	    	/* linked command for this logical unit */
   1332  1.7    dante 	u_int8_t	Sync	: 1;	    	/* synchronous data transfer */
   1333  1.7    dante 	u_int8_t	WBus16  : 1;	    	/* wide bus 16 bit data transfer */
   1334  1.7    dante 	u_int8_t	WBus32  : 1;	    	/* wide bus 32 bit data transfer */
   1335  1.7    dante 	u_int8_t	RelAdr  : 1;	    	/* relative addressing mode */
   1336  1.7    dante 	u_int8_t	vendor_id[8];		/* vendor identification */
   1337  1.7    dante 	u_int8_t	product_id[16];		/* product identification */
   1338  1.7    dante 	u_int8_t	product_rev_level[4];	/* product revision level */
   1339  1.7    dante 	u_int8_t	vendor_specific[20];	/* vendor specific */
   1340  1.7    dante 	u_int8_t	IUS	 : 1;		/* information unit supported */
   1341  1.7    dante 	u_int8_t	QAS	 : 1;		/* quick arbitrate supported */
   1342  1.7    dante 	u_int8_t	Clocking : 2;		/* clocking field */
   1343  1.7    dante 	u_int8_t	res5	 : 4;		/* reserved */
   1344  1.7    dante 	u_int8_t	res6;			/* reserved */
   1345  1.7    dante } ADW_SCSI_INQUIRY; /* 58 bytes */
   1346  1.1    dante 
   1347  1.7    dante #define SS_GOOD              0x00
   1348  1.7    dante #define SS_CHK_CONDITION     0x02
   1349  1.7    dante #define SS_CONDITION_MET     0x04
   1350  1.7    dante #define SS_TARGET_BUSY       0x08
   1351  1.7    dante #define SS_INTERMID          0x10
   1352  1.7    dante #define SS_INTERMID_COND_MET 0x14
   1353  1.7    dante #define SS_RSERV_CONFLICT    0x18
   1354  1.7    dante #define SS_CMD_TERMINATED    0x22
   1355  1.7    dante #define SS_QUEUE_FULL        0x28
   1356  1.7    dante #define MS_CMD_DONE    0x00
   1357  1.7    dante #define MS_EXTEND      0x01
   1358  1.7    dante #define MS_SDTR_LEN    0x03
   1359  1.7    dante #define MS_SDTR_CODE   0x01
   1360  1.7    dante #define MS_WDTR_LEN    0x02
   1361  1.7    dante #define MS_WDTR_CODE   0x03
   1362  1.7    dante #define MS_MDP_LEN    0x05
   1363  1.7    dante #define MS_MDP_CODE   0x00
   1364  1.7    dante #define M1_SAVE_DATA_PTR        0x02
   1365  1.7    dante #define M1_RESTORE_PTRS         0x03
   1366  1.7    dante #define M1_DISCONNECT           0x04
   1367  1.7    dante #define M1_INIT_DETECTED_ERR    0x05
   1368  1.7    dante #define M1_ABORT                0x06
   1369  1.7    dante #define M1_MSG_REJECT           0x07
   1370  1.7    dante #define M1_NO_OP                0x08
   1371  1.7    dante #define M1_MSG_PARITY_ERR       0x09
   1372  1.7    dante #define M1_LINK_CMD_DONE        0x0A
   1373  1.7    dante #define M1_LINK_CMD_DONE_WFLAG  0x0B
   1374  1.7    dante #define M1_BUS_DVC_RESET        0x0C
   1375  1.7    dante #define M1_ABORT_TAG            0x0D
   1376  1.7    dante #define M1_CLR_QUEUE            0x0E
   1377  1.7    dante #define M1_INIT_RECOVERY        0x0F
   1378  1.7    dante #define M1_RELEASE_RECOVERY     0x10
   1379  1.7    dante #define M1_KILL_IO_PROC         0x11
   1380  1.7    dante #define M2_QTAG_MSG_SIMPLE      0x20
   1381  1.7    dante #define M2_QTAG_MSG_HEAD        0x21
   1382  1.7    dante #define M2_QTAG_MSG_ORDERED     0x22
   1383  1.7    dante #define M2_IGNORE_WIDE_RESIDUE  0x23
   1384  1.1    dante 
   1385  1.1    dante 
   1386  1.1    dante #define ASC_MAX_SENSE_LEN   32
   1387  1.1    dante #define ASC_MIN_SENSE_LEN   14
   1388  1.1    dante 
   1389  1.1    dante typedef struct asc_req_sense {
   1390  1.1    dante 	u_int8_t	err_code:7;
   1391  1.1    dante 	u_int8_t	info_valid:1;
   1392  1.1    dante 	u_int8_t	segment_no;
   1393  1.1    dante 	u_int8_t	sense_key:4;
   1394  1.1    dante 	u_int8_t	reserved_bit:1;
   1395  1.1    dante 	u_int8_t	sense_ILI:1;
   1396  1.1    dante 	u_int8_t	sense_EOM:1;
   1397  1.1    dante 	u_int8_t	file_mark:1;
   1398  1.1    dante 	u_int8_t	info1[4];
   1399  1.1    dante 	u_int8_t	add_sense_len;
   1400  1.1    dante 	u_int8_t	cmd_sp_info[4];
   1401  1.1    dante 	u_int8_t	asc;
   1402  1.1    dante 	u_int8_t	ascq;
   1403  1.1    dante 	u_int8_t	fruc;
   1404  1.1    dante 	u_int8_t	sks_byte0:7;
   1405  1.1    dante 	u_int8_t	sks_valid:1;
   1406  1.1    dante 	u_int8_t	sks_bytes[2];
   1407  1.1    dante 	u_int8_t	notused[2];
   1408  1.1    dante 	u_int8_t	ex_sense_code;
   1409  1.1    dante 	u_int8_t	info2[4];
   1410  1.1    dante } ASC_REQ_SENSE;
   1411  1.1    dante 
   1412  1.1    dante 
   1413  1.1    dante /*
   1414  1.1    dante  * Adv Library functions available to drivers.
   1415  1.1    dante  */
   1416  1.1    dante 
   1417  1.7    dante int	AdvInitAsc3550Driver __P((ADW_SOFTC *));
   1418  1.7    dante int	AdvInitAsc38C0800Driver __P((ADW_SOFTC *));
   1419  1.8    dante int	AdvInitAsc38C1600Driver __P((ADW_SOFTC *));
   1420  1.7    dante int	AdvInitFrom3550EEP __P((ADW_SOFTC *));
   1421  1.7    dante int	AdvInitFrom38C0800EEP __P((ADW_SOFTC *));
   1422  1.8    dante int	AdvInitFrom38C1600EEP __P((ADW_SOFTC *));
   1423  1.1    dante int	AdvExeScsiQueue __P((ADW_SOFTC *, ADW_SCSI_REQ_Q *));
   1424  1.1    dante int	AdvISR __P((ADW_SOFTC *));
   1425  1.1    dante void	AdvResetChip __P((bus_space_tag_t, bus_space_handle_t));
   1426  1.7    dante int	AdvSendIdleCmd __P((ADW_SOFTC *, u_int16_t, u_int32_t));
   1427  1.7    dante int	AdvResetSCSIBus __P((ADW_SOFTC *));
   1428  1.1    dante int	AdvResetCCB __P((ADW_SOFTC *));
   1429  1.1    dante 
   1430  1.1    dante #endif	/* _ADVANSYS_WIDE_LIBRARY_H_ */
   1431