Home | History | Annotate | Line # | Download | only in ic
ihavar.h revision 1.2.2.3
      1  1.2.2.3  nathanw /*	$NetBSD: ihavar.h,v 1.2.2.3 2001/08/24 00:09:26 nathanw Exp $ */
      2  1.2.2.2  nathanw /*
      3  1.2.2.2  nathanw  * Initio INI-9xxxU/UW SCSI Device Driver
      4  1.2.2.2  nathanw  *
      5  1.2.2.2  nathanw  * Copyright (c) 2000 Ken Westerback
      6  1.2.2.2  nathanw  * All rights reserved.
      7  1.2.2.2  nathanw  *
      8  1.2.2.2  nathanw  * Redistribution and use in source and binary forms, with or without
      9  1.2.2.2  nathanw  * modification, are permitted provided that the following conditions
     10  1.2.2.2  nathanw  * are met:
     11  1.2.2.2  nathanw  * 1. Redistributions of source code must retain the above copyright
     12  1.2.2.2  nathanw  *    notice, this list of conditions and the following disclaimer,
     13  1.2.2.2  nathanw  *    without modification, immediately at the beginning of the file.
     14  1.2.2.2  nathanw  * 2. The name of the author may not be used to endorse or promote products
     15  1.2.2.2  nathanw  *    derived from this software without specific prior written permission.
     16  1.2.2.2  nathanw  *
     17  1.2.2.2  nathanw  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     18  1.2.2.2  nathanw  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     19  1.2.2.2  nathanw  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     20  1.2.2.2  nathanw  * IN NO EVENT SHALL THE AUTHOR OR HIS RELATIVES BE LIABLE FOR ANY DIRECT,
     21  1.2.2.2  nathanw  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
     22  1.2.2.2  nathanw  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
     23  1.2.2.2  nathanw  * SERVICES; LOSS OF MIND, USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     24  1.2.2.2  nathanw  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
     25  1.2.2.2  nathanw  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
     26  1.2.2.2  nathanw  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
     27  1.2.2.2  nathanw  * THE POSSIBILITY OF SUCH DAMAGE.
     28  1.2.2.2  nathanw  *
     29  1.2.2.2  nathanw  *-------------------------------------------------------------------------
     30  1.2.2.2  nathanw  *
     31  1.2.2.2  nathanw  * Ported from i91uscsi.h, provided by Initio Corporation, which probably
     32  1.2.2.2  nathanw  * came from the same people who provided i91u.c:
     33  1.2.2.2  nathanw  *
     34  1.2.2.3  nathanw  * Device driver for the INI-9XXXU/UW or INIC-940/950 PCI SCSI Controller.
     35  1.2.2.2  nathanw  *
     36  1.2.2.2  nathanw  * FreeBSD
     37  1.2.2.2  nathanw  *
     38  1.2.2.2  nathanw  *  Written for 386bsd and FreeBSD by
     39  1.2.2.2  nathanw  *	Winston Hung		<winstonh (at) initio.com>
     40  1.2.2.2  nathanw  *
     41  1.2.2.2  nathanw  * Copyright (c) 1997-99 Initio Corp.  All rights reserved.
     42  1.2.2.2  nathanw  *
     43  1.2.2.2  nathanw  *-------------------------------------------------------------------------
     44  1.2.2.2  nathanw  */
     45  1.2.2.2  nathanw 
     46  1.2.2.2  nathanw /*
     47  1.2.2.2  nathanw  * Ported to NetBSD by Izumi Tsutsui <tsutsui (at) ceres.dti.ne.jp> from OpenBSD:
     48  1.2.2.2  nathanw  * $OpenBSD: iha.h,v 1.2 2001/02/08 17:35:05 krw Exp $
     49  1.2.2.2  nathanw  */
     50  1.2.2.2  nathanw 
     51  1.2.2.2  nathanw #define IHA_MAX_SG_ENTRIES	33
     52  1.2.2.2  nathanw #define IHA_MAX_TARGETS		16
     53  1.2.2.2  nathanw #define IHA_MAX_SCB		32
     54  1.2.2.2  nathanw #define IHA_MAX_EXTENDED_MSG	 4 /* SDTR(3) and WDTR(4) only */
     55  1.2.2.2  nathanw #define IHA_MAX_OFFSET		15
     56  1.2.2.2  nathanw 
     57  1.2.2.2  nathanw #define SCSI_CONDITION_MET    0x04 /* SCSI Status codes not defined */
     58  1.2.2.2  nathanw #define SCSI_INTERM_COND_MET  0x14 /*     in scsi_all.h             */
     59  1.2.2.2  nathanw 
     60  1.2.2.2  nathanw /*
     61  1.2.2.2  nathanw  *   Scatter-Gather Element Structure
     62  1.2.2.2  nathanw  */
     63  1.2.2.2  nathanw struct iha_sg_element {
     64  1.2.2.2  nathanw 	u_int32_t sg_addr;	/* Data Pointer */
     65  1.2.2.2  nathanw 	u_int32_t sg_len;	/* Data Length  */
     66  1.2.2.2  nathanw };
     67  1.2.2.2  nathanw 
     68  1.2.2.2  nathanw struct iha_sglist {
     69  1.2.2.2  nathanw 	struct iha_sg_element sg_element[IHA_MAX_SG_ENTRIES];
     70  1.2.2.2  nathanw };
     71  1.2.2.2  nathanw 
     72  1.2.2.2  nathanw #define IHA_SG_SIZE (sizeof(struct iha_sglist))
     73  1.2.2.2  nathanw 
     74  1.2.2.2  nathanw /*
     75  1.2.2.2  nathanw  * iha_scsi_req_q - SCSI Request structure used by the
     76  1.2.2.3  nathanw  *		    Tulip (aka inic-940/950).
     77  1.2.2.2  nathanw  */
     78  1.2.2.2  nathanw 
     79  1.2.2.2  nathanw struct iha_scsi_req_q {
     80  1.2.2.2  nathanw 	TAILQ_ENTRY(iha_scsi_req_q) chain;
     81  1.2.2.2  nathanw 
     82  1.2.2.2  nathanw 	bus_dmamap_t dmap;		/* maps xs->buf xfer buffer	*/
     83  1.2.2.2  nathanw 
     84  1.2.2.2  nathanw 	int status;			/* Current status of the SCB	*/
     85  1.2.2.2  nathanw #define  STATUS_QUEUED	0		/*  SCB one of Free/Done/Pend	*/
     86  1.2.2.2  nathanw #define  STATUS_RENT	1		/*  SCB allocated, not queued	*/
     87  1.2.2.2  nathanw #define  STATUS_SELECT	2		/*  SCB being selected		*/
     88  1.2.2.2  nathanw #define  STATUS_BUSY	3		/*  SCB I/O is active		*/
     89  1.2.2.2  nathanw 	int nextstat;			/* Next state function to apply	*/
     90  1.2.2.2  nathanw 	int sg_index;			/* Scatter/Gather Index		*/
     91  1.2.2.2  nathanw 	int sg_max;			/* Scatter/Gather # valid entries */
     92  1.2.2.2  nathanw 	int flags;			/* SCB Flags (xs->flags + private)*/
     93  1.2.2.2  nathanw #define  FLAG_RSENS	0x00010000	/*  Request Sense sent		*/
     94  1.2.2.2  nathanw #define  FLAG_SG	0x00020000	/*  Scatter/Gather used		*/
     95  1.2.2.2  nathanw 	int target;			/* Target Id			*/
     96  1.2.2.2  nathanw 	int lun;			/* Lun				*/
     97  1.2.2.2  nathanw 
     98  1.2.2.2  nathanw 	u_int32_t bufaddr;		/* Data Buffer Physical Addr	*/
     99  1.2.2.2  nathanw 	u_int32_t buflen;		/* Data Allocation Length	*/
    100  1.2.2.2  nathanw 	int ha_stat;			/* Status of Host Adapter	*/
    101  1.2.2.2  nathanw #define  HOST_OK	0x00		/*  OK - operation a success	*/
    102  1.2.2.2  nathanw #define  HOST_TIMED_OUT	0x01		/*  Request timed out		*/
    103  1.2.2.2  nathanw #define  HOST_SPERR	0x10		/*  SCSI parity error		*/
    104  1.2.2.2  nathanw #define  HOST_SEL_TOUT	0x11		/*  Selection Timeout		*/
    105  1.2.2.2  nathanw #define  HOST_DO_DU	0x12		/*  Data Over/Underrun		*/
    106  1.2.2.2  nathanw #define  HOST_BAD_PHAS	0x14		/*  Unexpected SCSI bus phase	*/
    107  1.2.2.2  nathanw #define  HOST_SCSI_RST	0x1B		/*  SCSI bus was reset		*/
    108  1.2.2.2  nathanw #define  HOST_DEV_RST	0x1C		/*  Device was reset		*/
    109  1.2.2.2  nathanw 	int ta_stat;			/* SCSI Status Byte		*/
    110  1.2.2.2  nathanw 	int timeout;			/* in milliseconds		*/
    111  1.2.2.2  nathanw 
    112  1.2.2.2  nathanw 	struct scsipi_xfer *xs;		/* xs this SCB is executing	*/
    113  1.2.2.2  nathanw 	struct tcs *tcs;		/* tcs for SCB_Target	   	*/
    114  1.2.2.2  nathanw 	struct iha_sg_element *sglist;
    115  1.2.2.2  nathanw 	bus_size_t sgoffset;		/* xfer buf offset              */
    116  1.2.2.2  nathanw 
    117  1.2.2.2  nathanw 	int sg_size;			/* # of valid entries in sg_list */
    118  1.2.2.2  nathanw 	u_int32_t sg_addr;		/* SGList Physical Address	*/
    119  1.2.2.2  nathanw 
    120  1.2.2.2  nathanw 	int cmdlen;			/* CDB Length			*/
    121  1.2.2.2  nathanw 	u_int8_t cmd[12];		/* SCSI Command			*/
    122  1.2.2.2  nathanw 
    123  1.2.2.2  nathanw 	u_int8_t scb_id;		/* Identity Message		*/
    124  1.2.2.2  nathanw 	u_int8_t scb_tagmsg;		/* Tag Message			*/
    125  1.2.2.2  nathanw 	u_int8_t scb_tagid;		/* Queue Tag			*/
    126  1.2.2.2  nathanw };
    127  1.2.2.2  nathanw 
    128  1.2.2.2  nathanw /*
    129  1.2.2.2  nathanw  *   Target Device Control Structure
    130  1.2.2.2  nathanw  */
    131  1.2.2.2  nathanw struct tcs {
    132  1.2.2.2  nathanw 	int flags;
    133  1.2.2.3  nathanw #define		      FLAG_SCSI_RATE	 0x0007 /* Index into iha_rate_tbl[] */
    134  1.2.2.2  nathanw #define		      FLAG_EN_DISC	 0x0008 /* Enable disconnect	     */
    135  1.2.2.2  nathanw #define		      FLAG_NO_SYNC	 0x0010 /* No sync data transfer     */
    136  1.2.2.2  nathanw #define		      FLAG_NO_WIDE	 0x0020 /* No wide data transfer     */
    137  1.2.2.2  nathanw #define		      FLAG_1GIGA	 0x0040 /* 255 hd/63 sec (64/32)     */
    138  1.2.2.2  nathanw #define		      FLAG_SPINUP	 0x0080 /* Start disk drive	     */
    139  1.2.2.2  nathanw #define		      FLAG_WIDE_DONE	 0x0100 /* WDTR msg has been sent    */
    140  1.2.2.2  nathanw #define		      FLAG_SYNC_DONE	 0x0200 /* SDTR msg has been sent    */
    141  1.2.2.2  nathanw #define		      FLAG_NO_NEG_SYNC   (FLAG_NO_SYNC | FLAG_SYNC_DONE)
    142  1.2.2.2  nathanw #define		      FLAG_NO_NEG_WIDE   (FLAG_NO_WIDE | FLAG_WIDE_DONE)
    143  1.2.2.2  nathanw 	int period;
    144  1.2.2.2  nathanw 	int offset;
    145  1.2.2.2  nathanw 	int tagcnt;
    146  1.2.2.2  nathanw 
    147  1.2.2.2  nathanw 	struct iha_scsi_req_q *ntagscb;
    148  1.2.2.2  nathanw 
    149  1.2.2.2  nathanw 	u_int8_t  syncm;
    150  1.2.2.2  nathanw 	u_int8_t  sconfig0;
    151  1.2.2.2  nathanw };
    152  1.2.2.2  nathanw 
    153  1.2.2.2  nathanw struct iha_softc {
    154  1.2.2.2  nathanw 	struct device sc_dev;
    155  1.2.2.2  nathanw 
    156  1.2.2.2  nathanw 	bus_space_tag_t sc_iot;
    157  1.2.2.2  nathanw 	bus_space_handle_t sc_ioh;
    158  1.2.2.2  nathanw 
    159  1.2.2.2  nathanw 	bus_dma_tag_t sc_dmat;
    160  1.2.2.2  nathanw 	bus_dmamap_t sc_dmamap;
    161  1.2.2.2  nathanw 
    162  1.2.2.2  nathanw 	struct scsipi_adapter sc_adapter;
    163  1.2.2.2  nathanw 	struct scsipi_channel sc_channel;
    164  1.2.2.2  nathanw 
    165  1.2.2.2  nathanw 	int sc_id;
    166  1.2.2.2  nathanw 	void *sc_ih;
    167  1.2.2.2  nathanw 
    168  1.2.2.2  nathanw 	/*
    169  1.2.2.2  nathanw 	 *   Initio specific fields
    170  1.2.2.2  nathanw 	 */
    171  1.2.2.2  nathanw 	int sc_flags;
    172  1.2.2.2  nathanw #define		      FLAG_EXPECT_DISC	     0x01
    173  1.2.2.2  nathanw #define		      FLAG_EXPECT_SELECT     0x02
    174  1.2.2.2  nathanw #define		      FLAG_EXPECT_RESET	     0x10
    175  1.2.2.2  nathanw #define		      FLAG_EXPECT_DONE_DISC  0x20
    176  1.2.2.2  nathanw 	int sc_semaph;
    177  1.2.2.2  nathanw #define		      SEMAPH_IN_MAIN	     0x00   /* Already in tulip_main */
    178  1.2.2.2  nathanw 	int sc_phase;			  	    /* MSG  C/D	 I/O	     */
    179  1.2.2.2  nathanw #define		      PHASE_DATA_OUT	     0x00   /*	0    0	  0	     */
    180  1.2.2.2  nathanw #define		      PHASE_DATA_IN	     0x01   /*	0    0	  1	     */
    181  1.2.2.2  nathanw #define		      PHASE_CMD_OUT	     0x02   /*	0    1	  0	     */
    182  1.2.2.2  nathanw #define		      PHASE_STATUS_IN	     0x03   /*	0    1	  1	     */
    183  1.2.2.2  nathanw #define		      PHASE_MSG_OUT	     0x06   /*	1    1	  0	     */
    184  1.2.2.2  nathanw #define		      PHASE_MSG_IN	     0x07   /*	1    1	  1	     */
    185  1.2.2.2  nathanw 
    186  1.2.2.2  nathanw 	struct iha_scsi_req_q *sc_scb;		    /* SCB array	     */
    187  1.2.2.2  nathanw 	struct iha_scsi_req_q *sc_actscb;	    /* SCB using SCSI bus    */
    188  1.2.2.2  nathanw 	struct iha_sglist *sc_sglist;
    189  1.2.2.2  nathanw 
    190  1.2.2.2  nathanw 	TAILQ_HEAD(, iha_scsi_req_q) sc_freescb,
    191  1.2.2.2  nathanw 				     sc_pendscb,
    192  1.2.2.2  nathanw 				     sc_donescb;
    193  1.2.2.2  nathanw 
    194  1.2.2.2  nathanw 	struct tcs sc_tcs[IHA_MAX_TARGETS];
    195  1.2.2.2  nathanw 
    196  1.2.2.2  nathanw 	u_int8_t  sc_msg[IHA_MAX_EXTENDED_MSG];    /* [0] len, [1] Msg Code */
    197  1.2.2.2  nathanw 	u_int8_t  sc_sistat;
    198  1.2.2.2  nathanw 	u_int8_t  sc_status0;
    199  1.2.2.2  nathanw 	u_int8_t  sc_status1;
    200  1.2.2.2  nathanw 	u_int8_t  sc_sconf1;
    201  1.2.2.2  nathanw };
    202  1.2.2.2  nathanw 
    203  1.2.2.2  nathanw /*
    204  1.2.2.2  nathanw  *   EEPROM for one SCSI Channel
    205  1.2.2.2  nathanw  */
    206  1.2.2.2  nathanw 
    207  1.2.2.2  nathanw #define EEPROM_SIZE	32
    208  1.2.2.2  nathanw #define EEP_LBYTE(x)	((x) & 0xff)
    209  1.2.2.2  nathanw #define EEP_HBYTE(x)	((x) >> 8)
    210  1.2.2.2  nathanw #define EEP_WORD(l, h)	(((h) & 0xff) << 8 | ((l) && 0xff))
    211  1.2.2.2  nathanw #define EEP_WAIT()	DELAY(5)
    212  1.2.2.2  nathanw 
    213  1.2.2.2  nathanw struct eeprom_adapter {
    214  1.2.2.2  nathanw 	u_int16_t config1;		/* 0x00 Channel Adapter SCSI Id  */
    215  1.2.2.2  nathanw #define  CFG_ID_MASK	0x000f
    216  1.2.2.2  nathanw #define  CFG_ID(cfg)	((cfg) & CFG_ID_MASK)
    217  1.2.2.2  nathanw #define  CFG_SCSI_RESET	0x0100		/*     Reset bus at power up     */
    218  1.2.2.2  nathanw #define  CFG_EN_PAR	0x0200		/*     SCSI parity enable        */
    219  1.2.2.2  nathanw #define  CFG_ACT_TERM1	0x0400		/*     Enable active term 1      */
    220  1.2.2.2  nathanw #define  CFG_ACT_TERM2	0x0800		/*     Enable active term 2      */
    221  1.2.2.2  nathanw #define  CFG_AUTO_TERM	0x1000		/*     Enable auto terminator    */
    222  1.2.2.2  nathanw #define  CFG_EN_PWR	0x8000		/*     Enable power mgmt         */
    223  1.2.2.2  nathanw #define  CFG_DEFAULT	(CFG_SCSI_RESET | CFG_AUTO_TERM | CFG_EN_PAR)
    224  1.2.2.2  nathanw 	u_int16_t config2;
    225  1.2.2.2  nathanw #define  CFG_CFG2(x)	EEP_LBYTE(x)	/* 0x02 Unused Channel Cfg byte 2*/
    226  1.2.2.2  nathanw #define  CFG_TARGET(x)	EEP_HBYTE(x)	/* 0x03 Number of SCSI targets   */
    227  1.2.2.2  nathanw 					/* 0x04 Lower bytes of targ flags*/
    228  1.2.2.2  nathanw 	u_int16_t tflags[IHA_MAX_TARGETS / sizeof(u_int16_t)];
    229  1.2.2.2  nathanw #define  FLAG_DEFAULT	(FLAG_NO_WIDE | FLAG_1GIGA | FLAG_EN_DISC)
    230  1.2.2.2  nathanw };
    231  1.2.2.2  nathanw 
    232  1.2.2.2  nathanw /*
    233  1.2.2.3  nathanw  * Tulip (aka ini-940/950) Serial EEPROM Layout
    234  1.2.2.2  nathanw  */
    235  1.2.2.2  nathanw struct iha_eeprom {
    236  1.2.2.2  nathanw 	/* ---------- Header ------------------------------------------------*/
    237  1.2.2.2  nathanw 	u_int16_t signature;		       /* 0x00 NVRAM Signature	     */
    238  1.2.2.2  nathanw #define EEP_SIGNATURE	0xC925
    239  1.2.2.2  nathanw 	u_int16_t revision;
    240  1.2.2.2  nathanw #define EEP_SIZE(x)	EEP_LBYTE(x)	       /* 0x02 Size of data structure*/
    241  1.2.2.2  nathanw #define EEP_REV(x)	EEP_HBYTE(x)	       /* 0x03 Rev. of data structure*/
    242  1.2.2.2  nathanw 	/* ---------- Host Adapter Structure --------------------------------*/
    243  1.2.2.2  nathanw 	u_int16_t model;		       /* 0x04 Model number          */
    244  1.2.2.2  nathanw 	u_int16_t modelinfo;
    245  1.2.2.2  nathanw #define EEP_INFO(x)	EEP_LBYTE(x)	       /* 0x06 Model information     */
    246  1.2.2.2  nathanw #define EEP_CHAN(x)	EEP_HBYTE(x)	       /* 0x07 Number of SCSI channel*/
    247  1.2.2.2  nathanw 	u_int16_t bioscfg;		       /* 0x08 BIOS configuration 1  */
    248  1.2.2.2  nathanw #define EEP_BIOSCFG_ENABLE	0x0001	       /*      BIOS enable	     */
    249  1.2.2.2  nathanw #define EEP_BIOSCFG_8DRIVE	0x0002	       /*      Support > 2 drives    */
    250  1.2.2.2  nathanw #define EEP_BIOSCFG_REMOVABLE	0x0004	       /*      Support removable drv */
    251  1.2.2.2  nathanw #define EEP_BIOSCFG_INT19	0x0008	       /*      Intercept int 19h     */
    252  1.2.2.2  nathanw #define EEP_BIOSCFG_BIOSSCAN	0x0010	       /*      Dynamic BIOS scan     */
    253  1.2.2.2  nathanw #define EEP_BIOSCFG_LUNSUPPORT	0x0040	       /*      Support LUN	     */
    254  1.2.2.2  nathanw #define EEP_BIOSCFG_DEFAULT	EEP_BIOSCFG_ENABLE
    255  1.2.2.2  nathanw 	u_int16_t hacfg;		       /* 0x0a Host adapter config 1 */
    256  1.2.2.2  nathanw #define EEP_HACFG_BOOTIDMASK	0x000F	       /*      Boot ID number	     */
    257  1.2.2.2  nathanw #define EEP_HACFG_LUNMASK	0x0070	       /*      Boot LUN number	     */
    258  1.2.2.2  nathanw #define EEP_HACFG_CHANMASK	0x0080	       /*      Boot Channel number   */
    259  1.2.2.2  nathanw 	struct eeprom_adapter adapter[2];      /* 0x0c		             */
    260  1.2.2.2  nathanw 	u_int16_t reserved[5];		       /* 0x34			     */
    261  1.2.2.2  nathanw 
    262  1.2.2.2  nathanw 	/* --------- CheckSum -----------------------------------------------*/
    263  1.2.2.2  nathanw 	u_int16_t checksum;		       /* 0x3E Checksum of NVRam     */
    264  1.2.2.2  nathanw };
    265  1.2.2.2  nathanw 
    266  1.2.2.2  nathanw /* Functions used by higher SCSI layers, the kernel, or iha.c and iha_pci.c  */
    267  1.2.2.2  nathanw 
    268  1.2.2.2  nathanw int iha_intr(void *);
    269  1.2.2.2  nathanw void iha_attach(struct iha_softc *);
    270