FreeBSD/Linux Kernel Cross Reference
sys/dev/aha/ahareg.h
1 /*
2 * Generic register and struct definitions for the Adaptech 154x/164x
3 * SCSI host adapters. Product specific probe and attach routines can
4 * be found in:
5 * <fill in list here>
6 *
7 * Derived from bt.c written by:
8 *
9 * Copyright (c) 1998 Justin T. Gibbs.
10 * All rights reserved.
11 *
12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions
14 * are met:
15 * 1. Redistributions of source code must retain the above copyright
16 * notice, this list of conditions, and the following disclaimer,
17 * without modification, immediately at the beginning of the file.
18 * 2. The name of the author may not be used to endorse or promote products
19 * derived from this software without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
25 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 *
33 * $FreeBSD$
34 */
35
36 #ifndef _AHAREG_H_
37 #define _AHAREG_H_
38
39 #include "aha.h"
40
41 #include <sys/queue.h>
42 #include <cam/scsi/scsi_all.h>
43
44 #define AHA_MAXTRANSFER_SIZE 0xffffff /* limited by 24bit counter */
45 #define AHA_NSEG 17 /* The number of dma segments
46 * supported. */
47 #define ALL_TARGETS (~0)
48
49 /*
50 * Control Register pp. 1-8, 1-9 (Write Only)
51 */
52 #define CONTROL_REG 0x00
53 #define HARD_RESET 0x80 /* Hard Reset - return to POST state */
54 #define SOFT_RESET 0x40 /* Soft Reset - Clears Adapter state */
55 #define RESET_INTR 0x20 /* Reset/Ack Interrupt */
56 #define RESET_SBUS 0x10 /* Drive SCSI bus reset signal */
57
58 /*
59 * Status Register pp. 1-9, 1-10 (Read Only)
60 */
61 #define STATUS_REG 0x00
62 #define DIAG_ACTIVE 0x80 /* Performing Internal Diags */
63 #define DIAG_FAIL 0x40 /* Internal Diags failed */
64 #define INIT_REQUIRED 0x20 /* MBOXes need initialization */
65 #define HA_READY 0x10 /* HA ready for new commands */
66 #define CMD_REG_BUSY 0x08 /* HA busy with last cmd byte */
67 #define DATAIN_REG_READY 0x04 /* Data-in Byte available */
68 #define STATUS_REG_RSVD 0x02
69 #define CMD_INVALID 0x01 /* Invalid Command detected */
70
71 /*
72 * Command/Parameter Register pp. 1-10, 1-11 (Write Only)
73 */
74 #define COMMAND_REG 0x01
75
76 /*
77 * Data in Register p. 1-11 (Read Only)
78 */
79 #define DATAIN_REG 0x01
80
81 /*
82 * Interrupt Status Register pp. 1-12 -> 1-14 (Read Only)
83 */
84 #define INTSTAT_REG 0x02
85 #define INTR_PENDING 0x80 /* There is a pending INTR */
86 #define INTSTAT_REG_RSVD 0x70
87 #define SCSI_BUS_RESET 0x08 /* Bus Reset detected */
88 #define CMD_COMPLETE 0x04
89 #define OMB_READY 0x02 /* Outgoin Mailbox Ready */
90 #define IMB_LOADED 0x01 /* Incoming Mailbox loaded */
91
92 /*
93 * Definitions for the "undocumented" geometry register, we just need
94 * its location.
95 */
96 #define GEOMETRY_REG 0x03
97
98 #define AHA_NREGS (4)
99
100 /*
101 * Opcodes for Adapter commands.
102 */
103 typedef enum {
104 AOP_NOP = 0x00,
105 AOP_INITIALIZE_MBOX = 0x01,
106 AOP_START_MBOX = 0x02,
107 AOP_EXECUTE_BIOS_CMD = 0x03,
108 AOP_INQUIRE_BOARD_ID = 0x04,
109 AOP_ENABLE_OMBR_INT = 0x05,
110 AOP_SET_SEL_TIMOUT = 0x06,
111 AOP_SET_TIME_ON_BUS = 0x07,
112 AOP_SET_TIME_OFF_BUS = 0x08,
113 AOP_SET_BUS_TRANS_RATE = 0x09,
114 AOP_INQUIRE_INST_LDEVS = 0x0A,
115 AOP_INQUIRE_CONFIG = 0x0B,
116 AOP_ENABLE_TARGET_MODE = 0x0C,
117 AOP_INQUIRE_SETUP_INFO = 0x0D,
118 AOP_WRITE_LRAM = 0x1A,
119 AOP_READ_LRAM = 0x1B,
120 AOP_WRITE_CHIP_FIFO = 0x1C,
121 AOP_READ_CHIP_FIFO = 0x1D,
122 AOP_ECHO_DATA_BYTE = 0x1F,
123 AOP_ADAPTER_DIAGNOSTICS = 0x20,
124 AOP_SET_ADAPTER_OPTIONS = 0x21,
125 AOP_SET_EEPROM = 0x22,
126 AOP_RETURN_EEPROM = 0x23,
127 AOP_ENABLE_SHADOW_RAM = 0x24,
128 AOP_INIT_BIOS_MBOX = 0x25,
129 AOP_SET_BIOS_BANK_1 = 0x26,
130 AOP_SET_BIOS_BANK_2 = 0x27,
131 AOP_RETURN_EXT_BIOS_INFO= 0x28,
132 AOP_MBOX_IF_ENABLE = 0x29,
133 AOP_SCSI_TERM_STATUS = 0x2C,
134 AOP_INQUIRE_SCAM_DEV = 0x2D,
135 AOP_SCSI_DEV_TABLE = 0x2E,
136 AOP_SCAM_OP = 0x2F,
137 AOP_START_BIOS_CMD = 0x82,
138 AOP_INQUIRE_ESETUP_INFO = 0x8D
139 } aha_op_t;
140
141 /************** Definitions of Multi-byte commands and responses ************/
142
143 struct aha_extbios
144 {
145 u_int8_t flags; /* Bit 3 == 1 extended bios enabled */
146 u_int8_t mailboxlock; /* mail box lock code to unlock it */
147 };
148
149 typedef struct {
150 u_int8_t num_mboxes;
151 u_int8_t base_addr[3];
152 } init_24b_mbox_params_t;
153
154 typedef struct {
155 u_int8_t board_type;
156 /* These values are mostly from the aha-1540CP technical reference, but */
157 /* with other values from the old aha1542.c driver. The values from the */
158 /* aha-1540CP technical manual are used where conflicts arise */
159 #define BOARD_1540_16HEAD_BIOS 0x00
160 #define BOARD_1540_64HEAD_BIOS 0x30
161 #define BOARD_1542 0x41 /* aha-1540/1542 w/64-h bios */
162 #define BOARD_1640 0x42 /* aha-1640 */
163 #define BOARD_1740 0x43 /* aha-1740A/1742A/1744 */
164 #define BOARD_1542C 0x44 /* aha-1542C */
165 #define BOARD_1542CF 0x45 /* aha-1542CF */
166 #define BOARD_1542CP 0x46 /* aha-1542CP, plug and play */
167 u_int8_t cust_features;
168 #define FEATURES_STANDARD 0x30
169 u_int8_t firmware_rev_major;
170 u_int8_t firmware_rev_minor;
171 } board_id_data_t;
172
173 typedef struct {
174 u_int8_t dma_chan;
175 #define DMA_CHAN_5 0x20
176 #define DMA_CHAN_6 0x40
177 #define DMA_CHAN_7 0x80
178 u_int8_t irq;
179 #define IRQ_9 0x01
180 #define IRQ_10 0x02
181 #define IRQ_11 0x04
182 #define IRQ_12 0x08
183 #define IRQ_14 0x20
184 #define IRQ_15 0x40
185 u_int8_t scsi_id;
186 } config_data_t;
187
188 typedef struct {
189 u_int8_t enable;
190 } target_mode_params_t;
191
192 typedef struct {
193 u_int8_t offset : 4,
194 period : 3,
195 sync : 1;
196 } targ_syncinfo_t;
197
198 typedef struct {
199 u_int8_t initiate_sync : 1,
200 parity_enable : 1,
201 : 6;
202
203 u_int8_t bus_transfer_rate;
204 u_int8_t time_on_bus;
205 u_int8_t time_off_bus;
206 u_int8_t num_mboxes;
207 u_int8_t mbox_base_addr[3];
208 targ_syncinfo_t syncinfo[8];
209 u_int8_t discinfo;
210 u_int8_t customer_sig[20];
211 u_int8_t auto_retry;
212 u_int8_t board_switches;
213 u_int8_t firmware_cksum[2];
214 u_int8_t bios_mbox_addr[3];
215 } setup_data_t;
216
217 struct aha_isa_port {
218 u_int16_t addr;
219 u_int8_t probed;
220 u_int8_t bio; /* board IO offset */
221 };
222
223 #define AHA_NUM_ISAPORTS 6
224
225 typedef enum {
226 BIO_330 = 0,
227 BIO_334 = 1,
228 BIO_230 = 2,
229 BIO_234 = 3,
230 BIO_130 = 4,
231 BIO_134 = 5,
232 BIO_DISABLED = 6,
233 BIO_DISABLED2 = 7
234 } isa_compat_io_t;
235
236 typedef struct {
237 u_int8_t sync_rate[16]; /* Sync in 10ns units */
238 } target_sync_info_data_t;
239
240 typedef struct {
241 u_int8_t len[3];
242 u_int8_t addr[3];
243 } aha_sg_t;
244
245 /********************** Mail Box definitions *******************************/
246
247 typedef enum {
248 AMBO_FREE = 0x0, /* MBO intry is free */
249 AMBO_START = 0x1, /* MBO activate entry */
250 AMBO_ABORT = 0x2 /* MBO abort entry */
251 } aha_mbo_action_code_t;
252
253 typedef struct aha_mbox_out {
254 u_int8_t action_code;
255 u_int8_t ccb_addr[3];
256 } aha_mbox_out_t;
257
258 typedef enum {
259 AMBI_FREE = 0x0, /* MBI entry is free */
260 AMBI_OK = 0x1, /* completed without error */
261 AMBI_ABORT = 0x2, /* aborted ccb */
262 AMBI_NOT_FOUND = 0x3, /* Tried to abort invalid CCB */
263 AMBI_ERROR = 0x4 /* Completed with error */
264 } aha_mbi_comp_code_t;
265
266 typedef struct aha_mbox_in {
267 u_int8_t comp_code;
268 u_int8_t ccb_addr[3];
269 } aha_mbox_in_t;
270
271 /****************** Hardware CCB definition *********************************/
272 typedef enum {
273 INITIATOR_CCB = 0x00,
274 INITIATOR_SG_CCB = 0x02,
275 INITIATOR_CCB_WRESID = 0x03,
276 INITIATOR_SG_CCB_WRESID = 0x04,
277 INITIATOR_BUS_DEV_RESET = 0x81
278 } aha_ccb_opcode_t;
279
280 typedef enum {
281 AHASTAT_NOERROR = 0x00,
282 AHASTAT_SELTIMEOUT = 0x11,
283 AHASTAT_DATARUN_ERROR = 0x12,
284 AHASTAT_UNEXPECTED_BUSFREE = 0x13,
285 AHASTAT_INVALID_PHASE = 0x14,
286 AHASTAT_INVALID_ACTION_CODE = 0x15,
287 AHASTAT_INVALID_OPCODE = 0x16,
288 AHASTAT_LINKED_CCB_LUN_MISMATCH = 0x17,
289 AHASTAT_INVALID_CCB_OR_SG_PARAM = 0x1A,
290 AHASTAT_HA_SCSI_BUS_RESET = 0x22, /* stolen from bt */
291 AHASTAT_HA_BDR = 0x25 /* Stolen from bt */
292 } ahastat_t;
293
294 struct aha_hccb {
295 u_int8_t opcode; /* 0 */
296 u_int8_t lun : 3, /* 1 */
297 datain : 1,
298 dataout : 1,
299 target : 3;
300 u_int8_t cmd_len; /* 2 */
301 u_int8_t sense_len; /* 3 */
302 u_int8_t data_len[3]; /* 4 */
303 u_int8_t data_addr[3]; /* 7 */
304 u_int8_t link_ptr[3]; /* 10 */
305 u_int8_t link_id; /* 13 */
306 u_int8_t ahastat; /* 14 */
307 u_int8_t sdstat; /* 15 */
308 u_int8_t reserved1; /* 16 */
309 u_int8_t reserved2; /* 17 */
310 u_int8_t scsi_cdb[16]; /* 18 */
311 u_int8_t sense_data[SSD_FULL_SIZE];
312 };
313
314 typedef enum {
315 ACCB_FREE = 0x0,
316 ACCB_ACTIVE = 0x1,
317 ACCB_DEVICE_RESET = 0x2,
318 ACCB_RELEASE_SIMQ = 0x4
319 } accb_flags_t;
320
321 struct aha_ccb {
322 struct aha_hccb hccb; /* hccb assumed to be at 0 */
323 SLIST_ENTRY(aha_ccb) links;
324 u_int32_t flags;
325 union ccb *ccb;
326 bus_dmamap_t dmamap;
327 aha_sg_t *sg_list;
328 u_int32_t sg_list_phys;
329 };
330
331 struct sg_map_node {
332 bus_dmamap_t sg_dmamap;
333 bus_addr_t sg_physaddr;
334 aha_sg_t* sg_vaddr;
335 SLIST_ENTRY(sg_map_node) links;
336 };
337
338 struct aha_softc {
339 bus_space_tag_t tag;
340 bus_space_handle_t bsh;
341 struct cam_sim *sim;
342 struct cam_path *path;
343 aha_mbox_out_t *cur_outbox;
344 aha_mbox_in_t *cur_inbox;
345 aha_mbox_out_t *last_outbox;
346 aha_mbox_in_t *last_inbox;
347 struct aha_ccb *aha_ccb_array;
348 SLIST_HEAD(,aha_ccb) free_aha_ccbs;
349 LIST_HEAD(,ccb_hdr) pending_ccbs;
350 u_int active_ccbs;
351 u_int32_t aha_ccb_physbase;
352 aha_ccb_opcode_t ccb_sg_opcode;
353 aha_ccb_opcode_t ccb_ccb_opcode;
354 aha_mbox_in_t *in_boxes;
355 aha_mbox_out_t *out_boxes;
356 struct scsi_sense_data *sense_buffers;
357 u_int32_t sense_buffers_physbase;
358 struct aha_ccb *recovery_accb;
359 u_int num_boxes;
360 bus_dma_tag_t parent_dmat; /*
361 * All dmat's derive from
362 * the dmat defined by our
363 * bus.
364 */
365 bus_dma_tag_t buffer_dmat; /* dmat for buffer I/O */
366 bus_dma_tag_t mailbox_dmat; /* dmat for our mailboxes */
367 bus_dmamap_t mailbox_dmamap;
368 bus_dma_tag_t ccb_dmat; /* dmat for our ccb array */
369 bus_dmamap_t ccb_dmamap;
370 bus_dma_tag_t sg_dmat; /* dmat for our sg maps */
371 SLIST_HEAD(, sg_map_node) sg_maps;
372 bus_addr_t mailbox_physbase;
373 u_int num_ccbs; /* Number of CCBs malloc'd */
374 u_int max_ccbs; /* Maximum allocatable CCBs */
375 u_int max_sg;
376 u_int unit;
377 u_int scsi_id;
378 u_int32_t extended_trans :1,
379 diff_bus :1,
380 extended_lun :1,
381 strict_rr :1,
382 tag_capable :1,
383 resource_shortage:1,
384 :26;
385 u_int16_t disc_permitted;
386 u_int16_t sync_permitted;
387 u_int8_t init_level;
388 volatile u_int8_t command_cmp;
389 volatile u_int8_t latched_status;
390 u_int32_t bios_addr;
391 u_int8_t fw_major;
392 u_int8_t fw_minor;
393 char model[32];
394 u_int8_t boardid;
395 };
396
397 extern struct aha_softc *aha_softcs[]; /* XXX Config should handle this */
398 extern u_long aha_unit;
399
400 #define AHA_TEMP_UNIT 0xFF /* Unit for probes */
401 struct aha_softc* aha_alloc(int unit, bus_space_tag_t tag,
402 bus_space_handle_t bsh);
403 void aha_free(struct aha_softc *aha);
404 int aha_probe(struct aha_softc *aha);
405 int aha_fetch_adapter_info(struct aha_softc *aha);
406 int aha_init(struct aha_softc *aha);
407 int aha_attach(struct aha_softc *aha);
408 void aha_intr(void *arg);
409 char * aha_name(struct aha_softc *aha);
410 int aha_check_probed_iop(u_int ioport);
411 void aha_mark_probed_bio(isa_compat_io_t port);
412 void aha_mark_probed_iop(u_int ioport);
413 void aha_find_probe_range(int ioport,
414 int *port_index,
415 int *max_port_index);
416
417 int aha_iop_from_bio(isa_compat_io_t bio_index);
418
419 #define DEFAULT_CMD_TIMEOUT 10000 /* 1 sec */
420 int aha_cmd(struct aha_softc *aha, aha_op_t opcode,
421 u_int8_t *params, u_int param_len,
422 u_int8_t *reply_data, u_int reply_len,
423 u_int cmd_timeout);
424
425 #define aha_inb(aha, port) \
426 bus_space_read_1((aha)->tag, (aha)->bsh, port)
427
428 #define aha_outb(aha, port, value) \
429 bus_space_write_1((aha)->tag, (aha)->bsh, port, value)
430
431
432 #ifndef EXTRA_AHA
433 #if NPNP > 0
434 #define EXTRA_AHA MAX_PNP_CARDS
435 #else
436 #define EXTRA_AHA 0
437 #endif
438 #endif
439
440 #define NAHATOT (NAHA + EXTRA_AHA)
441
442 #define AHA1542_PNP 0x42159004 /* ADP1542 */
443 #define AHA1542_PNPCOMPAT 0xA000D040 /* PNP00A0 */
444
445 #endif /* _AHA_H_ */
Cache object: 74b6f550bb333f2f6049a4f8f735eb71
|