0001
0002
0003
0004
0005
0006
0007 #ifndef _QLOGICPTI_H
0008 #define _QLOGICPTI_H
0009
0010
0011 #define SBUS_CFG1 0x006UL
0012 #define SBUS_CTRL 0x008UL
0013 #define SBUS_STAT 0x00aUL
0014 #define SBUS_SEMAPHORE 0x00cUL
0015 #define CMD_DMA_CTRL 0x022UL
0016 #define DATA_DMA_CTRL 0x042UL
0017 #define MBOX0 0x080UL
0018 #define MBOX1 0x082UL
0019 #define MBOX2 0x084UL
0020 #define MBOX3 0x086UL
0021 #define MBOX4 0x088UL
0022 #define MBOX5 0x08aUL
0023 #define CPU_CMD 0x214UL
0024 #define CPU_ORIDE 0x224UL
0025 #define CPU_PCTRL 0x272UL
0026 #define CPU_PDIFF 0x276UL
0027 #define RISC_PSR 0x420UL
0028 #define RISC_MTREG 0x42EUL
0029 #define HCCTRL 0x440UL
0030
0031
0032 #define MAX_TARGETS 16
0033 #define MAX_LUNS 8
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046 #define QLOGICPTI_REQ_QUEUE_LEN 255
0047 #define QLOGICPTI_MAX_SG(ql) (4 + (((ql) > 0) ? 7*((ql) - 1) : 0))
0048
0049
0050 #define MBOX_COMMAND_COMPLETE 0x4000
0051 #define INVALID_COMMAND 0x4001
0052 #define HOST_INTERFACE_ERROR 0x4002
0053 #define TEST_FAILED 0x4003
0054 #define COMMAND_ERROR 0x4005
0055 #define COMMAND_PARAM_ERROR 0x4006
0056
0057
0058 #define ASYNC_SCSI_BUS_RESET 0x8001
0059 #define SYSTEM_ERROR 0x8002
0060 #define REQUEST_TRANSFER_ERROR 0x8003
0061 #define RESPONSE_TRANSFER_ERROR 0x8004
0062 #define REQUEST_QUEUE_WAKEUP 0x8005
0063 #define EXECUTION_TIMEOUT_RESET 0x8006
0064
0065
0066 struct Entry_header {
0067 #ifdef __BIG_ENDIAN
0068 u8 entry_cnt;
0069 u8 entry_type;
0070 u8 flags;
0071 u8 sys_def_1;
0072 #else
0073 u8 entry_type;
0074 u8 entry_cnt;
0075 u8 sys_def_1;
0076 u8 flags;
0077 #endif
0078 };
0079
0080
0081 #define ENTRY_COMMAND 1
0082 #define ENTRY_CONTINUATION 2
0083 #define ENTRY_STATUS 3
0084 #define ENTRY_MARKER 4
0085 #define ENTRY_EXTENDED_COMMAND 5
0086
0087
0088 #define EFLAG_CONTINUATION 1
0089 #define EFLAG_BUSY 2
0090 #define EFLAG_BAD_HEADER 4
0091 #define EFLAG_BAD_PAYLOAD 8
0092
0093 struct dataseg {
0094 u32 d_base;
0095 u32 d_count;
0096 };
0097
0098 struct Command_Entry {
0099 struct Entry_header hdr;
0100 u32 handle;
0101 #ifdef __BIG_ENDIAN
0102 u8 target_id;
0103 u8 target_lun;
0104 #else
0105 u8 target_lun;
0106 u8 target_id;
0107 #endif
0108 u16 cdb_length;
0109 u16 control_flags;
0110 u16 rsvd;
0111 u16 time_out;
0112 u16 segment_cnt;
0113 u8 cdb[12];
0114 struct dataseg dataseg[4];
0115 };
0116
0117
0118 #define CFLAG_NODISC 0x01
0119 #define CFLAG_HEAD_TAG 0x02
0120 #define CFLAG_ORDERED_TAG 0x04
0121 #define CFLAG_SIMPLE_TAG 0x08
0122 #define CFLAG_TAR_RTN 0x10
0123 #define CFLAG_READ 0x20
0124 #define CFLAG_WRITE 0x40
0125
0126 struct Ext_Command_Entry {
0127 struct Entry_header hdr;
0128 u32 handle;
0129 #ifdef __BIG_ENDIAN
0130 u8 target_id;
0131 u8 target_lun;
0132 #else
0133 u8 target_lun;
0134 u8 target_id;
0135 #endif
0136 u16 cdb_length;
0137 u16 control_flags;
0138 u16 rsvd;
0139 u16 time_out;
0140 u16 segment_cnt;
0141 u8 cdb[44];
0142 };
0143
0144 struct Continuation_Entry {
0145 struct Entry_header hdr;
0146 u32 reserved;
0147 struct dataseg dataseg[7];
0148 };
0149
0150 struct Marker_Entry {
0151 struct Entry_header hdr;
0152 u32 reserved;
0153 #ifdef __BIG_ENDIAN
0154 u8 target_id;
0155 u8 target_lun;
0156 #else
0157 u8 target_lun;
0158 u8 target_id;
0159 #endif
0160 #ifdef __BIG_ENDIAN
0161 u8 rsvd;
0162 u8 modifier;
0163 #else
0164 u8 modifier;
0165 u8 rsvd;
0166 #endif
0167 u8 rsvds[52];
0168 };
0169
0170
0171 #define SYNC_DEVICE 0
0172 #define SYNC_TARGET 1
0173 #define SYNC_ALL 2
0174
0175 struct Status_Entry {
0176 struct Entry_header hdr;
0177 u32 handle;
0178 u16 scsi_status;
0179 u16 completion_status;
0180 u16 state_flags;
0181 u16 status_flags;
0182 u16 time;
0183 u16 req_sense_len;
0184 u32 residual;
0185 u8 rsvd[8];
0186 u8 req_sense_data[32];
0187 };
0188
0189
0190 #define CS_COMPLETE 0x0000
0191 #define CS_INCOMPLETE 0x0001
0192 #define CS_DMA_ERROR 0x0002
0193 #define CS_TRANSPORT_ERROR 0x0003
0194 #define CS_RESET_OCCURRED 0x0004
0195 #define CS_ABORTED 0x0005
0196 #define CS_TIMEOUT 0x0006
0197 #define CS_DATA_OVERRUN 0x0007
0198 #define CS_COMMAND_OVERRUN 0x0008
0199 #define CS_STATUS_OVERRUN 0x0009
0200 #define CS_BAD_MESSAGE 0x000a
0201 #define CS_NO_MESSAGE_OUT 0x000b
0202 #define CS_EXT_ID_FAILED 0x000c
0203 #define CS_IDE_MSG_FAILED 0x000d
0204 #define CS_ABORT_MSG_FAILED 0x000e
0205 #define CS_REJECT_MSG_FAILED 0x000f
0206 #define CS_NOP_MSG_FAILED 0x0010
0207 #define CS_PARITY_ERROR_MSG_FAILED 0x0011
0208 #define CS_DEVICE_RESET_MSG_FAILED 0x0012
0209 #define CS_ID_MSG_FAILED 0x0013
0210 #define CS_UNEXP_BUS_FREE 0x0014
0211 #define CS_DATA_UNDERRUN 0x0015
0212 #define CS_BUS_RESET 0x001c
0213
0214
0215 #define SF_GOT_BUS 0x0100
0216 #define SF_GOT_TARGET 0x0200
0217 #define SF_SENT_CDB 0x0400
0218 #define SF_TRANSFERRED_DATA 0x0800
0219 #define SF_GOT_STATUS 0x1000
0220 #define SF_GOT_SENSE 0x2000
0221
0222
0223 #define STF_DISCONNECT 0x0001
0224 #define STF_SYNCHRONOUS 0x0002
0225 #define STF_PARITY_ERROR 0x0004
0226 #define STF_BUS_RESET 0x0008
0227 #define STF_DEVICE_RESET 0x0010
0228 #define STF_ABORTED 0x0020
0229 #define STF_TIMEOUT 0x0040
0230 #define STF_NEGOTIATION 0x0080
0231
0232
0233 #define MBOX_NO_OP 0x0000
0234 #define MBOX_LOAD_RAM 0x0001
0235 #define MBOX_EXEC_FIRMWARE 0x0002
0236 #define MBOX_DUMP_RAM 0x0003
0237 #define MBOX_WRITE_RAM_WORD 0x0004
0238 #define MBOX_READ_RAM_WORD 0x0005
0239 #define MBOX_MAILBOX_REG_TEST 0x0006
0240 #define MBOX_VERIFY_CHECKSUM 0x0007
0241 #define MBOX_ABOUT_FIRMWARE 0x0008
0242 #define MBOX_CHECK_FIRMWARE 0x000e
0243 #define MBOX_INIT_REQ_QUEUE 0x0010
0244 #define MBOX_INIT_RES_QUEUE 0x0011
0245 #define MBOX_EXECUTE_IOCB 0x0012
0246 #define MBOX_WAKE_UP 0x0013
0247 #define MBOX_STOP_FIRMWARE 0x0014
0248 #define MBOX_ABORT 0x0015
0249 #define MBOX_ABORT_DEVICE 0x0016
0250 #define MBOX_ABORT_TARGET 0x0017
0251 #define MBOX_BUS_RESET 0x0018
0252 #define MBOX_STOP_QUEUE 0x0019
0253 #define MBOX_START_QUEUE 0x001a
0254 #define MBOX_SINGLE_STEP_QUEUE 0x001b
0255 #define MBOX_ABORT_QUEUE 0x001c
0256 #define MBOX_GET_DEV_QUEUE_STATUS 0x001d
0257 #define MBOX_GET_FIRMWARE_STATUS 0x001f
0258 #define MBOX_GET_INIT_SCSI_ID 0x0020
0259 #define MBOX_GET_SELECT_TIMEOUT 0x0021
0260 #define MBOX_GET_RETRY_COUNT 0x0022
0261 #define MBOX_GET_TAG_AGE_LIMIT 0x0023
0262 #define MBOX_GET_CLOCK_RATE 0x0024
0263 #define MBOX_GET_ACT_NEG_STATE 0x0025
0264 #define MBOX_GET_ASYNC_DATA_SETUP_TIME 0x0026
0265 #define MBOX_GET_SBUS_PARAMS 0x0027
0266 #define MBOX_GET_TARGET_PARAMS 0x0028
0267 #define MBOX_GET_DEV_QUEUE_PARAMS 0x0029
0268 #define MBOX_SET_INIT_SCSI_ID 0x0030
0269 #define MBOX_SET_SELECT_TIMEOUT 0x0031
0270 #define MBOX_SET_RETRY_COUNT 0x0032
0271 #define MBOX_SET_TAG_AGE_LIMIT 0x0033
0272 #define MBOX_SET_CLOCK_RATE 0x0034
0273 #define MBOX_SET_ACTIVE_NEG_STATE 0x0035
0274 #define MBOX_SET_ASYNC_DATA_SETUP_TIME 0x0036
0275 #define MBOX_SET_SBUS_CONTROL_PARAMS 0x0037
0276 #define MBOX_SET_TARGET_PARAMS 0x0038
0277 #define MBOX_SET_DEV_QUEUE_PARAMS 0x0039
0278
0279 struct host_param {
0280 u_short initiator_scsi_id;
0281 u_short bus_reset_delay;
0282 u_short retry_count;
0283 u_short retry_delay;
0284 u_short async_data_setup_time;
0285 u_short req_ack_active_negation;
0286 u_short data_line_active_negation;
0287 u_short data_dma_burst_enable;
0288 u_short command_dma_burst_enable;
0289 u_short tag_aging;
0290 u_short selection_timeout;
0291 u_short max_queue_depth;
0292 };
0293
0294
0295
0296
0297
0298
0299
0300
0301
0302
0303
0304
0305
0306
0307
0308
0309 struct dev_param {
0310 u_short device_flags;
0311 u_short execution_throttle;
0312 u_short synchronous_period;
0313 u_short synchronous_offset;
0314 u_short device_enable;
0315 u_short reserved;
0316 };
0317
0318
0319
0320
0321
0322 #define RES_QUEUE_LEN 255
0323 #define QUEUE_ENTRY_LEN 64
0324
0325 #define NEXT_REQ_PTR(wheee) (((wheee) + 1) & QLOGICPTI_REQ_QUEUE_LEN)
0326 #define NEXT_RES_PTR(wheee) (((wheee) + 1) & RES_QUEUE_LEN)
0327 #define PREV_REQ_PTR(wheee) (((wheee) - 1) & QLOGICPTI_REQ_QUEUE_LEN)
0328 #define PREV_RES_PTR(wheee) (((wheee) - 1) & RES_QUEUE_LEN)
0329
0330 struct pti_queue_entry {
0331 char __opaque[QUEUE_ENTRY_LEN];
0332 };
0333
0334 struct scsi_cmnd;
0335
0336
0337 struct qlogicpti {
0338
0339 void __iomem *qregs;
0340 struct pti_queue_entry *res_cpu;
0341 struct pti_queue_entry *req_cpu;
0342
0343 u_int req_in_ptr;
0344 u_int res_out_ptr;
0345 long send_marker;
0346 struct platform_device *op;
0347 unsigned long __pad;
0348
0349 int cmd_count[MAX_TARGETS];
0350 unsigned long tag_ages[MAX_TARGETS];
0351
0352
0353
0354
0355
0356 struct scsi_cmnd *cmd_slots[QLOGICPTI_REQ_QUEUE_LEN + 1];
0357
0358
0359 struct qlogicpti *next;
0360 dma_addr_t res_dvma;
0361 dma_addr_t req_dvma;
0362 u_char fware_majrev, fware_minrev, fware_micrev;
0363 struct Scsi_Host *qhost;
0364 int qpti_id;
0365 int scsi_id;
0366 int prom_node;
0367 int irq;
0368 char differential, ultra, clock;
0369 unsigned char bursts;
0370 struct host_param host_param;
0371 struct dev_param dev_param[MAX_TARGETS];
0372
0373 void __iomem *sreg;
0374 #define SREG_TPOWER 0x80
0375 #define SREG_FUSE 0x40
0376 #define SREG_PDISAB 0x20
0377 #define SREG_DSENSE 0x10
0378 #define SREG_IMASK 0x0c
0379 #define SREG_SPMASK 0x03
0380 unsigned char swsreg;
0381 unsigned int
0382 gotirq : 1,
0383 is_pti : 1;
0384 };
0385
0386
0387
0388
0389 #define SBUS_CFG1_EPAR 0x0100
0390 #define SBUS_CFG1_FMASK 0x00f0
0391 #define SBUS_CFG1_BENAB 0x0004
0392 #define SBUS_CFG1_B64 0x0003
0393 #define SBUS_CFG1_B32 0x0002
0394 #define SBUS_CFG1_B16 0x0001
0395 #define SBUS_CFG1_B8 0x0008
0396
0397
0398 #define SBUS_CTRL_EDIRQ 0x0020
0399 #define SBUS_CTRL_ECIRQ 0x0010
0400 #define SBUS_CTRL_ESIRQ 0x0008
0401 #define SBUS_CTRL_ERIRQ 0x0004
0402 #define SBUS_CTRL_GENAB 0x0002
0403 #define SBUS_CTRL_RESET 0x0001
0404
0405
0406 #define SBUS_STAT_DINT 0x0020
0407 #define SBUS_STAT_CINT 0x0010
0408 #define SBUS_STAT_SINT 0x0008
0409 #define SBUS_STAT_RINT 0x0004
0410 #define SBUS_STAT_GINT 0x0002
0411
0412
0413 #define SBUS_SEMAPHORE_STAT 0x0002
0414 #define SBUS_SEMAPHORE_LCK 0x0001
0415
0416
0417 #define DMA_CTRL_CSUSPEND 0x0010
0418 #define DMA_CTRL_CCLEAR 0x0008
0419 #define DMA_CTRL_FCLEAR 0x0004
0420 #define DMA_CTRL_CIRQ 0x0002
0421 #define DMA_CTRL_DMASTART 0x0001
0422
0423
0424 #define CPU_ORIDE_ETRIG 0x8000
0425 #define CPU_ORIDE_STEP 0x4000
0426 #define CPU_ORIDE_BKPT 0x2000
0427 #define CPU_ORIDE_PWRITE 0x1000
0428 #define CPU_ORIDE_OFORCE 0x0800
0429 #define CPU_ORIDE_LBACK 0x0400
0430 #define CPU_ORIDE_PTEST 0x0200
0431 #define CPU_ORIDE_TENAB 0x0100
0432 #define CPU_ORIDE_TPINS 0x0080
0433 #define CPU_ORIDE_FRESET 0x0008
0434 #define CPU_ORIDE_CTERM 0x0004
0435 #define CPU_ORIDE_RREG 0x0002
0436 #define CPU_ORIDE_RMOD 0x0001
0437
0438
0439 #define CPU_CMD_BRESET 0x300b
0440
0441
0442 #define CPU_PCTRL_PVALID 0x8000
0443 #define CPU_PCTRL_PHI 0x0400
0444 #define CPU_PCTRL_PLO 0x0200
0445 #define CPU_PCTRL_REQ 0x0100
0446 #define CPU_PCTRL_ACK 0x0080
0447 #define CPU_PCTRL_RST 0x0040
0448 #define CPU_PCTRL_BSY 0x0020
0449 #define CPU_PCTRL_SEL 0x0010
0450 #define CPU_PCTRL_ATN 0x0008
0451 #define CPU_PCTRL_MSG 0x0004
0452 #define CPU_PCTRL_CD 0x0002
0453 #define CPU_PCTRL_IO 0x0001
0454
0455
0456 #define CPU_PDIFF_SENSE 0x0200
0457 #define CPU_PDIFF_MODE 0x0100
0458 #define CPU_PDIFF_OENAB 0x0080
0459 #define CPU_PDIFF_PMASK 0x007c
0460 #define CPU_PDIFF_TGT 0x0002
0461 #define CPU_PDIFF_INIT 0x0001
0462
0463
0464 #define RISC_PSR_FTRUE 0x8000
0465 #define RISC_PSR_LCD 0x4000
0466 #define RISC_PSR_RIRQ 0x2000
0467 #define RISC_PSR_TOFLOW 0x1000
0468 #define RISC_PSR_AOFLOW 0x0800
0469 #define RISC_PSR_AMSB 0x0400
0470 #define RISC_PSR_ACARRY 0x0200
0471 #define RISC_PSR_AZERO 0x0100
0472 #define RISC_PSR_ULTRA 0x0020
0473 #define RISC_PSR_DIRQ 0x0010
0474 #define RISC_PSR_SIRQ 0x0008
0475 #define RISC_PSR_HIRQ 0x0004
0476 #define RISC_PSR_IPEND 0x0002
0477 #define RISC_PSR_FFALSE 0x0001
0478
0479
0480 #define RISC_MTREG_P1DFLT 0x1200
0481 #define RISC_MTREG_P0DFLT 0x0012
0482 #define RISC_MTREG_P1ULTRA 0x2300
0483 #define RISC_MTREG_P0ULTRA 0x0023
0484
0485
0486 #define HCCTRL_NOP 0x0000
0487 #define HCCTRL_RESET 0x1000
0488 #define HCCTRL_PAUSE 0x2000
0489 #define HCCTRL_REL 0x3000
0490 #define HCCTRL_STEP 0x4000
0491 #define HCCTRL_SHIRQ 0x5000
0492 #define HCCTRL_CHIRQ 0x6000
0493 #define HCCTRL_CRIRQ 0x7000
0494 #define HCCTRL_BKPT 0x8000
0495 #define HCCTRL_TMODE 0xf000
0496 #define HCCTRL_HIRQ 0x0080
0497 #define HCCTRL_RRIP 0x0040
0498 #define HCCTRL_RPAUSED 0x0020
0499 #define HCCTRL_EBENAB 0x0010
0500 #define HCCTRL_B1ENAB 0x0008
0501 #define HCCTRL_B0ENAB 0x0004
0502
0503
0504 #define for_each_qlogicpti(qp) \
0505 for((qp) = qptichain; (qp); (qp) = (qp)->next)
0506
0507 #endif