fdomain.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607
  1. // SPDX-License-Identifier: GPL-2.0
  2. /*
  3. * Driver for Future Domain TMC-16x0 and TMC-3260 SCSI host adapters
  4. * Copyright 2019 Ondrej Zary
  5. *
  6. * Original driver by
  7. * Rickard E. Faith, [email protected]
  8. *
  9. * Future Domain BIOS versions supported for autodetect:
  10. * 2.0, 3.0, 3.2, 3.4 (1.0), 3.5 (2.0), 3.6, 3.61
  11. * Chips supported:
  12. * TMC-1800, TMC-18C50, TMC-18C30, TMC-36C70
  13. * Boards supported:
  14. * Future Domain TMC-1650, TMC-1660, TMC-1670, TMC-1680, TMC-1610M/MER/MEX
  15. * Future Domain TMC-3260 (PCI)
  16. * Quantum ISA-200S, ISA-250MG
  17. * Adaptec AHA-2920A (PCI) [BUT *NOT* AHA-2920C -- use aic7xxx instead]
  18. * IBM ?
  19. *
  20. * NOTE:
  21. *
  22. * The Adaptec AHA-2920C has an Adaptec AIC-7850 chip on it.
  23. * Use the aic7xxx driver for this board.
  24. *
  25. * The Adaptec AHA-2920A has a Future Domain chip on it, so this is the right
  26. * driver for that card. Unfortunately, the boxes will probably just say
  27. * "2920", so you'll have to look on the card for a Future Domain logo, or a
  28. * letter after the 2920.
  29. *
  30. * If you have a TMC-8xx or TMC-9xx board, then this is not the driver for
  31. * your board.
  32. *
  33. * DESCRIPTION:
  34. *
  35. * This is the Linux low-level SCSI driver for Future Domain TMC-1660/1680
  36. * TMC-1650/1670, and TMC-3260 SCSI host adapters. The 1650 and 1670 have a
  37. * 25-pin external connector, whereas the 1660 and 1680 have a SCSI-2 50-pin
  38. * high-density external connector. The 1670 and 1680 have floppy disk
  39. * controllers built in. The TMC-3260 is a PCI bus card.
  40. *
  41. * Future Domain's older boards are based on the TMC-1800 chip, and this
  42. * driver was originally written for a TMC-1680 board with the TMC-1800 chip.
  43. * More recently, boards are being produced with the TMC-18C50 and TMC-18C30
  44. * chips.
  45. *
  46. * Please note that the drive ordering that Future Domain implemented in BIOS
  47. * versions 3.4 and 3.5 is the opposite of the order (currently) used by the
  48. * rest of the SCSI industry.
  49. *
  50. *
  51. * REFERENCES USED:
  52. *
  53. * "TMC-1800 SCSI Chip Specification (FDC-1800T)", Future Domain Corporation,
  54. * 1990.
  55. *
  56. * "Technical Reference Manual: 18C50 SCSI Host Adapter Chip", Future Domain
  57. * Corporation, January 1992.
  58. *
  59. * "LXT SCSI Products: Specifications and OEM Technical Manual (Revision
  60. * B/September 1991)", Maxtor Corporation, 1991.
  61. *
  62. * "7213S product Manual (Revision P3)", Maxtor Corporation, 1992.
  63. *
  64. * "Draft Proposed American National Standard: Small Computer System
  65. * Interface - 2 (SCSI-2)", Global Engineering Documents. (X3T9.2/86-109,
  66. * revision 10h, October 17, 1991)
  67. *
  68. * Private communications, Drew Eckhardt ([email protected]) and Eric
  69. * Youngdale ([email protected]), 1992.
  70. *
  71. * Private communication, Tuong Le (Future Domain Engineering department),
  72. * 1994. (Disk geometry computations for Future Domain BIOS version 3.4, and
  73. * TMC-18C30 detection.)
  74. *
  75. * Hogan, Thom. The Programmer's PC Sourcebook. Microsoft Press, 1988. Page
  76. * 60 (2.39: Disk Partition Table Layout).
  77. *
  78. * "18C30 Technical Reference Manual", Future Domain Corporation, 1993, page
  79. * 6-1.
  80. */
  81. #include <linux/module.h>
  82. #include <linux/interrupt.h>
  83. #include <linux/delay.h>
  84. #include <linux/pci.h>
  85. #include <linux/workqueue.h>
  86. #include <scsi/scsicam.h>
  87. #include <scsi/scsi_cmnd.h>
  88. #include <scsi/scsi_device.h>
  89. #include <scsi/scsi_host.h>
  90. #include "fdomain.h"
  91. /*
  92. * FIFO_COUNT: The host adapter has an 8K cache (host adapters based on the
  93. * 18C30 chip have a 2k cache). When this many 512 byte blocks are filled by
  94. * the SCSI device, an interrupt will be raised. Therefore, this could be as
  95. * low as 0, or as high as 16. Note, however, that values which are too high
  96. * or too low seem to prevent any interrupts from occurring, and thereby lock
  97. * up the machine.
  98. */
  99. #define FIFO_COUNT 2 /* Number of 512 byte blocks before INTR */
  100. #define PARITY_MASK ACTL_PAREN /* Parity enabled, 0 = disabled */
  101. enum chip_type {
  102. unknown = 0x00,
  103. tmc1800 = 0x01,
  104. tmc18c50 = 0x02,
  105. tmc18c30 = 0x03,
  106. };
  107. struct fdomain {
  108. int base;
  109. struct scsi_cmnd *cur_cmd;
  110. enum chip_type chip;
  111. struct work_struct work;
  112. };
  113. static struct scsi_pointer *fdomain_scsi_pointer(struct scsi_cmnd *cmd)
  114. {
  115. return scsi_cmd_priv(cmd);
  116. }
  117. static inline void fdomain_make_bus_idle(struct fdomain *fd)
  118. {
  119. outb(0, fd->base + REG_BCTL);
  120. outb(0, fd->base + REG_MCTL);
  121. if (fd->chip == tmc18c50 || fd->chip == tmc18c30)
  122. /* Clear forced intr. */
  123. outb(ACTL_RESET | ACTL_CLRFIRQ | PARITY_MASK,
  124. fd->base + REG_ACTL);
  125. else
  126. outb(ACTL_RESET | PARITY_MASK, fd->base + REG_ACTL);
  127. }
  128. static enum chip_type fdomain_identify(int port)
  129. {
  130. u16 id = inb(port + REG_ID_LSB) | inb(port + REG_ID_MSB) << 8;
  131. switch (id) {
  132. case 0x6127:
  133. return tmc1800;
  134. case 0x60e9: /* 18c50 or 18c30 */
  135. break;
  136. default:
  137. return unknown;
  138. }
  139. /* Try to toggle 32-bit mode. This only works on an 18c30 chip. */
  140. outb(CFG2_32BIT, port + REG_CFG2);
  141. if ((inb(port + REG_CFG2) & CFG2_32BIT)) {
  142. outb(0, port + REG_CFG2);
  143. if ((inb(port + REG_CFG2) & CFG2_32BIT) == 0)
  144. return tmc18c30;
  145. }
  146. /* If that failed, we are an 18c50. */
  147. return tmc18c50;
  148. }
  149. static int fdomain_test_loopback(int base)
  150. {
  151. int i;
  152. for (i = 0; i < 255; i++) {
  153. outb(i, base + REG_LOOPBACK);
  154. if (inb(base + REG_LOOPBACK) != i)
  155. return 1;
  156. }
  157. return 0;
  158. }
  159. static void fdomain_reset(int base)
  160. {
  161. outb(BCTL_RST, base + REG_BCTL);
  162. mdelay(20);
  163. outb(0, base + REG_BCTL);
  164. mdelay(1150);
  165. outb(0, base + REG_MCTL);
  166. outb(PARITY_MASK, base + REG_ACTL);
  167. }
  168. static int fdomain_select(struct Scsi_Host *sh, int target)
  169. {
  170. int status;
  171. unsigned long timeout;
  172. struct fdomain *fd = shost_priv(sh);
  173. outb(BCTL_BUSEN | BCTL_SEL, fd->base + REG_BCTL);
  174. outb(BIT(sh->this_id) | BIT(target), fd->base + REG_SCSI_DATA_NOACK);
  175. /* Stop arbitration and enable parity */
  176. outb(PARITY_MASK, fd->base + REG_ACTL);
  177. timeout = 350; /* 350 msec */
  178. do {
  179. status = inb(fd->base + REG_BSTAT);
  180. if (status & BSTAT_BSY) {
  181. /* Enable SCSI Bus */
  182. /* (on error, should make bus idle with 0) */
  183. outb(BCTL_BUSEN, fd->base + REG_BCTL);
  184. return 0;
  185. }
  186. mdelay(1);
  187. } while (--timeout);
  188. fdomain_make_bus_idle(fd);
  189. return 1;
  190. }
  191. static void fdomain_finish_cmd(struct fdomain *fd)
  192. {
  193. outb(0, fd->base + REG_ICTL);
  194. fdomain_make_bus_idle(fd);
  195. scsi_done(fd->cur_cmd);
  196. fd->cur_cmd = NULL;
  197. }
  198. static void fdomain_read_data(struct scsi_cmnd *cmd)
  199. {
  200. struct fdomain *fd = shost_priv(cmd->device->host);
  201. unsigned char *virt, *ptr;
  202. size_t offset, len;
  203. while ((len = inw(fd->base + REG_FIFO_COUNT)) > 0) {
  204. offset = scsi_bufflen(cmd) - scsi_get_resid(cmd);
  205. virt = scsi_kmap_atomic_sg(scsi_sglist(cmd), scsi_sg_count(cmd),
  206. &offset, &len);
  207. ptr = virt + offset;
  208. if (len & 1)
  209. *ptr++ = inb(fd->base + REG_FIFO);
  210. if (len > 1)
  211. insw(fd->base + REG_FIFO, ptr, len >> 1);
  212. scsi_set_resid(cmd, scsi_get_resid(cmd) - len);
  213. scsi_kunmap_atomic_sg(virt);
  214. }
  215. }
  216. static void fdomain_write_data(struct scsi_cmnd *cmd)
  217. {
  218. struct fdomain *fd = shost_priv(cmd->device->host);
  219. /* 8k FIFO for pre-tmc18c30 chips, 2k FIFO for tmc18c30 */
  220. int FIFO_Size = fd->chip == tmc18c30 ? 0x800 : 0x2000;
  221. unsigned char *virt, *ptr;
  222. size_t offset, len;
  223. while ((len = FIFO_Size - inw(fd->base + REG_FIFO_COUNT)) > 512) {
  224. offset = scsi_bufflen(cmd) - scsi_get_resid(cmd);
  225. if (len + offset > scsi_bufflen(cmd)) {
  226. len = scsi_bufflen(cmd) - offset;
  227. if (len == 0)
  228. break;
  229. }
  230. virt = scsi_kmap_atomic_sg(scsi_sglist(cmd), scsi_sg_count(cmd),
  231. &offset, &len);
  232. ptr = virt + offset;
  233. if (len & 1)
  234. outb(*ptr++, fd->base + REG_FIFO);
  235. if (len > 1)
  236. outsw(fd->base + REG_FIFO, ptr, len >> 1);
  237. scsi_set_resid(cmd, scsi_get_resid(cmd) - len);
  238. scsi_kunmap_atomic_sg(virt);
  239. }
  240. }
  241. static void fdomain_work(struct work_struct *work)
  242. {
  243. struct fdomain *fd = container_of(work, struct fdomain, work);
  244. struct Scsi_Host *sh = container_of((void *)fd, struct Scsi_Host,
  245. hostdata);
  246. struct scsi_cmnd *cmd = fd->cur_cmd;
  247. struct scsi_pointer *scsi_pointer = fdomain_scsi_pointer(cmd);
  248. unsigned long flags;
  249. int status;
  250. int done = 0;
  251. spin_lock_irqsave(sh->host_lock, flags);
  252. if (scsi_pointer->phase & in_arbitration) {
  253. status = inb(fd->base + REG_ASTAT);
  254. if (!(status & ASTAT_ARB)) {
  255. set_host_byte(cmd, DID_BUS_BUSY);
  256. fdomain_finish_cmd(fd);
  257. goto out;
  258. }
  259. scsi_pointer->phase = in_selection;
  260. outb(ICTL_SEL | FIFO_COUNT, fd->base + REG_ICTL);
  261. outb(BCTL_BUSEN | BCTL_SEL, fd->base + REG_BCTL);
  262. outb(BIT(cmd->device->host->this_id) | BIT(scmd_id(cmd)),
  263. fd->base + REG_SCSI_DATA_NOACK);
  264. /* Stop arbitration and enable parity */
  265. outb(ACTL_IRQEN | PARITY_MASK, fd->base + REG_ACTL);
  266. goto out;
  267. } else if (scsi_pointer->phase & in_selection) {
  268. status = inb(fd->base + REG_BSTAT);
  269. if (!(status & BSTAT_BSY)) {
  270. /* Try again, for slow devices */
  271. if (fdomain_select(cmd->device->host, scmd_id(cmd))) {
  272. set_host_byte(cmd, DID_NO_CONNECT);
  273. fdomain_finish_cmd(fd);
  274. goto out;
  275. }
  276. /* Stop arbitration and enable parity */
  277. outb(ACTL_IRQEN | PARITY_MASK, fd->base + REG_ACTL);
  278. }
  279. scsi_pointer->phase = in_other;
  280. outb(ICTL_FIFO | ICTL_REQ | FIFO_COUNT, fd->base + REG_ICTL);
  281. outb(BCTL_BUSEN, fd->base + REG_BCTL);
  282. goto out;
  283. }
  284. /* fdomain_scsi_pointer(cur_cmd)->phase == in_other: this is the body of the routine */
  285. status = inb(fd->base + REG_BSTAT);
  286. if (status & BSTAT_REQ) {
  287. switch (status & (BSTAT_MSG | BSTAT_CMD | BSTAT_IO)) {
  288. case BSTAT_CMD: /* COMMAND OUT */
  289. outb(cmd->cmnd[scsi_pointer->sent_command++],
  290. fd->base + REG_SCSI_DATA);
  291. break;
  292. case 0: /* DATA OUT -- tmc18c50/tmc18c30 only */
  293. if (fd->chip != tmc1800 && !scsi_pointer->have_data_in) {
  294. scsi_pointer->have_data_in = -1;
  295. outb(ACTL_IRQEN | ACTL_FIFOWR | ACTL_FIFOEN |
  296. PARITY_MASK, fd->base + REG_ACTL);
  297. }
  298. break;
  299. case BSTAT_IO: /* DATA IN -- tmc18c50/tmc18c30 only */
  300. if (fd->chip != tmc1800 && !scsi_pointer->have_data_in) {
  301. scsi_pointer->have_data_in = 1;
  302. outb(ACTL_IRQEN | ACTL_FIFOEN | PARITY_MASK,
  303. fd->base + REG_ACTL);
  304. }
  305. break;
  306. case BSTAT_CMD | BSTAT_IO: /* STATUS IN */
  307. scsi_pointer->Status = inb(fd->base + REG_SCSI_DATA);
  308. break;
  309. case BSTAT_MSG | BSTAT_CMD: /* MESSAGE OUT */
  310. outb(MESSAGE_REJECT, fd->base + REG_SCSI_DATA);
  311. break;
  312. case BSTAT_MSG | BSTAT_CMD | BSTAT_IO: /* MESSAGE IN */
  313. scsi_pointer->Message = inb(fd->base + REG_SCSI_DATA);
  314. if (scsi_pointer->Message == COMMAND_COMPLETE)
  315. ++done;
  316. break;
  317. }
  318. }
  319. if (fd->chip == tmc1800 && !scsi_pointer->have_data_in &&
  320. scsi_pointer->sent_command >= cmd->cmd_len) {
  321. if (cmd->sc_data_direction == DMA_TO_DEVICE) {
  322. scsi_pointer->have_data_in = -1;
  323. outb(ACTL_IRQEN | ACTL_FIFOWR | ACTL_FIFOEN |
  324. PARITY_MASK, fd->base + REG_ACTL);
  325. } else {
  326. scsi_pointer->have_data_in = 1;
  327. outb(ACTL_IRQEN | ACTL_FIFOEN | PARITY_MASK,
  328. fd->base + REG_ACTL);
  329. }
  330. }
  331. if (scsi_pointer->have_data_in == -1) /* DATA OUT */
  332. fdomain_write_data(cmd);
  333. if (scsi_pointer->have_data_in == 1) /* DATA IN */
  334. fdomain_read_data(cmd);
  335. if (done) {
  336. set_status_byte(cmd, scsi_pointer->Status);
  337. set_host_byte(cmd, DID_OK);
  338. scsi_msg_to_host_byte(cmd, scsi_pointer->Message);
  339. fdomain_finish_cmd(fd);
  340. } else {
  341. if (scsi_pointer->phase & disconnect) {
  342. outb(ICTL_FIFO | ICTL_SEL | ICTL_REQ | FIFO_COUNT,
  343. fd->base + REG_ICTL);
  344. outb(0, fd->base + REG_BCTL);
  345. } else
  346. outb(ICTL_FIFO | ICTL_REQ | FIFO_COUNT,
  347. fd->base + REG_ICTL);
  348. }
  349. out:
  350. spin_unlock_irqrestore(sh->host_lock, flags);
  351. }
  352. static irqreturn_t fdomain_irq(int irq, void *dev_id)
  353. {
  354. struct fdomain *fd = dev_id;
  355. /* Is it our IRQ? */
  356. if ((inb(fd->base + REG_ASTAT) & ASTAT_IRQ) == 0)
  357. return IRQ_NONE;
  358. outb(0, fd->base + REG_ICTL);
  359. /* We usually have one spurious interrupt after each command. */
  360. if (!fd->cur_cmd) /* Spurious interrupt */
  361. return IRQ_NONE;
  362. schedule_work(&fd->work);
  363. return IRQ_HANDLED;
  364. }
  365. static int fdomain_queue(struct Scsi_Host *sh, struct scsi_cmnd *cmd)
  366. {
  367. struct scsi_pointer *scsi_pointer = fdomain_scsi_pointer(cmd);
  368. struct fdomain *fd = shost_priv(cmd->device->host);
  369. unsigned long flags;
  370. scsi_pointer->Status = 0;
  371. scsi_pointer->Message = 0;
  372. scsi_pointer->have_data_in = 0;
  373. scsi_pointer->sent_command = 0;
  374. scsi_pointer->phase = in_arbitration;
  375. scsi_set_resid(cmd, scsi_bufflen(cmd));
  376. spin_lock_irqsave(sh->host_lock, flags);
  377. fd->cur_cmd = cmd;
  378. fdomain_make_bus_idle(fd);
  379. /* Start arbitration */
  380. outb(0, fd->base + REG_ICTL);
  381. outb(0, fd->base + REG_BCTL); /* Disable data drivers */
  382. /* Set our id bit */
  383. outb(BIT(cmd->device->host->this_id), fd->base + REG_SCSI_DATA_NOACK);
  384. outb(ICTL_ARB, fd->base + REG_ICTL);
  385. /* Start arbitration */
  386. outb(ACTL_ARB | ACTL_IRQEN | PARITY_MASK, fd->base + REG_ACTL);
  387. spin_unlock_irqrestore(sh->host_lock, flags);
  388. return 0;
  389. }
  390. static int fdomain_abort(struct scsi_cmnd *cmd)
  391. {
  392. struct Scsi_Host *sh = cmd->device->host;
  393. struct fdomain *fd = shost_priv(sh);
  394. unsigned long flags;
  395. if (!fd->cur_cmd)
  396. return FAILED;
  397. spin_lock_irqsave(sh->host_lock, flags);
  398. fdomain_make_bus_idle(fd);
  399. fdomain_scsi_pointer(fd->cur_cmd)->phase |= aborted;
  400. /* Aborts are not done well. . . */
  401. set_host_byte(fd->cur_cmd, DID_ABORT);
  402. fdomain_finish_cmd(fd);
  403. spin_unlock_irqrestore(sh->host_lock, flags);
  404. return SUCCESS;
  405. }
  406. static int fdomain_host_reset(struct scsi_cmnd *cmd)
  407. {
  408. struct Scsi_Host *sh = cmd->device->host;
  409. struct fdomain *fd = shost_priv(sh);
  410. unsigned long flags;
  411. spin_lock_irqsave(sh->host_lock, flags);
  412. fdomain_reset(fd->base);
  413. spin_unlock_irqrestore(sh->host_lock, flags);
  414. return SUCCESS;
  415. }
  416. static int fdomain_biosparam(struct scsi_device *sdev,
  417. struct block_device *bdev, sector_t capacity,
  418. int geom[])
  419. {
  420. unsigned char *p = scsi_bios_ptable(bdev);
  421. if (p && p[65] == 0xaa && p[64] == 0x55 /* Partition table valid */
  422. && p[4]) { /* Partition type */
  423. geom[0] = p[5] + 1; /* heads */
  424. geom[1] = p[6] & 0x3f; /* sectors */
  425. } else {
  426. if (capacity >= 0x7e0000) {
  427. geom[0] = 255; /* heads */
  428. geom[1] = 63; /* sectors */
  429. } else if (capacity >= 0x200000) {
  430. geom[0] = 128; /* heads */
  431. geom[1] = 63; /* sectors */
  432. } else {
  433. geom[0] = 64; /* heads */
  434. geom[1] = 32; /* sectors */
  435. }
  436. }
  437. geom[2] = sector_div(capacity, geom[0] * geom[1]);
  438. kfree(p);
  439. return 0;
  440. }
  441. static struct scsi_host_template fdomain_template = {
  442. .module = THIS_MODULE,
  443. .name = "Future Domain TMC-16x0",
  444. .proc_name = "fdomain",
  445. .queuecommand = fdomain_queue,
  446. .eh_abort_handler = fdomain_abort,
  447. .eh_host_reset_handler = fdomain_host_reset,
  448. .bios_param = fdomain_biosparam,
  449. .can_queue = 1,
  450. .this_id = 7,
  451. .sg_tablesize = 64,
  452. .dma_boundary = PAGE_SIZE - 1,
  453. .cmd_size = sizeof(struct scsi_pointer),
  454. };
  455. struct Scsi_Host *fdomain_create(int base, int irq, int this_id,
  456. struct device *dev)
  457. {
  458. struct Scsi_Host *sh;
  459. struct fdomain *fd;
  460. enum chip_type chip;
  461. static const char * const chip_names[] = {
  462. "Unknown", "TMC-1800", "TMC-18C50", "TMC-18C30"
  463. };
  464. unsigned long irq_flags = 0;
  465. chip = fdomain_identify(base);
  466. if (!chip)
  467. return NULL;
  468. fdomain_reset(base);
  469. if (fdomain_test_loopback(base))
  470. return NULL;
  471. if (!irq) {
  472. dev_err(dev, "card has no IRQ assigned");
  473. return NULL;
  474. }
  475. sh = scsi_host_alloc(&fdomain_template, sizeof(struct fdomain));
  476. if (!sh)
  477. return NULL;
  478. if (this_id)
  479. sh->this_id = this_id & 0x07;
  480. sh->irq = irq;
  481. sh->io_port = base;
  482. sh->n_io_port = FDOMAIN_REGION_SIZE;
  483. fd = shost_priv(sh);
  484. fd->base = base;
  485. fd->chip = chip;
  486. INIT_WORK(&fd->work, fdomain_work);
  487. if (dev_is_pci(dev) || !strcmp(dev->bus->name, "pcmcia"))
  488. irq_flags = IRQF_SHARED;
  489. if (request_irq(irq, fdomain_irq, irq_flags, "fdomain", fd))
  490. goto fail_put;
  491. shost_printk(KERN_INFO, sh, "%s chip at 0x%x irq %d SCSI ID %d\n",
  492. dev_is_pci(dev) ? "TMC-36C70 (PCI bus)" : chip_names[chip],
  493. base, irq, sh->this_id);
  494. if (scsi_add_host(sh, dev))
  495. goto fail_free_irq;
  496. scsi_scan_host(sh);
  497. return sh;
  498. fail_free_irq:
  499. free_irq(irq, fd);
  500. fail_put:
  501. scsi_host_put(sh);
  502. return NULL;
  503. }
  504. EXPORT_SYMBOL_GPL(fdomain_create);
  505. int fdomain_destroy(struct Scsi_Host *sh)
  506. {
  507. struct fdomain *fd = shost_priv(sh);
  508. cancel_work_sync(&fd->work);
  509. scsi_remove_host(sh);
  510. if (sh->irq)
  511. free_irq(sh->irq, fd);
  512. scsi_host_put(sh);
  513. return 0;
  514. }
  515. EXPORT_SYMBOL_GPL(fdomain_destroy);
  516. #ifdef CONFIG_PM_SLEEP
  517. static int fdomain_resume(struct device *dev)
  518. {
  519. struct fdomain *fd = shost_priv(dev_get_drvdata(dev));
  520. fdomain_reset(fd->base);
  521. return 0;
  522. }
  523. static SIMPLE_DEV_PM_OPS(fdomain_pm_ops, NULL, fdomain_resume);
  524. #endif /* CONFIG_PM_SLEEP */
  525. MODULE_AUTHOR("Ondrej Zary, Rickard E. Faith");
  526. MODULE_DESCRIPTION("Future Domain TMC-16x0/TMC-3260 SCSI driver");
  527. MODULE_LICENSE("GPL");