Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

scsi: fdomain: Resurrect driver - Core

Future Domain TMC-16xx/TMC-3260 SCSI driver.

This is the core driver, common for PCI, ISA and PCMCIA cards.

Signed-off-by: Ondrej Zary <linux@zary.sk>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>

authored by

Ondrej Zary and committed by
Martin K. Petersen
ebeb4665 9a14f9b1

+644
+4
drivers/scsi/Kconfig
··· 641 641 To compile this driver as a module, choose M here: the 642 642 module will be called dmx3191d. 643 643 644 + config SCSI_FDOMAIN 645 + tristate 646 + depends on SCSI 647 + 644 648 config SCSI_GDTH 645 649 tristate "Intel/ICP (former GDT SCSI Disk Array) RAID Controller support" 646 650 depends on PCI && SCSI
+1
drivers/scsi/Makefile
··· 76 76 obj-$(CONFIG_SCSI_PM8001) += pm8001/ 77 77 obj-$(CONFIG_SCSI_ISCI) += isci/ 78 78 obj-$(CONFIG_SCSI_IPS) += ips.o 79 + obj-$(CONFIG_SCSI_FDOMAIN) += fdomain.o 79 80 obj-$(CONFIG_SCSI_GENERIC_NCR5380) += g_NCR5380.o 80 81 obj-$(CONFIG_SCSI_QLOGIC_FAS) += qlogicfas408.o qlogicfas.o 81 82 obj-$(CONFIG_PCMCIA_QLOGIC) += qlogicfas408.o
+586
drivers/scsi/fdomain.c
··· 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 + 82 + #include <linux/module.h> 83 + #include <linux/interrupt.h> 84 + #include <linux/delay.h> 85 + #include <linux/pci.h> 86 + #include <linux/workqueue.h> 87 + #include <scsi/scsicam.h> 88 + #include <scsi/scsi_cmnd.h> 89 + #include <scsi/scsi_device.h> 90 + #include <scsi/scsi_host.h> 91 + #include "fdomain.h" 92 + 93 + /* 94 + * FIFO_COUNT: The host adapter has an 8K cache (host adapters based on the 95 + * 18C30 chip have a 2k cache). When this many 512 byte blocks are filled by 96 + * the SCSI device, an interrupt will be raised. Therefore, this could be as 97 + * low as 0, or as high as 16. Note, however, that values which are too high 98 + * or too low seem to prevent any interrupts from occurring, and thereby lock 99 + * up the machine. 100 + */ 101 + #define FIFO_COUNT 2 /* Number of 512 byte blocks before INTR */ 102 + #define PARITY_MASK 0x08 /* Parity enabled, 0x00 = disabled */ 103 + 104 + enum chip_type { 105 + unknown = 0x00, 106 + tmc1800 = 0x01, 107 + tmc18c50 = 0x02, 108 + tmc18c30 = 0x03, 109 + }; 110 + 111 + struct fdomain { 112 + int base; 113 + struct scsi_cmnd *cur_cmd; 114 + enum chip_type chip; 115 + struct work_struct work; 116 + }; 117 + 118 + static inline void fdomain_make_bus_idle(struct fdomain *fd) 119 + { 120 + outb(0, fd->base + SCSI_Cntl); 121 + outb(0, fd->base + SCSI_Mode_Cntl); 122 + if (fd->chip == tmc18c50 || fd->chip == tmc18c30) 123 + /* Clear forced intr. */ 124 + outb(0x21 | PARITY_MASK, fd->base + TMC_Cntl); 125 + else 126 + outb(0x01 | PARITY_MASK, fd->base + TMC_Cntl); 127 + } 128 + 129 + static enum chip_type fdomain_identify(int port) 130 + { 131 + u16 id = inb(port + LSB_ID_Code) | inb(port + MSB_ID_Code) << 8; 132 + 133 + switch (id) { 134 + case 0x6127: 135 + return tmc1800; 136 + case 0x60e9: /* 18c50 or 18c30 */ 137 + break; 138 + default: 139 + return unknown; 140 + } 141 + 142 + /* Try to toggle 32-bit mode. This only works on an 18c30 chip. */ 143 + outb(0x80, port + IO_Control); 144 + if ((inb(port + Configuration2) & 0x80) == 0x80) { 145 + outb(0x00, port + IO_Control); 146 + if ((inb(port + Configuration2) & 0x80) == 0x00) 147 + return tmc18c30; 148 + } 149 + /* If that failed, we are an 18c50. */ 150 + return tmc18c50; 151 + } 152 + 153 + static int fdomain_test_loopback(int base) 154 + { 155 + int i; 156 + 157 + for (i = 0; i < 255; i++) { 158 + outb(i, base + Write_Loopback); 159 + if (inb(base + Read_Loopback) != i) 160 + return 1; 161 + } 162 + 163 + return 0; 164 + } 165 + 166 + static void fdomain_reset(int base) 167 + { 168 + outb(1, base + SCSI_Cntl); 169 + mdelay(20); 170 + outb(0, base + SCSI_Cntl); 171 + mdelay(1150); 172 + outb(0, base + SCSI_Mode_Cntl); 173 + outb(PARITY_MASK, base + TMC_Cntl); 174 + } 175 + 176 + static int fdomain_select(struct Scsi_Host *sh, int target) 177 + { 178 + int status; 179 + unsigned long timeout; 180 + struct fdomain *fd = shost_priv(sh); 181 + 182 + outb(0x82, fd->base + SCSI_Cntl); /* Bus Enable + Select */ 183 + outb(BIT(sh->this_id) | BIT(target), fd->base + SCSI_Data_NoACK); 184 + 185 + /* Stop arbitration and enable parity */ 186 + outb(PARITY_MASK, fd->base + TMC_Cntl); 187 + 188 + timeout = 350; /* 350 msec */ 189 + 190 + do { 191 + status = inb(fd->base + SCSI_Status); /* Read adapter status */ 192 + if (status & 1) { /* Busy asserted */ 193 + /* Enable SCSI Bus */ 194 + /* (on error, should make bus idle with 0) */ 195 + outb(0x80, fd->base + SCSI_Cntl); 196 + return 0; 197 + } 198 + mdelay(1); 199 + } while (--timeout); 200 + fdomain_make_bus_idle(fd); 201 + return 1; 202 + } 203 + 204 + static void fdomain_finish_cmd(struct fdomain *fd, int result) 205 + { 206 + outb(0x00, fd->base + Interrupt_Cntl); 207 + fdomain_make_bus_idle(fd); 208 + fd->cur_cmd->result = result; 209 + fd->cur_cmd->scsi_done(fd->cur_cmd); 210 + fd->cur_cmd = NULL; 211 + } 212 + 213 + static void fdomain_read_data(struct scsi_cmnd *cmd) 214 + { 215 + struct fdomain *fd = shost_priv(cmd->device->host); 216 + unsigned char *virt, *ptr; 217 + size_t offset, len; 218 + 219 + while ((len = inw(fd->base + FIFO_Data_Count)) > 0) { 220 + offset = scsi_bufflen(cmd) - scsi_get_resid(cmd); 221 + virt = scsi_kmap_atomic_sg(scsi_sglist(cmd), scsi_sg_count(cmd), 222 + &offset, &len); 223 + ptr = virt + offset; 224 + if (len & 1) 225 + *ptr++ = inb(fd->base + Read_FIFO); 226 + if (len > 1) 227 + insw(fd->base + Read_FIFO, ptr, len >> 1); 228 + scsi_set_resid(cmd, scsi_get_resid(cmd) - len); 229 + scsi_kunmap_atomic_sg(virt); 230 + } 231 + } 232 + 233 + static void fdomain_write_data(struct scsi_cmnd *cmd) 234 + { 235 + struct fdomain *fd = shost_priv(cmd->device->host); 236 + /* 8k FIFO for pre-tmc18c30 chips, 2k FIFO for tmc18c30 */ 237 + int FIFO_Size = fd->chip == tmc18c30 ? 0x800 : 0x2000; 238 + unsigned char *virt, *ptr; 239 + size_t offset, len; 240 + 241 + while ((len = FIFO_Size - inw(fd->base + FIFO_Data_Count)) > 512) { 242 + offset = scsi_bufflen(cmd) - scsi_get_resid(cmd); 243 + if (len + offset > scsi_bufflen(cmd)) { 244 + len = scsi_bufflen(cmd) - offset; 245 + if (len == 0) 246 + break; 247 + } 248 + virt = scsi_kmap_atomic_sg(scsi_sglist(cmd), scsi_sg_count(cmd), 249 + &offset, &len); 250 + ptr = virt + offset; 251 + if (len & 1) 252 + outb(*ptr++, fd->base + Write_FIFO); 253 + if (len > 1) 254 + outsw(fd->base + Write_FIFO, ptr, len >> 1); 255 + scsi_set_resid(cmd, scsi_get_resid(cmd) - len); 256 + scsi_kunmap_atomic_sg(virt); 257 + } 258 + } 259 + 260 + static void fdomain_work(struct work_struct *work) 261 + { 262 + struct fdomain *fd = container_of(work, struct fdomain, work); 263 + struct Scsi_Host *sh = container_of((void *)fd, struct Scsi_Host, 264 + hostdata); 265 + struct scsi_cmnd *cmd = fd->cur_cmd; 266 + unsigned long flags; 267 + int status; 268 + int done = 0; 269 + 270 + spin_lock_irqsave(sh->host_lock, flags); 271 + 272 + if (cmd->SCp.phase & in_arbitration) { 273 + status = inb(fd->base + TMC_Status); 274 + if (!(status & 0x02)) { 275 + fdomain_finish_cmd(fd, DID_BUS_BUSY << 16); 276 + goto out; 277 + } 278 + cmd->SCp.phase = in_selection; 279 + 280 + outb(0x40 | FIFO_COUNT, fd->base + Interrupt_Cntl); 281 + outb(0x82, fd->base + SCSI_Cntl); /* Bus Enable + Select */ 282 + outb(BIT(cmd->device->host->this_id) | 283 + BIT(scmd_id(cmd)), fd->base + SCSI_Data_NoACK); 284 + /* Stop arbitration and enable parity */ 285 + outb(0x10 | PARITY_MASK, fd->base + TMC_Cntl); 286 + goto out; 287 + } else if (cmd->SCp.phase & in_selection) { 288 + status = inb(fd->base + SCSI_Status); 289 + if (!(status & 0x01)) { 290 + /* Try again, for slow devices */ 291 + if (fdomain_select(cmd->device->host, scmd_id(cmd))) { 292 + fdomain_finish_cmd(fd, DID_NO_CONNECT << 16); 293 + goto out; 294 + } 295 + /* Stop arbitration and enable parity */ 296 + outb(0x10 | PARITY_MASK, fd->base + TMC_Cntl); 297 + } 298 + cmd->SCp.phase = in_other; 299 + outb(0x90 | FIFO_COUNT, fd->base + Interrupt_Cntl); 300 + outb(0x80, fd->base + SCSI_Cntl); 301 + goto out; 302 + } 303 + 304 + /* cur_cmd->SCp.phase == in_other: this is the body of the routine */ 305 + status = inb(fd->base + SCSI_Status); 306 + 307 + if (status & 0x10) { /* REQ */ 308 + switch (status & 0x0e) { 309 + case 0x08: /* COMMAND OUT */ 310 + outb(cmd->cmnd[cmd->SCp.sent_command++], 311 + fd->base + Write_SCSI_Data); 312 + break; 313 + case 0x00: /* DATA OUT -- tmc18c50/tmc18c30 only */ 314 + if (fd->chip != tmc1800 && !cmd->SCp.have_data_in) { 315 + cmd->SCp.have_data_in = -1; 316 + outb(0xd0 | PARITY_MASK, fd->base + TMC_Cntl); 317 + } 318 + break; 319 + case 0x04: /* DATA IN -- tmc18c50/tmc18c30 only */ 320 + if (fd->chip != tmc1800 && !cmd->SCp.have_data_in) { 321 + cmd->SCp.have_data_in = 1; 322 + outb(0x90 | PARITY_MASK, fd->base + TMC_Cntl); 323 + } 324 + break; 325 + case 0x0c: /* STATUS IN */ 326 + cmd->SCp.Status = inb(fd->base + Read_SCSI_Data); 327 + break; 328 + case 0x0a: /* MESSAGE OUT */ 329 + outb(MESSAGE_REJECT, fd->base + Write_SCSI_Data); 330 + break; 331 + case 0x0e: /* MESSAGE IN */ 332 + cmd->SCp.Message = inb(fd->base + Read_SCSI_Data); 333 + if (!cmd->SCp.Message) 334 + ++done; 335 + break; 336 + } 337 + } 338 + 339 + if (fd->chip == tmc1800 && !cmd->SCp.have_data_in && 340 + cmd->SCp.sent_command >= cmd->cmd_len) { 341 + if (cmd->sc_data_direction == DMA_TO_DEVICE) { 342 + cmd->SCp.have_data_in = -1; 343 + outb(0xd0 | PARITY_MASK, fd->base + TMC_Cntl); 344 + } else { 345 + cmd->SCp.have_data_in = 1; 346 + outb(0x90 | PARITY_MASK, fd->base + TMC_Cntl); 347 + } 348 + } 349 + 350 + if (cmd->SCp.have_data_in == -1) /* DATA OUT */ 351 + fdomain_write_data(cmd); 352 + 353 + if (cmd->SCp.have_data_in == 1) /* DATA IN */ 354 + fdomain_read_data(cmd); 355 + 356 + if (done) { 357 + fdomain_finish_cmd(fd, (cmd->SCp.Status & 0xff) | 358 + ((cmd->SCp.Message & 0xff) << 8) | 359 + (DID_OK << 16)); 360 + } else { 361 + if (cmd->SCp.phase & disconnect) { 362 + outb(0xd0 | FIFO_COUNT, fd->base + Interrupt_Cntl); 363 + outb(0x00, fd->base + SCSI_Cntl); 364 + } else 365 + outb(0x90 | FIFO_COUNT, fd->base + Interrupt_Cntl); 366 + } 367 + out: 368 + spin_unlock_irqrestore(sh->host_lock, flags); 369 + } 370 + 371 + static irqreturn_t fdomain_irq(int irq, void *dev_id) 372 + { 373 + struct fdomain *fd = dev_id; 374 + 375 + /* Is it our IRQ? */ 376 + if ((inb(fd->base + TMC_Status) & 0x01) == 0) 377 + return IRQ_NONE; 378 + 379 + outb(0x00, fd->base + Interrupt_Cntl); 380 + 381 + /* We usually have one spurious interrupt after each command. */ 382 + if (!fd->cur_cmd) /* Spurious interrupt */ 383 + return IRQ_NONE; 384 + 385 + schedule_work(&fd->work); 386 + 387 + return IRQ_HANDLED; 388 + } 389 + 390 + static int fdomain_queue(struct Scsi_Host *sh, struct scsi_cmnd *cmd) 391 + { 392 + struct fdomain *fd = shost_priv(cmd->device->host); 393 + unsigned long flags; 394 + 395 + cmd->SCp.Status = 0; 396 + cmd->SCp.Message = 0; 397 + cmd->SCp.have_data_in = 0; 398 + cmd->SCp.sent_command = 0; 399 + cmd->SCp.phase = in_arbitration; 400 + scsi_set_resid(cmd, scsi_bufflen(cmd)); 401 + 402 + spin_lock_irqsave(sh->host_lock, flags); 403 + 404 + fd->cur_cmd = cmd; 405 + 406 + fdomain_make_bus_idle(fd); 407 + 408 + /* Start arbitration */ 409 + outb(0x00, fd->base + Interrupt_Cntl); 410 + outb(0x00, fd->base + SCSI_Cntl); /* Disable data drivers */ 411 + outb(BIT(cmd->device->host->this_id), 412 + fd->base + SCSI_Data_NoACK); /* Set our id bit */ 413 + outb(0x20, fd->base + Interrupt_Cntl); 414 + outb(0x14 | PARITY_MASK, fd->base + TMC_Cntl); /* Start arbitration */ 415 + 416 + spin_unlock_irqrestore(sh->host_lock, flags); 417 + 418 + return 0; 419 + } 420 + 421 + static int fdomain_abort(struct scsi_cmnd *cmd) 422 + { 423 + struct Scsi_Host *sh = cmd->device->host; 424 + struct fdomain *fd = shost_priv(sh); 425 + unsigned long flags; 426 + 427 + if (!fd->cur_cmd) 428 + return FAILED; 429 + 430 + spin_lock_irqsave(sh->host_lock, flags); 431 + 432 + fdomain_make_bus_idle(fd); 433 + fd->cur_cmd->SCp.phase |= aborted; 434 + fd->cur_cmd->result = DID_ABORT << 16; 435 + 436 + /* Aborts are not done well. . . */ 437 + fdomain_finish_cmd(fd, DID_ABORT << 16); 438 + spin_unlock_irqrestore(sh->host_lock, flags); 439 + return SUCCESS; 440 + } 441 + 442 + static int fdomain_host_reset(struct scsi_cmnd *cmd) 443 + { 444 + struct Scsi_Host *sh = cmd->device->host; 445 + struct fdomain *fd = shost_priv(sh); 446 + unsigned long flags; 447 + 448 + spin_lock_irqsave(sh->host_lock, flags); 449 + fdomain_reset(fd->base); 450 + spin_unlock_irqrestore(sh->host_lock, flags); 451 + return SUCCESS; 452 + } 453 + 454 + static int fdomain_biosparam(struct scsi_device *sdev, 455 + struct block_device *bdev, sector_t capacity, 456 + int geom[]) 457 + { 458 + unsigned char *p = scsi_bios_ptable(bdev); 459 + 460 + if (p && p[65] == 0xaa && p[64] == 0x55 /* Partition table valid */ 461 + && p[4]) { /* Partition type */ 462 + geom[0] = p[5] + 1; /* heads */ 463 + geom[1] = p[6] & 0x3f; /* sectors */ 464 + } else { 465 + if (capacity >= 0x7e0000) { 466 + geom[0] = 255; /* heads */ 467 + geom[1] = 63; /* sectors */ 468 + } else if (capacity >= 0x200000) { 469 + geom[0] = 128; /* heads */ 470 + geom[1] = 63; /* sectors */ 471 + } else { 472 + geom[0] = 64; /* heads */ 473 + geom[1] = 32; /* sectors */ 474 + } 475 + } 476 + geom[2] = sector_div(capacity, geom[0] * geom[1]); 477 + kfree(p); 478 + 479 + return 0; 480 + } 481 + 482 + static struct scsi_host_template fdomain_template = { 483 + .module = THIS_MODULE, 484 + .name = "Future Domain TMC-16x0", 485 + .proc_name = "fdomain", 486 + .queuecommand = fdomain_queue, 487 + .eh_abort_handler = fdomain_abort, 488 + .eh_host_reset_handler = fdomain_host_reset, 489 + .bios_param = fdomain_biosparam, 490 + .can_queue = 1, 491 + .this_id = 7, 492 + .sg_tablesize = 64, 493 + .dma_boundary = PAGE_SIZE - 1, 494 + }; 495 + 496 + struct Scsi_Host *fdomain_create(int base, int irq, int this_id, 497 + struct device *dev) 498 + { 499 + struct Scsi_Host *sh; 500 + struct fdomain *fd; 501 + enum chip_type chip; 502 + static const char * const chip_names[] = { 503 + "Unknown", "TMC-1800", "TMC-18C50", "TMC-18C30" 504 + }; 505 + 506 + chip = fdomain_identify(base); 507 + if (!chip) 508 + return NULL; 509 + 510 + fdomain_reset(base); 511 + 512 + if (fdomain_test_loopback(base)) 513 + return NULL; 514 + 515 + if (!irq) { 516 + dev_err(dev, "card has no IRQ assigned"); 517 + return NULL; 518 + } 519 + 520 + sh = scsi_host_alloc(&fdomain_template, sizeof(struct fdomain)); 521 + if (!sh) 522 + return NULL; 523 + 524 + if (this_id) 525 + sh->this_id = this_id & 0x07; 526 + 527 + sh->irq = irq; 528 + sh->io_port = base; 529 + sh->n_io_port = FDOMAIN_REGION_SIZE; 530 + 531 + fd = shost_priv(sh); 532 + fd->base = base; 533 + fd->chip = chip; 534 + INIT_WORK(&fd->work, fdomain_work); 535 + 536 + if (request_irq(irq, fdomain_irq, dev_is_pci(dev) ? IRQF_SHARED : 0, 537 + "fdomain", fd)) 538 + goto fail_put; 539 + 540 + shost_printk(KERN_INFO, sh, "%s chip at 0x%x irq %d SCSI ID %d\n", 541 + dev_is_pci(dev) ? "TMC-36C70 (PCI bus)" : chip_names[chip], 542 + base, irq, sh->this_id); 543 + 544 + if (scsi_add_host(sh, dev)) 545 + goto fail_free_irq; 546 + 547 + scsi_scan_host(sh); 548 + 549 + return sh; 550 + 551 + fail_free_irq: 552 + free_irq(irq, fd); 553 + fail_put: 554 + scsi_host_put(sh); 555 + return NULL; 556 + } 557 + EXPORT_SYMBOL_GPL(fdomain_create); 558 + 559 + int fdomain_destroy(struct Scsi_Host *sh) 560 + { 561 + struct fdomain *fd = shost_priv(sh); 562 + 563 + cancel_work_sync(&fd->work); 564 + scsi_remove_host(sh); 565 + if (sh->irq) 566 + free_irq(sh->irq, fd); 567 + scsi_host_put(sh); 568 + return 0; 569 + } 570 + EXPORT_SYMBOL_GPL(fdomain_destroy); 571 + 572 + #ifdef CONFIG_PM_SLEEP 573 + static int fdomain_resume(struct device *dev) 574 + { 575 + struct fdomain *fd = shost_priv(dev_get_drvdata(dev)); 576 + 577 + fdomain_reset(fd->base); 578 + return 0; 579 + } 580 + 581 + static SIMPLE_DEV_PM_OPS(fdomain_pm_ops, NULL, fdomain_resume); 582 + #endif /* CONFIG_PM_SLEEP */ 583 + 584 + MODULE_AUTHOR("Ondrej Zary, Rickard E. Faith"); 585 + MODULE_DESCRIPTION("Future Domain TMC-16x0/TMC-3260 SCSI driver"); 586 + MODULE_LICENSE("GPL");
+53
drivers/scsi/fdomain.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0 */ 2 + 3 + #define FDOMAIN_REGION_SIZE 0x10 4 + #define FDOMAIN_BIOS_SIZE 0x2000 5 + 6 + enum { 7 + in_arbitration = 0x02, 8 + in_selection = 0x04, 9 + in_other = 0x08, 10 + disconnect = 0x10, 11 + aborted = 0x20, 12 + sent_ident = 0x40, 13 + }; 14 + 15 + enum in_port_type { 16 + Read_SCSI_Data = 0, 17 + SCSI_Status = 1, 18 + TMC_Status = 2, 19 + FIFO_Status = 3, /* tmc18c50/tmc18c30 only */ 20 + Interrupt_Cond = 4, /* tmc18c50/tmc18c30 only */ 21 + LSB_ID_Code = 5, 22 + MSB_ID_Code = 6, 23 + Read_Loopback = 7, 24 + SCSI_Data_NoACK = 8, 25 + Interrupt_Status = 9, 26 + Configuration1 = 10, 27 + Configuration2 = 11, /* tmc18c50/tmc18c30 only */ 28 + Read_FIFO = 12, 29 + FIFO_Data_Count = 14 30 + }; 31 + 32 + enum out_port_type { 33 + Write_SCSI_Data = 0, 34 + SCSI_Cntl = 1, 35 + Interrupt_Cntl = 2, 36 + SCSI_Mode_Cntl = 3, 37 + TMC_Cntl = 4, 38 + Memory_Cntl = 5, /* tmc18c50/tmc18c30 only */ 39 + Write_Loopback = 7, 40 + IO_Control = 11, /* tmc18c30 only */ 41 + Write_FIFO = 12 42 + }; 43 + 44 + #ifdef CONFIG_PM_SLEEP 45 + static const struct dev_pm_ops fdomain_pm_ops; 46 + #define FDOMAIN_PM_OPS (&fdomain_pm_ops) 47 + #else 48 + #define FDOMAIN_PM_OPS NULL 49 + #endif /* CONFIG_PM_SLEEP */ 50 + 51 + struct Scsi_Host *fdomain_create(int base, int irq, int this_id, 52 + struct device *dev); 53 + int fdomain_destroy(struct Scsi_Host *sh);