Lines Matching full:sh
193 static int aha1542_test_port(struct Scsi_Host *sh) in aha1542_test_port() argument
199 if (inb(STATUS(sh->io_port)) == 0xff) in aha1542_test_port()
205 aha1542_intr_reset(sh->io_port); /* reset interrupts, so they don't block */ in aha1542_test_port()
207 outb(SRST | IRST /*|SCRST */ , CONTROL(sh->io_port)); in aha1542_test_port()
212 if (!wait_mask(STATUS(sh->io_port), STATMASK, INIT | IDLE, STST | DIAGF | INVDCMD | DF | CDF, 0)) in aha1542_test_port()
216 if (inb(INTRFLAGS(sh->io_port)) & INTRMASK) in aha1542_test_port()
222 aha1542_outb(sh->io_port, CMD_INQUIRY); in aha1542_test_port()
225 if (!wait_mask(STATUS(sh->io_port), DF, DF, 0, 0)) in aha1542_test_port()
227 inquiry_result[i] = inb(DATA(sh->io_port)); in aha1542_test_port()
231 if (inb(STATUS(sh->io_port)) & DF) in aha1542_test_port()
235 if (!wait_mask(INTRFLAGS(sh->io_port), HACC, HACC, 0, 0)) in aha1542_test_port()
239 outb(IRST, CONTROL(sh->io_port)); in aha1542_test_port()
261 struct Scsi_Host *sh = dev_id; in aha1542_interrupt() local
262 struct aha1542_hostdata *aha1542 = shost_priv(sh); in aha1542_interrupt()
274 flag = inb(INTRFLAGS(sh->io_port)); in aha1542_interrupt()
275 shost_printk(KERN_DEBUG, sh, "aha1542_intr_handle: "); in aha1542_interrupt()
286 printk("status %02x\n", inb(STATUS(sh->io_port))); in aha1542_interrupt()
291 spin_lock_irqsave(sh->host_lock, flags); in aha1542_interrupt()
293 flag = inb(INTRFLAGS(sh->io_port)); in aha1542_interrupt()
307 aha1542_intr_reset(sh->io_port); in aha1542_interrupt()
322 spin_unlock_irqrestore(sh->host_lock, flags); in aha1542_interrupt()
325 shost_printk(KERN_WARNING, sh, "interrupt received, but no mail.\n"); in aha1542_interrupt()
336 shost_printk(KERN_DEBUG, sh, "aha1542_command: returning %x (status %d)\n", in aha1542_interrupt()
344 shost_printk(KERN_DEBUG, sh, "...done %d %d\n", mbo, mbi); in aha1542_interrupt()
350 spin_unlock_irqrestore(sh->host_lock, flags); in aha1542_interrupt()
351 shost_printk(KERN_WARNING, sh, "Unexpected interrupt\n"); in aha1542_interrupt()
352 shost_printk(KERN_WARNING, sh, "tarstat=%x, hastat=%x idlun=%x ccb#=%d\n", ccb[mbo].tarstat, in aha1542_interrupt()
377 shost_printk(KERN_DEBUG, sh, "(aha1542 error:%x %x %x) ", errstatus, in aha1542_interrupt()
392 static int aha1542_queuecommand(struct Scsi_Host *sh, struct scsi_cmnd *cmd) in aha1542_queuecommand() argument
395 struct aha1542_hostdata *aha1542 = shost_priv(sh); in aha1542_queuecommand()
418 shost_printk(KERN_DEBUG, sh, "aha1542_queuecommand: dev %d cmd %02x pos %d len %d", in aha1542_queuecommand()
430 acmd->chain_handle = dma_map_single(sh->dma_dev, acmd->chain, in aha1542_queuecommand()
432 if (dma_mapping_error(sh->dma_dev, acmd->chain_handle)) in aha1542_queuecommand()
439 spin_lock_irqsave(sh->host_lock, flags); in aha1542_queuecommand()
461 shost_printk(KERN_DEBUG, sh, "Sending command (%d %p)...", mbo, cmd->scsi_done); in aha1542_queuecommand()
491 shost_printk(KERN_DEBUG, sh, "cptr %p: ", acmd->chain); in aha1542_queuecommand()
510 spin_unlock_irqrestore(sh->host_lock, flags); in aha1542_queuecommand()
522 static void setup_mailboxes(struct Scsi_Host *sh) in setup_mailboxes() argument
524 struct aha1542_hostdata *aha1542 = shost_priv(sh); in setup_mailboxes()
534 aha1542_intr_reset(sh->io_port); /* reset interrupts, so they don't block */ in setup_mailboxes()
536 if (aha1542_out(sh->io_port, mb_cmd, 5)) in setup_mailboxes()
537 shost_printk(KERN_ERR, sh, "failed setting up mailboxes\n"); in setup_mailboxes()
538 aha1542_intr_reset(sh->io_port); in setup_mailboxes()
541 static int aha1542_getconfig(struct Scsi_Host *sh) in aha1542_getconfig() argument
545 i = inb(STATUS(sh->io_port)); in aha1542_getconfig()
547 i = inb(DATA(sh->io_port)); in aha1542_getconfig()
549 aha1542_outb(sh->io_port, CMD_RETCONF); in aha1542_getconfig()
550 aha1542_in(sh->io_port, inquiry_result, 3, 0); in aha1542_getconfig()
551 if (!wait_mask(INTRFLAGS(sh->io_port), INTRMASK, HACC, 0, 0)) in aha1542_getconfig()
552 shost_printk(KERN_ERR, sh, "error querying board settings\n"); in aha1542_getconfig()
553 aha1542_intr_reset(sh->io_port); in aha1542_getconfig()
556 sh->dma_channel = 7; in aha1542_getconfig()
559 sh->dma_channel = 6; in aha1542_getconfig()
562 sh->dma_channel = 5; in aha1542_getconfig()
565 sh->dma_channel = 0; in aha1542_getconfig()
570 sh->dma_channel = 0xFF; in aha1542_getconfig()
573 shost_printk(KERN_ERR, sh, "Unable to determine DMA channel.\n"); in aha1542_getconfig()
578 sh->irq = 15; in aha1542_getconfig()
581 sh->irq = 14; in aha1542_getconfig()
584 sh->irq = 12; in aha1542_getconfig()
587 sh->irq = 11; in aha1542_getconfig()
590 sh->irq = 10; in aha1542_getconfig()
593 sh->irq = 9; in aha1542_getconfig()
596 shost_printk(KERN_ERR, sh, "Unable to determine IRQ level.\n"); in aha1542_getconfig()
599 sh->this_id = inquiry_result[2] & 7; in aha1542_getconfig()
606 static int aha1542_mbenable(struct Scsi_Host *sh) in aha1542_mbenable() argument
614 aha1542_outb(sh->io_port, CMD_EXTBIOS); in aha1542_mbenable()
615 if (aha1542_in(sh->io_port, mbenable_result, 2, 100)) in aha1542_mbenable()
617 if (!wait_mask(INTRFLAGS(sh->io_port), INTRMASK, HACC, 0, 100)) in aha1542_mbenable()
619 aha1542_intr_reset(sh->io_port); in aha1542_mbenable()
629 if (aha1542_out(sh->io_port, mbenable_cmd, 3)) in aha1542_mbenable()
634 shost_printk(KERN_ERR, sh, "Mailbox init failed\n"); in aha1542_mbenable()
636 aha1542_intr_reset(sh->io_port); in aha1542_mbenable()
641 static int aha1542_query(struct Scsi_Host *sh) in aha1542_query() argument
643 struct aha1542_hostdata *aha1542 = shost_priv(sh); in aha1542_query()
646 i = inb(STATUS(sh->io_port)); in aha1542_query()
648 i = inb(DATA(sh->io_port)); in aha1542_query()
650 aha1542_outb(sh->io_port, CMD_INQUIRY); in aha1542_query()
651 aha1542_in(sh->io_port, inquiry_result, 4, 0); in aha1542_query()
652 if (!wait_mask(INTRFLAGS(sh->io_port), INTRMASK, HACC, 0, 0)) in aha1542_query()
653 shost_printk(KERN_ERR, sh, "error querying card type\n"); in aha1542_query()
654 aha1542_intr_reset(sh->io_port); in aha1542_query()
665 …shost_printk(KERN_INFO, sh, "Emulation mode not supported for AHA-1740 hardware, use aha1740 drive… in aha1542_query()
672 aha1542->bios_translation = aha1542_mbenable(sh); in aha1542_query()
696 static void aha1542_set_bus_times(struct Scsi_Host *sh, int bus_on, int bus_off, int dma_speed) in aha1542_set_bus_times() argument
701 aha1542_intr_reset(sh->io_port); in aha1542_set_bus_times()
702 if (aha1542_out(sh->io_port, oncmd, 2)) in aha1542_set_bus_times()
709 aha1542_intr_reset(sh->io_port); in aha1542_set_bus_times()
710 if (aha1542_out(sh->io_port, offcmd, 2)) in aha1542_set_bus_times()
717 aha1542_intr_reset(sh->io_port); in aha1542_set_bus_times()
718 if (aha1542_out(sh->io_port, dmacmd, 2)) in aha1542_set_bus_times()
721 aha1542_intr_reset(sh->io_port); in aha1542_set_bus_times()
724 shost_printk(KERN_ERR, sh, "setting bus on/off-time failed\n"); in aha1542_set_bus_times()
725 aha1542_intr_reset(sh->io_port); in aha1542_set_bus_times()
732 struct Scsi_Host *sh; in aha1542_hw_init() local
742 sh = scsi_host_alloc(tpnt, sizeof(struct aha1542_hostdata)); in aha1542_hw_init()
743 if (!sh) in aha1542_hw_init()
745 aha1542 = shost_priv(sh); in aha1542_hw_init()
747 sh->unique_id = base_io; in aha1542_hw_init()
748 sh->io_port = base_io; in aha1542_hw_init()
749 sh->n_io_port = AHA1542_REGION_SIZE; in aha1542_hw_init()
753 if (!aha1542_test_port(sh)) in aha1542_hw_init()
756 aha1542_set_bus_times(sh, bus_on[indx], bus_off[indx], dma_speed[indx]); in aha1542_hw_init()
757 if (aha1542_query(sh)) in aha1542_hw_init()
759 if (aha1542_getconfig(sh) == -1) in aha1542_hw_init()
762 if (sh->dma_channel != 0xFF) in aha1542_hw_init()
763 snprintf(dma_info, sizeof(dma_info), "DMA %d", sh->dma_channel); in aha1542_hw_init()
764 shost_printk(KERN_INFO, sh, "Adaptec AHA-1542 (SCSI-ID %d) at IO 0x%x, IRQ %d, %s\n", in aha1542_hw_init()
765 sh->this_id, base_io, sh->irq, dma_info); in aha1542_hw_init()
767 shost_printk(KERN_INFO, sh, "Using extended bios translation\n"); in aha1542_hw_init()
784 setup_mailboxes(sh); in aha1542_hw_init()
786 if (request_irq(sh->irq, aha1542_interrupt, 0, "aha1542", sh)) { in aha1542_hw_init()
787 shost_printk(KERN_ERR, sh, "Unable to allocate IRQ.\n"); in aha1542_hw_init()
790 if (sh->dma_channel != 0xFF) { in aha1542_hw_init()
791 if (request_dma(sh->dma_channel, "aha1542")) { in aha1542_hw_init()
792 shost_printk(KERN_ERR, sh, "Unable to allocate DMA channel.\n"); in aha1542_hw_init()
795 if (sh->dma_channel == 0 || sh->dma_channel >= 5) { in aha1542_hw_init()
796 set_dma_mode(sh->dma_channel, DMA_MODE_CASCADE); in aha1542_hw_init()
797 enable_dma(sh->dma_channel); in aha1542_hw_init()
801 if (scsi_add_host(sh, pdev)) in aha1542_hw_init()
804 scsi_scan_host(sh); in aha1542_hw_init()
806 return sh; in aha1542_hw_init()
809 if (sh->dma_channel != 0xff) in aha1542_hw_init()
810 free_dma(sh->dma_channel); in aha1542_hw_init()
812 free_irq(sh->irq, sh); in aha1542_hw_init()
820 scsi_host_put(sh); in aha1542_hw_init()
827 static int aha1542_release(struct Scsi_Host *sh) in aha1542_release() argument
829 struct aha1542_hostdata *aha1542 = shost_priv(sh); in aha1542_release()
830 struct device *dev = sh->dma_dev; in aha1542_release()
832 scsi_remove_host(sh); in aha1542_release()
833 if (sh->dma_channel != 0xff) in aha1542_release()
834 free_dma(sh->dma_channel); in aha1542_release()
839 if (sh->irq) in aha1542_release()
840 free_irq(sh->irq, sh); in aha1542_release()
841 if (sh->io_port && sh->n_io_port) in aha1542_release()
842 release_region(sh->io_port, sh->n_io_port); in aha1542_release()
843 scsi_host_put(sh); in aha1542_release()
854 struct Scsi_Host *sh = cmd->device->host; in aha1542_dev_reset() local
855 struct aha1542_hostdata *aha1542 = shost_priv(sh); in aha1542_dev_reset()
863 spin_lock_irqsave(sh->host_lock, flags); in aha1542_dev_reset()
901 aha1542_outb(sh->io_port, CMD_START_SCSI); in aha1542_dev_reset()
902 spin_unlock_irqrestore(sh->host_lock, flags); in aha1542_dev_reset()
912 struct Scsi_Host *sh = cmd->device->host; in aha1542_reset() local
913 struct aha1542_hostdata *aha1542 = shost_priv(sh); in aha1542_reset()
917 spin_lock_irqsave(sh->host_lock, flags); in aha1542_reset()
928 spin_unlock_irqrestore(sh->host_lock, flags); in aha1542_reset()
967 spin_unlock_irqrestore(sh->host_lock, flags); in aha1542_reset()
1019 struct Scsi_Host *sh = aha1542_hw_init(&driver_template, pdev, ndev); in aha1542_isa_match() local
1021 if (!sh) in aha1542_isa_match()
1024 dev_set_drvdata(pdev, sh); in aha1542_isa_match()
1055 struct Scsi_Host *sh; in aha1542_pnp_probe() local
1072 sh = aha1542_hw_init(&driver_template, &pdev->dev, indx); in aha1542_pnp_probe()
1073 if (!sh) in aha1542_pnp_probe()
1076 pnp_set_drvdata(pdev, sh); in aha1542_pnp_probe()