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