162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 262306a36Sopenharmony_ci/* qlogicpti.h: Performance Technologies QlogicISP sbus card defines. 362306a36Sopenharmony_ci * 462306a36Sopenharmony_ci * Copyright (C) 1996 David S. Miller (davem@caipfs.rutgers.edu) 562306a36Sopenharmony_ci */ 662306a36Sopenharmony_ci 762306a36Sopenharmony_ci#ifndef _QLOGICPTI_H 862306a36Sopenharmony_ci#define _QLOGICPTI_H 962306a36Sopenharmony_ci 1062306a36Sopenharmony_ci/* Qlogic/SBUS controller registers. */ 1162306a36Sopenharmony_ci#define SBUS_CFG1 0x006UL 1262306a36Sopenharmony_ci#define SBUS_CTRL 0x008UL 1362306a36Sopenharmony_ci#define SBUS_STAT 0x00aUL 1462306a36Sopenharmony_ci#define SBUS_SEMAPHORE 0x00cUL 1562306a36Sopenharmony_ci#define CMD_DMA_CTRL 0x022UL 1662306a36Sopenharmony_ci#define DATA_DMA_CTRL 0x042UL 1762306a36Sopenharmony_ci#define MBOX0 0x080UL 1862306a36Sopenharmony_ci#define MBOX1 0x082UL 1962306a36Sopenharmony_ci#define MBOX2 0x084UL 2062306a36Sopenharmony_ci#define MBOX3 0x086UL 2162306a36Sopenharmony_ci#define MBOX4 0x088UL 2262306a36Sopenharmony_ci#define MBOX5 0x08aUL 2362306a36Sopenharmony_ci#define CPU_CMD 0x214UL 2462306a36Sopenharmony_ci#define CPU_ORIDE 0x224UL 2562306a36Sopenharmony_ci#define CPU_PCTRL 0x272UL 2662306a36Sopenharmony_ci#define CPU_PDIFF 0x276UL 2762306a36Sopenharmony_ci#define RISC_PSR 0x420UL 2862306a36Sopenharmony_ci#define RISC_MTREG 0x42EUL 2962306a36Sopenharmony_ci#define HCCTRL 0x440UL 3062306a36Sopenharmony_ci 3162306a36Sopenharmony_ci/* SCSI parameters for this driver. */ 3262306a36Sopenharmony_ci#define MAX_TARGETS 16 3362306a36Sopenharmony_ci#define MAX_LUNS 8 3462306a36Sopenharmony_ci 3562306a36Sopenharmony_ci/* With the qlogic interface, every queue slot can hold a SCSI 3662306a36Sopenharmony_ci * command with up to 4 scatter/gather entries. If we need more 3762306a36Sopenharmony_ci * than 4 entries, continuation entries can be used that hold 3862306a36Sopenharmony_ci * another 7 entries each. Unlike for other drivers, this means 3962306a36Sopenharmony_ci * that the maximum number of scatter/gather entries we can 4062306a36Sopenharmony_ci * support at any given time is a function of the number of queue 4162306a36Sopenharmony_ci * slots available. That is, host->can_queue and host->sg_tablesize 4262306a36Sopenharmony_ci * are dynamic and _not_ independent. This all works fine because 4362306a36Sopenharmony_ci * requests are queued serially and the scatter/gather limit is 4462306a36Sopenharmony_ci * determined for each queue request anew. 4562306a36Sopenharmony_ci */ 4662306a36Sopenharmony_ci#define QLOGICPTI_REQ_QUEUE_LEN 255 /* must be power of two - 1 */ 4762306a36Sopenharmony_ci#define QLOGICPTI_MAX_SG(ql) (4 + (((ql) > 0) ? 7*((ql) - 1) : 0)) 4862306a36Sopenharmony_ci 4962306a36Sopenharmony_ci/* mailbox command complete status codes */ 5062306a36Sopenharmony_ci#define MBOX_COMMAND_COMPLETE 0x4000 5162306a36Sopenharmony_ci#define INVALID_COMMAND 0x4001 5262306a36Sopenharmony_ci#define HOST_INTERFACE_ERROR 0x4002 5362306a36Sopenharmony_ci#define TEST_FAILED 0x4003 5462306a36Sopenharmony_ci#define COMMAND_ERROR 0x4005 5562306a36Sopenharmony_ci#define COMMAND_PARAM_ERROR 0x4006 5662306a36Sopenharmony_ci 5762306a36Sopenharmony_ci/* async event status codes */ 5862306a36Sopenharmony_ci#define ASYNC_SCSI_BUS_RESET 0x8001 5962306a36Sopenharmony_ci#define SYSTEM_ERROR 0x8002 6062306a36Sopenharmony_ci#define REQUEST_TRANSFER_ERROR 0x8003 6162306a36Sopenharmony_ci#define RESPONSE_TRANSFER_ERROR 0x8004 6262306a36Sopenharmony_ci#define REQUEST_QUEUE_WAKEUP 0x8005 6362306a36Sopenharmony_ci#define EXECUTION_TIMEOUT_RESET 0x8006 6462306a36Sopenharmony_ci 6562306a36Sopenharmony_ci/* Am I fucking pedantic or what? */ 6662306a36Sopenharmony_cistruct Entry_header { 6762306a36Sopenharmony_ci#ifdef __BIG_ENDIAN 6862306a36Sopenharmony_ci u8 entry_cnt; 6962306a36Sopenharmony_ci u8 entry_type; 7062306a36Sopenharmony_ci u8 flags; 7162306a36Sopenharmony_ci u8 sys_def_1; 7262306a36Sopenharmony_ci#else /* __LITTLE_ENDIAN */ 7362306a36Sopenharmony_ci u8 entry_type; 7462306a36Sopenharmony_ci u8 entry_cnt; 7562306a36Sopenharmony_ci u8 sys_def_1; 7662306a36Sopenharmony_ci u8 flags; 7762306a36Sopenharmony_ci#endif 7862306a36Sopenharmony_ci}; 7962306a36Sopenharmony_ci 8062306a36Sopenharmony_ci/* entry header type commands */ 8162306a36Sopenharmony_ci#define ENTRY_COMMAND 1 8262306a36Sopenharmony_ci#define ENTRY_CONTINUATION 2 8362306a36Sopenharmony_ci#define ENTRY_STATUS 3 8462306a36Sopenharmony_ci#define ENTRY_MARKER 4 8562306a36Sopenharmony_ci#define ENTRY_EXTENDED_COMMAND 5 8662306a36Sopenharmony_ci 8762306a36Sopenharmony_ci/* entry header flag definitions */ 8862306a36Sopenharmony_ci#define EFLAG_CONTINUATION 1 8962306a36Sopenharmony_ci#define EFLAG_BUSY 2 9062306a36Sopenharmony_ci#define EFLAG_BAD_HEADER 4 9162306a36Sopenharmony_ci#define EFLAG_BAD_PAYLOAD 8 9262306a36Sopenharmony_ci 9362306a36Sopenharmony_cistruct dataseg { 9462306a36Sopenharmony_ci u32 d_base; 9562306a36Sopenharmony_ci u32 d_count; 9662306a36Sopenharmony_ci}; 9762306a36Sopenharmony_ci 9862306a36Sopenharmony_cistruct Command_Entry { 9962306a36Sopenharmony_ci struct Entry_header hdr; 10062306a36Sopenharmony_ci u32 handle; 10162306a36Sopenharmony_ci#ifdef __BIG_ENDIAN 10262306a36Sopenharmony_ci u8 target_id; 10362306a36Sopenharmony_ci u8 target_lun; 10462306a36Sopenharmony_ci#else /* __LITTLE_ENDIAN */ 10562306a36Sopenharmony_ci u8 target_lun; 10662306a36Sopenharmony_ci u8 target_id; 10762306a36Sopenharmony_ci#endif 10862306a36Sopenharmony_ci u16 cdb_length; 10962306a36Sopenharmony_ci u16 control_flags; 11062306a36Sopenharmony_ci u16 rsvd; 11162306a36Sopenharmony_ci u16 time_out; 11262306a36Sopenharmony_ci u16 segment_cnt; 11362306a36Sopenharmony_ci u8 cdb[12]; 11462306a36Sopenharmony_ci struct dataseg dataseg[4]; 11562306a36Sopenharmony_ci}; 11662306a36Sopenharmony_ci 11762306a36Sopenharmony_ci/* command entry control flag definitions */ 11862306a36Sopenharmony_ci#define CFLAG_NODISC 0x01 11962306a36Sopenharmony_ci#define CFLAG_HEAD_TAG 0x02 12062306a36Sopenharmony_ci#define CFLAG_ORDERED_TAG 0x04 12162306a36Sopenharmony_ci#define CFLAG_SIMPLE_TAG 0x08 12262306a36Sopenharmony_ci#define CFLAG_TAR_RTN 0x10 12362306a36Sopenharmony_ci#define CFLAG_READ 0x20 12462306a36Sopenharmony_ci#define CFLAG_WRITE 0x40 12562306a36Sopenharmony_ci 12662306a36Sopenharmony_cistruct Ext_Command_Entry { 12762306a36Sopenharmony_ci struct Entry_header hdr; 12862306a36Sopenharmony_ci u32 handle; 12962306a36Sopenharmony_ci#ifdef __BIG_ENDIAN 13062306a36Sopenharmony_ci u8 target_id; 13162306a36Sopenharmony_ci u8 target_lun; 13262306a36Sopenharmony_ci#else /* __LITTLE_ENDIAN */ 13362306a36Sopenharmony_ci u8 target_lun; 13462306a36Sopenharmony_ci u8 target_id; 13562306a36Sopenharmony_ci#endif 13662306a36Sopenharmony_ci u16 cdb_length; 13762306a36Sopenharmony_ci u16 control_flags; 13862306a36Sopenharmony_ci u16 rsvd; 13962306a36Sopenharmony_ci u16 time_out; 14062306a36Sopenharmony_ci u16 segment_cnt; 14162306a36Sopenharmony_ci u8 cdb[44]; 14262306a36Sopenharmony_ci}; 14362306a36Sopenharmony_ci 14462306a36Sopenharmony_cistruct Continuation_Entry { 14562306a36Sopenharmony_ci struct Entry_header hdr; 14662306a36Sopenharmony_ci u32 reserved; 14762306a36Sopenharmony_ci struct dataseg dataseg[7]; 14862306a36Sopenharmony_ci}; 14962306a36Sopenharmony_ci 15062306a36Sopenharmony_cistruct Marker_Entry { 15162306a36Sopenharmony_ci struct Entry_header hdr; 15262306a36Sopenharmony_ci u32 reserved; 15362306a36Sopenharmony_ci#ifdef __BIG_ENDIAN 15462306a36Sopenharmony_ci u8 target_id; 15562306a36Sopenharmony_ci u8 target_lun; 15662306a36Sopenharmony_ci#else /* __LITTLE_ENDIAN */ 15762306a36Sopenharmony_ci u8 target_lun; 15862306a36Sopenharmony_ci u8 target_id; 15962306a36Sopenharmony_ci#endif 16062306a36Sopenharmony_ci#ifdef __BIG_ENDIAN 16162306a36Sopenharmony_ci u8 rsvd; 16262306a36Sopenharmony_ci u8 modifier; 16362306a36Sopenharmony_ci#else /* __LITTLE_ENDIAN */ 16462306a36Sopenharmony_ci u8 modifier; 16562306a36Sopenharmony_ci u8 rsvd; 16662306a36Sopenharmony_ci#endif 16762306a36Sopenharmony_ci u8 rsvds[52]; 16862306a36Sopenharmony_ci}; 16962306a36Sopenharmony_ci 17062306a36Sopenharmony_ci/* marker entry modifier definitions */ 17162306a36Sopenharmony_ci#define SYNC_DEVICE 0 17262306a36Sopenharmony_ci#define SYNC_TARGET 1 17362306a36Sopenharmony_ci#define SYNC_ALL 2 17462306a36Sopenharmony_ci 17562306a36Sopenharmony_cistruct Status_Entry { 17662306a36Sopenharmony_ci struct Entry_header hdr; 17762306a36Sopenharmony_ci u32 handle; 17862306a36Sopenharmony_ci u16 scsi_status; 17962306a36Sopenharmony_ci u16 completion_status; 18062306a36Sopenharmony_ci u16 state_flags; 18162306a36Sopenharmony_ci u16 status_flags; 18262306a36Sopenharmony_ci u16 time; 18362306a36Sopenharmony_ci u16 req_sense_len; 18462306a36Sopenharmony_ci u32 residual; 18562306a36Sopenharmony_ci u8 rsvd[8]; 18662306a36Sopenharmony_ci u8 req_sense_data[32]; 18762306a36Sopenharmony_ci}; 18862306a36Sopenharmony_ci 18962306a36Sopenharmony_ci/* status entry completion status definitions */ 19062306a36Sopenharmony_ci#define CS_COMPLETE 0x0000 19162306a36Sopenharmony_ci#define CS_INCOMPLETE 0x0001 19262306a36Sopenharmony_ci#define CS_DMA_ERROR 0x0002 19362306a36Sopenharmony_ci#define CS_TRANSPORT_ERROR 0x0003 19462306a36Sopenharmony_ci#define CS_RESET_OCCURRED 0x0004 19562306a36Sopenharmony_ci#define CS_ABORTED 0x0005 19662306a36Sopenharmony_ci#define CS_TIMEOUT 0x0006 19762306a36Sopenharmony_ci#define CS_DATA_OVERRUN 0x0007 19862306a36Sopenharmony_ci#define CS_COMMAND_OVERRUN 0x0008 19962306a36Sopenharmony_ci#define CS_STATUS_OVERRUN 0x0009 20062306a36Sopenharmony_ci#define CS_BAD_MESSAGE 0x000a 20162306a36Sopenharmony_ci#define CS_NO_MESSAGE_OUT 0x000b 20262306a36Sopenharmony_ci#define CS_EXT_ID_FAILED 0x000c 20362306a36Sopenharmony_ci#define CS_IDE_MSG_FAILED 0x000d 20462306a36Sopenharmony_ci#define CS_ABORT_MSG_FAILED 0x000e 20562306a36Sopenharmony_ci#define CS_REJECT_MSG_FAILED 0x000f 20662306a36Sopenharmony_ci#define CS_NOP_MSG_FAILED 0x0010 20762306a36Sopenharmony_ci#define CS_PARITY_ERROR_MSG_FAILED 0x0011 20862306a36Sopenharmony_ci#define CS_DEVICE_RESET_MSG_FAILED 0x0012 20962306a36Sopenharmony_ci#define CS_ID_MSG_FAILED 0x0013 21062306a36Sopenharmony_ci#define CS_UNEXP_BUS_FREE 0x0014 21162306a36Sopenharmony_ci#define CS_DATA_UNDERRUN 0x0015 21262306a36Sopenharmony_ci#define CS_BUS_RESET 0x001c 21362306a36Sopenharmony_ci 21462306a36Sopenharmony_ci/* status entry state flag definitions */ 21562306a36Sopenharmony_ci#define SF_GOT_BUS 0x0100 21662306a36Sopenharmony_ci#define SF_GOT_TARGET 0x0200 21762306a36Sopenharmony_ci#define SF_SENT_CDB 0x0400 21862306a36Sopenharmony_ci#define SF_TRANSFERRED_DATA 0x0800 21962306a36Sopenharmony_ci#define SF_GOT_STATUS 0x1000 22062306a36Sopenharmony_ci#define SF_GOT_SENSE 0x2000 22162306a36Sopenharmony_ci 22262306a36Sopenharmony_ci/* status entry status flag definitions */ 22362306a36Sopenharmony_ci#define STF_DISCONNECT 0x0001 22462306a36Sopenharmony_ci#define STF_SYNCHRONOUS 0x0002 22562306a36Sopenharmony_ci#define STF_PARITY_ERROR 0x0004 22662306a36Sopenharmony_ci#define STF_BUS_RESET 0x0008 22762306a36Sopenharmony_ci#define STF_DEVICE_RESET 0x0010 22862306a36Sopenharmony_ci#define STF_ABORTED 0x0020 22962306a36Sopenharmony_ci#define STF_TIMEOUT 0x0040 23062306a36Sopenharmony_ci#define STF_NEGOTIATION 0x0080 23162306a36Sopenharmony_ci 23262306a36Sopenharmony_ci/* mailbox commands */ 23362306a36Sopenharmony_ci#define MBOX_NO_OP 0x0000 23462306a36Sopenharmony_ci#define MBOX_LOAD_RAM 0x0001 23562306a36Sopenharmony_ci#define MBOX_EXEC_FIRMWARE 0x0002 23662306a36Sopenharmony_ci#define MBOX_DUMP_RAM 0x0003 23762306a36Sopenharmony_ci#define MBOX_WRITE_RAM_WORD 0x0004 23862306a36Sopenharmony_ci#define MBOX_READ_RAM_WORD 0x0005 23962306a36Sopenharmony_ci#define MBOX_MAILBOX_REG_TEST 0x0006 24062306a36Sopenharmony_ci#define MBOX_VERIFY_CHECKSUM 0x0007 24162306a36Sopenharmony_ci#define MBOX_ABOUT_FIRMWARE 0x0008 24262306a36Sopenharmony_ci#define MBOX_CHECK_FIRMWARE 0x000e 24362306a36Sopenharmony_ci#define MBOX_INIT_REQ_QUEUE 0x0010 24462306a36Sopenharmony_ci#define MBOX_INIT_RES_QUEUE 0x0011 24562306a36Sopenharmony_ci#define MBOX_EXECUTE_IOCB 0x0012 24662306a36Sopenharmony_ci#define MBOX_WAKE_UP 0x0013 24762306a36Sopenharmony_ci#define MBOX_STOP_FIRMWARE 0x0014 24862306a36Sopenharmony_ci#define MBOX_ABORT 0x0015 24962306a36Sopenharmony_ci#define MBOX_ABORT_DEVICE 0x0016 25062306a36Sopenharmony_ci#define MBOX_ABORT_TARGET 0x0017 25162306a36Sopenharmony_ci#define MBOX_BUS_RESET 0x0018 25262306a36Sopenharmony_ci#define MBOX_STOP_QUEUE 0x0019 25362306a36Sopenharmony_ci#define MBOX_START_QUEUE 0x001a 25462306a36Sopenharmony_ci#define MBOX_SINGLE_STEP_QUEUE 0x001b 25562306a36Sopenharmony_ci#define MBOX_ABORT_QUEUE 0x001c 25662306a36Sopenharmony_ci#define MBOX_GET_DEV_QUEUE_STATUS 0x001d 25762306a36Sopenharmony_ci#define MBOX_GET_FIRMWARE_STATUS 0x001f 25862306a36Sopenharmony_ci#define MBOX_GET_INIT_SCSI_ID 0x0020 25962306a36Sopenharmony_ci#define MBOX_GET_SELECT_TIMEOUT 0x0021 26062306a36Sopenharmony_ci#define MBOX_GET_RETRY_COUNT 0x0022 26162306a36Sopenharmony_ci#define MBOX_GET_TAG_AGE_LIMIT 0x0023 26262306a36Sopenharmony_ci#define MBOX_GET_CLOCK_RATE 0x0024 26362306a36Sopenharmony_ci#define MBOX_GET_ACT_NEG_STATE 0x0025 26462306a36Sopenharmony_ci#define MBOX_GET_ASYNC_DATA_SETUP_TIME 0x0026 26562306a36Sopenharmony_ci#define MBOX_GET_SBUS_PARAMS 0x0027 26662306a36Sopenharmony_ci#define MBOX_GET_TARGET_PARAMS 0x0028 26762306a36Sopenharmony_ci#define MBOX_GET_DEV_QUEUE_PARAMS 0x0029 26862306a36Sopenharmony_ci#define MBOX_SET_INIT_SCSI_ID 0x0030 26962306a36Sopenharmony_ci#define MBOX_SET_SELECT_TIMEOUT 0x0031 27062306a36Sopenharmony_ci#define MBOX_SET_RETRY_COUNT 0x0032 27162306a36Sopenharmony_ci#define MBOX_SET_TAG_AGE_LIMIT 0x0033 27262306a36Sopenharmony_ci#define MBOX_SET_CLOCK_RATE 0x0034 27362306a36Sopenharmony_ci#define MBOX_SET_ACTIVE_NEG_STATE 0x0035 27462306a36Sopenharmony_ci#define MBOX_SET_ASYNC_DATA_SETUP_TIME 0x0036 27562306a36Sopenharmony_ci#define MBOX_SET_SBUS_CONTROL_PARAMS 0x0037 27662306a36Sopenharmony_ci#define MBOX_SET_TARGET_PARAMS 0x0038 27762306a36Sopenharmony_ci#define MBOX_SET_DEV_QUEUE_PARAMS 0x0039 27862306a36Sopenharmony_ci 27962306a36Sopenharmony_cistruct host_param { 28062306a36Sopenharmony_ci u_short initiator_scsi_id; 28162306a36Sopenharmony_ci u_short bus_reset_delay; 28262306a36Sopenharmony_ci u_short retry_count; 28362306a36Sopenharmony_ci u_short retry_delay; 28462306a36Sopenharmony_ci u_short async_data_setup_time; 28562306a36Sopenharmony_ci u_short req_ack_active_negation; 28662306a36Sopenharmony_ci u_short data_line_active_negation; 28762306a36Sopenharmony_ci u_short data_dma_burst_enable; 28862306a36Sopenharmony_ci u_short command_dma_burst_enable; 28962306a36Sopenharmony_ci u_short tag_aging; 29062306a36Sopenharmony_ci u_short selection_timeout; 29162306a36Sopenharmony_ci u_short max_queue_depth; 29262306a36Sopenharmony_ci}; 29362306a36Sopenharmony_ci 29462306a36Sopenharmony_ci/* 29562306a36Sopenharmony_ci * Device Flags: 29662306a36Sopenharmony_ci * 29762306a36Sopenharmony_ci * Bit Name 29862306a36Sopenharmony_ci * --------- 29962306a36Sopenharmony_ci * 7 Disconnect Privilege 30062306a36Sopenharmony_ci * 6 Parity Checking 30162306a36Sopenharmony_ci * 5 Wide Data Transfers 30262306a36Sopenharmony_ci * 4 Synchronous Data Transfers 30362306a36Sopenharmony_ci * 3 Tagged Queuing 30462306a36Sopenharmony_ci * 2 Automatic Request Sense 30562306a36Sopenharmony_ci * 1 Stop Queue on Check Condition 30662306a36Sopenharmony_ci * 0 Renegotiate on Error 30762306a36Sopenharmony_ci */ 30862306a36Sopenharmony_ci 30962306a36Sopenharmony_cistruct dev_param { 31062306a36Sopenharmony_ci u_short device_flags; 31162306a36Sopenharmony_ci u_short execution_throttle; 31262306a36Sopenharmony_ci u_short synchronous_period; 31362306a36Sopenharmony_ci u_short synchronous_offset; 31462306a36Sopenharmony_ci u_short device_enable; 31562306a36Sopenharmony_ci u_short reserved; /* pad */ 31662306a36Sopenharmony_ci}; 31762306a36Sopenharmony_ci 31862306a36Sopenharmony_ci/* 31962306a36Sopenharmony_ci * The result queue can be quite a bit smaller since continuation entries 32062306a36Sopenharmony_ci * do not show up there: 32162306a36Sopenharmony_ci */ 32262306a36Sopenharmony_ci#define RES_QUEUE_LEN 255 /* Must be power of two - 1 */ 32362306a36Sopenharmony_ci#define QUEUE_ENTRY_LEN 64 32462306a36Sopenharmony_ci 32562306a36Sopenharmony_ci#define NEXT_REQ_PTR(wheee) (((wheee) + 1) & QLOGICPTI_REQ_QUEUE_LEN) 32662306a36Sopenharmony_ci#define NEXT_RES_PTR(wheee) (((wheee) + 1) & RES_QUEUE_LEN) 32762306a36Sopenharmony_ci#define PREV_REQ_PTR(wheee) (((wheee) - 1) & QLOGICPTI_REQ_QUEUE_LEN) 32862306a36Sopenharmony_ci#define PREV_RES_PTR(wheee) (((wheee) - 1) & RES_QUEUE_LEN) 32962306a36Sopenharmony_ci 33062306a36Sopenharmony_cistruct pti_queue_entry { 33162306a36Sopenharmony_ci char __opaque[QUEUE_ENTRY_LEN]; 33262306a36Sopenharmony_ci}; 33362306a36Sopenharmony_ci 33462306a36Sopenharmony_cistruct scsi_cmnd; 33562306a36Sopenharmony_ci 33662306a36Sopenharmony_ci/* Software state for the driver. */ 33762306a36Sopenharmony_cistruct qlogicpti { 33862306a36Sopenharmony_ci /* These are the hot elements in the cache, so they come first. */ 33962306a36Sopenharmony_ci void __iomem *qregs; /* Adapter registers */ 34062306a36Sopenharmony_ci struct pti_queue_entry *res_cpu; /* Ptr to RESPONSE bufs (CPU) */ 34162306a36Sopenharmony_ci struct pti_queue_entry *req_cpu; /* Ptr to REQUEST bufs (CPU) */ 34262306a36Sopenharmony_ci 34362306a36Sopenharmony_ci u_int req_in_ptr; /* index of next request slot */ 34462306a36Sopenharmony_ci u_int res_out_ptr; /* index of next result slot */ 34562306a36Sopenharmony_ci long send_marker; /* must we send a marker? */ 34662306a36Sopenharmony_ci struct platform_device *op; 34762306a36Sopenharmony_ci unsigned long __pad; 34862306a36Sopenharmony_ci 34962306a36Sopenharmony_ci int cmd_count[MAX_TARGETS]; 35062306a36Sopenharmony_ci unsigned long tag_ages[MAX_TARGETS]; 35162306a36Sopenharmony_ci 35262306a36Sopenharmony_ci /* The cmd->handler is only 32-bits, so that things work even on monster 35362306a36Sopenharmony_ci * Ex000 sparc64 machines with >4GB of ram we just keep track of the 35462306a36Sopenharmony_ci * scsi command pointers here. This is essentially what Matt Jacob does. -DaveM 35562306a36Sopenharmony_ci */ 35662306a36Sopenharmony_ci struct scsi_cmnd *cmd_slots[QLOGICPTI_REQ_QUEUE_LEN + 1]; 35762306a36Sopenharmony_ci 35862306a36Sopenharmony_ci /* The rest of the elements are unimportant for performance. */ 35962306a36Sopenharmony_ci struct qlogicpti *next; 36062306a36Sopenharmony_ci dma_addr_t res_dvma; /* Ptr to RESPONSE bufs (DVMA)*/ 36162306a36Sopenharmony_ci dma_addr_t req_dvma; /* Ptr to REQUEST bufs (DVMA) */ 36262306a36Sopenharmony_ci u_char fware_majrev, fware_minrev, fware_micrev; 36362306a36Sopenharmony_ci struct Scsi_Host *qhost; 36462306a36Sopenharmony_ci int qpti_id; 36562306a36Sopenharmony_ci int scsi_id; 36662306a36Sopenharmony_ci int prom_node; 36762306a36Sopenharmony_ci int irq; 36862306a36Sopenharmony_ci char differential, ultra, clock; 36962306a36Sopenharmony_ci unsigned char bursts; 37062306a36Sopenharmony_ci struct host_param host_param; 37162306a36Sopenharmony_ci struct dev_param dev_param[MAX_TARGETS]; 37262306a36Sopenharmony_ci 37362306a36Sopenharmony_ci void __iomem *sreg; 37462306a36Sopenharmony_ci#define SREG_TPOWER 0x80 /* State of termpwr */ 37562306a36Sopenharmony_ci#define SREG_FUSE 0x40 /* State of on board fuse */ 37662306a36Sopenharmony_ci#define SREG_PDISAB 0x20 /* Disable state for power on */ 37762306a36Sopenharmony_ci#define SREG_DSENSE 0x10 /* Sense for differential */ 37862306a36Sopenharmony_ci#define SREG_IMASK 0x0c /* Interrupt level */ 37962306a36Sopenharmony_ci#define SREG_SPMASK 0x03 /* Mask for switch pack */ 38062306a36Sopenharmony_ci unsigned char swsreg; 38162306a36Sopenharmony_ci unsigned int 38262306a36Sopenharmony_ci gotirq : 1, /* this instance got an irq */ 38362306a36Sopenharmony_ci is_pti : 1; /* Non-zero if this is a PTI board. */ 38462306a36Sopenharmony_ci}; 38562306a36Sopenharmony_ci 38662306a36Sopenharmony_ci/* How to twiddle them bits... */ 38762306a36Sopenharmony_ci 38862306a36Sopenharmony_ci/* SBUS config register one. */ 38962306a36Sopenharmony_ci#define SBUS_CFG1_EPAR 0x0100 /* Enable parity checking */ 39062306a36Sopenharmony_ci#define SBUS_CFG1_FMASK 0x00f0 /* Forth code cycle mask */ 39162306a36Sopenharmony_ci#define SBUS_CFG1_BENAB 0x0004 /* Burst dvma enable */ 39262306a36Sopenharmony_ci#define SBUS_CFG1_B64 0x0003 /* Enable 64byte bursts */ 39362306a36Sopenharmony_ci#define SBUS_CFG1_B32 0x0002 /* Enable 32byte bursts */ 39462306a36Sopenharmony_ci#define SBUS_CFG1_B16 0x0001 /* Enable 16byte bursts */ 39562306a36Sopenharmony_ci#define SBUS_CFG1_B8 0x0008 /* Enable 8byte bursts */ 39662306a36Sopenharmony_ci 39762306a36Sopenharmony_ci/* SBUS control register */ 39862306a36Sopenharmony_ci#define SBUS_CTRL_EDIRQ 0x0020 /* Enable Data DVMA Interrupts */ 39962306a36Sopenharmony_ci#define SBUS_CTRL_ECIRQ 0x0010 /* Enable Command DVMA Interrupts */ 40062306a36Sopenharmony_ci#define SBUS_CTRL_ESIRQ 0x0008 /* Enable SCSI Processor Interrupts */ 40162306a36Sopenharmony_ci#define SBUS_CTRL_ERIRQ 0x0004 /* Enable RISC Processor Interrupts */ 40262306a36Sopenharmony_ci#define SBUS_CTRL_GENAB 0x0002 /* Global Interrupt Enable */ 40362306a36Sopenharmony_ci#define SBUS_CTRL_RESET 0x0001 /* Soft Reset */ 40462306a36Sopenharmony_ci 40562306a36Sopenharmony_ci/* SBUS status register */ 40662306a36Sopenharmony_ci#define SBUS_STAT_DINT 0x0020 /* Data DVMA IRQ pending */ 40762306a36Sopenharmony_ci#define SBUS_STAT_CINT 0x0010 /* Command DVMA IRQ pending */ 40862306a36Sopenharmony_ci#define SBUS_STAT_SINT 0x0008 /* SCSI Processor IRQ pending */ 40962306a36Sopenharmony_ci#define SBUS_STAT_RINT 0x0004 /* RISC Processor IRQ pending */ 41062306a36Sopenharmony_ci#define SBUS_STAT_GINT 0x0002 /* Global IRQ pending */ 41162306a36Sopenharmony_ci 41262306a36Sopenharmony_ci/* SBUS semaphore register */ 41362306a36Sopenharmony_ci#define SBUS_SEMAPHORE_STAT 0x0002 /* Semaphore status bit */ 41462306a36Sopenharmony_ci#define SBUS_SEMAPHORE_LCK 0x0001 /* Semaphore lock bit */ 41562306a36Sopenharmony_ci 41662306a36Sopenharmony_ci/* DVMA control register */ 41762306a36Sopenharmony_ci#define DMA_CTRL_CSUSPEND 0x0010 /* DMA channel suspend */ 41862306a36Sopenharmony_ci#define DMA_CTRL_CCLEAR 0x0008 /* DMA channel clear and reset */ 41962306a36Sopenharmony_ci#define DMA_CTRL_FCLEAR 0x0004 /* DMA fifo clear */ 42062306a36Sopenharmony_ci#define DMA_CTRL_CIRQ 0x0002 /* DMA irq clear */ 42162306a36Sopenharmony_ci#define DMA_CTRL_DMASTART 0x0001 /* DMA transfer start */ 42262306a36Sopenharmony_ci 42362306a36Sopenharmony_ci/* SCSI processor override register */ 42462306a36Sopenharmony_ci#define CPU_ORIDE_ETRIG 0x8000 /* External trigger enable */ 42562306a36Sopenharmony_ci#define CPU_ORIDE_STEP 0x4000 /* Single step mode enable */ 42662306a36Sopenharmony_ci#define CPU_ORIDE_BKPT 0x2000 /* Breakpoint reg enable */ 42762306a36Sopenharmony_ci#define CPU_ORIDE_PWRITE 0x1000 /* SCSI pin write enable */ 42862306a36Sopenharmony_ci#define CPU_ORIDE_OFORCE 0x0800 /* Force outputs on */ 42962306a36Sopenharmony_ci#define CPU_ORIDE_LBACK 0x0400 /* SCSI loopback enable */ 43062306a36Sopenharmony_ci#define CPU_ORIDE_PTEST 0x0200 /* Parity test enable */ 43162306a36Sopenharmony_ci#define CPU_ORIDE_TENAB 0x0100 /* SCSI pins tristate enable */ 43262306a36Sopenharmony_ci#define CPU_ORIDE_TPINS 0x0080 /* SCSI pins enable */ 43362306a36Sopenharmony_ci#define CPU_ORIDE_FRESET 0x0008 /* FIFO reset */ 43462306a36Sopenharmony_ci#define CPU_ORIDE_CTERM 0x0004 /* Command terminate */ 43562306a36Sopenharmony_ci#define CPU_ORIDE_RREG 0x0002 /* Reset SCSI processor regs */ 43662306a36Sopenharmony_ci#define CPU_ORIDE_RMOD 0x0001 /* Reset SCSI processor module */ 43762306a36Sopenharmony_ci 43862306a36Sopenharmony_ci/* SCSI processor commands */ 43962306a36Sopenharmony_ci#define CPU_CMD_BRESET 0x300b /* Reset SCSI bus */ 44062306a36Sopenharmony_ci 44162306a36Sopenharmony_ci/* SCSI processor pin control register */ 44262306a36Sopenharmony_ci#define CPU_PCTRL_PVALID 0x8000 /* Phase bits are valid */ 44362306a36Sopenharmony_ci#define CPU_PCTRL_PHI 0x0400 /* Parity bit high */ 44462306a36Sopenharmony_ci#define CPU_PCTRL_PLO 0x0200 /* Parity bit low */ 44562306a36Sopenharmony_ci#define CPU_PCTRL_REQ 0x0100 /* REQ bus signal */ 44662306a36Sopenharmony_ci#define CPU_PCTRL_ACK 0x0080 /* ACK bus signal */ 44762306a36Sopenharmony_ci#define CPU_PCTRL_RST 0x0040 /* RST bus signal */ 44862306a36Sopenharmony_ci#define CPU_PCTRL_BSY 0x0020 /* BSY bus signal */ 44962306a36Sopenharmony_ci#define CPU_PCTRL_SEL 0x0010 /* SEL bus signal */ 45062306a36Sopenharmony_ci#define CPU_PCTRL_ATN 0x0008 /* ATN bus signal */ 45162306a36Sopenharmony_ci#define CPU_PCTRL_MSG 0x0004 /* MSG bus signal */ 45262306a36Sopenharmony_ci#define CPU_PCTRL_CD 0x0002 /* CD bus signal */ 45362306a36Sopenharmony_ci#define CPU_PCTRL_IO 0x0001 /* IO bus signal */ 45462306a36Sopenharmony_ci 45562306a36Sopenharmony_ci/* SCSI processor differential pins register */ 45662306a36Sopenharmony_ci#define CPU_PDIFF_SENSE 0x0200 /* Differential sense */ 45762306a36Sopenharmony_ci#define CPU_PDIFF_MODE 0x0100 /* Differential mode */ 45862306a36Sopenharmony_ci#define CPU_PDIFF_OENAB 0x0080 /* Outputs enable */ 45962306a36Sopenharmony_ci#define CPU_PDIFF_PMASK 0x007c /* Differential control pins */ 46062306a36Sopenharmony_ci#define CPU_PDIFF_TGT 0x0002 /* Target mode enable */ 46162306a36Sopenharmony_ci#define CPU_PDIFF_INIT 0x0001 /* Initiator mode enable */ 46262306a36Sopenharmony_ci 46362306a36Sopenharmony_ci/* RISC processor status register */ 46462306a36Sopenharmony_ci#define RISC_PSR_FTRUE 0x8000 /* Force true */ 46562306a36Sopenharmony_ci#define RISC_PSR_LCD 0x4000 /* Loop counter shows done status */ 46662306a36Sopenharmony_ci#define RISC_PSR_RIRQ 0x2000 /* RISC irq status */ 46762306a36Sopenharmony_ci#define RISC_PSR_TOFLOW 0x1000 /* Timer overflow (rollover) */ 46862306a36Sopenharmony_ci#define RISC_PSR_AOFLOW 0x0800 /* Arithmetic overflow */ 46962306a36Sopenharmony_ci#define RISC_PSR_AMSB 0x0400 /* Arithmetic big endian */ 47062306a36Sopenharmony_ci#define RISC_PSR_ACARRY 0x0200 /* Arithmetic carry */ 47162306a36Sopenharmony_ci#define RISC_PSR_AZERO 0x0100 /* Arithmetic zero */ 47262306a36Sopenharmony_ci#define RISC_PSR_ULTRA 0x0020 /* Ultra mode */ 47362306a36Sopenharmony_ci#define RISC_PSR_DIRQ 0x0010 /* DVMA interrupt */ 47462306a36Sopenharmony_ci#define RISC_PSR_SIRQ 0x0008 /* SCSI processor interrupt */ 47562306a36Sopenharmony_ci#define RISC_PSR_HIRQ 0x0004 /* Host interrupt */ 47662306a36Sopenharmony_ci#define RISC_PSR_IPEND 0x0002 /* Interrupt pending */ 47762306a36Sopenharmony_ci#define RISC_PSR_FFALSE 0x0001 /* Force false */ 47862306a36Sopenharmony_ci 47962306a36Sopenharmony_ci/* RISC processor memory timing register */ 48062306a36Sopenharmony_ci#define RISC_MTREG_P1DFLT 0x1200 /* Default read/write timing, pg1 */ 48162306a36Sopenharmony_ci#define RISC_MTREG_P0DFLT 0x0012 /* Default read/write timing, pg0 */ 48262306a36Sopenharmony_ci#define RISC_MTREG_P1ULTRA 0x2300 /* Ultra-mode rw timing, pg1 */ 48362306a36Sopenharmony_ci#define RISC_MTREG_P0ULTRA 0x0023 /* Ultra-mode rw timing, pg0 */ 48462306a36Sopenharmony_ci 48562306a36Sopenharmony_ci/* Host command/ctrl register */ 48662306a36Sopenharmony_ci#define HCCTRL_NOP 0x0000 /* CMD: No operation */ 48762306a36Sopenharmony_ci#define HCCTRL_RESET 0x1000 /* CMD: Reset RISC cpu */ 48862306a36Sopenharmony_ci#define HCCTRL_PAUSE 0x2000 /* CMD: Pause RISC cpu */ 48962306a36Sopenharmony_ci#define HCCTRL_REL 0x3000 /* CMD: Release paused RISC cpu */ 49062306a36Sopenharmony_ci#define HCCTRL_STEP 0x4000 /* CMD: Single step RISC cpu */ 49162306a36Sopenharmony_ci#define HCCTRL_SHIRQ 0x5000 /* CMD: Set host irq */ 49262306a36Sopenharmony_ci#define HCCTRL_CHIRQ 0x6000 /* CMD: Clear host irq */ 49362306a36Sopenharmony_ci#define HCCTRL_CRIRQ 0x7000 /* CMD: Clear RISC cpu irq */ 49462306a36Sopenharmony_ci#define HCCTRL_BKPT 0x8000 /* CMD: Breakpoint enables change */ 49562306a36Sopenharmony_ci#define HCCTRL_TMODE 0xf000 /* CMD: Enable test mode */ 49662306a36Sopenharmony_ci#define HCCTRL_HIRQ 0x0080 /* Host IRQ pending */ 49762306a36Sopenharmony_ci#define HCCTRL_RRIP 0x0040 /* RISC cpu reset in happening now */ 49862306a36Sopenharmony_ci#define HCCTRL_RPAUSED 0x0020 /* RISC cpu is paused now */ 49962306a36Sopenharmony_ci#define HCCTRL_EBENAB 0x0010 /* External breakpoint enable */ 50062306a36Sopenharmony_ci#define HCCTRL_B1ENAB 0x0008 /* Breakpoint 1 enable */ 50162306a36Sopenharmony_ci#define HCCTRL_B0ENAB 0x0004 /* Breakpoint 0 enable */ 50262306a36Sopenharmony_ci 50362306a36Sopenharmony_ci/* For our interrupt engine. */ 50462306a36Sopenharmony_ci#define for_each_qlogicpti(qp) \ 50562306a36Sopenharmony_ci for((qp) = qptichain; (qp); (qp) = (qp)->next) 50662306a36Sopenharmony_ci 50762306a36Sopenharmony_ci#endif /* !(_QLOGICPTI_H) */ 508