xref: /openbmc/linux/drivers/scsi/qlogicpti.h (revision 597473720f4dc69749542bfcfed4a927a43d935e)
1*b2441318SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 */
21da177e4SLinus Torvalds /* qlogicpti.h: Performance Technologies QlogicISP sbus card defines.
31da177e4SLinus Torvalds  *
41da177e4SLinus Torvalds  * Copyright (C) 1996 David S. Miller (davem@caipfs.rutgers.edu)
51da177e4SLinus Torvalds  */
61da177e4SLinus Torvalds 
71da177e4SLinus Torvalds #ifndef _QLOGICPTI_H
81da177e4SLinus Torvalds #define _QLOGICPTI_H
91da177e4SLinus Torvalds 
101da177e4SLinus Torvalds /* Qlogic/SBUS controller registers. */
111da177e4SLinus Torvalds #define SBUS_CFG1	0x006UL
121da177e4SLinus Torvalds #define SBUS_CTRL	0x008UL
131da177e4SLinus Torvalds #define SBUS_STAT	0x00aUL
141da177e4SLinus Torvalds #define SBUS_SEMAPHORE	0x00cUL
151da177e4SLinus Torvalds #define CMD_DMA_CTRL	0x022UL
161da177e4SLinus Torvalds #define DATA_DMA_CTRL	0x042UL
171da177e4SLinus Torvalds #define MBOX0		0x080UL
181da177e4SLinus Torvalds #define MBOX1		0x082UL
191da177e4SLinus Torvalds #define MBOX2		0x084UL
201da177e4SLinus Torvalds #define MBOX3		0x086UL
211da177e4SLinus Torvalds #define MBOX4		0x088UL
221da177e4SLinus Torvalds #define MBOX5		0x08aUL
231da177e4SLinus Torvalds #define CPU_CMD		0x214UL
241da177e4SLinus Torvalds #define CPU_ORIDE	0x224UL
251da177e4SLinus Torvalds #define CPU_PCTRL	0x272UL
261da177e4SLinus Torvalds #define CPU_PDIFF	0x276UL
271da177e4SLinus Torvalds #define RISC_PSR	0x420UL
281da177e4SLinus Torvalds #define RISC_MTREG	0x42EUL
291da177e4SLinus Torvalds #define HCCTRL		0x440UL
301da177e4SLinus Torvalds 
311da177e4SLinus Torvalds /* SCSI parameters for this driver. */
321da177e4SLinus Torvalds #define MAX_TARGETS	16
331da177e4SLinus Torvalds #define MAX_LUNS	8
341da177e4SLinus Torvalds 
351da177e4SLinus Torvalds /* With the qlogic interface, every queue slot can hold a SCSI
361da177e4SLinus Torvalds  * command with up to 4 scatter/gather entries.  If we need more
371da177e4SLinus Torvalds  * than 4 entries, continuation entries can be used that hold
381da177e4SLinus Torvalds  * another 7 entries each.  Unlike for other drivers, this means
391da177e4SLinus Torvalds  * that the maximum number of scatter/gather entries we can
401da177e4SLinus Torvalds  * support at any given time is a function of the number of queue
411da177e4SLinus Torvalds  * slots available.  That is, host->can_queue and host->sg_tablesize
421da177e4SLinus Torvalds  * are dynamic and _not_ independent.  This all works fine because
431da177e4SLinus Torvalds  * requests are queued serially and the scatter/gather limit is
441da177e4SLinus Torvalds  * determined for each queue request anew.
451da177e4SLinus Torvalds  */
461da177e4SLinus Torvalds #define QLOGICPTI_REQ_QUEUE_LEN	255	/* must be power of two - 1 */
47cd7560cbSRoel Kluin #define QLOGICPTI_MAX_SG(ql)	(4 + (((ql) > 0) ? 7*((ql) - 1) : 0))
481da177e4SLinus Torvalds 
491da177e4SLinus Torvalds /* mailbox command complete status codes */
501da177e4SLinus Torvalds #define MBOX_COMMAND_COMPLETE		0x4000
511da177e4SLinus Torvalds #define INVALID_COMMAND			0x4001
521da177e4SLinus Torvalds #define HOST_INTERFACE_ERROR		0x4002
531da177e4SLinus Torvalds #define TEST_FAILED			0x4003
541da177e4SLinus Torvalds #define COMMAND_ERROR			0x4005
551da177e4SLinus Torvalds #define COMMAND_PARAM_ERROR		0x4006
561da177e4SLinus Torvalds 
571da177e4SLinus Torvalds /* async event status codes */
581da177e4SLinus Torvalds #define ASYNC_SCSI_BUS_RESET		0x8001
591da177e4SLinus Torvalds #define SYSTEM_ERROR			0x8002
601da177e4SLinus Torvalds #define REQUEST_TRANSFER_ERROR		0x8003
611da177e4SLinus Torvalds #define RESPONSE_TRANSFER_ERROR		0x8004
621da177e4SLinus Torvalds #define REQUEST_QUEUE_WAKEUP		0x8005
631da177e4SLinus Torvalds #define EXECUTION_TIMEOUT_RESET		0x8006
641da177e4SLinus Torvalds 
651da177e4SLinus Torvalds /* Am I fucking pedantic or what? */
661da177e4SLinus Torvalds struct Entry_header {
671da177e4SLinus Torvalds #ifdef __BIG_ENDIAN
681da177e4SLinus Torvalds 	u8	entry_cnt;
691da177e4SLinus Torvalds 	u8	entry_type;
701da177e4SLinus Torvalds 	u8	flags;
711da177e4SLinus Torvalds 	u8	sys_def_1;
721da177e4SLinus Torvalds #else /* __LITTLE_ENDIAN */
731da177e4SLinus Torvalds 	u8	entry_type;
741da177e4SLinus Torvalds 	u8	entry_cnt;
751da177e4SLinus Torvalds 	u8	sys_def_1;
761da177e4SLinus Torvalds 	u8	flags;
771da177e4SLinus Torvalds #endif
781da177e4SLinus Torvalds };
791da177e4SLinus Torvalds 
801da177e4SLinus Torvalds /* entry header type commands */
811da177e4SLinus Torvalds #define ENTRY_COMMAND		1
821da177e4SLinus Torvalds #define ENTRY_CONTINUATION	2
831da177e4SLinus Torvalds #define ENTRY_STATUS		3
841da177e4SLinus Torvalds #define ENTRY_MARKER		4
851da177e4SLinus Torvalds #define ENTRY_EXTENDED_COMMAND	5
861da177e4SLinus Torvalds 
871da177e4SLinus Torvalds /* entry header flag definitions */
881da177e4SLinus Torvalds #define EFLAG_CONTINUATION	1
891da177e4SLinus Torvalds #define EFLAG_BUSY		2
901da177e4SLinus Torvalds #define EFLAG_BAD_HEADER	4
911da177e4SLinus Torvalds #define EFLAG_BAD_PAYLOAD	8
921da177e4SLinus Torvalds 
931da177e4SLinus Torvalds struct dataseg {
941da177e4SLinus Torvalds 	u32	d_base;
951da177e4SLinus Torvalds 	u32	d_count;
961da177e4SLinus Torvalds };
971da177e4SLinus Torvalds 
981da177e4SLinus Torvalds struct Command_Entry {
991da177e4SLinus Torvalds 	struct Entry_header	hdr;
1001da177e4SLinus Torvalds 	u32			handle;
1011da177e4SLinus Torvalds #ifdef __BIG_ENDIAN
1021da177e4SLinus Torvalds 	u8			target_id;
1031da177e4SLinus Torvalds 	u8			target_lun;
1041da177e4SLinus Torvalds #else /* __LITTLE_ENDIAN */
1051da177e4SLinus Torvalds 	u8			target_lun;
1061da177e4SLinus Torvalds 	u8			target_id;
1071da177e4SLinus Torvalds #endif
1081da177e4SLinus Torvalds 	u16			cdb_length;
1091da177e4SLinus Torvalds 	u16			control_flags;
1101da177e4SLinus Torvalds 	u16			rsvd;
1111da177e4SLinus Torvalds 	u16			time_out;
1121da177e4SLinus Torvalds 	u16			segment_cnt;
1131da177e4SLinus Torvalds 	u8			cdb[12];
1141da177e4SLinus Torvalds 	struct dataseg		dataseg[4];
1151da177e4SLinus Torvalds };
1161da177e4SLinus Torvalds 
1171da177e4SLinus Torvalds /* command entry control flag definitions */
1181da177e4SLinus Torvalds #define CFLAG_NODISC		0x01
1191da177e4SLinus Torvalds #define CFLAG_HEAD_TAG		0x02
1201da177e4SLinus Torvalds #define CFLAG_ORDERED_TAG	0x04
1211da177e4SLinus Torvalds #define CFLAG_SIMPLE_TAG	0x08
1221da177e4SLinus Torvalds #define CFLAG_TAR_RTN		0x10
1231da177e4SLinus Torvalds #define CFLAG_READ		0x20
1241da177e4SLinus Torvalds #define CFLAG_WRITE		0x40
1251da177e4SLinus Torvalds 
1261da177e4SLinus Torvalds struct Ext_Command_Entry {
1271da177e4SLinus Torvalds 	struct Entry_header	hdr;
1281da177e4SLinus Torvalds 	u32			handle;
1291da177e4SLinus Torvalds #ifdef __BIG_ENDIAN
1301da177e4SLinus Torvalds 	u8			target_id;
1311da177e4SLinus Torvalds 	u8			target_lun;
1321da177e4SLinus Torvalds #else /* __LITTLE_ENDIAN */
1331da177e4SLinus Torvalds 	u8			target_lun;
1341da177e4SLinus Torvalds 	u8			target_id;
1351da177e4SLinus Torvalds #endif
1361da177e4SLinus Torvalds 	u16			cdb_length;
1371da177e4SLinus Torvalds 	u16			control_flags;
1381da177e4SLinus Torvalds 	u16			rsvd;
1391da177e4SLinus Torvalds 	u16			time_out;
1401da177e4SLinus Torvalds 	u16			segment_cnt;
1411da177e4SLinus Torvalds 	u8			cdb[44];
1421da177e4SLinus Torvalds };
1431da177e4SLinus Torvalds 
1441da177e4SLinus Torvalds struct Continuation_Entry {
1451da177e4SLinus Torvalds 	struct Entry_header	hdr;
1461da177e4SLinus Torvalds 	u32			reserved;
1471da177e4SLinus Torvalds 	struct dataseg		dataseg[7];
1481da177e4SLinus Torvalds };
1491da177e4SLinus Torvalds 
1501da177e4SLinus Torvalds struct Marker_Entry {
1511da177e4SLinus Torvalds 	struct Entry_header	hdr;
1521da177e4SLinus Torvalds 	u32			reserved;
1531da177e4SLinus Torvalds #ifdef __BIG_ENDIAN
1541da177e4SLinus Torvalds 	u8			target_id;
1551da177e4SLinus Torvalds 	u8			target_lun;
1561da177e4SLinus Torvalds #else /* __LITTLE_ENDIAN */
1571da177e4SLinus Torvalds 	u8			target_lun;
1581da177e4SLinus Torvalds 	u8			target_id;
1591da177e4SLinus Torvalds #endif
1601da177e4SLinus Torvalds #ifdef __BIG_ENDIAN
1611da177e4SLinus Torvalds 	u8			rsvd;
1621da177e4SLinus Torvalds 	u8			modifier;
1631da177e4SLinus Torvalds #else /* __LITTLE_ENDIAN */
1641da177e4SLinus Torvalds 	u8			modifier;
1651da177e4SLinus Torvalds 	u8			rsvd;
1661da177e4SLinus Torvalds #endif
1671da177e4SLinus Torvalds 	u8			rsvds[52];
1681da177e4SLinus Torvalds };
1691da177e4SLinus Torvalds 
1701da177e4SLinus Torvalds /* marker entry modifier definitions */
1711da177e4SLinus Torvalds #define SYNC_DEVICE	0
1721da177e4SLinus Torvalds #define SYNC_TARGET	1
1731da177e4SLinus Torvalds #define SYNC_ALL	2
1741da177e4SLinus Torvalds 
1751da177e4SLinus Torvalds struct Status_Entry {
1761da177e4SLinus Torvalds 	struct Entry_header	hdr;
1771da177e4SLinus Torvalds 	u32			handle;
1781da177e4SLinus Torvalds 	u16			scsi_status;
1791da177e4SLinus Torvalds 	u16			completion_status;
1801da177e4SLinus Torvalds 	u16			state_flags;
1811da177e4SLinus Torvalds 	u16			status_flags;
1821da177e4SLinus Torvalds 	u16			time;
1831da177e4SLinus Torvalds 	u16			req_sense_len;
1841da177e4SLinus Torvalds 	u32			residual;
1851da177e4SLinus Torvalds 	u8			rsvd[8];
1861da177e4SLinus Torvalds 	u8			req_sense_data[32];
1871da177e4SLinus Torvalds };
1881da177e4SLinus Torvalds 
1891da177e4SLinus Torvalds /* status entry completion status definitions */
1901da177e4SLinus Torvalds #define CS_COMPLETE			0x0000
1911da177e4SLinus Torvalds #define CS_INCOMPLETE			0x0001
1921da177e4SLinus Torvalds #define CS_DMA_ERROR			0x0002
1931da177e4SLinus Torvalds #define CS_TRANSPORT_ERROR		0x0003
1941da177e4SLinus Torvalds #define CS_RESET_OCCURRED		0x0004
1951da177e4SLinus Torvalds #define CS_ABORTED			0x0005
1961da177e4SLinus Torvalds #define CS_TIMEOUT			0x0006
1971da177e4SLinus Torvalds #define CS_DATA_OVERRUN			0x0007
1981da177e4SLinus Torvalds #define CS_COMMAND_OVERRUN		0x0008
1991da177e4SLinus Torvalds #define CS_STATUS_OVERRUN		0x0009
2001da177e4SLinus Torvalds #define CS_BAD_MESSAGE			0x000a
2011da177e4SLinus Torvalds #define CS_NO_MESSAGE_OUT		0x000b
2021da177e4SLinus Torvalds #define CS_EXT_ID_FAILED		0x000c
2031da177e4SLinus Torvalds #define CS_IDE_MSG_FAILED		0x000d
2041da177e4SLinus Torvalds #define CS_ABORT_MSG_FAILED		0x000e
2051da177e4SLinus Torvalds #define CS_REJECT_MSG_FAILED		0x000f
2061da177e4SLinus Torvalds #define CS_NOP_MSG_FAILED		0x0010
2071da177e4SLinus Torvalds #define CS_PARITY_ERROR_MSG_FAILED	0x0011
2081da177e4SLinus Torvalds #define CS_DEVICE_RESET_MSG_FAILED	0x0012
2091da177e4SLinus Torvalds #define CS_ID_MSG_FAILED		0x0013
2101da177e4SLinus Torvalds #define CS_UNEXP_BUS_FREE		0x0014
2111da177e4SLinus Torvalds #define CS_DATA_UNDERRUN		0x0015
2121da177e4SLinus Torvalds #define CS_BUS_RESET			0x001c
2131da177e4SLinus Torvalds 
2141da177e4SLinus Torvalds /* status entry state flag definitions */
2151da177e4SLinus Torvalds #define SF_GOT_BUS			0x0100
2161da177e4SLinus Torvalds #define SF_GOT_TARGET			0x0200
2171da177e4SLinus Torvalds #define SF_SENT_CDB			0x0400
2181da177e4SLinus Torvalds #define SF_TRANSFERRED_DATA		0x0800
2191da177e4SLinus Torvalds #define SF_GOT_STATUS			0x1000
2201da177e4SLinus Torvalds #define SF_GOT_SENSE			0x2000
2211da177e4SLinus Torvalds 
2221da177e4SLinus Torvalds /* status entry status flag definitions */
2231da177e4SLinus Torvalds #define STF_DISCONNECT			0x0001
2241da177e4SLinus Torvalds #define STF_SYNCHRONOUS			0x0002
2251da177e4SLinus Torvalds #define STF_PARITY_ERROR		0x0004
2261da177e4SLinus Torvalds #define STF_BUS_RESET			0x0008
2271da177e4SLinus Torvalds #define STF_DEVICE_RESET		0x0010
2281da177e4SLinus Torvalds #define STF_ABORTED			0x0020
2291da177e4SLinus Torvalds #define STF_TIMEOUT			0x0040
2301da177e4SLinus Torvalds #define STF_NEGOTIATION			0x0080
2311da177e4SLinus Torvalds 
2321da177e4SLinus Torvalds /* mailbox commands */
2331da177e4SLinus Torvalds #define MBOX_NO_OP			0x0000
2341da177e4SLinus Torvalds #define MBOX_LOAD_RAM			0x0001
2351da177e4SLinus Torvalds #define MBOX_EXEC_FIRMWARE		0x0002
2361da177e4SLinus Torvalds #define MBOX_DUMP_RAM			0x0003
2371da177e4SLinus Torvalds #define MBOX_WRITE_RAM_WORD		0x0004
2381da177e4SLinus Torvalds #define MBOX_READ_RAM_WORD		0x0005
2391da177e4SLinus Torvalds #define MBOX_MAILBOX_REG_TEST		0x0006
2401da177e4SLinus Torvalds #define MBOX_VERIFY_CHECKSUM		0x0007
2411da177e4SLinus Torvalds #define MBOX_ABOUT_FIRMWARE		0x0008
2421da177e4SLinus Torvalds #define MBOX_CHECK_FIRMWARE		0x000e
2431da177e4SLinus Torvalds #define MBOX_INIT_REQ_QUEUE		0x0010
2441da177e4SLinus Torvalds #define MBOX_INIT_RES_QUEUE		0x0011
2451da177e4SLinus Torvalds #define MBOX_EXECUTE_IOCB		0x0012
2461da177e4SLinus Torvalds #define MBOX_WAKE_UP			0x0013
2471da177e4SLinus Torvalds #define MBOX_STOP_FIRMWARE		0x0014
2481da177e4SLinus Torvalds #define MBOX_ABORT			0x0015
2491da177e4SLinus Torvalds #define MBOX_ABORT_DEVICE		0x0016
2501da177e4SLinus Torvalds #define MBOX_ABORT_TARGET		0x0017
2511da177e4SLinus Torvalds #define MBOX_BUS_RESET			0x0018
2521da177e4SLinus Torvalds #define MBOX_STOP_QUEUE			0x0019
2531da177e4SLinus Torvalds #define MBOX_START_QUEUE		0x001a
2541da177e4SLinus Torvalds #define MBOX_SINGLE_STEP_QUEUE		0x001b
2551da177e4SLinus Torvalds #define MBOX_ABORT_QUEUE		0x001c
2561da177e4SLinus Torvalds #define MBOX_GET_DEV_QUEUE_STATUS	0x001d
2571da177e4SLinus Torvalds #define MBOX_GET_FIRMWARE_STATUS	0x001f
2581da177e4SLinus Torvalds #define MBOX_GET_INIT_SCSI_ID		0x0020
2591da177e4SLinus Torvalds #define MBOX_GET_SELECT_TIMEOUT		0x0021
2601da177e4SLinus Torvalds #define MBOX_GET_RETRY_COUNT		0x0022
2611da177e4SLinus Torvalds #define MBOX_GET_TAG_AGE_LIMIT		0x0023
2621da177e4SLinus Torvalds #define MBOX_GET_CLOCK_RATE		0x0024
2631da177e4SLinus Torvalds #define MBOX_GET_ACT_NEG_STATE		0x0025
2641da177e4SLinus Torvalds #define MBOX_GET_ASYNC_DATA_SETUP_TIME	0x0026
2651da177e4SLinus Torvalds #define MBOX_GET_SBUS_PARAMS		0x0027
2661da177e4SLinus Torvalds #define MBOX_GET_TARGET_PARAMS		0x0028
2671da177e4SLinus Torvalds #define MBOX_GET_DEV_QUEUE_PARAMS	0x0029
2681da177e4SLinus Torvalds #define MBOX_SET_INIT_SCSI_ID		0x0030
2691da177e4SLinus Torvalds #define MBOX_SET_SELECT_TIMEOUT		0x0031
2701da177e4SLinus Torvalds #define MBOX_SET_RETRY_COUNT		0x0032
2711da177e4SLinus Torvalds #define MBOX_SET_TAG_AGE_LIMIT		0x0033
2721da177e4SLinus Torvalds #define MBOX_SET_CLOCK_RATE		0x0034
2731da177e4SLinus Torvalds #define MBOX_SET_ACTIVE_NEG_STATE	0x0035
2741da177e4SLinus Torvalds #define MBOX_SET_ASYNC_DATA_SETUP_TIME	0x0036
2751da177e4SLinus Torvalds #define MBOX_SET_SBUS_CONTROL_PARAMS	0x0037
2761da177e4SLinus Torvalds #define MBOX_SET_TARGET_PARAMS		0x0038
2771da177e4SLinus Torvalds #define MBOX_SET_DEV_QUEUE_PARAMS	0x0039
2781da177e4SLinus Torvalds 
2791da177e4SLinus Torvalds struct host_param {
2801da177e4SLinus Torvalds 	u_short		initiator_scsi_id;
2811da177e4SLinus Torvalds 	u_short		bus_reset_delay;
2821da177e4SLinus Torvalds 	u_short		retry_count;
2831da177e4SLinus Torvalds 	u_short		retry_delay;
2841da177e4SLinus Torvalds 	u_short		async_data_setup_time;
2851da177e4SLinus Torvalds 	u_short		req_ack_active_negation;
2861da177e4SLinus Torvalds 	u_short		data_line_active_negation;
2871da177e4SLinus Torvalds 	u_short		data_dma_burst_enable;
2881da177e4SLinus Torvalds 	u_short		command_dma_burst_enable;
2891da177e4SLinus Torvalds 	u_short		tag_aging;
2901da177e4SLinus Torvalds 	u_short		selection_timeout;
2911da177e4SLinus Torvalds 	u_short		max_queue_depth;
2921da177e4SLinus Torvalds };
2931da177e4SLinus Torvalds 
2941da177e4SLinus Torvalds /*
2951da177e4SLinus Torvalds  * Device Flags:
2961da177e4SLinus Torvalds  *
2971da177e4SLinus Torvalds  * Bit  Name
2981da177e4SLinus Torvalds  * ---------
2991da177e4SLinus Torvalds  *  7   Disconnect Privilege
3001da177e4SLinus Torvalds  *  6   Parity Checking
3011da177e4SLinus Torvalds  *  5   Wide Data Transfers
3021da177e4SLinus Torvalds  *  4   Synchronous Data Transfers
3031da177e4SLinus Torvalds  *  3   Tagged Queuing
3041da177e4SLinus Torvalds  *  2   Automatic Request Sense
3051da177e4SLinus Torvalds  *  1   Stop Queue on Check Condition
3061da177e4SLinus Torvalds  *  0   Renegotiate on Error
3071da177e4SLinus Torvalds  */
3081da177e4SLinus Torvalds 
3091da177e4SLinus Torvalds struct dev_param {
3101da177e4SLinus Torvalds 	u_short		device_flags;
3111da177e4SLinus Torvalds 	u_short		execution_throttle;
3121da177e4SLinus Torvalds 	u_short		synchronous_period;
3131da177e4SLinus Torvalds 	u_short		synchronous_offset;
3141da177e4SLinus Torvalds 	u_short		device_enable;
3151da177e4SLinus Torvalds 	u_short		reserved; /* pad */
3161da177e4SLinus Torvalds };
3171da177e4SLinus Torvalds 
3181da177e4SLinus Torvalds /*
3191da177e4SLinus Torvalds  * The result queue can be quite a bit smaller since continuation entries
3201da177e4SLinus Torvalds  * do not show up there:
3211da177e4SLinus Torvalds  */
3221da177e4SLinus Torvalds #define RES_QUEUE_LEN		255	/* Must be power of two - 1 */
3231da177e4SLinus Torvalds #define QUEUE_ENTRY_LEN		64
3241da177e4SLinus Torvalds 
3251da177e4SLinus Torvalds #define NEXT_REQ_PTR(wheee)   (((wheee) + 1) & QLOGICPTI_REQ_QUEUE_LEN)
3261da177e4SLinus Torvalds #define NEXT_RES_PTR(wheee)   (((wheee) + 1) & RES_QUEUE_LEN)
3271da177e4SLinus Torvalds #define PREV_REQ_PTR(wheee)   (((wheee) - 1) & QLOGICPTI_REQ_QUEUE_LEN)
3281da177e4SLinus Torvalds #define PREV_RES_PTR(wheee)   (((wheee) - 1) & RES_QUEUE_LEN)
3291da177e4SLinus Torvalds 
3301da177e4SLinus Torvalds struct pti_queue_entry {
3311da177e4SLinus Torvalds 	char __opaque[QUEUE_ENTRY_LEN];
3321da177e4SLinus Torvalds };
3331da177e4SLinus Torvalds 
3341da177e4SLinus Torvalds struct scsi_cmnd;
3351da177e4SLinus Torvalds 
3361da177e4SLinus Torvalds /* Software state for the driver. */
3371da177e4SLinus Torvalds struct qlogicpti {
3381da177e4SLinus Torvalds 	/* These are the hot elements in the cache, so they come first. */
3391da177e4SLinus Torvalds 	void __iomem             *qregs;                /* Adapter registers          */
3401da177e4SLinus Torvalds 	struct pti_queue_entry   *res_cpu;              /* Ptr to RESPONSE bufs (CPU) */
3411da177e4SLinus Torvalds 	struct pti_queue_entry   *req_cpu;              /* Ptr to REQUEST bufs (CPU)  */
3421da177e4SLinus Torvalds 
3431da177e4SLinus Torvalds 	u_int	                  req_in_ptr;		/* index of next request slot */
3441da177e4SLinus Torvalds 	u_int	                  res_out_ptr;		/* index of next result slot  */
3451da177e4SLinus Torvalds 	long	                  send_marker;		/* must we send a marker?     */
3462dc11581SGrant Likely 	struct platform_device	 *op;
3471da177e4SLinus Torvalds 	unsigned long		  __pad;
3481da177e4SLinus Torvalds 
3491da177e4SLinus Torvalds 	int                       cmd_count[MAX_TARGETS];
3501da177e4SLinus Torvalds 	unsigned long             tag_ages[MAX_TARGETS];
3511da177e4SLinus Torvalds 
3521da177e4SLinus Torvalds 	/* The cmd->handler is only 32-bits, so that things work even on monster
3531da177e4SLinus Torvalds 	 * Ex000 sparc64 machines with >4GB of ram we just keep track of the
3541da177e4SLinus Torvalds 	 * scsi command pointers here.  This is essentially what Matt Jacob does. -DaveM
3551da177e4SLinus Torvalds 	 */
3561da177e4SLinus Torvalds 	struct scsi_cmnd         *cmd_slots[QLOGICPTI_REQ_QUEUE_LEN + 1];
3571da177e4SLinus Torvalds 
3581da177e4SLinus Torvalds 	/* The rest of the elements are unimportant for performance. */
3591da177e4SLinus Torvalds 	struct qlogicpti         *next;
360e58566b1STushar Dave 	dma_addr_t                res_dvma;             /* Ptr to RESPONSE bufs (DVMA)*/
361e58566b1STushar Dave 	dma_addr_t                req_dvma;             /* Ptr to REQUEST bufs (DVMA) */
3621da177e4SLinus Torvalds 	u_char	                  fware_majrev, fware_minrev, fware_micrev;
3631da177e4SLinus Torvalds 	struct Scsi_Host         *qhost;
3641da177e4SLinus Torvalds 	int                       qpti_id;
3651da177e4SLinus Torvalds 	int                       scsi_id;
3661da177e4SLinus Torvalds 	int                       prom_node;
3671da177e4SLinus Torvalds 	int                       irq;
3681da177e4SLinus Torvalds 	char                      differential, ultra, clock;
3691da177e4SLinus Torvalds 	unsigned char             bursts;
3701da177e4SLinus Torvalds 	struct	host_param        host_param;
3711da177e4SLinus Torvalds 	struct	dev_param         dev_param[MAX_TARGETS];
3721da177e4SLinus Torvalds 
3731da177e4SLinus Torvalds 	void __iomem              *sreg;
3741da177e4SLinus Torvalds #define SREG_TPOWER               0x80   /* State of termpwr           */
3751da177e4SLinus Torvalds #define SREG_FUSE                 0x40   /* State of on board fuse     */
3761da177e4SLinus Torvalds #define SREG_PDISAB               0x20   /* Disable state for power on */
3771da177e4SLinus Torvalds #define SREG_DSENSE               0x10   /* Sense for differential     */
3781da177e4SLinus Torvalds #define SREG_IMASK                0x0c   /* Interrupt level            */
3791da177e4SLinus Torvalds #define SREG_SPMASK               0x03   /* Mask for switch pack       */
3801da177e4SLinus Torvalds 	unsigned char             swsreg;
3811da177e4SLinus Torvalds 	unsigned int
3821da177e4SLinus Torvalds 		gotirq	:	1,	/* this instance got an irq */
3839ec76fbfSMatthew Wilcox 		is_pti	: 	1;	/* Non-zero if this is a PTI board. */
3841da177e4SLinus Torvalds };
3851da177e4SLinus Torvalds 
3861da177e4SLinus Torvalds /* How to twiddle them bits... */
3871da177e4SLinus Torvalds 
3881da177e4SLinus Torvalds /* SBUS config register one. */
3891da177e4SLinus Torvalds #define SBUS_CFG1_EPAR          0x0100      /* Enable parity checking           */
3901da177e4SLinus Torvalds #define SBUS_CFG1_FMASK         0x00f0      /* Forth code cycle mask            */
3911da177e4SLinus Torvalds #define SBUS_CFG1_BENAB         0x0004      /* Burst dvma enable                */
3921da177e4SLinus Torvalds #define SBUS_CFG1_B64           0x0003      /* Enable 64byte bursts             */
3931da177e4SLinus Torvalds #define SBUS_CFG1_B32           0x0002      /* Enable 32byte bursts             */
3941da177e4SLinus Torvalds #define SBUS_CFG1_B16           0x0001      /* Enable 16byte bursts             */
3951da177e4SLinus Torvalds #define SBUS_CFG1_B8            0x0008      /* Enable 8byte bursts              */
3961da177e4SLinus Torvalds 
3971da177e4SLinus Torvalds /* SBUS control register */
3981da177e4SLinus Torvalds #define SBUS_CTRL_EDIRQ         0x0020      /* Enable Data DVMA Interrupts      */
3991da177e4SLinus Torvalds #define SBUS_CTRL_ECIRQ         0x0010      /* Enable Command DVMA Interrupts   */
4001da177e4SLinus Torvalds #define SBUS_CTRL_ESIRQ         0x0008      /* Enable SCSI Processor Interrupts */
4011da177e4SLinus Torvalds #define SBUS_CTRL_ERIRQ         0x0004      /* Enable RISC Processor Interrupts */
4021da177e4SLinus Torvalds #define SBUS_CTRL_GENAB         0x0002      /* Global Interrupt Enable          */
4031da177e4SLinus Torvalds #define SBUS_CTRL_RESET         0x0001      /* Soft Reset                       */
4041da177e4SLinus Torvalds 
4051da177e4SLinus Torvalds /* SBUS status register */
4061da177e4SLinus Torvalds #define SBUS_STAT_DINT          0x0020      /* Data DVMA IRQ pending            */
4071da177e4SLinus Torvalds #define SBUS_STAT_CINT          0x0010      /* Command DVMA IRQ pending         */
4081da177e4SLinus Torvalds #define SBUS_STAT_SINT          0x0008      /* SCSI Processor IRQ pending       */
4091da177e4SLinus Torvalds #define SBUS_STAT_RINT          0x0004      /* RISC Processor IRQ pending       */
4101da177e4SLinus Torvalds #define SBUS_STAT_GINT          0x0002      /* Global IRQ pending               */
4111da177e4SLinus Torvalds 
4121da177e4SLinus Torvalds /* SBUS semaphore register */
4131da177e4SLinus Torvalds #define SBUS_SEMAPHORE_STAT     0x0002      /* Semaphore status bit             */
4141da177e4SLinus Torvalds #define SBUS_SEMAPHORE_LCK      0x0001      /* Semaphore lock bit               */
4151da177e4SLinus Torvalds 
4161da177e4SLinus Torvalds /* DVMA control register */
4171da177e4SLinus Torvalds #define DMA_CTRL_CSUSPEND       0x0010      /* DMA channel suspend              */
4181da177e4SLinus Torvalds #define DMA_CTRL_CCLEAR         0x0008      /* DMA channel clear and reset      */
4191da177e4SLinus Torvalds #define DMA_CTRL_FCLEAR         0x0004      /* DMA fifo clear                   */
4201da177e4SLinus Torvalds #define DMA_CTRL_CIRQ           0x0002      /* DMA irq clear                    */
4211da177e4SLinus Torvalds #define DMA_CTRL_DMASTART       0x0001      /* DMA transfer start               */
4221da177e4SLinus Torvalds 
4231da177e4SLinus Torvalds /* SCSI processor override register */
4241da177e4SLinus Torvalds #define CPU_ORIDE_ETRIG         0x8000      /* External trigger enable          */
4251da177e4SLinus Torvalds #define CPU_ORIDE_STEP          0x4000      /* Single step mode enable          */
4261da177e4SLinus Torvalds #define CPU_ORIDE_BKPT          0x2000      /* Breakpoint reg enable            */
4271da177e4SLinus Torvalds #define CPU_ORIDE_PWRITE        0x1000      /* SCSI pin write enable            */
4281da177e4SLinus Torvalds #define CPU_ORIDE_OFORCE        0x0800      /* Force outputs on                 */
4291da177e4SLinus Torvalds #define CPU_ORIDE_LBACK         0x0400      /* SCSI loopback enable             */
4301da177e4SLinus Torvalds #define CPU_ORIDE_PTEST         0x0200      /* Parity test enable               */
4311da177e4SLinus Torvalds #define CPU_ORIDE_TENAB         0x0100      /* SCSI pins tristate enable        */
4321da177e4SLinus Torvalds #define CPU_ORIDE_TPINS         0x0080      /* SCSI pins enable                 */
4331da177e4SLinus Torvalds #define CPU_ORIDE_FRESET        0x0008      /* FIFO reset                       */
4341da177e4SLinus Torvalds #define CPU_ORIDE_CTERM         0x0004      /* Command terminate                */
4351da177e4SLinus Torvalds #define CPU_ORIDE_RREG          0x0002      /* Reset SCSI processor regs        */
4361da177e4SLinus Torvalds #define CPU_ORIDE_RMOD          0x0001      /* Reset SCSI processor module      */
4371da177e4SLinus Torvalds 
4381da177e4SLinus Torvalds /* SCSI processor commands */
4391da177e4SLinus Torvalds #define CPU_CMD_BRESET          0x300b      /* Reset SCSI bus                   */
4401da177e4SLinus Torvalds 
4411da177e4SLinus Torvalds /* SCSI processor pin control register */
4421da177e4SLinus Torvalds #define CPU_PCTRL_PVALID        0x8000      /* Phase bits are valid             */
4431da177e4SLinus Torvalds #define CPU_PCTRL_PHI           0x0400      /* Parity bit high                  */
4441da177e4SLinus Torvalds #define CPU_PCTRL_PLO           0x0200      /* Parity bit low                   */
4451da177e4SLinus Torvalds #define CPU_PCTRL_REQ           0x0100      /* REQ bus signal                   */
4461da177e4SLinus Torvalds #define CPU_PCTRL_ACK           0x0080      /* ACK bus signal                   */
4471da177e4SLinus Torvalds #define CPU_PCTRL_RST           0x0040      /* RST bus signal                   */
4481da177e4SLinus Torvalds #define CPU_PCTRL_BSY           0x0020      /* BSY bus signal                   */
4491da177e4SLinus Torvalds #define CPU_PCTRL_SEL           0x0010      /* SEL bus signal                   */
4501da177e4SLinus Torvalds #define CPU_PCTRL_ATN           0x0008      /* ATN bus signal                   */
4511da177e4SLinus Torvalds #define CPU_PCTRL_MSG           0x0004      /* MSG bus signal                   */
4521da177e4SLinus Torvalds #define CPU_PCTRL_CD            0x0002      /* CD bus signal                    */
4531da177e4SLinus Torvalds #define CPU_PCTRL_IO            0x0001      /* IO bus signal                    */
4541da177e4SLinus Torvalds 
4551da177e4SLinus Torvalds /* SCSI processor differential pins register */
4561da177e4SLinus Torvalds #define CPU_PDIFF_SENSE         0x0200      /* Differential sense               */
4571da177e4SLinus Torvalds #define CPU_PDIFF_MODE          0x0100      /* Differential mode                */
4581da177e4SLinus Torvalds #define CPU_PDIFF_OENAB         0x0080      /* Outputs enable                   */
4591da177e4SLinus Torvalds #define CPU_PDIFF_PMASK         0x007c      /* Differential control pins        */
4601da177e4SLinus Torvalds #define CPU_PDIFF_TGT           0x0002      /* Target mode enable               */
4611da177e4SLinus Torvalds #define CPU_PDIFF_INIT          0x0001      /* Initiator mode enable            */
4621da177e4SLinus Torvalds 
4631da177e4SLinus Torvalds /* RISC processor status register */
4641da177e4SLinus Torvalds #define RISC_PSR_FTRUE          0x8000      /* Force true                       */
4651da177e4SLinus Torvalds #define RISC_PSR_LCD            0x4000      /* Loop counter shows done status   */
4661da177e4SLinus Torvalds #define RISC_PSR_RIRQ           0x2000      /* RISC irq status                  */
4671da177e4SLinus Torvalds #define RISC_PSR_TOFLOW         0x1000      /* Timer overflow (rollover)        */
4681da177e4SLinus Torvalds #define RISC_PSR_AOFLOW         0x0800      /* Arithmetic overflow              */
4691da177e4SLinus Torvalds #define RISC_PSR_AMSB           0x0400      /* Arithmetic big endian            */
4701da177e4SLinus Torvalds #define RISC_PSR_ACARRY         0x0200      /* Arithmetic carry                 */
4711da177e4SLinus Torvalds #define RISC_PSR_AZERO          0x0100      /* Arithmetic zero                  */
4721da177e4SLinus Torvalds #define RISC_PSR_ULTRA          0x0020      /* Ultra mode                       */
4731da177e4SLinus Torvalds #define RISC_PSR_DIRQ           0x0010      /* DVMA interrupt                   */
4741da177e4SLinus Torvalds #define RISC_PSR_SIRQ           0x0008      /* SCSI processor interrupt         */
4751da177e4SLinus Torvalds #define RISC_PSR_HIRQ           0x0004      /* Host interrupt                   */
4761da177e4SLinus Torvalds #define RISC_PSR_IPEND          0x0002      /* Interrupt pending                */
4771da177e4SLinus Torvalds #define RISC_PSR_FFALSE         0x0001      /* Force false                      */
4781da177e4SLinus Torvalds 
4791da177e4SLinus Torvalds /* RISC processor memory timing register */
4801da177e4SLinus Torvalds #define RISC_MTREG_P1DFLT       0x1200      /* Default read/write timing, pg1   */
4811da177e4SLinus Torvalds #define RISC_MTREG_P0DFLT       0x0012      /* Default read/write timing, pg0   */
4821da177e4SLinus Torvalds #define RISC_MTREG_P1ULTRA      0x2300      /* Ultra-mode rw timing, pg1        */
4831da177e4SLinus Torvalds #define RISC_MTREG_P0ULTRA      0x0023      /* Ultra-mode rw timing, pg0        */
4841da177e4SLinus Torvalds 
4851da177e4SLinus Torvalds /* Host command/ctrl register */
4861da177e4SLinus Torvalds #define HCCTRL_NOP              0x0000      /* CMD: No operation                */
4871da177e4SLinus Torvalds #define HCCTRL_RESET            0x1000      /* CMD: Reset RISC cpu              */
4881da177e4SLinus Torvalds #define HCCTRL_PAUSE            0x2000      /* CMD: Pause RISC cpu              */
4891da177e4SLinus Torvalds #define HCCTRL_REL              0x3000      /* CMD: Release paused RISC cpu     */
4901da177e4SLinus Torvalds #define HCCTRL_STEP             0x4000      /* CMD: Single step RISC cpu        */
4911da177e4SLinus Torvalds #define HCCTRL_SHIRQ            0x5000      /* CMD: Set host irq                */
4921da177e4SLinus Torvalds #define HCCTRL_CHIRQ            0x6000      /* CMD: Clear host irq              */
4931da177e4SLinus Torvalds #define HCCTRL_CRIRQ            0x7000      /* CMD: Clear RISC cpu irq          */
4941da177e4SLinus Torvalds #define HCCTRL_BKPT             0x8000      /* CMD: Breakpoint enables change   */
4951da177e4SLinus Torvalds #define HCCTRL_TMODE            0xf000      /* CMD: Enable test mode            */
4961da177e4SLinus Torvalds #define HCCTRL_HIRQ             0x0080      /* Host IRQ pending                 */
4971da177e4SLinus Torvalds #define HCCTRL_RRIP             0x0040      /* RISC cpu reset in happening now  */
4981da177e4SLinus Torvalds #define HCCTRL_RPAUSED          0x0020      /* RISC cpu is paused now           */
4991da177e4SLinus Torvalds #define HCCTRL_EBENAB           0x0010      /* External breakpoint enable       */
5001da177e4SLinus Torvalds #define HCCTRL_B1ENAB           0x0008      /* Breakpoint 1 enable              */
5011da177e4SLinus Torvalds #define HCCTRL_B0ENAB           0x0004      /* Breakpoint 0 enable              */
5021da177e4SLinus Torvalds 
5031da177e4SLinus Torvalds /* For our interrupt engine. */
5041da177e4SLinus Torvalds #define for_each_qlogicpti(qp) \
5051da177e4SLinus Torvalds         for((qp) = qptichain; (qp); (qp) = (qp)->next)
5061da177e4SLinus Torvalds 
5071da177e4SLinus Torvalds #endif /* !(_QLOGICPTI_H) */
508