Lines Matching refs:sh
185 static int aha1542_test_port(struct Scsi_Host *sh) in aha1542_test_port() argument
191 if (inb(STATUS(sh->io_port)) == 0xff) in aha1542_test_port()
197 aha1542_intr_reset(sh->io_port); /* reset interrupts, so they don't block */ in aha1542_test_port()
199 outb(SRST | IRST /*|SCRST */ , CONTROL(sh->io_port)); in aha1542_test_port()
204 if (!wait_mask(STATUS(sh->io_port), STATMASK, INIT | IDLE, STST | DIAGF | INVDCMD | DF | CDF, 0)) in aha1542_test_port()
208 if (inb(INTRFLAGS(sh->io_port)) & INTRMASK) in aha1542_test_port()
214 aha1542_outb(sh->io_port, CMD_INQUIRY); in aha1542_test_port()
217 if (!wait_mask(STATUS(sh->io_port), DF, DF, 0, 0)) in aha1542_test_port()
219 inquiry_result[i] = inb(DATA(sh->io_port)); in aha1542_test_port()
223 if (inb(STATUS(sh->io_port)) & DF) in aha1542_test_port()
227 if (!wait_mask(INTRFLAGS(sh->io_port), HACC, HACC, 0, 0)) in aha1542_test_port()
231 outb(IRST, CONTROL(sh->io_port)); in aha1542_test_port()
238 struct Scsi_Host *sh = dev_id; in aha1542_interrupt() local
239 struct aha1542_hostdata *aha1542 = shost_priv(sh); in aha1542_interrupt()
251 flag = inb(INTRFLAGS(sh->io_port)); in aha1542_interrupt()
252 shost_printk(KERN_DEBUG, sh, "aha1542_intr_handle: "); in aha1542_interrupt()
263 printk("status %02x\n", inb(STATUS(sh->io_port))); in aha1542_interrupt()
268 spin_lock_irqsave(sh->host_lock, flags); in aha1542_interrupt()
270 flag = inb(INTRFLAGS(sh->io_port)); in aha1542_interrupt()
284 aha1542_intr_reset(sh->io_port); in aha1542_interrupt()
299 spin_unlock_irqrestore(sh->host_lock, flags); in aha1542_interrupt()
302 shost_printk(KERN_WARNING, sh, "interrupt received, but no mail.\n"); in aha1542_interrupt()
313 shost_printk(KERN_DEBUG, sh, "aha1542_command: returning %x (status %d)\n", in aha1542_interrupt()
321 shost_printk(KERN_DEBUG, sh, "...done %d %d\n", mbo, mbi); in aha1542_interrupt()
327 spin_unlock_irqrestore(sh->host_lock, flags); in aha1542_interrupt()
328 shost_printk(KERN_WARNING, sh, "Unexpected interrupt\n"); in aha1542_interrupt()
329 shost_printk(KERN_WARNING, sh, "tarstat=%x, hastat=%x idlun=%x ccb#=%d\n", ccb[mbo].tarstat, in aha1542_interrupt()
355 shost_printk(KERN_DEBUG, sh, "(aha1542 error:%x %x %x) ", errstatus, in aha1542_interrupt()
370 static int aha1542_queuecommand(struct Scsi_Host *sh, struct scsi_cmnd *cmd) in aha1542_queuecommand() argument
372 struct aha1542_hostdata *aha1542 = shost_priv(sh); in aha1542_queuecommand()
396 shost_printk(KERN_DEBUG, sh, "aha1542_queuecommand: dev %d cmd %02x pos %d len %d", in aha1542_queuecommand()
411 spin_lock_irqsave(sh->host_lock, flags); in aha1542_queuecommand()
433 shost_printk(KERN_DEBUG, sh, "Sending command (%d %p)...", mbo, cmd->scsi_done); in aha1542_queuecommand()
464 shost_printk(KERN_DEBUG, sh, "cptr %p: ", cptr); in aha1542_queuecommand()
484 spin_unlock_irqrestore(sh->host_lock, flags); in aha1542_queuecommand()
490 static void setup_mailboxes(struct Scsi_Host *sh) in setup_mailboxes() argument
492 struct aha1542_hostdata *aha1542 = shost_priv(sh); in setup_mailboxes()
503 aha1542_intr_reset(sh->io_port); /* reset interrupts, so they don't block */ in setup_mailboxes()
505 if (aha1542_out(sh->io_port, mb_cmd, 5)) in setup_mailboxes()
506 shost_printk(KERN_ERR, sh, "failed setting up mailboxes\n"); in setup_mailboxes()
507 aha1542_intr_reset(sh->io_port); in setup_mailboxes()
510 static int aha1542_getconfig(struct Scsi_Host *sh) in aha1542_getconfig() argument
514 i = inb(STATUS(sh->io_port)); in aha1542_getconfig()
516 i = inb(DATA(sh->io_port)); in aha1542_getconfig()
518 aha1542_outb(sh->io_port, CMD_RETCONF); in aha1542_getconfig()
519 aha1542_in(sh->io_port, inquiry_result, 3, 0); in aha1542_getconfig()
520 if (!wait_mask(INTRFLAGS(sh->io_port), INTRMASK, HACC, 0, 0)) in aha1542_getconfig()
521 shost_printk(KERN_ERR, sh, "error querying board settings\n"); in aha1542_getconfig()
522 aha1542_intr_reset(sh->io_port); in aha1542_getconfig()
525 sh->dma_channel = 7; in aha1542_getconfig()
528 sh->dma_channel = 6; in aha1542_getconfig()
531 sh->dma_channel = 5; in aha1542_getconfig()
534 sh->dma_channel = 0; in aha1542_getconfig()
539 sh->dma_channel = 0xFF; in aha1542_getconfig()
542 shost_printk(KERN_ERR, sh, "Unable to determine DMA channel.\n"); in aha1542_getconfig()
547 sh->irq = 15; in aha1542_getconfig()
550 sh->irq = 14; in aha1542_getconfig()
553 sh->irq = 12; in aha1542_getconfig()
556 sh->irq = 11; in aha1542_getconfig()
559 sh->irq = 10; in aha1542_getconfig()
562 sh->irq = 9; in aha1542_getconfig()
565 shost_printk(KERN_ERR, sh, "Unable to determine IRQ level.\n"); in aha1542_getconfig()
568 sh->this_id = inquiry_result[2] & 7; in aha1542_getconfig()
575 static int aha1542_mbenable(struct Scsi_Host *sh) in aha1542_mbenable() argument
583 aha1542_outb(sh->io_port, CMD_EXTBIOS); in aha1542_mbenable()
584 if (aha1542_in(sh->io_port, mbenable_result, 2, 100)) in aha1542_mbenable()
586 if (!wait_mask(INTRFLAGS(sh->io_port), INTRMASK, HACC, 0, 100)) in aha1542_mbenable()
588 aha1542_intr_reset(sh->io_port); in aha1542_mbenable()
598 if (aha1542_out(sh->io_port, mbenable_cmd, 3)) in aha1542_mbenable()
603 shost_printk(KERN_ERR, sh, "Mailbox init failed\n"); in aha1542_mbenable()
605 aha1542_intr_reset(sh->io_port); in aha1542_mbenable()
610 static int aha1542_query(struct Scsi_Host *sh) in aha1542_query() argument
612 struct aha1542_hostdata *aha1542 = shost_priv(sh); in aha1542_query()
615 i = inb(STATUS(sh->io_port)); in aha1542_query()
617 i = inb(DATA(sh->io_port)); in aha1542_query()
619 aha1542_outb(sh->io_port, CMD_INQUIRY); in aha1542_query()
620 aha1542_in(sh->io_port, inquiry_result, 4, 0); in aha1542_query()
621 if (!wait_mask(INTRFLAGS(sh->io_port), INTRMASK, HACC, 0, 0)) in aha1542_query()
622 shost_printk(KERN_ERR, sh, "error querying card type\n"); in aha1542_query()
623 aha1542_intr_reset(sh->io_port); in aha1542_query()
634 …shost_printk(KERN_INFO, sh, "Emulation mode not supported for AHA-1740 hardware, use aha1740 drive… in aha1542_query()
641 aha1542->bios_translation = aha1542_mbenable(sh); in aha1542_query()
665 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
670 aha1542_intr_reset(sh->io_port); in aha1542_set_bus_times()
671 if (aha1542_out(sh->io_port, oncmd, 2)) in aha1542_set_bus_times()
678 aha1542_intr_reset(sh->io_port); in aha1542_set_bus_times()
679 if (aha1542_out(sh->io_port, offcmd, 2)) in aha1542_set_bus_times()
686 aha1542_intr_reset(sh->io_port); in aha1542_set_bus_times()
687 if (aha1542_out(sh->io_port, dmacmd, 2)) in aha1542_set_bus_times()
690 aha1542_intr_reset(sh->io_port); in aha1542_set_bus_times()
693 shost_printk(KERN_ERR, sh, "setting bus on/off-time failed\n"); in aha1542_set_bus_times()
694 aha1542_intr_reset(sh->io_port); in aha1542_set_bus_times()
701 struct Scsi_Host *sh; in aha1542_hw_init() local
711 sh = scsi_host_alloc(tpnt, sizeof(struct aha1542_hostdata)); in aha1542_hw_init()
712 if (!sh) in aha1542_hw_init()
714 aha1542 = shost_priv(sh); in aha1542_hw_init()
716 sh->unique_id = base_io; in aha1542_hw_init()
717 sh->io_port = base_io; in aha1542_hw_init()
718 sh->n_io_port = AHA1542_REGION_SIZE; in aha1542_hw_init()
722 if (!aha1542_test_port(sh)) in aha1542_hw_init()
725 aha1542_set_bus_times(sh, bus_on[indx], bus_off[indx], dma_speed[indx]); in aha1542_hw_init()
726 if (aha1542_query(sh)) in aha1542_hw_init()
728 if (aha1542_getconfig(sh) == -1) in aha1542_hw_init()
731 if (sh->dma_channel != 0xFF) in aha1542_hw_init()
732 snprintf(dma_info, sizeof(dma_info), "DMA %d", sh->dma_channel); in aha1542_hw_init()
733 shost_printk(KERN_INFO, sh, "Adaptec AHA-1542 (SCSI-ID %d) at IO 0x%x, IRQ %d, %s\n", in aha1542_hw_init()
734 sh->this_id, base_io, sh->irq, dma_info); in aha1542_hw_init()
736 shost_printk(KERN_INFO, sh, "Using extended bios translation\n"); in aha1542_hw_init()
738 setup_mailboxes(sh); in aha1542_hw_init()
740 if (request_irq(sh->irq, aha1542_interrupt, 0, "aha1542", sh)) { in aha1542_hw_init()
741 shost_printk(KERN_ERR, sh, "Unable to allocate IRQ.\n"); in aha1542_hw_init()
744 if (sh->dma_channel != 0xFF) { in aha1542_hw_init()
745 if (request_dma(sh->dma_channel, "aha1542")) { in aha1542_hw_init()
746 shost_printk(KERN_ERR, sh, "Unable to allocate DMA channel.\n"); in aha1542_hw_init()
749 if (sh->dma_channel == 0 || sh->dma_channel >= 5) { in aha1542_hw_init()
750 set_dma_mode(sh->dma_channel, DMA_MODE_CASCADE); in aha1542_hw_init()
751 enable_dma(sh->dma_channel); in aha1542_hw_init()
755 if (scsi_add_host(sh, pdev)) in aha1542_hw_init()
758 scsi_scan_host(sh); in aha1542_hw_init()
760 return sh; in aha1542_hw_init()
762 if (sh->dma_channel != 0xff) in aha1542_hw_init()
763 free_dma(sh->dma_channel); in aha1542_hw_init()
765 free_irq(sh->irq, sh); in aha1542_hw_init()
767 scsi_host_put(sh); in aha1542_hw_init()
774 static int aha1542_release(struct Scsi_Host *sh) in aha1542_release() argument
776 scsi_remove_host(sh); in aha1542_release()
777 if (sh->dma_channel != 0xff) in aha1542_release()
778 free_dma(sh->dma_channel); in aha1542_release()
779 if (sh->irq) in aha1542_release()
780 free_irq(sh->irq, sh); in aha1542_release()
781 if (sh->io_port && sh->n_io_port) in aha1542_release()
782 release_region(sh->io_port, sh->n_io_port); in aha1542_release()
783 scsi_host_put(sh); in aha1542_release()
794 struct Scsi_Host *sh = cmd->device->host; in aha1542_dev_reset() local
795 struct aha1542_hostdata *aha1542 = shost_priv(sh); in aha1542_dev_reset()
803 spin_lock_irqsave(sh->host_lock, flags); in aha1542_dev_reset()
840 aha1542_outb(sh->io_port, CMD_START_SCSI); in aha1542_dev_reset()
841 spin_unlock_irqrestore(sh->host_lock, flags); in aha1542_dev_reset()
851 struct Scsi_Host *sh = cmd->device->host; in aha1542_reset() local
852 struct aha1542_hostdata *aha1542 = shost_priv(sh); in aha1542_reset()
856 spin_lock_irqsave(sh->host_lock, flags); in aha1542_reset()
867 spin_unlock_irqrestore(sh->host_lock, flags); in aha1542_reset()
907 spin_unlock_irqrestore(sh->host_lock, flags); in aha1542_reset()
959 struct Scsi_Host *sh = aha1542_hw_init(&driver_template, pdev, ndev); in aha1542_isa_match() local
961 if (!sh) in aha1542_isa_match()
964 dev_set_drvdata(pdev, sh); in aha1542_isa_match()
995 struct Scsi_Host *sh; in aha1542_pnp_probe() local
1012 sh = aha1542_hw_init(&driver_template, &pdev->dev, indx); in aha1542_pnp_probe()
1013 if (!sh) in aha1542_pnp_probe()
1016 pnp_set_drvdata(pdev, sh); in aha1542_pnp_probe()