18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci
48c2ecf20Sopenharmony_ci  Linux Driver for BusLogic MultiMaster and FlashPoint SCSI Host Adapters
58c2ecf20Sopenharmony_ci
68c2ecf20Sopenharmony_ci  Copyright 1995-1998 by Leonard N. Zubkoff <lnz@dandelion.com>
78c2ecf20Sopenharmony_ci
88c2ecf20Sopenharmony_ci
98c2ecf20Sopenharmony_ci  The author respectfully requests that any modifications to this software be
108c2ecf20Sopenharmony_ci  sent directly to him for evaluation and testing.
118c2ecf20Sopenharmony_ci
128c2ecf20Sopenharmony_ci  Special thanks to Wayne Yen, Jin-Lon Hon, and Alex Win of BusLogic, whose
138c2ecf20Sopenharmony_ci  advice has been invaluable, to David Gentzel, for writing the original Linux
148c2ecf20Sopenharmony_ci  BusLogic driver, and to Paul Gortmaker, for being such a dedicated test site.
158c2ecf20Sopenharmony_ci
168c2ecf20Sopenharmony_ci  Finally, special thanks to Mylex/BusLogic for making the FlashPoint SCCB
178c2ecf20Sopenharmony_ci  Manager available as freely redistributable source code.
188c2ecf20Sopenharmony_ci
198c2ecf20Sopenharmony_ci*/
208c2ecf20Sopenharmony_ci
218c2ecf20Sopenharmony_ci#ifndef _BUSLOGIC_H
228c2ecf20Sopenharmony_ci#define _BUSLOGIC_H
238c2ecf20Sopenharmony_ci
248c2ecf20Sopenharmony_ci
258c2ecf20Sopenharmony_ci#ifndef PACKED
268c2ecf20Sopenharmony_ci#define PACKED __attribute__((packed))
278c2ecf20Sopenharmony_ci#endif
288c2ecf20Sopenharmony_ci
298c2ecf20Sopenharmony_ci/*
308c2ecf20Sopenharmony_ci  Define the maximum number of BusLogic Host Adapters supported by this driver.
318c2ecf20Sopenharmony_ci*/
328c2ecf20Sopenharmony_ci
338c2ecf20Sopenharmony_ci#define BLOGIC_MAX_ADAPTERS		16
348c2ecf20Sopenharmony_ci
358c2ecf20Sopenharmony_ci
368c2ecf20Sopenharmony_ci/*
378c2ecf20Sopenharmony_ci  Define the maximum number of Target Devices supported by this driver.
388c2ecf20Sopenharmony_ci*/
398c2ecf20Sopenharmony_ci
408c2ecf20Sopenharmony_ci#define BLOGIC_MAXDEV			16
418c2ecf20Sopenharmony_ci
428c2ecf20Sopenharmony_ci
438c2ecf20Sopenharmony_ci/*
448c2ecf20Sopenharmony_ci  Define the maximum number of Scatter/Gather Segments used by this driver.
458c2ecf20Sopenharmony_ci  For optimal performance, it is important that this limit be at least as
468c2ecf20Sopenharmony_ci  large as the largest single request generated by the I/O Subsystem.
478c2ecf20Sopenharmony_ci*/
488c2ecf20Sopenharmony_ci
498c2ecf20Sopenharmony_ci#define BLOGIC_SG_LIMIT		128
508c2ecf20Sopenharmony_ci
518c2ecf20Sopenharmony_ci
528c2ecf20Sopenharmony_ci/*
538c2ecf20Sopenharmony_ci  Define the maximum, maximum automatic, minimum automatic, and default Queue
548c2ecf20Sopenharmony_ci  Depth to allow for Target Devices depending on whether or not they support
558c2ecf20Sopenharmony_ci  Tagged Queuing and whether or not ISA Bounce Buffers are required.
568c2ecf20Sopenharmony_ci*/
578c2ecf20Sopenharmony_ci
588c2ecf20Sopenharmony_ci#define BLOGIC_MAX_TAG_DEPTH		64
598c2ecf20Sopenharmony_ci#define BLOGIC_MAX_AUTO_TAG_DEPTH	28
608c2ecf20Sopenharmony_ci#define BLOGIC_MIN_AUTO_TAG_DEPTH	7
618c2ecf20Sopenharmony_ci#define BLOGIC_TAG_DEPTH_BB		3
628c2ecf20Sopenharmony_ci#define BLOGIC_UNTAG_DEPTH		3
638c2ecf20Sopenharmony_ci#define BLOGIC_UNTAG_DEPTH_BB		2
648c2ecf20Sopenharmony_ci
658c2ecf20Sopenharmony_ci
668c2ecf20Sopenharmony_ci/*
678c2ecf20Sopenharmony_ci  Define the default amount of time in seconds to wait between a Host Adapter
688c2ecf20Sopenharmony_ci  Hard Reset which initiates a SCSI Bus Reset and issuing any SCSI commands.
698c2ecf20Sopenharmony_ci  Some SCSI devices get confused if they receive SCSI commands too soon after
708c2ecf20Sopenharmony_ci  a SCSI Bus Reset.
718c2ecf20Sopenharmony_ci*/
728c2ecf20Sopenharmony_ci
738c2ecf20Sopenharmony_ci#define BLOGIC_BUS_SETTLE_TIME		2
748c2ecf20Sopenharmony_ci
758c2ecf20Sopenharmony_ci
768c2ecf20Sopenharmony_ci/*
778c2ecf20Sopenharmony_ci  Define the maximum number of Mailboxes that should be used for MultiMaster
788c2ecf20Sopenharmony_ci  Host Adapters.  This number is chosen to be larger than the maximum Host
798c2ecf20Sopenharmony_ci  Adapter Queue Depth and small enough so that the Host Adapter structure
808c2ecf20Sopenharmony_ci  does not cross an allocation block size boundary.
818c2ecf20Sopenharmony_ci*/
828c2ecf20Sopenharmony_ci
838c2ecf20Sopenharmony_ci#define BLOGIC_MAX_MAILBOX		211
848c2ecf20Sopenharmony_ci
858c2ecf20Sopenharmony_ci
868c2ecf20Sopenharmony_ci/*
878c2ecf20Sopenharmony_ci  Define the number of CCBs that should be allocated as a group to optimize
888c2ecf20Sopenharmony_ci  Kernel memory allocation.
898c2ecf20Sopenharmony_ci*/
908c2ecf20Sopenharmony_ci
918c2ecf20Sopenharmony_ci#define BLOGIC_CCB_GRP_ALLOCSIZE	7
928c2ecf20Sopenharmony_ci
938c2ecf20Sopenharmony_ci
948c2ecf20Sopenharmony_ci/*
958c2ecf20Sopenharmony_ci  Define the Host Adapter Line and Message Buffer Sizes.
968c2ecf20Sopenharmony_ci*/
978c2ecf20Sopenharmony_ci
988c2ecf20Sopenharmony_ci#define BLOGIC_LINEBUF_SIZE		100
998c2ecf20Sopenharmony_ci#define BLOGIC_MSGBUF_SIZE		9700
1008c2ecf20Sopenharmony_ci
1018c2ecf20Sopenharmony_ci
1028c2ecf20Sopenharmony_ci/*
1038c2ecf20Sopenharmony_ci  Define the Driver Message Levels.
1048c2ecf20Sopenharmony_ci*/
1058c2ecf20Sopenharmony_ci
1068c2ecf20Sopenharmony_cienum blogic_msglevel {
1078c2ecf20Sopenharmony_ci	BLOGIC_ANNOUNCE_LEVEL = 0,
1088c2ecf20Sopenharmony_ci	BLOGIC_INFO_LEVEL = 1,
1098c2ecf20Sopenharmony_ci	BLOGIC_NOTICE_LEVEL = 2,
1108c2ecf20Sopenharmony_ci	BLOGIC_WARN_LEVEL = 3,
1118c2ecf20Sopenharmony_ci	BLOGIC_ERR_LEVEL = 4
1128c2ecf20Sopenharmony_ci};
1138c2ecf20Sopenharmony_ci
1148c2ecf20Sopenharmony_cistatic char *blogic_msglevelmap[] = { KERN_NOTICE, KERN_NOTICE, KERN_NOTICE, KERN_WARNING, KERN_ERR };
1158c2ecf20Sopenharmony_ci
1168c2ecf20Sopenharmony_ci
1178c2ecf20Sopenharmony_ci/*
1188c2ecf20Sopenharmony_ci  Define Driver Message macros.
1198c2ecf20Sopenharmony_ci*/
1208c2ecf20Sopenharmony_ci
1218c2ecf20Sopenharmony_ci#define blogic_announce(format, args...) \
1228c2ecf20Sopenharmony_ci	blogic_msg(BLOGIC_ANNOUNCE_LEVEL, format, ##args)
1238c2ecf20Sopenharmony_ci
1248c2ecf20Sopenharmony_ci#define blogic_info(format, args...) \
1258c2ecf20Sopenharmony_ci	blogic_msg(BLOGIC_INFO_LEVEL, format, ##args)
1268c2ecf20Sopenharmony_ci
1278c2ecf20Sopenharmony_ci#define blogic_notice(format, args...) \
1288c2ecf20Sopenharmony_ci	blogic_msg(BLOGIC_NOTICE_LEVEL, format, ##args)
1298c2ecf20Sopenharmony_ci
1308c2ecf20Sopenharmony_ci#define blogic_warn(format, args...) \
1318c2ecf20Sopenharmony_ci	blogic_msg(BLOGIC_WARN_LEVEL, format, ##args)
1328c2ecf20Sopenharmony_ci
1338c2ecf20Sopenharmony_ci#define blogic_err(format, args...) \
1348c2ecf20Sopenharmony_ci	blogic_msg(BLOGIC_ERR_LEVEL, format, ##args)
1358c2ecf20Sopenharmony_ci
1368c2ecf20Sopenharmony_ci
1378c2ecf20Sopenharmony_ci/*
1388c2ecf20Sopenharmony_ci  Define the types of BusLogic Host Adapters that are supported and the number
1398c2ecf20Sopenharmony_ci  of I/O Addresses required by each type.
1408c2ecf20Sopenharmony_ci*/
1418c2ecf20Sopenharmony_ci
1428c2ecf20Sopenharmony_cienum blogic_adapter_type {
1438c2ecf20Sopenharmony_ci	BLOGIC_MULTIMASTER = 1,
1448c2ecf20Sopenharmony_ci	BLOGIC_FLASHPOINT = 2
1458c2ecf20Sopenharmony_ci} PACKED;
1468c2ecf20Sopenharmony_ci
1478c2ecf20Sopenharmony_ci#define BLOGIC_MULTIMASTER_ADDR_COUNT	4
1488c2ecf20Sopenharmony_ci#define BLOGIC_FLASHPOINT_ADDR_COUNT	256
1498c2ecf20Sopenharmony_ci
1508c2ecf20Sopenharmony_cistatic int blogic_adapter_addr_count[3] = { 0, BLOGIC_MULTIMASTER_ADDR_COUNT, BLOGIC_FLASHPOINT_ADDR_COUNT };
1518c2ecf20Sopenharmony_ci
1528c2ecf20Sopenharmony_ci
1538c2ecf20Sopenharmony_ci/*
1548c2ecf20Sopenharmony_ci  Define macros for testing the Host Adapter Type.
1558c2ecf20Sopenharmony_ci*/
1568c2ecf20Sopenharmony_ci
1578c2ecf20Sopenharmony_ci#ifdef CONFIG_SCSI_FLASHPOINT
1588c2ecf20Sopenharmony_ci
1598c2ecf20Sopenharmony_ci#define blogic_multimaster_type(adapter) \
1608c2ecf20Sopenharmony_ci	(adapter->adapter_type == BLOGIC_MULTIMASTER)
1618c2ecf20Sopenharmony_ci
1628c2ecf20Sopenharmony_ci#define blogic_flashpoint_type(adapter) \
1638c2ecf20Sopenharmony_ci	(adapter->adapter_type == BLOGIC_FLASHPOINT)
1648c2ecf20Sopenharmony_ci
1658c2ecf20Sopenharmony_ci#else
1668c2ecf20Sopenharmony_ci
1678c2ecf20Sopenharmony_ci#define blogic_multimaster_type(adapter)	(true)
1688c2ecf20Sopenharmony_ci#define blogic_flashpoint_type(adapter)		(false)
1698c2ecf20Sopenharmony_ci
1708c2ecf20Sopenharmony_ci#endif
1718c2ecf20Sopenharmony_ci
1728c2ecf20Sopenharmony_ci
1738c2ecf20Sopenharmony_ci/*
1748c2ecf20Sopenharmony_ci  Define the possible Host Adapter Bus Types.
1758c2ecf20Sopenharmony_ci*/
1768c2ecf20Sopenharmony_ci
1778c2ecf20Sopenharmony_cienum blogic_adapter_bus_type {
1788c2ecf20Sopenharmony_ci	BLOGIC_UNKNOWN_BUS = 0,
1798c2ecf20Sopenharmony_ci	BLOGIC_ISA_BUS = 1,
1808c2ecf20Sopenharmony_ci	BLOGIC_EISA_BUS = 2,
1818c2ecf20Sopenharmony_ci	BLOGIC_PCI_BUS = 3,
1828c2ecf20Sopenharmony_ci	BLOGIC_VESA_BUS = 4,
1838c2ecf20Sopenharmony_ci	BLOGIC_MCA_BUS = 5
1848c2ecf20Sopenharmony_ci} PACKED;
1858c2ecf20Sopenharmony_ci
1868c2ecf20Sopenharmony_cistatic char *blogic_adapter_busnames[] = { "Unknown", "ISA", "EISA", "PCI", "VESA", "MCA" };
1878c2ecf20Sopenharmony_ci
1888c2ecf20Sopenharmony_cistatic enum blogic_adapter_bus_type blogic_adater_bus_types[] = {
1898c2ecf20Sopenharmony_ci	BLOGIC_VESA_BUS,	/* BT-4xx */
1908c2ecf20Sopenharmony_ci	BLOGIC_ISA_BUS,		/* BT-5xx */
1918c2ecf20Sopenharmony_ci	BLOGIC_MCA_BUS,		/* BT-6xx */
1928c2ecf20Sopenharmony_ci	BLOGIC_EISA_BUS,	/* BT-7xx */
1938c2ecf20Sopenharmony_ci	BLOGIC_UNKNOWN_BUS,	/* BT-8xx */
1948c2ecf20Sopenharmony_ci	BLOGIC_PCI_BUS		/* BT-9xx */
1958c2ecf20Sopenharmony_ci};
1968c2ecf20Sopenharmony_ci
1978c2ecf20Sopenharmony_ci/*
1988c2ecf20Sopenharmony_ci  Define the possible Host Adapter BIOS Disk Geometry Translations.
1998c2ecf20Sopenharmony_ci*/
2008c2ecf20Sopenharmony_ci
2018c2ecf20Sopenharmony_cienum blogic_bios_diskgeometry {
2028c2ecf20Sopenharmony_ci	BLOGIC_BIOS_NODISK = 0,
2038c2ecf20Sopenharmony_ci	BLOGIC_BIOS_DISK64x32 = 1,
2048c2ecf20Sopenharmony_ci	BLOGIC_BIOS_DISK128x32 = 2,
2058c2ecf20Sopenharmony_ci	BLOGIC_BIOS_DISK255x63 = 3
2068c2ecf20Sopenharmony_ci} PACKED;
2078c2ecf20Sopenharmony_ci
2088c2ecf20Sopenharmony_ci
2098c2ecf20Sopenharmony_ci/*
2108c2ecf20Sopenharmony_ci  Define a 10^18 Statistics Byte Counter data type.
2118c2ecf20Sopenharmony_ci*/
2128c2ecf20Sopenharmony_ci
2138c2ecf20Sopenharmony_cistruct blogic_byte_count {
2148c2ecf20Sopenharmony_ci	unsigned int units;
2158c2ecf20Sopenharmony_ci	unsigned int billions;
2168c2ecf20Sopenharmony_ci};
2178c2ecf20Sopenharmony_ci
2188c2ecf20Sopenharmony_ci
2198c2ecf20Sopenharmony_ci/*
2208c2ecf20Sopenharmony_ci  Define the structure for I/O Address and Bus Probing Information.
2218c2ecf20Sopenharmony_ci*/
2228c2ecf20Sopenharmony_ci
2238c2ecf20Sopenharmony_cistruct blogic_probeinfo {
2248c2ecf20Sopenharmony_ci	enum blogic_adapter_type adapter_type;
2258c2ecf20Sopenharmony_ci	enum blogic_adapter_bus_type adapter_bus_type;
2268c2ecf20Sopenharmony_ci	unsigned long io_addr;
2278c2ecf20Sopenharmony_ci	unsigned long pci_addr;
2288c2ecf20Sopenharmony_ci	struct pci_dev *pci_device;
2298c2ecf20Sopenharmony_ci	unsigned char bus;
2308c2ecf20Sopenharmony_ci	unsigned char dev;
2318c2ecf20Sopenharmony_ci	unsigned char irq_ch;
2328c2ecf20Sopenharmony_ci};
2338c2ecf20Sopenharmony_ci
2348c2ecf20Sopenharmony_ci/*
2358c2ecf20Sopenharmony_ci  Define the Probe Options.
2368c2ecf20Sopenharmony_ci*/
2378c2ecf20Sopenharmony_ci
2388c2ecf20Sopenharmony_cistruct blogic_probe_options {
2398c2ecf20Sopenharmony_ci	bool noprobe:1;			/* Bit 0 */
2408c2ecf20Sopenharmony_ci	bool noprobe_isa:1;		/* Bit 1 */
2418c2ecf20Sopenharmony_ci	bool noprobe_pci:1;		/* Bit 2 */
2428c2ecf20Sopenharmony_ci	bool nosort_pci:1;		/* Bit 3 */
2438c2ecf20Sopenharmony_ci	bool multimaster_first:1;	/* Bit 4 */
2448c2ecf20Sopenharmony_ci	bool flashpoint_first:1;	/* Bit 5 */
2458c2ecf20Sopenharmony_ci	bool limited_isa:1;		/* Bit 6 */
2468c2ecf20Sopenharmony_ci	bool probe330:1;		/* Bit 7 */
2478c2ecf20Sopenharmony_ci	bool probe334:1;		/* Bit 8 */
2488c2ecf20Sopenharmony_ci	bool probe230:1;		/* Bit 9 */
2498c2ecf20Sopenharmony_ci	bool probe234:1;		/* Bit 10 */
2508c2ecf20Sopenharmony_ci	bool probe130:1;		/* Bit 11 */
2518c2ecf20Sopenharmony_ci	bool probe134:1;		/* Bit 12 */
2528c2ecf20Sopenharmony_ci};
2538c2ecf20Sopenharmony_ci
2548c2ecf20Sopenharmony_ci/*
2558c2ecf20Sopenharmony_ci  Define the Global Options.
2568c2ecf20Sopenharmony_ci*/
2578c2ecf20Sopenharmony_ci
2588c2ecf20Sopenharmony_cistruct blogic_global_options {
2598c2ecf20Sopenharmony_ci	bool trace_probe:1;	/* Bit 0 */
2608c2ecf20Sopenharmony_ci	bool trace_hw_reset:1;	/* Bit 1 */
2618c2ecf20Sopenharmony_ci	bool trace_config:1;	/* Bit 2 */
2628c2ecf20Sopenharmony_ci	bool trace_err:1;	/* Bit 3 */
2638c2ecf20Sopenharmony_ci};
2648c2ecf20Sopenharmony_ci
2658c2ecf20Sopenharmony_ci/*
2668c2ecf20Sopenharmony_ci  Define the BusLogic SCSI Host Adapter I/O Register Offsets.
2678c2ecf20Sopenharmony_ci*/
2688c2ecf20Sopenharmony_ci
2698c2ecf20Sopenharmony_ci#define BLOGIC_CNTRL_REG	0	/* WO register */
2708c2ecf20Sopenharmony_ci#define BLOGIC_STATUS_REG	0	/* RO register */
2718c2ecf20Sopenharmony_ci#define BLOGIC_CMD_PARM_REG	1	/* WO register */
2728c2ecf20Sopenharmony_ci#define BLOGIC_DATAIN_REG	1	/* RO register */
2738c2ecf20Sopenharmony_ci#define BLOGIC_INT_REG		2	/* RO register */
2748c2ecf20Sopenharmony_ci#define BLOGIC_GEOMETRY_REG	3	/* RO register */
2758c2ecf20Sopenharmony_ci
2768c2ecf20Sopenharmony_ci/*
2778c2ecf20Sopenharmony_ci  Define the structure of the write-only Control Register.
2788c2ecf20Sopenharmony_ci*/
2798c2ecf20Sopenharmony_ci
2808c2ecf20Sopenharmony_ciunion blogic_cntrl_reg {
2818c2ecf20Sopenharmony_ci	unsigned char all;
2828c2ecf20Sopenharmony_ci	struct {
2838c2ecf20Sopenharmony_ci		unsigned char:4;	/* Bits 0-3 */
2848c2ecf20Sopenharmony_ci		bool bus_reset:1;	/* Bit 4 */
2858c2ecf20Sopenharmony_ci		bool int_reset:1;	/* Bit 5 */
2868c2ecf20Sopenharmony_ci		bool soft_reset:1;	/* Bit 6 */
2878c2ecf20Sopenharmony_ci		bool hard_reset:1;	/* Bit 7 */
2888c2ecf20Sopenharmony_ci	} cr;
2898c2ecf20Sopenharmony_ci};
2908c2ecf20Sopenharmony_ci
2918c2ecf20Sopenharmony_ci/*
2928c2ecf20Sopenharmony_ci  Define the structure of the read-only Status Register.
2938c2ecf20Sopenharmony_ci*/
2948c2ecf20Sopenharmony_ci
2958c2ecf20Sopenharmony_ciunion blogic_stat_reg {
2968c2ecf20Sopenharmony_ci	unsigned char all;
2978c2ecf20Sopenharmony_ci	struct {
2988c2ecf20Sopenharmony_ci		bool cmd_invalid:1;	/* Bit 0 */
2998c2ecf20Sopenharmony_ci		bool rsvd:1;		/* Bit 1 */
3008c2ecf20Sopenharmony_ci		bool datain_ready:1;	/* Bit 2 */
3018c2ecf20Sopenharmony_ci		bool cmd_param_busy:1;	/* Bit 3 */
3028c2ecf20Sopenharmony_ci		bool adapter_ready:1;	/* Bit 4 */
3038c2ecf20Sopenharmony_ci		bool init_reqd:1;	/* Bit 5 */
3048c2ecf20Sopenharmony_ci		bool diag_failed:1;	/* Bit 6 */
3058c2ecf20Sopenharmony_ci		bool diag_active:1;	/* Bit 7 */
3068c2ecf20Sopenharmony_ci	} sr;
3078c2ecf20Sopenharmony_ci};
3088c2ecf20Sopenharmony_ci
3098c2ecf20Sopenharmony_ci/*
3108c2ecf20Sopenharmony_ci  Define the structure of the read-only Interrupt Register.
3118c2ecf20Sopenharmony_ci*/
3128c2ecf20Sopenharmony_ci
3138c2ecf20Sopenharmony_ciunion blogic_int_reg {
3148c2ecf20Sopenharmony_ci	unsigned char all;
3158c2ecf20Sopenharmony_ci	struct {
3168c2ecf20Sopenharmony_ci		bool mailin_loaded:1;	/* Bit 0 */
3178c2ecf20Sopenharmony_ci		bool mailout_avail:1;	/* Bit 1 */
3188c2ecf20Sopenharmony_ci		bool cmd_complete:1;	/* Bit 2 */
3198c2ecf20Sopenharmony_ci		bool ext_busreset:1;	/* Bit 3 */
3208c2ecf20Sopenharmony_ci		unsigned char rsvd:3;	/* Bits 4-6 */
3218c2ecf20Sopenharmony_ci		bool int_valid:1;	/* Bit 7 */
3228c2ecf20Sopenharmony_ci	} ir;
3238c2ecf20Sopenharmony_ci};
3248c2ecf20Sopenharmony_ci
3258c2ecf20Sopenharmony_ci/*
3268c2ecf20Sopenharmony_ci  Define the structure of the read-only Geometry Register.
3278c2ecf20Sopenharmony_ci*/
3288c2ecf20Sopenharmony_ci
3298c2ecf20Sopenharmony_ciunion blogic_geo_reg {
3308c2ecf20Sopenharmony_ci	unsigned char all;
3318c2ecf20Sopenharmony_ci	struct {
3328c2ecf20Sopenharmony_ci		enum blogic_bios_diskgeometry d0_geo:2;	/* Bits 0-1 */
3338c2ecf20Sopenharmony_ci		enum blogic_bios_diskgeometry d1_geo:2;	/* Bits 2-3 */
3348c2ecf20Sopenharmony_ci		unsigned char:3;	/* Bits 4-6 */
3358c2ecf20Sopenharmony_ci		bool ext_trans_enable:1;	/* Bit 7 */
3368c2ecf20Sopenharmony_ci	} gr;
3378c2ecf20Sopenharmony_ci};
3388c2ecf20Sopenharmony_ci
3398c2ecf20Sopenharmony_ci/*
3408c2ecf20Sopenharmony_ci  Define the BusLogic SCSI Host Adapter Command Register Operation Codes.
3418c2ecf20Sopenharmony_ci*/
3428c2ecf20Sopenharmony_ci
3438c2ecf20Sopenharmony_cienum blogic_opcode {
3448c2ecf20Sopenharmony_ci	BLOGIC_TEST_CMP_COMPLETE = 0x00,
3458c2ecf20Sopenharmony_ci	BLOGIC_INIT_MBOX = 0x01,
3468c2ecf20Sopenharmony_ci	BLOGIC_EXEC_MBOX_CMD = 0x02,
3478c2ecf20Sopenharmony_ci	BLOGIC_EXEC_BIOS_CMD = 0x03,
3488c2ecf20Sopenharmony_ci	BLOGIC_GET_BOARD_ID = 0x04,
3498c2ecf20Sopenharmony_ci	BLOGIC_ENABLE_OUTBOX_AVAIL_INT = 0x05,
3508c2ecf20Sopenharmony_ci	BLOGIC_SET_SELECT_TIMEOUT = 0x06,
3518c2ecf20Sopenharmony_ci	BLOGIC_SET_PREEMPT_TIME = 0x07,
3528c2ecf20Sopenharmony_ci	BLOGIC_SET_TIMEOFF_BUS = 0x08,
3538c2ecf20Sopenharmony_ci	BLOGIC_SET_TXRATE = 0x09,
3548c2ecf20Sopenharmony_ci	BLOGIC_INQ_DEV0TO7 = 0x0A,
3558c2ecf20Sopenharmony_ci	BLOGIC_INQ_CONFIG = 0x0B,
3568c2ecf20Sopenharmony_ci	BLOGIC_TGT_MODE = 0x0C,
3578c2ecf20Sopenharmony_ci	BLOGIC_INQ_SETUPINFO = 0x0D,
3588c2ecf20Sopenharmony_ci	BLOGIC_WRITE_LOCALRAM = 0x1A,
3598c2ecf20Sopenharmony_ci	BLOGIC_READ_LOCALRAM = 0x1B,
3608c2ecf20Sopenharmony_ci	BLOGIC_WRITE_BUSMASTER_FIFO = 0x1C,
3618c2ecf20Sopenharmony_ci	BLOGIC_READ_BUSMASTER_FIFO = 0x1D,
3628c2ecf20Sopenharmony_ci	BLOGIC_ECHO_CMDDATA = 0x1F,
3638c2ecf20Sopenharmony_ci	BLOGIC_ADAPTER_DIAG = 0x20,
3648c2ecf20Sopenharmony_ci	BLOGIC_SET_OPTIONS = 0x21,
3658c2ecf20Sopenharmony_ci	BLOGIC_INQ_DEV8TO15 = 0x23,
3668c2ecf20Sopenharmony_ci	BLOGIC_INQ_DEV = 0x24,
3678c2ecf20Sopenharmony_ci	BLOGIC_DISABLE_INT = 0x25,
3688c2ecf20Sopenharmony_ci	BLOGIC_INIT_EXT_MBOX = 0x81,
3698c2ecf20Sopenharmony_ci	BLOGIC_EXEC_SCS_CMD = 0x83,
3708c2ecf20Sopenharmony_ci	BLOGIC_INQ_FWVER_D3 = 0x84,
3718c2ecf20Sopenharmony_ci	BLOGIC_INQ_FWVER_LETTER = 0x85,
3728c2ecf20Sopenharmony_ci	BLOGIC_INQ_PCI_INFO = 0x86,
3738c2ecf20Sopenharmony_ci	BLOGIC_INQ_MODELNO = 0x8B,
3748c2ecf20Sopenharmony_ci	BLOGIC_INQ_SYNC_PERIOD = 0x8C,
3758c2ecf20Sopenharmony_ci	BLOGIC_INQ_EXTSETUP = 0x8D,
3768c2ecf20Sopenharmony_ci	BLOGIC_STRICT_RR = 0x8F,
3778c2ecf20Sopenharmony_ci	BLOGIC_STORE_LOCALRAM = 0x90,
3788c2ecf20Sopenharmony_ci	BLOGIC_FETCH_LOCALRAM = 0x91,
3798c2ecf20Sopenharmony_ci	BLOGIC_STORE_TO_EEPROM = 0x92,
3808c2ecf20Sopenharmony_ci	BLOGIC_LOAD_AUTOSCSICODE = 0x94,
3818c2ecf20Sopenharmony_ci	BLOGIC_MOD_IOADDR = 0x95,
3828c2ecf20Sopenharmony_ci	BLOGIC_SETCCB_FMT = 0x96,
3838c2ecf20Sopenharmony_ci	BLOGIC_WRITE_INQBUF = 0x9A,
3848c2ecf20Sopenharmony_ci	BLOGIC_READ_INQBUF = 0x9B,
3858c2ecf20Sopenharmony_ci	BLOGIC_FLASH_LOAD = 0xA7,
3868c2ecf20Sopenharmony_ci	BLOGIC_READ_SCAMDATA = 0xA8,
3878c2ecf20Sopenharmony_ci	BLOGIC_WRITE_SCAMDATA = 0xA9
3888c2ecf20Sopenharmony_ci};
3898c2ecf20Sopenharmony_ci
3908c2ecf20Sopenharmony_ci/*
3918c2ecf20Sopenharmony_ci  Define the Inquire Board ID reply structure.
3928c2ecf20Sopenharmony_ci*/
3938c2ecf20Sopenharmony_ci
3948c2ecf20Sopenharmony_cistruct blogic_board_id {
3958c2ecf20Sopenharmony_ci	unsigned char type;		/* Byte 0 */
3968c2ecf20Sopenharmony_ci	unsigned char custom_features;	/* Byte 1 */
3978c2ecf20Sopenharmony_ci	unsigned char fw_ver_digit1;	/* Byte 2 */
3988c2ecf20Sopenharmony_ci	unsigned char fw_ver_digit2;	/* Byte 3 */
3998c2ecf20Sopenharmony_ci};
4008c2ecf20Sopenharmony_ci
4018c2ecf20Sopenharmony_ci/*
4028c2ecf20Sopenharmony_ci  Define the Inquire Configuration reply structure.
4038c2ecf20Sopenharmony_ci*/
4048c2ecf20Sopenharmony_ci
4058c2ecf20Sopenharmony_cistruct blogic_config {
4068c2ecf20Sopenharmony_ci	unsigned char:5;	/* Byte 0 Bits 0-4 */
4078c2ecf20Sopenharmony_ci	bool dma_ch5:1;		/* Byte 0 Bit 5 */
4088c2ecf20Sopenharmony_ci	bool dma_ch6:1;		/* Byte 0 Bit 6 */
4098c2ecf20Sopenharmony_ci	bool dma_ch7:1;		/* Byte 0 Bit 7 */
4108c2ecf20Sopenharmony_ci	bool irq_ch9:1;		/* Byte 1 Bit 0 */
4118c2ecf20Sopenharmony_ci	bool irq_ch10:1;	/* Byte 1 Bit 1 */
4128c2ecf20Sopenharmony_ci	bool irq_ch11:1;	/* Byte 1 Bit 2 */
4138c2ecf20Sopenharmony_ci	bool irq_ch12:1;	/* Byte 1 Bit 3 */
4148c2ecf20Sopenharmony_ci	unsigned char:1;	/* Byte 1 Bit 4 */
4158c2ecf20Sopenharmony_ci	bool irq_ch14:1;	/* Byte 1 Bit 5 */
4168c2ecf20Sopenharmony_ci	bool irq_ch15:1;	/* Byte 1 Bit 6 */
4178c2ecf20Sopenharmony_ci	unsigned char:1;	/* Byte 1 Bit 7 */
4188c2ecf20Sopenharmony_ci	unsigned char id:4;	/* Byte 2 Bits 0-3 */
4198c2ecf20Sopenharmony_ci	unsigned char:4;	/* Byte 2 Bits 4-7 */
4208c2ecf20Sopenharmony_ci};
4218c2ecf20Sopenharmony_ci
4228c2ecf20Sopenharmony_ci/*
4238c2ecf20Sopenharmony_ci  Define the Inquire Setup Information reply structure.
4248c2ecf20Sopenharmony_ci*/
4258c2ecf20Sopenharmony_ci
4268c2ecf20Sopenharmony_cistruct blogic_syncval {
4278c2ecf20Sopenharmony_ci	unsigned char offset:4;		/* Bits 0-3 */
4288c2ecf20Sopenharmony_ci	unsigned char tx_period:3;	/* Bits 4-6 */
4298c2ecf20Sopenharmony_ci	bool sync:1;			/* Bit 7 */
4308c2ecf20Sopenharmony_ci};
4318c2ecf20Sopenharmony_ci
4328c2ecf20Sopenharmony_cistruct blogic_setup_info {
4338c2ecf20Sopenharmony_ci	bool sync:1;				/* Byte 0 Bit 0 */
4348c2ecf20Sopenharmony_ci	bool parity:1;				/* Byte 0 Bit 1 */
4358c2ecf20Sopenharmony_ci	unsigned char:6;			/* Byte 0 Bits 2-7 */
4368c2ecf20Sopenharmony_ci	unsigned char tx_rate;			/* Byte 1 */
4378c2ecf20Sopenharmony_ci	unsigned char preempt_time;		/* Byte 2 */
4388c2ecf20Sopenharmony_ci	unsigned char timeoff_bus;		/* Byte 3 */
4398c2ecf20Sopenharmony_ci	unsigned char mbox_count;		/* Byte 4 */
4408c2ecf20Sopenharmony_ci	unsigned char mbox_addr[3];		/* Bytes 5-7 */
4418c2ecf20Sopenharmony_ci	struct blogic_syncval sync0to7[8];	/* Bytes 8-15 */
4428c2ecf20Sopenharmony_ci	unsigned char disconnect_ok0to7;	/* Byte 16 */
4438c2ecf20Sopenharmony_ci	unsigned char sig;			/* Byte 17 */
4448c2ecf20Sopenharmony_ci	unsigned char char_d;			/* Byte 18 */
4458c2ecf20Sopenharmony_ci	unsigned char bus_type;			/* Byte 19 */
4468c2ecf20Sopenharmony_ci	unsigned char wide_tx_ok0to7;		/* Byte 20 */
4478c2ecf20Sopenharmony_ci	unsigned char wide_tx_active0to7;	/* Byte 21 */
4488c2ecf20Sopenharmony_ci	struct blogic_syncval sync8to15[8];	/* Bytes 22-29 */
4498c2ecf20Sopenharmony_ci	unsigned char disconnect_ok8to15;	/* Byte 30 */
4508c2ecf20Sopenharmony_ci	unsigned char:8;			/* Byte 31 */
4518c2ecf20Sopenharmony_ci	unsigned char wide_tx_ok8to15;		/* Byte 32 */
4528c2ecf20Sopenharmony_ci	unsigned char wide_tx_active8to15;	/* Byte 33 */
4538c2ecf20Sopenharmony_ci};
4548c2ecf20Sopenharmony_ci
4558c2ecf20Sopenharmony_ci/*
4568c2ecf20Sopenharmony_ci  Define the Initialize Extended Mailbox request structure.
4578c2ecf20Sopenharmony_ci*/
4588c2ecf20Sopenharmony_ci
4598c2ecf20Sopenharmony_cistruct blogic_extmbox_req {
4608c2ecf20Sopenharmony_ci	unsigned char mbox_count;	/* Byte 0 */
4618c2ecf20Sopenharmony_ci	u32 base_mbox_addr;		/* Bytes 1-4 */
4628c2ecf20Sopenharmony_ci} PACKED;
4638c2ecf20Sopenharmony_ci
4648c2ecf20Sopenharmony_ci
4658c2ecf20Sopenharmony_ci/*
4668c2ecf20Sopenharmony_ci  Define the Inquire PCI Host Adapter Information reply type.  The ISA
4678c2ecf20Sopenharmony_ci  Compatible I/O Port values are defined here and are also used with
4688c2ecf20Sopenharmony_ci  the Modify I/O Address command.
4698c2ecf20Sopenharmony_ci*/
4708c2ecf20Sopenharmony_ci
4718c2ecf20Sopenharmony_cienum blogic_isa_ioport {
4728c2ecf20Sopenharmony_ci	BLOGIC_IO_330 = 0,
4738c2ecf20Sopenharmony_ci	BLOGIC_IO_334 = 1,
4748c2ecf20Sopenharmony_ci	BLOGIC_IO_230 = 2,
4758c2ecf20Sopenharmony_ci	BLOGIC_IO_234 = 3,
4768c2ecf20Sopenharmony_ci	BLOGIC_IO_130 = 4,
4778c2ecf20Sopenharmony_ci	BLOGIC_IO_134 = 5,
4788c2ecf20Sopenharmony_ci	BLOGIC_IO_DISABLE = 6,
4798c2ecf20Sopenharmony_ci	BLOGIC_IO_DISABLE2 = 7
4808c2ecf20Sopenharmony_ci} PACKED;
4818c2ecf20Sopenharmony_ci
4828c2ecf20Sopenharmony_cistruct blogic_adapter_info {
4838c2ecf20Sopenharmony_ci	enum blogic_isa_ioport isa_port;	/* Byte 0 */
4848c2ecf20Sopenharmony_ci	unsigned char irq_ch;		/* Byte 1 */
4858c2ecf20Sopenharmony_ci	bool low_term:1;		/* Byte 2 Bit 0 */
4868c2ecf20Sopenharmony_ci	bool high_term:1;		/* Byte 2 Bit 1 */
4878c2ecf20Sopenharmony_ci	unsigned char:2;		/* Byte 2 Bits 2-3 */
4888c2ecf20Sopenharmony_ci	bool JP1:1;			/* Byte 2 Bit 4 */
4898c2ecf20Sopenharmony_ci	bool JP2:1;			/* Byte 2 Bit 5 */
4908c2ecf20Sopenharmony_ci	bool JP3:1;			/* Byte 2 Bit 6 */
4918c2ecf20Sopenharmony_ci	bool genericinfo_valid:1;	/* Byte 2 Bit 7 */
4928c2ecf20Sopenharmony_ci	unsigned char:8;		/* Byte 3 */
4938c2ecf20Sopenharmony_ci};
4948c2ecf20Sopenharmony_ci
4958c2ecf20Sopenharmony_ci/*
4968c2ecf20Sopenharmony_ci  Define the Inquire Extended Setup Information reply structure.
4978c2ecf20Sopenharmony_ci*/
4988c2ecf20Sopenharmony_ci
4998c2ecf20Sopenharmony_cistruct blogic_ext_setup {
5008c2ecf20Sopenharmony_ci	unsigned char bus_type;		/* Byte 0 */
5018c2ecf20Sopenharmony_ci	unsigned char bios_addr;	/* Byte 1 */
5028c2ecf20Sopenharmony_ci	unsigned short sg_limit;	/* Bytes 2-3 */
5038c2ecf20Sopenharmony_ci	unsigned char mbox_count;	/* Byte 4 */
5048c2ecf20Sopenharmony_ci	u32 base_mbox_addr;		/* Bytes 5-8 */
5058c2ecf20Sopenharmony_ci	struct {
5068c2ecf20Sopenharmony_ci		unsigned char:2;	/* Byte 9 Bits 0-1 */
5078c2ecf20Sopenharmony_ci		bool fast_on_eisa:1;	/* Byte 9 Bit 2 */
5088c2ecf20Sopenharmony_ci		unsigned char:3;	/* Byte 9 Bits 3-5 */
5098c2ecf20Sopenharmony_ci		bool level_int:1;	/* Byte 9 Bit 6 */
5108c2ecf20Sopenharmony_ci		unsigned char:1;	/* Byte 9 Bit 7 */
5118c2ecf20Sopenharmony_ci	} misc;
5128c2ecf20Sopenharmony_ci	unsigned char fw_rev[3];	/* Bytes 10-12 */
5138c2ecf20Sopenharmony_ci	bool wide:1;			/* Byte 13 Bit 0 */
5148c2ecf20Sopenharmony_ci	bool differential:1;		/* Byte 13 Bit 1 */
5158c2ecf20Sopenharmony_ci	bool scam:1;			/* Byte 13 Bit 2 */
5168c2ecf20Sopenharmony_ci	bool ultra:1;			/* Byte 13 Bit 3 */
5178c2ecf20Sopenharmony_ci	bool smart_term:1;		/* Byte 13 Bit 4 */
5188c2ecf20Sopenharmony_ci	unsigned char:3;		/* Byte 13 Bits 5-7 */
5198c2ecf20Sopenharmony_ci} PACKED;
5208c2ecf20Sopenharmony_ci
5218c2ecf20Sopenharmony_ci/*
5228c2ecf20Sopenharmony_ci  Define the Enable Strict Round Robin Mode request type.
5238c2ecf20Sopenharmony_ci*/
5248c2ecf20Sopenharmony_ci
5258c2ecf20Sopenharmony_cienum blogic_rr_req {
5268c2ecf20Sopenharmony_ci	BLOGIC_AGGRESSIVE_RR = 0,
5278c2ecf20Sopenharmony_ci	BLOGIC_STRICT_RR_MODE = 1
5288c2ecf20Sopenharmony_ci} PACKED;
5298c2ecf20Sopenharmony_ci
5308c2ecf20Sopenharmony_ci
5318c2ecf20Sopenharmony_ci/*
5328c2ecf20Sopenharmony_ci  Define the Fetch Host Adapter Local RAM request type.
5338c2ecf20Sopenharmony_ci*/
5348c2ecf20Sopenharmony_ci
5358c2ecf20Sopenharmony_ci#define BLOGIC_BIOS_BASE		0
5368c2ecf20Sopenharmony_ci#define BLOGIC_AUTOSCSI_BASE		64
5378c2ecf20Sopenharmony_ci
5388c2ecf20Sopenharmony_cistruct blogic_fetch_localram {
5398c2ecf20Sopenharmony_ci	unsigned char offset;	/* Byte 0 */
5408c2ecf20Sopenharmony_ci	unsigned char count;	/* Byte 1 */
5418c2ecf20Sopenharmony_ci};
5428c2ecf20Sopenharmony_ci
5438c2ecf20Sopenharmony_ci/*
5448c2ecf20Sopenharmony_ci  Define the Host Adapter Local RAM AutoSCSI structure.
5458c2ecf20Sopenharmony_ci*/
5468c2ecf20Sopenharmony_ci
5478c2ecf20Sopenharmony_cistruct blogic_autoscsi {
5488c2ecf20Sopenharmony_ci	unsigned char factory_sig[2];		/* Bytes 0-1 */
5498c2ecf20Sopenharmony_ci	unsigned char info_bytes;		/* Byte 2 */
5508c2ecf20Sopenharmony_ci	unsigned char adapter_type[6];		/* Bytes 3-8 */
5518c2ecf20Sopenharmony_ci	unsigned char:8;			/* Byte 9 */
5528c2ecf20Sopenharmony_ci	bool floppy:1;				/* Byte 10 Bit 0 */
5538c2ecf20Sopenharmony_ci	bool floppy_sec:1;			/* Byte 10 Bit 1 */
5548c2ecf20Sopenharmony_ci	bool level_int:1;			/* Byte 10 Bit 2 */
5558c2ecf20Sopenharmony_ci	unsigned char:2;			/* Byte 10 Bits 3-4 */
5568c2ecf20Sopenharmony_ci	unsigned char systemram_bios:3;		/* Byte 10 Bits 5-7 */
5578c2ecf20Sopenharmony_ci	unsigned char dma_ch:7;			/* Byte 11 Bits 0-6 */
5588c2ecf20Sopenharmony_ci	bool dma_autoconf:1;			/* Byte 11 Bit 7 */
5598c2ecf20Sopenharmony_ci	unsigned char irq_ch:7;			/* Byte 12 Bits 0-6 */
5608c2ecf20Sopenharmony_ci	bool irq_autoconf:1;			/* Byte 12 Bit 7 */
5618c2ecf20Sopenharmony_ci	unsigned char dma_tx_rate;		/* Byte 13 */
5628c2ecf20Sopenharmony_ci	unsigned char scsi_id;			/* Byte 14 */
5638c2ecf20Sopenharmony_ci	bool low_term:1;			/* Byte 15 Bit 0 */
5648c2ecf20Sopenharmony_ci	bool parity:1;				/* Byte 15 Bit 1 */
5658c2ecf20Sopenharmony_ci	bool high_term:1;			/* Byte 15 Bit 2 */
5668c2ecf20Sopenharmony_ci	bool noisy_cable:1;			/* Byte 15 Bit 3 */
5678c2ecf20Sopenharmony_ci	bool fast_sync_neg:1;			/* Byte 15 Bit 4 */
5688c2ecf20Sopenharmony_ci	bool reset_enabled:1;			/* Byte 15 Bit 5 */
5698c2ecf20Sopenharmony_ci	bool:1;					/* Byte 15 Bit 6 */
5708c2ecf20Sopenharmony_ci	bool active_negation:1;			/* Byte 15 Bit 7 */
5718c2ecf20Sopenharmony_ci	unsigned char bus_on_delay;		/* Byte 16 */
5728c2ecf20Sopenharmony_ci	unsigned char bus_off_delay;		/* Byte 17 */
5738c2ecf20Sopenharmony_ci	bool bios_enabled:1;			/* Byte 18 Bit 0 */
5748c2ecf20Sopenharmony_ci	bool int19_redir_enabled:1;		/* Byte 18 Bit 1 */
5758c2ecf20Sopenharmony_ci	bool ext_trans_enable:1;		/* Byte 18 Bit 2 */
5768c2ecf20Sopenharmony_ci	bool removable_as_fixed:1;		/* Byte 18 Bit 3 */
5778c2ecf20Sopenharmony_ci	bool:1;					/* Byte 18 Bit 4 */
5788c2ecf20Sopenharmony_ci	bool morethan2_drives:1;		/* Byte 18 Bit 5 */
5798c2ecf20Sopenharmony_ci	bool bios_int:1;			/* Byte 18 Bit 6 */
5808c2ecf20Sopenharmony_ci	bool floptical:1;			/* Byte 19 Bit 7 */
5818c2ecf20Sopenharmony_ci	unsigned short dev_enabled;		/* Bytes 19-20 */
5828c2ecf20Sopenharmony_ci	unsigned short wide_ok;			/* Bytes 21-22 */
5838c2ecf20Sopenharmony_ci	unsigned short fast_ok;			/* Bytes 23-24 */
5848c2ecf20Sopenharmony_ci	unsigned short sync_ok;			/* Bytes 25-26 */
5858c2ecf20Sopenharmony_ci	unsigned short discon_ok;		/* Bytes 27-28 */
5868c2ecf20Sopenharmony_ci	unsigned short send_start_unit;		/* Bytes 29-30 */
5878c2ecf20Sopenharmony_ci	unsigned short ignore_bios_scan;	/* Bytes 31-32 */
5888c2ecf20Sopenharmony_ci	unsigned char pci_int_pin:2;		/* Byte 33 Bits 0-1 */
5898c2ecf20Sopenharmony_ci	unsigned char adapter_ioport:2;		/* Byte 33 Bits 2-3 */
5908c2ecf20Sopenharmony_ci	bool strict_rr_enabled:1;		/* Byte 33 Bit 4 */
5918c2ecf20Sopenharmony_ci	bool vesabus_33mhzplus:1;		/* Byte 33 Bit 5 */
5928c2ecf20Sopenharmony_ci	bool vesa_burst_write:1;		/* Byte 33 Bit 6 */
5938c2ecf20Sopenharmony_ci	bool vesa_burst_read:1;			/* Byte 33 Bit 7 */
5948c2ecf20Sopenharmony_ci	unsigned short ultra_ok;		/* Bytes 34-35 */
5958c2ecf20Sopenharmony_ci	unsigned int:32;			/* Bytes 36-39 */
5968c2ecf20Sopenharmony_ci	unsigned char:8;			/* Byte 40 */
5978c2ecf20Sopenharmony_ci	unsigned char autoscsi_maxlun;		/* Byte 41 */
5988c2ecf20Sopenharmony_ci	bool:1;					/* Byte 42 Bit 0 */
5998c2ecf20Sopenharmony_ci	bool scam_dominant:1;			/* Byte 42 Bit 1 */
6008c2ecf20Sopenharmony_ci	bool scam_enabled:1;			/* Byte 42 Bit 2 */
6018c2ecf20Sopenharmony_ci	bool scam_lev2:1;			/* Byte 42 Bit 3 */
6028c2ecf20Sopenharmony_ci	unsigned char:4;			/* Byte 42 Bits 4-7 */
6038c2ecf20Sopenharmony_ci	bool int13_exten:1;			/* Byte 43 Bit 0 */
6048c2ecf20Sopenharmony_ci	bool:1;					/* Byte 43 Bit 1 */
6058c2ecf20Sopenharmony_ci	bool cd_boot:1;				/* Byte 43 Bit 2 */
6068c2ecf20Sopenharmony_ci	unsigned char:5;			/* Byte 43 Bits 3-7 */
6078c2ecf20Sopenharmony_ci	unsigned char boot_id:4;		/* Byte 44 Bits 0-3 */
6088c2ecf20Sopenharmony_ci	unsigned char boot_ch:4;		/* Byte 44 Bits 4-7 */
6098c2ecf20Sopenharmony_ci	unsigned char force_scan_order:1;	/* Byte 45 Bit 0 */
6108c2ecf20Sopenharmony_ci	unsigned char:7;			/* Byte 45 Bits 1-7 */
6118c2ecf20Sopenharmony_ci	unsigned short nontagged_to_alt_ok;	/* Bytes 46-47 */
6128c2ecf20Sopenharmony_ci	unsigned short reneg_sync_on_check;	/* Bytes 48-49 */
6138c2ecf20Sopenharmony_ci	unsigned char rsvd[10];			/* Bytes 50-59 */
6148c2ecf20Sopenharmony_ci	unsigned char manuf_diag[2];		/* Bytes 60-61 */
6158c2ecf20Sopenharmony_ci	unsigned short cksum;			/* Bytes 62-63 */
6168c2ecf20Sopenharmony_ci} PACKED;
6178c2ecf20Sopenharmony_ci
6188c2ecf20Sopenharmony_ci/*
6198c2ecf20Sopenharmony_ci  Define the Host Adapter Local RAM Auto SCSI Byte 45 structure.
6208c2ecf20Sopenharmony_ci*/
6218c2ecf20Sopenharmony_ci
6228c2ecf20Sopenharmony_cistruct blogic_autoscsi_byte45 {
6238c2ecf20Sopenharmony_ci	unsigned char force_scan_order:1;	/* Bit 0 */
6248c2ecf20Sopenharmony_ci	unsigned char:7;	/* Bits 1-7 */
6258c2ecf20Sopenharmony_ci};
6268c2ecf20Sopenharmony_ci
6278c2ecf20Sopenharmony_ci/*
6288c2ecf20Sopenharmony_ci  Define the Host Adapter Local RAM BIOS Drive Map Byte structure.
6298c2ecf20Sopenharmony_ci*/
6308c2ecf20Sopenharmony_ci
6318c2ecf20Sopenharmony_ci#define BLOGIC_BIOS_DRVMAP		17
6328c2ecf20Sopenharmony_ci
6338c2ecf20Sopenharmony_cistruct blogic_bios_drvmap {
6348c2ecf20Sopenharmony_ci	unsigned char tgt_idbit3:1;			/* Bit 0 */
6358c2ecf20Sopenharmony_ci	unsigned char:2;				/* Bits 1-2 */
6368c2ecf20Sopenharmony_ci	enum blogic_bios_diskgeometry diskgeom:2;	/* Bits 3-4 */
6378c2ecf20Sopenharmony_ci	unsigned char tgt_id:3;				/* Bits 5-7 */
6388c2ecf20Sopenharmony_ci};
6398c2ecf20Sopenharmony_ci
6408c2ecf20Sopenharmony_ci/*
6418c2ecf20Sopenharmony_ci  Define the Set CCB Format request type.  Extended LUN Format CCBs are
6428c2ecf20Sopenharmony_ci  necessary to support more than 8 Logical Units per Target Device.
6438c2ecf20Sopenharmony_ci*/
6448c2ecf20Sopenharmony_ci
6458c2ecf20Sopenharmony_cienum blogic_setccb_fmt {
6468c2ecf20Sopenharmony_ci	BLOGIC_LEGACY_LUN_CCB = 0,
6478c2ecf20Sopenharmony_ci	BLOGIC_EXT_LUN_CCB = 1
6488c2ecf20Sopenharmony_ci} PACKED;
6498c2ecf20Sopenharmony_ci
6508c2ecf20Sopenharmony_ci/*
6518c2ecf20Sopenharmony_ci  Define the Outgoing Mailbox Action Codes.
6528c2ecf20Sopenharmony_ci*/
6538c2ecf20Sopenharmony_ci
6548c2ecf20Sopenharmony_cienum blogic_action {
6558c2ecf20Sopenharmony_ci	BLOGIC_OUTBOX_FREE = 0x00,
6568c2ecf20Sopenharmony_ci	BLOGIC_MBOX_START = 0x01,
6578c2ecf20Sopenharmony_ci	BLOGIC_MBOX_ABORT = 0x02
6588c2ecf20Sopenharmony_ci} PACKED;
6598c2ecf20Sopenharmony_ci
6608c2ecf20Sopenharmony_ci
6618c2ecf20Sopenharmony_ci/*
6628c2ecf20Sopenharmony_ci  Define the Incoming Mailbox Completion Codes.  The MultiMaster Firmware
6638c2ecf20Sopenharmony_ci  only uses codes 0 - 4.  The FlashPoint SCCB Manager has no mailboxes, so
6648c2ecf20Sopenharmony_ci  completion codes are stored in the CCB; it only uses codes 1, 2, 4, and 5.
6658c2ecf20Sopenharmony_ci*/
6668c2ecf20Sopenharmony_ci
6678c2ecf20Sopenharmony_cienum blogic_cmplt_code {
6688c2ecf20Sopenharmony_ci	BLOGIC_INBOX_FREE = 0x00,
6698c2ecf20Sopenharmony_ci	BLOGIC_CMD_COMPLETE_GOOD = 0x01,
6708c2ecf20Sopenharmony_ci	BLOGIC_CMD_ABORT_BY_HOST = 0x02,
6718c2ecf20Sopenharmony_ci	BLOGIC_CMD_NOTFOUND = 0x03,
6728c2ecf20Sopenharmony_ci	BLOGIC_CMD_COMPLETE_ERROR = 0x04,
6738c2ecf20Sopenharmony_ci	BLOGIC_INVALID_CCB = 0x05
6748c2ecf20Sopenharmony_ci} PACKED;
6758c2ecf20Sopenharmony_ci
6768c2ecf20Sopenharmony_ci/*
6778c2ecf20Sopenharmony_ci  Define the Command Control Block (CCB) Opcodes.
6788c2ecf20Sopenharmony_ci*/
6798c2ecf20Sopenharmony_ci
6808c2ecf20Sopenharmony_cienum blogic_ccb_opcode {
6818c2ecf20Sopenharmony_ci	BLOGIC_INITIATOR_CCB = 0x00,
6828c2ecf20Sopenharmony_ci	BLOGIC_TGT_CCB = 0x01,
6838c2ecf20Sopenharmony_ci	BLOGIC_INITIATOR_CCB_SG = 0x02,
6848c2ecf20Sopenharmony_ci	BLOGIC_INITIATOR_CCBB_RESIDUAL = 0x03,
6858c2ecf20Sopenharmony_ci	BLOGIC_INITIATOR_CCB_SG_RESIDUAL = 0x04,
6868c2ecf20Sopenharmony_ci	BLOGIC_BDR = 0x81
6878c2ecf20Sopenharmony_ci} PACKED;
6888c2ecf20Sopenharmony_ci
6898c2ecf20Sopenharmony_ci
6908c2ecf20Sopenharmony_ci/*
6918c2ecf20Sopenharmony_ci  Define the CCB Data Direction Codes.
6928c2ecf20Sopenharmony_ci*/
6938c2ecf20Sopenharmony_ci
6948c2ecf20Sopenharmony_cienum blogic_datadir {
6958c2ecf20Sopenharmony_ci	BLOGIC_UNCHECKED_TX = 0,
6968c2ecf20Sopenharmony_ci	BLOGIC_DATAIN_CHECKED = 1,
6978c2ecf20Sopenharmony_ci	BLOGIC_DATAOUT_CHECKED = 2,
6988c2ecf20Sopenharmony_ci	BLOGIC_NOTX = 3
6998c2ecf20Sopenharmony_ci};
7008c2ecf20Sopenharmony_ci
7018c2ecf20Sopenharmony_ci
7028c2ecf20Sopenharmony_ci/*
7038c2ecf20Sopenharmony_ci  Define the Host Adapter Status Codes.  The MultiMaster Firmware does not
7048c2ecf20Sopenharmony_ci  return status code 0x0C; it uses 0x12 for both overruns and underruns.
7058c2ecf20Sopenharmony_ci*/
7068c2ecf20Sopenharmony_ci
7078c2ecf20Sopenharmony_cienum blogic_adapter_status {
7088c2ecf20Sopenharmony_ci	BLOGIC_CMD_CMPLT_NORMAL = 0x00,
7098c2ecf20Sopenharmony_ci	BLOGIC_LINK_CMD_CMPLT = 0x0A,
7108c2ecf20Sopenharmony_ci	BLOGIC_LINK_CMD_CMPLT_FLAG = 0x0B,
7118c2ecf20Sopenharmony_ci	BLOGIC_DATA_UNDERRUN = 0x0C,
7128c2ecf20Sopenharmony_ci	BLOGIC_SELECT_TIMEOUT = 0x11,
7138c2ecf20Sopenharmony_ci	BLOGIC_DATA_OVERRUN = 0x12,
7148c2ecf20Sopenharmony_ci	BLOGIC_NOEXPECT_BUSFREE = 0x13,
7158c2ecf20Sopenharmony_ci	BLOGIC_INVALID_BUSPHASE = 0x14,
7168c2ecf20Sopenharmony_ci	BLOGIC_INVALID_OUTBOX_CODE = 0x15,
7178c2ecf20Sopenharmony_ci	BLOGIC_INVALID_CMD_CODE = 0x16,
7188c2ecf20Sopenharmony_ci	BLOGIC_LINKCCB_BADLUN = 0x17,
7198c2ecf20Sopenharmony_ci	BLOGIC_BAD_CMD_PARAM = 0x1A,
7208c2ecf20Sopenharmony_ci	BLOGIC_AUTOREQSENSE_FAIL = 0x1B,
7218c2ecf20Sopenharmony_ci	BLOGIC_TAGQUEUE_REJECT = 0x1C,
7228c2ecf20Sopenharmony_ci	BLOGIC_BAD_MSG_RCVD = 0x1D,
7238c2ecf20Sopenharmony_ci	BLOGIC_HW_FAIL = 0x20,
7248c2ecf20Sopenharmony_ci	BLOGIC_NORESPONSE_TO_ATN = 0x21,
7258c2ecf20Sopenharmony_ci	BLOGIC_HW_RESET = 0x22,
7268c2ecf20Sopenharmony_ci	BLOGIC_RST_FROM_OTHERDEV = 0x23,
7278c2ecf20Sopenharmony_ci	BLOGIC_BAD_RECONNECT = 0x24,
7288c2ecf20Sopenharmony_ci	BLOGIC_HW_BDR = 0x25,
7298c2ecf20Sopenharmony_ci	BLOGIC_ABRT_QUEUE = 0x26,
7308c2ecf20Sopenharmony_ci	BLOGIC_ADAPTER_SW_ERROR = 0x27,
7318c2ecf20Sopenharmony_ci	BLOGIC_HW_TIMEOUT = 0x30,
7328c2ecf20Sopenharmony_ci	BLOGIC_PARITY_ERR = 0x34
7338c2ecf20Sopenharmony_ci} PACKED;
7348c2ecf20Sopenharmony_ci
7358c2ecf20Sopenharmony_ci
7368c2ecf20Sopenharmony_ci/*
7378c2ecf20Sopenharmony_ci  Define the SCSI Target Device Status Codes.
7388c2ecf20Sopenharmony_ci*/
7398c2ecf20Sopenharmony_ci
7408c2ecf20Sopenharmony_cienum blogic_tgt_status {
7418c2ecf20Sopenharmony_ci	BLOGIC_OP_GOOD = 0x00,
7428c2ecf20Sopenharmony_ci	BLOGIC_CHECKCONDITION = 0x02,
7438c2ecf20Sopenharmony_ci	BLOGIC_DEVBUSY = 0x08
7448c2ecf20Sopenharmony_ci} PACKED;
7458c2ecf20Sopenharmony_ci
7468c2ecf20Sopenharmony_ci/*
7478c2ecf20Sopenharmony_ci  Define the Queue Tag Codes.
7488c2ecf20Sopenharmony_ci*/
7498c2ecf20Sopenharmony_ci
7508c2ecf20Sopenharmony_cienum blogic_queuetag {
7518c2ecf20Sopenharmony_ci	BLOGIC_SIMPLETAG = 0,
7528c2ecf20Sopenharmony_ci	BLOGIC_HEADTAG = 1,
7538c2ecf20Sopenharmony_ci	BLOGIC_ORDEREDTAG = 2,
7548c2ecf20Sopenharmony_ci	BLOGIC_RSVDTAG = 3
7558c2ecf20Sopenharmony_ci};
7568c2ecf20Sopenharmony_ci
7578c2ecf20Sopenharmony_ci/*
7588c2ecf20Sopenharmony_ci  Define the SCSI Command Descriptor Block (CDB).
7598c2ecf20Sopenharmony_ci*/
7608c2ecf20Sopenharmony_ci
7618c2ecf20Sopenharmony_ci#define BLOGIC_CDB_MAXLEN			12
7628c2ecf20Sopenharmony_ci
7638c2ecf20Sopenharmony_ci
7648c2ecf20Sopenharmony_ci/*
7658c2ecf20Sopenharmony_ci  Define the Scatter/Gather Segment structure required by the MultiMaster
7668c2ecf20Sopenharmony_ci  Firmware Interface and the FlashPoint SCCB Manager.
7678c2ecf20Sopenharmony_ci*/
7688c2ecf20Sopenharmony_ci
7698c2ecf20Sopenharmony_cistruct blogic_sg_seg {
7708c2ecf20Sopenharmony_ci	u32 segbytes;	/* Bytes 0-3 */
7718c2ecf20Sopenharmony_ci	u32 segdata;	/* Bytes 4-7 */
7728c2ecf20Sopenharmony_ci};
7738c2ecf20Sopenharmony_ci
7748c2ecf20Sopenharmony_ci/*
7758c2ecf20Sopenharmony_ci  Define the Driver CCB Status Codes.
7768c2ecf20Sopenharmony_ci*/
7778c2ecf20Sopenharmony_ci
7788c2ecf20Sopenharmony_cienum blogic_ccb_status {
7798c2ecf20Sopenharmony_ci	BLOGIC_CCB_FREE = 0,
7808c2ecf20Sopenharmony_ci	BLOGIC_CCB_ACTIVE = 1,
7818c2ecf20Sopenharmony_ci	BLOGIC_CCB_COMPLETE = 2,
7828c2ecf20Sopenharmony_ci	BLOGIC_CCB_RESET = 3
7838c2ecf20Sopenharmony_ci} PACKED;
7848c2ecf20Sopenharmony_ci
7858c2ecf20Sopenharmony_ci
7868c2ecf20Sopenharmony_ci/*
7878c2ecf20Sopenharmony_ci  Define the 32 Bit Mode Command Control Block (CCB) structure.  The first 40
7888c2ecf20Sopenharmony_ci  bytes are defined by and common to both the MultiMaster Firmware and the
7898c2ecf20Sopenharmony_ci  FlashPoint SCCB Manager.  The next 60 bytes are defined by the FlashPoint
7908c2ecf20Sopenharmony_ci  SCCB Manager.  The remaining components are defined by the Linux BusLogic
7918c2ecf20Sopenharmony_ci  Driver.  Extended LUN Format CCBs differ from Legacy LUN Format 32 Bit Mode
7928c2ecf20Sopenharmony_ci  CCBs only in having the TagEnable and QueueTag fields moved from byte 17 to
7938c2ecf20Sopenharmony_ci  byte 1, and the Logical Unit field in byte 17 expanded to 6 bits.  In theory,
7948c2ecf20Sopenharmony_ci  Extended LUN Format CCBs can support up to 64 Logical Units, but in practice
7958c2ecf20Sopenharmony_ci  many devices will respond improperly to Logical Units between 32 and 63, and
7968c2ecf20Sopenharmony_ci  the SCSI-2 specification defines Bit 5 as LUNTAR.  Extended LUN Format CCBs
7978c2ecf20Sopenharmony_ci  are used by recent versions of the MultiMaster Firmware, as well as by the
7988c2ecf20Sopenharmony_ci  FlashPoint SCCB Manager; the FlashPoint SCCB Manager only supports 32 Logical
7998c2ecf20Sopenharmony_ci  Units.  Since 64 Logical Units are unlikely to be needed in practice, and
8008c2ecf20Sopenharmony_ci  since they are problematic for the above reasons, and since limiting them to
8018c2ecf20Sopenharmony_ci  5 bits simplifies the CCB structure definition, this driver only supports
8028c2ecf20Sopenharmony_ci  32 Logical Units per Target Device.
8038c2ecf20Sopenharmony_ci*/
8048c2ecf20Sopenharmony_ci
8058c2ecf20Sopenharmony_cistruct blogic_ccb {
8068c2ecf20Sopenharmony_ci	/*
8078c2ecf20Sopenharmony_ci	   MultiMaster Firmware and FlashPoint SCCB Manager Common Portion.
8088c2ecf20Sopenharmony_ci	 */
8098c2ecf20Sopenharmony_ci	enum blogic_ccb_opcode opcode;			/* Byte 0 */
8108c2ecf20Sopenharmony_ci	unsigned char:3;				/* Byte 1 Bits 0-2 */
8118c2ecf20Sopenharmony_ci	enum blogic_datadir datadir:2;			/* Byte 1 Bits 3-4 */
8128c2ecf20Sopenharmony_ci	bool tag_enable:1;				/* Byte 1 Bit 5 */
8138c2ecf20Sopenharmony_ci	enum blogic_queuetag queuetag:2;		/* Byte 1 Bits 6-7 */
8148c2ecf20Sopenharmony_ci	unsigned char cdblen;				/* Byte 2 */
8158c2ecf20Sopenharmony_ci	unsigned char sense_datalen;			/* Byte 3 */
8168c2ecf20Sopenharmony_ci	u32 datalen;					/* Bytes 4-7 */
8178c2ecf20Sopenharmony_ci	u32 data;					/* Bytes 8-11 */
8188c2ecf20Sopenharmony_ci	unsigned char:8;				/* Byte 12 */
8198c2ecf20Sopenharmony_ci	unsigned char:8;				/* Byte 13 */
8208c2ecf20Sopenharmony_ci	enum blogic_adapter_status adapter_status;	/* Byte 14 */
8218c2ecf20Sopenharmony_ci	enum blogic_tgt_status tgt_status;		/* Byte 15 */
8228c2ecf20Sopenharmony_ci	unsigned char tgt_id;				/* Byte 16 */
8238c2ecf20Sopenharmony_ci	unsigned char lun:5;				/* Byte 17 Bits 0-4 */
8248c2ecf20Sopenharmony_ci	bool legacytag_enable:1;			/* Byte 17 Bit 5 */
8258c2ecf20Sopenharmony_ci	enum blogic_queuetag legacy_tag:2;		/* Byte 17 Bits 6-7 */
8268c2ecf20Sopenharmony_ci	unsigned char cdb[BLOGIC_CDB_MAXLEN];		/* Bytes 18-29 */
8278c2ecf20Sopenharmony_ci	unsigned char:8;				/* Byte 30 */
8288c2ecf20Sopenharmony_ci	unsigned char:8;				/* Byte 31 */
8298c2ecf20Sopenharmony_ci	u32 rsvd_int;					/* Bytes 32-35 */
8308c2ecf20Sopenharmony_ci	u32 sensedata;					/* Bytes 36-39 */
8318c2ecf20Sopenharmony_ci	/*
8328c2ecf20Sopenharmony_ci	   FlashPoint SCCB Manager Defined Portion.
8338c2ecf20Sopenharmony_ci	 */
8348c2ecf20Sopenharmony_ci	void (*callback) (struct blogic_ccb *);		/* Bytes 40-43 */
8358c2ecf20Sopenharmony_ci	u32 base_addr;					/* Bytes 44-47 */
8368c2ecf20Sopenharmony_ci	enum blogic_cmplt_code comp_code;		/* Byte 48 */
8378c2ecf20Sopenharmony_ci#ifdef CONFIG_SCSI_FLASHPOINT
8388c2ecf20Sopenharmony_ci	unsigned char:8;				/* Byte 49 */
8398c2ecf20Sopenharmony_ci	u16 os_flags;					/* Bytes 50-51 */
8408c2ecf20Sopenharmony_ci	unsigned char private[24];			/* Bytes 52-99 */
8418c2ecf20Sopenharmony_ci	void *rsvd1;
8428c2ecf20Sopenharmony_ci	void *rsvd2;
8438c2ecf20Sopenharmony_ci	unsigned char private2[16];
8448c2ecf20Sopenharmony_ci#endif
8458c2ecf20Sopenharmony_ci	/*
8468c2ecf20Sopenharmony_ci	   BusLogic Linux Driver Defined Portion.
8478c2ecf20Sopenharmony_ci	 */
8488c2ecf20Sopenharmony_ci	dma_addr_t allocgrp_head;
8498c2ecf20Sopenharmony_ci	unsigned int allocgrp_size;
8508c2ecf20Sopenharmony_ci	u32 dma_handle;
8518c2ecf20Sopenharmony_ci	enum blogic_ccb_status status;
8528c2ecf20Sopenharmony_ci	unsigned long serial;
8538c2ecf20Sopenharmony_ci	struct scsi_cmnd *command;
8548c2ecf20Sopenharmony_ci	struct blogic_adapter *adapter;
8558c2ecf20Sopenharmony_ci	struct blogic_ccb *next;
8568c2ecf20Sopenharmony_ci	struct blogic_ccb *next_all;
8578c2ecf20Sopenharmony_ci	struct blogic_sg_seg sglist[BLOGIC_SG_LIMIT];
8588c2ecf20Sopenharmony_ci};
8598c2ecf20Sopenharmony_ci
8608c2ecf20Sopenharmony_ci/*
8618c2ecf20Sopenharmony_ci  Define the 32 Bit Mode Outgoing Mailbox structure.
8628c2ecf20Sopenharmony_ci*/
8638c2ecf20Sopenharmony_ci
8648c2ecf20Sopenharmony_cistruct blogic_outbox {
8658c2ecf20Sopenharmony_ci	u32 ccb;			/* Bytes 0-3 */
8668c2ecf20Sopenharmony_ci	u32:24;				/* Bytes 4-6 */
8678c2ecf20Sopenharmony_ci	enum blogic_action action;	/* Byte 7 */
8688c2ecf20Sopenharmony_ci};
8698c2ecf20Sopenharmony_ci
8708c2ecf20Sopenharmony_ci/*
8718c2ecf20Sopenharmony_ci  Define the 32 Bit Mode Incoming Mailbox structure.
8728c2ecf20Sopenharmony_ci*/
8738c2ecf20Sopenharmony_ci
8748c2ecf20Sopenharmony_cistruct blogic_inbox {
8758c2ecf20Sopenharmony_ci	u32 ccb;					/* Bytes 0-3 */
8768c2ecf20Sopenharmony_ci	enum blogic_adapter_status adapter_status;	/* Byte 4 */
8778c2ecf20Sopenharmony_ci	enum blogic_tgt_status tgt_status;		/* Byte 5 */
8788c2ecf20Sopenharmony_ci	unsigned char:8;				/* Byte 6 */
8798c2ecf20Sopenharmony_ci	enum blogic_cmplt_code comp_code;		/* Byte 7 */
8808c2ecf20Sopenharmony_ci};
8818c2ecf20Sopenharmony_ci
8828c2ecf20Sopenharmony_ci
8838c2ecf20Sopenharmony_ci/*
8848c2ecf20Sopenharmony_ci  Define the BusLogic Driver Options structure.
8858c2ecf20Sopenharmony_ci*/
8868c2ecf20Sopenharmony_ci
8878c2ecf20Sopenharmony_cistruct blogic_drvr_options {
8888c2ecf20Sopenharmony_ci	unsigned short tagq_ok;
8898c2ecf20Sopenharmony_ci	unsigned short tagq_ok_mask;
8908c2ecf20Sopenharmony_ci	unsigned short bus_settle_time;
8918c2ecf20Sopenharmony_ci	unsigned short stop_tgt_inquiry;
8928c2ecf20Sopenharmony_ci	unsigned char common_qdepth;
8938c2ecf20Sopenharmony_ci	unsigned char qdepth[BLOGIC_MAXDEV];
8948c2ecf20Sopenharmony_ci};
8958c2ecf20Sopenharmony_ci
8968c2ecf20Sopenharmony_ci/*
8978c2ecf20Sopenharmony_ci  Define the Host Adapter Target Flags structure.
8988c2ecf20Sopenharmony_ci*/
8998c2ecf20Sopenharmony_ci
9008c2ecf20Sopenharmony_cistruct blogic_tgt_flags {
9018c2ecf20Sopenharmony_ci	bool tgt_exists:1;
9028c2ecf20Sopenharmony_ci	bool tagq_ok:1;
9038c2ecf20Sopenharmony_ci	bool wide_ok:1;
9048c2ecf20Sopenharmony_ci	bool tagq_active:1;
9058c2ecf20Sopenharmony_ci	bool wide_active:1;
9068c2ecf20Sopenharmony_ci	bool cmd_good:1;
9078c2ecf20Sopenharmony_ci	bool tgt_info_in:1;
9088c2ecf20Sopenharmony_ci};
9098c2ecf20Sopenharmony_ci
9108c2ecf20Sopenharmony_ci/*
9118c2ecf20Sopenharmony_ci  Define the Host Adapter Target Statistics structure.
9128c2ecf20Sopenharmony_ci*/
9138c2ecf20Sopenharmony_ci
9148c2ecf20Sopenharmony_ci#define BLOGIC_SZ_BUCKETS			10
9158c2ecf20Sopenharmony_ci
9168c2ecf20Sopenharmony_cistruct blogic_tgt_stats {
9178c2ecf20Sopenharmony_ci	unsigned int cmds_tried;
9188c2ecf20Sopenharmony_ci	unsigned int cmds_complete;
9198c2ecf20Sopenharmony_ci	unsigned int read_cmds;
9208c2ecf20Sopenharmony_ci	unsigned int write_cmds;
9218c2ecf20Sopenharmony_ci	struct blogic_byte_count bytesread;
9228c2ecf20Sopenharmony_ci	struct blogic_byte_count byteswritten;
9238c2ecf20Sopenharmony_ci	unsigned int read_sz_buckets[BLOGIC_SZ_BUCKETS];
9248c2ecf20Sopenharmony_ci	unsigned int write_sz_buckets[BLOGIC_SZ_BUCKETS];
9258c2ecf20Sopenharmony_ci	unsigned short aborts_request;
9268c2ecf20Sopenharmony_ci	unsigned short aborts_tried;
9278c2ecf20Sopenharmony_ci	unsigned short aborts_done;
9288c2ecf20Sopenharmony_ci	unsigned short bdr_request;
9298c2ecf20Sopenharmony_ci	unsigned short bdr_tried;
9308c2ecf20Sopenharmony_ci	unsigned short bdr_done;
9318c2ecf20Sopenharmony_ci	unsigned short adapter_reset_req;
9328c2ecf20Sopenharmony_ci	unsigned short adapter_reset_attempt;
9338c2ecf20Sopenharmony_ci	unsigned short adapter_reset_done;
9348c2ecf20Sopenharmony_ci};
9358c2ecf20Sopenharmony_ci
9368c2ecf20Sopenharmony_ci/*
9378c2ecf20Sopenharmony_ci  Define the FlashPoint Card Handle data type.
9388c2ecf20Sopenharmony_ci*/
9398c2ecf20Sopenharmony_ci
9408c2ecf20Sopenharmony_ci#define FPOINT_BADCARD_HANDLE		0xFFFFFFFFL
9418c2ecf20Sopenharmony_ci
9428c2ecf20Sopenharmony_ci
9438c2ecf20Sopenharmony_ci/*
9448c2ecf20Sopenharmony_ci  Define the FlashPoint Information structure.  This structure is defined
9458c2ecf20Sopenharmony_ci  by the FlashPoint SCCB Manager.
9468c2ecf20Sopenharmony_ci*/
9478c2ecf20Sopenharmony_ci
9488c2ecf20Sopenharmony_cistruct fpoint_info {
9498c2ecf20Sopenharmony_ci	u32 base_addr;				/* Bytes 0-3 */
9508c2ecf20Sopenharmony_ci	bool present;				/* Byte 4 */
9518c2ecf20Sopenharmony_ci	unsigned char irq_ch;			/* Byte 5 */
9528c2ecf20Sopenharmony_ci	unsigned char scsi_id;			/* Byte 6 */
9538c2ecf20Sopenharmony_ci	unsigned char scsi_lun;			/* Byte 7 */
9548c2ecf20Sopenharmony_ci	u16 fw_rev;				/* Bytes 8-9 */
9558c2ecf20Sopenharmony_ci	u16 sync_ok;				/* Bytes 10-11 */
9568c2ecf20Sopenharmony_ci	u16 fast_ok;				/* Bytes 12-13 */
9578c2ecf20Sopenharmony_ci	u16 ultra_ok;				/* Bytes 14-15 */
9588c2ecf20Sopenharmony_ci	u16 discon_ok;				/* Bytes 16-17 */
9598c2ecf20Sopenharmony_ci	u16 wide_ok;				/* Bytes 18-19 */
9608c2ecf20Sopenharmony_ci	bool parity:1;				/* Byte 20 Bit 0 */
9618c2ecf20Sopenharmony_ci	bool wide:1;				/* Byte 20 Bit 1 */
9628c2ecf20Sopenharmony_ci	bool softreset:1;			/* Byte 20 Bit 2 */
9638c2ecf20Sopenharmony_ci	bool ext_trans_enable:1;		/* Byte 20 Bit 3 */
9648c2ecf20Sopenharmony_ci	bool low_term:1;			/* Byte 20 Bit 4 */
9658c2ecf20Sopenharmony_ci	bool high_term:1;			/* Byte 20 Bit 5 */
9668c2ecf20Sopenharmony_ci	bool report_underrun:1;			/* Byte 20 Bit 6 */
9678c2ecf20Sopenharmony_ci	bool scam_enabled:1;			/* Byte 20 Bit 7 */
9688c2ecf20Sopenharmony_ci	bool scam_lev2:1;			/* Byte 21 Bit 0 */
9698c2ecf20Sopenharmony_ci	unsigned char:7;			/* Byte 21 Bits 1-7 */
9708c2ecf20Sopenharmony_ci	unsigned char family;			/* Byte 22 */
9718c2ecf20Sopenharmony_ci	unsigned char bus_type;			/* Byte 23 */
9728c2ecf20Sopenharmony_ci	unsigned char model[3];			/* Bytes 24-26 */
9738c2ecf20Sopenharmony_ci	unsigned char relative_cardnum;		/* Byte 27 */
9748c2ecf20Sopenharmony_ci	unsigned char rsvd[4];			/* Bytes 28-31 */
9758c2ecf20Sopenharmony_ci	u32 os_rsvd;				/* Bytes 32-35 */
9768c2ecf20Sopenharmony_ci	unsigned char translation_info[4];	/* Bytes 36-39 */
9778c2ecf20Sopenharmony_ci	u32 rsvd2[5];				/* Bytes 40-59 */
9788c2ecf20Sopenharmony_ci	u32 sec_range;				/* Bytes 60-63 */
9798c2ecf20Sopenharmony_ci};
9808c2ecf20Sopenharmony_ci
9818c2ecf20Sopenharmony_ci/*
9828c2ecf20Sopenharmony_ci  Define the BusLogic Driver Host Adapter structure.
9838c2ecf20Sopenharmony_ci*/
9848c2ecf20Sopenharmony_ci
9858c2ecf20Sopenharmony_cistruct blogic_adapter {
9868c2ecf20Sopenharmony_ci	struct Scsi_Host *scsi_host;
9878c2ecf20Sopenharmony_ci	struct pci_dev *pci_device;
9888c2ecf20Sopenharmony_ci	enum blogic_adapter_type adapter_type;
9898c2ecf20Sopenharmony_ci	enum blogic_adapter_bus_type adapter_bus_type;
9908c2ecf20Sopenharmony_ci	unsigned long io_addr;
9918c2ecf20Sopenharmony_ci	unsigned long pci_addr;
9928c2ecf20Sopenharmony_ci	unsigned short addr_count;
9938c2ecf20Sopenharmony_ci	unsigned char host_no;
9948c2ecf20Sopenharmony_ci	unsigned char model[9];
9958c2ecf20Sopenharmony_ci	unsigned char fw_ver[6];
9968c2ecf20Sopenharmony_ci	unsigned char full_model[18];
9978c2ecf20Sopenharmony_ci	unsigned char bus;
9988c2ecf20Sopenharmony_ci	unsigned char dev;
9998c2ecf20Sopenharmony_ci	unsigned char irq_ch;
10008c2ecf20Sopenharmony_ci	unsigned char dma_ch;
10018c2ecf20Sopenharmony_ci	unsigned char scsi_id;
10028c2ecf20Sopenharmony_ci	bool irq_acquired:1;
10038c2ecf20Sopenharmony_ci	bool dma_chan_acquired:1;
10048c2ecf20Sopenharmony_ci	bool ext_trans_enable:1;
10058c2ecf20Sopenharmony_ci	bool parity:1;
10068c2ecf20Sopenharmony_ci	bool reset_enabled:1;
10078c2ecf20Sopenharmony_ci	bool level_int:1;
10088c2ecf20Sopenharmony_ci	bool wide:1;
10098c2ecf20Sopenharmony_ci	bool differential:1;
10108c2ecf20Sopenharmony_ci	bool scam:1;
10118c2ecf20Sopenharmony_ci	bool ultra:1;
10128c2ecf20Sopenharmony_ci	bool ext_lun:1;
10138c2ecf20Sopenharmony_ci	bool terminfo_valid:1;
10148c2ecf20Sopenharmony_ci	bool low_term:1;
10158c2ecf20Sopenharmony_ci	bool high_term:1;
10168c2ecf20Sopenharmony_ci	bool need_bouncebuf:1;
10178c2ecf20Sopenharmony_ci	bool strict_rr:1;
10188c2ecf20Sopenharmony_ci	bool scam_enabled:1;
10198c2ecf20Sopenharmony_ci	bool scam_lev2:1;
10208c2ecf20Sopenharmony_ci	bool adapter_initd:1;
10218c2ecf20Sopenharmony_ci	bool adapter_extreset:1;
10228c2ecf20Sopenharmony_ci	bool adapter_intern_err:1;
10238c2ecf20Sopenharmony_ci	bool processing_ccbs;
10248c2ecf20Sopenharmony_ci	volatile bool adapter_cmd_complete;
10258c2ecf20Sopenharmony_ci	unsigned short adapter_sglimit;
10268c2ecf20Sopenharmony_ci	unsigned short drvr_sglimit;
10278c2ecf20Sopenharmony_ci	unsigned short maxdev;
10288c2ecf20Sopenharmony_ci	unsigned short maxlun;
10298c2ecf20Sopenharmony_ci	unsigned short mbox_count;
10308c2ecf20Sopenharmony_ci	unsigned short initccbs;
10318c2ecf20Sopenharmony_ci	unsigned short inc_ccbs;
10328c2ecf20Sopenharmony_ci	unsigned short alloc_ccbs;
10338c2ecf20Sopenharmony_ci	unsigned short drvr_qdepth;
10348c2ecf20Sopenharmony_ci	unsigned short adapter_qdepth;
10358c2ecf20Sopenharmony_ci	unsigned short untag_qdepth;
10368c2ecf20Sopenharmony_ci	unsigned short common_qdepth;
10378c2ecf20Sopenharmony_ci	unsigned short bus_settle_time;
10388c2ecf20Sopenharmony_ci	unsigned short sync_ok;
10398c2ecf20Sopenharmony_ci	unsigned short fast_ok;
10408c2ecf20Sopenharmony_ci	unsigned short ultra_ok;
10418c2ecf20Sopenharmony_ci	unsigned short wide_ok;
10428c2ecf20Sopenharmony_ci	unsigned short discon_ok;
10438c2ecf20Sopenharmony_ci	unsigned short tagq_ok;
10448c2ecf20Sopenharmony_ci	unsigned short ext_resets;
10458c2ecf20Sopenharmony_ci	unsigned short adapter_intern_errors;
10468c2ecf20Sopenharmony_ci	unsigned short tgt_count;
10478c2ecf20Sopenharmony_ci	unsigned short msgbuflen;
10488c2ecf20Sopenharmony_ci	u32 bios_addr;
10498c2ecf20Sopenharmony_ci	struct blogic_drvr_options *drvr_opts;
10508c2ecf20Sopenharmony_ci	struct fpoint_info fpinfo;
10518c2ecf20Sopenharmony_ci	void *cardhandle;
10528c2ecf20Sopenharmony_ci	struct list_head host_list;
10538c2ecf20Sopenharmony_ci	struct blogic_ccb *all_ccbs;
10548c2ecf20Sopenharmony_ci	struct blogic_ccb *free_ccbs;
10558c2ecf20Sopenharmony_ci	struct blogic_ccb *firstccb;
10568c2ecf20Sopenharmony_ci	struct blogic_ccb *lastccb;
10578c2ecf20Sopenharmony_ci	struct blogic_ccb *bdr_pend[BLOGIC_MAXDEV];
10588c2ecf20Sopenharmony_ci	struct blogic_tgt_flags tgt_flags[BLOGIC_MAXDEV];
10598c2ecf20Sopenharmony_ci	unsigned char qdepth[BLOGIC_MAXDEV];
10608c2ecf20Sopenharmony_ci	unsigned char sync_period[BLOGIC_MAXDEV];
10618c2ecf20Sopenharmony_ci	unsigned char sync_offset[BLOGIC_MAXDEV];
10628c2ecf20Sopenharmony_ci	unsigned char active_cmds[BLOGIC_MAXDEV];
10638c2ecf20Sopenharmony_ci	unsigned int cmds_since_rst[BLOGIC_MAXDEV];
10648c2ecf20Sopenharmony_ci	unsigned long last_seqpoint[BLOGIC_MAXDEV];
10658c2ecf20Sopenharmony_ci	unsigned long last_resettried[BLOGIC_MAXDEV];
10668c2ecf20Sopenharmony_ci	unsigned long last_resetdone[BLOGIC_MAXDEV];
10678c2ecf20Sopenharmony_ci	struct blogic_outbox *first_outbox;
10688c2ecf20Sopenharmony_ci	struct blogic_outbox *last_outbox;
10698c2ecf20Sopenharmony_ci	struct blogic_outbox *next_outbox;
10708c2ecf20Sopenharmony_ci	struct blogic_inbox *first_inbox;
10718c2ecf20Sopenharmony_ci	struct blogic_inbox *last_inbox;
10728c2ecf20Sopenharmony_ci	struct blogic_inbox *next_inbox;
10738c2ecf20Sopenharmony_ci	struct blogic_tgt_stats tgt_stats[BLOGIC_MAXDEV];
10748c2ecf20Sopenharmony_ci	unsigned char *mbox_space;
10758c2ecf20Sopenharmony_ci	dma_addr_t mbox_space_handle;
10768c2ecf20Sopenharmony_ci	unsigned int mbox_sz;
10778c2ecf20Sopenharmony_ci	unsigned long ccb_offset;
10788c2ecf20Sopenharmony_ci	char msgbuf[BLOGIC_MSGBUF_SIZE];
10798c2ecf20Sopenharmony_ci};
10808c2ecf20Sopenharmony_ci
10818c2ecf20Sopenharmony_ci/*
10828c2ecf20Sopenharmony_ci  Define a structure for the BIOS Disk Parameters.
10838c2ecf20Sopenharmony_ci*/
10848c2ecf20Sopenharmony_ci
10858c2ecf20Sopenharmony_cistruct bios_diskparam {
10868c2ecf20Sopenharmony_ci	int heads;
10878c2ecf20Sopenharmony_ci	int sectors;
10888c2ecf20Sopenharmony_ci	int cylinders;
10898c2ecf20Sopenharmony_ci};
10908c2ecf20Sopenharmony_ci
10918c2ecf20Sopenharmony_ci/*
10928c2ecf20Sopenharmony_ci  Define a structure for the SCSI Inquiry command results.
10938c2ecf20Sopenharmony_ci*/
10948c2ecf20Sopenharmony_ci
10958c2ecf20Sopenharmony_cistruct scsi_inquiry {
10968c2ecf20Sopenharmony_ci	unsigned char devtype:5;	/* Byte 0 Bits 0-4 */
10978c2ecf20Sopenharmony_ci	unsigned char dev_qual:3;	/* Byte 0 Bits 5-7 */
10988c2ecf20Sopenharmony_ci	unsigned char dev_modifier:7;	/* Byte 1 Bits 0-6 */
10998c2ecf20Sopenharmony_ci	bool rmb:1;			/* Byte 1 Bit 7 */
11008c2ecf20Sopenharmony_ci	unsigned char ansi_ver:3;	/* Byte 2 Bits 0-2 */
11018c2ecf20Sopenharmony_ci	unsigned char ecma_ver:3;	/* Byte 2 Bits 3-5 */
11028c2ecf20Sopenharmony_ci	unsigned char iso_ver:2;	/* Byte 2 Bits 6-7 */
11038c2ecf20Sopenharmony_ci	unsigned char resp_fmt:4;	/* Byte 3 Bits 0-3 */
11048c2ecf20Sopenharmony_ci	unsigned char:2;		/* Byte 3 Bits 4-5 */
11058c2ecf20Sopenharmony_ci	bool TrmIOP:1;			/* Byte 3 Bit 6 */
11068c2ecf20Sopenharmony_ci	bool AENC:1;			/* Byte 3 Bit 7 */
11078c2ecf20Sopenharmony_ci	unsigned char addl_len;		/* Byte 4 */
11088c2ecf20Sopenharmony_ci	unsigned char:8;		/* Byte 5 */
11098c2ecf20Sopenharmony_ci	unsigned char:8;		/* Byte 6 */
11108c2ecf20Sopenharmony_ci	bool SftRe:1;			/* Byte 7 Bit 0 */
11118c2ecf20Sopenharmony_ci	bool CmdQue:1;			/* Byte 7 Bit 1 */
11128c2ecf20Sopenharmony_ci	bool:1;				/* Byte 7 Bit 2 */
11138c2ecf20Sopenharmony_ci	bool linked:1;			/* Byte 7 Bit 3 */
11148c2ecf20Sopenharmony_ci	bool sync:1;			/* Byte 7 Bit 4 */
11158c2ecf20Sopenharmony_ci	bool WBus16:1;			/* Byte 7 Bit 5 */
11168c2ecf20Sopenharmony_ci	bool WBus32:1;			/* Byte 7 Bit 6 */
11178c2ecf20Sopenharmony_ci	bool RelAdr:1;			/* Byte 7 Bit 7 */
11188c2ecf20Sopenharmony_ci	unsigned char vendor[8];	/* Bytes 8-15 */
11198c2ecf20Sopenharmony_ci	unsigned char product[16];	/* Bytes 16-31 */
11208c2ecf20Sopenharmony_ci	unsigned char product_rev[4];	/* Bytes 32-35 */
11218c2ecf20Sopenharmony_ci};
11228c2ecf20Sopenharmony_ci
11238c2ecf20Sopenharmony_ci
11248c2ecf20Sopenharmony_ci/*
11258c2ecf20Sopenharmony_ci  Define functions to provide an abstraction for reading and writing the
11268c2ecf20Sopenharmony_ci  Host Adapter I/O Registers.
11278c2ecf20Sopenharmony_ci*/
11288c2ecf20Sopenharmony_ci
11298c2ecf20Sopenharmony_cistatic inline void blogic_busreset(struct blogic_adapter *adapter)
11308c2ecf20Sopenharmony_ci{
11318c2ecf20Sopenharmony_ci	union blogic_cntrl_reg cr;
11328c2ecf20Sopenharmony_ci	cr.all = 0;
11338c2ecf20Sopenharmony_ci	cr.cr.bus_reset = true;
11348c2ecf20Sopenharmony_ci	outb(cr.all, adapter->io_addr + BLOGIC_CNTRL_REG);
11358c2ecf20Sopenharmony_ci}
11368c2ecf20Sopenharmony_ci
11378c2ecf20Sopenharmony_cistatic inline void blogic_intreset(struct blogic_adapter *adapter)
11388c2ecf20Sopenharmony_ci{
11398c2ecf20Sopenharmony_ci	union blogic_cntrl_reg cr;
11408c2ecf20Sopenharmony_ci	cr.all = 0;
11418c2ecf20Sopenharmony_ci	cr.cr.int_reset = true;
11428c2ecf20Sopenharmony_ci	outb(cr.all, adapter->io_addr + BLOGIC_CNTRL_REG);
11438c2ecf20Sopenharmony_ci}
11448c2ecf20Sopenharmony_ci
11458c2ecf20Sopenharmony_cistatic inline void blogic_softreset(struct blogic_adapter *adapter)
11468c2ecf20Sopenharmony_ci{
11478c2ecf20Sopenharmony_ci	union blogic_cntrl_reg cr;
11488c2ecf20Sopenharmony_ci	cr.all = 0;
11498c2ecf20Sopenharmony_ci	cr.cr.soft_reset = true;
11508c2ecf20Sopenharmony_ci	outb(cr.all, adapter->io_addr + BLOGIC_CNTRL_REG);
11518c2ecf20Sopenharmony_ci}
11528c2ecf20Sopenharmony_ci
11538c2ecf20Sopenharmony_cistatic inline void blogic_hardreset(struct blogic_adapter *adapter)
11548c2ecf20Sopenharmony_ci{
11558c2ecf20Sopenharmony_ci	union blogic_cntrl_reg cr;
11568c2ecf20Sopenharmony_ci	cr.all = 0;
11578c2ecf20Sopenharmony_ci	cr.cr.hard_reset = true;
11588c2ecf20Sopenharmony_ci	outb(cr.all, adapter->io_addr + BLOGIC_CNTRL_REG);
11598c2ecf20Sopenharmony_ci}
11608c2ecf20Sopenharmony_ci
11618c2ecf20Sopenharmony_cistatic inline unsigned char blogic_rdstatus(struct blogic_adapter *adapter)
11628c2ecf20Sopenharmony_ci{
11638c2ecf20Sopenharmony_ci	return inb(adapter->io_addr + BLOGIC_STATUS_REG);
11648c2ecf20Sopenharmony_ci}
11658c2ecf20Sopenharmony_ci
11668c2ecf20Sopenharmony_cistatic inline void blogic_setcmdparam(struct blogic_adapter *adapter,
11678c2ecf20Sopenharmony_ci					unsigned char value)
11688c2ecf20Sopenharmony_ci{
11698c2ecf20Sopenharmony_ci	outb(value, adapter->io_addr + BLOGIC_CMD_PARM_REG);
11708c2ecf20Sopenharmony_ci}
11718c2ecf20Sopenharmony_ci
11728c2ecf20Sopenharmony_cistatic inline unsigned char blogic_rddatain(struct blogic_adapter *adapter)
11738c2ecf20Sopenharmony_ci{
11748c2ecf20Sopenharmony_ci	return inb(adapter->io_addr + BLOGIC_DATAIN_REG);
11758c2ecf20Sopenharmony_ci}
11768c2ecf20Sopenharmony_ci
11778c2ecf20Sopenharmony_cistatic inline unsigned char blogic_rdint(struct blogic_adapter *adapter)
11788c2ecf20Sopenharmony_ci{
11798c2ecf20Sopenharmony_ci	return inb(adapter->io_addr + BLOGIC_INT_REG);
11808c2ecf20Sopenharmony_ci}
11818c2ecf20Sopenharmony_ci
11828c2ecf20Sopenharmony_cistatic inline unsigned char blogic_rdgeom(struct blogic_adapter *adapter)
11838c2ecf20Sopenharmony_ci{
11848c2ecf20Sopenharmony_ci	return inb(adapter->io_addr + BLOGIC_GEOMETRY_REG);
11858c2ecf20Sopenharmony_ci}
11868c2ecf20Sopenharmony_ci
11878c2ecf20Sopenharmony_ci/*
11888c2ecf20Sopenharmony_ci  blogic_execmbox issues an Execute Mailbox Command, which
11898c2ecf20Sopenharmony_ci  notifies the Host Adapter that an entry has been made in an Outgoing
11908c2ecf20Sopenharmony_ci  Mailbox.
11918c2ecf20Sopenharmony_ci*/
11928c2ecf20Sopenharmony_ci
11938c2ecf20Sopenharmony_cistatic inline void blogic_execmbox(struct blogic_adapter *adapter)
11948c2ecf20Sopenharmony_ci{
11958c2ecf20Sopenharmony_ci	blogic_setcmdparam(adapter, BLOGIC_EXEC_MBOX_CMD);
11968c2ecf20Sopenharmony_ci}
11978c2ecf20Sopenharmony_ci
11988c2ecf20Sopenharmony_ci/*
11998c2ecf20Sopenharmony_ci  blogic_delay waits for Seconds to elapse.
12008c2ecf20Sopenharmony_ci*/
12018c2ecf20Sopenharmony_ci
12028c2ecf20Sopenharmony_cistatic inline void blogic_delay(int seconds)
12038c2ecf20Sopenharmony_ci{
12048c2ecf20Sopenharmony_ci	mdelay(1000 * seconds);
12058c2ecf20Sopenharmony_ci}
12068c2ecf20Sopenharmony_ci
12078c2ecf20Sopenharmony_ci/*
12088c2ecf20Sopenharmony_ci  virt_to_32bit_virt maps between Kernel Virtual Addresses and
12098c2ecf20Sopenharmony_ci  32 bit Kernel Virtual Addresses.  This avoids compilation warnings
12108c2ecf20Sopenharmony_ci  on 64 bit architectures.
12118c2ecf20Sopenharmony_ci*/
12128c2ecf20Sopenharmony_ci
12138c2ecf20Sopenharmony_cistatic inline u32 virt_to_32bit_virt(void *virt_addr)
12148c2ecf20Sopenharmony_ci{
12158c2ecf20Sopenharmony_ci	return (u32) (unsigned long) virt_addr;
12168c2ecf20Sopenharmony_ci}
12178c2ecf20Sopenharmony_ci
12188c2ecf20Sopenharmony_ci/*
12198c2ecf20Sopenharmony_ci  blogic_inc_count increments counter by 1, stopping at
12208c2ecf20Sopenharmony_ci  65535 rather than wrapping around to 0.
12218c2ecf20Sopenharmony_ci*/
12228c2ecf20Sopenharmony_ci
12238c2ecf20Sopenharmony_cistatic inline void blogic_inc_count(unsigned short *count)
12248c2ecf20Sopenharmony_ci{
12258c2ecf20Sopenharmony_ci	if (*count < 65535)
12268c2ecf20Sopenharmony_ci		(*count)++;
12278c2ecf20Sopenharmony_ci}
12288c2ecf20Sopenharmony_ci
12298c2ecf20Sopenharmony_ci/*
12308c2ecf20Sopenharmony_ci  blogic_addcount increments Byte Counter by Amount.
12318c2ecf20Sopenharmony_ci*/
12328c2ecf20Sopenharmony_ci
12338c2ecf20Sopenharmony_cistatic inline void blogic_addcount(struct blogic_byte_count *bytecount,
12348c2ecf20Sopenharmony_ci					unsigned int amount)
12358c2ecf20Sopenharmony_ci{
12368c2ecf20Sopenharmony_ci	bytecount->units += amount;
12378c2ecf20Sopenharmony_ci	if (bytecount->units > 999999999) {
12388c2ecf20Sopenharmony_ci		bytecount->units -= 1000000000;
12398c2ecf20Sopenharmony_ci		bytecount->billions++;
12408c2ecf20Sopenharmony_ci	}
12418c2ecf20Sopenharmony_ci}
12428c2ecf20Sopenharmony_ci
12438c2ecf20Sopenharmony_ci/*
12448c2ecf20Sopenharmony_ci  blogic_incszbucket increments the Bucket for Amount.
12458c2ecf20Sopenharmony_ci*/
12468c2ecf20Sopenharmony_ci
12478c2ecf20Sopenharmony_cistatic inline void blogic_incszbucket(unsigned int *cmdsz_buckets,
12488c2ecf20Sopenharmony_ci					unsigned int amount)
12498c2ecf20Sopenharmony_ci{
12508c2ecf20Sopenharmony_ci	int index = 0;
12518c2ecf20Sopenharmony_ci	if (amount < 8 * 1024) {
12528c2ecf20Sopenharmony_ci		if (amount < 2 * 1024)
12538c2ecf20Sopenharmony_ci			index = (amount < 1 * 1024 ? 0 : 1);
12548c2ecf20Sopenharmony_ci		else
12558c2ecf20Sopenharmony_ci			index = (amount < 4 * 1024 ? 2 : 3);
12568c2ecf20Sopenharmony_ci	} else if (amount < 128 * 1024) {
12578c2ecf20Sopenharmony_ci		if (amount < 32 * 1024)
12588c2ecf20Sopenharmony_ci			index = (amount < 16 * 1024 ? 4 : 5);
12598c2ecf20Sopenharmony_ci		else
12608c2ecf20Sopenharmony_ci			index = (amount < 64 * 1024 ? 6 : 7);
12618c2ecf20Sopenharmony_ci	} else
12628c2ecf20Sopenharmony_ci		index = (amount < 256 * 1024 ? 8 : 9);
12638c2ecf20Sopenharmony_ci	cmdsz_buckets[index]++;
12648c2ecf20Sopenharmony_ci}
12658c2ecf20Sopenharmony_ci
12668c2ecf20Sopenharmony_ci/*
12678c2ecf20Sopenharmony_ci  Define the version number of the FlashPoint Firmware (SCCB Manager).
12688c2ecf20Sopenharmony_ci*/
12698c2ecf20Sopenharmony_ci
12708c2ecf20Sopenharmony_ci#define FLASHPOINT_FW_VER		"5.02"
12718c2ecf20Sopenharmony_ci
12728c2ecf20Sopenharmony_ci/*
12738c2ecf20Sopenharmony_ci  Define the possible return values from FlashPoint_HandleInterrupt.
12748c2ecf20Sopenharmony_ci*/
12758c2ecf20Sopenharmony_ci
12768c2ecf20Sopenharmony_ci#define FPOINT_NORMAL_INT		0x00
12778c2ecf20Sopenharmony_ci#define FPOINT_INTERN_ERR		0xFE
12788c2ecf20Sopenharmony_ci#define FPOINT_EXT_RESET		0xFF
12798c2ecf20Sopenharmony_ci
12808c2ecf20Sopenharmony_ci/*
12818c2ecf20Sopenharmony_ci  Define prototypes for the forward referenced BusLogic Driver
12828c2ecf20Sopenharmony_ci  Internal Functions.
12838c2ecf20Sopenharmony_ci*/
12848c2ecf20Sopenharmony_ci
12858c2ecf20Sopenharmony_cistatic const char *blogic_drvr_info(struct Scsi_Host *);
12868c2ecf20Sopenharmony_cistatic int blogic_qcmd(struct Scsi_Host *h, struct scsi_cmnd *);
12878c2ecf20Sopenharmony_cistatic int blogic_diskparam(struct scsi_device *, struct block_device *, sector_t, int *);
12888c2ecf20Sopenharmony_cistatic int blogic_slaveconfig(struct scsi_device *);
12898c2ecf20Sopenharmony_cistatic void blogic_qcompleted_ccb(struct blogic_ccb *);
12908c2ecf20Sopenharmony_cistatic irqreturn_t blogic_inthandler(int, void *);
12918c2ecf20Sopenharmony_cistatic int blogic_resetadapter(struct blogic_adapter *, bool hard_reset);
12928c2ecf20Sopenharmony_cistatic void blogic_msg(enum blogic_msglevel, char *, struct blogic_adapter *, ...);
12938c2ecf20Sopenharmony_cistatic int __init blogic_setup(char *);
12948c2ecf20Sopenharmony_ci
12958c2ecf20Sopenharmony_ci#endif				/* _BUSLOGIC_H */
1296