sym53c8xx_comm.h 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792
  1. /******************************************************************************
  2. ** High Performance device driver for the Symbios 53C896 controller.
  3. **
  4. ** Copyright (C) 1998-2001 Gerard Roudier <groudier@free.fr>
  5. **
  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.
  9. **
  10. ** This driver is based on the Linux port of the FreeBSD ncr driver.
  11. **
  12. ** Copyright (C) 1994 Wolfgang Stanglmeier
  13. **
  14. **-----------------------------------------------------------------------------
  15. **
  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.
  20. **
  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.
  25. **
  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.
  29. **
  30. **-----------------------------------------------------------------------------
  31. **
  32. ** The Linux port of the FreeBSD ncr driver has been achieved in
  33. ** november 1995 by:
  34. **
  35. ** Gerard Roudier <groudier@free.fr>
  36. **
  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
  40. ** version.
  41. **
  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>
  45. **
  46. **-----------------------------------------------------------------------------
  47. **
  48. ** Major contributions:
  49. ** --------------------
  50. **
  51. ** NVRAM detection and reading.
  52. ** Copyright (C) 1997 Richard Waltham <dormouse@farsrobt.demon.co.uk>
  53. **
  54. *******************************************************************************
  55. */
  56. /*==========================================================
  57. **
  58. ** Debugging tags
  59. **
  60. **==========================================================
  61. */
  62. #define DEBUG_ALLOC (0x0001)
  63. #define DEBUG_PHASE (0x0002)
  64. #define DEBUG_QUEUE (0x0008)
  65. #define DEBUG_RESULT (0x0010)
  66. #define DEBUG_POINTER (0x0020)
  67. #define DEBUG_SCRIPT (0x0040)
  68. #define DEBUG_TINY (0x0080)
  69. #define DEBUG_TIMING (0x0100)
  70. #define DEBUG_NEGO (0x0200)
  71. #define DEBUG_TAGS (0x0400)
  72. #define DEBUG_SCATTER (0x0800)
  73. #define DEBUG_IC (0x1000)
  74. /*
  75. ** Enable/Disable debug messages.
  76. ** Can be changed at runtime too.
  77. */
  78. #ifdef SCSI_NCR_DEBUG_INFO_SUPPORT
  79. static int ncr_debug = SCSI_NCR_DEBUG_FLAGS;
  80. #define DEBUG_FLAGS ncr_debug
  81. #else
  82. #define DEBUG_FLAGS SCSI_NCR_DEBUG_FLAGS
  83. #endif
  84. static inline struct list_head *ncr_list_pop(struct list_head *head)
  85. {
  86. if (!list_empty(head)) {
  87. struct list_head *elem = head->next;
  88. list_del(elem);
  89. return elem;
  90. }
  91. return NULL;
  92. }
  93. #ifdef __sparc__
  94. #include <asm/irq.h>
  95. #endif
  96. /*==========================================================
  97. **
  98. ** Simple power of two buddy-like allocator.
  99. **
  100. ** This simple code is not intended to be fast, but to
  101. ** provide power of 2 aligned memory allocations.
  102. ** Since the SCRIPTS processor only supplies 8 bit
  103. ** arithmetic, this allocator allows simple and fast
  104. ** address calculations from the SCRIPTS code.
  105. ** In addition, cache line alignment is guaranteed for
  106. ** power of 2 cache line size.
  107. ** Enhanced in linux-2.3.44 to provide a memory pool
  108. ** per pcidev to support dynamic dma mapping. (I would
  109. ** have preferred a real bus astraction, btw).
  110. **
  111. **==========================================================
  112. */
  113. #define MEMO_SHIFT 4 /* 16 bytes minimum memory chunk */
  114. #if PAGE_SIZE >= 8192
  115. #define MEMO_PAGE_ORDER 0 /* 1 PAGE maximum */
  116. #else
  117. #define MEMO_PAGE_ORDER 1 /* 2 PAGES maximum */
  118. #endif
  119. #define MEMO_FREE_UNUSED /* Free unused pages immediately */
  120. #define MEMO_WARN 1
  121. #define MEMO_GFP_FLAGS GFP_ATOMIC
  122. #define MEMO_CLUSTER_SHIFT (PAGE_SHIFT+MEMO_PAGE_ORDER)
  123. #define MEMO_CLUSTER_SIZE (1UL << MEMO_CLUSTER_SHIFT)
  124. #define MEMO_CLUSTER_MASK (MEMO_CLUSTER_SIZE-1)
  125. typedef u_long m_addr_t; /* Enough bits to bit-hack addresses */
  126. typedef struct device *m_bush_t; /* Something that addresses DMAable */
  127. typedef struct m_link { /* Link between free memory chunks */
  128. struct m_link *next;
  129. } m_link_s;
  130. typedef struct m_vtob { /* Virtual to Bus address translation */
  131. struct m_vtob *next;
  132. m_addr_t vaddr;
  133. m_addr_t baddr;
  134. } m_vtob_s;
  135. #define VTOB_HASH_SHIFT 5
  136. #define VTOB_HASH_SIZE (1UL << VTOB_HASH_SHIFT)
  137. #define VTOB_HASH_MASK (VTOB_HASH_SIZE-1)
  138. #define VTOB_HASH_CODE(m) \
  139. ((((m_addr_t) (m)) >> MEMO_CLUSTER_SHIFT) & VTOB_HASH_MASK)
  140. typedef struct m_pool { /* Memory pool of a given kind */
  141. m_bush_t bush;
  142. m_addr_t (*getp)(struct m_pool *);
  143. void (*freep)(struct m_pool *, m_addr_t);
  144. int nump;
  145. m_vtob_s *(vtob[VTOB_HASH_SIZE]);
  146. struct m_pool *next;
  147. struct m_link h[PAGE_SHIFT-MEMO_SHIFT+MEMO_PAGE_ORDER+1];
  148. } m_pool_s;
  149. static void *___m_alloc(m_pool_s *mp, int size)
  150. {
  151. int i = 0;
  152. int s = (1 << MEMO_SHIFT);
  153. int j;
  154. m_addr_t a;
  155. m_link_s *h = mp->h;
  156. if (size > (PAGE_SIZE << MEMO_PAGE_ORDER))
  157. return NULL;
  158. while (size > s) {
  159. s <<= 1;
  160. ++i;
  161. }
  162. j = i;
  163. while (!h[j].next) {
  164. if (s == (PAGE_SIZE << MEMO_PAGE_ORDER)) {
  165. h[j].next = (m_link_s *)mp->getp(mp);
  166. if (h[j].next)
  167. h[j].next->next = NULL;
  168. break;
  169. }
  170. ++j;
  171. s <<= 1;
  172. }
  173. a = (m_addr_t) h[j].next;
  174. if (a) {
  175. h[j].next = h[j].next->next;
  176. while (j > i) {
  177. j -= 1;
  178. s >>= 1;
  179. h[j].next = (m_link_s *) (a+s);
  180. h[j].next->next = NULL;
  181. }
  182. }
  183. #ifdef DEBUG
  184. printk("___m_alloc(%d) = %p\n", size, (void *) a);
  185. #endif
  186. return (void *) a;
  187. }
  188. static void ___m_free(m_pool_s *mp, void *ptr, int size)
  189. {
  190. int i = 0;
  191. int s = (1 << MEMO_SHIFT);
  192. m_link_s *q;
  193. m_addr_t a, b;
  194. m_link_s *h = mp->h;
  195. #ifdef DEBUG
  196. printk("___m_free(%p, %d)\n", ptr, size);
  197. #endif
  198. if (size > (PAGE_SIZE << MEMO_PAGE_ORDER))
  199. return;
  200. while (size > s) {
  201. s <<= 1;
  202. ++i;
  203. }
  204. a = (m_addr_t) ptr;
  205. while (1) {
  206. #ifdef MEMO_FREE_UNUSED
  207. if (s == (PAGE_SIZE << MEMO_PAGE_ORDER)) {
  208. mp->freep(mp, a);
  209. break;
  210. }
  211. #endif
  212. b = a ^ s;
  213. q = &h[i];
  214. while (q->next && q->next != (m_link_s *) b) {
  215. q = q->next;
  216. }
  217. if (!q->next) {
  218. ((m_link_s *) a)->next = h[i].next;
  219. h[i].next = (m_link_s *) a;
  220. break;
  221. }
  222. q->next = q->next->next;
  223. a = a & b;
  224. s <<= 1;
  225. ++i;
  226. }
  227. }
  228. static DEFINE_SPINLOCK(ncr53c8xx_lock);
  229. static void *__m_calloc2(m_pool_s *mp, int size, char *name, int uflags)
  230. {
  231. void *p;
  232. p = ___m_alloc(mp, size);
  233. if (DEBUG_FLAGS & DEBUG_ALLOC)
  234. printk ("new %-10s[%4d] @%p.\n", name, size, p);
  235. if (p)
  236. memset(p, 0, size);
  237. else if (uflags & MEMO_WARN)
  238. printk (NAME53C8XX ": failed to allocate %s[%d]\n", name, size);
  239. return p;
  240. }
  241. #define __m_calloc(mp, s, n) __m_calloc2(mp, s, n, MEMO_WARN)
  242. static void __m_free(m_pool_s *mp, void *ptr, int size, char *name)
  243. {
  244. if (DEBUG_FLAGS & DEBUG_ALLOC)
  245. printk ("freeing %-10s[%4d] @%p.\n", name, size, ptr);
  246. ___m_free(mp, ptr, size);
  247. }
  248. /*
  249. * With pci bus iommu support, we use a default pool of unmapped memory
  250. * for memory we donnot need to DMA from/to and one pool per pcidev for
  251. * memory accessed by the PCI chip. `mp0' is the default not DMAable pool.
  252. */
  253. static m_addr_t ___mp0_getp(m_pool_s *mp)
  254. {
  255. m_addr_t m = __get_free_pages(MEMO_GFP_FLAGS, MEMO_PAGE_ORDER);
  256. if (m)
  257. ++mp->nump;
  258. return m;
  259. }
  260. static void ___mp0_freep(m_pool_s *mp, m_addr_t m)
  261. {
  262. free_pages(m, MEMO_PAGE_ORDER);
  263. --mp->nump;
  264. }
  265. static m_pool_s mp0 = {NULL, ___mp0_getp, ___mp0_freep};
  266. /*
  267. * DMAable pools.
  268. */
  269. /*
  270. * With pci bus iommu support, we maintain one pool per pcidev and a
  271. * hashed reverse table for virtual to bus physical address translations.
  272. */
  273. static m_addr_t ___dma_getp(m_pool_s *mp)
  274. {
  275. m_addr_t vp;
  276. m_vtob_s *vbp;
  277. vbp = __m_calloc(&mp0, sizeof(*vbp), "VTOB");
  278. if (vbp) {
  279. dma_addr_t daddr;
  280. vp = (m_addr_t) dma_alloc_coherent(mp->bush,
  281. PAGE_SIZE<<MEMO_PAGE_ORDER,
  282. &daddr, GFP_ATOMIC);
  283. if (vp) {
  284. int hc = VTOB_HASH_CODE(vp);
  285. vbp->vaddr = vp;
  286. vbp->baddr = daddr;
  287. vbp->next = mp->vtob[hc];
  288. mp->vtob[hc] = vbp;
  289. ++mp->nump;
  290. return vp;
  291. }
  292. }
  293. if (vbp)
  294. __m_free(&mp0, vbp, sizeof(*vbp), "VTOB");
  295. return 0;
  296. }
  297. static void ___dma_freep(m_pool_s *mp, m_addr_t m)
  298. {
  299. m_vtob_s **vbpp, *vbp;
  300. int hc = VTOB_HASH_CODE(m);
  301. vbpp = &mp->vtob[hc];
  302. while (*vbpp && (*vbpp)->vaddr != m)
  303. vbpp = &(*vbpp)->next;
  304. if (*vbpp) {
  305. vbp = *vbpp;
  306. *vbpp = (*vbpp)->next;
  307. dma_free_coherent(mp->bush, PAGE_SIZE<<MEMO_PAGE_ORDER,
  308. (void *)vbp->vaddr, (dma_addr_t)vbp->baddr);
  309. __m_free(&mp0, vbp, sizeof(*vbp), "VTOB");
  310. --mp->nump;
  311. }
  312. }
  313. static inline m_pool_s *___get_dma_pool(m_bush_t bush)
  314. {
  315. m_pool_s *mp;
  316. for (mp = mp0.next; mp && mp->bush != bush; mp = mp->next);
  317. return mp;
  318. }
  319. static m_pool_s *___cre_dma_pool(m_bush_t bush)
  320. {
  321. m_pool_s *mp;
  322. mp = __m_calloc(&mp0, sizeof(*mp), "MPOOL");
  323. if (mp) {
  324. memset(mp, 0, sizeof(*mp));
  325. mp->bush = bush;
  326. mp->getp = ___dma_getp;
  327. mp->freep = ___dma_freep;
  328. mp->next = mp0.next;
  329. mp0.next = mp;
  330. }
  331. return mp;
  332. }
  333. static void ___del_dma_pool(m_pool_s *p)
  334. {
  335. struct m_pool **pp = &mp0.next;
  336. while (*pp && *pp != p)
  337. pp = &(*pp)->next;
  338. if (*pp) {
  339. *pp = (*pp)->next;
  340. __m_free(&mp0, p, sizeof(*p), "MPOOL");
  341. }
  342. }
  343. static void *__m_calloc_dma(m_bush_t bush, int size, char *name)
  344. {
  345. u_long flags;
  346. struct m_pool *mp;
  347. void *m = NULL;
  348. spin_lock_irqsave(&ncr53c8xx_lock, flags);
  349. mp = ___get_dma_pool(bush);
  350. if (!mp)
  351. mp = ___cre_dma_pool(bush);
  352. if (mp)
  353. m = __m_calloc(mp, size, name);
  354. if (mp && !mp->nump)
  355. ___del_dma_pool(mp);
  356. spin_unlock_irqrestore(&ncr53c8xx_lock, flags);
  357. return m;
  358. }
  359. static void __m_free_dma(m_bush_t bush, void *m, int size, char *name)
  360. {
  361. u_long flags;
  362. struct m_pool *mp;
  363. spin_lock_irqsave(&ncr53c8xx_lock, flags);
  364. mp = ___get_dma_pool(bush);
  365. if (mp)
  366. __m_free(mp, m, size, name);
  367. if (mp && !mp->nump)
  368. ___del_dma_pool(mp);
  369. spin_unlock_irqrestore(&ncr53c8xx_lock, flags);
  370. }
  371. static m_addr_t __vtobus(m_bush_t bush, void *m)
  372. {
  373. u_long flags;
  374. m_pool_s *mp;
  375. int hc = VTOB_HASH_CODE(m);
  376. m_vtob_s *vp = NULL;
  377. m_addr_t a = ((m_addr_t) m) & ~MEMO_CLUSTER_MASK;
  378. spin_lock_irqsave(&ncr53c8xx_lock, flags);
  379. mp = ___get_dma_pool(bush);
  380. if (mp) {
  381. vp = mp->vtob[hc];
  382. while (vp && (m_addr_t) vp->vaddr != a)
  383. vp = vp->next;
  384. }
  385. spin_unlock_irqrestore(&ncr53c8xx_lock, flags);
  386. return vp ? vp->baddr + (((m_addr_t) m) - a) : 0;
  387. }
  388. #define _m_calloc_dma(np, s, n) __m_calloc_dma(np->dev, s, n)
  389. #define _m_free_dma(np, p, s, n) __m_free_dma(np->dev, p, s, n)
  390. #define m_calloc_dma(s, n) _m_calloc_dma(np, s, n)
  391. #define m_free_dma(p, s, n) _m_free_dma(np, p, s, n)
  392. #define _vtobus(np, p) __vtobus(np->dev, p)
  393. #define vtobus(p) _vtobus(np, p)
  394. /*
  395. * Deal with DMA mapping/unmapping.
  396. */
  397. /* To keep track of the dma mapping (sg/single) that has been set */
  398. #define __data_mapped SCp.phase
  399. #define __data_mapping SCp.have_data_in
  400. static void __unmap_scsi_data(struct device *dev, struct scsi_cmnd *cmd)
  401. {
  402. switch(cmd->__data_mapped) {
  403. case 2:
  404. dma_unmap_sg(dev, cmd->buffer, cmd->use_sg,
  405. cmd->sc_data_direction);
  406. break;
  407. case 1:
  408. dma_unmap_single(dev, cmd->__data_mapping,
  409. cmd->request_bufflen,
  410. cmd->sc_data_direction);
  411. break;
  412. }
  413. cmd->__data_mapped = 0;
  414. }
  415. static u_long __map_scsi_single_data(struct device *dev, struct scsi_cmnd *cmd)
  416. {
  417. dma_addr_t mapping;
  418. if (cmd->request_bufflen == 0)
  419. return 0;
  420. mapping = dma_map_single(dev, cmd->request_buffer,
  421. cmd->request_bufflen,
  422. cmd->sc_data_direction);
  423. cmd->__data_mapped = 1;
  424. cmd->__data_mapping = mapping;
  425. return mapping;
  426. }
  427. static int __map_scsi_sg_data(struct device *dev, struct scsi_cmnd *cmd)
  428. {
  429. int use_sg;
  430. if (cmd->use_sg == 0)
  431. return 0;
  432. use_sg = dma_map_sg(dev, cmd->buffer, cmd->use_sg,
  433. cmd->sc_data_direction);
  434. cmd->__data_mapped = 2;
  435. cmd->__data_mapping = use_sg;
  436. return use_sg;
  437. }
  438. #define unmap_scsi_data(np, cmd) __unmap_scsi_data(np->dev, cmd)
  439. #define map_scsi_single_data(np, cmd) __map_scsi_single_data(np->dev, cmd)
  440. #define map_scsi_sg_data(np, cmd) __map_scsi_sg_data(np->dev, cmd)
  441. /*==========================================================
  442. **
  443. ** Driver setup.
  444. **
  445. ** This structure is initialized from linux config
  446. ** options. It can be overridden at boot-up by the boot
  447. ** command line.
  448. **
  449. **==========================================================
  450. */
  451. static struct ncr_driver_setup
  452. driver_setup = SCSI_NCR_DRIVER_SETUP;
  453. #ifdef SCSI_NCR_BOOT_COMMAND_LINE_SUPPORT
  454. static struct ncr_driver_setup
  455. driver_safe_setup __initdata = SCSI_NCR_DRIVER_SAFE_SETUP;
  456. #endif
  457. #define initverbose (driver_setup.verbose)
  458. #define bootverbose (np->verbose)
  459. /*===================================================================
  460. **
  461. ** Driver setup from the boot command line
  462. **
  463. **===================================================================
  464. */
  465. #ifdef MODULE
  466. #define ARG_SEP ' '
  467. #else
  468. #define ARG_SEP ','
  469. #endif
  470. #define OPT_TAGS 1
  471. #define OPT_MASTER_PARITY 2
  472. #define OPT_SCSI_PARITY 3
  473. #define OPT_DISCONNECTION 4
  474. #define OPT_SPECIAL_FEATURES 5
  475. #define OPT_UNUSED_1 6
  476. #define OPT_FORCE_SYNC_NEGO 7
  477. #define OPT_REVERSE_PROBE 8
  478. #define OPT_DEFAULT_SYNC 9
  479. #define OPT_VERBOSE 10
  480. #define OPT_DEBUG 11
  481. #define OPT_BURST_MAX 12
  482. #define OPT_LED_PIN 13
  483. #define OPT_MAX_WIDE 14
  484. #define OPT_SETTLE_DELAY 15
  485. #define OPT_DIFF_SUPPORT 16
  486. #define OPT_IRQM 17
  487. #define OPT_PCI_FIX_UP 18
  488. #define OPT_BUS_CHECK 19
  489. #define OPT_OPTIMIZE 20
  490. #define OPT_RECOVERY 21
  491. #define OPT_SAFE_SETUP 22
  492. #define OPT_USE_NVRAM 23
  493. #define OPT_EXCLUDE 24
  494. #define OPT_HOST_ID 25
  495. #ifdef SCSI_NCR_IARB_SUPPORT
  496. #define OPT_IARB 26
  497. #endif
  498. static char setup_token[] __initdata =
  499. "tags:" "mpar:"
  500. "spar:" "disc:"
  501. "specf:" "ultra:"
  502. "fsn:" "revprob:"
  503. "sync:" "verb:"
  504. "debug:" "burst:"
  505. "led:" "wide:"
  506. "settle:" "diff:"
  507. "irqm:" "pcifix:"
  508. "buschk:" "optim:"
  509. "recovery:"
  510. "safe:" "nvram:"
  511. "excl:" "hostid:"
  512. #ifdef SCSI_NCR_IARB_SUPPORT
  513. "iarb:"
  514. #endif
  515. ; /* DONNOT REMOVE THIS ';' */
  516. #ifdef MODULE
  517. #define ARG_SEP ' '
  518. #else
  519. #define ARG_SEP ','
  520. #endif
  521. static int __init get_setup_token(char *p)
  522. {
  523. char *cur = setup_token;
  524. char *pc;
  525. int i = 0;
  526. while (cur != NULL && (pc = strchr(cur, ':')) != NULL) {
  527. ++pc;
  528. ++i;
  529. if (!strncmp(p, cur, pc - cur))
  530. return i;
  531. cur = pc;
  532. }
  533. return 0;
  534. }
  535. static int __init sym53c8xx__setup(char *str)
  536. {
  537. #ifdef SCSI_NCR_BOOT_COMMAND_LINE_SUPPORT
  538. char *cur = str;
  539. char *pc, *pv;
  540. int i, val, c;
  541. int xi = 0;
  542. while (cur != NULL && (pc = strchr(cur, ':')) != NULL) {
  543. char *pe;
  544. val = 0;
  545. pv = pc;
  546. c = *++pv;
  547. if (c == 'n')
  548. val = 0;
  549. else if (c == 'y')
  550. val = 1;
  551. else
  552. val = (int) simple_strtoul(pv, &pe, 0);
  553. switch (get_setup_token(cur)) {
  554. case OPT_TAGS:
  555. driver_setup.default_tags = val;
  556. if (pe && *pe == '/') {
  557. i = 0;
  558. while (*pe && *pe != ARG_SEP &&
  559. i < sizeof(driver_setup.tag_ctrl)-1) {
  560. driver_setup.tag_ctrl[i++] = *pe++;
  561. }
  562. driver_setup.tag_ctrl[i] = '\0';
  563. }
  564. break;
  565. case OPT_MASTER_PARITY:
  566. driver_setup.master_parity = val;
  567. break;
  568. case OPT_SCSI_PARITY:
  569. driver_setup.scsi_parity = val;
  570. break;
  571. case OPT_DISCONNECTION:
  572. driver_setup.disconnection = val;
  573. break;
  574. case OPT_SPECIAL_FEATURES:
  575. driver_setup.special_features = val;
  576. break;
  577. case OPT_FORCE_SYNC_NEGO:
  578. driver_setup.force_sync_nego = val;
  579. break;
  580. case OPT_REVERSE_PROBE:
  581. driver_setup.reverse_probe = val;
  582. break;
  583. case OPT_DEFAULT_SYNC:
  584. driver_setup.default_sync = val;
  585. break;
  586. case OPT_VERBOSE:
  587. driver_setup.verbose = val;
  588. break;
  589. case OPT_DEBUG:
  590. driver_setup.debug = val;
  591. break;
  592. case OPT_BURST_MAX:
  593. driver_setup.burst_max = val;
  594. break;
  595. case OPT_LED_PIN:
  596. driver_setup.led_pin = val;
  597. break;
  598. case OPT_MAX_WIDE:
  599. driver_setup.max_wide = val? 1:0;
  600. break;
  601. case OPT_SETTLE_DELAY:
  602. driver_setup.settle_delay = val;
  603. break;
  604. case OPT_DIFF_SUPPORT:
  605. driver_setup.diff_support = val;
  606. break;
  607. case OPT_IRQM:
  608. driver_setup.irqm = val;
  609. break;
  610. case OPT_PCI_FIX_UP:
  611. driver_setup.pci_fix_up = val;
  612. break;
  613. case OPT_BUS_CHECK:
  614. driver_setup.bus_check = val;
  615. break;
  616. case OPT_OPTIMIZE:
  617. driver_setup.optimize = val;
  618. break;
  619. case OPT_RECOVERY:
  620. driver_setup.recovery = val;
  621. break;
  622. case OPT_USE_NVRAM:
  623. driver_setup.use_nvram = val;
  624. break;
  625. case OPT_SAFE_SETUP:
  626. memcpy(&driver_setup, &driver_safe_setup,
  627. sizeof(driver_setup));
  628. break;
  629. case OPT_EXCLUDE:
  630. if (xi < SCSI_NCR_MAX_EXCLUDES)
  631. driver_setup.excludes[xi++] = val;
  632. break;
  633. case OPT_HOST_ID:
  634. driver_setup.host_id = val;
  635. break;
  636. #ifdef SCSI_NCR_IARB_SUPPORT
  637. case OPT_IARB:
  638. driver_setup.iarb = val;
  639. break;
  640. #endif
  641. default:
  642. printk("sym53c8xx_setup: unexpected boot option '%.*s' ignored\n", (int)(pc-cur+1), cur);
  643. break;
  644. }
  645. if ((cur = strchr(cur, ARG_SEP)) != NULL)
  646. ++cur;
  647. }
  648. #endif /* SCSI_NCR_BOOT_COMMAND_LINE_SUPPORT */
  649. return 1;
  650. }
  651. /*===================================================================
  652. **
  653. ** Get device queue depth from boot command line.
  654. **
  655. **===================================================================
  656. */
  657. #define DEF_DEPTH (driver_setup.default_tags)
  658. #define ALL_TARGETS -2
  659. #define NO_TARGET -1
  660. #define ALL_LUNS -2
  661. #define NO_LUN -1
  662. static int device_queue_depth(int unit, int target, int lun)
  663. {
  664. int c, h, t, u, v;
  665. char *p = driver_setup.tag_ctrl;
  666. char *ep;
  667. h = -1;
  668. t = NO_TARGET;
  669. u = NO_LUN;
  670. while ((c = *p++) != 0) {
  671. v = simple_strtoul(p, &ep, 0);
  672. switch(c) {
  673. case '/':
  674. ++h;
  675. t = ALL_TARGETS;
  676. u = ALL_LUNS;
  677. break;
  678. case 't':
  679. if (t != target)
  680. t = (target == v) ? v : NO_TARGET;
  681. u = ALL_LUNS;
  682. break;
  683. case 'u':
  684. if (u != lun)
  685. u = (lun == v) ? v : NO_LUN;
  686. break;
  687. case 'q':
  688. if (h == unit &&
  689. (t == ALL_TARGETS || t == target) &&
  690. (u == ALL_LUNS || u == lun))
  691. return v;
  692. break;
  693. case '-':
  694. t = ALL_TARGETS;
  695. u = ALL_LUNS;
  696. break;
  697. default:
  698. break;
  699. }
  700. p = ep;
  701. }
  702. return DEF_DEPTH;
  703. }