fdomain.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597
  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, faith@cs.unc.edu
  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 (drew@cs.colorado.edu) and Eric
  69. * Youngdale (ericy@cais.com), 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 inline void fdomain_make_bus_idle(struct fdomain *fd)
  114. {
  115. outb(0, fd->base + REG_BCTL);
  116. outb(0, fd->base + REG_MCTL);
  117. if (fd->chip == tmc18c50 || fd->chip == tmc18c30)
  118. /* Clear forced intr. */
  119. outb(ACTL_RESET | ACTL_CLRFIRQ | PARITY_MASK,
  120. fd->base + REG_ACTL);
  121. else
  122. outb(ACTL_RESET | PARITY_MASK, fd->base + REG_ACTL);
  123. }
  124. static enum chip_type fdomain_identify(int port)
  125. {
  126. u16 id = inb(port + REG_ID_LSB) | inb(port + REG_ID_MSB) << 8;
  127. switch (id) {
  128. case 0x6127:
  129. return tmc1800;
  130. case 0x60e9: /* 18c50 or 18c30 */
  131. break;
  132. default:
  133. return unknown;
  134. }
  135. /* Try to toggle 32-bit mode. This only works on an 18c30 chip. */
  136. outb(CFG2_32BIT, port + REG_CFG2);
  137. if ((inb(port + REG_CFG2) & CFG2_32BIT)) {
  138. outb(0, port + REG_CFG2);
  139. if ((inb(port + REG_CFG2) & CFG2_32BIT) == 0)
  140. return tmc18c30;
  141. }
  142. /* If that failed, we are an 18c50. */
  143. return tmc18c50;
  144. }
  145. static int fdomain_test_loopback(int base)
  146. {
  147. int i;
  148. for (i = 0; i < 255; i++) {
  149. outb(i, base + REG_LOOPBACK);
  150. if (inb(base + REG_LOOPBACK) != i)
  151. return 1;
  152. }
  153. return 0;
  154. }
  155. static void fdomain_reset(int base)
  156. {
  157. outb(BCTL_RST, base + REG_BCTL);
  158. mdelay(20);
  159. outb(0, base + REG_BCTL);
  160. mdelay(1150);
  161. outb(0, base + REG_MCTL);
  162. outb(PARITY_MASK, base + REG_ACTL);
  163. }
  164. static int fdomain_select(struct Scsi_Host *sh, int target)
  165. {
  166. int status;
  167. unsigned long timeout;
  168. struct fdomain *fd = shost_priv(sh);
  169. outb(BCTL_BUSEN | BCTL_SEL, fd->base + REG_BCTL);
  170. outb(BIT(sh->this_id) | BIT(target), fd->base + REG_SCSI_DATA_NOACK);
  171. /* Stop arbitration and enable parity */
  172. outb(PARITY_MASK, fd->base + REG_ACTL);
  173. timeout = 350; /* 350 msec */
  174. do {
  175. status = inb(fd->base + REG_BSTAT);
  176. if (status & BSTAT_BSY) {
  177. /* Enable SCSI Bus */
  178. /* (on error, should make bus idle with 0) */
  179. outb(BCTL_BUSEN, fd->base + REG_BCTL);
  180. return 0;
  181. }
  182. mdelay(1);
  183. } while (--timeout);
  184. fdomain_make_bus_idle(fd);
  185. return 1;
  186. }
  187. static void fdomain_finish_cmd(struct fdomain *fd, int result)
  188. {
  189. outb(0, fd->base + REG_ICTL);
  190. fdomain_make_bus_idle(fd);
  191. fd->cur_cmd->result = result;
  192. fd->cur_cmd->scsi_done(fd->cur_cmd);
  193. fd->cur_cmd = NULL;
  194. }
  195. static void fdomain_read_data(struct scsi_cmnd *cmd)
  196. {
  197. struct fdomain *fd = shost_priv(cmd->device->host);
  198. unsigned char *virt, *ptr;
  199. size_t offset, len;
  200. while ((len = inw(fd->base + REG_FIFO_COUNT)) > 0) {
  201. offset = scsi_bufflen(cmd) - scsi_get_resid(cmd);
  202. virt = scsi_kmap_atomic_sg(scsi_sglist(cmd), scsi_sg_count(cmd),
  203. &offset, &len);
  204. ptr = virt + offset;
  205. if (len & 1)
  206. *ptr++ = inb(fd->base + REG_FIFO);
  207. if (len > 1)
  208. insw(fd->base + REG_FIFO, ptr, len >> 1);
  209. scsi_set_resid(cmd, scsi_get_resid(cmd) - len);
  210. scsi_kunmap_atomic_sg(virt);
  211. }
  212. }
  213. static void fdomain_write_data(struct scsi_cmnd *cmd)
  214. {
  215. struct fdomain *fd = shost_priv(cmd->device->host);
  216. /* 8k FIFO for pre-tmc18c30 chips, 2k FIFO for tmc18c30 */
  217. int FIFO_Size = fd->chip == tmc18c30 ? 0x800 : 0x2000;
  218. unsigned char *virt, *ptr;
  219. size_t offset, len;
  220. while ((len = FIFO_Size - inw(fd->base + REG_FIFO_COUNT)) > 512) {
  221. offset = scsi_bufflen(cmd) - scsi_get_resid(cmd);
  222. if (len + offset > scsi_bufflen(cmd)) {
  223. len = scsi_bufflen(cmd) - offset;
  224. if (len == 0)
  225. break;
  226. }
  227. virt = scsi_kmap_atomic_sg(scsi_sglist(cmd), scsi_sg_count(cmd),
  228. &offset, &len);
  229. ptr = virt + offset;
  230. if (len & 1)
  231. outb(*ptr++, fd->base + REG_FIFO);
  232. if (len > 1)
  233. outsw(fd->base + REG_FIFO, ptr, len >> 1);
  234. scsi_set_resid(cmd, scsi_get_resid(cmd) - len);
  235. scsi_kunmap_atomic_sg(virt);
  236. }
  237. }
  238. static void fdomain_work(struct work_struct *work)
  239. {
  240. struct fdomain *fd = container_of(work, struct fdomain, work);
  241. struct Scsi_Host *sh = container_of((void *)fd, struct Scsi_Host,
  242. hostdata);
  243. struct scsi_cmnd *cmd = fd->cur_cmd;
  244. unsigned long flags;
  245. int status;
  246. int done = 0;
  247. spin_lock_irqsave(sh->host_lock, flags);
  248. if (cmd->SCp.phase & in_arbitration) {
  249. status = inb(fd->base + REG_ASTAT);
  250. if (!(status & ASTAT_ARB)) {
  251. fdomain_finish_cmd(fd, DID_BUS_BUSY << 16);
  252. goto out;
  253. }
  254. cmd->SCp.phase = in_selection;
  255. outb(ICTL_SEL | FIFO_COUNT, fd->base + REG_ICTL);
  256. outb(BCTL_BUSEN | BCTL_SEL, fd->base + REG_BCTL);
  257. outb(BIT(cmd->device->host->this_id) | BIT(scmd_id(cmd)),
  258. fd->base + REG_SCSI_DATA_NOACK);
  259. /* Stop arbitration and enable parity */
  260. outb(ACTL_IRQEN | PARITY_MASK, fd->base + REG_ACTL);
  261. goto out;
  262. } else if (cmd->SCp.phase & in_selection) {
  263. status = inb(fd->base + REG_BSTAT);
  264. if (!(status & BSTAT_BSY)) {
  265. /* Try again, for slow devices */
  266. if (fdomain_select(cmd->device->host, scmd_id(cmd))) {
  267. fdomain_finish_cmd(fd, DID_NO_CONNECT << 16);
  268. goto out;
  269. }
  270. /* Stop arbitration and enable parity */
  271. outb(ACTL_IRQEN | PARITY_MASK, fd->base + REG_ACTL);
  272. }
  273. cmd->SCp.phase = in_other;
  274. outb(ICTL_FIFO | ICTL_REQ | FIFO_COUNT, fd->base + REG_ICTL);
  275. outb(BCTL_BUSEN, fd->base + REG_BCTL);
  276. goto out;
  277. }
  278. /* cur_cmd->SCp.phase == in_other: this is the body of the routine */
  279. status = inb(fd->base + REG_BSTAT);
  280. if (status & BSTAT_REQ) {
  281. switch (status & (BSTAT_MSG | BSTAT_CMD | BSTAT_IO)) {
  282. case BSTAT_CMD: /* COMMAND OUT */
  283. outb(cmd->cmnd[cmd->SCp.sent_command++],
  284. fd->base + REG_SCSI_DATA);
  285. break;
  286. case 0: /* DATA OUT -- tmc18c50/tmc18c30 only */
  287. if (fd->chip != tmc1800 && !cmd->SCp.have_data_in) {
  288. cmd->SCp.have_data_in = -1;
  289. outb(ACTL_IRQEN | ACTL_FIFOWR | ACTL_FIFOEN |
  290. PARITY_MASK, fd->base + REG_ACTL);
  291. }
  292. break;
  293. case BSTAT_IO: /* DATA IN -- tmc18c50/tmc18c30 only */
  294. if (fd->chip != tmc1800 && !cmd->SCp.have_data_in) {
  295. cmd->SCp.have_data_in = 1;
  296. outb(ACTL_IRQEN | ACTL_FIFOEN | PARITY_MASK,
  297. fd->base + REG_ACTL);
  298. }
  299. break;
  300. case BSTAT_CMD | BSTAT_IO: /* STATUS IN */
  301. cmd->SCp.Status = inb(fd->base + REG_SCSI_DATA);
  302. break;
  303. case BSTAT_MSG | BSTAT_CMD: /* MESSAGE OUT */
  304. outb(MESSAGE_REJECT, fd->base + REG_SCSI_DATA);
  305. break;
  306. case BSTAT_MSG | BSTAT_CMD | BSTAT_IO: /* MESSAGE IN */
  307. cmd->SCp.Message = inb(fd->base + REG_SCSI_DATA);
  308. if (!cmd->SCp.Message)
  309. ++done;
  310. break;
  311. }
  312. }
  313. if (fd->chip == tmc1800 && !cmd->SCp.have_data_in &&
  314. cmd->SCp.sent_command >= cmd->cmd_len) {
  315. if (cmd->sc_data_direction == DMA_TO_DEVICE) {
  316. cmd->SCp.have_data_in = -1;
  317. outb(ACTL_IRQEN | ACTL_FIFOWR | ACTL_FIFOEN |
  318. PARITY_MASK, fd->base + REG_ACTL);
  319. } else {
  320. cmd->SCp.have_data_in = 1;
  321. outb(ACTL_IRQEN | ACTL_FIFOEN | PARITY_MASK,
  322. fd->base + REG_ACTL);
  323. }
  324. }
  325. if (cmd->SCp.have_data_in == -1) /* DATA OUT */
  326. fdomain_write_data(cmd);
  327. if (cmd->SCp.have_data_in == 1) /* DATA IN */
  328. fdomain_read_data(cmd);
  329. if (done) {
  330. fdomain_finish_cmd(fd, (cmd->SCp.Status & 0xff) |
  331. ((cmd->SCp.Message & 0xff) << 8) |
  332. (DID_OK << 16));
  333. } else {
  334. if (cmd->SCp.phase & disconnect) {
  335. outb(ICTL_FIFO | ICTL_SEL | ICTL_REQ | FIFO_COUNT,
  336. fd->base + REG_ICTL);
  337. outb(0, fd->base + REG_BCTL);
  338. } else
  339. outb(ICTL_FIFO | ICTL_REQ | FIFO_COUNT,
  340. fd->base + REG_ICTL);
  341. }
  342. out:
  343. spin_unlock_irqrestore(sh->host_lock, flags);
  344. }
  345. static irqreturn_t fdomain_irq(int irq, void *dev_id)
  346. {
  347. struct fdomain *fd = dev_id;
  348. /* Is it our IRQ? */
  349. if ((inb(fd->base + REG_ASTAT) & ASTAT_IRQ) == 0)
  350. return IRQ_NONE;
  351. outb(0, fd->base + REG_ICTL);
  352. /* We usually have one spurious interrupt after each command. */
  353. if (!fd->cur_cmd) /* Spurious interrupt */
  354. return IRQ_NONE;
  355. schedule_work(&fd->work);
  356. return IRQ_HANDLED;
  357. }
  358. static int fdomain_queue(struct Scsi_Host *sh, struct scsi_cmnd *cmd)
  359. {
  360. struct fdomain *fd = shost_priv(cmd->device->host);
  361. unsigned long flags;
  362. cmd->SCp.Status = 0;
  363. cmd->SCp.Message = 0;
  364. cmd->SCp.have_data_in = 0;
  365. cmd->SCp.sent_command = 0;
  366. cmd->SCp.phase = in_arbitration;
  367. scsi_set_resid(cmd, scsi_bufflen(cmd));
  368. spin_lock_irqsave(sh->host_lock, flags);
  369. fd->cur_cmd = cmd;
  370. fdomain_make_bus_idle(fd);
  371. /* Start arbitration */
  372. outb(0, fd->base + REG_ICTL);
  373. outb(0, fd->base + REG_BCTL); /* Disable data drivers */
  374. /* Set our id bit */
  375. outb(BIT(cmd->device->host->this_id), fd->base + REG_SCSI_DATA_NOACK);
  376. outb(ICTL_ARB, fd->base + REG_ICTL);
  377. /* Start arbitration */
  378. outb(ACTL_ARB | ACTL_IRQEN | PARITY_MASK, fd->base + REG_ACTL);
  379. spin_unlock_irqrestore(sh->host_lock, flags);
  380. return 0;
  381. }
  382. static int fdomain_abort(struct scsi_cmnd *cmd)
  383. {
  384. struct Scsi_Host *sh = cmd->device->host;
  385. struct fdomain *fd = shost_priv(sh);
  386. unsigned long flags;
  387. if (!fd->cur_cmd)
  388. return FAILED;
  389. spin_lock_irqsave(sh->host_lock, flags);
  390. fdomain_make_bus_idle(fd);
  391. fd->cur_cmd->SCp.phase |= aborted;
  392. fd->cur_cmd->result = DID_ABORT << 16;
  393. /* Aborts are not done well. . . */
  394. fdomain_finish_cmd(fd, DID_ABORT << 16);
  395. spin_unlock_irqrestore(sh->host_lock, flags);
  396. return SUCCESS;
  397. }
  398. static int fdomain_host_reset(struct scsi_cmnd *cmd)
  399. {
  400. struct Scsi_Host *sh = cmd->device->host;
  401. struct fdomain *fd = shost_priv(sh);
  402. unsigned long flags;
  403. spin_lock_irqsave(sh->host_lock, flags);
  404. fdomain_reset(fd->base);
  405. spin_unlock_irqrestore(sh->host_lock, flags);
  406. return SUCCESS;
  407. }
  408. static int fdomain_biosparam(struct scsi_device *sdev,
  409. struct block_device *bdev, sector_t capacity,
  410. int geom[])
  411. {
  412. unsigned char *p = scsi_bios_ptable(bdev);
  413. if (p && p[65] == 0xaa && p[64] == 0x55 /* Partition table valid */
  414. && p[4]) { /* Partition type */
  415. geom[0] = p[5] + 1; /* heads */
  416. geom[1] = p[6] & 0x3f; /* sectors */
  417. } else {
  418. if (capacity >= 0x7e0000) {
  419. geom[0] = 255; /* heads */
  420. geom[1] = 63; /* sectors */
  421. } else if (capacity >= 0x200000) {
  422. geom[0] = 128; /* heads */
  423. geom[1] = 63; /* sectors */
  424. } else {
  425. geom[0] = 64; /* heads */
  426. geom[1] = 32; /* sectors */
  427. }
  428. }
  429. geom[2] = sector_div(capacity, geom[0] * geom[1]);
  430. kfree(p);
  431. return 0;
  432. }
  433. static struct scsi_host_template fdomain_template = {
  434. .module = THIS_MODULE,
  435. .name = "Future Domain TMC-16x0",
  436. .proc_name = "fdomain",
  437. .queuecommand = fdomain_queue,
  438. .eh_abort_handler = fdomain_abort,
  439. .eh_host_reset_handler = fdomain_host_reset,
  440. .bios_param = fdomain_biosparam,
  441. .can_queue = 1,
  442. .this_id = 7,
  443. .sg_tablesize = 64,
  444. .dma_boundary = PAGE_SIZE - 1,
  445. };
  446. struct Scsi_Host *fdomain_create(int base, int irq, int this_id,
  447. struct device *dev)
  448. {
  449. struct Scsi_Host *sh;
  450. struct fdomain *fd;
  451. enum chip_type chip;
  452. static const char * const chip_names[] = {
  453. "Unknown", "TMC-1800", "TMC-18C50", "TMC-18C30"
  454. };
  455. unsigned long irq_flags = 0;
  456. chip = fdomain_identify(base);
  457. if (!chip)
  458. return NULL;
  459. fdomain_reset(base);
  460. if (fdomain_test_loopback(base))
  461. return NULL;
  462. if (!irq) {
  463. dev_err(dev, "card has no IRQ assigned");
  464. return NULL;
  465. }
  466. sh = scsi_host_alloc(&fdomain_template, sizeof(struct fdomain));
  467. if (!sh)
  468. return NULL;
  469. if (this_id)
  470. sh->this_id = this_id & 0x07;
  471. sh->irq = irq;
  472. sh->io_port = base;
  473. sh->n_io_port = FDOMAIN_REGION_SIZE;
  474. fd = shost_priv(sh);
  475. fd->base = base;
  476. fd->chip = chip;
  477. INIT_WORK(&fd->work, fdomain_work);
  478. if (dev_is_pci(dev) || !strcmp(dev->bus->name, "pcmcia"))
  479. irq_flags = IRQF_SHARED;
  480. if (request_irq(irq, fdomain_irq, irq_flags, "fdomain", fd))
  481. goto fail_put;
  482. shost_printk(KERN_INFO, sh, "%s chip at 0x%x irq %d SCSI ID %d\n",
  483. dev_is_pci(dev) ? "TMC-36C70 (PCI bus)" : chip_names[chip],
  484. base, irq, sh->this_id);
  485. if (scsi_add_host(sh, dev))
  486. goto fail_free_irq;
  487. scsi_scan_host(sh);
  488. return sh;
  489. fail_free_irq:
  490. free_irq(irq, fd);
  491. fail_put:
  492. scsi_host_put(sh);
  493. return NULL;
  494. }
  495. EXPORT_SYMBOL_GPL(fdomain_create);
  496. int fdomain_destroy(struct Scsi_Host *sh)
  497. {
  498. struct fdomain *fd = shost_priv(sh);
  499. cancel_work_sync(&fd->work);
  500. scsi_remove_host(sh);
  501. if (sh->irq)
  502. free_irq(sh->irq, fd);
  503. scsi_host_put(sh);
  504. return 0;
  505. }
  506. EXPORT_SYMBOL_GPL(fdomain_destroy);
  507. #ifdef CONFIG_PM_SLEEP
  508. static int fdomain_resume(struct device *dev)
  509. {
  510. struct fdomain *fd = shost_priv(dev_get_drvdata(dev));
  511. fdomain_reset(fd->base);
  512. return 0;
  513. }
  514. static SIMPLE_DEV_PM_OPS(fdomain_pm_ops, NULL, fdomain_resume);
  515. #endif /* CONFIG_PM_SLEEP */
  516. MODULE_AUTHOR("Ondrej Zary, Rickard E. Faith");
  517. MODULE_DESCRIPTION("Future Domain TMC-16x0/TMC-3260 SCSI driver");
  518. MODULE_LICENSE("GPL");