Lines Matching full: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()
415 spin_lock_irqsave(sh->host_lock, flags); in aha1542_queuecommand()
437 shost_printk(KERN_DEBUG, sh, "Sending command (%d %p)...", mbo, cmd->scsi_done); in aha1542_queuecommand()
468 shost_printk(KERN_DEBUG, sh, "cptr %p: ", cptr); in aha1542_queuecommand()
488 spin_unlock_irqrestore(sh->host_lock, flags); in aha1542_queuecommand()
494 static void setup_mailboxes(struct Scsi_Host *sh) in setup_mailboxes() argument
496 struct aha1542_hostdata *aha1542 = shost_priv(sh); in setup_mailboxes()
507 aha1542_intr_reset(sh->io_port); /* reset interrupts, so they don't block */ in setup_mailboxes()
509 if (aha1542_out(sh->io_port, mb_cmd, 5)) in setup_mailboxes()
510 shost_printk(KERN_ERR, sh, "failed setting up mailboxes\n"); in setup_mailboxes()
511 aha1542_intr_reset(sh->io_port); in setup_mailboxes()
514 static int aha1542_getconfig(struct Scsi_Host *sh) in aha1542_getconfig() argument
518 i = inb(STATUS(sh->io_port)); in aha1542_getconfig()
520 i = inb(DATA(sh->io_port)); in aha1542_getconfig()
522 aha1542_outb(sh->io_port, CMD_RETCONF); in aha1542_getconfig()
523 aha1542_in(sh->io_port, inquiry_result, 3, 0); in aha1542_getconfig()
524 if (!wait_mask(INTRFLAGS(sh->io_port), INTRMASK, HACC, 0, 0)) in aha1542_getconfig()
525 shost_printk(KERN_ERR, sh, "error querying board settings\n"); in aha1542_getconfig()
526 aha1542_intr_reset(sh->io_port); in aha1542_getconfig()
529 sh->dma_channel = 7; in aha1542_getconfig()
532 sh->dma_channel = 6; in aha1542_getconfig()
535 sh->dma_channel = 5; in aha1542_getconfig()
538 sh->dma_channel = 0; in aha1542_getconfig()
543 sh->dma_channel = 0xFF; in aha1542_getconfig()
546 shost_printk(KERN_ERR, sh, "Unable to determine DMA channel.\n"); in aha1542_getconfig()
551 sh->irq = 15; in aha1542_getconfig()
554 sh->irq = 14; in aha1542_getconfig()
557 sh->irq = 12; in aha1542_getconfig()
560 sh->irq = 11; in aha1542_getconfig()
563 sh->irq = 10; in aha1542_getconfig()
566 sh->irq = 9; in aha1542_getconfig()
569 shost_printk(KERN_ERR, sh, "Unable to determine IRQ level.\n"); in aha1542_getconfig()
572 sh->this_id = inquiry_result[2] & 7; in aha1542_getconfig()
579 static int aha1542_mbenable(struct Scsi_Host *sh) in aha1542_mbenable() argument
587 aha1542_outb(sh->io_port, CMD_EXTBIOS); in aha1542_mbenable()
588 if (aha1542_in(sh->io_port, mbenable_result, 2, 100)) in aha1542_mbenable()
590 if (!wait_mask(INTRFLAGS(sh->io_port), INTRMASK, HACC, 0, 100)) in aha1542_mbenable()
592 aha1542_intr_reset(sh->io_port); in aha1542_mbenable()
602 if (aha1542_out(sh->io_port, mbenable_cmd, 3)) in aha1542_mbenable()
607 shost_printk(KERN_ERR, sh, "Mailbox init failed\n"); in aha1542_mbenable()
609 aha1542_intr_reset(sh->io_port); in aha1542_mbenable()
614 static int aha1542_query(struct Scsi_Host *sh) in aha1542_query() argument
616 struct aha1542_hostdata *aha1542 = shost_priv(sh); in aha1542_query()
619 i = inb(STATUS(sh->io_port)); in aha1542_query()
621 i = inb(DATA(sh->io_port)); in aha1542_query()
623 aha1542_outb(sh->io_port, CMD_INQUIRY); in aha1542_query()
624 aha1542_in(sh->io_port, inquiry_result, 4, 0); in aha1542_query()
625 if (!wait_mask(INTRFLAGS(sh->io_port), INTRMASK, HACC, 0, 0)) in aha1542_query()
626 shost_printk(KERN_ERR, sh, "error querying card type\n"); in aha1542_query()
627 aha1542_intr_reset(sh->io_port); in aha1542_query()
638 …shost_printk(KERN_INFO, sh, "Emulation mode not supported for AHA-1740 hardware, use aha1740 drive… in aha1542_query()
645 aha1542->bios_translation = aha1542_mbenable(sh); in aha1542_query()
669 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
674 aha1542_intr_reset(sh->io_port); in aha1542_set_bus_times()
675 if (aha1542_out(sh->io_port, oncmd, 2)) in aha1542_set_bus_times()
682 aha1542_intr_reset(sh->io_port); in aha1542_set_bus_times()
683 if (aha1542_out(sh->io_port, offcmd, 2)) in aha1542_set_bus_times()
690 aha1542_intr_reset(sh->io_port); in aha1542_set_bus_times()
691 if (aha1542_out(sh->io_port, dmacmd, 2)) in aha1542_set_bus_times()
694 aha1542_intr_reset(sh->io_port); in aha1542_set_bus_times()
697 shost_printk(KERN_ERR, sh, "setting bus on/off-time failed\n"); in aha1542_set_bus_times()
698 aha1542_intr_reset(sh->io_port); in aha1542_set_bus_times()
705 struct Scsi_Host *sh; in aha1542_hw_init() local
715 sh = scsi_host_alloc(tpnt, sizeof(struct aha1542_hostdata)); in aha1542_hw_init()
716 if (!sh) in aha1542_hw_init()
718 aha1542 = shost_priv(sh); in aha1542_hw_init()
720 sh->unique_id = base_io; in aha1542_hw_init()
721 sh->io_port = base_io; in aha1542_hw_init()
722 sh->n_io_port = AHA1542_REGION_SIZE; in aha1542_hw_init()
726 if (!aha1542_test_port(sh)) in aha1542_hw_init()
729 aha1542_set_bus_times(sh, bus_on[indx], bus_off[indx], dma_speed[indx]); in aha1542_hw_init()
730 if (aha1542_query(sh)) in aha1542_hw_init()
732 if (aha1542_getconfig(sh) == -1) in aha1542_hw_init()
735 if (sh->dma_channel != 0xFF) in aha1542_hw_init()
736 snprintf(dma_info, sizeof(dma_info), "DMA %d", sh->dma_channel); in aha1542_hw_init()
737 shost_printk(KERN_INFO, sh, "Adaptec AHA-1542 (SCSI-ID %d) at IO 0x%x, IRQ %d, %s\n", in aha1542_hw_init()
738 sh->this_id, base_io, sh->irq, dma_info); in aha1542_hw_init()
740 shost_printk(KERN_INFO, sh, "Using extended bios translation\n"); in aha1542_hw_init()
742 setup_mailboxes(sh); in aha1542_hw_init()
744 if (request_irq(sh->irq, aha1542_interrupt, 0, "aha1542", sh)) { in aha1542_hw_init()
745 shost_printk(KERN_ERR, sh, "Unable to allocate IRQ.\n"); in aha1542_hw_init()
748 if (sh->dma_channel != 0xFF) { in aha1542_hw_init()
749 if (request_dma(sh->dma_channel, "aha1542")) { in aha1542_hw_init()
750 shost_printk(KERN_ERR, sh, "Unable to allocate DMA channel.\n"); in aha1542_hw_init()
753 if (sh->dma_channel == 0 || sh->dma_channel >= 5) { in aha1542_hw_init()
754 set_dma_mode(sh->dma_channel, DMA_MODE_CASCADE); in aha1542_hw_init()
755 enable_dma(sh->dma_channel); in aha1542_hw_init()
759 if (scsi_add_host(sh, pdev)) in aha1542_hw_init()
762 scsi_scan_host(sh); in aha1542_hw_init()
764 return sh; in aha1542_hw_init()
766 if (sh->dma_channel != 0xff) in aha1542_hw_init()
767 free_dma(sh->dma_channel); in aha1542_hw_init()
769 free_irq(sh->irq, sh); in aha1542_hw_init()
771 scsi_host_put(sh); in aha1542_hw_init()
778 static int aha1542_release(struct Scsi_Host *sh) in aha1542_release() argument
780 scsi_remove_host(sh); in aha1542_release()
781 if (sh->dma_channel != 0xff) in aha1542_release()
782 free_dma(sh->dma_channel); in aha1542_release()
783 if (sh->irq) in aha1542_release()
784 free_irq(sh->irq, sh); in aha1542_release()
785 if (sh->io_port && sh->n_io_port) in aha1542_release()
786 release_region(sh->io_port, sh->n_io_port); in aha1542_release()
787 scsi_host_put(sh); in aha1542_release()
798 struct Scsi_Host *sh = cmd->device->host; in aha1542_dev_reset() local
799 struct aha1542_hostdata *aha1542 = shost_priv(sh); in aha1542_dev_reset()
807 spin_lock_irqsave(sh->host_lock, flags); in aha1542_dev_reset()
844 aha1542_outb(sh->io_port, CMD_START_SCSI); in aha1542_dev_reset()
845 spin_unlock_irqrestore(sh->host_lock, flags); in aha1542_dev_reset()
855 struct Scsi_Host *sh = cmd->device->host; in aha1542_reset() local
856 struct aha1542_hostdata *aha1542 = shost_priv(sh); in aha1542_reset()
860 spin_lock_irqsave(sh->host_lock, flags); in aha1542_reset()
871 spin_unlock_irqrestore(sh->host_lock, flags); in aha1542_reset()
911 spin_unlock_irqrestore(sh->host_lock, flags); in aha1542_reset()
963 struct Scsi_Host *sh = aha1542_hw_init(&driver_template, pdev, ndev); in aha1542_isa_match() local
965 if (!sh) in aha1542_isa_match()
968 dev_set_drvdata(pdev, sh); in aha1542_isa_match()
999 struct Scsi_Host *sh; in aha1542_pnp_probe() local
1016 sh = aha1542_hw_init(&driver_template, &pdev->dev, indx); in aha1542_pnp_probe()
1017 if (!sh) in aha1542_pnp_probe()
1020 pnp_set_drvdata(pdev, sh); in aha1542_pnp_probe()