Lines Matching +full:host +full:- +full:command

4  * Copyright (c) 1994-1998 Initio Corporation
5 * Copyright (c) 2003-2004 Christoph Hellwig
37 * 07/02/98 hl - v.91n Initial drivers.
38 * 09/14/98 hl - v1.01 Support new Kernel.
39 * 09/22/98 hl - v1.01a Support reset.
40 * 09/24/98 hl - v1.01b Fixed reset.
41 * 10/05/98 hl - v1.02 split the source code and release.
42 * 12/19/98 bv - v1.02a Use spinlocks for 2.1.95 and up
43 * 01/31/99 bv - v1.02b Use mdelay instead of waitForPause
44 * 08/08/99 bv - v1.02c Use waitForPause again.
45 * 06/25/02 Doug Ledford <dledford@redhat.com> - v1.02d
46 * - Remove limit on number of controllers
47 * - Port to DMA mapping API
48 * - Clean up interrupt handler registration
49 * - Fix memory leaks
50 * - Fix allocation of scsi host structs and private data
52 * - Port to new probing API
53 * - Fix some more leaks in init failure cases
55 * - merge the two source files
56 * - remove internal queueing code
58 * - Grand cleanup and Linuxisation
72 #include <linux/dma-mapping.h>
85 static struct orc_scb *__orc_alloc_scb(struct orc_host * host);
86 static void inia100_scb_handler(struct orc_host *host, struct orc_scb *scb);
92 /*----------header -------------*/
105 /* -- Host Adapter Structure --- */
110 /* --- SCSI Channel 0 Configuration --- */
118 /* 0x16-0x25 */
121 /* --- SCSI Channel 1 Configuration --- */
129 /* 0x2C-0x3B */
139 static u8 wait_chip_ready(struct orc_host * host) in wait_chip_ready() argument
144 if (inb(host->base + ORC_HCTRL) & HOSTSTOP) /* Wait HOSTSTOP set */ in wait_chip_ready()
151 static u8 wait_firmware_ready(struct orc_host * host) in wait_firmware_ready() argument
156 if (inb(host->base + ORC_HSTUS) & RREADY) /* Wait READY set */ in wait_firmware_ready()
164 static u8 wait_scsi_reset_done(struct orc_host * host) in wait_scsi_reset_done() argument
169 if (!(inb(host->base + ORC_HCTRL) & SCSIRST)) /* Wait SCSIRST done */ in wait_scsi_reset_done()
177 static u8 wait_HDO_off(struct orc_host * host) in wait_HDO_off() argument
182 if (!(inb(host->base + ORC_HCTRL) & HDO)) /* Wait HDO off */ in wait_HDO_off()
190 static u8 wait_hdi_set(struct orc_host * host, u8 * data) in wait_hdi_set() argument
195 if ((*data = inb(host->base + ORC_HSTUS)) & HDI) in wait_hdi_set()
203 static unsigned short orc_read_fwrev(struct orc_host * host) in orc_read_fwrev() argument
208 outb(ORC_CMD_VERSION, host->base + ORC_HDATA); in orc_read_fwrev()
209 outb(HDO, host->base + ORC_HCTRL); in orc_read_fwrev()
210 if (wait_HDO_off(host) == 0) /* Wait HDO off */ in orc_read_fwrev()
213 if (wait_hdi_set(host, &data) == 0) /* Wait HDI set */ in orc_read_fwrev()
215 version = inb(host->base + ORC_HDATA); in orc_read_fwrev()
216 outb(data, host->base + ORC_HSTUS); /* Clear HDI */ in orc_read_fwrev()
218 if (wait_hdi_set(host, &data) == 0) /* Wait HDI set */ in orc_read_fwrev()
220 version |= inb(host->base + ORC_HDATA) << 8; in orc_read_fwrev()
221 outb(data, host->base + ORC_HSTUS); /* Clear HDI */ in orc_read_fwrev()
227 static u8 orc_nv_write(struct orc_host * host, unsigned char address, unsigned char value) in orc_nv_write() argument
229 outb(ORC_CMD_SET_NVM, host->base + ORC_HDATA); /* Write command */ in orc_nv_write()
230 outb(HDO, host->base + ORC_HCTRL); in orc_nv_write()
231 if (wait_HDO_off(host) == 0) /* Wait HDO off */ in orc_nv_write()
234 outb(address, host->base + ORC_HDATA); /* Write address */ in orc_nv_write()
235 outb(HDO, host->base + ORC_HCTRL); in orc_nv_write()
236 if (wait_HDO_off(host) == 0) /* Wait HDO off */ in orc_nv_write()
239 outb(value, host->base + ORC_HDATA); /* Write value */ in orc_nv_write()
240 outb(HDO, host->base + ORC_HCTRL); in orc_nv_write()
241 if (wait_HDO_off(host) == 0) /* Wait HDO off */ in orc_nv_write()
248 static u8 orc_nv_read(struct orc_host * host, u8 address, u8 *ptr) in orc_nv_read() argument
252 outb(ORC_CMD_GET_NVM, host->base + ORC_HDATA); /* Write command */ in orc_nv_read()
253 outb(HDO, host->base + ORC_HCTRL); in orc_nv_read()
254 if (wait_HDO_off(host) == 0) /* Wait HDO off */ in orc_nv_read()
257 outb(address, host->base + ORC_HDATA); /* Write address */ in orc_nv_read()
258 outb(HDO, host->base + ORC_HCTRL); in orc_nv_read()
259 if (wait_HDO_off(host) == 0) /* Wait HDO off */ in orc_nv_read()
262 if (wait_hdi_set(host, &data) == 0) /* Wait HDI set */ in orc_nv_read()
264 *ptr = inb(host->base + ORC_HDATA); in orc_nv_read()
265 outb(data, host->base + ORC_HSTUS); /* Clear HDI */ in orc_nv_read()
272 * orc_exec_scb - Queue an SCB with the HA
273 * @host: host adapter the SCB belongs to
277 static void orc_exec_scb(struct orc_host * host, struct orc_scb * scb) in orc_exec_scb() argument
279 scb->status = ORCSCB_POST; in orc_exec_scb()
280 outb(scb->scbidx, host->base + ORC_PQUEUE); in orc_exec_scb()
285 * se2_rd_all - read SCSI parameters from EEPROM
286 * @host: Host whose EEPROM is being loaded
291 static int se2_rd_all(struct orc_host * host) in se2_rd_all() argument
298 if (orc_nv_read(host, (u8) i, np) == 0) in se2_rd_all()
299 return -1; in se2_rd_all()
302 /*------ Is ckecksum ok ? ------*/ in se2_rd_all()
307 if (nvramp->CheckSum != (u8) chksum) in se2_rd_all()
308 return -1; in se2_rd_all()
313 * se2_update_all - update the EEPROM
314 * @host: Host whose EEPROM is being updated
319 static void se2_update_all(struct orc_host * host) in se2_update_all() argument
334 orc_nv_write(host, (u8) i, *np); in se2_update_all()
339 * read_eeprom - load EEPROM
340 * @host: Host EEPROM to read
342 * Read the EEPROM for a given host. If it is invalid or fails
346 static void read_eeprom(struct orc_host * host) in read_eeprom() argument
348 if (se2_rd_all(host) != 1) { in read_eeprom()
349 se2_update_all(host); /* setup default pattern */ in read_eeprom()
350 se2_rd_all(host); /* load again */ in read_eeprom()
356 * orc_load_firmware - initialise firmware
357 * @host: Host to set up
365 static u8 orc_load_firmware(struct orc_host * host) in orc_load_firmware() argument
375 data = inb(host->base + ORC_GCFG); in orc_load_firmware()
376 outb(data | EEPRG, host->base + ORC_GCFG); /* Enable EEPROM programming */ in orc_load_firmware()
377 outb(0x00, host->base + ORC_EBIOSADR2); in orc_load_firmware()
378 outw(0x0000, host->base + ORC_EBIOSADR0); in orc_load_firmware()
379 if (inb(host->base + ORC_EBIOSDATA) != 0x55) { in orc_load_firmware()
380 outb(data, host->base + ORC_GCFG); /* Disable EEPROM programming */ in orc_load_firmware()
383 outw(0x0001, host->base + ORC_EBIOSADR0); in orc_load_firmware()
384 if (inb(host->base + ORC_EBIOSDATA) != 0xAA) { in orc_load_firmware()
385 outb(data, host->base + ORC_GCFG); /* Disable EEPROM programming */ in orc_load_firmware()
389 outb(PRGMRST | DOWNLOAD, host->base + ORC_RISCCTL); /* Enable SRAM programming */ in orc_load_firmware()
392 outw(0x0010, host->base + ORC_EBIOSADR0); in orc_load_firmware()
393 *data32_ptr = inb(host->base + ORC_EBIOSDATA); /* Read from BIOS */ in orc_load_firmware()
394 outw(0x0011, host->base + ORC_EBIOSADR0); in orc_load_firmware()
395 *(data32_ptr + 1) = inb(host->base + ORC_EBIOSDATA); /* Read from BIOS */ in orc_load_firmware()
396 outw(0x0012, host->base + ORC_EBIOSADR0); in orc_load_firmware()
397 *(data32_ptr + 2) = inb(host->base + ORC_EBIOSDATA); /* Read from BIOS */ in orc_load_firmware()
398 outw(*(data32_ptr + 2), host->base + ORC_EBIOSADR2); in orc_load_firmware()
399 outl(le32_to_cpu(data32), host->base + ORC_FWBASEADR); /* Write FW address */ in orc_load_firmware()
403 udelay(500); /* Required on Sun Ultra 5 ... 350 -> failures */ in orc_load_firmware()
408 outw(bios_addr, host->base + ORC_EBIOSADR0); in orc_load_firmware()
409 *data32_ptr++ = inb(host->base + ORC_EBIOSDATA); /* Read from BIOS */ in orc_load_firmware()
411 outl(le32_to_cpu(data32), host->base + ORC_RISCRAM); /* Write every 4 bytes */ in orc_load_firmware()
418 outb(PRGMRST | DOWNLOAD, host->base + ORC_RISCCTL); /* Reset program count 0 */ in orc_load_firmware()
419 bios_addr -= 0x1000; /* Reset the BIOS address */ in orc_load_firmware()
423 outw(bios_addr, host->base + ORC_EBIOSADR0); in orc_load_firmware()
424 *data32_ptr++ = inb(host->base + ORC_EBIOSDATA); /* Read from BIOS */ in orc_load_firmware()
426 if (inl(host->base + ORC_RISCRAM) != le32_to_cpu(data32)) { in orc_load_firmware()
427 outb(PRGMRST, host->base + ORC_RISCCTL); /* Reset program to 0 */ in orc_load_firmware()
428 outb(data, host->base + ORC_GCFG); /*Disable EEPROM programming */ in orc_load_firmware()
436 outb(PRGMRST, host->base + ORC_RISCCTL); /* Reset program to 0 */ in orc_load_firmware()
437 outb(data, host->base + ORC_GCFG); /* Disable EEPROM programming */ in orc_load_firmware()
442 static void setup_SCBs(struct orc_host * host) in setup_SCBs() argument
450 outb(ORC_MAXQUEUE, host->base + ORC_SCBSIZE); /* Total number of SCBs */ in setup_SCBs()
452 outl(host->scb_phys, host->base + ORC_SCBBASE0); in setup_SCBs()
454 outl(host->scb_phys, host->base + ORC_SCBBASE1); in setup_SCBs()
457 scb = host->scb_virt; in setup_SCBs()
458 escb = host->escb_virt; in setup_SCBs()
461 escb_phys = (host->escb_phys + (sizeof(struct orc_extended_scb) * i)); in setup_SCBs()
462 scb->sg_addr = cpu_to_le32((u32) escb_phys); in setup_SCBs()
463 scb->sense_addr = cpu_to_le32((u32) escb_phys); in setup_SCBs()
464 scb->escb = escb; in setup_SCBs()
465 scb->scbidx = i; in setup_SCBs()
472 * init_alloc_map - initialise allocation map
473 * @host: host map to configure
479 static void init_alloc_map(struct orc_host * host) in init_alloc_map() argument
485 host->allocation_map[i][j] = 0xffffffff; in init_alloc_map()
491 * init_orchid - initialise the host adapter
492 * @host:host adapter to initialise
496 * Returns -1 if the initialisation fails.
499 static int init_orchid(struct orc_host * host) in init_orchid() argument
505 init_alloc_map(host); in init_orchid()
506 outb(0xFF, host->base + ORC_GIMSK); /* Disable all interrupts */ in init_orchid()
508 if (inb(host->base + ORC_HSTUS) & RREADY) { /* Orchid is ready */ in init_orchid()
509 revision = orc_read_fwrev(host); in init_orchid()
511 outb(DEVRST, host->base + ORC_HCTRL); /* Reset Host Adapter */ in init_orchid()
512 if (wait_chip_ready(host) == 0) in init_orchid()
513 return -1; in init_orchid()
514 orc_load_firmware(host); /* Download FW */ in init_orchid()
515 setup_SCBs(host); /* Setup SCB base and SCB Size registers */ in init_orchid()
516 outb(0x00, host->base + ORC_HCTRL); /* clear HOSTSTOP */ in init_orchid()
517 if (wait_firmware_ready(host) == 0) in init_orchid()
518 return -1; in init_orchid()
521 setup_SCBs(host); /* Setup SCB base and SCB Size registers */ in init_orchid()
524 outb(DEVRST, host->base + ORC_HCTRL); /* Reset Host Adapter */ in init_orchid()
525 if (wait_chip_ready(host) == 0) in init_orchid()
526 return -1; in init_orchid()
527 orc_load_firmware(host); /* Download FW */ in init_orchid()
528 setup_SCBs(host); /* Setup SCB base and SCB Size registers */ in init_orchid()
529 outb(HDO, host->base + ORC_HCTRL); /* Do Hardware Reset & */ in init_orchid()
532 if (wait_firmware_ready(host) == 0) /* Wait for firmware ready */ in init_orchid()
533 return -1; in init_orchid()
538 read_eeprom(host); in init_orchid()
540 if (nvramp->revision != 1) in init_orchid()
541 return -1; in init_orchid()
543 host->scsi_id = nvramp->scsi_id; in init_orchid()
544 host->BIOScfg = nvramp->BIOSConfig1; in init_orchid()
545 host->max_targets = MAX_TARGETS; in init_orchid()
546 ptr = (u8 *) & (nvramp->Target00Config); in init_orchid()
548 host->target_flag[i] = *ptr; in init_orchid()
549 host->max_tags[i] = ORC_MAXTAGS; in init_orchid()
552 if (nvramp->SCSI0Config & NCC_BUSRESET) in init_orchid()
553 host->flags |= HCF_SCSI_RESET; in init_orchid()
554 outb(0xFB, host->base + ORC_GIMSK); /* enable RP FIFO interrupt */ in init_orchid()
559 * orc_reset_scsi_bus - perform bus reset
560 * @host: host being reset
565 static int orc_reset_scsi_bus(struct orc_host * host) in orc_reset_scsi_bus() argument
566 { /* I need Host Control Block Information */ in orc_reset_scsi_bus()
569 spin_lock_irqsave(&host->allocation_lock, flags); in orc_reset_scsi_bus()
571 init_alloc_map(host); in orc_reset_scsi_bus()
573 outb(SCSIRST, host->base + ORC_HCTRL); in orc_reset_scsi_bus()
576 if (wait_scsi_reset_done(host) == 0) { in orc_reset_scsi_bus()
577 spin_unlock_irqrestore(&host->allocation_lock, flags); in orc_reset_scsi_bus()
580 spin_unlock_irqrestore(&host->allocation_lock, flags); in orc_reset_scsi_bus()
586 * orc_device_reset - device reset handler
587 * @host: host to reset
588 * @cmd: command causing the reset
595 static int orc_device_reset(struct orc_host * host, struct scsi_cmnd *cmd, unsigned int target) in orc_device_reset() argument
596 { /* I need Host Control Block Information */ in orc_device_reset()
603 spin_lock_irqsave(&(host->allocation_lock), flags); in orc_device_reset()
608 host_scb = host->scb_virt; in orc_device_reset()
612 init_alloc_map(host); in orc_device_reset()
614 /* Find the scb corresponding to the command */ in orc_device_reset()
616 escb = host_scb->escb; in orc_device_reset()
617 if (host_scb->status && escb->srb == cmd) in orc_device_reset()
623 printk(KERN_ERR "Unable to Reset - No SCB Found\n"); in orc_device_reset()
624 spin_unlock_irqrestore(&(host->allocation_lock), flags); in orc_device_reset()
628 /* Allocate a new SCB for the reset command to the firmware */ in orc_device_reset()
629 if ((scb = __orc_alloc_scb(host)) == NULL) { in orc_device_reset()
631 spin_unlock_irqrestore(&(host->allocation_lock), flags); in orc_device_reset()
637 scb->opcode = ORC_BUSDEVRST; in orc_device_reset()
638 scb->target = target; in orc_device_reset()
639 scb->hastat = 0; in orc_device_reset()
640 scb->tastat = 0; in orc_device_reset()
641 scb->status = 0x0; in orc_device_reset()
642 scb->link = 0xFF; in orc_device_reset()
643 scb->reserved0 = 0; in orc_device_reset()
644 scb->reserved1 = 0; in orc_device_reset()
645 scb->xferlen = cpu_to_le32(0); in orc_device_reset()
646 scb->sg_len = cpu_to_le32(0); in orc_device_reset()
648 escb->srb = NULL; in orc_device_reset()
649 escb->srb = cmd; in orc_device_reset()
650 orc_exec_scb(host, scb); /* Start execute SCB */ in orc_device_reset()
651 spin_unlock_irqrestore(&host->allocation_lock, flags); in orc_device_reset()
656 * __orc_alloc_scb - allocate an SCB
657 * @host: host to allocate from
665 static struct orc_scb *__orc_alloc_scb(struct orc_host * host) in __orc_alloc_scb() argument
672 channel = host->index; in __orc_alloc_scb()
675 if ((host->allocation_map[channel][i] >> index) & 0x01) { in __orc_alloc_scb()
676 host->allocation_map[channel][i] &= ~(1 << index); in __orc_alloc_scb()
681 return host->scb_virt + idx; in __orc_alloc_scb()
689 * orc_alloc_scb - allocate an SCB
690 * @host: host to allocate from
696 static struct orc_scb *orc_alloc_scb(struct orc_host * host) in orc_alloc_scb() argument
701 spin_lock_irqsave(&host->allocation_lock, flags); in orc_alloc_scb()
702 scb = __orc_alloc_scb(host); in orc_alloc_scb()
703 spin_unlock_irqrestore(&host->allocation_lock, flags); in orc_alloc_scb()
708 * orc_release_scb - release an SCB
709 * @host: host owning the SCB
713 * calling the SCB must be out of use on both the host and the HA.
716 static void orc_release_scb(struct orc_host *host, struct orc_scb *scb) in orc_release_scb() argument
721 spin_lock_irqsave(&(host->allocation_lock), flags); in orc_release_scb()
722 channel = host->index; /* Channel */ in orc_release_scb()
723 index = scb->scbidx; in orc_release_scb()
726 host->allocation_map[channel][i] |= (1 << index); in orc_release_scb()
727 spin_unlock_irqrestore(&(host->allocation_lock), flags); in orc_release_scb()
731 * orchid_abort_scb - abort a command
733 * Abort a queued command that has been passed to the firmware layer
735 * and it either aborts the command or fails
738 static int orchid_abort_scb(struct orc_host * host, struct orc_scb * scb) in orchid_abort_scb() argument
742 outb(ORC_CMD_ABORT_SCB, host->base + ORC_HDATA); /* Write command */ in orchid_abort_scb()
743 outb(HDO, host->base + ORC_HCTRL); in orchid_abort_scb()
744 if (wait_HDO_off(host) == 0) /* Wait HDO off */ in orchid_abort_scb()
747 outb(scb->scbidx, host->base + ORC_HDATA); /* Write address */ in orchid_abort_scb()
748 outb(HDO, host->base + ORC_HCTRL); in orchid_abort_scb()
749 if (wait_HDO_off(host) == 0) /* Wait HDO off */ in orchid_abort_scb()
752 if (wait_hdi_set(host, &data) == 0) /* Wait HDI set */ in orchid_abort_scb()
754 status = inb(host->base + ORC_HDATA); in orchid_abort_scb()
755 outb(data, host->base + ORC_HSTUS); /* Clear HDI */ in orchid_abort_scb()
757 if (status == 1) /* 0 - Successfully */ in orchid_abort_scb()
758 return 0; /* 1 - Fail */ in orchid_abort_scb()
762 static int inia100_abort_cmd(struct orc_host * host, struct scsi_cmnd *cmd) in inia100_abort_cmd() argument
769 spin_lock_irqsave(&(host->allocation_lock), flags); in inia100_abort_cmd()
771 scb = host->scb_virt; in inia100_abort_cmd()
773 /* Walk the queue until we find the SCB that belongs to the command in inia100_abort_cmd()
778 escb = scb->escb; in inia100_abort_cmd()
779 if (scb->status && escb->srb == cmd) { in inia100_abort_cmd()
780 if (scb->tag_msg == 0) { in inia100_abort_cmd()
784 if (orchid_abort_scb(host, scb)) { in inia100_abort_cmd()
785 escb->srb = NULL; in inia100_abort_cmd()
786 spin_unlock_irqrestore(&host->allocation_lock, flags); in inia100_abort_cmd()
794 spin_unlock_irqrestore(&host->allocation_lock, flags); in inia100_abort_cmd()
799 * orc_interrupt - IRQ processing
800 * @host: Host causing the interrupt
803 * by the host lock. While the controller reports that there are
805 * index into a host address pointer to the scb and call the scb
811 static irqreturn_t orc_interrupt(struct orc_host * host) in orc_interrupt() argument
817 if (inb(host->base + ORC_RQUEUECNT) == 0) in orc_interrupt()
822 scb_index = inb(host->base + ORC_RQUEUE); in orc_interrupt()
824 /* Translate it back to a host pointer */ in orc_interrupt()
825 …scb = (struct orc_scb *) ((unsigned long) host->scb_virt + (unsigned long) (sizeof(struct orc_scb)… in orc_interrupt()
826 scb->status = 0x0; in orc_interrupt()
828 inia100_scb_handler(host, scb); in orc_interrupt()
829 } while (inb(host->base + ORC_RQUEUECNT)); in orc_interrupt()
834 * inia100_build_scb - build SCB
835 * @host: host owing the control block
837 * @cmd: Mid layer command
839 * Build a host adapter control block from the SCSI mid layer command
842 static int inia100_build_scb(struct orc_host * host, struct orc_scb * scb, struct scsi_cmnd * cmd) in inia100_build_scb() argument
850 escb = scb->escb; in inia100_build_scb()
851 escb->srb = cmd; in inia100_build_scb()
854 /* Set up the SCB to do a SCSI command block */ in inia100_build_scb()
855 scb->opcode = ORC_EXECSCSI; in inia100_build_scb()
856 scb->flags = SCF_NO_DCHK; /* Clear done bit */ in inia100_build_scb()
857 scb->target = cmd->device->id; in inia100_build_scb()
858 scb->lun = cmd->device->lun; in inia100_build_scb()
859 scb->reserved0 = 0; in inia100_build_scb()
860 scb->reserved1 = 0; in inia100_build_scb()
861 scb->sg_len = cpu_to_le32(0); in inia100_build_scb()
863 scb->xferlen = cpu_to_le32((u32) scsi_bufflen(cmd)); in inia100_build_scb()
864 sgent = (struct orc_sgent *) & escb->sglist[0]; in inia100_build_scb()
873 scb->sg_len = cpu_to_le32((u32) (count_sg * 8)); in inia100_build_scb()
875 sgent->base = cpu_to_le32((u32) sg_dma_address(sg)); in inia100_build_scb()
876 sgent->length = cpu_to_le32((u32) sg_dma_len(sg)); in inia100_build_scb()
880 scb->sg_len = cpu_to_le32(0); in inia100_build_scb()
881 sgent->base = cpu_to_le32(0); in inia100_build_scb()
882 sgent->length = cpu_to_le32(0); in inia100_build_scb()
884 scb->sg_addr = (u32) scb->sense_addr; /* sense_addr is already little endian */ in inia100_build_scb()
885 scb->hastat = 0; in inia100_build_scb()
886 scb->tastat = 0; in inia100_build_scb()
887 scb->link = 0xFF; in inia100_build_scb()
888 scb->sense_len = SENSE_SIZE; in inia100_build_scb()
889 scb->cdb_len = cmd->cmd_len; in inia100_build_scb()
890 if (scb->cdb_len >= IMAX_CDB) { in inia100_build_scb()
891 printk("max cdb length= %x\n", cmd->cmd_len); in inia100_build_scb()
892 scb->cdb_len = IMAX_CDB; in inia100_build_scb()
894 scb->ident = (u8)(cmd->device->lun & 0xff) | DISC_ALLOW; in inia100_build_scb()
895 if (cmd->device->tagged_supported) { /* Tag Support */ in inia100_build_scb()
896 scb->tag_msg = SIMPLE_QUEUE_TAG; /* Do simple tag only */ in inia100_build_scb()
898 scb->tag_msg = 0; /* No tag support */ in inia100_build_scb()
900 memcpy(scb->cdb, cmd->cmnd, scb->cdb_len); in inia100_build_scb()
905 * inia100_queue_lck - queue command with host
906 * @cmd: Command block
908 * Called by the mid layer to queue a command. Process the command
909 * block, build the host specific scb structures and if there is room
910 * queue the command down to the controller
915 struct orc_host *host; /* Point to Host adapter control block */ in inia100_queue_lck() local
917 host = (struct orc_host *) cmd->device->host->hostdata; in inia100_queue_lck()
919 if ((scb = orc_alloc_scb(host)) == NULL) in inia100_queue_lck()
922 if (inia100_build_scb(host, scb, cmd)) { in inia100_queue_lck()
923 orc_release_scb(host, scb); in inia100_queue_lck()
926 orc_exec_scb(host, scb); /* Start execute SCB */ in inia100_queue_lck()
934 Description : Abort a queued command. in DEF_SCSI_QCMD()
936 Input : host - Pointer to host adapter structure in DEF_SCSI_QCMD()
938 Return : pSRB - Pointer to SCSI request block. in DEF_SCSI_QCMD()
942 struct orc_host *host; in DEF_SCSI_QCMD() local
944 host = (struct orc_host *) cmd->device->host->hostdata; in DEF_SCSI_QCMD()
945 return inia100_abort_cmd(host, cmd); in DEF_SCSI_QCMD()
952 Input : host - Pointer to host adapter structure
954 Return : pSRB - Pointer to SCSI request block.
957 { /* I need Host Control Block Information */ in inia100_bus_reset()
958 struct orc_host *host; in inia100_bus_reset() local
959 host = (struct orc_host *) cmd->device->host->hostdata; in inia100_bus_reset()
960 return orc_reset_scsi_bus(host); in inia100_bus_reset()
966 Input : host - Pointer to host adapter structure
968 Return : pSRB - Pointer to SCSI request block.
971 { /* I need Host Control Block Information */ in inia100_device_reset()
972 struct orc_host *host; in inia100_device_reset() local
973 host = (struct orc_host *) cmd->device->host->hostdata; in inia100_device_reset()
974 return orc_device_reset(host, cmd, scmd_id(cmd)); in inia100_device_reset()
979 * inia100_scb_handler - interrupt callback
980 * @host: Host causing the interrupt
984 * from host to SCSI midlayer error coding, save any sense data and
988 static void inia100_scb_handler(struct orc_host *host, struct orc_scb *scb) in inia100_scb_handler() argument
993 escb = scb->escb; in inia100_scb_handler()
994 if ((cmd = (struct scsi_cmnd *) escb->srb) == NULL) { in inia100_scb_handler()
996 orc_release_scb(host, scb); /* Release SCB for current channel */ in inia100_scb_handler()
999 escb->srb = NULL; in inia100_scb_handler()
1001 switch (scb->hastat) { in inia100_scb_handler()
1003 case 0xa: /* Linked command complete without error and linked normally */ in inia100_scb_handler()
1004 case 0xb: /* Linked command complete without error interrupt generated */ in inia100_scb_handler()
1005 scb->hastat = 0; in inia100_scb_handler()
1008 case 0x11: /* Selection time out-The initiator selection or target in inia100_scb_handler()
1010 scb->hastat = DID_TIME_OUT; in inia100_scb_handler()
1013 case 0x14: /* Target bus phase sequence failure-An invalid bus phase or bus in inia100_scb_handler()
1014 phase sequence was requested by the target. The host adapter in inia100_scb_handler()
1015 will generate a SCSI Reset Condition, notifying the host with in inia100_scb_handler()
1017 scb->hastat = DID_RESET; in inia100_scb_handler()
1021 scb->hastat = DID_ABORT; in inia100_scb_handler()
1024 case 0x12: /* Data overrun/underrun-The target attempted to transfer more data in inia100_scb_handler()
1027 case 0x13: /* Unexpected bus free-The target dropped the SCSI BSY at an unexpected time. */ in inia100_scb_handler()
1028 case 0x16: /* Invalid CCB Operation Code-The first byte of the CCB was invalid. */ in inia100_scb_handler()
1031 printk(KERN_DEBUG "inia100: %x %x\n", scb->hastat, scb->tastat); in inia100_scb_handler()
1032 scb->hastat = DID_ERROR; /* Couldn't find any better */ in inia100_scb_handler()
1036 if (scb->tastat == 2) { /* Check condition */ in inia100_scb_handler()
1037 memcpy((unsigned char *) &cmd->sense_buffer[0], in inia100_scb_handler()
1038 (unsigned char *) &escb->sglist[0], SENSE_SIZE); in inia100_scb_handler()
1040 cmd->result = scb->tastat | (scb->hastat << 16); in inia100_scb_handler()
1043 orc_release_scb(host, scb); /* Release SCB for current channel */ in inia100_scb_handler()
1047 * inia100_intr - interrupt handler
1049 * @devid: Host adapter
1057 struct orc_host *host = (struct orc_host *)shost->hostdata; in inia100_intr() local
1061 spin_lock_irqsave(shost->host_lock, flags); in inia100_intr()
1062 res = orc_interrupt(host); in inia100_intr()
1063 spin_unlock_irqrestore(shost->host_lock, flags); in inia100_intr()
1084 struct orc_host *host; in inia100_probe_one() local
1086 int error = -ENODEV; in inia100_probe_one()
1091 if (dma_set_mask(&pdev->dev, DMA_BIT_MASK(32))) { in inia100_probe_one()
1113 host = (struct orc_host *)shost->hostdata; in inia100_probe_one()
1114 host->pdev = pdev; in inia100_probe_one()
1115 host->base = port; in inia100_probe_one()
1116 host->BIOScfg = bios; in inia100_probe_one()
1117 spin_lock_init(&host->allocation_lock); in inia100_probe_one()
1121 host->scb_virt = dma_alloc_coherent(&pdev->dev, sz, &host->scb_phys, in inia100_probe_one()
1123 if (!host->scb_virt) { in inia100_probe_one()
1130 host->escb_virt = dma_alloc_coherent(&pdev->dev, sz, &host->escb_phys, in inia100_probe_one()
1132 if (!host->escb_virt) { in inia100_probe_one()
1137 if (init_orchid(host)) { /* Initialize orchid chip */ in inia100_probe_one()
1142 shost->io_port = host->base; in inia100_probe_one()
1143 shost->n_io_port = 0xff; in inia100_probe_one()
1144 shost->can_queue = ORC_MAXQUEUE; in inia100_probe_one()
1145 shost->unique_id = shost->io_port; in inia100_probe_one()
1146 shost->max_id = host->max_targets; in inia100_probe_one()
1147 shost->max_lun = 16; in inia100_probe_one()
1148 shost->irq = pdev->irq; in inia100_probe_one()
1149 shost->this_id = host->scsi_id; /* Assign HCS index */ in inia100_probe_one()
1150 shost->sg_tablesize = TOTAL_SG_ENTRY; in inia100_probe_one()
1153 error = request_irq(pdev->irq, inia100_intr, IRQF_SHARED, in inia100_probe_one()
1157 pdev->irq); in inia100_probe_one()
1163 error = scsi_add_host(shost, &pdev->dev); in inia100_probe_one()
1171 free_irq(shost->irq, shost); in inia100_probe_one()
1173 dma_free_coherent(&pdev->dev, in inia100_probe_one()
1175 host->escb_virt, host->escb_phys); in inia100_probe_one()
1177 dma_free_coherent(&pdev->dev, in inia100_probe_one()
1179 host->scb_virt, host->scb_phys); in inia100_probe_one()
1193 struct orc_host *host = (struct orc_host *)shost->hostdata; in inia100_remove_one() local
1197 free_irq(shost->irq, shost); in inia100_remove_one()
1198 dma_free_coherent(&pdev->dev, in inia100_remove_one()
1200 host->escb_virt, host->escb_phys); in inia100_remove_one()
1201 dma_free_coherent(&pdev->dev, in inia100_remove_one()
1203 host->scb_virt, host->scb_phys); in inia100_remove_one()
1204 release_region(shost->io_port, 256); in inia100_remove_one()