158751759SThomas Gleixner /* SPDX-License-Identifier: GPL-2.0-only */
21da177e4SLinus Torvalds /*
31da177e4SLinus Torvalds
41da177e4SLinus Torvalds Linux Driver for BusLogic MultiMaster and FlashPoint SCSI Host Adapters
51da177e4SLinus Torvalds
61da177e4SLinus Torvalds Copyright 1995-1998 by Leonard N. Zubkoff <lnz@dandelion.com>
71da177e4SLinus Torvalds
81da177e4SLinus Torvalds
91da177e4SLinus Torvalds The author respectfully requests that any modifications to this software be
101da177e4SLinus Torvalds sent directly to him for evaluation and testing.
111da177e4SLinus Torvalds
121da177e4SLinus Torvalds Special thanks to Wayne Yen, Jin-Lon Hon, and Alex Win of BusLogic, whose
131da177e4SLinus Torvalds advice has been invaluable, to David Gentzel, for writing the original Linux
141da177e4SLinus Torvalds BusLogic driver, and to Paul Gortmaker, for being such a dedicated test site.
151da177e4SLinus Torvalds
161da177e4SLinus Torvalds Finally, special thanks to Mylex/BusLogic for making the FlashPoint SCCB
171da177e4SLinus Torvalds Manager available as freely redistributable source code.
181da177e4SLinus Torvalds
191da177e4SLinus Torvalds */
201da177e4SLinus Torvalds
211da177e4SLinus Torvalds #ifndef _BUSLOGIC_H
221da177e4SLinus Torvalds #define _BUSLOGIC_H
231da177e4SLinus Torvalds
241da177e4SLinus Torvalds
251da177e4SLinus Torvalds #ifndef PACKED
261da177e4SLinus Torvalds #define PACKED __attribute__((packed))
271da177e4SLinus Torvalds #endif
281da177e4SLinus Torvalds
291da177e4SLinus Torvalds /*
301da177e4SLinus Torvalds Define the maximum number of BusLogic Host Adapters supported by this driver.
311da177e4SLinus Torvalds */
321da177e4SLinus Torvalds
33839cb99eSKhalid Aziz #define BLOGIC_MAX_ADAPTERS 16
341da177e4SLinus Torvalds
351da177e4SLinus Torvalds
361da177e4SLinus Torvalds /*
371da177e4SLinus Torvalds Define the maximum number of Target Devices supported by this driver.
381da177e4SLinus Torvalds */
391da177e4SLinus Torvalds
40839cb99eSKhalid Aziz #define BLOGIC_MAXDEV 16
411da177e4SLinus Torvalds
421da177e4SLinus Torvalds
431da177e4SLinus Torvalds /*
441da177e4SLinus Torvalds Define the maximum number of Scatter/Gather Segments used by this driver.
451da177e4SLinus Torvalds For optimal performance, it is important that this limit be at least as
461da177e4SLinus Torvalds large as the largest single request generated by the I/O Subsystem.
471da177e4SLinus Torvalds */
481da177e4SLinus Torvalds
49839cb99eSKhalid Aziz #define BLOGIC_SG_LIMIT 128
501da177e4SLinus Torvalds
511da177e4SLinus Torvalds
521da177e4SLinus Torvalds /*
531da177e4SLinus Torvalds Define the maximum, maximum automatic, minimum automatic, and default Queue
541da177e4SLinus Torvalds Depth to allow for Target Devices depending on whether or not they support
551da177e4SLinus Torvalds Tagged Queuing and whether or not ISA Bounce Buffers are required.
561da177e4SLinus Torvalds */
571da177e4SLinus Torvalds
58839cb99eSKhalid Aziz #define BLOGIC_MAX_TAG_DEPTH 64
59839cb99eSKhalid Aziz #define BLOGIC_MAX_AUTO_TAG_DEPTH 28
60839cb99eSKhalid Aziz #define BLOGIC_MIN_AUTO_TAG_DEPTH 7
61839cb99eSKhalid Aziz #define BLOGIC_TAG_DEPTH_BB 3
62839cb99eSKhalid Aziz #define BLOGIC_UNTAG_DEPTH 3
63839cb99eSKhalid Aziz #define BLOGIC_UNTAG_DEPTH_BB 2
641da177e4SLinus Torvalds
651da177e4SLinus Torvalds
661da177e4SLinus Torvalds /*
671da177e4SLinus Torvalds Define the default amount of time in seconds to wait between a Host Adapter
681da177e4SLinus Torvalds Hard Reset which initiates a SCSI Bus Reset and issuing any SCSI commands.
691da177e4SLinus Torvalds Some SCSI devices get confused if they receive SCSI commands too soon after
701da177e4SLinus Torvalds a SCSI Bus Reset.
711da177e4SLinus Torvalds */
721da177e4SLinus Torvalds
73839cb99eSKhalid Aziz #define BLOGIC_BUS_SETTLE_TIME 2
741da177e4SLinus Torvalds
751da177e4SLinus Torvalds
761da177e4SLinus Torvalds /*
771da177e4SLinus Torvalds Define the maximum number of Mailboxes that should be used for MultiMaster
781da177e4SLinus Torvalds Host Adapters. This number is chosen to be larger than the maximum Host
791da177e4SLinus Torvalds Adapter Queue Depth and small enough so that the Host Adapter structure
801da177e4SLinus Torvalds does not cross an allocation block size boundary.
811da177e4SLinus Torvalds */
821da177e4SLinus Torvalds
83839cb99eSKhalid Aziz #define BLOGIC_MAX_MAILBOX 211
841da177e4SLinus Torvalds
851da177e4SLinus Torvalds
861da177e4SLinus Torvalds /*
871da177e4SLinus Torvalds Define the number of CCBs that should be allocated as a group to optimize
881da177e4SLinus Torvalds Kernel memory allocation.
891da177e4SLinus Torvalds */
901da177e4SLinus Torvalds
91839cb99eSKhalid Aziz #define BLOGIC_CCB_GRP_ALLOCSIZE 7
921da177e4SLinus Torvalds
931da177e4SLinus Torvalds
941da177e4SLinus Torvalds /*
951da177e4SLinus Torvalds Define the Host Adapter Line and Message Buffer Sizes.
961da177e4SLinus Torvalds */
971da177e4SLinus Torvalds
98839cb99eSKhalid Aziz #define BLOGIC_LINEBUF_SIZE 100
99839cb99eSKhalid Aziz #define BLOGIC_MSGBUF_SIZE 9700
1001da177e4SLinus Torvalds
1011da177e4SLinus Torvalds
1021da177e4SLinus Torvalds /*
1031da177e4SLinus Torvalds Define the Driver Message Levels.
1041da177e4SLinus Torvalds */
1051da177e4SLinus Torvalds
106839cb99eSKhalid Aziz enum blogic_msglevel {
107839cb99eSKhalid Aziz BLOGIC_ANNOUNCE_LEVEL = 0,
108839cb99eSKhalid Aziz BLOGIC_INFO_LEVEL = 1,
109839cb99eSKhalid Aziz BLOGIC_NOTICE_LEVEL = 2,
110839cb99eSKhalid Aziz BLOGIC_WARN_LEVEL = 3,
111839cb99eSKhalid Aziz BLOGIC_ERR_LEVEL = 4
1121da177e4SLinus Torvalds };
1131da177e4SLinus Torvalds
114839cb99eSKhalid Aziz static char *blogic_msglevelmap[] = { KERN_NOTICE, KERN_NOTICE, KERN_NOTICE, KERN_WARNING, KERN_ERR };
1151da177e4SLinus Torvalds
1161da177e4SLinus Torvalds
1171da177e4SLinus Torvalds /*
1181da177e4SLinus Torvalds Define Driver Message macros.
1191da177e4SLinus Torvalds */
1201da177e4SLinus Torvalds
121839cb99eSKhalid Aziz #define blogic_announce(format, args...) \
122839cb99eSKhalid Aziz blogic_msg(BLOGIC_ANNOUNCE_LEVEL, format, ##args)
1231da177e4SLinus Torvalds
124839cb99eSKhalid Aziz #define blogic_info(format, args...) \
125839cb99eSKhalid Aziz blogic_msg(BLOGIC_INFO_LEVEL, format, ##args)
1261da177e4SLinus Torvalds
127839cb99eSKhalid Aziz #define blogic_notice(format, args...) \
128839cb99eSKhalid Aziz blogic_msg(BLOGIC_NOTICE_LEVEL, format, ##args)
1291da177e4SLinus Torvalds
130839cb99eSKhalid Aziz #define blogic_warn(format, args...) \
131839cb99eSKhalid Aziz blogic_msg(BLOGIC_WARN_LEVEL, format, ##args)
1321da177e4SLinus Torvalds
133839cb99eSKhalid Aziz #define blogic_err(format, args...) \
134839cb99eSKhalid Aziz blogic_msg(BLOGIC_ERR_LEVEL, format, ##args)
1351da177e4SLinus Torvalds
1361da177e4SLinus Torvalds
1371da177e4SLinus Torvalds /*
1381da177e4SLinus Torvalds Define the types of BusLogic Host Adapters that are supported and the number
1391da177e4SLinus Torvalds of I/O Addresses required by each type.
1401da177e4SLinus Torvalds */
1411da177e4SLinus Torvalds
142839cb99eSKhalid Aziz enum blogic_adapter_type {
143839cb99eSKhalid Aziz BLOGIC_MULTIMASTER = 1,
144839cb99eSKhalid Aziz BLOGIC_FLASHPOINT = 2
1451da177e4SLinus Torvalds } PACKED;
1461da177e4SLinus Torvalds
147839cb99eSKhalid Aziz #define BLOGIC_MULTIMASTER_ADDR_COUNT 4
148839cb99eSKhalid Aziz #define BLOGIC_FLASHPOINT_ADDR_COUNT 256
1491da177e4SLinus Torvalds
150839cb99eSKhalid Aziz static int blogic_adapter_addr_count[3] = { 0, BLOGIC_MULTIMASTER_ADDR_COUNT, BLOGIC_FLASHPOINT_ADDR_COUNT };
1511da177e4SLinus Torvalds
1521da177e4SLinus Torvalds
1531da177e4SLinus Torvalds /*
1541da177e4SLinus Torvalds Define macros for testing the Host Adapter Type.
1551da177e4SLinus Torvalds */
1561da177e4SLinus Torvalds
15778b4b05dSMatthew Wilcox #ifdef CONFIG_SCSI_FLASHPOINT
1581da177e4SLinus Torvalds
159839cb99eSKhalid Aziz #define blogic_multimaster_type(adapter) \
160839cb99eSKhalid Aziz (adapter->adapter_type == BLOGIC_MULTIMASTER)
1611da177e4SLinus Torvalds
162839cb99eSKhalid Aziz #define blogic_flashpoint_type(adapter) \
163839cb99eSKhalid Aziz (adapter->adapter_type == BLOGIC_FLASHPOINT)
1641da177e4SLinus Torvalds
1651da177e4SLinus Torvalds #else
1661da177e4SLinus Torvalds
167839cb99eSKhalid Aziz #define blogic_multimaster_type(adapter) (true)
168839cb99eSKhalid Aziz #define blogic_flashpoint_type(adapter) (false)
1691da177e4SLinus Torvalds
1701da177e4SLinus Torvalds #endif
1711da177e4SLinus Torvalds
1721da177e4SLinus Torvalds
1731da177e4SLinus Torvalds /*
1741da177e4SLinus Torvalds Define the possible Host Adapter Bus Types.
1751da177e4SLinus Torvalds */
1761da177e4SLinus Torvalds
177839cb99eSKhalid Aziz enum blogic_adapter_bus_type {
178839cb99eSKhalid Aziz BLOGIC_UNKNOWN_BUS = 0,
179839cb99eSKhalid Aziz BLOGIC_ISA_BUS = 1,
180839cb99eSKhalid Aziz BLOGIC_EISA_BUS = 2,
181839cb99eSKhalid Aziz BLOGIC_PCI_BUS = 3,
182839cb99eSKhalid Aziz BLOGIC_VESA_BUS = 4,
183839cb99eSKhalid Aziz BLOGIC_MCA_BUS = 5
1841da177e4SLinus Torvalds } PACKED;
1851da177e4SLinus Torvalds
186839cb99eSKhalid Aziz static char *blogic_adapter_busnames[] = { "Unknown", "ISA", "EISA", "PCI", "VESA", "MCA" };
1871da177e4SLinus Torvalds
188839cb99eSKhalid Aziz static enum blogic_adapter_bus_type blogic_adater_bus_types[] = {
189839cb99eSKhalid Aziz BLOGIC_VESA_BUS, /* BT-4xx */
190839cb99eSKhalid Aziz BLOGIC_ISA_BUS, /* BT-5xx */
191839cb99eSKhalid Aziz BLOGIC_MCA_BUS, /* BT-6xx */
192839cb99eSKhalid Aziz BLOGIC_EISA_BUS, /* BT-7xx */
193839cb99eSKhalid Aziz BLOGIC_UNKNOWN_BUS, /* BT-8xx */
194839cb99eSKhalid Aziz BLOGIC_PCI_BUS /* BT-9xx */
1951da177e4SLinus Torvalds };
1961da177e4SLinus Torvalds
1971da177e4SLinus Torvalds /*
1981da177e4SLinus Torvalds Define the possible Host Adapter BIOS Disk Geometry Translations.
1991da177e4SLinus Torvalds */
2001da177e4SLinus Torvalds
201839cb99eSKhalid Aziz enum blogic_bios_diskgeometry {
202839cb99eSKhalid Aziz BLOGIC_BIOS_NODISK = 0,
203839cb99eSKhalid Aziz BLOGIC_BIOS_DISK64x32 = 1,
204839cb99eSKhalid Aziz BLOGIC_BIOS_DISK128x32 = 2,
205839cb99eSKhalid Aziz BLOGIC_BIOS_DISK255x63 = 3
2061da177e4SLinus Torvalds } PACKED;
2071da177e4SLinus Torvalds
2081da177e4SLinus Torvalds
2091da177e4SLinus Torvalds /*
2101da177e4SLinus Torvalds Define a 10^18 Statistics Byte Counter data type.
2111da177e4SLinus Torvalds */
2121da177e4SLinus Torvalds
213839cb99eSKhalid Aziz struct blogic_byte_count {
214839cb99eSKhalid Aziz unsigned int units;
215839cb99eSKhalid Aziz unsigned int billions;
2161da177e4SLinus Torvalds };
2171da177e4SLinus Torvalds
2181da177e4SLinus Torvalds
2191da177e4SLinus Torvalds /*
2201da177e4SLinus Torvalds Define the structure for I/O Address and Bus Probing Information.
2211da177e4SLinus Torvalds */
2221da177e4SLinus Torvalds
223839cb99eSKhalid Aziz struct blogic_probeinfo {
224839cb99eSKhalid Aziz enum blogic_adapter_type adapter_type;
225839cb99eSKhalid Aziz enum blogic_adapter_bus_type adapter_bus_type;
226839cb99eSKhalid Aziz unsigned long io_addr;
227839cb99eSKhalid Aziz unsigned long pci_addr;
228839cb99eSKhalid Aziz struct pci_dev *pci_device;
229839cb99eSKhalid Aziz unsigned char bus;
230839cb99eSKhalid Aziz unsigned char dev;
231839cb99eSKhalid Aziz unsigned char irq_ch;
2321da177e4SLinus Torvalds };
2331da177e4SLinus Torvalds
2341da177e4SLinus Torvalds /*
2351da177e4SLinus Torvalds Define the Probe Options.
2361da177e4SLinus Torvalds */
2371da177e4SLinus Torvalds
238839cb99eSKhalid Aziz struct blogic_probe_options {
239839cb99eSKhalid Aziz bool noprobe:1; /* Bit 0 */
240839cb99eSKhalid Aziz bool noprobe_pci:1; /* Bit 2 */
241839cb99eSKhalid Aziz bool nosort_pci:1; /* Bit 3 */
242839cb99eSKhalid Aziz bool multimaster_first:1; /* Bit 4 */
243839cb99eSKhalid Aziz bool flashpoint_first:1; /* Bit 5 */
2441da177e4SLinus Torvalds };
2451da177e4SLinus Torvalds
2461da177e4SLinus Torvalds /*
2471da177e4SLinus Torvalds Define the Global Options.
2481da177e4SLinus Torvalds */
2491da177e4SLinus Torvalds
250839cb99eSKhalid Aziz struct blogic_global_options {
251839cb99eSKhalid Aziz bool trace_probe:1; /* Bit 0 */
252839cb99eSKhalid Aziz bool trace_hw_reset:1; /* Bit 1 */
253839cb99eSKhalid Aziz bool trace_config:1; /* Bit 2 */
254839cb99eSKhalid Aziz bool trace_err:1; /* Bit 3 */
2551da177e4SLinus Torvalds };
2561da177e4SLinus Torvalds
2571da177e4SLinus Torvalds /*
2581da177e4SLinus Torvalds Define the BusLogic SCSI Host Adapter I/O Register Offsets.
2591da177e4SLinus Torvalds */
2601da177e4SLinus Torvalds
261839cb99eSKhalid Aziz #define BLOGIC_CNTRL_REG 0 /* WO register */
262839cb99eSKhalid Aziz #define BLOGIC_STATUS_REG 0 /* RO register */
263839cb99eSKhalid Aziz #define BLOGIC_CMD_PARM_REG 1 /* WO register */
264839cb99eSKhalid Aziz #define BLOGIC_DATAIN_REG 1 /* RO register */
265839cb99eSKhalid Aziz #define BLOGIC_INT_REG 2 /* RO register */
266839cb99eSKhalid Aziz #define BLOGIC_GEOMETRY_REG 3 /* RO register */
2671da177e4SLinus Torvalds
2681da177e4SLinus Torvalds /*
2691da177e4SLinus Torvalds Define the structure of the write-only Control Register.
2701da177e4SLinus Torvalds */
2711da177e4SLinus Torvalds
272839cb99eSKhalid Aziz union blogic_cntrl_reg {
273839cb99eSKhalid Aziz unsigned char all;
2741da177e4SLinus Torvalds struct {
2751da177e4SLinus Torvalds unsigned char:4; /* Bits 0-3 */
276839cb99eSKhalid Aziz bool bus_reset:1; /* Bit 4 */
277839cb99eSKhalid Aziz bool int_reset:1; /* Bit 5 */
278839cb99eSKhalid Aziz bool soft_reset:1; /* Bit 6 */
279839cb99eSKhalid Aziz bool hard_reset:1; /* Bit 7 */
2801da177e4SLinus Torvalds } cr;
2811da177e4SLinus Torvalds };
2821da177e4SLinus Torvalds
2831da177e4SLinus Torvalds /*
2841da177e4SLinus Torvalds Define the structure of the read-only Status Register.
2851da177e4SLinus Torvalds */
2861da177e4SLinus Torvalds
287839cb99eSKhalid Aziz union blogic_stat_reg {
288839cb99eSKhalid Aziz unsigned char all;
2891da177e4SLinus Torvalds struct {
290839cb99eSKhalid Aziz bool cmd_invalid:1; /* Bit 0 */
291839cb99eSKhalid Aziz bool rsvd:1; /* Bit 1 */
292839cb99eSKhalid Aziz bool datain_ready:1; /* Bit 2 */
293839cb99eSKhalid Aziz bool cmd_param_busy:1; /* Bit 3 */
294839cb99eSKhalid Aziz bool adapter_ready:1; /* Bit 4 */
295839cb99eSKhalid Aziz bool init_reqd:1; /* Bit 5 */
296839cb99eSKhalid Aziz bool diag_failed:1; /* Bit 6 */
297839cb99eSKhalid Aziz bool diag_active:1; /* Bit 7 */
2981da177e4SLinus Torvalds } sr;
2991da177e4SLinus Torvalds };
3001da177e4SLinus Torvalds
3011da177e4SLinus Torvalds /*
3021da177e4SLinus Torvalds Define the structure of the read-only Interrupt Register.
3031da177e4SLinus Torvalds */
3041da177e4SLinus Torvalds
305839cb99eSKhalid Aziz union blogic_int_reg {
306839cb99eSKhalid Aziz unsigned char all;
3071da177e4SLinus Torvalds struct {
308839cb99eSKhalid Aziz bool mailin_loaded:1; /* Bit 0 */
309839cb99eSKhalid Aziz bool mailout_avail:1; /* Bit 1 */
310839cb99eSKhalid Aziz bool cmd_complete:1; /* Bit 2 */
311839cb99eSKhalid Aziz bool ext_busreset:1; /* Bit 3 */
312839cb99eSKhalid Aziz unsigned char rsvd:3; /* Bits 4-6 */
313839cb99eSKhalid Aziz bool int_valid:1; /* Bit 7 */
3141da177e4SLinus Torvalds } ir;
3151da177e4SLinus Torvalds };
3161da177e4SLinus Torvalds
3171da177e4SLinus Torvalds /*
3181da177e4SLinus Torvalds Define the structure of the read-only Geometry Register.
3191da177e4SLinus Torvalds */
3201da177e4SLinus Torvalds
321839cb99eSKhalid Aziz union blogic_geo_reg {
322839cb99eSKhalid Aziz unsigned char all;
3231da177e4SLinus Torvalds struct {
324839cb99eSKhalid Aziz enum blogic_bios_diskgeometry d0_geo:2; /* Bits 0-1 */
325839cb99eSKhalid Aziz enum blogic_bios_diskgeometry d1_geo:2; /* Bits 2-3 */
3261da177e4SLinus Torvalds unsigned char:3; /* Bits 4-6 */
327839cb99eSKhalid Aziz bool ext_trans_enable:1; /* Bit 7 */
3281da177e4SLinus Torvalds } gr;
3291da177e4SLinus Torvalds };
3301da177e4SLinus Torvalds
3311da177e4SLinus Torvalds /*
3321da177e4SLinus Torvalds Define the BusLogic SCSI Host Adapter Command Register Operation Codes.
3331da177e4SLinus Torvalds */
3341da177e4SLinus Torvalds
335839cb99eSKhalid Aziz enum blogic_opcode {
336839cb99eSKhalid Aziz BLOGIC_TEST_CMP_COMPLETE = 0x00,
337839cb99eSKhalid Aziz BLOGIC_INIT_MBOX = 0x01,
338839cb99eSKhalid Aziz BLOGIC_EXEC_MBOX_CMD = 0x02,
339839cb99eSKhalid Aziz BLOGIC_EXEC_BIOS_CMD = 0x03,
340839cb99eSKhalid Aziz BLOGIC_GET_BOARD_ID = 0x04,
341839cb99eSKhalid Aziz BLOGIC_ENABLE_OUTBOX_AVAIL_INT = 0x05,
342839cb99eSKhalid Aziz BLOGIC_SET_SELECT_TIMEOUT = 0x06,
343839cb99eSKhalid Aziz BLOGIC_SET_PREEMPT_TIME = 0x07,
344839cb99eSKhalid Aziz BLOGIC_SET_TIMEOFF_BUS = 0x08,
345839cb99eSKhalid Aziz BLOGIC_SET_TXRATE = 0x09,
346839cb99eSKhalid Aziz BLOGIC_INQ_DEV0TO7 = 0x0A,
347839cb99eSKhalid Aziz BLOGIC_INQ_CONFIG = 0x0B,
348839cb99eSKhalid Aziz BLOGIC_TGT_MODE = 0x0C,
349839cb99eSKhalid Aziz BLOGIC_INQ_SETUPINFO = 0x0D,
350839cb99eSKhalid Aziz BLOGIC_WRITE_LOCALRAM = 0x1A,
351839cb99eSKhalid Aziz BLOGIC_READ_LOCALRAM = 0x1B,
352839cb99eSKhalid Aziz BLOGIC_WRITE_BUSMASTER_FIFO = 0x1C,
353839cb99eSKhalid Aziz BLOGIC_READ_BUSMASTER_FIFO = 0x1D,
354839cb99eSKhalid Aziz BLOGIC_ECHO_CMDDATA = 0x1F,
355839cb99eSKhalid Aziz BLOGIC_ADAPTER_DIAG = 0x20,
356839cb99eSKhalid Aziz BLOGIC_SET_OPTIONS = 0x21,
357839cb99eSKhalid Aziz BLOGIC_INQ_DEV8TO15 = 0x23,
358839cb99eSKhalid Aziz BLOGIC_INQ_DEV = 0x24,
359839cb99eSKhalid Aziz BLOGIC_DISABLE_INT = 0x25,
360839cb99eSKhalid Aziz BLOGIC_INIT_EXT_MBOX = 0x81,
361839cb99eSKhalid Aziz BLOGIC_EXEC_SCS_CMD = 0x83,
362839cb99eSKhalid Aziz BLOGIC_INQ_FWVER_D3 = 0x84,
363839cb99eSKhalid Aziz BLOGIC_INQ_FWVER_LETTER = 0x85,
364839cb99eSKhalid Aziz BLOGIC_INQ_PCI_INFO = 0x86,
365839cb99eSKhalid Aziz BLOGIC_INQ_MODELNO = 0x8B,
366839cb99eSKhalid Aziz BLOGIC_INQ_SYNC_PERIOD = 0x8C,
367839cb99eSKhalid Aziz BLOGIC_INQ_EXTSETUP = 0x8D,
368839cb99eSKhalid Aziz BLOGIC_STRICT_RR = 0x8F,
369839cb99eSKhalid Aziz BLOGIC_STORE_LOCALRAM = 0x90,
370839cb99eSKhalid Aziz BLOGIC_FETCH_LOCALRAM = 0x91,
371839cb99eSKhalid Aziz BLOGIC_STORE_TO_EEPROM = 0x92,
372839cb99eSKhalid Aziz BLOGIC_LOAD_AUTOSCSICODE = 0x94,
373839cb99eSKhalid Aziz BLOGIC_MOD_IOADDR = 0x95,
374839cb99eSKhalid Aziz BLOGIC_SETCCB_FMT = 0x96,
375839cb99eSKhalid Aziz BLOGIC_WRITE_INQBUF = 0x9A,
376839cb99eSKhalid Aziz BLOGIC_READ_INQBUF = 0x9B,
377839cb99eSKhalid Aziz BLOGIC_FLASH_LOAD = 0xA7,
378839cb99eSKhalid Aziz BLOGIC_READ_SCAMDATA = 0xA8,
379839cb99eSKhalid Aziz BLOGIC_WRITE_SCAMDATA = 0xA9
3801da177e4SLinus Torvalds };
3811da177e4SLinus Torvalds
3821da177e4SLinus Torvalds /*
3831da177e4SLinus Torvalds Define the Inquire Board ID reply structure.
3841da177e4SLinus Torvalds */
3851da177e4SLinus Torvalds
386839cb99eSKhalid Aziz struct blogic_board_id {
387839cb99eSKhalid Aziz unsigned char type; /* Byte 0 */
388839cb99eSKhalid Aziz unsigned char custom_features; /* Byte 1 */
389839cb99eSKhalid Aziz unsigned char fw_ver_digit1; /* Byte 2 */
390839cb99eSKhalid Aziz unsigned char fw_ver_digit2; /* Byte 3 */
3911da177e4SLinus Torvalds };
3921da177e4SLinus Torvalds
3931da177e4SLinus Torvalds /*
3941da177e4SLinus Torvalds Define the Inquire Configuration reply structure.
3951da177e4SLinus Torvalds */
3961da177e4SLinus Torvalds
397839cb99eSKhalid Aziz struct blogic_config {
3981da177e4SLinus Torvalds unsigned char:5; /* Byte 0 Bits 0-4 */
399839cb99eSKhalid Aziz bool dma_ch5:1; /* Byte 0 Bit 5 */
400839cb99eSKhalid Aziz bool dma_ch6:1; /* Byte 0 Bit 6 */
401839cb99eSKhalid Aziz bool dma_ch7:1; /* Byte 0 Bit 7 */
402839cb99eSKhalid Aziz bool irq_ch9:1; /* Byte 1 Bit 0 */
403839cb99eSKhalid Aziz bool irq_ch10:1; /* Byte 1 Bit 1 */
404839cb99eSKhalid Aziz bool irq_ch11:1; /* Byte 1 Bit 2 */
405839cb99eSKhalid Aziz bool irq_ch12:1; /* Byte 1 Bit 3 */
4061da177e4SLinus Torvalds unsigned char:1; /* Byte 1 Bit 4 */
407839cb99eSKhalid Aziz bool irq_ch14:1; /* Byte 1 Bit 5 */
408839cb99eSKhalid Aziz bool irq_ch15:1; /* Byte 1 Bit 6 */
4091da177e4SLinus Torvalds unsigned char:1; /* Byte 1 Bit 7 */
410839cb99eSKhalid Aziz unsigned char id:4; /* Byte 2 Bits 0-3 */
4111da177e4SLinus Torvalds unsigned char:4; /* Byte 2 Bits 4-7 */
4121da177e4SLinus Torvalds };
4131da177e4SLinus Torvalds
4141da177e4SLinus Torvalds /*
4151da177e4SLinus Torvalds Define the Inquire Setup Information reply structure.
4161da177e4SLinus Torvalds */
4171da177e4SLinus Torvalds
418839cb99eSKhalid Aziz struct blogic_syncval {
419839cb99eSKhalid Aziz unsigned char offset:4; /* Bits 0-3 */
420839cb99eSKhalid Aziz unsigned char tx_period:3; /* Bits 4-6 */
421839cb99eSKhalid Aziz bool sync:1; /* Bit 7 */
4221da177e4SLinus Torvalds };
4231da177e4SLinus Torvalds
424839cb99eSKhalid Aziz struct blogic_setup_info {
425839cb99eSKhalid Aziz bool sync:1; /* Byte 0 Bit 0 */
426839cb99eSKhalid Aziz bool parity:1; /* Byte 0 Bit 1 */
4271da177e4SLinus Torvalds unsigned char:6; /* Byte 0 Bits 2-7 */
428839cb99eSKhalid Aziz unsigned char tx_rate; /* Byte 1 */
429839cb99eSKhalid Aziz unsigned char preempt_time; /* Byte 2 */
430839cb99eSKhalid Aziz unsigned char timeoff_bus; /* Byte 3 */
431839cb99eSKhalid Aziz unsigned char mbox_count; /* Byte 4 */
432839cb99eSKhalid Aziz unsigned char mbox_addr[3]; /* Bytes 5-7 */
433839cb99eSKhalid Aziz struct blogic_syncval sync0to7[8]; /* Bytes 8-15 */
434839cb99eSKhalid Aziz unsigned char disconnect_ok0to7; /* Byte 16 */
435839cb99eSKhalid Aziz unsigned char sig; /* Byte 17 */
436839cb99eSKhalid Aziz unsigned char char_d; /* Byte 18 */
437839cb99eSKhalid Aziz unsigned char bus_type; /* Byte 19 */
438839cb99eSKhalid Aziz unsigned char wide_tx_ok0to7; /* Byte 20 */
439839cb99eSKhalid Aziz unsigned char wide_tx_active0to7; /* Byte 21 */
440839cb99eSKhalid Aziz struct blogic_syncval sync8to15[8]; /* Bytes 22-29 */
441839cb99eSKhalid Aziz unsigned char disconnect_ok8to15; /* Byte 30 */
4421da177e4SLinus Torvalds unsigned char:8; /* Byte 31 */
443839cb99eSKhalid Aziz unsigned char wide_tx_ok8to15; /* Byte 32 */
444839cb99eSKhalid Aziz unsigned char wide_tx_active8to15; /* Byte 33 */
4451da177e4SLinus Torvalds };
4461da177e4SLinus Torvalds
4471da177e4SLinus Torvalds /*
4481da177e4SLinus Torvalds Define the Initialize Extended Mailbox request structure.
4491da177e4SLinus Torvalds */
4501da177e4SLinus Torvalds
451839cb99eSKhalid Aziz struct blogic_extmbox_req {
452839cb99eSKhalid Aziz unsigned char mbox_count; /* Byte 0 */
453839cb99eSKhalid Aziz u32 base_mbox_addr; /* Bytes 1-4 */
4541da177e4SLinus Torvalds } PACKED;
4551da177e4SLinus Torvalds
4561da177e4SLinus Torvalds
4571da177e4SLinus Torvalds /*
4581da177e4SLinus Torvalds Define the Inquire PCI Host Adapter Information reply type. The ISA
4591da177e4SLinus Torvalds Compatible I/O Port values are defined here and are also used with
4601da177e4SLinus Torvalds the Modify I/O Address command.
4611da177e4SLinus Torvalds */
4621da177e4SLinus Torvalds
463839cb99eSKhalid Aziz enum blogic_isa_ioport {
464839cb99eSKhalid Aziz BLOGIC_IO_330 = 0,
465839cb99eSKhalid Aziz BLOGIC_IO_334 = 1,
466839cb99eSKhalid Aziz BLOGIC_IO_230 = 2,
467839cb99eSKhalid Aziz BLOGIC_IO_234 = 3,
468839cb99eSKhalid Aziz BLOGIC_IO_130 = 4,
469839cb99eSKhalid Aziz BLOGIC_IO_134 = 5,
470839cb99eSKhalid Aziz BLOGIC_IO_DISABLE = 6,
471839cb99eSKhalid Aziz BLOGIC_IO_DISABLE2 = 7
4721da177e4SLinus Torvalds } PACKED;
4731da177e4SLinus Torvalds
474839cb99eSKhalid Aziz struct blogic_adapter_info {
475839cb99eSKhalid Aziz enum blogic_isa_ioport isa_port; /* Byte 0 */
476839cb99eSKhalid Aziz unsigned char irq_ch; /* Byte 1 */
477839cb99eSKhalid Aziz bool low_term:1; /* Byte 2 Bit 0 */
478839cb99eSKhalid Aziz bool high_term:1; /* Byte 2 Bit 1 */
4791da177e4SLinus Torvalds unsigned char:2; /* Byte 2 Bits 2-3 */
4802065e310SRichard Knutsson bool JP1:1; /* Byte 2 Bit 4 */
4812065e310SRichard Knutsson bool JP2:1; /* Byte 2 Bit 5 */
4822065e310SRichard Knutsson bool JP3:1; /* Byte 2 Bit 6 */
483839cb99eSKhalid Aziz bool genericinfo_valid:1; /* Byte 2 Bit 7 */
4841da177e4SLinus Torvalds unsigned char:8; /* Byte 3 */
4851da177e4SLinus Torvalds };
4861da177e4SLinus Torvalds
4871da177e4SLinus Torvalds /*
4881da177e4SLinus Torvalds Define the Inquire Extended Setup Information reply structure.
4891da177e4SLinus Torvalds */
4901da177e4SLinus Torvalds
491839cb99eSKhalid Aziz struct blogic_ext_setup {
492839cb99eSKhalid Aziz unsigned char bus_type; /* Byte 0 */
493839cb99eSKhalid Aziz unsigned char bios_addr; /* Byte 1 */
494839cb99eSKhalid Aziz unsigned short sg_limit; /* Bytes 2-3 */
495839cb99eSKhalid Aziz unsigned char mbox_count; /* Byte 4 */
496839cb99eSKhalid Aziz u32 base_mbox_addr; /* Bytes 5-8 */
4971da177e4SLinus Torvalds struct {
4981da177e4SLinus Torvalds unsigned char:2; /* Byte 9 Bits 0-1 */
499839cb99eSKhalid Aziz bool fast_on_eisa:1; /* Byte 9 Bit 2 */
5001da177e4SLinus Torvalds unsigned char:3; /* Byte 9 Bits 3-5 */
501839cb99eSKhalid Aziz bool level_int:1; /* Byte 9 Bit 6 */
5021da177e4SLinus Torvalds unsigned char:1; /* Byte 9 Bit 7 */
503839cb99eSKhalid Aziz } misc;
504839cb99eSKhalid Aziz unsigned char fw_rev[3]; /* Bytes 10-12 */
505839cb99eSKhalid Aziz bool wide:1; /* Byte 13 Bit 0 */
506839cb99eSKhalid Aziz bool differential:1; /* Byte 13 Bit 1 */
507839cb99eSKhalid Aziz bool scam:1; /* Byte 13 Bit 2 */
508839cb99eSKhalid Aziz bool ultra:1; /* Byte 13 Bit 3 */
509839cb99eSKhalid Aziz bool smart_term:1; /* Byte 13 Bit 4 */
5101da177e4SLinus Torvalds unsigned char:3; /* Byte 13 Bits 5-7 */
5111da177e4SLinus Torvalds } PACKED;
5121da177e4SLinus Torvalds
5131da177e4SLinus Torvalds /*
5141da177e4SLinus Torvalds Define the Enable Strict Round Robin Mode request type.
5151da177e4SLinus Torvalds */
5161da177e4SLinus Torvalds
517839cb99eSKhalid Aziz enum blogic_rr_req {
518839cb99eSKhalid Aziz BLOGIC_AGGRESSIVE_RR = 0,
519839cb99eSKhalid Aziz BLOGIC_STRICT_RR_MODE = 1
5201da177e4SLinus Torvalds } PACKED;
5211da177e4SLinus Torvalds
5221da177e4SLinus Torvalds
5231da177e4SLinus Torvalds /*
5241da177e4SLinus Torvalds Define the Fetch Host Adapter Local RAM request type.
5251da177e4SLinus Torvalds */
5261da177e4SLinus Torvalds
527839cb99eSKhalid Aziz #define BLOGIC_BIOS_BASE 0
528839cb99eSKhalid Aziz #define BLOGIC_AUTOSCSI_BASE 64
5291da177e4SLinus Torvalds
530839cb99eSKhalid Aziz struct blogic_fetch_localram {
531839cb99eSKhalid Aziz unsigned char offset; /* Byte 0 */
532839cb99eSKhalid Aziz unsigned char count; /* Byte 1 */
5331da177e4SLinus Torvalds };
5341da177e4SLinus Torvalds
5351da177e4SLinus Torvalds /*
5361da177e4SLinus Torvalds Define the Host Adapter Local RAM AutoSCSI structure.
5371da177e4SLinus Torvalds */
5381da177e4SLinus Torvalds
539839cb99eSKhalid Aziz struct blogic_autoscsi {
540839cb99eSKhalid Aziz unsigned char factory_sig[2]; /* Bytes 0-1 */
541839cb99eSKhalid Aziz unsigned char info_bytes; /* Byte 2 */
542839cb99eSKhalid Aziz unsigned char adapter_type[6]; /* Bytes 3-8 */
5431da177e4SLinus Torvalds unsigned char:8; /* Byte 9 */
544839cb99eSKhalid Aziz bool floppy:1; /* Byte 10 Bit 0 */
545839cb99eSKhalid Aziz bool floppy_sec:1; /* Byte 10 Bit 1 */
546839cb99eSKhalid Aziz bool level_int:1; /* Byte 10 Bit 2 */
5471da177e4SLinus Torvalds unsigned char:2; /* Byte 10 Bits 3-4 */
548839cb99eSKhalid Aziz unsigned char systemram_bios:3; /* Byte 10 Bits 5-7 */
549839cb99eSKhalid Aziz unsigned char dma_ch:7; /* Byte 11 Bits 0-6 */
550839cb99eSKhalid Aziz bool dma_autoconf:1; /* Byte 11 Bit 7 */
551839cb99eSKhalid Aziz unsigned char irq_ch:7; /* Byte 12 Bits 0-6 */
552839cb99eSKhalid Aziz bool irq_autoconf:1; /* Byte 12 Bit 7 */
553839cb99eSKhalid Aziz unsigned char dma_tx_rate; /* Byte 13 */
554839cb99eSKhalid Aziz unsigned char scsi_id; /* Byte 14 */
555839cb99eSKhalid Aziz bool low_term:1; /* Byte 15 Bit 0 */
556839cb99eSKhalid Aziz bool parity:1; /* Byte 15 Bit 1 */
557839cb99eSKhalid Aziz bool high_term:1; /* Byte 15 Bit 2 */
558839cb99eSKhalid Aziz bool noisy_cable:1; /* Byte 15 Bit 3 */
559839cb99eSKhalid Aziz bool fast_sync_neg:1; /* Byte 15 Bit 4 */
560839cb99eSKhalid Aziz bool reset_enabled:1; /* Byte 15 Bit 5 */
5612065e310SRichard Knutsson bool:1; /* Byte 15 Bit 6 */
562839cb99eSKhalid Aziz bool active_negation:1; /* Byte 15 Bit 7 */
563839cb99eSKhalid Aziz unsigned char bus_on_delay; /* Byte 16 */
564839cb99eSKhalid Aziz unsigned char bus_off_delay; /* Byte 17 */
565839cb99eSKhalid Aziz bool bios_enabled:1; /* Byte 18 Bit 0 */
566839cb99eSKhalid Aziz bool int19_redir_enabled:1; /* Byte 18 Bit 1 */
567839cb99eSKhalid Aziz bool ext_trans_enable:1; /* Byte 18 Bit 2 */
568839cb99eSKhalid Aziz bool removable_as_fixed:1; /* Byte 18 Bit 3 */
5692065e310SRichard Knutsson bool:1; /* Byte 18 Bit 4 */
570839cb99eSKhalid Aziz bool morethan2_drives:1; /* Byte 18 Bit 5 */
571839cb99eSKhalid Aziz bool bios_int:1; /* Byte 18 Bit 6 */
572839cb99eSKhalid Aziz bool floptical:1; /* Byte 19 Bit 7 */
573839cb99eSKhalid Aziz unsigned short dev_enabled; /* Bytes 19-20 */
574839cb99eSKhalid Aziz unsigned short wide_ok; /* Bytes 21-22 */
575839cb99eSKhalid Aziz unsigned short fast_ok; /* Bytes 23-24 */
576839cb99eSKhalid Aziz unsigned short sync_ok; /* Bytes 25-26 */
577839cb99eSKhalid Aziz unsigned short discon_ok; /* Bytes 27-28 */
578839cb99eSKhalid Aziz unsigned short send_start_unit; /* Bytes 29-30 */
579839cb99eSKhalid Aziz unsigned short ignore_bios_scan; /* Bytes 31-32 */
580839cb99eSKhalid Aziz unsigned char pci_int_pin:2; /* Byte 33 Bits 0-1 */
581839cb99eSKhalid Aziz unsigned char adapter_ioport:2; /* Byte 33 Bits 2-3 */
582839cb99eSKhalid Aziz bool strict_rr_enabled:1; /* Byte 33 Bit 4 */
583839cb99eSKhalid Aziz bool vesabus_33mhzplus:1; /* Byte 33 Bit 5 */
584839cb99eSKhalid Aziz bool vesa_burst_write:1; /* Byte 33 Bit 6 */
585839cb99eSKhalid Aziz bool vesa_burst_read:1; /* Byte 33 Bit 7 */
586839cb99eSKhalid Aziz unsigned short ultra_ok; /* Bytes 34-35 */
5871da177e4SLinus Torvalds unsigned int:32; /* Bytes 36-39 */
5881da177e4SLinus Torvalds unsigned char:8; /* Byte 40 */
589839cb99eSKhalid Aziz unsigned char autoscsi_maxlun; /* Byte 41 */
5902065e310SRichard Knutsson bool:1; /* Byte 42 Bit 0 */
591839cb99eSKhalid Aziz bool scam_dominant:1; /* Byte 42 Bit 1 */
592839cb99eSKhalid Aziz bool scam_enabled:1; /* Byte 42 Bit 2 */
593839cb99eSKhalid Aziz bool scam_lev2:1; /* Byte 42 Bit 3 */
5941da177e4SLinus Torvalds unsigned char:4; /* Byte 42 Bits 4-7 */
595839cb99eSKhalid Aziz bool int13_exten:1; /* Byte 43 Bit 0 */
5962065e310SRichard Knutsson bool:1; /* Byte 43 Bit 1 */
597839cb99eSKhalid Aziz bool cd_boot:1; /* Byte 43 Bit 2 */
5981da177e4SLinus Torvalds unsigned char:5; /* Byte 43 Bits 3-7 */
599839cb99eSKhalid Aziz unsigned char boot_id:4; /* Byte 44 Bits 0-3 */
600839cb99eSKhalid Aziz unsigned char boot_ch:4; /* Byte 44 Bits 4-7 */
601839cb99eSKhalid Aziz unsigned char force_scan_order:1; /* Byte 45 Bit 0 */
6021da177e4SLinus Torvalds unsigned char:7; /* Byte 45 Bits 1-7 */
603839cb99eSKhalid Aziz unsigned short nontagged_to_alt_ok; /* Bytes 46-47 */
604839cb99eSKhalid Aziz unsigned short reneg_sync_on_check; /* Bytes 48-49 */
605839cb99eSKhalid Aziz unsigned char rsvd[10]; /* Bytes 50-59 */
606839cb99eSKhalid Aziz unsigned char manuf_diag[2]; /* Bytes 60-61 */
607839cb99eSKhalid Aziz unsigned short cksum; /* Bytes 62-63 */
6081da177e4SLinus Torvalds } PACKED;
6091da177e4SLinus Torvalds
6101da177e4SLinus Torvalds /*
6111da177e4SLinus Torvalds Define the Host Adapter Local RAM Auto SCSI Byte 45 structure.
6121da177e4SLinus Torvalds */
6131da177e4SLinus Torvalds
614839cb99eSKhalid Aziz struct blogic_autoscsi_byte45 {
615839cb99eSKhalid Aziz unsigned char force_scan_order:1; /* Bit 0 */
6161da177e4SLinus Torvalds unsigned char:7; /* Bits 1-7 */
6171da177e4SLinus Torvalds };
6181da177e4SLinus Torvalds
6191da177e4SLinus Torvalds /*
6201da177e4SLinus Torvalds Define the Host Adapter Local RAM BIOS Drive Map Byte structure.
6211da177e4SLinus Torvalds */
6221da177e4SLinus Torvalds
623839cb99eSKhalid Aziz #define BLOGIC_BIOS_DRVMAP 17
6241da177e4SLinus Torvalds
625839cb99eSKhalid Aziz struct blogic_bios_drvmap {
626839cb99eSKhalid Aziz unsigned char tgt_idbit3:1; /* Bit 0 */
6271da177e4SLinus Torvalds unsigned char:2; /* Bits 1-2 */
628839cb99eSKhalid Aziz enum blogic_bios_diskgeometry diskgeom:2; /* Bits 3-4 */
629839cb99eSKhalid Aziz unsigned char tgt_id:3; /* Bits 5-7 */
6301da177e4SLinus Torvalds };
6311da177e4SLinus Torvalds
6321da177e4SLinus Torvalds /*
6331da177e4SLinus Torvalds Define the Set CCB Format request type. Extended LUN Format CCBs are
6341da177e4SLinus Torvalds necessary to support more than 8 Logical Units per Target Device.
6351da177e4SLinus Torvalds */
6361da177e4SLinus Torvalds
637839cb99eSKhalid Aziz enum blogic_setccb_fmt {
638839cb99eSKhalid Aziz BLOGIC_LEGACY_LUN_CCB = 0,
639839cb99eSKhalid Aziz BLOGIC_EXT_LUN_CCB = 1
6401da177e4SLinus Torvalds } PACKED;
6411da177e4SLinus Torvalds
6421da177e4SLinus Torvalds /*
6431da177e4SLinus Torvalds Define the Outgoing Mailbox Action Codes.
6441da177e4SLinus Torvalds */
6451da177e4SLinus Torvalds
646839cb99eSKhalid Aziz enum blogic_action {
647839cb99eSKhalid Aziz BLOGIC_OUTBOX_FREE = 0x00,
648839cb99eSKhalid Aziz BLOGIC_MBOX_START = 0x01,
649839cb99eSKhalid Aziz BLOGIC_MBOX_ABORT = 0x02
6501da177e4SLinus Torvalds } PACKED;
6511da177e4SLinus Torvalds
6521da177e4SLinus Torvalds
6531da177e4SLinus Torvalds /*
6541da177e4SLinus Torvalds Define the Incoming Mailbox Completion Codes. The MultiMaster Firmware
6551da177e4SLinus Torvalds only uses codes 0 - 4. The FlashPoint SCCB Manager has no mailboxes, so
6561da177e4SLinus Torvalds completion codes are stored in the CCB; it only uses codes 1, 2, 4, and 5.
6571da177e4SLinus Torvalds */
6581da177e4SLinus Torvalds
659839cb99eSKhalid Aziz enum blogic_cmplt_code {
660839cb99eSKhalid Aziz BLOGIC_INBOX_FREE = 0x00,
661839cb99eSKhalid Aziz BLOGIC_CMD_COMPLETE_GOOD = 0x01,
662839cb99eSKhalid Aziz BLOGIC_CMD_ABORT_BY_HOST = 0x02,
663839cb99eSKhalid Aziz BLOGIC_CMD_NOTFOUND = 0x03,
664839cb99eSKhalid Aziz BLOGIC_CMD_COMPLETE_ERROR = 0x04,
665839cb99eSKhalid Aziz BLOGIC_INVALID_CCB = 0x05
6661da177e4SLinus Torvalds } PACKED;
6671da177e4SLinus Torvalds
6681da177e4SLinus Torvalds /*
6691da177e4SLinus Torvalds Define the Command Control Block (CCB) Opcodes.
6701da177e4SLinus Torvalds */
6711da177e4SLinus Torvalds
672839cb99eSKhalid Aziz enum blogic_ccb_opcode {
673839cb99eSKhalid Aziz BLOGIC_INITIATOR_CCB = 0x00,
674839cb99eSKhalid Aziz BLOGIC_TGT_CCB = 0x01,
675839cb99eSKhalid Aziz BLOGIC_INITIATOR_CCB_SG = 0x02,
676839cb99eSKhalid Aziz BLOGIC_INITIATOR_CCBB_RESIDUAL = 0x03,
677839cb99eSKhalid Aziz BLOGIC_INITIATOR_CCB_SG_RESIDUAL = 0x04,
678839cb99eSKhalid Aziz BLOGIC_BDR = 0x81
6791da177e4SLinus Torvalds } PACKED;
6801da177e4SLinus Torvalds
6811da177e4SLinus Torvalds
6821da177e4SLinus Torvalds /*
6831da177e4SLinus Torvalds Define the CCB Data Direction Codes.
6841da177e4SLinus Torvalds */
6851da177e4SLinus Torvalds
686839cb99eSKhalid Aziz enum blogic_datadir {
687839cb99eSKhalid Aziz BLOGIC_UNCHECKED_TX = 0,
688839cb99eSKhalid Aziz BLOGIC_DATAIN_CHECKED = 1,
689839cb99eSKhalid Aziz BLOGIC_DATAOUT_CHECKED = 2,
690839cb99eSKhalid Aziz BLOGIC_NOTX = 3
6911da177e4SLinus Torvalds };
6921da177e4SLinus Torvalds
6931da177e4SLinus Torvalds
6941da177e4SLinus Torvalds /*
6951da177e4SLinus Torvalds Define the Host Adapter Status Codes. The MultiMaster Firmware does not
6961da177e4SLinus Torvalds return status code 0x0C; it uses 0x12 for both overruns and underruns.
6971da177e4SLinus Torvalds */
6981da177e4SLinus Torvalds
699839cb99eSKhalid Aziz enum blogic_adapter_status {
700839cb99eSKhalid Aziz BLOGIC_CMD_CMPLT_NORMAL = 0x00,
701839cb99eSKhalid Aziz BLOGIC_LINK_CMD_CMPLT = 0x0A,
702839cb99eSKhalid Aziz BLOGIC_LINK_CMD_CMPLT_FLAG = 0x0B,
703839cb99eSKhalid Aziz BLOGIC_DATA_UNDERRUN = 0x0C,
704839cb99eSKhalid Aziz BLOGIC_SELECT_TIMEOUT = 0x11,
705839cb99eSKhalid Aziz BLOGIC_DATA_OVERRUN = 0x12,
706839cb99eSKhalid Aziz BLOGIC_NOEXPECT_BUSFREE = 0x13,
707839cb99eSKhalid Aziz BLOGIC_INVALID_BUSPHASE = 0x14,
708839cb99eSKhalid Aziz BLOGIC_INVALID_OUTBOX_CODE = 0x15,
709839cb99eSKhalid Aziz BLOGIC_INVALID_CMD_CODE = 0x16,
710839cb99eSKhalid Aziz BLOGIC_LINKCCB_BADLUN = 0x17,
711839cb99eSKhalid Aziz BLOGIC_BAD_CMD_PARAM = 0x1A,
712839cb99eSKhalid Aziz BLOGIC_AUTOREQSENSE_FAIL = 0x1B,
713839cb99eSKhalid Aziz BLOGIC_TAGQUEUE_REJECT = 0x1C,
714839cb99eSKhalid Aziz BLOGIC_BAD_MSG_RCVD = 0x1D,
715839cb99eSKhalid Aziz BLOGIC_HW_FAIL = 0x20,
716839cb99eSKhalid Aziz BLOGIC_NORESPONSE_TO_ATN = 0x21,
717839cb99eSKhalid Aziz BLOGIC_HW_RESET = 0x22,
718839cb99eSKhalid Aziz BLOGIC_RST_FROM_OTHERDEV = 0x23,
719839cb99eSKhalid Aziz BLOGIC_BAD_RECONNECT = 0x24,
720839cb99eSKhalid Aziz BLOGIC_HW_BDR = 0x25,
721839cb99eSKhalid Aziz BLOGIC_ABRT_QUEUE = 0x26,
722839cb99eSKhalid Aziz BLOGIC_ADAPTER_SW_ERROR = 0x27,
723839cb99eSKhalid Aziz BLOGIC_HW_TIMEOUT = 0x30,
724839cb99eSKhalid Aziz BLOGIC_PARITY_ERR = 0x34
7251da177e4SLinus Torvalds } PACKED;
7261da177e4SLinus Torvalds
7271da177e4SLinus Torvalds
7281da177e4SLinus Torvalds /*
7291da177e4SLinus Torvalds Define the SCSI Target Device Status Codes.
7301da177e4SLinus Torvalds */
7311da177e4SLinus Torvalds
732839cb99eSKhalid Aziz enum blogic_tgt_status {
733839cb99eSKhalid Aziz BLOGIC_OP_GOOD = 0x00,
734839cb99eSKhalid Aziz BLOGIC_CHECKCONDITION = 0x02,
735839cb99eSKhalid Aziz BLOGIC_DEVBUSY = 0x08
7361da177e4SLinus Torvalds } PACKED;
7371da177e4SLinus Torvalds
7381da177e4SLinus Torvalds /*
7391da177e4SLinus Torvalds Define the Queue Tag Codes.
7401da177e4SLinus Torvalds */
7411da177e4SLinus Torvalds
742839cb99eSKhalid Aziz enum blogic_queuetag {
743839cb99eSKhalid Aziz BLOGIC_SIMPLETAG = 0,
744839cb99eSKhalid Aziz BLOGIC_HEADTAG = 1,
745839cb99eSKhalid Aziz BLOGIC_ORDEREDTAG = 2,
746839cb99eSKhalid Aziz BLOGIC_RSVDTAG = 3
7471da177e4SLinus Torvalds };
7481da177e4SLinus Torvalds
7491da177e4SLinus Torvalds /*
7501da177e4SLinus Torvalds Define the SCSI Command Descriptor Block (CDB).
7511da177e4SLinus Torvalds */
7521da177e4SLinus Torvalds
753839cb99eSKhalid Aziz #define BLOGIC_CDB_MAXLEN 12
7541da177e4SLinus Torvalds
7551da177e4SLinus Torvalds
7561da177e4SLinus Torvalds /*
7571da177e4SLinus Torvalds Define the Scatter/Gather Segment structure required by the MultiMaster
7581da177e4SLinus Torvalds Firmware Interface and the FlashPoint SCCB Manager.
7591da177e4SLinus Torvalds */
7601da177e4SLinus Torvalds
761839cb99eSKhalid Aziz struct blogic_sg_seg {
762839cb99eSKhalid Aziz u32 segbytes; /* Bytes 0-3 */
763839cb99eSKhalid Aziz u32 segdata; /* Bytes 4-7 */
7641da177e4SLinus Torvalds };
7651da177e4SLinus Torvalds
7661da177e4SLinus Torvalds /*
7671da177e4SLinus Torvalds Define the Driver CCB Status Codes.
7681da177e4SLinus Torvalds */
7691da177e4SLinus Torvalds
770839cb99eSKhalid Aziz enum blogic_ccb_status {
771839cb99eSKhalid Aziz BLOGIC_CCB_FREE = 0,
772839cb99eSKhalid Aziz BLOGIC_CCB_ACTIVE = 1,
773839cb99eSKhalid Aziz BLOGIC_CCB_COMPLETE = 2,
774839cb99eSKhalid Aziz BLOGIC_CCB_RESET = 3
7751da177e4SLinus Torvalds } PACKED;
7761da177e4SLinus Torvalds
7771da177e4SLinus Torvalds
7781da177e4SLinus Torvalds /*
7791da177e4SLinus Torvalds Define the 32 Bit Mode Command Control Block (CCB) structure. The first 40
7801da177e4SLinus Torvalds bytes are defined by and common to both the MultiMaster Firmware and the
7811da177e4SLinus Torvalds FlashPoint SCCB Manager. The next 60 bytes are defined by the FlashPoint
7821da177e4SLinus Torvalds SCCB Manager. The remaining components are defined by the Linux BusLogic
7831da177e4SLinus Torvalds Driver. Extended LUN Format CCBs differ from Legacy LUN Format 32 Bit Mode
7841da177e4SLinus Torvalds CCBs only in having the TagEnable and QueueTag fields moved from byte 17 to
7851da177e4SLinus Torvalds byte 1, and the Logical Unit field in byte 17 expanded to 6 bits. In theory,
7861da177e4SLinus Torvalds Extended LUN Format CCBs can support up to 64 Logical Units, but in practice
7871da177e4SLinus Torvalds many devices will respond improperly to Logical Units between 32 and 63, and
7881da177e4SLinus Torvalds the SCSI-2 specification defines Bit 5 as LUNTAR. Extended LUN Format CCBs
7891da177e4SLinus Torvalds are used by recent versions of the MultiMaster Firmware, as well as by the
7901da177e4SLinus Torvalds FlashPoint SCCB Manager; the FlashPoint SCCB Manager only supports 32 Logical
7911da177e4SLinus Torvalds Units. Since 64 Logical Units are unlikely to be needed in practice, and
7921da177e4SLinus Torvalds since they are problematic for the above reasons, and since limiting them to
7931da177e4SLinus Torvalds 5 bits simplifies the CCB structure definition, this driver only supports
7941da177e4SLinus Torvalds 32 Logical Units per Target Device.
7951da177e4SLinus Torvalds */
7961da177e4SLinus Torvalds
797839cb99eSKhalid Aziz struct blogic_ccb {
7981da177e4SLinus Torvalds /*
7991da177e4SLinus Torvalds MultiMaster Firmware and FlashPoint SCCB Manager Common Portion.
8001da177e4SLinus Torvalds */
801839cb99eSKhalid Aziz enum blogic_ccb_opcode opcode; /* Byte 0 */
8021da177e4SLinus Torvalds unsigned char:3; /* Byte 1 Bits 0-2 */
803839cb99eSKhalid Aziz enum blogic_datadir datadir:2; /* Byte 1 Bits 3-4 */
804839cb99eSKhalid Aziz bool tag_enable:1; /* Byte 1 Bit 5 */
805839cb99eSKhalid Aziz enum blogic_queuetag queuetag:2; /* Byte 1 Bits 6-7 */
806839cb99eSKhalid Aziz unsigned char cdblen; /* Byte 2 */
807839cb99eSKhalid Aziz unsigned char sense_datalen; /* Byte 3 */
808839cb99eSKhalid Aziz u32 datalen; /* Bytes 4-7 */
809*56f39614SMatt Wang u32 data; /* Bytes 8-11 */
8101da177e4SLinus Torvalds unsigned char:8; /* Byte 12 */
8111da177e4SLinus Torvalds unsigned char:8; /* Byte 13 */
812839cb99eSKhalid Aziz enum blogic_adapter_status adapter_status; /* Byte 14 */
813839cb99eSKhalid Aziz enum blogic_tgt_status tgt_status; /* Byte 15 */
814839cb99eSKhalid Aziz unsigned char tgt_id; /* Byte 16 */
815839cb99eSKhalid Aziz unsigned char lun:5; /* Byte 17 Bits 0-4 */
816839cb99eSKhalid Aziz bool legacytag_enable:1; /* Byte 17 Bit 5 */
817839cb99eSKhalid Aziz enum blogic_queuetag legacy_tag:2; /* Byte 17 Bits 6-7 */
818839cb99eSKhalid Aziz unsigned char cdb[BLOGIC_CDB_MAXLEN]; /* Bytes 18-29 */
8191da177e4SLinus Torvalds unsigned char:8; /* Byte 30 */
8201da177e4SLinus Torvalds unsigned char:8; /* Byte 31 */
821391e2f25SKhalid Aziz u32 rsvd_int; /* Bytes 32-35 */
822839cb99eSKhalid Aziz u32 sensedata; /* Bytes 36-39 */
8231da177e4SLinus Torvalds /*
8241da177e4SLinus Torvalds FlashPoint SCCB Manager Defined Portion.
8251da177e4SLinus Torvalds */
826839cb99eSKhalid Aziz void (*callback) (struct blogic_ccb *); /* Bytes 40-43 */
827839cb99eSKhalid Aziz u32 base_addr; /* Bytes 44-47 */
828839cb99eSKhalid Aziz enum blogic_cmplt_code comp_code; /* Byte 48 */
82978b4b05dSMatthew Wilcox #ifdef CONFIG_SCSI_FLASHPOINT
8301da177e4SLinus Torvalds unsigned char:8; /* Byte 49 */
831391e2f25SKhalid Aziz u16 os_flags; /* Bytes 50-51 */
832391e2f25SKhalid Aziz unsigned char private[24]; /* Bytes 52-99 */
833391e2f25SKhalid Aziz void *rsvd1;
834391e2f25SKhalid Aziz void *rsvd2;
835391e2f25SKhalid Aziz unsigned char private2[16];
8361da177e4SLinus Torvalds #endif
8371da177e4SLinus Torvalds /*
8381da177e4SLinus Torvalds BusLogic Linux Driver Defined Portion.
8391da177e4SLinus Torvalds */
840839cb99eSKhalid Aziz dma_addr_t allocgrp_head;
841839cb99eSKhalid Aziz unsigned int allocgrp_size;
842839cb99eSKhalid Aziz u32 dma_handle;
843839cb99eSKhalid Aziz enum blogic_ccb_status status;
844839cb99eSKhalid Aziz unsigned long serial;
845839cb99eSKhalid Aziz struct scsi_cmnd *command;
846839cb99eSKhalid Aziz struct blogic_adapter *adapter;
847839cb99eSKhalid Aziz struct blogic_ccb *next;
848839cb99eSKhalid Aziz struct blogic_ccb *next_all;
849839cb99eSKhalid Aziz struct blogic_sg_seg sglist[BLOGIC_SG_LIMIT];
8501da177e4SLinus Torvalds };
8511da177e4SLinus Torvalds
8521da177e4SLinus Torvalds /*
8531da177e4SLinus Torvalds Define the 32 Bit Mode Outgoing Mailbox structure.
8541da177e4SLinus Torvalds */
8551da177e4SLinus Torvalds
856839cb99eSKhalid Aziz struct blogic_outbox {
857839cb99eSKhalid Aziz u32 ccb; /* Bytes 0-3 */
858391e2f25SKhalid Aziz u32:24; /* Bytes 4-6 */
859839cb99eSKhalid Aziz enum blogic_action action; /* Byte 7 */
8601da177e4SLinus Torvalds };
8611da177e4SLinus Torvalds
8621da177e4SLinus Torvalds /*
8631da177e4SLinus Torvalds Define the 32 Bit Mode Incoming Mailbox structure.
8641da177e4SLinus Torvalds */
8651da177e4SLinus Torvalds
866839cb99eSKhalid Aziz struct blogic_inbox {
867839cb99eSKhalid Aziz u32 ccb; /* Bytes 0-3 */
868839cb99eSKhalid Aziz enum blogic_adapter_status adapter_status; /* Byte 4 */
869839cb99eSKhalid Aziz enum blogic_tgt_status tgt_status; /* Byte 5 */
8701da177e4SLinus Torvalds unsigned char:8; /* Byte 6 */
871839cb99eSKhalid Aziz enum blogic_cmplt_code comp_code; /* Byte 7 */
8721da177e4SLinus Torvalds };
8731da177e4SLinus Torvalds
8741da177e4SLinus Torvalds
8751da177e4SLinus Torvalds /*
8761da177e4SLinus Torvalds Define the BusLogic Driver Options structure.
8771da177e4SLinus Torvalds */
8781da177e4SLinus Torvalds
879839cb99eSKhalid Aziz struct blogic_drvr_options {
880839cb99eSKhalid Aziz unsigned short tagq_ok;
881839cb99eSKhalid Aziz unsigned short tagq_ok_mask;
882839cb99eSKhalid Aziz unsigned short bus_settle_time;
883839cb99eSKhalid Aziz unsigned short stop_tgt_inquiry;
884839cb99eSKhalid Aziz unsigned char common_qdepth;
885839cb99eSKhalid Aziz unsigned char qdepth[BLOGIC_MAXDEV];
8861da177e4SLinus Torvalds };
8871da177e4SLinus Torvalds
8881da177e4SLinus Torvalds /*
8891da177e4SLinus Torvalds Define the Host Adapter Target Flags structure.
8901da177e4SLinus Torvalds */
8911da177e4SLinus Torvalds
892839cb99eSKhalid Aziz struct blogic_tgt_flags {
893839cb99eSKhalid Aziz bool tgt_exists:1;
894839cb99eSKhalid Aziz bool tagq_ok:1;
895839cb99eSKhalid Aziz bool wide_ok:1;
896839cb99eSKhalid Aziz bool tagq_active:1;
897839cb99eSKhalid Aziz bool wide_active:1;
898839cb99eSKhalid Aziz bool cmd_good:1;
899839cb99eSKhalid Aziz bool tgt_info_in:1;
9001da177e4SLinus Torvalds };
9011da177e4SLinus Torvalds
9021da177e4SLinus Torvalds /*
9031da177e4SLinus Torvalds Define the Host Adapter Target Statistics structure.
9041da177e4SLinus Torvalds */
9051da177e4SLinus Torvalds
906839cb99eSKhalid Aziz #define BLOGIC_SZ_BUCKETS 10
9071da177e4SLinus Torvalds
908839cb99eSKhalid Aziz struct blogic_tgt_stats {
909839cb99eSKhalid Aziz unsigned int cmds_tried;
910839cb99eSKhalid Aziz unsigned int cmds_complete;
911839cb99eSKhalid Aziz unsigned int read_cmds;
912839cb99eSKhalid Aziz unsigned int write_cmds;
913839cb99eSKhalid Aziz struct blogic_byte_count bytesread;
914839cb99eSKhalid Aziz struct blogic_byte_count byteswritten;
915839cb99eSKhalid Aziz unsigned int read_sz_buckets[BLOGIC_SZ_BUCKETS];
916839cb99eSKhalid Aziz unsigned int write_sz_buckets[BLOGIC_SZ_BUCKETS];
917839cb99eSKhalid Aziz unsigned short aborts_request;
918839cb99eSKhalid Aziz unsigned short aborts_tried;
919839cb99eSKhalid Aziz unsigned short aborts_done;
920839cb99eSKhalid Aziz unsigned short bdr_request;
921839cb99eSKhalid Aziz unsigned short bdr_tried;
922839cb99eSKhalid Aziz unsigned short bdr_done;
92320961065SColin Ian King unsigned short adapter_reset_req;
924839cb99eSKhalid Aziz unsigned short adapter_reset_attempt;
925839cb99eSKhalid Aziz unsigned short adapter_reset_done;
9261da177e4SLinus Torvalds };
9271da177e4SLinus Torvalds
9281da177e4SLinus Torvalds /*
9291da177e4SLinus Torvalds Define the FlashPoint Card Handle data type.
9301da177e4SLinus Torvalds */
9311da177e4SLinus Torvalds
932391e2f25SKhalid Aziz #define FPOINT_BADCARD_HANDLE 0xFFFFFFFFL
9331da177e4SLinus Torvalds
9341da177e4SLinus Torvalds
9351da177e4SLinus Torvalds /*
9361da177e4SLinus Torvalds Define the FlashPoint Information structure. This structure is defined
9371da177e4SLinus Torvalds by the FlashPoint SCCB Manager.
9381da177e4SLinus Torvalds */
9391da177e4SLinus Torvalds
940839cb99eSKhalid Aziz struct fpoint_info {
941839cb99eSKhalid Aziz u32 base_addr; /* Bytes 0-3 */
942839cb99eSKhalid Aziz bool present; /* Byte 4 */
943839cb99eSKhalid Aziz unsigned char irq_ch; /* Byte 5 */
944839cb99eSKhalid Aziz unsigned char scsi_id; /* Byte 6 */
945839cb99eSKhalid Aziz unsigned char scsi_lun; /* Byte 7 */
946391e2f25SKhalid Aziz u16 fw_rev; /* Bytes 8-9 */
947391e2f25SKhalid Aziz u16 sync_ok; /* Bytes 10-11 */
948391e2f25SKhalid Aziz u16 fast_ok; /* Bytes 12-13 */
949391e2f25SKhalid Aziz u16 ultra_ok; /* Bytes 14-15 */
950391e2f25SKhalid Aziz u16 discon_ok; /* Bytes 16-17 */
951391e2f25SKhalid Aziz u16 wide_ok; /* Bytes 18-19 */
952839cb99eSKhalid Aziz bool parity:1; /* Byte 20 Bit 0 */
953839cb99eSKhalid Aziz bool wide:1; /* Byte 20 Bit 1 */
954839cb99eSKhalid Aziz bool softreset:1; /* Byte 20 Bit 2 */
955839cb99eSKhalid Aziz bool ext_trans_enable:1; /* Byte 20 Bit 3 */
956839cb99eSKhalid Aziz bool low_term:1; /* Byte 20 Bit 4 */
957839cb99eSKhalid Aziz bool high_term:1; /* Byte 20 Bit 5 */
958839cb99eSKhalid Aziz bool report_underrun:1; /* Byte 20 Bit 6 */
959839cb99eSKhalid Aziz bool scam_enabled:1; /* Byte 20 Bit 7 */
960839cb99eSKhalid Aziz bool scam_lev2:1; /* Byte 21 Bit 0 */
9611da177e4SLinus Torvalds unsigned char:7; /* Byte 21 Bits 1-7 */
962839cb99eSKhalid Aziz unsigned char family; /* Byte 22 */
963839cb99eSKhalid Aziz unsigned char bus_type; /* Byte 23 */
964839cb99eSKhalid Aziz unsigned char model[3]; /* Bytes 24-26 */
965839cb99eSKhalid Aziz unsigned char relative_cardnum; /* Byte 27 */
966839cb99eSKhalid Aziz unsigned char rsvd[4]; /* Bytes 28-31 */
967391e2f25SKhalid Aziz u32 os_rsvd; /* Bytes 32-35 */
968839cb99eSKhalid Aziz unsigned char translation_info[4]; /* Bytes 36-39 */
969391e2f25SKhalid Aziz u32 rsvd2[5]; /* Bytes 40-59 */
970391e2f25SKhalid Aziz u32 sec_range; /* Bytes 60-63 */
9711da177e4SLinus Torvalds };
9721da177e4SLinus Torvalds
9731da177e4SLinus Torvalds /*
9741da177e4SLinus Torvalds Define the BusLogic Driver Host Adapter structure.
9751da177e4SLinus Torvalds */
9761da177e4SLinus Torvalds
977839cb99eSKhalid Aziz struct blogic_adapter {
978839cb99eSKhalid Aziz struct Scsi_Host *scsi_host;
979839cb99eSKhalid Aziz struct pci_dev *pci_device;
980839cb99eSKhalid Aziz enum blogic_adapter_type adapter_type;
981839cb99eSKhalid Aziz enum blogic_adapter_bus_type adapter_bus_type;
982839cb99eSKhalid Aziz unsigned long io_addr;
983839cb99eSKhalid Aziz unsigned long pci_addr;
984839cb99eSKhalid Aziz unsigned short addr_count;
985839cb99eSKhalid Aziz unsigned char host_no;
986839cb99eSKhalid Aziz unsigned char model[9];
987839cb99eSKhalid Aziz unsigned char fw_ver[6];
988839cb99eSKhalid Aziz unsigned char full_model[18];
989839cb99eSKhalid Aziz unsigned char bus;
990839cb99eSKhalid Aziz unsigned char dev;
991839cb99eSKhalid Aziz unsigned char irq_ch;
992839cb99eSKhalid Aziz unsigned char scsi_id;
993839cb99eSKhalid Aziz bool irq_acquired:1;
994839cb99eSKhalid Aziz bool ext_trans_enable:1;
995839cb99eSKhalid Aziz bool parity:1;
996839cb99eSKhalid Aziz bool reset_enabled:1;
997839cb99eSKhalid Aziz bool level_int:1;
998839cb99eSKhalid Aziz bool wide:1;
999839cb99eSKhalid Aziz bool differential:1;
1000839cb99eSKhalid Aziz bool scam:1;
1001839cb99eSKhalid Aziz bool ultra:1;
1002839cb99eSKhalid Aziz bool ext_lun:1;
1003839cb99eSKhalid Aziz bool terminfo_valid:1;
1004839cb99eSKhalid Aziz bool low_term:1;
1005839cb99eSKhalid Aziz bool high_term:1;
1006839cb99eSKhalid Aziz bool strict_rr:1;
1007839cb99eSKhalid Aziz bool scam_enabled:1;
1008839cb99eSKhalid Aziz bool scam_lev2:1;
1009839cb99eSKhalid Aziz bool adapter_initd:1;
1010839cb99eSKhalid Aziz bool adapter_extreset:1;
1011839cb99eSKhalid Aziz bool adapter_intern_err:1;
1012839cb99eSKhalid Aziz bool processing_ccbs;
1013839cb99eSKhalid Aziz volatile bool adapter_cmd_complete;
1014839cb99eSKhalid Aziz unsigned short adapter_sglimit;
1015839cb99eSKhalid Aziz unsigned short drvr_sglimit;
1016839cb99eSKhalid Aziz unsigned short maxdev;
1017839cb99eSKhalid Aziz unsigned short maxlun;
1018839cb99eSKhalid Aziz unsigned short mbox_count;
1019839cb99eSKhalid Aziz unsigned short initccbs;
1020839cb99eSKhalid Aziz unsigned short inc_ccbs;
1021839cb99eSKhalid Aziz unsigned short alloc_ccbs;
1022839cb99eSKhalid Aziz unsigned short drvr_qdepth;
1023839cb99eSKhalid Aziz unsigned short adapter_qdepth;
1024839cb99eSKhalid Aziz unsigned short untag_qdepth;
1025839cb99eSKhalid Aziz unsigned short common_qdepth;
1026839cb99eSKhalid Aziz unsigned short bus_settle_time;
1027839cb99eSKhalid Aziz unsigned short sync_ok;
1028839cb99eSKhalid Aziz unsigned short fast_ok;
1029839cb99eSKhalid Aziz unsigned short ultra_ok;
1030839cb99eSKhalid Aziz unsigned short wide_ok;
1031839cb99eSKhalid Aziz unsigned short discon_ok;
1032839cb99eSKhalid Aziz unsigned short tagq_ok;
1033839cb99eSKhalid Aziz unsigned short ext_resets;
1034839cb99eSKhalid Aziz unsigned short adapter_intern_errors;
1035839cb99eSKhalid Aziz unsigned short tgt_count;
1036839cb99eSKhalid Aziz unsigned short msgbuflen;
1037839cb99eSKhalid Aziz u32 bios_addr;
1038839cb99eSKhalid Aziz struct blogic_drvr_options *drvr_opts;
1039839cb99eSKhalid Aziz struct fpoint_info fpinfo;
1040391e2f25SKhalid Aziz void *cardhandle;
10411da177e4SLinus Torvalds struct list_head host_list;
1042839cb99eSKhalid Aziz struct blogic_ccb *all_ccbs;
1043839cb99eSKhalid Aziz struct blogic_ccb *free_ccbs;
1044839cb99eSKhalid Aziz struct blogic_ccb *firstccb;
1045839cb99eSKhalid Aziz struct blogic_ccb *lastccb;
1046839cb99eSKhalid Aziz struct blogic_ccb *bdr_pend[BLOGIC_MAXDEV];
1047839cb99eSKhalid Aziz struct blogic_tgt_flags tgt_flags[BLOGIC_MAXDEV];
1048839cb99eSKhalid Aziz unsigned char qdepth[BLOGIC_MAXDEV];
1049839cb99eSKhalid Aziz unsigned char sync_period[BLOGIC_MAXDEV];
1050839cb99eSKhalid Aziz unsigned char sync_offset[BLOGIC_MAXDEV];
1051839cb99eSKhalid Aziz unsigned char active_cmds[BLOGIC_MAXDEV];
1052839cb99eSKhalid Aziz unsigned int cmds_since_rst[BLOGIC_MAXDEV];
1053839cb99eSKhalid Aziz unsigned long last_seqpoint[BLOGIC_MAXDEV];
1054839cb99eSKhalid Aziz unsigned long last_resettried[BLOGIC_MAXDEV];
1055839cb99eSKhalid Aziz unsigned long last_resetdone[BLOGIC_MAXDEV];
1056839cb99eSKhalid Aziz struct blogic_outbox *first_outbox;
1057839cb99eSKhalid Aziz struct blogic_outbox *last_outbox;
1058839cb99eSKhalid Aziz struct blogic_outbox *next_outbox;
1059839cb99eSKhalid Aziz struct blogic_inbox *first_inbox;
1060839cb99eSKhalid Aziz struct blogic_inbox *last_inbox;
1061839cb99eSKhalid Aziz struct blogic_inbox *next_inbox;
1062839cb99eSKhalid Aziz struct blogic_tgt_stats tgt_stats[BLOGIC_MAXDEV];
1063839cb99eSKhalid Aziz unsigned char *mbox_space;
1064839cb99eSKhalid Aziz dma_addr_t mbox_space_handle;
1065839cb99eSKhalid Aziz unsigned int mbox_sz;
1066839cb99eSKhalid Aziz unsigned long ccb_offset;
1067839cb99eSKhalid Aziz char msgbuf[BLOGIC_MSGBUF_SIZE];
10681da177e4SLinus Torvalds };
10691da177e4SLinus Torvalds
10701da177e4SLinus Torvalds /*
10711da177e4SLinus Torvalds Define a structure for the BIOS Disk Parameters.
10721da177e4SLinus Torvalds */
10731da177e4SLinus Torvalds
1074839cb99eSKhalid Aziz struct bios_diskparam {
1075839cb99eSKhalid Aziz int heads;
1076839cb99eSKhalid Aziz int sectors;
1077839cb99eSKhalid Aziz int cylinders;
10781da177e4SLinus Torvalds };
10791da177e4SLinus Torvalds
10801da177e4SLinus Torvalds /*
10811da177e4SLinus Torvalds Define a structure for the SCSI Inquiry command results.
10821da177e4SLinus Torvalds */
10831da177e4SLinus Torvalds
1084839cb99eSKhalid Aziz struct scsi_inquiry {
1085839cb99eSKhalid Aziz unsigned char devtype:5; /* Byte 0 Bits 0-4 */
1086839cb99eSKhalid Aziz unsigned char dev_qual:3; /* Byte 0 Bits 5-7 */
1087839cb99eSKhalid Aziz unsigned char dev_modifier:7; /* Byte 1 Bits 0-6 */
1088839cb99eSKhalid Aziz bool rmb:1; /* Byte 1 Bit 7 */
1089839cb99eSKhalid Aziz unsigned char ansi_ver:3; /* Byte 2 Bits 0-2 */
1090839cb99eSKhalid Aziz unsigned char ecma_ver:3; /* Byte 2 Bits 3-5 */
1091839cb99eSKhalid Aziz unsigned char iso_ver:2; /* Byte 2 Bits 6-7 */
1092839cb99eSKhalid Aziz unsigned char resp_fmt:4; /* Byte 3 Bits 0-3 */
10931da177e4SLinus Torvalds unsigned char:2; /* Byte 3 Bits 4-5 */
10942065e310SRichard Knutsson bool TrmIOP:1; /* Byte 3 Bit 6 */
10952065e310SRichard Knutsson bool AENC:1; /* Byte 3 Bit 7 */
1096839cb99eSKhalid Aziz unsigned char addl_len; /* Byte 4 */
10971da177e4SLinus Torvalds unsigned char:8; /* Byte 5 */
10981da177e4SLinus Torvalds unsigned char:8; /* Byte 6 */
10992065e310SRichard Knutsson bool SftRe:1; /* Byte 7 Bit 0 */
11002065e310SRichard Knutsson bool CmdQue:1; /* Byte 7 Bit 1 */
11012065e310SRichard Knutsson bool:1; /* Byte 7 Bit 2 */
1102839cb99eSKhalid Aziz bool linked:1; /* Byte 7 Bit 3 */
1103839cb99eSKhalid Aziz bool sync:1; /* Byte 7 Bit 4 */
11042065e310SRichard Knutsson bool WBus16:1; /* Byte 7 Bit 5 */
11052065e310SRichard Knutsson bool WBus32:1; /* Byte 7 Bit 6 */
11062065e310SRichard Knutsson bool RelAdr:1; /* Byte 7 Bit 7 */
1107839cb99eSKhalid Aziz unsigned char vendor[8]; /* Bytes 8-15 */
1108839cb99eSKhalid Aziz unsigned char product[16]; /* Bytes 16-31 */
1109839cb99eSKhalid Aziz unsigned char product_rev[4]; /* Bytes 32-35 */
11101da177e4SLinus Torvalds };
11111da177e4SLinus Torvalds
11121da177e4SLinus Torvalds
11131da177e4SLinus Torvalds /*
11141da177e4SLinus Torvalds Define functions to provide an abstraction for reading and writing the
11151da177e4SLinus Torvalds Host Adapter I/O Registers.
11161da177e4SLinus Torvalds */
11171da177e4SLinus Torvalds
blogic_busreset(struct blogic_adapter * adapter)1118839cb99eSKhalid Aziz static inline void blogic_busreset(struct blogic_adapter *adapter)
11191da177e4SLinus Torvalds {
1120839cb99eSKhalid Aziz union blogic_cntrl_reg cr;
1121839cb99eSKhalid Aziz cr.all = 0;
1122839cb99eSKhalid Aziz cr.cr.bus_reset = true;
1123839cb99eSKhalid Aziz outb(cr.all, adapter->io_addr + BLOGIC_CNTRL_REG);
11241da177e4SLinus Torvalds }
11251da177e4SLinus Torvalds
blogic_intreset(struct blogic_adapter * adapter)1126839cb99eSKhalid Aziz static inline void blogic_intreset(struct blogic_adapter *adapter)
11271da177e4SLinus Torvalds {
1128839cb99eSKhalid Aziz union blogic_cntrl_reg cr;
1129839cb99eSKhalid Aziz cr.all = 0;
1130839cb99eSKhalid Aziz cr.cr.int_reset = true;
1131839cb99eSKhalid Aziz outb(cr.all, adapter->io_addr + BLOGIC_CNTRL_REG);
11321da177e4SLinus Torvalds }
11331da177e4SLinus Torvalds
blogic_softreset(struct blogic_adapter * adapter)1134839cb99eSKhalid Aziz static inline void blogic_softreset(struct blogic_adapter *adapter)
11351da177e4SLinus Torvalds {
1136839cb99eSKhalid Aziz union blogic_cntrl_reg cr;
1137839cb99eSKhalid Aziz cr.all = 0;
1138839cb99eSKhalid Aziz cr.cr.soft_reset = true;
1139839cb99eSKhalid Aziz outb(cr.all, adapter->io_addr + BLOGIC_CNTRL_REG);
11401da177e4SLinus Torvalds }
11411da177e4SLinus Torvalds
blogic_hardreset(struct blogic_adapter * adapter)1142839cb99eSKhalid Aziz static inline void blogic_hardreset(struct blogic_adapter *adapter)
11431da177e4SLinus Torvalds {
1144839cb99eSKhalid Aziz union blogic_cntrl_reg cr;
1145839cb99eSKhalid Aziz cr.all = 0;
1146839cb99eSKhalid Aziz cr.cr.hard_reset = true;
1147839cb99eSKhalid Aziz outb(cr.all, adapter->io_addr + BLOGIC_CNTRL_REG);
11481da177e4SLinus Torvalds }
11491da177e4SLinus Torvalds
blogic_rdstatus(struct blogic_adapter * adapter)1150839cb99eSKhalid Aziz static inline unsigned char blogic_rdstatus(struct blogic_adapter *adapter)
11511da177e4SLinus Torvalds {
1152839cb99eSKhalid Aziz return inb(adapter->io_addr + BLOGIC_STATUS_REG);
11531da177e4SLinus Torvalds }
11541da177e4SLinus Torvalds
blogic_setcmdparam(struct blogic_adapter * adapter,unsigned char value)1155839cb99eSKhalid Aziz static inline void blogic_setcmdparam(struct blogic_adapter *adapter,
1156839cb99eSKhalid Aziz unsigned char value)
11571da177e4SLinus Torvalds {
1158839cb99eSKhalid Aziz outb(value, adapter->io_addr + BLOGIC_CMD_PARM_REG);
11591da177e4SLinus Torvalds }
11601da177e4SLinus Torvalds
blogic_rddatain(struct blogic_adapter * adapter)1161839cb99eSKhalid Aziz static inline unsigned char blogic_rddatain(struct blogic_adapter *adapter)
11621da177e4SLinus Torvalds {
1163839cb99eSKhalid Aziz return inb(adapter->io_addr + BLOGIC_DATAIN_REG);
11641da177e4SLinus Torvalds }
11651da177e4SLinus Torvalds
blogic_rdint(struct blogic_adapter * adapter)1166839cb99eSKhalid Aziz static inline unsigned char blogic_rdint(struct blogic_adapter *adapter)
11671da177e4SLinus Torvalds {
1168839cb99eSKhalid Aziz return inb(adapter->io_addr + BLOGIC_INT_REG);
11691da177e4SLinus Torvalds }
11701da177e4SLinus Torvalds
blogic_rdgeom(struct blogic_adapter * adapter)1171839cb99eSKhalid Aziz static inline unsigned char blogic_rdgeom(struct blogic_adapter *adapter)
11721da177e4SLinus Torvalds {
1173839cb99eSKhalid Aziz return inb(adapter->io_addr + BLOGIC_GEOMETRY_REG);
11741da177e4SLinus Torvalds }
11751da177e4SLinus Torvalds
11761da177e4SLinus Torvalds /*
1177839cb99eSKhalid Aziz blogic_execmbox issues an Execute Mailbox Command, which
11781da177e4SLinus Torvalds notifies the Host Adapter that an entry has been made in an Outgoing
11791da177e4SLinus Torvalds Mailbox.
11801da177e4SLinus Torvalds */
11811da177e4SLinus Torvalds
blogic_execmbox(struct blogic_adapter * adapter)1182839cb99eSKhalid Aziz static inline void blogic_execmbox(struct blogic_adapter *adapter)
11831da177e4SLinus Torvalds {
1184839cb99eSKhalid Aziz blogic_setcmdparam(adapter, BLOGIC_EXEC_MBOX_CMD);
11851da177e4SLinus Torvalds }
11861da177e4SLinus Torvalds
11871da177e4SLinus Torvalds /*
1188839cb99eSKhalid Aziz blogic_delay waits for Seconds to elapse.
11891da177e4SLinus Torvalds */
11901da177e4SLinus Torvalds
blogic_delay(int seconds)1191839cb99eSKhalid Aziz static inline void blogic_delay(int seconds)
11921da177e4SLinus Torvalds {
1193839cb99eSKhalid Aziz mdelay(1000 * seconds);
11941da177e4SLinus Torvalds }
11951da177e4SLinus Torvalds
11961da177e4SLinus Torvalds /*
1197839cb99eSKhalid Aziz virt_to_32bit_virt maps between Kernel Virtual Addresses and
11981da177e4SLinus Torvalds 32 bit Kernel Virtual Addresses. This avoids compilation warnings
11991da177e4SLinus Torvalds on 64 bit architectures.
12001da177e4SLinus Torvalds */
12011da177e4SLinus Torvalds
virt_to_32bit_virt(void * virt_addr)1202839cb99eSKhalid Aziz static inline u32 virt_to_32bit_virt(void *virt_addr)
12031da177e4SLinus Torvalds {
1204839cb99eSKhalid Aziz return (u32) (unsigned long) virt_addr;
12051da177e4SLinus Torvalds }
12061da177e4SLinus Torvalds
12071da177e4SLinus Torvalds /*
1208839cb99eSKhalid Aziz blogic_inc_count increments counter by 1, stopping at
12091da177e4SLinus Torvalds 65535 rather than wrapping around to 0.
12101da177e4SLinus Torvalds */
12111da177e4SLinus Torvalds
blogic_inc_count(unsigned short * count)1212839cb99eSKhalid Aziz static inline void blogic_inc_count(unsigned short *count)
12131da177e4SLinus Torvalds {
1214839cb99eSKhalid Aziz if (*count < 65535)
1215839cb99eSKhalid Aziz (*count)++;
12161da177e4SLinus Torvalds }
12171da177e4SLinus Torvalds
12181da177e4SLinus Torvalds /*
1219839cb99eSKhalid Aziz blogic_addcount increments Byte Counter by Amount.
12201da177e4SLinus Torvalds */
12211da177e4SLinus Torvalds
blogic_addcount(struct blogic_byte_count * bytecount,unsigned int amount)1222839cb99eSKhalid Aziz static inline void blogic_addcount(struct blogic_byte_count *bytecount,
1223839cb99eSKhalid Aziz unsigned int amount)
12241da177e4SLinus Torvalds {
1225839cb99eSKhalid Aziz bytecount->units += amount;
1226839cb99eSKhalid Aziz if (bytecount->units > 999999999) {
1227839cb99eSKhalid Aziz bytecount->units -= 1000000000;
1228839cb99eSKhalid Aziz bytecount->billions++;
12291da177e4SLinus Torvalds }
12301da177e4SLinus Torvalds }
12311da177e4SLinus Torvalds
12321da177e4SLinus Torvalds /*
1233839cb99eSKhalid Aziz blogic_incszbucket increments the Bucket for Amount.
12341da177e4SLinus Torvalds */
12351da177e4SLinus Torvalds
blogic_incszbucket(unsigned int * cmdsz_buckets,unsigned int amount)1236839cb99eSKhalid Aziz static inline void blogic_incszbucket(unsigned int *cmdsz_buckets,
1237839cb99eSKhalid Aziz unsigned int amount)
12381da177e4SLinus Torvalds {
1239839cb99eSKhalid Aziz int index = 0;
1240839cb99eSKhalid Aziz if (amount < 8 * 1024) {
1241839cb99eSKhalid Aziz if (amount < 2 * 1024)
1242839cb99eSKhalid Aziz index = (amount < 1 * 1024 ? 0 : 1);
12431da177e4SLinus Torvalds else
1244839cb99eSKhalid Aziz index = (amount < 4 * 1024 ? 2 : 3);
1245839cb99eSKhalid Aziz } else if (amount < 128 * 1024) {
1246839cb99eSKhalid Aziz if (amount < 32 * 1024)
1247839cb99eSKhalid Aziz index = (amount < 16 * 1024 ? 4 : 5);
12481da177e4SLinus Torvalds else
1249839cb99eSKhalid Aziz index = (amount < 64 * 1024 ? 6 : 7);
12501da177e4SLinus Torvalds } else
1251839cb99eSKhalid Aziz index = (amount < 256 * 1024 ? 8 : 9);
1252839cb99eSKhalid Aziz cmdsz_buckets[index]++;
12531da177e4SLinus Torvalds }
12541da177e4SLinus Torvalds
12551da177e4SLinus Torvalds /*
12561da177e4SLinus Torvalds Define the version number of the FlashPoint Firmware (SCCB Manager).
12571da177e4SLinus Torvalds */
12581da177e4SLinus Torvalds
1259839cb99eSKhalid Aziz #define FLASHPOINT_FW_VER "5.02"
12601da177e4SLinus Torvalds
12611da177e4SLinus Torvalds /*
12621da177e4SLinus Torvalds Define the possible return values from FlashPoint_HandleInterrupt.
12631da177e4SLinus Torvalds */
12641da177e4SLinus Torvalds
1265839cb99eSKhalid Aziz #define FPOINT_NORMAL_INT 0x00
1266839cb99eSKhalid Aziz #define FPOINT_INTERN_ERR 0xFE
1267839cb99eSKhalid Aziz #define FPOINT_EXT_RESET 0xFF
12681da177e4SLinus Torvalds
12691da177e4SLinus Torvalds /*
12701da177e4SLinus Torvalds Define prototypes for the forward referenced BusLogic Driver
12711da177e4SLinus Torvalds Internal Functions.
12721da177e4SLinus Torvalds */
12731da177e4SLinus Torvalds
1274839cb99eSKhalid Aziz static const char *blogic_drvr_info(struct Scsi_Host *);
1275839cb99eSKhalid Aziz static int blogic_qcmd(struct Scsi_Host *h, struct scsi_cmnd *);
1276839cb99eSKhalid Aziz static int blogic_diskparam(struct scsi_device *, struct block_device *, sector_t, int *);
1277839cb99eSKhalid Aziz static int blogic_slaveconfig(struct scsi_device *);
1278839cb99eSKhalid Aziz static void blogic_qcompleted_ccb(struct blogic_ccb *);
1279839cb99eSKhalid Aziz static irqreturn_t blogic_inthandler(int, void *);
1280839cb99eSKhalid Aziz static int blogic_resetadapter(struct blogic_adapter *, bool hard_reset);
1281839cb99eSKhalid Aziz static void blogic_msg(enum blogic_msglevel, char *, struct blogic_adapter *, ...);
1282839cb99eSKhalid Aziz static int __init blogic_setup(char *);
12831da177e4SLinus Torvalds
12841da177e4SLinus Torvalds #endif /* _BUSLOGIC_H */
1285