static int mts_scsi_detect (struct SHT * sht) { /* Whole function stolen from usb-storage */ struct mts_desc * desc = (struct mts_desc *)sht->proc_dir; /* What a hideous hack! */ char local_name[48]; MTS_DEBUG_GOT_HERE(); /* set up the name of our subdirectory under /proc/scsi/ */ sprintf(local_name, "microtek-%d", desc->host_number); sht->proc_name = kmalloc (strlen(local_name) + 1, GFP_KERNEL); /* FIXME: where is this freed ? */ if (!sht->proc_name) { MTS_ERROR( "unable to allocate memory for proc interface!!\n" ); return 0; } strcpy(sht->proc_name, local_name); sht->proc_dir = NULL; /* In host->hostdata we store a pointer to desc */ desc->host = scsi_register(sht, sizeof(desc)); desc->host->hostdata[0] = (unsigned long)desc; /* FIXME: what if sizeof(void*) != sizeof(unsigned long)? */ return 1; }
/* detect a virtual adapter (always works) */ static int detect(struct SHT *sht) { struct us_data *us; char local_name[32]; /* Note: this function gets called with io_request_lock spinlock helt! */ /* This is not nice at all, but how else are we to get the * data here? */ us = (struct us_data *)sht->proc_dir; /* set up the name of our subdirectory under /proc/scsi/ */ sprintf(local_name, "usb-storage-%d", us->host_number); sht->proc_name = kmalloc (strlen(local_name) + 1, GFP_ATOMIC); if (!sht->proc_name) return 0; strcpy(sht->proc_name, local_name); /* we start with no /proc directory entry */ sht->proc_dir = NULL; /* register the host */ us->host = scsi_register(sht, sizeof(us)); if (us->host) { us->host->hostdata[0] = (unsigned long)us; us->host_no = us->host->host_no; return 1; } /* odd... didn't register properly. Abort and free pointers */ kfree(sht->proc_name); sht->proc_name = NULL; return 0; }
int a3000_detect(Scsi_Host_Template *tpnt) { static unsigned char called = 0; if (called) return 0; if (!MACH_IS_AMIGA || !AMIGAHW_PRESENT(A3000_SCSI)) return 0; tpnt->proc_dir = &proc_scsi_a3000; tpnt->proc_info = &wd33c93_proc_info; a3000_host = scsi_register (tpnt, sizeof(struct WD33C93_hostdata)); a3000_host->base = (unsigned char *)ZTWO_VADDR(0xDD0000); a3000_host->irq = IRQ_AMIGA_PORTS & ~IRQ_MACHSPEC; DMA(a3000_host)->DAWR = DAWR_A3000; wd33c93_init(a3000_host, (wd33c93_regs *)&(DMA(a3000_host)->SASR), dma_setup, dma_stop, WD33C93_FS_12_15); request_irq(IRQ_AMIGA_PORTS, a3000_intr, 0, "A3000 SCSI", a3000_intr); DMA(a3000_host)->CNTR = CNTR_PDMD | CNTR_INTEN; called = 1; return 1; }
int ecoscsi_detect(Scsi_Host_Template * tpnt) { struct Scsi_Host *instance; tpnt->proc_name = "ecoscsi"; instance = scsi_register (tpnt, sizeof(struct NCR5380_hostdata)); instance->io_port = 0x80ce8000; instance->n_io_port = 144; instance->irq = IRQ_NONE; if (check_region (instance->io_port, instance->n_io_port)) { scsi_unregister (instance); return 0; } ecoscsi_write (instance, MODE_REG, 0x20); /* Is it really SCSI? */ if (ecoscsi_read (instance, MODE_REG) != 0x20) { /* Write to a reg. */ scsi_unregister(instance); return 0; /* and try to read */ } ecoscsi_write( instance, MODE_REG, 0x00 ); /* it back. */ if (ecoscsi_read (instance, MODE_REG) != 0x00) { scsi_unregister(instance); return 0; } NCR5380_init(instance, 0); if (request_region (instance->io_port, instance->n_io_port, "ecoscsi") == NULL) { scsi_unregister(instance); return 0; } if (instance->irq != IRQ_NONE) if (request_irq(instance->irq, do_ecoscsi_intr, SA_INTERRUPT, "ecoscsi", NULL)) { printk("scsi%d: IRQ%d not free, interrupts disabled\n", instance->host_no, instance->irq); instance->irq = IRQ_NONE; } if (instance->irq != IRQ_NONE) { printk("scsi%d: eek! Interrupts enabled, but I don't think\n", instance->host_no); printk("scsi%d: that the board had an interrupt!\n", instance->host_no); } printk("scsi%d: at port %X irq", instance->host_no, instance->io_port); if (instance->irq == IRQ_NONE) printk ("s disabled"); else printk (" %d", instance->irq); printk(" options CAN_QUEUE=%d CMD_PER_LUN=%d release=%d", CAN_QUEUE, CMD_PER_LUN, ECOSCSI_PUBLIC_RELEASE); printk("\nscsi%d:", instance->host_no); NCR5380_print_options(instance); printk("\n"); return 1; }
int oakscsi_detect(Scsi_Host_Template * tpnt) { int count = 0; struct Scsi_Host *instance; tpnt->proc_name = "oakscsi"; memset (ecs, 0, sizeof (ecs)); ecard_startfind (); while(1) { if ((ecs[count] = ecard_find(0, oakscsi_cids)) == NULL) break; instance = scsi_register (tpnt, sizeof(struct NCR5380_hostdata)); instance->io_port = OAK_ADDRESS(ecs[count]); instance->irq = OAK_IRQ(ecs[count]); NCR5380_init(instance, 0); ecard_claim(ecs[count]); instance->n_io_port = 255; request_region (instance->io_port, instance->n_io_port, "Oak SCSI"); if (instance->irq != IRQ_NONE) if (request_irq(instance->irq, do_oakscsi_intr, SA_INTERRUPT, "Oak SCSI", NULL)) { printk("scsi%d: IRQ%d not free, interrupts disabled\n", instance->host_no, instance->irq); instance->irq = IRQ_NONE; } if (instance->irq != IRQ_NONE) { printk("scsi%d: eek! Interrupts enabled, but I don't think\n", instance->host_no); printk("scsi%d: that the board had an interrupt!\n", instance->host_no); } printk("scsi%d: at port %lX irq", instance->host_no, instance->io_port); if (instance->irq == IRQ_NONE) printk ("s disabled"); else printk (" %d", instance->irq); printk(" options CAN_QUEUE=%d CMD_PER_LUN=%d release=%d", tpnt->can_queue, tpnt->cmd_per_lun, OAKSCSI_PUBLIC_RELEASE); printk("\nscsi%d:", instance->host_no); NCR5380_print_options(instance); printk("\n"); ++count; } #ifdef MODULE if(count == 0) printk("No oak scsi devices found\n"); #endif return count; }
int mvme147_detect(struct scsi_host_template *tpnt) { static unsigned char called = 0; struct Scsi_Host *instance; wd33c93_regs regs; struct WD33C93_hostdata *hdata; if (!MACH_IS_MVME147 || called) return 0; called++; tpnt->proc_name = "MVME147"; tpnt->proc_info = &wd33c93_proc_info; instance = scsi_register(tpnt, sizeof(struct WD33C93_hostdata)); if (!instance) goto err_out; instance->base = 0xfffe4000; instance->irq = MVME147_IRQ_SCSI_PORT; regs.SASR = (volatile unsigned char *)0xfffe4000; regs.SCMD = (volatile unsigned char *)0xfffe4001; hdata = shost_priv(instance); hdata->no_sync = 0xff; hdata->fast = 0; hdata->dma_mode = CTRL_DMA; wd33c93_init(instance, regs, dma_setup, dma_stop, WD33C93_FS_8_10); if (request_irq(MVME147_IRQ_SCSI_PORT, mvme147_intr, 0, "MVME147 SCSI PORT", instance)) goto err_unregister; if (request_irq(MVME147_IRQ_SCSI_DMA, mvme147_intr, 0, "MVME147 SCSI DMA", instance)) goto err_free_irq; #if 0 /* Disabled; causes problems booting */ m147_pcc->scsi_interrupt = 0x10; /* Assert SCSI bus reset */ udelay(100); m147_pcc->scsi_interrupt = 0x00; /* Negate SCSI bus reset */ udelay(2000); m147_pcc->scsi_interrupt = 0x40; /* Clear bus reset interrupt */ #endif m147_pcc->scsi_interrupt = 0x09; /* Enable interrupt */ m147_pcc->dma_cntrl = 0x00; /* ensure DMA is stopped */ m147_pcc->dma_intr = 0x89; /* Ack and enable ints */ return 1; err_free_irq: free_irq(MVME147_IRQ_SCSI_PORT, mvme147_intr); err_unregister: scsi_unregister(instance); err_out: return 0; }
static int __init a2091_detect(struct scsi_host_template *tpnt) { static unsigned char called = 0; struct Scsi_Host *instance; unsigned long address; struct zorro_dev *z = NULL; wd33c93_regs regs; int num_a2091 = 0; if (!MACH_IS_AMIGA || called) return 0; called = 1; tpnt->proc_name = "A2091"; tpnt->proc_info = &wd33c93_proc_info; while ((z = zorro_find_device(ZORRO_WILDCARD, z))) { if (z->id != ZORRO_PROD_CBM_A590_A2091_1 && z->id != ZORRO_PROD_CBM_A590_A2091_2) continue; address = z->resource.start; if (!request_mem_region(address, 256, "wd33c93")) continue; instance = scsi_register (tpnt, sizeof (struct WD33C93_hostdata)); if (instance == NULL) goto release; instance->base = ZTWO_VADDR(address); instance->irq = IRQ_AMIGA_PORTS; instance->unique_id = z->slotaddr; DMA(instance)->DAWR = DAWR_A2091; regs.SASR = &(DMA(instance)->SASR); regs.SCMD = &(DMA(instance)->SCMD); HDATA(instance)->no_sync = 0xff; HDATA(instance)->fast = 0; HDATA(instance)->dma_mode = CTRL_DMA; wd33c93_init(instance, regs, dma_setup, dma_stop, WD33C93_FS_8_10); if (request_irq(IRQ_AMIGA_PORTS, a2091_intr, IRQF_SHARED, "A2091 SCSI", instance)) goto unregister; DMA(instance)->CNTR = CNTR_PDMD | CNTR_INTEN; num_a2091++; continue; unregister: scsi_unregister(instance); wd33c93_release(); release: release_mem_region(address, 256); } return num_a2091; }
int cumanascsi_detect(Scsi_Host_Template * tpnt) { int count = 0; struct Scsi_Host *instance; tpnt->proc_name = "CumanaSCSI-1"; memset (ecs, 0, sizeof (ecs)); while(1) { if((ecs[count] = ecard_find(0, cumanascsi_cids)) == NULL) break; instance = scsi_register (tpnt, sizeof(struct NCR5380_hostdata)); instance->io_port = CUMANA_ADDRESS(ecs[count]); instance->irq = CUMANA_IRQ(ecs[count]); NCR5380_init(instance, 0); ecard_claim(ecs[count]); instance->n_io_port = 255; request_region (instance->io_port, instance->n_io_port, "CumanaSCSI-1"); ((struct NCR5380_hostdata *)instance->hostdata)->ctrl = 0; outb(0x00, instance->io_port - 577); if (instance->irq != IRQ_NONE) if (request_irq(instance->irq, do_cumanascsi_intr, SA_INTERRUPT, "CumanaSCSI-1", NULL)) { printk("scsi%d: IRQ%d not free, interrupts disabled\n", instance->host_no, instance->irq); instance->irq = IRQ_NONE; } if (instance->irq == IRQ_NONE) { printk("scsi%d: interrupts not enabled. for better interactive performance,\n", instance->host_no); printk("scsi%d: please jumper the board for a free IRQ.\n", instance->host_no); } printk("scsi%d: at port %lX irq", instance->host_no, instance->io_port); if (instance->irq == IRQ_NONE) printk ("s disabled"); else printk (" %d", instance->irq); printk(" options CAN_QUEUE=%d CMD_PER_LUN=%d release=%d", tpnt->can_queue, tpnt->cmd_per_lun, CUMANASCSI_PUBLIC_RELEASE); printk("\nscsi%d:", instance->host_no); NCR5380_print_options(instance); printk("\n"); ++count; } return count; }
static int __init dmx3191d_detect(Scsi_Host_Template *tmpl) { int boards = 0; struct Scsi_Host *instance = NULL; struct pci_dev *pdev = NULL; tmpl->proc_name = DMX3191D_DRIVER_NAME; while ((pdev = pci_find_device(PCI_VENDOR_ID_DOMEX, PCI_DEVICE_ID_DOMEX_DMX3191D, pdev))) { unsigned long port; if (pci_enable_device(pdev)) continue; port = pci_resource_start (pdev, 0); if (!request_region(port, DMX3191D_REGION, DMX3191D_DRIVER_NAME)) { printk(KERN_ERR "dmx3191: region 0x%lx-0x%lx already reserved\n", port, port + DMX3191D_REGION); continue; } instance = scsi_register(tmpl, sizeof(struct NCR5380_hostdata)); if(instance == NULL) { release_region(port, DMX3191D_REGION); continue; } scsi_set_device(instance, &pdev->dev); instance->io_port = port; instance->irq = pdev->irq; NCR5380_init(instance, FLAG_NO_PSEUDO_DMA | FLAG_DTC3181E); if (request_irq(pdev->irq, dmx3191d_intr, SA_SHIRQ, DMX3191D_DRIVER_NAME, instance)) { printk(KERN_WARNING "dmx3191: IRQ %d not available - switching to polled mode.\n", pdev->irq); /* Steam powered scsi controllers run without an IRQ anyway */ instance->irq = SCSI_IRQ_NONE; } boards++; } return boards; }
int __init a3000_detect(struct scsi_host_template *tpnt) { wd33c93_regs regs; if (!MACH_IS_AMIGA || !AMIGAHW_PRESENT(A3000_SCSI)) return 0; if (!request_mem_region(0xDD0000, 256, "wd33c93")) return 0; tpnt->proc_name = "A3000"; tpnt->proc_info = &wd33c93_proc_info; a3000_host = scsi_register (tpnt, sizeof(struct WD33C93_hostdata)); if (a3000_host == NULL) goto fail_register; a3000_host->base = ZTWO_VADDR(0xDD0000); a3000_host->irq = IRQ_AMIGA_PORTS; DMA(a3000_host)->DAWR = DAWR_A3000; regs.SASR = &(DMA(a3000_host)->SASR); regs.SCMD = &(DMA(a3000_host)->SCMD); HDATA(a3000_host)->no_sync = 0xff; HDATA(a3000_host)->fast = 0; HDATA(a3000_host)->dma_mode = CTRL_DMA; wd33c93_init(a3000_host, regs, dma_setup, dma_stop, WD33C93_FS_12_15); if (request_irq(IRQ_AMIGA_PORTS, a3000_intr, IRQF_SHARED, "A3000 SCSI", a3000_intr)) goto fail_irq; DMA(a3000_host)->CNTR = CNTR_PDMD | CNTR_INTEN; return 1; fail_irq: wd33c93_release(); scsi_unregister(a3000_host); fail_register: release_mem_region(0xDD0000, 256); return 0; }
int sun3scsi_detect(struct scsi_host_template * tpnt) { unsigned long ioaddr; static int called = 0; struct Scsi_Host *instance; /* check that this machine has an onboard 5380 */ switch(idprom->id_machtype) { case SM_SUN3|SM_3_50: case SM_SUN3|SM_3_60: break; default: return 0; } if(called) return 0; tpnt->proc_name = "Sun3 5380 SCSI"; /* setup variables */ tpnt->can_queue = (setup_can_queue > 0) ? setup_can_queue : CAN_QUEUE; tpnt->cmd_per_lun = (setup_cmd_per_lun > 0) ? setup_cmd_per_lun : CMD_PER_LUN; tpnt->sg_tablesize = (setup_sg_tablesize >= 0) ? setup_sg_tablesize : SG_TABLESIZE; if (setup_hostid >= 0) tpnt->this_id = setup_hostid; else { /* use 7 as default */ tpnt->this_id = 7; } ioaddr = (unsigned long)ioremap(IOBASE_SUN3_SCSI, PAGE_SIZE); sun3_scsi_regp = (unsigned char *)ioaddr; dregs = (struct sun3_dma_regs *)(((unsigned char *)ioaddr) + 8); if((udc_regs = dvma_malloc(sizeof(struct sun3_udc_regs))) == NULL) { printk("SUN3 Scsi couldn't allocate DVMA memory!\n"); return 0; } #ifdef OLDDMA if((dmabuf = dvma_malloc_align(SUN3_DVMA_BUFSIZE, 0x10000)) == NULL) { printk("SUN3 Scsi couldn't allocate DVMA memory!\n"); return 0; } #endif #ifdef SUPPORT_TAGS if (setup_use_tagged_queuing < 0) setup_use_tagged_queuing = USE_TAGGED_QUEUING; #endif instance = scsi_register (tpnt, sizeof(struct NCR5380_hostdata)); if(instance == NULL) return 0; default_instance = instance; instance->io_port = (unsigned long) ioaddr; instance->irq = IRQ_SUN3_SCSI; NCR5380_init(instance, 0); instance->n_io_port = 32; ((struct NCR5380_hostdata *)instance->hostdata)->ctrl = 0; if (request_irq(instance->irq, scsi_sun3_intr, 0, "Sun3SCSI-5380", instance)) { #ifndef REAL_DMA printk("scsi%d: IRQ%d not free, interrupts disabled\n", instance->host_no, instance->irq); instance->irq = SCSI_IRQ_NONE; #else printk("scsi%d: IRQ%d not free, bailing out\n", instance->host_no, instance->irq); return 0; #endif } printk("scsi%d: Sun3 5380 at port %lX irq", instance->host_no, instance->io_port); if (instance->irq == SCSI_IRQ_NONE) printk ("s disabled"); else printk (" %d", instance->irq); printk(" options CAN_QUEUE=%d CMD_PER_LUN=%d release=%d", instance->can_queue, instance->cmd_per_lun, SUN3SCSI_PUBLIC_RELEASE); printk("\nscsi%d:", instance->host_no); NCR5380_print_options(instance); printk("\n"); dregs->csr = 0; udelay(SUN3_DMA_DELAY); dregs->csr = CSR_SCSI | CSR_FIFO | CSR_INTR; udelay(SUN3_DMA_DELAY); dregs->fifo_count = 0; called = 1; #ifdef RESET_BOOT sun3_scsi_reset_boot(instance); #endif return 1; }
int atari_scsi_detect (Scsi_Host_Template *host) { static int called = 0; struct Scsi_Host *instance; if (!MACH_IS_ATARI || (!ATARIHW_PRESENT(ST_SCSI) && !ATARIHW_PRESENT(TT_SCSI)) || called) return( 0 ); host->proc_dir = &proc_scsi_atari; atari_scsi_reg_read = IS_A_TT() ? atari_scsi_tt_reg_read : atari_scsi_falcon_reg_read; atari_scsi_reg_write = IS_A_TT() ? atari_scsi_tt_reg_write : atari_scsi_falcon_reg_write; /* setup variables */ host->can_queue = (setup_can_queue > 0) ? setup_can_queue : IS_A_TT() ? ATARI_TT_CAN_QUEUE : ATARI_FALCON_CAN_QUEUE; host->cmd_per_lun = (setup_cmd_per_lun > 0) ? setup_cmd_per_lun : IS_A_TT() ? ATARI_TT_CMD_PER_LUN : ATARI_FALCON_CMD_PER_LUN; /* Force sg_tablesize to 0 on a Falcon! */ host->sg_tablesize = !IS_A_TT() ? ATARI_FALCON_SG_TABLESIZE : (setup_sg_tablesize >= 0) ? setup_sg_tablesize : ATARI_TT_SG_TABLESIZE; if (setup_hostid >= 0) host->this_id = setup_hostid; else { /* use 7 as default */ host->this_id = 7; /* Test if a host id is set in the NVRam */ if (ATARIHW_PRESENT(TT_CLK)) { unsigned char sum = 0, b; int i; /* Make checksum */ for( i = 14; i < 62; ++i ) sum += RTC_READ(i); if (/* NV-Ram checksum valid? */ RTC_READ(62) == sum && RTC_READ(63) == ~sum && /* Arbitration enabled? (for TOS) */ (b = RTC_READ( 30 )) & 0x80) { host->this_id = b & 7; } } } #ifdef SUPPORT_TAGS if (setup_use_tagged_queuing < 0) setup_use_tagged_queuing = DEFAULT_USE_TAGGED_QUEUING; #endif /* If running on a Falcon and if there's TT-Ram (i.e., more than one * memory block, since there's always ST-Ram in a Falcon), then allocate a * STRAM_BUFFER_SIZE byte dribble buffer for transfers from/to alternative * Ram. */ if (MACH_IS_ATARI && ATARIHW_PRESENT(ST_SCSI) && !ATARIHW_PRESENT(EXTD_DMA) && boot_info.num_memory > 1) { atari_dma_buffer = scsi_init_malloc(STRAM_BUFFER_SIZE, GFP_ATOMIC | GFP_DMA); atari_dma_phys_buffer = VTOP( atari_dma_buffer ); atari_dma_orig_addr = 0; } instance = scsi_register (host, sizeof (struct NCR5380_hostdata)); atari_scsi_host = instance; instance->irq = IS_A_TT() ? IRQ_TT_MFP_SCSI : IRQ_MFP_FSCSI; atari_scsi_reset_boot(); NCR5380_init (instance, 0); if (IS_A_TT()) { /* This int is actually "pseudo-slow", i.e. it acts like a slow * interrupt after having cleared the pending flag for the DMA * interrupt. */ add_isr(IRQ_TT_MFP_SCSI, scsi_tt_intr, IRQ_TYPE_SLOW, NULL, "SCSI NCR5380"); tt_mfp.active_edge |= 0x80; /* SCSI int on L->H */ #ifdef REAL_DMA tt_scsi_dma.dma_ctrl = 0; atari_dma_residual = 0; #endif /* REAL_DMA */ if (is_medusa) { /* While the read overruns (described by Drew Eckhardt in * NCR5380.c) never happened on TTs, they do in fact on the Medusa * (This was the cause why SCSI didn't work right for so long * there.) Since handling the overruns slows down a bit, I turned * the #ifdef's into a runtime condition. * * In principle it should be sufficient to do max. 1 byte with * PIO, but there is another problem on the Medusa with the DMA * rest data register. So 'atari_read_overruns' is currently set * to 4 to avoid having transfers that aren't a multiple of 4. If * the rest data bug is fixed, this can be lowered to 1. */ atari_read_overruns = 4; } } else { /* ! IS_A_TT */ /* Nothing to do for the interrupt: the ST-DMA is initialized * already by atari_init_INTS() */ #ifdef REAL_DMA atari_dma_residual = 0; atari_dma_active = 0; atari_dma_stram_mask = (ATARIHW_PRESENT(EXTD_DMA) ? 0x00000000 : 0xff000000); #endif } printk(KERN_INFO "scsi%d: options CAN_QUEUE=%d CMD_PER_LUN=%d SCAT-GAT=%d " #ifdef SUPPORT_TAGS "TAGGED-QUEUING=%s " #endif "HOSTID=%d", instance->host_no, instance->hostt->can_queue, instance->hostt->cmd_per_lun, instance->hostt->sg_tablesize, #ifdef SUPPORT_TAGS setup_use_tagged_queuing ? "yes" : "no", #endif instance->hostt->this_id ); NCR5380_print_options (instance); printk ("\n"); called = 1; return( 1 ); }
int macscsi_detect(struct scsi_host_template * tpnt) { static int called = 0; int flags = 0; struct Scsi_Host *instance; if (!MACH_IS_MAC || called) return( 0 ); if (macintosh_config->scsi_type != MAC_SCSI_OLD) return( 0 ); /* setup variables */ tpnt->can_queue = (setup_can_queue > 0) ? setup_can_queue : CAN_QUEUE; tpnt->cmd_per_lun = (setup_cmd_per_lun > 0) ? setup_cmd_per_lun : CMD_PER_LUN; tpnt->sg_tablesize = (setup_sg_tablesize >= 0) ? setup_sg_tablesize : SG_TABLESIZE; if (setup_hostid >= 0) tpnt->this_id = setup_hostid; else { /* use 7 as default */ tpnt->this_id = 7; } #ifdef SUPPORT_TAGS if (setup_use_tagged_queuing < 0) setup_use_tagged_queuing = USE_TAGGED_QUEUING; #endif /* Once we support multiple 5380s (e.g. DuoDock) we'll do something different here */ instance = scsi_register (tpnt, sizeof(struct NCR5380_hostdata)); #if NDEBUG default_instance = instance; #endif if (macintosh_config->ident == MAC_MODEL_IIFX) { mac_scsi_regp = via1+0x8000; mac_scsi_drq = via1+0xE000; mac_scsi_nodrq = via1+0xC000; /* The IIFX should be able to do true DMA, but pseudo-dma doesn't work */ flags = FLAG_NO_PSEUDO_DMA; } else { mac_scsi_regp = via1+0x10000; mac_scsi_drq = via1+0x6000; mac_scsi_nodrq = via1+0x12000; } if (! setup_use_pdma) flags = FLAG_NO_PSEUDO_DMA; instance->io_port = (unsigned long) mac_scsi_regp; instance->irq = IRQ_MAC_SCSI; #ifdef RESET_BOOT mac_scsi_reset_boot(instance); #endif NCR5380_init(instance, flags); instance->n_io_port = 255; ((struct NCR5380_hostdata *)instance->hostdata)->ctrl = 0; if (instance->irq != SCSI_IRQ_NONE) if (request_irq(instance->irq, NCR5380_intr, IRQ_FLG_SLOW, "ncr5380", instance)) { printk(KERN_WARNING "scsi%d: IRQ%d not free, interrupts disabled\n", instance->host_no, instance->irq); instance->irq = SCSI_IRQ_NONE; } printk(KERN_INFO "scsi%d: generic 5380 at port %lX irq", instance->host_no, instance->io_port); if (instance->irq == SCSI_IRQ_NONE) printk (KERN_INFO "s disabled"); else printk (KERN_INFO " %d", instance->irq); printk(KERN_INFO " options CAN_QUEUE=%d CMD_PER_LUN=%d release=%d", instance->can_queue, instance->cmd_per_lun, MACSCSI_PUBLIC_RELEASE); printk(KERN_INFO "\nscsi%d:", instance->host_no); NCR5380_print_options(instance); printk("\n"); called = 1; return 1; }
static int port_detect \ (unsigned long port_base, unsigned int j, struct scsi_host_template *tpnt) { unsigned char irq, dma_channel, subversion, i; unsigned char in_byte; char *bus_type, dma_name[16]; /* Allowed BIOS base addresses (NULL indicates reserved) */ unsigned long bios_segment_table[8] = { 0, 0xc4000, 0xc8000, 0xcc000, 0xd0000, 0xd4000, 0xd8000, 0xdc000 }; /* Allowed IRQs */ unsigned char interrupt_table[4] = { 15, 14, 11, 10 }; /* Allowed DMA channels for ISA (0 indicates reserved) */ unsigned char dma_channel_table[4] = { 5, 6, 7, 0 }; /* Head/sector mappings */ struct { unsigned char heads; unsigned char sectors; } mapping_table[4] = { { 16, 63 }, { 64, 32 }, { 64, 63 }, { 64, 32 } }; struct config_1 { #if defined(__BIG_ENDIAN_BITFIELD) unsigned char dma_channel: 2, interrupt:2, removable_disks_as_fixed:1, bios_segment: 3; #else unsigned char bios_segment: 3, removable_disks_as_fixed: 1, interrupt: 2, dma_channel: 2; #endif } config_1; struct config_2 { #if defined(__BIG_ENDIAN_BITFIELD) unsigned char tfr_port: 2, bios_drive_number: 1, mapping_mode: 2, ha_scsi_id: 3; #else unsigned char ha_scsi_id: 3, mapping_mode: 2, bios_drive_number: 1, tfr_port: 2; #endif } config_2; char name[16]; sprintf(name, "%s%d", driver_name, j); if (!request_region(port_base, REGION_SIZE, driver_name)) { #if defined(DEBUG_DETECT) printk("%s: address 0x%03lx in use, skipping probe.\n", name, port_base); #endif goto fail; } spin_lock_irq(&driver_lock); if (inb(port_base + REG_PRODUCT_ID1) != PRODUCT_ID1) goto freelock; in_byte = inb(port_base + REG_PRODUCT_ID2); if ((in_byte & 0xf0) != PRODUCT_ID2) goto freelock; *(char *)&config_1 = inb(port_base + REG_CONFIG1); *(char *)&config_2 = inb(port_base + REG_CONFIG2); irq = interrupt_table[config_1.interrupt]; dma_channel = dma_channel_table[config_1.dma_channel]; subversion = (in_byte & 0x0f); /* Board detected, allocate its IRQ */ if (request_irq(irq, do_interrupt_handler, IRQF_DISABLED | ((subversion == ESA) ? IRQF_SHARED : 0), driver_name, (void *) &sha[j])) { printk("%s: unable to allocate IRQ %u, detaching.\n", name, irq); goto freelock; } if (subversion == ISA && request_dma(dma_channel, driver_name)) { printk("%s: unable to allocate DMA channel %u, detaching.\n", name, dma_channel); goto freeirq; } if (have_old_firmware) tpnt->use_clustering = DISABLE_CLUSTERING; spin_unlock_irq(&driver_lock); sh[j] = scsi_register(tpnt, sizeof(struct hostdata)); spin_lock_irq(&driver_lock); if (sh[j] == NULL) { printk("%s: unable to register host, detaching.\n", name); goto freedma; } sh[j]->io_port = port_base; sh[j]->unique_id = port_base; sh[j]->n_io_port = REGION_SIZE; sh[j]->base = bios_segment_table[config_1.bios_segment]; sh[j]->irq = irq; sh[j]->sg_tablesize = MAX_SGLIST; sh[j]->this_id = config_2.ha_scsi_id; sh[j]->can_queue = MAX_MAILBOXES; sh[j]->cmd_per_lun = MAX_CMD_PER_LUN; #if defined(DEBUG_DETECT) { unsigned char sys_mask, lcl_mask; sys_mask = inb(sh[j]->io_port + REG_SYS_MASK); lcl_mask = inb(sh[j]->io_port + REG_LCL_MASK); printk("SYS_MASK 0x%x, LCL_MASK 0x%x.\n", sys_mask, lcl_mask); } #endif /* Probably a bogus host scsi id, set it to the dummy value */ if (sh[j]->this_id == 0) sh[j]->this_id = -1; /* If BIOS is disabled, force enable interrupts */ if (sh[j]->base == 0) outb(CMD_ENA_INTR, sh[j]->io_port + REG_SYS_MASK); memset(HD(j), 0, sizeof(struct hostdata)); HD(j)->heads = mapping_table[config_2.mapping_mode].heads; HD(j)->sectors = mapping_table[config_2.mapping_mode].sectors; HD(j)->subversion = subversion; HD(j)->pdev = NULL; HD(j)->board_number = j; if (have_old_firmware) sh[j]->sg_tablesize = MAX_SAFE_SGLIST; if (HD(j)->subversion == ESA) { sh[j]->unchecked_isa_dma = FALSE; sh[j]->dma_channel = NO_DMA; sprintf(BN(j), "U34F%d", j); bus_type = "VESA"; } else { unsigned long flags; sh[j]->unchecked_isa_dma = TRUE; flags=claim_dma_lock(); disable_dma(dma_channel); clear_dma_ff(dma_channel); set_dma_mode(dma_channel, DMA_MODE_CASCADE); enable_dma(dma_channel); release_dma_lock(flags); sh[j]->dma_channel = dma_channel; sprintf(BN(j), "U14F%d", j); bus_type = "ISA"; } sh[j]->max_channel = MAX_CHANNEL - 1; sh[j]->max_id = MAX_TARGET; sh[j]->max_lun = MAX_LUN; if (HD(j)->subversion == ISA && !board_inquiry(j)) { HD(j)->board_id[40] = 0; if (strcmp(&HD(j)->board_id[32], "06000600")) { printk("%s: %s.\n", BN(j), &HD(j)->board_id[8]); printk("%s: firmware %s is outdated, FW PROM should be 28004-006.\n", BN(j), &HD(j)->board_id[32]); sh[j]->hostt->use_clustering = DISABLE_CLUSTERING; sh[j]->sg_tablesize = MAX_SAFE_SGLIST; } } if (dma_channel == NO_DMA) sprintf(dma_name, "%s", "BMST"); else sprintf(dma_name, "DMA %u", dma_channel); spin_unlock_irq(&driver_lock); for (i = 0; i < sh[j]->can_queue; i++) HD(j)->cp[i].cp_dma_addr = pci_map_single(HD(j)->pdev, &HD(j)->cp[i], sizeof(struct mscp), PCI_DMA_BIDIRECTIONAL); for (i = 0; i < sh[j]->can_queue; i++) if (! ((&HD(j)->cp[i])->sglist = kmalloc( sh[j]->sg_tablesize * sizeof(struct sg_list), (sh[j]->unchecked_isa_dma ? GFP_DMA : 0) | GFP_ATOMIC))) { printk("%s: kmalloc SGlist failed, mbox %d, detaching.\n", BN(j), i); goto release; } if (max_queue_depth > MAX_TAGGED_CMD_PER_LUN) max_queue_depth = MAX_TAGGED_CMD_PER_LUN; if (max_queue_depth < MAX_CMD_PER_LUN) max_queue_depth = MAX_CMD_PER_LUN; if (tag_mode != TAG_DISABLED && tag_mode != TAG_SIMPLE) tag_mode = TAG_ORDERED; if (j == 0) { printk("UltraStor 14F/34F: Copyright (C) 1994-2003 Dario Ballabio.\n"); printk("%s config options -> of:%c, tm:%d, lc:%c, mq:%d, et:%c.\n", driver_name, YESNO(have_old_firmware), tag_mode, YESNO(linked_comm), max_queue_depth, YESNO(ext_tran)); } printk("%s: %s 0x%03lx, BIOS 0x%05x, IRQ %u, %s, SG %d, MB %d.\n", BN(j), bus_type, (unsigned long)sh[j]->io_port, (int)sh[j]->base, sh[j]->irq, dma_name, sh[j]->sg_tablesize, sh[j]->can_queue); if (sh[j]->max_id > 8 || sh[j]->max_lun > 8) printk("%s: wide SCSI support enabled, max_id %u, max_lun %u.\n", BN(j), sh[j]->max_id, sh[j]->max_lun); for (i = 0; i <= sh[j]->max_channel; i++) printk("%s: SCSI channel %u enabled, host target ID %d.\n", BN(j), i, sh[j]->this_id); return TRUE; freedma: if (subversion == ISA) free_dma(dma_channel); freeirq: free_irq(irq, &sha[j]); freelock: spin_unlock_irq(&driver_lock); release_region(port_base, REGION_SIZE); fail: return FALSE; release: u14_34f_release(sh[j]); return FALSE; }
int atari_scsi_detect (Scsi_Host_Template *host) { static int called = 0; struct Scsi_Host *instance; if (!MACH_IS_ATARI || (!ATARIHW_PRESENT(ST_SCSI) && !ATARIHW_PRESENT(TT_SCSI)) || called) return( 0 ); host->proc_name = "Atari"; atari_scsi_reg_read = IS_A_TT() ? atari_scsi_tt_reg_read : atari_scsi_falcon_reg_read; atari_scsi_reg_write = IS_A_TT() ? atari_scsi_tt_reg_write : atari_scsi_falcon_reg_write; /* setup variables */ host->can_queue = (setup_can_queue > 0) ? setup_can_queue : IS_A_TT() ? ATARI_TT_CAN_QUEUE : ATARI_FALCON_CAN_QUEUE; host->cmd_per_lun = (setup_cmd_per_lun > 0) ? setup_cmd_per_lun : IS_A_TT() ? ATARI_TT_CMD_PER_LUN : ATARI_FALCON_CMD_PER_LUN; /* Force sg_tablesize to 0 on a Falcon! */ host->sg_tablesize = !IS_A_TT() ? ATARI_FALCON_SG_TABLESIZE : (setup_sg_tablesize >= 0) ? setup_sg_tablesize : ATARI_TT_SG_TABLESIZE; if (setup_hostid >= 0) host->this_id = setup_hostid; else { /* use 7 as default */ host->this_id = 7; /* Test if a host id is set in the NVRam */ if (ATARIHW_PRESENT(TT_CLK) && nvram_check_checksum()) { unsigned char b = nvram_read_byte( 14 ); /* Arbitration enabled? (for TOS) If yes, use configured host ID */ if (b & 0x80) host->this_id = b & 7; } } #ifdef SUPPORT_TAGS if (setup_use_tagged_queuing < 0) setup_use_tagged_queuing = DEFAULT_USE_TAGGED_QUEUING; #endif #ifdef REAL_DMA /* If running on a Falcon and if there's TT-Ram (i.e., more than one * memory block, since there's always ST-Ram in a Falcon), then allocate a * STRAM_BUFFER_SIZE byte dribble buffer for transfers from/to alternative * Ram. */ if (MACH_IS_ATARI && ATARIHW_PRESENT(ST_SCSI) && !ATARIHW_PRESENT(EXTD_DMA) && m68k_num_memory > 1) { atari_dma_buffer = atari_stram_alloc(STRAM_BUFFER_SIZE, "SCSI"); if (!atari_dma_buffer) { printk( KERN_ERR "atari_scsi_detect: can't allocate ST-RAM " "double buffer\n" ); return( 0 ); } atari_dma_phys_buffer = virt_to_phys( atari_dma_buffer ); atari_dma_orig_addr = 0; } #endif instance = scsi_register (host, sizeof (struct NCR5380_hostdata)); if(instance == NULL) { atari_stram_free(atari_dma_buffer); atari_dma_buffer = 0; return 0; } atari_scsi_host = instance; /* Set irq to 0, to avoid that the mid-level code disables our interrupt * during queue_command calls. This is completely unnecessary, and even * worse causes bad problems on the Falcon, where the int is shared with * IDE and floppy! */ instance->irq = 0; #ifdef CONFIG_ATARI_SCSI_RESET_BOOT atari_scsi_reset_boot(); #endif NCR5380_init (instance, 0); if (IS_A_TT()) { /* This int is actually "pseudo-slow", i.e. it acts like a slow * interrupt after having cleared the pending flag for the DMA * interrupt. */ if (request_irq(IRQ_TT_MFP_SCSI, scsi_tt_intr, IRQ_TYPE_SLOW, "SCSI NCR5380", scsi_tt_intr)) { printk(KERN_ERR "atari_scsi_detect: cannot allocate irq %d, aborting",IRQ_TT_MFP_SCSI); scsi_unregister(atari_scsi_host); atari_stram_free(atari_dma_buffer); atari_dma_buffer = 0; return 0; } tt_mfp.active_edge |= 0x80; /* SCSI int on L->H */ #ifdef REAL_DMA tt_scsi_dma.dma_ctrl = 0; atari_dma_residual = 0; #ifdef CONFIG_TT_DMA_EMUL if (MACH_IS_HADES) { if (request_irq(IRQ_AUTO_2, hades_dma_emulator, IRQ_TYPE_PRIO, "Hades DMA emulator", hades_dma_emulator)) { printk(KERN_ERR "atari_scsi_detect: cannot allocate irq %d, aborting (MACH_IS_HADES)",IRQ_AUTO_2); free_irq(IRQ_TT_MFP_SCSI, scsi_tt_intr); scsi_unregister(atari_scsi_host); atari_stram_free(atari_dma_buffer); atari_dma_buffer = 0; return 0; } } #endif if (MACH_IS_MEDUSA || MACH_IS_HADES) { /* While the read overruns (described by Drew Eckhardt in * NCR5380.c) never happened on TTs, they do in fact on the Medusa * (This was the cause why SCSI didn't work right for so long * there.) Since handling the overruns slows down a bit, I turned * the #ifdef's into a runtime condition. * * In principle it should be sufficient to do max. 1 byte with * PIO, but there is another problem on the Medusa with the DMA * rest data register. So 'atari_read_overruns' is currently set * to 4 to avoid having transfers that aren't a multiple of 4. If * the rest data bug is fixed, this can be lowered to 1. */ atari_read_overruns = 4; } #endif /*REAL_DMA*/ } else { /* ! IS_A_TT */ /* Nothing to do for the interrupt: the ST-DMA is initialized * already by atari_init_INTS() */ #ifdef REAL_DMA atari_dma_residual = 0; atari_dma_active = 0; atari_dma_stram_mask = (ATARIHW_PRESENT(EXTD_DMA) ? 0x00000000 : 0xff000000); #endif } printk(KERN_INFO "scsi%d: options CAN_QUEUE=%d CMD_PER_LUN=%d SCAT-GAT=%d " #ifdef SUPPORT_TAGS "TAGGED-QUEUING=%s " #endif "HOSTID=%d", instance->host_no, instance->hostt->can_queue, instance->hostt->cmd_per_lun, instance->hostt->sg_tablesize, #ifdef SUPPORT_TAGS setup_use_tagged_queuing ? "yes" : "no", #endif instance->hostt->this_id ); NCR5380_print_options (instance); printk ("\n"); called = 1; return( 1 ); }
/* Detect all SSAs attached to the machine. To be fast, do it on all online FC channels at the same time. */ __initfunc(int pluto_detect(Scsi_Host_Template *tpnt)) { int i, retry, nplutos; fc_channel *fc; Scsi_Device dev; tpnt->proc_dir = &proc_scsi_pluto; fcscount = 0; for_each_online_fc_channel(fc) fcscount++; PLND(("%d channels online\n", fcscount)) if (!fcscount) { #if defined(MODULE) && defined(CONFIG_FC4_SOC_MODULE) && defined(CONFIG_KMOD) request_module("soc"); for_each_online_fc_channel(fc) fcscount++; if (!fcscount) #endif return 0; } fcs = (struct ctrl_inquiry *) scsi_init_malloc (sizeof (struct ctrl_inquiry) * fcscount, GFP_DMA); if (!fcs) { printk ("PLUTO: Not enough memory to probe\n"); return 0; } memset (fcs, 0, sizeof (struct ctrl_inquiry) * fcscount); memset (&dev, 0, sizeof(dev)); atomic_set (&fcss, fcscount); fc_timer.function = pluto_detect_timeout; i = 0; for_each_online_fc_channel(fc) { Scsi_Cmnd *SCpnt; struct Scsi_Host *host; struct pluto *pluto; if (i == fcscount) break; PLD(("trying to find SSA\n")) /* If this is already registered to some other SCSI host, then it cannot be pluto */ if (fc->scsi_name[0]) continue; memcpy (fc->scsi_name, "SSA", 4); fcs[i].fc = fc; fc->can_queue = PLUTO_CAN_QUEUE; fc->rsp_size = 64; fc->encode_addr = pluto_encode_addr; fc->fcp_register(fc, TYPE_SCSI_FCP, 0); SCpnt = &(fcs[i].cmd); host = &(fcs[i].host); pluto = (struct pluto *)host->hostdata; pluto->fc = fc; SCpnt->host = host; SCpnt->cmnd[0] = INQUIRY; SCpnt->cmnd[4] = 255; /* FC layer requires this, so that SCpnt->device->tagged_supported is initially 0 */ SCpnt->device = &dev; SCpnt->cmd_len = COMMAND_SIZE(INQUIRY); SCpnt->request.rq_status = RQ_SCSI_BUSY; SCpnt->done = pluto_detect_done; SCpnt->bufflen = 256; SCpnt->buffer = fcs[i].inquiry; SCpnt->request_bufflen = 256; SCpnt->request_buffer = fcs[i].inquiry; PLD(("set up %d %08lx\n", i, (long)SCpnt)) i++; } for (retry = 0; retry < 5; retry++) { for (i = 0; i < fcscount; i++) { if (!fcs[i].fc) break; if (fcs[i].cmd.request.rq_status != RQ_SCSI_DONE) { disable_irq(fcs[i].fc->irq); PLND(("queuecommand %d %d\n", retry, i)) fcp_scsi_queuecommand (&(fcs[i].cmd), pluto_detect_scsi_done); enable_irq(fcs[i].fc->irq); } } fc_timer.expires = jiffies + 10 * HZ; add_timer(&fc_timer); down(&fc_sem); PLND(("Woken up\n")) if (!atomic_read(&fcss)) break; /* All fc channels have answered us */ } del_timer(&fc_timer); PLND(("Finished search\n")) for (i = 0, nplutos = 0; i < fcscount; i++) { Scsi_Cmnd *SCpnt; if (!(fc = fcs[i].fc)) break; SCpnt = &(fcs[i].cmd); /* Let FC mid-level free allocated resources */ SCpnt->done (SCpnt); if (!SCpnt->result) { struct pluto_inquiry *inq; struct pluto *pluto; struct Scsi_Host *host; inq = (struct pluto_inquiry *)fcs[i].inquiry; if ((inq->dtype & 0x1f) == TYPE_PROCESSOR && !strncmp (inq->vendor_id, "SUN", 3) && !strncmp (inq->product_id, "SSA", 3)) { char *p; long *ages; ages = kmalloc (((inq->channels + 1) * inq->targets) * sizeof(long), GFP_KERNEL); if (!ages) continue; host = scsi_register (tpnt, sizeof (struct pluto)); if (!host) panic ("Cannot register PLUTO host\n"); nplutos++; if (fc->module) __MOD_INC_USE_COUNT(fc->module); pluto = (struct pluto *)host->hostdata; host->max_id = inq->targets; host->max_channel = inq->channels; host->irq = fc->irq; host->select_queue_depths = pluto_select_queue_depths; fc->channels = inq->channels + 1; fc->targets = inq->targets; fc->ages = ages; memset (ages, 0, ((inq->channels + 1) * inq->targets) * sizeof(long)); pluto->fc = fc; memcpy (pluto->rev_str, inq->revision, 4); pluto->rev_str[4] = 0; p = strchr (pluto->rev_str, ' '); if (p) *p = 0; memcpy (pluto->fw_rev_str, inq->fw_revision, 4); pluto->fw_rev_str[4] = 0; p = strchr (pluto->fw_rev_str, ' '); if (p) *p = 0; memcpy (pluto->serial_str, inq->serial, 12); pluto->serial_str[12] = 0; p = strchr (pluto->serial_str, ' '); if (p) *p = 0; PLD(("Found SSA rev %s fw rev %s serial %s %dx%d\n", pluto->rev_str, pluto->fw_rev_str, pluto->serial_str, host->max_channel, host->max_id)) } else fc->fcp_register(fc, TYPE_SCSI_FCP, 1); } else
unsigned int scsi_init() { static int called = 0; int i, pcount; Scsi_Host_Template * tpnt; struct Scsi_Host * shpnt; const char * name; if(called) return 0; called = 1; for (tpnt = &builtin_scsi_hosts[0], i = 0; i < MAX_SCSI_HOSTS; ++i, tpnt++) { /* * Initialize our semaphores. -1 is interpreted to mean * "inactive" - where as 0 will indicate a time out condition. */ pcount = next_scsi_host; if ((tpnt->detect) && (tpnt->present = tpnt->detect(tpnt))) { /* The only time this should come up is when people use * some kind of patched driver of some kind or another. */ if(pcount == next_scsi_host) { if(tpnt->present > 1) panic("Failure to register low-level scsi driver"); /* The low-level driver failed to register a driver. We * can do this now. */ scsi_register(tpnt,0); } tpnt->next = scsi_hosts; scsi_hosts = tpnt; /* Add the driver to /proc/scsi */ #if CONFIG_PROC_FS build_proc_dir_entries(tpnt); #endif } } for(shpnt=scsi_hostlist; shpnt; shpnt = shpnt->next) { if(shpnt->hostt->info) name = shpnt->hostt->info(shpnt); else name = shpnt->hostt->name; printk ("scsi%d : %s\n", /* And print a little message */ shpnt->host_no, name); } printk ("scsi : %d host%s.\n", next_scsi_host, (next_scsi_host == 1) ? "" : "s"); scsi_make_blocked_list(); /* Now attach the high level drivers */ #ifdef CONFIG_BLK_DEV_SD scsi_register_device(&sd_template); #endif #ifdef CONFIG_BLK_DEV_SR scsi_register_device(&sr_template); #endif #ifdef CONFIG_CHR_DEV_ST scsi_register_device(&st_template); #endif #ifdef CONFIG_CHR_DEV_SG scsi_register_device(&sg_template); #endif #if 0 max_scsi_hosts = next_scsi_host; #endif return 0; }
/* Prototype: int powertecscsi_detect(Scsi_Host_Template * tpnt) * Purpose : initialises PowerTec SCSI driver * Params : tpnt - template for this SCSI adapter * Returns : >0 if host found, 0 otherwise. */ int powertecscsi_detect(Scsi_Host_Template *tpnt) { static const card_ids powertecscsi_cids[] = { POWERTECSCSI_LIST, { 0xffff, 0xffff} }; int count = 0; struct Scsi_Host *host; tpnt->proc_dir = &proc_scsi_powertec; memset(ecs, 0, sizeof (ecs)); ecard_startfind(); while (1) { PowerTecScsi_Info *info; ecs[count] = ecard_find(0, powertecscsi_cids); if (!ecs[count]) break; ecard_claim(ecs[count]); host = scsi_register(tpnt, sizeof (PowerTecScsi_Info)); if (!host) { ecard_release(ecs[count]); break; } host->io_port = ecard_address(ecs[count], ECARD_IOC, ECARD_FAST); host->irq = ecs[count]->irq; host->dma_channel = ecs[count]->dma; info = (PowerTecScsi_Info *)host->hostdata; info->control.term_port = host->io_port + POWERTEC_TERM_CONTROL; info->control.terms = term[count] ? POWERTEC_TERM_ENABLE : 0; powertecscsi_terminator_ctl(host, info->control.terms); info->info.scsi.io_port = host->io_port + POWERTEC_FAS216_OFFSET; info->info.scsi.io_shift= POWERTEC_FAS216_SHIFT; info->info.scsi.irq = host->irq; info->info.ifcfg.clockrate = POWERTEC_XTALFREQ; info->info.ifcfg.select_timeout = 255; info->info.ifcfg.asyncperiod = POWERTEC_ASYNC_PERIOD; info->info.ifcfg.sync_max_depth = POWERTEC_SYNC_DEPTH; info->info.ifcfg.cntl3 = /*CNTL3_BS8 |*/ CNTL3_FASTSCSI | CNTL3_FASTCLK; info->info.ifcfg.disconnect_ok = 1; info->info.ifcfg.wide_max_size = 0; info->info.dma.setup = powertecscsi_dma_setup; info->info.dma.pseudo = NULL; info->info.dma.stop = powertecscsi_dma_stop; ecs[count]->irqaddr = (unsigned char *) ioaddr(host->io_port + POWERTEC_INTR_STATUS); ecs[count]->irqmask = POWERTEC_INTR_BIT; ecs[count]->irq_data = (void *) (host->io_port + POWERTEC_INTR_CONTROL); ecs[count]->ops = (expansioncard_ops_t *)&powertecscsi_ops; request_region(host->io_port + POWERTEC_FAS216_OFFSET, 16 << POWERTEC_FAS216_SHIFT, "powertec2-fas"); if (host->irq != NO_IRQ && request_irq(host->irq, powertecscsi_intr, SA_INTERRUPT, "powertec", host)) { printk("scsi%d: IRQ%d not free, interrupts disabled\n", host->host_no, host->irq); host->irq = NO_IRQ; info->info.scsi.irq = NO_IRQ; } if (host->dma_channel != NO_DMA && request_dma(host->dma_channel, "powertec")) { printk("scsi%d: DMA%d not free, DMA disabled\n", host->host_no, host->dma_channel); host->dma_channel = NO_DMA; } fas216_init(host); ++count; } return count; }
int nbpmacscsi_detect(struct scsi_host_template * tpnt) { int flags = 0; struct Scsi_Host *instance; struct device_node *dp; const u32 *reg; if (called) return( 0 ); // dp = find_devices("5380"); dp = of_find_node_by_name(NULL, "5380"); if (!dp) return 0; reg = of_get_property(dp, "reg", NULL); if (reg == NULL) { printk(KERN_ERR "nbpmac5380: No \"reg\" property !\n"); of_node_put(dp); return 0; } tpnt->proc_name = "nbpmac5380"; /* setup variables */ tpnt->can_queue = (setup_can_queue > 0) ? setup_can_queue : CAN_QUEUE; tpnt->cmd_per_lun = (setup_cmd_per_lun > 0) ? setup_cmd_per_lun : CMD_PER_LUN; tpnt->sg_tablesize = (setup_sg_tablesize >= 0) ? setup_sg_tablesize : SG_TABLESIZE; if (setup_hostid >= 0) tpnt->this_id = setup_hostid; else /* use 7 as default */ tpnt->this_id = 7; #ifdef SUPPORT_TAGS if (setup_use_tagged_queuing < 0) setup_use_tagged_queuing = USE_TAGGED_QUEUING; #endif /* Once we support multiple 5380s (e.g. DuoDock) we'll do something different here */ instance = scsi_register (tpnt, sizeof(struct NCR5380_hostdata)); #if NDEBUG default_instance = instance; #endif /* mac68k source says multiple device support is broken */ mac_scsi_regp = (volatile unsigned char *) of_iomap(dp, 0); mac_scsi_drq = (volatile unsigned char *) of_iomap(dp, 1); mac_scsi_nodrq = (volatile unsigned char *) of_iomap(dp, 2); if (! setup_use_pdma) flags = FLAG_NO_PSEUDO_DMA; instance->io_port = (unsigned long) mac_scsi_regp; instance->irq = irq_of_parse_and_map(dp, 0); instance->n_io_port = 255; ((struct NCR5380_hostdata *)instance->hostdata)->ctrl = 0; if (instance->irq != SCSI_IRQ_NONE) if (request_irq(instance->irq, NCR5380_intr, 0, "ncr5380", instance)) { printk("scsi%d : IRQ%d not free, interrupts disabled\n", instance->host_no, instance->irq); instance->irq = SCSI_IRQ_NONE; } #ifdef DRQ_INTERRUPT drq = irq_of_parse_and_map(vias, 1); request_irq(drq, macscsi_dma_intr, 0, "ncr5380 DRQ", instance); #endif of_node_put(dp); #ifdef RESET_BOOT mac_scsi_reset_boot(instance); #endif flags |= FLAG_HAS_LAST_BYTE_SENT; NCR5380_init(instance, flags); printk(KERN_INFO "scsi%d : generic 5380 at port %lX irq", instance->host_no, instance->io_port); if (instance->irq == SCSI_IRQ_NONE) printk (KERN_INFO "s disabled"); else printk (KERN_INFO " %d", instance->irq); printk(KERN_INFO " options CAN_QUEUE=%d CMD_PER_LUN=%d release=%d", instance->can_queue, instance->cmd_per_lun, MACSCSI_PUBLIC_RELEASE); printk(KERN_INFO "\nscsi%d :", instance->host_no); NCR5380_print_options(instance); printk("\n"); called = 1; return 1; }
static int sun3scsi_detect(struct scsi_host_template * tpnt) { unsigned long ioaddr, irq = 0; static int called = 0; struct Scsi_Host *instance; int i; unsigned long addrs[3] = { IOBASE_SUN3_VMESCSI, IOBASE_SUN3_VMESCSI + 0x4000, 0 }; unsigned long vecs[3] = { SUN3_VEC_VMESCSI0, SUN3_VEC_VMESCSI1, 0 }; /* check that this machine has an onboard 5380 */ switch(idprom->id_machtype) { case SM_SUN3|SM_3_160: case SM_SUN3|SM_3_260: break; default: return 0; } if(called) return 0; tpnt->proc_name = "Sun3 5380 VME SCSI"; /* setup variables */ tpnt->can_queue = (setup_can_queue > 0) ? setup_can_queue : CAN_QUEUE; tpnt->cmd_per_lun = (setup_cmd_per_lun > 0) ? setup_cmd_per_lun : CMD_PER_LUN; tpnt->sg_tablesize = (setup_sg_tablesize >= 0) ? setup_sg_tablesize : SG_TABLESIZE; if (setup_hostid >= 0) tpnt->this_id = setup_hostid; else { /* use 7 as default */ tpnt->this_id = 7; } ioaddr = 0; for(i = 0; addrs[i] != 0; i++) { unsigned char x; ioaddr = (unsigned long)sun3_ioremap(addrs[i], PAGE_SIZE, SUN3_PAGE_TYPE_VME16); irq = vecs[i]; sun3_scsi_regp = (unsigned char *)ioaddr; dregs = (struct sun3_dma_regs *)(((unsigned char *)ioaddr) + 8); if(sun3_map_test((unsigned long)dregs, &x)) { unsigned short oldcsr; oldcsr = dregs->csr; dregs->csr = 0; udelay(SUN3_DMA_DELAY); if(dregs->csr == 0x1400) break; dregs->csr = oldcsr; } iounmap((void *)ioaddr); ioaddr = 0; } if(!ioaddr) return 0; #ifdef SUPPORT_TAGS if (setup_use_tagged_queuing < 0) setup_use_tagged_queuing = USE_TAGGED_QUEUING; #endif instance = scsi_register (tpnt, sizeof(struct NCR5380_hostdata)); if(instance == NULL) return 0; default_instance = instance; instance->io_port = (unsigned long) ioaddr; instance->irq = irq; NCR5380_init(instance, 0); instance->n_io_port = 32; ((struct NCR5380_hostdata *)instance->hostdata)->ctrl = 0; if (request_irq(instance->irq, scsi_sun3_intr, 0, "Sun3SCSI-5380VME", instance)) { #ifndef REAL_DMA printk("scsi%d: IRQ%d not free, interrupts disabled\n", instance->host_no, instance->irq); instance->irq = SCSI_IRQ_NONE; #else printk("scsi%d: IRQ%d not free, bailing out\n", instance->host_no, instance->irq); return 0; #endif } printk("scsi%d: Sun3 5380 VME at port %lX irq", instance->host_no, instance->io_port); if (instance->irq == SCSI_IRQ_NONE) printk ("s disabled"); else printk (" %d", instance->irq); printk(" options CAN_QUEUE=%d CMD_PER_LUN=%d release=%d", instance->can_queue, instance->cmd_per_lun, SUN3SCSI_PUBLIC_RELEASE); printk("\nscsi%d:", instance->host_no); NCR5380_print_options(instance); printk("\n"); dregs->csr = 0; udelay(SUN3_DMA_DELAY); dregs->csr = CSR_SCSI | CSR_FIFO | CSR_INTR; udelay(SUN3_DMA_DELAY); dregs->fifo_count = 0; dregs->fifo_count_hi = 0; dregs->dma_addr_hi = 0; dregs->dma_addr_lo = 0; dregs->dma_count_hi = 0; dregs->dma_count_lo = 0; dregs->ivect = VME_DATA24 | (instance->irq & 0xff); called = 1; #ifdef RESET_BOOT sun3_scsi_reset_boot(instance); #endif return 1; }
int __init sgiwd93_detect(Scsi_Host_Template *SGIblows) { static unsigned char called = 0; struct hpc3_scsiregs *hregs = &hpc3c0->scsi_chan0; struct hpc3_scsiregs *hregs1 = &hpc3c0->scsi_chan1; struct WD33C93_hostdata *hdata; struct WD33C93_hostdata *hdata1; wd33c93_regs regs; uchar *buf; if(called) return 0; /* Should bitch on the console about this... */ SGIblows->proc_name = "SGIWD93"; sgiwd93_host = scsi_register(SGIblows, sizeof(struct WD33C93_hostdata)); if(sgiwd93_host == NULL) return 0; sgiwd93_host->base = (unsigned long) hregs; sgiwd93_host->irq = SGI_WD93_0_IRQ; buf = (uchar *) get_zeroed_page(GFP_KERNEL); if (!buf) { printk(KERN_WARNING "sgiwd93: Could not allocate memory for host0 buffer.\n"); scsi_unregister(sgiwd93_host); return 0; } init_hpc_chain(buf); /* HPC_SCSI_REG0 | 0x03 | KSEG1 */ regs.SASR = (unsigned char*) KSEG1ADDR (0x1fbc0003); regs.SCMD = (unsigned char*) KSEG1ADDR (0x1fbc0007); wd33c93_init(sgiwd93_host, regs, dma_setup, dma_stop, WD33C93_FS_16_20); hdata = (struct WD33C93_hostdata *)sgiwd93_host->hostdata; hdata->no_sync = 0; hdata->dma_bounce_buffer = (uchar *) (KSEG1ADDR(buf)); if (request_irq(SGI_WD93_0_IRQ, sgiwd93_intr, 0, "SGI WD93", (void *) sgiwd93_host)) { printk(KERN_WARNING "sgiwd93: Could not register IRQ %d (for host 0).\n", SGI_WD93_0_IRQ); wd33c93_release(); free_page((unsigned long)buf); scsi_unregister(sgiwd93_host); return 0; } /* set up second controller on the Indigo2 */ if(!sgi_guiness) { sgiwd93_host1 = scsi_register(SGIblows, sizeof(struct WD33C93_hostdata)); if(sgiwd93_host1 != NULL) { sgiwd93_host1->base = (unsigned long) hregs1; sgiwd93_host1->irq = SGI_WD93_1_IRQ; buf = (uchar *) get_zeroed_page(GFP_KERNEL); if (!buf) { printk(KERN_WARNING "sgiwd93: Could not allocate memory for host1 buffer.\n"); scsi_unregister(sgiwd93_host1); called = 1; return 1; /* We registered host0 so return success*/ } init_hpc_chain(buf); /* HPC_SCSI_REG1 | 0x03 | KSEG1 */ regs.SASR = (unsigned char*) KSEG1ADDR(0x1fbc8003); regs.SCMD = (unsigned char*) KSEG1ADDR(0x1fbc8007); wd33c93_init(sgiwd93_host1, regs, dma_setup, dma_stop, WD33C93_FS_16_20); hdata1 = (struct WD33C93_hostdata *)sgiwd93_host1->hostdata; hdata1->no_sync = 0; hdata1->dma_bounce_buffer = (uchar *) (KSEG1ADDR(buf)); if (request_irq(SGI_WD93_1_IRQ, sgiwd93_intr, 0, "SGI WD93", (void *) sgiwd93_host1)) { printk(KERN_WARNING "sgiwd93: Could not allocate irq %d (for host1).\n", SGI_WD93_1_IRQ); wd33c93_release(); free_page((unsigned long)buf); scsi_unregister(sgiwd93_host1); /* Fall through since host0 registered OK */ } } } called = 1; return 1; /* Found one. */ }
static int powertecscsi_probe(struct expansion_card *ec) { struct Scsi_Host *host; struct powertec_info *info; unsigned long base; int ret; base = ecard_address(ec, ECARD_IOC, ECARD_FAST); request_region(base + POWERTEC_FAS216_OFFSET, 16 << POWERTEC_FAS216_SHIFT, "powertec2-fas"); host = scsi_register(&powertecscsi_template, sizeof (struct powertec_info)); if (!host) { ret = -ENOMEM; goto out_region; } host->io_port = base; host->irq = ec->irq; host->dma_channel = ec->dma; ec->irqaddr = (unsigned char *)ioaddr(base + POWERTEC_INTR_STATUS); ec->irqmask = POWERTEC_INTR_BIT; ec->irq_data = (void *)(base + POWERTEC_INTR_CONTROL); ec->ops = (expansioncard_ops_t *)&powertecscsi_ops; info = (struct powertec_info *)host->hostdata; info->ec = ec; info->term_port = base + POWERTEC_TERM_CONTROL; powertecscsi_terminator_ctl(host, term[ec->slot_no]); info->info.scsi.io_port = host->io_port + POWERTEC_FAS216_OFFSET; info->info.scsi.io_shift = POWERTEC_FAS216_SHIFT; info->info.scsi.irq = host->irq; info->info.ifcfg.clockrate = 40; /* MHz */ info->info.ifcfg.select_timeout = 255; info->info.ifcfg.asyncperiod = 200; /* ns */ info->info.ifcfg.sync_max_depth = 7; info->info.ifcfg.cntl3 = CNTL3_BS8 | CNTL3_FASTSCSI | CNTL3_FASTCLK; info->info.ifcfg.disconnect_ok = 1; info->info.ifcfg.wide_max_size = 0; info->info.ifcfg.capabilities = 0; info->info.dma.setup = powertecscsi_dma_setup; info->info.dma.pseudo = NULL; info->info.dma.stop = powertecscsi_dma_stop; ret = fas216_init(host); if (ret) goto out_free; ret = request_irq(host->irq, powertecscsi_intr, SA_INTERRUPT, "powertec", &info->info); if (ret) { printk("scsi%d: IRQ%d not free: %d\n", host->host_no, host->irq, ret); goto out_release; } if (host->dma_channel != NO_DMA) { if (request_dma(host->dma_channel, "powertec")) { printk("scsi%d: DMA%d not free, using PIO\n", host->host_no, host->dma_channel); host->dma_channel = NO_DMA; } else { set_dma_speed(host->dma_channel, 180); info->info.ifcfg.capabilities |= FASCAP_DMA; } } ret = fas216_add(host); if (ret == 0) goto out; if (host->dma_channel != NO_DMA) free_dma(host->dma_channel); free_irq(host->irq, host); out_release: fas216_release(host); out_free: scsi_unregister(host); out_region: release_region(base + POWERTEC_FAS216_OFFSET, 16 << POWERTEC_FAS216_SHIFT); out: return ret; }
/***************************************************************************** Function name : inia100_detect Description : Input : pHCB - Pointer to host adapter structure Output : None. Return : pSRB - Pointer to SCSI request block. *****************************************************************************/ int inia100_detect(Scsi_Host_Template * tpnt) { ORC_HCS *pHCB; struct Scsi_Host *hreg; U32 sz; U32 i; /* 01/14/98 */ int ok = 0, iAdapters; ULONG dBiosAdr; BYTE *pbBiosAdr; #if LINUX_VERSION_CODE >= CVT_LINUX_VERSION(1,3,0) tpnt->proc_dir = &proc_scsi_inia100; #endif if (setup_called) { /* Setup by inia100_setup */ printk("inia100: processing commandline: "); } /* Get total number of adapters in the motherboard */ iAdapters = orc_ReturnNumberOfAdapters(); /* printk("inia100: Total Initio Adapters = %d\n", iAdapters); */ if (iAdapters == 0) /* If no orc founded, return */ return (0); orc_num_ch = (iAdapters > orc_num_ch) ? orc_num_ch : iAdapters; orc_num_scb = ORC_MAXQUEUE; /* clear the memory needed for HCS */ i = orc_num_ch * sizeof(ORC_HCS); memset((unsigned char *) &orc_hcs[0], 0, i); /* Initialize orc_hcs 0 */ #if 0 printk("orc_num_scb= %x orc_num_ch= %x hcsize= %x scbsize= %x escbsize= %x\n", orc_num_scb, orc_num_ch, sizeof(ORC_HCS), sizeof(ORC_SCB), sizeof(ESCB)); #endif for (i = 0, pHCB = &orc_hcs[0]; /* Get pointer for control block */ i < orc_num_ch; i++, pHCB++) { pHCB->pSRB_head = NULL; /* Initial SRB save queue */ pHCB->pSRB_tail = NULL; /* Initial SRB save queue */ #if LINUX_VERSION_CODE >= CVT_LINUX_VERSION(2,1,95) pHCB->pSRB_lock = SPIN_LOCK_UNLOCKED; /* SRB save queue lock */ #endif /* Get total memory needed for SCB */ sz = orc_num_scb * sizeof(ORC_SCB); if ((pHCB->HCS_virScbArray = (PVOID) kmalloc(sz, GFP_ATOMIC | GFP_DMA)) == NULL) { printk("inia100: SCB memory allocation error\n"); return (0); } memset((unsigned char *) pHCB->HCS_virScbArray, 0, sz); pHCB->HCS_physScbArray = (U32) VIRT_TO_BUS(pHCB->HCS_virScbArray); /* Get total memory needed for ESCB */ sz = orc_num_scb * sizeof(ESCB); if ((pHCB->HCS_virEscbArray = (PVOID) kmalloc(sz, GFP_ATOMIC | GFP_DMA)) == NULL) { printk("inia100: ESCB memory allocation error\n"); return (0); } memset((unsigned char *) pHCB->HCS_virEscbArray, 0, sz); pHCB->HCS_physEscbArray = (U32) VIRT_TO_BUS(pHCB->HCS_virEscbArray); request_region(pHCB->HCS_Base, 0x100, "inia100"); /* Register */ get_orcPCIConfig(pHCB, i); dBiosAdr = pHCB->HCS_BIOS; dBiosAdr = (dBiosAdr << 4); #if LINUX_VERSION_CODE >= CVT_LINUX_VERSION(1,3,0) pbBiosAdr = phys_to_virt(dBiosAdr); #endif if (init_orchid(pHCB)) { /* Initial orchid chip */ printk("inia100: initial orchid fail!!\n"); return (0); } hreg = scsi_register(tpnt, sizeof(ORC_HCS)); if (hreg == NULL) { printk("Invalid scsi_register pointer.\n"); } hreg->io_port = pHCB->HCS_Base; hreg->n_io_port = 0xff; hreg->can_queue = orc_num_scb; /* 03/05/98 */ #if LINUX_VERSION_CODE >= CVT_LINUX_VERSION(1,3,0) hreg->unique_id = pHCB->HCS_Base; hreg->max_id = pHCB->HCS_MaxTar; #endif hreg->max_lun = 32; /* 10/21/97 */ /* hreg->max_lun = 8; hreg->max_channel = 1; */ hreg->irq = pHCB->HCS_Intr; hreg->this_id = pHCB->HCS_SCSI_ID; /* Assign HCS index */ hreg->base = (UCHAR *) pHCB; #if 1 hreg->sg_tablesize = TOTAL_SG_ENTRY; /* Maximun support is 32 */ #else hreg->sg_tablesize = SG_NONE; /* No SG */ #endif /* Initial orc chip */ switch (i) { #if LINUX_VERSION_CODE >= CVT_LINUX_VERSION(1,3,0) case 0: ok = request_irq(pHCB->HCS_Intr, inia100_intr0, SA_INTERRUPT | SA_SHIRQ, "inia100", NULL); break; case 1: ok = request_irq(pHCB->HCS_Intr, inia100_intr1, SA_INTERRUPT | SA_SHIRQ, "inia100", NULL); break; case 2: ok = request_irq(pHCB->HCS_Intr, inia100_intr2, SA_INTERRUPT | SA_SHIRQ, "inia100", NULL); break; case 3: ok = request_irq(pHCB->HCS_Intr, inia100_intr3, SA_INTERRUPT | SA_SHIRQ, "inia100", NULL); break; case 4: ok = request_irq(pHCB->HCS_Intr, inia100_intr4, SA_INTERRUPT | SA_SHIRQ, "inia100", NULL); break; case 5: ok = request_irq(pHCB->HCS_Intr, inia100_intr5, SA_INTERRUPT | SA_SHIRQ, "inia100", NULL); break; case 6: ok = request_irq(pHCB->HCS_Intr, inia100_intr6, SA_INTERRUPT | SA_SHIRQ, "inia100", NULL); break; case 7: ok = request_irq(pHCB->HCS_Intr, inia100_intr7, SA_INTERRUPT | SA_SHIRQ, "inia100", NULL); break; default: inia100_panic("inia100: Too many host adapters\n"); break; } if (ok < 0) { if (ok == -EINVAL) { printk("inia100: bad IRQ %d.\n", pHCB->HCS_Intr); printk(" Contact author.\n"); } else { if (ok == -EBUSY) printk("inia100: IRQ %d already in use. Configure another.\n", pHCB->HCS_Intr); else { printk("\ninia100: Unexpected error code on requesting IRQ %d.\n", pHCB->HCS_Intr); printk(" Contact author.\n"); } } inia100_panic("inia100: driver needs an IRQ.\n"); } #endif } tpnt->this_id = -1; tpnt->can_queue = 1; return 1; }
int sun3scsi_detect(Scsi_Host_Template * tpnt) { unsigned long ioaddr, iopte; int count = 0; static int called = 0; struct Scsi_Host *instance; if(called) return 0; tpnt->proc_name = "Sun3 5380 SCSI"; /* setup variables */ tpnt->can_queue = (setup_can_queue > 0) ? setup_can_queue : CAN_QUEUE; tpnt->cmd_per_lun = (setup_cmd_per_lun > 0) ? setup_cmd_per_lun : CMD_PER_LUN; tpnt->sg_tablesize = (setup_sg_tablesize >= 0) ? setup_sg_tablesize : SG_TABLESIZE; if (setup_hostid >= 0) tpnt->this_id = setup_hostid; else { /* use 7 as default */ tpnt->this_id = 7; } /* Taken from Sammy's lance driver: */ /* IOBASE_SUN3_SCSI can be found within the IO pmeg with some effort */ for(ioaddr = 0xfe00000; ioaddr < (0xfe00000 + SUN3_PMEG_SIZE); ioaddr += SUN3_PTE_SIZE) { iopte = sun3_get_pte(ioaddr); if(!(iopte & SUN3_PAGE_TYPE_IO)) /* this an io page? */ continue; if(((iopte & SUN3_PAGE_PGNUM_MASK) << PAGE_SHIFT) == IOBASE_SUN3_SCSI) { count = 1; break; } } if(!count) { printk("No Sun3 NCR5380 found!\n"); return 0; } sun3_scsi_regp = (unsigned char *)ioaddr; dregs = (struct sun3_dma_regs *)(((unsigned char *)ioaddr) + 8); if((dmabuf = sun3_dvma_malloc(SUN3_DVMA_BUFSIZE)) == NULL) { printk("SUN3 Scsi couldn't allocate DVMA memory!\n"); return 0; } if((udc_regs = sun3_dvma_malloc(sizeof(struct sun3_udc_regs))) == NULL) { printk("SUN3 Scsi couldn't allocate DVMA memory!\n"); return 0; } #ifdef SUPPORT_TAGS if (setup_use_tagged_queuing < 0) setup_use_tagged_queuing = DEFAULT_USE_TAGGED_QUEUING; #endif instance = scsi_register (tpnt, sizeof(struct NCR5380_hostdata)); if(instance == NULL) return 0; default_instance = instance; instance->io_port = (unsigned long) ioaddr; instance->irq = IRQ_SUN3_SCSI; NCR5380_init(instance, 0); instance->n_io_port = 32; ((struct NCR5380_hostdata *)instance->hostdata)->ctrl = 0; if (request_irq(instance->irq, scsi_sun3_intr, 0, "Sun3SCSI-5380", NULL)) { #ifndef REAL_DMA printk("scsi%d: IRQ%d not free, interrupts disabled\n", instance->host_no, instance->irq); instance->irq = IRQ_NONE; #else printk("scsi%d: IRQ%d not free, bailing out\n", instance->host_no, instance->irq); return 0; #endif } printk("scsi%d: Sun3 5380 at port %lX irq", instance->host_no, instance->io_port); if (instance->irq == IRQ_NONE) printk ("s disabled"); else printk (" %d", instance->irq); printk(" options CAN_QUEUE=%d CMD_PER_LUN=%d release=%d", instance->can_queue, instance->cmd_per_lun, SUN3SCSI_PUBLIC_RELEASE); printk("\nscsi%d:", instance->host_no); NCR5380_print_options(instance); printk("\n"); dregs->csr = 0; udelay(SUN3_DMA_DELAY); dregs->csr = CSR_SCSI | CSR_FIFO | CSR_INTR; udelay(SUN3_DMA_DELAY); dregs->fifo_count = 0; called = 1; return 1; }
int tc2550_detect(Scsi_Host_Template * tpnt) { int flag = 0; int retcode; struct Scsi_Host *shpnt; unsigned long flags; unsigned int mod4; flag = tc2550_pci_bios_detect(&interrupt_level, &port_base); if (!flag) return (0); init_chip_reg(); /* chip Tc-2550 initialize */ flag = download_RISC_code(); if (flag == 0) { printk(KERN_INFO "tc2550: Successful F/W download on TC-2550x\n"); } /* now do a scsi register and get scsi host ptr */ shpnt = scsi_register(tpnt, 0); save_flags(flags); cli(); retcode = request_irq(interrupt_level, tc2550_intr, SA_INTERRUPT, "tripace", NULL); if (retcode) { printk(KERN_ERR "tc2550: Unable to allocate IRQ for Tripace TC-2550x based SCSI Host Adapter.\n"); goto unregister; } /* For multiple HA we need to change all this */ tripace_host = shpnt; shpnt->io_port = CFG_BASE; shpnt->n_io_port = 0xfc; /* Number of bytes of I/O space used */ shpnt->dma_channel = 0; shpnt->irq = interrupt_level; restore_flags(flags); /* log i/o ports with the kernel */ request_region(port_base, 0xfc, "tripace"); /* when we support multiple HA ,we need to modify */ Init_struc(0); /* init mailboxes for one adapter */ /* sg table init */ /* get physical address */ startsgptr = (unsigned char *) table; pstartsgptr = virt_to_phys((unsigned char *) table); mod4 = pstartsgptr % 4; if (mod4) { pstartsgptr += (4 - mod4); startsgptr += (4 - mod4); } return (0); unregister: scsi_unregister(shpnt); return (0); }
int mac53c94_detect(Scsi_Host_Template *tp) { struct device_node *node; int nfscs; struct fsc_state *state, **prev_statep; struct Scsi_Host *host; void *dma_cmd_space; unsigned char *clkprop; int proplen; struct pci_dev *pdev; u8 pbus, devfn; nfscs = 0; prev_statep = &all_53c94s; for (node = find_devices("53c94"); node != 0; node = node->next) { if (node->n_addrs != 2 || node->n_intrs != 2) { printk(KERN_ERR "mac53c94: expected 2 addrs and intrs" " (got %d/%d) for node %s\n", node->n_addrs, node->n_intrs, node->full_name); continue; } pdev = NULL; if (node->parent != NULL && !pci_device_from_OF_node(node->parent, &pbus, &devfn)) pdev = pci_find_slot(pbus, devfn); if (pdev == NULL) { printk(KERN_ERR "mac53c94: can't find PCI device " "for %s\n", node->full_name); continue; } host = scsi_register(tp, sizeof(struct fsc_state)); if (host == NULL) break; host->unique_id = nfscs; state = (struct fsc_state *) host->hostdata; if (state == 0) { /* "can't happen" */ printk(KERN_ERR "mac53c94: no state for %s?!\n", node->full_name); scsi_unregister(host); break; } state->host = host; state->pdev = pdev; state->regs = (volatile struct mac53c94_regs *) ioremap(node->addrs[0].address, 0x1000); state->intr = node->intrs[0].line; state->dma = (volatile struct dbdma_regs *) ioremap(node->addrs[1].address, 0x1000); state->dmaintr = node->intrs[1].line; if (state->regs == NULL || state->dma == NULL) { printk(KERN_ERR "mac53c94: ioremap failed for %s\n", node->full_name); if (state->dma != NULL) iounmap(state->dma); if (state->regs != NULL) iounmap(state->regs); scsi_unregister(host); break; } clkprop = get_property(node, "clock-frequency", &proplen); if (clkprop == NULL || proplen != sizeof(int)) { printk(KERN_ERR "%s: can't get clock frequency, " "assuming 25MHz\n", node->full_name); state->clk_freq = 25000000; } else state->clk_freq = *(int *)clkprop; /* Space for dma command list: +1 for stop command, +1 to allow for aligning. */ dma_cmd_space = kmalloc((host->sg_tablesize + 2) * sizeof(struct dbdma_cmd), GFP_KERNEL); if (dma_cmd_space == 0) { printk(KERN_ERR "mac53c94: couldn't allocate dma " "command space for %s\n", node->full_name); goto err_cleanup; } state->dma_cmds = (struct dbdma_cmd *) DBDMA_ALIGN(dma_cmd_space); memset(state->dma_cmds, 0, (host->sg_tablesize + 1) * sizeof(struct dbdma_cmd)); state->dma_cmd_space = dma_cmd_space; *prev_statep = state; prev_statep = &state->next; if (request_irq(state->intr, do_mac53c94_interrupt, 0, "53C94", state)) { printk(KERN_ERR "mac53C94: can't get irq %d for %s\n", state->intr, node->full_name); err_cleanup: iounmap(state->dma); iounmap(state->regs); scsi_unregister(host); break; } mac53c94_init(state); ++nfscs; } return nfscs; }
int seagate_st0x_detect (Scsi_Host_Template * tpnt) { struct Scsi_Host *instance; #ifndef OVERRIDE int i,j; #endif tpnt->proc_dir = &proc_scsi_seagate; /* * First, we try for the manual override. */ #ifdef DEBUG printk("Autodetecting ST0x / TMC-8xx\n"); #endif if (hostno != -1) { printk ("ERROR : seagate_st0x_detect() called twice.\n"); return 0; } /* If the user specified the controller type from the command line, controller_type will be non-zero, so don't try to detect one */ if (!controller_type) { #ifdef OVERRIDE base_address = (void *) OVERRIDE; /* CONTROLLER is used to override controller (SEAGATE or FD). PM: 07/01/93 */ #ifdef CONTROLLER controller_type = CONTROLLER; #else #error Please use -DCONTROLLER=SEAGATE or -DCONTROLLER=FD to override controller type #endif /* CONTROLLER */ #ifdef DEBUG printk("Base address overridden to %x, controller type is %s\n", base_address,controller_type == SEAGATE ? "SEAGATE" : "FD"); #endif #else /* OVERRIDE */ /* * To detect this card, we simply look for the signature * from the BIOS version notice in all the possible locations * of the ROM's. This has a nice side effect of not trashing * any register locations that might be used by something else. * * XXX - note that we probably should be probing the address * space for the on-board RAM instead. */ for (i = 0; i < (sizeof (seagate_bases) / sizeof (char * )); ++i) for (j = 0; !base_address && j < NUM_SIGNATURES; ++j) if (!memcmp ((const void *) (seagate_bases[i] + signatures[j].offset), (const void *) signatures[j].signature, signatures[j].length)) { base_address = (const void *) seagate_bases[i]; controller_type = signatures[j].type; } #endif /* OVERRIDE */ } /* (! controller_type) */ tpnt->this_id = (controller_type == SEAGATE) ? 7 : 6; tpnt->name = (controller_type == SEAGATE) ? ST0X_ID_STR : FD_ID_STR; if (base_address) { st0x_cr_sr =(void *) (((const unsigned char *) base_address) + (controller_type == SEAGATE ? 0x1a00 : 0x1c00)); st0x_dr = (void *) (((const unsigned char *) base_address ) + (controller_type == SEAGATE ? 0x1c00 : 0x1e00)); #ifdef DEBUG printk("%s detected. Base address = %x, cr = %x, dr = %x\n", tpnt->name, base_address, st0x_cr_sr, st0x_dr); #endif /* * At all times, we will use IRQ 5. Should also check for IRQ3 if we * loose our first interrupt. */ instance = scsi_register(tpnt, 0); hostno = instance->host_no; if (request_irq((int) irq, seagate_reconnect_intr, SA_INTERRUPT, (controller_type == SEAGATE) ? "seagate" : "tmc-8xx", NULL)) { printk("scsi%d : unable to allocate IRQ%d\n", hostno, (int) irq); return 0; } instance->irq = irq; instance->io_port = (unsigned int) base_address; #ifdef SLOW_HANDSHAKE borken_init(); #endif printk("%s options:" #ifdef ARBITRATE " ARBITRATE" #endif #ifdef SLOW_HANDSHAKE " SLOW_HANDSHAKE" #endif #ifdef FAST #ifdef FAST32 " FAST32" #else " FAST" #endif #endif #ifdef LINKED " LINKED" #endif "\n", tpnt->name); return 1; } else { #ifdef DEBUG printk("ST0x / TMC-8xx not detected.\n"); #endif return 0; } }