Go to the documentation of this file.
63 #define SCSI_NCR_BOOT_COMMAND_LINE_SUPPORT
64 #define SCSI_NCR_DEBUG_INFO_SUPPORT
70 #ifdef CONFIG_SCSI_NCR53C8XX_INTEGRITY_CHECK
71 # define SCSI_NCR_ENABLE_INTEGRITY_CHECK
91 #define SCSI_NCR_SETUP_SPECIAL_FEATURES (3)
93 #define SCSI_NCR_MAX_SYNC (80)
98 #ifdef CONFIG_SCSI_NCR53C8XX_MAX_TAGS
99 #if CONFIG_SCSI_NCR53C8XX_MAX_TAGS < 2
100 #define SCSI_NCR_MAX_TAGS (2)
101 #elif CONFIG_SCSI_NCR53C8XX_MAX_TAGS > 256
102 #define SCSI_NCR_MAX_TAGS (256)
104 #define SCSI_NCR_MAX_TAGS CONFIG_SCSI_NCR53C8XX_MAX_TAGS
107 #define SCSI_NCR_MAX_TAGS (8)
114 #ifdef CONFIG_SCSI_NCR53C8XX_DEFAULT_TAGS
115 #define SCSI_NCR_SETUP_DEFAULT_TAGS CONFIG_SCSI_NCR53C8XX_DEFAULT_TAGS
116 #elif defined CONFIG_SCSI_NCR53C8XX_TAGGED_QUEUE
117 #define SCSI_NCR_SETUP_DEFAULT_TAGS SCSI_NCR_MAX_TAGS
119 #define SCSI_NCR_SETUP_DEFAULT_TAGS (0)
125 #if defined(CONFIG_SCSI_NCR53C8XX_IARB)
126 #define SCSI_NCR_IARB_SUPPORT
133 #ifndef CONFIG_SCSI_NCR53C8XX_SYNC
134 #define CONFIG_SCSI_NCR53C8XX_SYNC (20)
135 #elif CONFIG_SCSI_NCR53C8XX_SYNC > SCSI_NCR_MAX_SYNC
136 #undef CONFIG_SCSI_NCR53C8XX_SYNC
137 #define CONFIG_SCSI_NCR53C8XX_SYNC SCSI_NCR_MAX_SYNC
140 #if CONFIG_SCSI_NCR53C8XX_SYNC == 0
141 #define SCSI_NCR_SETUP_DEFAULT_SYNC (255)
142 #elif CONFIG_SCSI_NCR53C8XX_SYNC <= 5
143 #define SCSI_NCR_SETUP_DEFAULT_SYNC (50)
144 #elif CONFIG_SCSI_NCR53C8XX_SYNC <= 20
145 #define SCSI_NCR_SETUP_DEFAULT_SYNC (250/(CONFIG_SCSI_NCR53C8XX_SYNC))
146 #elif CONFIG_SCSI_NCR53C8XX_SYNC <= 33
147 #define SCSI_NCR_SETUP_DEFAULT_SYNC (11)
148 #elif CONFIG_SCSI_NCR53C8XX_SYNC <= 40
149 #define SCSI_NCR_SETUP_DEFAULT_SYNC (10)
151 #define SCSI_NCR_SETUP_DEFAULT_SYNC (9)
157 #ifdef CONFIG_SCSI_NCR53C8XX_NO_DISCONNECT
158 #define SCSI_NCR_SETUP_DISCONNECTION (0)
160 #define SCSI_NCR_SETUP_DISCONNECTION (1)
166 #ifdef CONFIG_SCSI_NCR53C8XX_FORCE_SYNC_NEGO
167 #define SCSI_NCR_SETUP_FORCE_SYNC_NEGO (1)
169 #define SCSI_NCR_SETUP_FORCE_SYNC_NEGO (0)
175 #ifdef CONFIG_SCSI_NCR53C8XX_DISABLE_MPARITY_CHECK
176 #define SCSI_NCR_SETUP_MASTER_PARITY (0)
178 #define SCSI_NCR_SETUP_MASTER_PARITY (1)
184 #ifdef CONFIG_SCSI_NCR53C8XX_DISABLE_PARITY_CHECK
185 #define SCSI_NCR_SETUP_SCSI_PARITY (0)
187 #define SCSI_NCR_SETUP_SCSI_PARITY (1)
193 #define SCSI_NCR_SETUP_SETTLE_TIME (2)
198 #ifndef SCSI_NCR_PCIQ_WORK_AROUND_OPT
199 #define SCSI_NCR_PCIQ_WORK_AROUND_OPT 1
212 #if SCSI_NCR_PCIQ_WORK_AROUND_OPT == 1
213 #define SCSI_NCR_PCIQ_MAY_NOT_FLUSH_PW_UPSTREAM
214 #define SCSI_NCR_PCIQ_MAY_REORDER_WRITES
215 #define SCSI_NCR_PCIQ_MAY_MISS_COMPLETIONS
230 #elif SCSI_NCR_PCIQ_WORK_AROUND_OPT == 2
231 #define SCSI_NCR_PCIQ_MAY_NOT_FLUSH_PW_UPSTREAM
232 #define SCSI_NCR_PCIQ_MAY_REORDER_WRITES
233 #define SCSI_NCR_PCIQ_MAY_MISS_COMPLETIONS
234 #define SCSI_NCR_PCIQ_BROKEN_INTR
242 #elif SCSI_NCR_PCIQ_WORK_AROUND_OPT == 3
243 #define SCSI_NCR_PCIQ_SYNC_ON_INTR
251 #define SCSI_NCR_ALWAYS_SIMPLE_TAG
252 #define SCSI_NCR_MAX_SCATTER (127)
253 #define SCSI_NCR_MAX_TARGET (16)
261 #define SCSI_NCR_CAN_QUEUE (8*SCSI_NCR_MAX_TAGS + 2*SCSI_NCR_MAX_TARGET)
262 #define SCSI_NCR_CMD_PER_LUN (SCSI_NCR_MAX_TAGS)
264 #define SCSI_NCR_SG_TABLESIZE (SCSI_NCR_MAX_SCATTER)
265 #define SCSI_NCR_TIMER_INTERVAL (HZ)
268 #define SCSI_NCR_MAX_LUN (16)
270 #define SCSI_NCR_MAX_LUN (1)
282 #define outw_b2l outw
283 #define outl_b2l outl
285 #define readb_raw readb
286 #define writeb_raw writeb
288 #if defined(SCSI_NCR_BIG_ENDIAN)
289 #define readw_l2b __raw_readw
290 #define readl_l2b __raw_readl
291 #define writew_b2l __raw_writew
292 #define writel_b2l __raw_writel
293 #define readw_raw __raw_readw
294 #define readl_raw __raw_readl
295 #define writew_raw __raw_writew
296 #define writel_raw __raw_writel
298 #define readw_l2b readw
299 #define readl_l2b readl
300 #define writew_b2l writew
301 #define writel_b2l writel
302 #define readw_raw readw
303 #define readl_raw readl
304 #define writew_raw writew
305 #define writel_raw writel
312 #define outw_raw outw
313 #define outl_raw outl
315 #define readb_raw readb
316 #define readw_raw readw
317 #define readl_raw readl
318 #define writeb_raw writeb
319 #define writew_raw writew
320 #define writel_raw writel
324 #if !defined(__hppa__) && !defined(__mips__)
325 #ifdef SCSI_NCR_BIG_ENDIAN
326 #error "The NCR in BIG ENDIAN addressing mode is not (yet) supported"
330 #define MEMORY_BARRIER() mb()
341 #if defined(SCSI_NCR_BIG_ENDIAN)
343 #define ncr_offb(o) (((o)&~3)+((~((o)&3))&3))
344 #define ncr_offw(o) (((o)&~3)+((~((o)&3))&2))
348 #define ncr_offb(o) (o)
349 #define ncr_offw(o) (o)
361 #if defined(__BIG_ENDIAN) && !defined(SCSI_NCR_BIG_ENDIAN)
363 #define cpu_to_scr(dw) cpu_to_le32(dw)
364 #define scr_to_cpu(dw) le32_to_cpu(dw)
366 #elif defined(__LITTLE_ENDIAN) && defined(SCSI_NCR_BIG_ENDIAN)
368 #define cpu_to_scr(dw) cpu_to_be32(dw)
369 #define scr_to_cpu(dw) be32_to_cpu(dw)
373 #define cpu_to_scr(dw) (dw)
374 #define scr_to_cpu(dw) (dw)
395 #define INB_OFF(o) readb_raw((char __iomem *)np->reg + ncr_offb(o))
396 #define OUTB_OFF(o, val) writeb_raw((val), (char __iomem *)np->reg + ncr_offb(o))
398 #if defined(__BIG_ENDIAN) && !defined(SCSI_NCR_BIG_ENDIAN)
400 #define INW_OFF(o) readw_l2b((char __iomem *)np->reg + ncr_offw(o))
401 #define INL_OFF(o) readl_l2b((char __iomem *)np->reg + (o))
403 #define OUTW_OFF(o, val) writew_b2l((val), (char __iomem *)np->reg + ncr_offw(o))
404 #define OUTL_OFF(o, val) writel_b2l((val), (char __iomem *)np->reg + (o))
406 #elif defined(__LITTLE_ENDIAN) && defined(SCSI_NCR_BIG_ENDIAN)
408 #define INW_OFF(o) readw_b2l((char __iomem *)np->reg + ncr_offw(o))
409 #define INL_OFF(o) readl_b2l((char __iomem *)np->reg + (o))
411 #define OUTW_OFF(o, val) writew_l2b((val), (char __iomem *)np->reg + ncr_offw(o))
412 #define OUTL_OFF(o, val) writel_l2b((val), (char __iomem *)np->reg + (o))
416 #ifdef CONFIG_SCSI_NCR53C8XX_NO_WORD_TRANSFERS
418 #define INW_OFF(o) (readb((char __iomem *)np->reg + ncr_offw(o)) << 8 | readb((char __iomem *)np->reg + ncr_offw(o) + 1))
420 #define INW_OFF(o) readw_raw((char __iomem *)np->reg + ncr_offw(o))
422 #define INL_OFF(o) readl_raw((char __iomem *)np->reg + (o))
424 #ifdef CONFIG_SCSI_NCR53C8XX_NO_WORD_TRANSFERS
426 #define OUTW_OFF(o, val) do { writeb((char)((val) >> 8), (char __iomem *)np->reg + ncr_offw(o)); writeb((char)(val), (char __iomem *)np->reg + ncr_offw(o) + 1); } while (0)
428 #define OUTW_OFF(o, val) writew_raw((val), (char __iomem *)np->reg + ncr_offw(o))
430 #define OUTL_OFF(o, val) writel_raw((val), (char __iomem *)np->reg + (o))
434 #define INB(r) INB_OFF (offsetof(struct ncr_reg,r))
435 #define INW(r) INW_OFF (offsetof(struct ncr_reg,r))
436 #define INL(r) INL_OFF (offsetof(struct ncr_reg,r))
438 #define OUTB(r, val) OUTB_OFF (offsetof(struct ncr_reg,r), (val))
439 #define OUTW(r, val) OUTW_OFF (offsetof(struct ncr_reg,r), (val))
440 #define OUTL(r, val) OUTL_OFF (offsetof(struct ncr_reg,r), (val))
446 #define OUTONB(r, m) OUTB(r, INB(r) | (m))
447 #define OUTOFFB(r, m) OUTB(r, INB(r) & ~(m))
448 #define OUTONW(r, m) OUTW(r, INW(r) | (m))
449 #define OUTOFFW(r, m) OUTW(r, INW(r) & ~(m))
450 #define OUTONL(r, m) OUTL(r, INL(r) | (m))
451 #define OUTOFFL(r, m) OUTL(r, INL(r) & ~(m))
458 #define OUTL_DSP(v) \
461 OUTL (nc_dsp, (v)); \
464 #define OUTONB_STD() \
467 OUTONB (nc_dcntl, (STD|NOCOM)); \
480 #define FE_LED0 (1<<0)
481 #define FE_WIDE (1<<1)
482 #define FE_ULTRA (1<<2)
483 #define FE_DBLR (1<<4)
484 #define FE_QUAD (1<<5)
485 #define FE_ERL (1<<6)
486 #define FE_CLSE (1<<7)
487 #define FE_WRIE (1<<8)
488 #define FE_ERMP (1<<9)
489 #define FE_BOF (1<<10)
490 #define FE_DFS (1<<11)
491 #define FE_PFEN (1<<12)
492 #define FE_LDSTR (1<<13)
493 #define FE_RAM (1<<14)
494 #define FE_VARCLK (1<<15)
495 #define FE_RAM8K (1<<16)
496 #define FE_64BIT (1<<17)
497 #define FE_IO256 (1<<18)
498 #define FE_NOPM (1<<19)
499 #define FE_LEDC (1<<20)
500 #define FE_DIFF (1<<21)
501 #define FE_66MHZ (1<<23)
502 #define FE_DAC (1<<24)
503 #define FE_ISTAT1 (1<<25)
504 #define FE_DAC_IN_USE (1<<26)
505 #define FE_EHP (1<<27)
506 #define FE_MUX (1<<28)
507 #define FE_EA (1<<29)
509 #define FE_CACHE_SET (FE_ERL|FE_CLSE|FE_WRIE|FE_ERMP)
510 #define FE_SCSI_SET (FE_WIDE|FE_ULTRA|FE_DBLR|FE_QUAD|F_CLK80)
511 #define FE_SPECIAL_SET (FE_CACHE_SET|FE_BOF|FE_DFS|FE_LDSTR|FE_PFEN|FE_RAM)
521 #define SCSI_NCR_MAX_EXCLUDES 8
554 #define SCSI_NCR_DRIVER_SETUP \
556 SCSI_NCR_SETUP_MASTER_PARITY, \
557 SCSI_NCR_SETUP_SCSI_PARITY, \
558 SCSI_NCR_SETUP_DISCONNECTION, \
559 SCSI_NCR_SETUP_SPECIAL_FEATURES, \
560 SCSI_NCR_SETUP_FORCE_SYNC_NEGO, \
565 SCSI_NCR_SETUP_DEFAULT_TAGS, \
566 SCSI_NCR_SETUP_DEFAULT_SYNC, \
571 SCSI_NCR_SETUP_SETTLE_TIME, \
586 #define SCSI_NCR_DRIVER_SAFE_SETUP \
825 #define SMODE_HVD 0x40
826 #define SMODE_SE 0x80
827 #define SMODE_LVD 0xc0
868 #define XCLKH_DT 0x08
870 #define XCLKH_ST 0x04
914 #define REGJ(p,r) (offsetof(struct ncr_reg, p ## r))
915 #define REG(r) REGJ (nc_, r)
928 #define SCR_DATA_OUT 0x00000000
929 #define SCR_DATA_IN 0x01000000
930 #define SCR_COMMAND 0x02000000
931 #define SCR_STATUS 0x03000000
932 #define SCR_DT_DATA_OUT 0x04000000
933 #define SCR_DT_DATA_IN 0x05000000
934 #define SCR_MSG_OUT 0x06000000
935 #define SCR_MSG_IN 0x07000000
937 #define SCR_ILG_OUT 0x04000000
938 #define SCR_ILG_IN 0x05000000
958 #define OPC_MOVE 0x08000000
960 #define SCR_MOVE_ABS(l) ((0x00000000 | OPC_MOVE) | (l))
961 #define SCR_MOVE_IND(l) ((0x20000000 | OPC_MOVE) | (l))
962 #define SCR_MOVE_TBL (0x10000000 | OPC_MOVE)
964 #define SCR_CHMOV_ABS(l) ((0x00000000) | (l))
965 #define SCR_CHMOV_IND(l) ((0x20000000) | (l))
966 #define SCR_CHMOV_TBL (0x10000000)
988 #define SCR_SEL_ABS 0x40000000
989 #define SCR_SEL_ABS_ATN 0x41000000
990 #define SCR_SEL_TBL 0x42000000
991 #define SCR_SEL_TBL_ATN 0x43000000
994 #ifdef SCSI_NCR_BIG_ENDIAN
1010 #define SCR_JMP_REL 0x04000000
1011 #define SCR_ID(id) (((u32)(id)) << 16)
1028 #define SCR_WAIT_DISC 0x48000000
1029 #define SCR_WAIT_RESEL 0x50000000
1044 #define SCR_SET(f) (0x58000000 | (f))
1045 #define SCR_CLR(f) (0x60000000 | (f))
1047 #define SCR_CARRY 0x00000400
1048 #define SCR_TRG 0x00000200
1049 #define SCR_ACK 0x00000040
1050 #define SCR_ATN 0x00000008
1073 #define SCR_NO_FLUSH 0x01000000
1075 #define SCR_COPY(n) (0xc0000000 | SCR_NO_FLUSH | (n))
1076 #define SCR_COPY_F(n) (0xc0000000 | (n))
1102 #define SCR_REG_OFS(ofs) ((((ofs) & 0x7f) << 16ul) + ((ofs) & 0x80))
1104 #define SCR_SFBR_REG(reg,op,data) \
1105 (0x68000000 | (SCR_REG_OFS(REG(reg))) | (op) | (((data)&0xff)<<8ul))
1107 #define SCR_REG_SFBR(reg,op,data) \
1108 (0x70000000 | (SCR_REG_OFS(REG(reg))) | (op) | (((data)&0xff)<<8ul))
1110 #define SCR_REG_REG(reg,op,data) \
1111 (0x78000000 | (SCR_REG_OFS(REG(reg))) | (op) | (((data)&0xff)<<8ul))
1114 #define SCR_LOAD 0x00000000
1115 #define SCR_SHL 0x01000000
1116 #define SCR_OR 0x02000000
1117 #define SCR_XOR 0x03000000
1118 #define SCR_AND 0x04000000
1119 #define SCR_SHR 0x05000000
1120 #define SCR_ADD 0x06000000
1121 #define SCR_ADDC 0x07000000
1123 #define SCR_SFBR_DATA (0x00800000>>8ul)
1142 #define SCR_FROM_REG(reg) \
1143 SCR_REG_SFBR(reg,SCR_OR,0)
1145 #define SCR_TO_REG(reg) \
1146 SCR_SFBR_REG(reg,SCR_OR,0)
1148 #define SCR_LOAD_REG(reg,data) \
1149 SCR_REG_REG(reg,SCR_LOAD,data)
1151 #define SCR_LOAD_SFBR(data) \
1152 (SCR_REG_SFBR (gpreg, SCR_LOAD, data))
1172 #define SCR_REG_OFS2(ofs) (((ofs) & 0xff) << 16ul)
1173 #define SCR_NO_FLUSH2 0x02000000
1174 #define SCR_DSA_REL2 0x10000000
1176 #define SCR_LOAD_R(reg, how, n) \
1177 (0xe1000000 | how | (SCR_REG_OFS2(REG(reg))) | (n))
1179 #define SCR_STORE_R(reg, how, n) \
1180 (0xe0000000 | how | (SCR_REG_OFS2(REG(reg))) | (n))
1182 #define SCR_LOAD_ABS(reg, n) SCR_LOAD_R(reg, SCR_NO_FLUSH2, n)
1183 #define SCR_LOAD_REL(reg, n) SCR_LOAD_R(reg, SCR_NO_FLUSH2|SCR_DSA_REL2, n)
1184 #define SCR_LOAD_ABS_F(reg, n) SCR_LOAD_R(reg, 0, n)
1185 #define SCR_LOAD_REL_F(reg, n) SCR_LOAD_R(reg, SCR_DSA_REL2, n)
1187 #define SCR_STORE_ABS(reg, n) SCR_STORE_R(reg, SCR_NO_FLUSH2, n)
1188 #define SCR_STORE_REL(reg, n) SCR_STORE_R(reg, SCR_NO_FLUSH2|SCR_DSA_REL2,n)
1189 #define SCR_STORE_ABS_F(reg, n) SCR_STORE_R(reg, 0, n)
1190 #define SCR_STORE_REL_F(reg, n) SCR_STORE_R(reg, SCR_DSA_REL2, n)
1229 #define SCR_NO_OP 0x80000000
1230 #define SCR_JUMP 0x80080000
1231 #define SCR_JUMP64 0x80480000
1232 #define SCR_JUMPR 0x80880000
1233 #define SCR_CALL 0x88080000
1234 #define SCR_CALLR 0x88880000
1235 #define SCR_RETURN 0x90080000
1236 #define SCR_INT 0x98080000
1237 #define SCR_INT_FLY 0x98180000
1239 #define IFFALSE(arg) (0x00080000 | (arg))
1240 #define IFTRUE(arg) (0x00000000 | (arg))
1242 #define WHEN(phase) (0x00030000 | (phase))
1243 #define IF(phase) (0x00020000 | (phase))
1245 #define DATA(D) (0x00040000 | ((D) & 0xff))
1246 #define MASK(D,M) (0x00040000 | (((M ^ 0xff) & 0xff) << 8ul)|((D) & 0xff))
1248 #define CARRYSET (0x00200000)
1261 #define S_GOOD (0x00)
1262 #define S_CHECK_COND (0x02)
1263 #define S_COND_MET (0x04)
1264 #define S_BUSY (0x08)
1265 #define S_INT (0x10)
1266 #define S_INT_COND_MET (0x14)
1267 #define S_CONFLICT (0x18)
1268 #define S_TERMINATED (0x20)
1269 #define S_QUEUE_FULL (0x28)
1270 #define S_ILLEGAL (0xff)
1271 #define S_SENSE (0x80)
1283 #define ncr_build_sge(np, data, badd, len) \
1285 (data)->addr = cpu_to_scr(badd); \
1286 (data)->size = cpu_to_scr(len); \