1 /******************************************************************************
2 ** High Performance device driver for the Symbios 53C896 controller.
4 ** Copyright (C) 1998-2001 Gerard Roudier <groudier@free.fr>
6 ** This driver also supports all the Symbios 53C8XX controller family,
7 ** except 53C810 revisions < 16, 53C825 revisions < 16 and all
8 ** revisions of 53C815 controllers.
10 ** This driver is based on the Linux port of the FreeBSD ncr driver.
12 ** Copyright (C) 1994 Wolfgang Stanglmeier
14 **-----------------------------------------------------------------------------
16 ** This program is free software; you can redistribute it and/or modify
17 ** it under the terms of the GNU General Public License as published by
18 ** the Free Software Foundation; either version 2 of the License, or
19 ** (at your option) any later version.
21 ** This program is distributed in the hope that it will be useful,
22 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
23 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 ** GNU General Public License for more details.
26 ** You should have received a copy of the GNU General Public License
27 ** along with this program; if not, write to the Free Software
28 ** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
30 **-----------------------------------------------------------------------------
32 ** The Linux port of the FreeBSD ncr driver has been achieved in
35 ** Gerard Roudier <groudier@free.fr>
37 ** Being given that this driver originates from the FreeBSD version, and
38 ** in order to keep synergy on both, any suggested enhancements and corrections
39 ** received on Linux are automatically a potential candidate for the FreeBSD
42 ** The original driver has been written for 386bsd and FreeBSD by
43 ** Wolfgang Stanglmeier <wolf@cologne.de>
44 ** Stefan Esser <se@mi.Uni-Koeln.de>
46 **-----------------------------------------------------------------------------
48 ** Major contributions:
49 ** --------------------
51 ** NVRAM detection and reading.
52 ** Copyright (C) 1997 Richard Waltham <dormouse@farsrobt.demon.co.uk>
54 *******************************************************************************
58 ** This file contains definitions and code that the
59 ** sym53c8xx and ncr53c8xx drivers should share.
60 ** The sharing will be achieved in a further version
61 ** of the driver bundle. For now, only the ncr53c8xx
62 ** driver includes this file.
65 /*==========================================================
67 ** Hmmm... What complex some PCI-HOST bridges actually
68 ** are, despite the fact that the PCI specifications
69 ** are looking so smart and simple! ;-)
71 **==========================================================
74 /*==========================================================
76 ** Miscallaneous defines.
78 **==========================================================
81 #define u_char unsigned char
82 #define u_long unsigned long
85 #define bzero(d, n) memset((d), 0, (n))
88 /*==========================================================
92 **==========================================================
94 ** modified copy from 386bsd:/usr/include/sys/assert.h
96 **----------------------------------------------------------
99 #define assert(expression) { \
100 if (!(expression)) { \
102 "assertion \"%s\" failed: file \"%s\", line %d\n", \
104 __FILE__, __LINE__); \
108 /*==========================================================
112 **==========================================================
115 #define DEBUG_ALLOC (0x0001)
116 #define DEBUG_PHASE (0x0002)
117 #define DEBUG_QUEUE (0x0008)
118 #define DEBUG_RESULT (0x0010)
119 #define DEBUG_POINTER (0x0020)
120 #define DEBUG_SCRIPT (0x0040)
121 #define DEBUG_TINY (0x0080)
122 #define DEBUG_TIMING (0x0100)
123 #define DEBUG_NEGO (0x0200)
124 #define DEBUG_TAGS (0x0400)
125 #define DEBUG_SCATTER (0x0800)
126 #define DEBUG_IC (0x1000)
129 ** Enable/Disable debug messages.
130 ** Can be changed at runtime too.
133 #ifdef SCSI_NCR_DEBUG_INFO_SUPPORT
134 static int ncr_debug
= SCSI_NCR_DEBUG_FLAGS
;
135 #define DEBUG_FLAGS ncr_debug
137 #define DEBUG_FLAGS SCSI_NCR_DEBUG_FLAGS
140 /*==========================================================
142 ** A la VMS/CAM-3 queue management.
143 ** Implemented from linux list management.
145 **==========================================================
148 typedef struct xpt_quehead
{
149 struct xpt_quehead
*flink
; /* Forward pointer */
150 struct xpt_quehead
*blink
; /* Backward pointer */
153 #define xpt_que_init(ptr) do { \
154 (ptr)->flink = (ptr); (ptr)->blink = (ptr); \
157 static inline void __xpt_que_add(struct xpt_quehead
* new,
158 struct xpt_quehead
* blink
,
159 struct xpt_quehead
* flink
)
167 static inline void __xpt_que_del(struct xpt_quehead
* blink
,
168 struct xpt_quehead
* flink
)
170 flink
->blink
= blink
;
171 blink
->flink
= flink
;
174 static inline int xpt_que_empty(struct xpt_quehead
*head
)
176 return head
->flink
== head
;
179 static inline void xpt_que_splice(struct xpt_quehead
*list
,
180 struct xpt_quehead
*head
)
182 struct xpt_quehead
*first
= list
->flink
;
185 struct xpt_quehead
*last
= list
->blink
;
186 struct xpt_quehead
*at
= head
->flink
;
196 #define xpt_que_entry(ptr, type, member) \
197 ((type *)((char *)(ptr)-(unsigned long)(&((type *)0)->member)))
200 #define xpt_insque(new, pos) __xpt_que_add(new, pos, (pos)->flink)
202 #define xpt_remque(el) __xpt_que_del((el)->blink, (el)->flink)
204 #define xpt_insque_head(new, head) __xpt_que_add(new, head, (head)->flink)
206 static inline struct xpt_quehead
*xpt_remque_head(struct xpt_quehead
*head
)
208 struct xpt_quehead
*elem
= head
->flink
;
211 __xpt_que_del(head
, elem
->flink
);
217 #define xpt_insque_tail(new, head) __xpt_que_add(new, (head)->blink, head)
219 static inline struct xpt_quehead
*xpt_remque_tail(struct xpt_quehead
*head
)
221 struct xpt_quehead
*elem
= head
->blink
;
224 __xpt_que_del(elem
->blink
, head
);
231 /*==========================================================
235 ** Assuming that SMP systems are generally high end
236 ** systems and may use several SCSI adapters, we are
237 ** using one lock per controller instead of some global
238 ** one. For the moment (linux-2.1.95), driver's entry
239 ** points are called with the 'io_request_lock' lock
241 ** - We are uselessly loosing a couple of micro-seconds
242 ** to lock the controller data structure.
243 ** - But the driver is not broken by design for SMP and
244 ** so can be more resistant to bugs or bad changes in
245 ** the IO sub-system code.
246 ** - A small advantage could be that the interrupt code
247 ** is grained as wished (e.g.: by controller).
249 **==========================================================
252 spinlock_t DRIVER_SMP_LOCK
= SPIN_LOCK_UNLOCKED
;
253 #define NCR_LOCK_DRIVER(flags) spin_lock_irqsave(&DRIVER_SMP_LOCK, flags)
254 #define NCR_UNLOCK_DRIVER(flags) \
255 spin_unlock_irqrestore(&DRIVER_SMP_LOCK, flags)
257 #define NCR_INIT_LOCK_NCB(np) spin_lock_init(&np->smp_lock)
258 #define NCR_LOCK_NCB(np, flags) spin_lock_irqsave(&np->smp_lock, flags)
259 #define NCR_UNLOCK_NCB(np, flags) spin_unlock_irqrestore(&np->smp_lock, flags)
261 #define NCR_LOCK_SCSI_DONE(host, flags) \
262 spin_lock_irqsave((host)->host_lock, flags)
263 #define NCR_UNLOCK_SCSI_DONE(host, flags) \
264 spin_unlock_irqrestore(((host)->host_lock), flags)
266 /*==========================================================
270 ** Since linux-2.1, we must use ioremap() to map the io
271 ** memory space and iounmap() to unmap it. This allows
272 ** portability. Linux 1.3.X and 2.0.X allow to remap
273 ** physical pages addresses greater than the highest
274 ** physical memory address to kernel virtual pages with
275 ** vremap() / vfree(). That was not portable but worked
276 ** with i386 architecture.
278 **==========================================================
285 #define memcpy_to_pci(a, b, c) memcpy_toio((a), (b), (c))
287 /*==========================================================
289 ** Insert a delay in micro-seconds and milli-seconds.
291 ** Under Linux, udelay() is restricted to delay <
292 ** 1 milli-second. In fact, it generally works for up
293 ** to 1 second delay. Since 2.1.105, the mdelay() function
294 ** is provided for delays in milli-seconds.
295 ** Under 2.0 kernels, udelay() is an inline function
296 ** that is very inaccurate on Pentium processors.
298 **==========================================================
301 #define UDELAY udelay
302 #define MDELAY mdelay
304 /*==========================================================
306 ** Simple power of two buddy-like allocator.
308 ** This simple code is not intended to be fast, but to
309 ** provide power of 2 aligned memory allocations.
310 ** Since the SCRIPTS processor only supplies 8 bit
311 ** arithmetic, this allocator allows simple and fast
312 ** address calculations from the SCRIPTS code.
313 ** In addition, cache line alignment is guaranteed for
314 ** power of 2 cache line size.
315 ** Enhanced in linux-2.3.44 to provide a memory pool
316 ** per pcidev to support dynamic dma mapping. (I would
317 ** have preferred a real bus astraction, btw).
319 **==========================================================
322 #define __GetFreePages(flags, order) __get_free_pages(flags, order)
324 #define MEMO_SHIFT 4 /* 16 bytes minimum memory chunk */
325 #if PAGE_SIZE >= 8192
326 #define MEMO_PAGE_ORDER 0 /* 1 PAGE maximum */
328 #define MEMO_PAGE_ORDER 1 /* 2 PAGES maximum */
330 #define MEMO_FREE_UNUSED /* Free unused pages immediately */
332 #define MEMO_GFP_FLAGS GFP_ATOMIC
333 #define MEMO_CLUSTER_SHIFT (PAGE_SHIFT+MEMO_PAGE_ORDER)
334 #define MEMO_CLUSTER_SIZE (1UL << MEMO_CLUSTER_SHIFT)
335 #define MEMO_CLUSTER_MASK (MEMO_CLUSTER_SIZE-1)
337 typedef u_long m_addr_t
; /* Enough bits to bit-hack addresses */
338 typedef struct device
*m_bush_t
; /* Something that addresses DMAable */
340 typedef struct m_link
{ /* Link between free memory chunks */
344 typedef struct m_vtob
{ /* Virtual to Bus address translation */
349 #define VTOB_HASH_SHIFT 5
350 #define VTOB_HASH_SIZE (1UL << VTOB_HASH_SHIFT)
351 #define VTOB_HASH_MASK (VTOB_HASH_SIZE-1)
352 #define VTOB_HASH_CODE(m) \
353 ((((m_addr_t) (m)) >> MEMO_CLUSTER_SHIFT) & VTOB_HASH_MASK)
355 typedef struct m_pool
{ /* Memory pool of a given kind */
357 m_addr_t (*getp
)(struct m_pool
*);
358 void (*freep
)(struct m_pool
*, m_addr_t
);
359 #define M_GETP() mp->getp(mp)
360 #define M_FREEP(p) mp->freep(mp, p)
361 #define GetPages() __GetFreePages(MEMO_GFP_FLAGS, MEMO_PAGE_ORDER)
362 #define FreePages(p) free_pages(p, MEMO_PAGE_ORDER)
364 m_vtob_s
*(vtob
[VTOB_HASH_SIZE
]);
366 struct m_link h
[PAGE_SHIFT
-MEMO_SHIFT
+MEMO_PAGE_ORDER
+1];
369 static void *___m_alloc(m_pool_s
*mp
, int size
)
372 int s
= (1 << MEMO_SHIFT
);
377 if (size
> (PAGE_SIZE
<< MEMO_PAGE_ORDER
))
387 if (s
== (PAGE_SIZE
<< MEMO_PAGE_ORDER
)) {
388 h
[j
].next
= (m_link_s
*) M_GETP();
390 h
[j
].next
->next
= NULL
;
396 a
= (m_addr_t
) h
[j
].next
;
398 h
[j
].next
= h
[j
].next
->next
;
402 h
[j
].next
= (m_link_s
*) (a
+s
);
403 h
[j
].next
->next
= NULL
;
407 printk("___m_alloc(%d) = %p\n", size
, (void *) a
);
412 static void ___m_free(m_pool_s
*mp
, void *ptr
, int size
)
415 int s
= (1 << MEMO_SHIFT
);
421 printk("___m_free(%p, %d)\n", ptr
, size
);
424 if (size
> (PAGE_SIZE
<< MEMO_PAGE_ORDER
))
435 #ifdef MEMO_FREE_UNUSED
436 if (s
== (PAGE_SIZE
<< MEMO_PAGE_ORDER
)) {
443 while (q
->next
&& q
->next
!= (m_link_s
*) b
) {
447 ((m_link_s
*) a
)->next
= h
[i
].next
;
448 h
[i
].next
= (m_link_s
*) a
;
451 q
->next
= q
->next
->next
;
458 static void *__m_calloc2(m_pool_s
*mp
, int size
, char *name
, int uflags
)
462 p
= ___m_alloc(mp
, size
);
464 if (DEBUG_FLAGS
& DEBUG_ALLOC
)
465 printk ("new %-10s[%4d] @%p.\n", name
, size
, p
);
469 else if (uflags
& MEMO_WARN
)
470 printk (NAME53C8XX
": failed to allocate %s[%d]\n", name
, size
);
475 #define __m_calloc(mp, s, n) __m_calloc2(mp, s, n, MEMO_WARN)
477 static void __m_free(m_pool_s
*mp
, void *ptr
, int size
, char *name
)
479 if (DEBUG_FLAGS
& DEBUG_ALLOC
)
480 printk ("freeing %-10s[%4d] @%p.\n", name
, size
, ptr
);
482 ___m_free(mp
, ptr
, size
);
487 * With pci bus iommu support, we use a default pool of unmapped memory
488 * for memory we donnot need to DMA from/to and one pool per pcidev for
489 * memory accessed by the PCI chip. `mp0' is the default not DMAable pool.
492 static m_addr_t
___mp0_getp(m_pool_s
*mp
)
494 m_addr_t m
= GetPages();
500 static void ___mp0_freep(m_pool_s
*mp
, m_addr_t m
)
506 static m_pool_s mp0
= {NULL
, ___mp0_getp
, ___mp0_freep
};
513 * With pci bus iommu support, we maintain one pool per pcidev and a
514 * hashed reverse table for virtual to bus physical address translations.
516 static m_addr_t
___dma_getp(m_pool_s
*mp
)
521 vbp
= __m_calloc(&mp0
, sizeof(*vbp
), "VTOB");
524 vp
= (m_addr_t
) dma_alloc_coherent(mp
->bush
,
525 PAGE_SIZE
<<MEMO_PAGE_ORDER
,
528 int hc
= VTOB_HASH_CODE(vp
);
531 vbp
->next
= mp
->vtob
[hc
];
538 __m_free(&mp0
, vbp
, sizeof(*vbp
), "VTOB");
542 static void ___dma_freep(m_pool_s
*mp
, m_addr_t m
)
544 m_vtob_s
**vbpp
, *vbp
;
545 int hc
= VTOB_HASH_CODE(m
);
547 vbpp
= &mp
->vtob
[hc
];
548 while (*vbpp
&& (*vbpp
)->vaddr
!= m
)
549 vbpp
= &(*vbpp
)->next
;
552 *vbpp
= (*vbpp
)->next
;
553 dma_free_coherent(mp
->bush
, PAGE_SIZE
<<MEMO_PAGE_ORDER
,
554 (void *)vbp
->vaddr
, (dma_addr_t
)vbp
->baddr
);
555 __m_free(&mp0
, vbp
, sizeof(*vbp
), "VTOB");
560 static inline m_pool_s
*___get_dma_pool(m_bush_t bush
)
563 for (mp
= mp0
.next
; mp
&& mp
->bush
!= bush
; mp
= mp
->next
);
567 static m_pool_s
*___cre_dma_pool(m_bush_t bush
)
570 mp
= __m_calloc(&mp0
, sizeof(*mp
), "MPOOL");
572 bzero(mp
, sizeof(*mp
));
574 mp
->getp
= ___dma_getp
;
575 mp
->freep
= ___dma_freep
;
582 static void ___del_dma_pool(m_pool_s
*p
)
584 struct m_pool
**pp
= &mp0
.next
;
586 while (*pp
&& *pp
!= p
)
590 __m_free(&mp0
, p
, sizeof(*p
), "MPOOL");
594 static void *__m_calloc_dma(m_bush_t bush
, int size
, char *name
)
600 NCR_LOCK_DRIVER(flags
);
601 mp
= ___get_dma_pool(bush
);
603 mp
= ___cre_dma_pool(bush
);
605 m
= __m_calloc(mp
, size
, name
);
608 NCR_UNLOCK_DRIVER(flags
);
613 static void __m_free_dma(m_bush_t bush
, void *m
, int size
, char *name
)
618 NCR_LOCK_DRIVER(flags
);
619 mp
= ___get_dma_pool(bush
);
621 __m_free(mp
, m
, size
, name
);
624 NCR_UNLOCK_DRIVER(flags
);
627 static m_addr_t
__vtobus(m_bush_t bush
, void *m
)
631 int hc
= VTOB_HASH_CODE(m
);
633 m_addr_t a
= ((m_addr_t
) m
) & ~MEMO_CLUSTER_MASK
;
635 NCR_LOCK_DRIVER(flags
);
636 mp
= ___get_dma_pool(bush
);
639 while (vp
&& (m_addr_t
) vp
->vaddr
!= a
)
642 NCR_UNLOCK_DRIVER(flags
);
643 return vp
? vp
->baddr
+ (((m_addr_t
) m
) - a
) : 0;
646 #define _m_calloc_dma(np, s, n) __m_calloc_dma(np->dev, s, n)
647 #define _m_free_dma(np, p, s, n) __m_free_dma(np->dev, p, s, n)
648 #define m_calloc_dma(s, n) _m_calloc_dma(np, s, n)
649 #define m_free_dma(p, s, n) _m_free_dma(np, p, s, n)
650 #define _vtobus(np, p) __vtobus(np->dev, p)
651 #define vtobus(p) _vtobus(np, p)
654 * Deal with DMA mapping/unmapping.
657 /* To keep track of the dma mapping (sg/single) that has been set */
658 #define __data_mapped SCp.phase
659 #define __data_mapping SCp.have_data_in
661 static void __unmap_scsi_data(struct device
*dev
, Scsi_Cmnd
*cmd
)
663 enum dma_data_direction dma_dir
=
664 (enum dma_data_direction
)scsi_to_pci_dma_dir(cmd
->sc_data_direction
);
666 switch(cmd
->__data_mapped
) {
668 dma_unmap_sg(dev
, cmd
->buffer
, cmd
->use_sg
, dma_dir
);
671 dma_unmap_single(dev
, cmd
->__data_mapping
,
672 cmd
->request_bufflen
, dma_dir
);
675 cmd
->__data_mapped
= 0;
678 static u_long
__map_scsi_single_data(struct device
*dev
, Scsi_Cmnd
*cmd
)
681 enum dma_data_direction dma_dir
=
682 (enum dma_data_direction
)scsi_to_pci_dma_dir(cmd
->sc_data_direction
);
685 if (cmd
->request_bufflen
== 0)
688 mapping
= dma_map_single(dev
, cmd
->request_buffer
,
689 cmd
->request_bufflen
, dma_dir
);
690 cmd
->__data_mapped
= 1;
691 cmd
->__data_mapping
= mapping
;
696 static int __map_scsi_sg_data(struct device
*dev
, Scsi_Cmnd
*cmd
)
699 enum dma_data_direction dma_dir
=
700 (enum dma_data_direction
)scsi_to_pci_dma_dir(cmd
->sc_data_direction
);
702 if (cmd
->use_sg
== 0)
705 use_sg
= dma_map_sg(dev
, cmd
->buffer
, cmd
->use_sg
, dma_dir
);
706 cmd
->__data_mapped
= 2;
707 cmd
->__data_mapping
= use_sg
;
712 static void __sync_scsi_data_for_cpu(struct device
*dev
, Scsi_Cmnd
*cmd
)
714 enum dma_data_direction dma_dir
=
715 (enum dma_data_direction
)scsi_to_pci_dma_dir(cmd
->sc_data_direction
);
717 switch(cmd
->__data_mapped
) {
719 dma_sync_sg_for_cpu(dev
, cmd
->buffer
, cmd
->use_sg
, dma_dir
);
722 dma_sync_single_for_cpu(dev
, cmd
->__data_mapping
,
723 cmd
->request_bufflen
, dma_dir
);
728 static void __sync_scsi_data_for_device(struct device
*dev
, Scsi_Cmnd
*cmd
)
730 enum dma_data_direction dma_dir
=
731 (enum dma_data_direction
)scsi_to_pci_dma_dir(cmd
->sc_data_direction
);
733 switch(cmd
->__data_mapped
) {
735 dma_sync_sg_for_device(dev
, cmd
->buffer
, cmd
->use_sg
, dma_dir
);
738 dma_sync_single_for_device(dev
, cmd
->__data_mapping
,
739 cmd
->request_bufflen
, dma_dir
);
744 #define scsi_sg_dma_address(sc) sg_dma_address(sc)
745 #define scsi_sg_dma_len(sc) sg_dma_len(sc)
747 #define unmap_scsi_data(np, cmd) __unmap_scsi_data(np->dev, cmd)
748 #define map_scsi_single_data(np, cmd) __map_scsi_single_data(np->dev, cmd)
749 #define map_scsi_sg_data(np, cmd) __map_scsi_sg_data(np->dev, cmd)
750 #define sync_scsi_data_for_cpu(np, cmd) __sync_scsi_data_for_cpu(np->dev, cmd)
751 #define sync_scsi_data_for_device(np, cmd) __sync_scsi_data_for_device(np->dev, cmd)
753 #define scsi_data_direction(cmd) (cmd->sc_data_direction)
755 /*==========================================================
759 ** This structure is initialized from linux config
760 ** options. It can be overridden at boot-up by the boot
763 **==========================================================
765 static struct ncr_driver_setup
766 driver_setup
= SCSI_NCR_DRIVER_SETUP
;
768 #ifdef SCSI_NCR_BOOT_COMMAND_LINE_SUPPORT
769 static struct ncr_driver_setup
770 driver_safe_setup __initdata
= SCSI_NCR_DRIVER_SAFE_SETUP
;
773 #define initverbose (driver_setup.verbose)
774 #define bootverbose (np->verbose)
777 /*===================================================================
779 ** Utility routines that protperly return data through /proc FS.
781 **===================================================================
783 #ifdef SCSI_NCR_USER_INFO_SUPPORT
793 static void copy_mem_info(struct info_str
*info
, char *data
, int len
)
795 if (info
->pos
+ len
> info
->length
)
796 len
= info
->length
- info
->pos
;
798 if (info
->pos
+ len
< info
->offset
) {
802 if (info
->pos
< info
->offset
) {
803 data
+= (info
->offset
- info
->pos
);
804 len
-= (info
->offset
- info
->pos
);
808 memcpy(info
->buffer
+ info
->pos
, data
, len
);
813 static int copy_info(struct info_str
*info
, char *fmt
, ...)
820 len
= vsprintf(buf
, fmt
, args
);
823 copy_mem_info(info
, buf
, len
);
829 /*===================================================================
831 ** Driver setup from the boot command line
833 **===================================================================
843 #define OPT_MASTER_PARITY 2
844 #define OPT_SCSI_PARITY 3
845 #define OPT_DISCONNECTION 4
846 #define OPT_SPECIAL_FEATURES 5
847 #define OPT_UNUSED_1 6
848 #define OPT_FORCE_SYNC_NEGO 7
849 #define OPT_REVERSE_PROBE 8
850 #define OPT_DEFAULT_SYNC 9
851 #define OPT_VERBOSE 10
853 #define OPT_BURST_MAX 12
854 #define OPT_LED_PIN 13
855 #define OPT_MAX_WIDE 14
856 #define OPT_SETTLE_DELAY 15
857 #define OPT_DIFF_SUPPORT 16
859 #define OPT_PCI_FIX_UP 18
860 #define OPT_BUS_CHECK 19
861 #define OPT_OPTIMIZE 20
862 #define OPT_RECOVERY 21
863 #define OPT_SAFE_SETUP 22
864 #define OPT_USE_NVRAM 23
865 #define OPT_EXCLUDE 24
866 #define OPT_HOST_ID 25
868 #ifdef SCSI_NCR_IARB_SUPPORT
872 static char setup_token
[] __initdata
=
886 #ifdef SCSI_NCR_IARB_SUPPORT
889 ; /* DONNOT REMOVE THIS ';' */
897 static int __init
get_setup_token(char *p
)
899 char *cur
= setup_token
;
903 while (cur
!= NULL
&& (pc
= strchr(cur
, ':')) != NULL
) {
906 if (!strncmp(p
, cur
, pc
- cur
))
914 static int __init
sym53c8xx__setup(char *str
)
916 #ifdef SCSI_NCR_BOOT_COMMAND_LINE_SUPPORT
922 while (cur
!= NULL
&& (pc
= strchr(cur
, ':')) != NULL
) {
934 val
= (int) simple_strtoul(pv
, &pe
, 0);
936 switch (get_setup_token(cur
)) {
938 driver_setup
.default_tags
= val
;
939 if (pe
&& *pe
== '/') {
941 while (*pe
&& *pe
!= ARG_SEP
&&
942 i
< sizeof(driver_setup
.tag_ctrl
)-1) {
943 driver_setup
.tag_ctrl
[i
++] = *pe
++;
945 driver_setup
.tag_ctrl
[i
] = '\0';
948 case OPT_MASTER_PARITY
:
949 driver_setup
.master_parity
= val
;
951 case OPT_SCSI_PARITY
:
952 driver_setup
.scsi_parity
= val
;
954 case OPT_DISCONNECTION
:
955 driver_setup
.disconnection
= val
;
957 case OPT_SPECIAL_FEATURES
:
958 driver_setup
.special_features
= val
;
960 case OPT_FORCE_SYNC_NEGO
:
961 driver_setup
.force_sync_nego
= val
;
963 case OPT_REVERSE_PROBE
:
964 driver_setup
.reverse_probe
= val
;
966 case OPT_DEFAULT_SYNC
:
967 driver_setup
.default_sync
= val
;
970 driver_setup
.verbose
= val
;
973 driver_setup
.debug
= val
;
976 driver_setup
.burst_max
= val
;
979 driver_setup
.led_pin
= val
;
982 driver_setup
.max_wide
= val
? 1:0;
984 case OPT_SETTLE_DELAY
:
985 driver_setup
.settle_delay
= val
;
987 case OPT_DIFF_SUPPORT
:
988 driver_setup
.diff_support
= val
;
991 driver_setup
.irqm
= val
;
994 driver_setup
.pci_fix_up
= val
;
997 driver_setup
.bus_check
= val
;
1000 driver_setup
.optimize
= val
;
1003 driver_setup
.recovery
= val
;
1006 driver_setup
.use_nvram
= val
;
1008 case OPT_SAFE_SETUP
:
1009 memcpy(&driver_setup
, &driver_safe_setup
,
1010 sizeof(driver_setup
));
1013 if (xi
< SCSI_NCR_MAX_EXCLUDES
)
1014 driver_setup
.excludes
[xi
++] = val
;
1017 driver_setup
.host_id
= val
;
1019 #ifdef SCSI_NCR_IARB_SUPPORT
1021 driver_setup
.iarb
= val
;
1025 printk("sym53c8xx_setup: unexpected boot option '%.*s' ignored\n", (int)(pc
-cur
+1), cur
);
1029 if ((cur
= strchr(cur
, ARG_SEP
)) != NULL
)
1032 #endif /* SCSI_NCR_BOOT_COMMAND_LINE_SUPPORT */
1036 /*===================================================================
1038 ** Get device queue depth from boot command line.
1040 **===================================================================
1042 #define DEF_DEPTH (driver_setup.default_tags)
1043 #define ALL_TARGETS -2
1044 #define NO_TARGET -1
1048 static int device_queue_depth(int unit
, int target
, int lun
)
1051 char *p
= driver_setup
.tag_ctrl
;
1057 while ((c
= *p
++) != 0) {
1058 v
= simple_strtoul(p
, &ep
, 0);
1067 t
= (target
== v
) ? v
: NO_TARGET
;
1072 u
= (lun
== v
) ? v
: NO_LUN
;
1076 (t
== ALL_TARGETS
|| t
== target
) &&
1077 (u
== ALL_LUNS
|| u
== lun
))