Lines Matching refs:sh

207 static int aha1542_test_port(struct Scsi_Host *sh)
212 if (inb(STATUS(sh->io_port)) == 0xff)
218 aha1542_intr_reset(sh->io_port); /* reset interrupts, so they don't block */
220 outb(SRST | IRST /*|SCRST */ , CONTROL(sh->io_port));
225 if (!wait_mask(STATUS(sh->io_port), STATMASK, INIT | IDLE, STST | DIAGF | INVDCMD | DF | CDF, 0))
229 if (inb(INTRFLAGS(sh->io_port)) & INTRMASK)
237 aha1542_outb(sh->io_port, CMD_INQUIRY);
240 if (!wait_mask(STATUS(sh->io_port), DF, DF, 0, 0))
242 (void)inb(DATA(sh->io_port));
246 if (inb(STATUS(sh->io_port)) & DF)
250 if (!wait_mask(INTRFLAGS(sh->io_port), HACC, HACC, 0, 0))
254 outb(IRST, CONTROL(sh->io_port));
280 struct Scsi_Host *sh = dev_id;
281 struct aha1542_hostdata *aha1542 = shost_priv(sh);
292 flag = inb(INTRFLAGS(sh->io_port));
293 shost_printk(KERN_DEBUG, sh, "aha1542_intr_handle: ");
304 printk("status %02x\n", inb(STATUS(sh->io_port)));
309 spin_lock_irqsave(sh->host_lock, flags);
311 flag = inb(INTRFLAGS(sh->io_port));
327 aha1542_intr_reset(sh->io_port);
342 spin_unlock_irqrestore(sh->host_lock, flags);
345 shost_printk(KERN_WARNING, sh, "interrupt received, but no mail.\n");
356 shost_printk(KERN_DEBUG, sh, "aha1542_command: returning %x (status %d)\n",
364 shost_printk(KERN_DEBUG, sh, "...done %d %d\n", mbo, mbi);
370 spin_unlock_irqrestore(sh->host_lock, flags);
371 shost_printk(KERN_WARNING, sh, "Unexpected interrupt\n");
372 shost_printk(KERN_WARNING, sh, "tarstat=%x, hastat=%x idlun=%x ccb#=%d\n", ccb[mbo].tarstat,
398 shost_printk(KERN_DEBUG, sh, "(aha1542 error:%x %x %x) ", errstatus,
414 static int aha1542_queuecommand(struct Scsi_Host *sh, struct scsi_cmnd *cmd)
417 struct aha1542_hostdata *aha1542 = shost_priv(sh);
440 shost_printk(KERN_DEBUG, sh, "aha1542_queuecommand: dev %d cmd %02x pos %d len %d",
463 spin_lock_irqsave(sh->host_lock, flags);
486 shost_printk(KERN_DEBUG, sh, "Sending command (%d)...", mbo);
520 spin_unlock_irqrestore(sh->host_lock, flags);
526 static void setup_mailboxes(struct Scsi_Host *sh)
528 struct aha1542_hostdata *aha1542 = shost_priv(sh);
538 aha1542_intr_reset(sh->io_port); /* reset interrupts, so they don't block */
540 if (aha1542_out(sh->io_port, mb_cmd, 5))
541 shost_printk(KERN_ERR, sh, "failed setting up mailboxes\n");
542 aha1542_intr_reset(sh->io_port);
545 static int aha1542_getconfig(struct Scsi_Host *sh)
549 i = inb(STATUS(sh->io_port));
551 i = inb(DATA(sh->io_port));
553 aha1542_outb(sh->io_port, CMD_RETCONF);
554 aha1542_in(sh->io_port, inquiry_result, 3, 0);
555 if (!wait_mask(INTRFLAGS(sh->io_port), INTRMASK, HACC, 0, 0))
556 shost_printk(KERN_ERR, sh, "error querying board settings\n");
557 aha1542_intr_reset(sh->io_port);
560 sh->dma_channel = 7;
563 sh->dma_channel = 6;
566 sh->dma_channel = 5;
569 sh->dma_channel = 0;
576 sh->dma_channel = 0xFF;
579 shost_printk(KERN_ERR, sh, "Unable to determine DMA channel.\n");
584 sh->irq = 15;
587 sh->irq = 14;
590 sh->irq = 12;
593 sh->irq = 11;
596 sh->irq = 10;
599 sh->irq = 9;
602 shost_printk(KERN_ERR, sh, "Unable to determine IRQ level.\n");
605 sh->this_id = inquiry_result[2] & 7;
614 static int aha1542_mbenable(struct Scsi_Host *sh)
622 aha1542_outb(sh->io_port, CMD_EXTBIOS);
623 if (aha1542_in(sh->io_port, mbenable_result, 2, 100))
625 if (!wait_mask(INTRFLAGS(sh->io_port), INTRMASK, HACC, 0, 100))
627 aha1542_intr_reset(sh->io_port);
637 if (aha1542_out(sh->io_port, mbenable_cmd, 3))
642 shost_printk(KERN_ERR, sh, "Mailbox init failed\n");
644 aha1542_intr_reset(sh->io_port);
649 static int aha1542_query(struct Scsi_Host *sh)
651 struct aha1542_hostdata *aha1542 = shost_priv(sh);
654 i = inb(STATUS(sh->io_port));
656 i = inb(DATA(sh->io_port));
658 aha1542_outb(sh->io_port, CMD_INQUIRY);
659 aha1542_in(sh->io_port, inquiry_result, 4, 0);
660 if (!wait_mask(INTRFLAGS(sh->io_port), INTRMASK, HACC, 0, 0))
661 shost_printk(KERN_ERR, sh, "error querying card type\n");
662 aha1542_intr_reset(sh->io_port);
674 shost_printk(KERN_INFO, sh, "Emulation mode not supported for AHA-1740 hardware, use aha1740 driver instead.\n");
683 aha1542->bios_translation = aha1542_mbenable(sh);
707 static void aha1542_set_bus_times(struct Scsi_Host *sh, int bus_on, int bus_off, int dma_speed)
712 aha1542_intr_reset(sh->io_port);
713 if (aha1542_out(sh->io_port, oncmd, 2))
720 aha1542_intr_reset(sh->io_port);
721 if (aha1542_out(sh->io_port, offcmd, 2))
728 aha1542_intr_reset(sh->io_port);
729 if (aha1542_out(sh->io_port, dmacmd, 2))
732 aha1542_intr_reset(sh->io_port);
735 shost_printk(KERN_ERR, sh, "setting bus on/off-time failed\n");
736 aha1542_intr_reset(sh->io_port);
744 struct Scsi_Host *sh;
754 sh = scsi_host_alloc(tpnt, sizeof(struct aha1542_hostdata));
755 if (!sh)
757 aha1542 = shost_priv(sh);
759 sh->unique_id = base_io;
760 sh->io_port = base_io;
761 sh->n_io_port = AHA1542_REGION_SIZE;
765 if (!aha1542_test_port(sh))
768 aha1542_set_bus_times(sh, bus_on[indx], bus_off[indx], dma_speed[indx]);
769 if (aha1542_query(sh))
771 if (aha1542_getconfig(sh) == -1)
774 if (sh->dma_channel != 0xFF)
775 snprintf(dma_info, sizeof(dma_info), "DMA %d", sh->dma_channel);
776 shost_printk(KERN_INFO, sh, "Adaptec AHA-1542 (SCSI-ID %d) at IO 0x%x, IRQ %d, %s\n",
777 sh->this_id, base_io, sh->irq, dma_info);
779 shost_printk(KERN_INFO, sh, "Using extended bios translation\n");
796 setup_mailboxes(sh);
798 if (request_irq(sh->irq, aha1542_interrupt, 0, "aha1542", sh)) {
799 shost_printk(KERN_ERR, sh, "Unable to allocate IRQ.\n");
802 if (sh->dma_channel != 0xFF) {
803 if (request_dma(sh->dma_channel, "aha1542")) {
804 shost_printk(KERN_ERR, sh, "Unable to allocate DMA channel.\n");
807 if (sh->dma_channel == 0 || sh->dma_channel >= 5) {
808 set_dma_mode(sh->dma_channel, DMA_MODE_CASCADE);
809 enable_dma(sh->dma_channel);
813 if (scsi_add_host(sh, pdev))
816 scsi_scan_host(sh);
818 return sh;
821 if (sh->dma_channel != 0xff)
822 free_dma(sh->dma_channel);
824 free_irq(sh->irq, sh);
832 scsi_host_put(sh);
839 static int aha1542_release(struct Scsi_Host *sh)
841 struct aha1542_hostdata *aha1542 = shost_priv(sh);
842 struct device *dev = sh->dma_dev;
844 scsi_remove_host(sh);
845 if (sh->dma_channel != 0xff)
846 free_dma(sh->dma_channel);
851 if (sh->irq)
852 free_irq(sh->irq, sh);
853 if (sh->io_port && sh->n_io_port)
854 release_region(sh->io_port, sh->n_io_port);
855 scsi_host_put(sh);
866 struct Scsi_Host *sh = cmd->device->host;
867 struct aha1542_hostdata *aha1542 = shost_priv(sh);
875 spin_lock_irqsave(sh->host_lock, flags);
914 aha1542_outb(sh->io_port, CMD_START_SCSI);
915 spin_unlock_irqrestore(sh->host_lock, flags);
925 struct Scsi_Host *sh = cmd->device->host;
926 struct aha1542_hostdata *aha1542 = shost_priv(sh);
930 spin_lock_irqsave(sh->host_lock, flags);
941 spin_unlock_irqrestore(sh->host_lock, flags);
980 spin_unlock_irqrestore(sh->host_lock, flags);
1055 struct Scsi_Host *sh = aha1542_hw_init(&driver_template, pdev, ndev);
1057 if (!sh)
1060 dev_set_drvdata(pdev, sh);
1090 struct Scsi_Host *sh;
1109 sh = aha1542_hw_init(&driver_template, &pdev->dev, indx);
1110 if (!sh)
1113 pnp_set_drvdata(pdev, sh);