Home | History | Annotate | Line # | Download | only in ic
dptreg.h revision 1.8.2.1
      1  1.8.2.1  minoura /*	$NetBSD: dptreg.h,v 1.8.2.1 2000/06/22 17:06:40 minoura Exp $	*/
      2      1.1       ad 
      3      1.1       ad /*
      4  1.8.2.1  minoura  * Copyright (c) 1999 Andrew Doran <ad (at) NetBSD.org>
      5      1.1       ad  * All rights reserved.
      6      1.1       ad  *
      7      1.1       ad  * Redistribution and use in source and binary forms, with or without
      8      1.1       ad  * modification, are permitted provided that the following conditions
      9      1.1       ad  * are met:
     10      1.1       ad  * 1. Redistributions of source code must retain the above copyright
     11      1.1       ad  *    notice, this list of conditions and the following disclaimer.
     12      1.1       ad  * 2. Redistributions in binary form must reproduce the above copyright
     13      1.1       ad  *    notice, this list of conditions and the following disclaimer in the
     14      1.1       ad  *    documentation and/or other materials provided with the distribution.
     15      1.1       ad  *
     16      1.1       ad  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
     17      1.1       ad  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     18      1.1       ad  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     19      1.1       ad  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
     20      1.1       ad  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     21      1.1       ad  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     22      1.1       ad  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     23      1.1       ad  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     24      1.1       ad  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     25      1.1       ad  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     26      1.1       ad  * SUCH DAMAGE.
     27      1.1       ad  *
     28      1.1       ad  */
     29      1.1       ad 
     30      1.7       ad #ifndef	_IC_DPTREG_H_
     31      1.7       ad #define	_IC_DPTREG_H_	1
     32      1.1       ad 
     33      1.1       ad /* Hardware limits */
     34      1.1       ad #define DPT_MAX_TARGETS		16
     35      1.1       ad #define DPT_MAX_LUNS		8
     36      1.1       ad #define DPT_MAX_CHANNELS	3
     37      1.1       ad 
     38      1.1       ad /* Software parameters */
     39      1.1       ad #define	DPT_MAX_XFER		((DPT_SG_SIZE - 1) << PGSHIFT)
     40      1.1       ad #define DPT_MAX_CCBS		256
     41      1.1       ad #define DPT_SG_SIZE        	64
     42      1.4       ad #define DPT_ABORT_TIMEOUT	2000	/* milliseconds */
     43      1.4       ad #define DPT_MORE_TIMEOUT	1000	/* microseconds */
     44      1.7       ad #define DPT_SCRATCH_SIZE	256	/* bytes */
     45      1.1       ad 
     46      1.1       ad #ifdef _KERNEL
     47      1.1       ad 
     48      1.1       ad #define dpt_inb(x, o)	\
     49      1.1       ad     bus_space_read_1((x)->sc_iot, (x)->sc_ioh, (o))
     50      1.1       ad #define dpt_inw(x, o)	\
     51      1.8       ad     bus_space_read_2((x)->sc_iot, (x)->sc_ioh, (o))
     52      1.1       ad #define dpt_inl(x, o)	\
     53      1.8       ad     bus_space_read_4((x)->sc_iot, (x)->sc_ioh, (o))
     54      1.1       ad 
     55      1.1       ad #define dpt_outb(x, o, d) \
     56      1.1       ad     bus_space_write_1((x)->sc_iot, (x)->sc_ioh, (o), (d))
     57      1.1       ad #define dpt_outw(x, o, d) \
     58      1.8       ad     bus_space_write_2((x)->sc_iot, (x)->sc_ioh, (o), (d))
     59      1.1       ad #define dpt_outl(x, o, d) \
     60      1.8       ad     bus_space_write_4((x)->sc_iot, (x)->sc_ioh, (o), (d))
     61      1.1       ad 
     62      1.1       ad #endif	/* _KERNEL */
     63      1.1       ad 
     64      1.1       ad /*
     65      1.1       ad  * HBA registers
     66      1.1       ad  */
     67      1.6       ad #define HA_DATA			0
     68      1.6       ad #define HA_ERROR		1
     69      1.6       ad #define HA_DMA_BASE		2
     70      1.6       ad #define HA_ICMD_CODE2	       	4
     71      1.6       ad #define HA_ICMD_CODE1	       	5
     72      1.6       ad #define HA_ICMD			6
     73      1.1       ad 
     74      1.5       ad /* EATA commands. There are many more that we don't define or use. */
     75      1.6       ad #define HA_COMMAND		7
     76      1.1       ad #define   CP_PIO_GETCFG		0xf0	/* Read configuration data, PIO */
     77      1.1       ad #define   CP_PIO_CMD		0xf2	/* Execute command, PIO */
     78      1.1       ad #define   CP_DMA_GETCFG		0xfd	/* Read configuration data, DMA */
     79      1.1       ad #define   CP_DMA_CMD		0xff	/* Execute command, DMA */
     80      1.1       ad #define   CP_PIO_TRUNCATE	0xf4	/* Truncate transfer command, PIO */
     81      1.1       ad #define   CP_RESET		0xf9	/* Reset controller and SCSI bus */
     82      1.1       ad #define   CP_REBOOT		0x06	/* Reboot controller (last resort) */
     83      1.1       ad #define   CP_IMMEDIATE		0xfa	/* EATA immediate command */
     84      1.1       ad #define     CPI_GEN_ABORT	0x00	/* Generic abort */
     85      1.1       ad #define     CPI_SPEC_RESET	0x01	/* Specific reset */
     86      1.1       ad #define     CPI_BUS_RESET	0x02	/* Bus reset */
     87      1.1       ad #define     CPI_SPEC_ABORT	0x03	/* Specific abort */
     88      1.1       ad #define     CPI_QUIET_INTR	0x04	/* ?? */
     89      1.1       ad #define     CPI_ROM_DL_EN	0x05	/* ?? */
     90      1.1       ad #define     CPI_COLD_BOOT	0x06	/* Cold boot HBA */
     91      1.1       ad #define     CPI_FORCE_IO	0x07	/* ?? */
     92      1.1       ad #define     CPI_BUS_OFFLINE	0x08	/* Set SCSI bus offline */
     93      1.1       ad #define     CPI_RESET_MSKD_BUS	0x09	/* Reset masked bus */
     94      1.1       ad #define     CPI_POWEROFF_WARN	0x0a	/* Power about to fail */
     95      1.1       ad 
     96      1.6       ad #define HA_STATUS		7
     97      1.1       ad #define   HA_ST_ERROR		0x01
     98      1.3       ad #define   HA_ST_MORE		0x02
     99      1.1       ad #define   HA_ST_CORRECTD	0x04
    100      1.1       ad #define   HA_ST_DRQ		0x08
    101      1.1       ad #define   HA_ST_SEEK_COMPLETE	0x10
    102      1.1       ad #define   HA_ST_WRT_FLT		0x20
    103      1.1       ad #define   HA_ST_READY		0x40
    104      1.1       ad #define   HA_ST_BUSY		0x80
    105      1.1       ad #define   HA_ST_DATA_RDY	(HA_ST_SEEK_COMPLETE|HA_ST_READY|HA_ST_DRQ)
    106      1.1       ad 
    107      1.6       ad #define HA_AUX_STATUS		8
    108      1.1       ad #define   HA_AUX_BUSY		0x01
    109      1.1       ad #define   HA_AUX_INTR		0x02
    110      1.1       ad 
    111      1.1       ad /*
    112      1.1       ad  * Structure of an EATA command packet.
    113      1.1       ad  */
    114      1.1       ad struct eata_cp {
    115      1.7       ad 	u_int8_t	cp_ctl0;		/* Control flags 0 */
    116      1.7       ad 	u_int8_t	cp_senselen;		/* Request sense length */
    117      1.7       ad 	u_int8_t	cp_unused0[3];		/* Unused */
    118      1.7       ad 	u_int8_t	cp_ctl1;		/* Control flags 1 */
    119      1.7       ad 	u_int8_t	cp_ctl2;		/* Control flags 2 */
    120      1.7       ad 	u_int8_t	cp_ctl3;		/* Control flags 3 */
    121      1.7       ad 	u_int8_t	cp_ctl4;		/* Control flags 4 */
    122      1.7       ad 	u_int8_t	cp_msg[3];		/* Message bytes 0-3 */
    123      1.7       ad 	u_int8_t	cp_cdb_cmd;		/* SCSI CDB */
    124      1.7       ad 	u_int8_t	cp_cdb_more0[3];	/* SCSI CDB */
    125      1.7       ad 	u_int8_t	cp_cdb_len;		/* SCSI CDB */
    126      1.7       ad 	u_int8_t	cp_cdb_more1[7];	/* SCSI CDB */
    127      1.7       ad 	u_int32_t	cp_datalen;		/* Bytes of data/SG list */
    128      1.7       ad 	u_int32_t	cp_ccbid;		/* ID of software CCB */
    129      1.7       ad 	u_int32_t	cp_dataaddr;		/* Addr of data/SG list */
    130      1.7       ad 	u_int32_t	cp_stataddr;		/* Addr of status packet */
    131      1.7       ad 	u_int32_t	cp_senseaddr;		/* Addr of req. sense */
    132      1.1       ad };
    133      1.1       ad 
    134      1.7       ad #define CP_C0_SCSI_RESET	0x01	/* Cause a bus reset */
    135      1.7       ad #define CP_C0_HBA_INIT		0x02	/* Reinitialize HBA */
    136      1.7       ad #define CP_C0_AUTO_SENSE	0x04	/* Auto request sense on error */
    137      1.7       ad #define CP_C0_SCATTER		0x08	/* Do scatter/gather I/O */
    138      1.7       ad #define CP_C0_QUICK		0x10	/* Return no status packet */
    139      1.7       ad #define CP_C0_INTERPRET		0x20	/* HBA interprets SCSI CDB */
    140      1.7       ad #define CP_C0_DATA_OUT		0x40	/* Data out phase */
    141      1.7       ad #define CP_C0_DATA_IN		0x80	/* Data in phase */
    142      1.7       ad 
    143      1.7       ad #define CP_C1_TO_PHYS		0x01	/* Send to RAID component */
    144      1.7       ad #define CP_C1_RESERVED		0xfe
    145      1.7       ad 
    146      1.7       ad #define CP_C2_PHYS_UNIT		0x01	/* Physical unit on mirrored pair */
    147      1.7       ad #define CP_C2_NO_AT		0x02	/* No address translation */
    148      1.7       ad #define CP_C2_NO_CACHE		0x04	/* No HBA caching */
    149      1.7       ad #define CP_C2_RESERVED		0xf8
    150      1.7       ad 
    151      1.7       ad #define CP_C3_ID_MASK		0x1f	/* Target ID */
    152      1.7       ad #define CP_C3_ID_SHIFT		0
    153      1.7       ad #define CP_C3_CHANNEL_MASK	0xe0	/* Target channel */
    154      1.7       ad #define CP_C3_CHANNEL_SHIFT	5
    155      1.7       ad 
    156      1.7       ad #define CP_C4_LUN_MASK		0x07	/* Target LUN */
    157      1.7       ad #define CP_C4_LUN_SHIFT		0
    158      1.7       ad #define CP_C4_RESERVED		0x18
    159      1.7       ad #define CP_C4_LUN_TAR		0x20	/* CP is for target ROUTINE */
    160      1.7       ad #define CP_C4_DIS_PRI		0x40	/* Give disconnect privilege */
    161      1.7       ad #define CP_C4_IDENTIFY		0x80	/* Always true */
    162      1.7       ad 
    163      1.1       ad /*
    164      1.1       ad  * EATA status packet as returned by controller upon command completion. It
    165      1.1       ad  * contains status, message info and a handle on the initiating CCB.
    166      1.1       ad  */
    167      1.1       ad struct eata_sp {
    168      1.7       ad 	u_int8_t	sp_hba_status;		/* Host adapter status */
    169      1.1       ad 	u_int8_t	sp_scsi_status;		/* SCSI bus status */
    170      1.7       ad 	u_int8_t	sp_reserved[2];		/* Reserved */
    171      1.7       ad 	u_int32_t	sp_inv_residue;		/* Bytes not transfered */
    172      1.1       ad 	u_int32_t	sp_ccbid;		/* ID of software CCB */
    173      1.1       ad 	u_int8_t	sp_id_message;
    174      1.1       ad 	u_int8_t	sp_que_message;
    175      1.1       ad 	u_int8_t	sp_tag_message;
    176      1.1       ad 	u_int8_t	sp_messages[9];
    177      1.1       ad };
    178      1.1       ad 
    179      1.4       ad /*
    180      1.4       ad  * HBA status as returned by status packet. Bit 7 signals end of command.
    181      1.4       ad  */
    182      1.7       ad #define SP_HBA_NO_ERROR		0x00    /* No error on command */
    183      1.7       ad #define SP_HBA_ERROR_SEL_TO	0x01    /* Device selection timeout */
    184      1.7       ad #define SP_HBA_ERROR_CMD_TO	0x02    /* Device command timeout */
    185      1.7       ad #define SP_HBA_ERROR_RESET	0x03    /* SCSI bus was reset */
    186      1.7       ad #define SP_HBA_INIT_POWERUP	0x04    /* Initial controller power up */
    187      1.7       ad #define SP_HBA_UNX_BUSPHASE	0x05    /* Unexpected bus phase */
    188      1.7       ad #define SP_HBA_UNX_BUS_FREE	0x06    /* Unexpected bus free */
    189      1.7       ad #define SP_HBA_BUS_PARITY	0x07    /* SCSI bus parity error */
    190      1.7       ad #define SP_HBA_SCSI_HUNG	0x08    /* SCSI bus hung */
    191      1.7       ad #define SP_HBA_UNX_MSGRJCT	0x09    /* Unexpected message reject */
    192      1.7       ad #define SP_HBA_RESET_STUCK	0x0a    /* SCSI bus reset stuck */
    193      1.7       ad #define SP_HBA_RSENSE_FAIL	0x0b    /* Auto-request sense failed */
    194      1.7       ad #define SP_HBA_PARITY		0x0c    /* HBA memory parity error */
    195      1.7       ad #define SP_HBA_ABORT_NA		0x0d    /* CP aborted - not on bus */
    196      1.7       ad #define SP_HBA_ABORTED		0x0e    /* CP aborted - was on bus */
    197      1.7       ad #define SP_HBA_RESET_NA		0x0f    /* CP reset - not on bus */
    198      1.7       ad #define SP_HBA_RESET		0x10    /* CP reset - was on bus */
    199      1.7       ad #define SP_HBA_ECC		0x11    /* HBA memory ECC error */
    200      1.7       ad #define SP_HBA_PCI_PARITY	0x12    /* PCI parity error */
    201      1.7       ad #define SP_HBA_PCI_MASTER	0x13    /* PCI master abort */
    202      1.7       ad #define SP_HBA_PCI_TARGET	0x14    /* PCI target abort */
    203      1.7       ad #define SP_HBA_PCI_SIG_TARGET	0x15    /* PCI signalled target abort */
    204      1.7       ad #define SP_HBA_ABORT		0x20    /* Software abort (too many retries) */
    205      1.1       ad 
    206      1.1       ad /*
    207      1.1       ad  * Scatter-gather list element.
    208      1.1       ad  */
    209      1.1       ad struct eata_sg {
    210      1.1       ad 	u_int32_t	sg_addr;
    211      1.1       ad 	u_int32_t	sg_len;
    212      1.1       ad };
    213      1.1       ad 
    214      1.1       ad /*
    215      1.7       ad  * EATA configuration data as returned by HBA. XXX this is bogus - it
    216      1.7       ad  * doesn't sync up with the structure FreeBSD uses. [ad]
    217      1.1       ad  */
    218      1.1       ad struct eata_cfg {
    219      1.7       ad 	u_int8_t	ec_devtype;
    220      1.7       ad 	u_int8_t	ec_pagecode;
    221      1.7       ad 	u_int8_t	ec_reserved0;
    222      1.7       ad 	u_int8_t	ec_cfglen;		/* Length in bytes past here */
    223      1.7       ad 	u_int8_t	ec_eatasig[4];		/* EATA signature */
    224      1.7       ad 	u_int8_t	ec_eataversion;		/* EATA version number */
    225      1.7       ad 	u_int8_t	ec_feat0;		/* First feature byte */
    226      1.7       ad 	u_int8_t	ec_padlength[2];	/* Pad bytes for PIO cmds */
    227      1.7       ad 	u_int8_t	ec_hba[4];		/* Host adapter SCSI IDs */
    228      1.7       ad 	u_int8_t	ec_cplen[4];		/* Command packet length */
    229      1.7       ad 	u_int8_t	ec_splen[4];		/* Status packet length */
    230      1.7       ad 	u_int8_t	ec_queuedepth[2];	/* Controller queue depth */
    231      1.7       ad 	u_int8_t	ec_reserved1[2];
    232      1.7       ad 	u_int8_t	ec_sglen[2];		/* Maximum s/g list size */
    233      1.7       ad 	u_int8_t	ec_feat1;		/* 2nd feature byte */
    234      1.7       ad 	u_int8_t	ec_irq;			/* IRQ address */
    235      1.7       ad 	u_int8_t	ec_feat2;		/* 3rd feature byte */
    236      1.7       ad 	u_int8_t	ec_feat3;		/* 4th feature byte */
    237      1.7       ad 	u_int8_t	ec_maxlun;		/* Maximum LUN supported */
    238      1.7       ad 	u_int8_t	ec_feat4;		/* 5th feature byte */
    239      1.7       ad 	u_int8_t	ec_raidnum;		/* RAID host adapter humber */
    240      1.1       ad };
    241      1.1       ad 
    242      1.7       ad #define EC_F0_OVERLAP_CMDS	0x01	/* Overlapped cmds supported */
    243      1.7       ad #define EC_F0_TARGET_MODE	0x02	/* Target mode supported */
    244      1.7       ad #define EC_F0_TRUNC_NOT_REC	0x04	/* Truncate cmd not supported */
    245      1.7       ad #define EC_F0_MORE_SUPPORTED	0x08	/* More cmd supported */
    246      1.7       ad #define EC_F0_DMA_SUPPORTED	0x10	/* DMA mode supported */
    247      1.7       ad #define EC_F0_DMA_NUM_VALID	0x20	/* DMA channel field is valid */
    248      1.7       ad #define EC_F0_ATA_DEV		0x40	/* This is an ATA device */
    249      1.7       ad #define EC_F0_HBA_VALID		0x80	/* HBA field is valid */
    250      1.7       ad 
    251      1.7       ad #define EC_F1_IRQ_NUM_MASK	0x0f	/* IRQ number mask */
    252      1.7       ad #define EC_F1_IRQ_NUM_SHIFT	0
    253      1.7       ad #define EC_F1_IRQ_TRIGGER	0x10	/* IRQ trigger: 0 = edge, 1 = level */
    254      1.7       ad #define EC_F1_SECONDARY		0x20	/* Controller not at address 0x170 */
    255      1.7       ad #define EC_F1_DMA_NUM_MASK	0xc0 	/* DMA channel *index* for ISA */
    256      1.7       ad #define EC_F1_DMA_NUM_SHIFT	6
    257      1.7       ad 
    258      1.7       ad #define EC_F2_ISA_IO_DISABLE	0x01	/* ISA I/O address disabled */
    259      1.7       ad #define EC_F2_FORCE_ADDR	0x02	/* HBA forced to EISA/ISA address */
    260      1.7       ad #define EC_F2_SG_64K		0x04	/* 64kB of scatter/gather space */
    261      1.7       ad #define EC_F2_SG_UNALIGNED	0x08	/* Can do unaligned scatter/gather */
    262      1.7       ad #define EC_F2_RESERVED0		0x10	/* Reserved */
    263      1.7       ad #define EC_F2_RESERVED1		0x20	/* Reserved */
    264      1.7       ad #define EC_F2_RESERVED2		0x40	/* Reserved */
    265      1.7       ad #define EC_F2_RESERVED3		0x40	/* Reserved */
    266      1.7       ad 
    267      1.7       ad #define EC_F3_MAX_TARGET_MASK	0x1f	/* Maximum target ID supported */
    268      1.7       ad #define EC_F3_MAX_TARGET_SHIFT	0
    269      1.7       ad #define EC_F3_MAX_CHANNEL_MASK	0xe0	/* Maximum channel ID supported */
    270      1.7       ad #define EC_F3_MAX_CHANNEL_SHIFT	5
    271      1.7       ad 
    272      1.7       ad #define EC_F4_RESERVED0		0x01	/* Reserved */
    273      1.7       ad #define EC_F4_RESERVED1		0x02	/* Reserved */
    274      1.7       ad #define EC_F4_RESERVED2		0x04	/* Reserved */
    275      1.7       ad #define EC_F4_AUTO_TERM		0x08	/* Supports auto termination */
    276      1.7       ad #define EC_F4_PCIM1		0x10	/* PCI M1 chipset */
    277      1.7       ad #define EC_F4_BOGUS_RAID_ID	0x20	/* RAID ID may be questionable  */
    278      1.7       ad #define EC_F4_HBA_PCI		0x40	/* PCI adapter */
    279      1.7       ad #define EC_F4_HBA_EISA		0x80	/* EISA adapter */
    280      1.7       ad 
    281      1.1       ad /*
    282      1.1       ad  * How SCSI inquiry data breaks down for EATA boards.
    283      1.1       ad  */
    284      1.1       ad struct eata_inquiry_data {
    285      1.1       ad 	u_int8_t	ei_device;
    286      1.1       ad 	u_int8_t	ei_dev_qual2;
    287      1.1       ad 	u_int8_t	ei_version;
    288      1.1       ad 	u_int8_t 	ei_response_format;
    289      1.1       ad 	u_int8_t 	ei_additional_length;
    290      1.1       ad 	u_int8_t 	ei_unused[2];
    291      1.1       ad 	u_int8_t	ei_flags;
    292      1.7       ad 	char		ei_vendor[8];		/* Vendor, e.g: DPT, NEC */
    293      1.7       ad 	char		ei_model[7];		/* Model number */
    294      1.7       ad 	char		ei_suffix[9];		/* Model number suffix */
    295      1.7       ad 	char		ei_fw[3];		/* Firmware */
    296      1.7       ad 	char		ei_fwrev[1];		/* Firmware revision */
    297      1.1       ad 	u_int8_t	ei_extra[8];
    298      1.1       ad };
    299      1.1       ad 
    300      1.1       ad #endif	/* !defined _IC_DPTREG_H_ */
    301