21 #undef NCR_700_TAG_DEBUG
24 #define DEBUG(x) printk x
25 #define DDEBUG(prefix, sdev, fmt, a...) \
26 sdev_printk(prefix, sdev, fmt, ##a)
27 #define CDEBUG(prefix, scmd, fmt, a...) \
28 scmd_printk(prefix, scmd, fmt, ##a)
30 #define DEBUG(x) do {} while (0)
31 #define DDEBUG(prefix, scmd, fmt, a...) do {} while (0)
32 #define CDEBUG(prefix, scmd, fmt, a...) do {} while (0)
36 #define NCR_700_COMMAND_SLOTS_PER_HOST 64
38 #define NCR_700_SG_SEGMENTS 32
40 #define NCR_700_MAX_LUNS 32
41 #define NCR_700_LUN_MASK (NCR_700_MAX_LUNS - 1)
43 #define NCR_700_MAX_TAGS 16
45 #define NCR_700_DEFAULT_TAGS 4
50 #define NCR_700_CMD_PER_LUN 2
52 #define NCR_700_INTERNAL_SENSE_MAGIC 0x42
71 #define SCRIPT_MOVE_DATA_IN 0x09000000
72 #define SCRIPT_MOVE_DATA_OUT 0x08000000
75 #define SCRIPT_NOP 0x80000000
76 #define SCRIPT_RETURN 0x90080000
102 #define NCR_700_DEV_NEGOTIATED_SYNC (1<<16)
103 #define NCR_700_DEV_BEGIN_SYNC_NEGOTIATION (1<<17)
104 #define NCR_700_DEV_PRINT_SYNC_NEGOTIATION (1<<19)
106 static inline char *NCR_700_get_sense_cmnd(
struct scsi_device *SDp)
110 return hostdata->
cmnd;
125 return hostdata->
depth;
172 #define NCR_700_SLOT_MASK 0xFC
173 #define NCR_700_SLOT_MAGIC 0xb8
174 #define NCR_700_SLOT_FREE (0|NCR_700_SLOT_MAGIC)
175 #define NCR_700_SLOT_BUSY (1|NCR_700_SLOT_MAGIC)
176 #define NCR_700_SLOT_QUEUED (2|NCR_700_SLOT_MAGIC)
178 #define NCR_700_FLAG_AUTOSENSE 0x01
203 #ifdef CONFIG_53C700_LE_ON_BE
206 __u32 force_le_on_be:1;
225 #define MSG_ARRAY_SIZE 8
226 #define MSGOUT_OFFSET (L1_CACHE_ALIGN(sizeof(SCRIPT)))
228 #define MSGIN_OFFSET (MSGOUT_OFFSET + L1_CACHE_ALIGN(MSG_ARRAY_SIZE))
230 #define STATUS_OFFSET (MSGIN_OFFSET + L1_CACHE_ALIGN(MSG_ARRAY_SIZE))
232 #define SLOTS_OFFSET (STATUS_OFFSET + L1_CACHE_ALIGN(MSG_ARRAY_SIZE))
234 #define TOTAL_MEM_SIZE (SLOTS_OFFSET + L1_CACHE_ALIGN(sizeof(struct NCR_700_command_slot) * NCR_700_COMMAND_SLOTS_PER_HOST))
255 #ifdef CONFIG_53C700_LE_ON_BE
256 #define bE (hostdata->force_le_on_be ? 0 : 3)
257 #define bSWAP (hostdata->force_le_on_be)
258 #define bEBus (!hostdata->force_le_on_be)
259 #elif defined(__BIG_ENDIAN)
262 #elif defined(__LITTLE_ENDIAN)
266 #error "__BIG_ENDIAN or __LITTLE_ENDIAN must be defined, did you include byteorder.h?"
269 #ifdef CONFIG_53C700_BE_BUS
275 #define bS_to_cpu(x) (bSWAP ? le32_to_cpu(x) : (x))
276 #define bS_to_host(x) (bSWAP ? cpu_to_le32(x) : (x))
280 #define SCNTL0_REG 0x00
281 #define FULL_ARBITRATION 0xc0
283 #define ENABLE_PARITY 0x04
284 #define AUTO_ATN 0x02
285 #define SCNTL1_REG 0x01
286 #define SLOW_BUS 0x80
287 #define ENABLE_SELECT 0x20
288 #define ASSERT_RST 0x08
289 #define ASSERT_EVEN_PARITY 0x04
290 #define SDID_REG 0x02
291 #define SIEN_REG 0x03
292 #define PHASE_MM_INT 0x80
293 #define FUNC_COMP_INT 0x40
294 #define SEL_TIMEOUT_INT 0x20
295 #define SELECT_INT 0x10
296 #define GROSS_ERR_INT 0x08
297 #define UX_DISC_INT 0x04
299 #define PAR_ERR_INT 0x01
300 #define SCID_REG 0x04
301 #define SXFER_REG 0x05
302 #define ASYNC_OPERATION 0x00
303 #define SODL_REG 0x06
304 #define SOCL_REG 0x07
305 #define SFBR_REG 0x08
306 #define SIDL_REG 0x09
307 #define SBDL_REG 0x0A
308 #define SBCL_REG 0x0B
312 #define SYNC_DIV_AS_ASYNC 0x00
313 #define SYNC_DIV_1_0 0x01
314 #define SYNC_DIV_1_5 0x02
315 #define SYNC_DIV_2_0 0x03
316 #define DSTAT_REG 0x0C
317 #define ILGL_INST_DETECTED 0x01
318 #define WATCH_DOG_INTERRUPT 0x02
319 #define SCRIPT_INT_RECEIVED 0x04
321 #define SSTAT0_REG 0x0D
322 #define PARITY_ERROR 0x01
323 #define SCSI_RESET_DETECTED 0x02
324 #define UNEXPECTED_DISCONNECT 0x04
325 #define SCSI_GROSS_ERROR 0x08
326 #define SELECTED 0x10
327 #define SELECTION_TIMEOUT 0x20
328 #define FUNCTION_COMPLETE 0x40
329 #define PHASE_MISMATCH 0x80
330 #define SSTAT1_REG 0x0E
331 #define SIDL_REG_FULL 0x80
332 #define SODR_REG_FULL 0x40
333 #define SODL_REG_FULL 0x20
334 #define SSTAT2_REG 0x0F
335 #define CTEST0_REG 0x14
336 #define BTB_TIMER_DISABLE 0x40
337 #define CTEST1_REG 0x15
338 #define CTEST2_REG 0x16
339 #define CTEST3_REG 0x17
340 #define CTEST4_REG 0x18
341 #define DISABLE_FIFO 0x00
344 #define BYTE_LANE0 0x04
345 #define BYTE_LANE1 0x05
346 #define BYTE_LANE2 0x06
347 #define BYTE_LANE3 0x07
348 #define SCSI_ZMODE 0x20
350 #define CTEST5_REG 0x19
351 #define MASTER_CONTROL 0x10
352 #define DMA_DIRECTION 0x08
353 #define CTEST7_REG 0x1B
354 #define BURST_DISABLE 0x80
355 #define SEL_TIMEOUT_DISABLE 0x10
358 #define CTEST7_TT1 0x02
360 #define CTEST6_REG 0x1A
361 #define TEMP_REG 0x1C
362 #define DFIFO_REG 0x20
363 #define FLUSH_DMA_FIFO 0x80
364 #define CLR_FIFO 0x40
365 #define ISTAT_REG 0x21
366 #define ABORT_OPERATION 0x80
367 #define SOFTWARE_RESET_710 0x40
368 #define DMA_INT_PENDING 0x01
369 #define SCSI_INT_PENDING 0x02
370 #define CONNECTED 0x08
371 #define CTEST8_REG 0x22
372 #define LAST_DIS_ENBL 0x01
373 #define SHORTEN_FILTERING 0x04
374 #define ENABLE_ACTIVE_NEGATION 0x10
375 #define GENERATE_RECEIVE_PARITY 0x20
376 #define CLR_FIFO_710 0x04
377 #define FLUSH_DMA_FIFO_710 0x08
378 #define CTEST9_REG 0x23
380 #define DCMD_REG 0x27
381 #define DNAD_REG 0x28
382 #define DIEN_REG 0x39
383 #define BUS_FAULT 0x20
384 #define ABORT_INT 0x10
385 #define INT_INST_INT 0x04
387 #define ILGL_INST_INT 0x01
388 #define DCNTL_REG 0x3B
389 #define SOFTWARE_RESET 0x01
390 #define COMPAT_700_MODE 0x01
391 #define SCRPTS_16BITS 0x20
393 #define ASYNC_DIV_2_0 0x00
394 #define ASYNC_DIV_1_5 0x40
395 #define ASYNC_DIV_1_0 0x80
396 #define ASYNC_DIV_3_0 0xc0
397 #define DMODE_710_REG 0x38
398 #define DMODE_700_REG 0x34
399 #define BURST_LENGTH_1 0x00
400 #define BURST_LENGTH_2 0x40
401 #define BURST_LENGTH_4 0x80
402 #define BURST_LENGTH_8 0xC0
403 #define DMODE_FC1 0x10
404 #define DMODE_FC2 0x20
411 #define DSPS_REG 0x30
415 #define NCR_700_MAX_OFFSET 8
418 #define NCR_710_MAX_OFFSET 8
419 #define NCR_700_MIN_XFERP 1
420 #define NCR_710_MIN_XFERP 0
421 #define NCR_700_MIN_PERIOD 25
423 #define script_patch_32(dev, script, symbol, value) \
426 for(i=0; i< (sizeof(A_##symbol##_used) / sizeof(__u32)); i++) { \
427 __u32 val = bS_to_cpu((script)[A_##symbol##_used[i]]) + value; \
428 (script)[A_##symbol##_used[i]] = bS_to_host(val); \
429 dma_cache_sync((dev), &(script)[A_##symbol##_used[i]], 4, DMA_TO_DEVICE); \
430 DEBUG((" script, patching %s at %d to 0x%lx\n", \
431 #symbol, A_##symbol##_used[i], (value))); \
435 #define script_patch_32_abs(dev, script, symbol, value) \
438 for(i=0; i< (sizeof(A_##symbol##_used) / sizeof(__u32)); i++) { \
439 (script)[A_##symbol##_used[i]] = bS_to_host(value); \
440 dma_cache_sync((dev), &(script)[A_##symbol##_used[i]], 4, DMA_TO_DEVICE); \
441 DEBUG((" script, patching %s at %d to 0x%lx\n", \
442 #symbol, A_##symbol##_used[i], (value))); \
447 #define script_patch_ID(dev, script, symbol, value) \
450 for(i=0; i< (sizeof(A_##symbol##_used) / sizeof(__u32)); i++) { \
451 __u32 val = bS_to_cpu((script)[A_##symbol##_used[i]]); \
453 val |= ((value) & 0xff) << 16; \
454 (script)[A_##symbol##_used[i]] = bS_to_host(val); \
455 dma_cache_sync((dev), &(script)[A_##symbol##_used[i]], 4, DMA_TO_DEVICE); \
456 DEBUG((" script, patching ID field %s at %d to 0x%x\n", \
457 #symbol, A_##symbol##_used[i], val)); \
461 #define script_patch_16(dev, script, symbol, value) \
464 for(i=0; i< (sizeof(A_##symbol##_used) / sizeof(__u32)); i++) { \
465 __u32 val = bS_to_cpu((script)[A_##symbol##_used[i]]); \
467 val |= ((value) & 0xffff); \
468 (script)[A_##symbol##_used[i]] = bS_to_host(val); \
469 dma_cache_sync((dev), &(script)[A_##symbol##_used[i]], 4, DMA_TO_DEVICE); \
470 DEBUG((" script, patching short field %s at %d to 0x%x\n", \
471 #symbol, A_##symbol##_used[i], val)); \