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