Index: Makefile.dc390 =================================================================== RCS file: /home/cvsroot/dc390/Attic/Makefile.dc390,v retrieving revision 1.1.2.2 retrieving revision 1.1.2.4 diff -u -r1.1.2.2 -r1.1.2.4 --- Makefile.dc390 2000/05/18 07:42:35 1.1.2.2 +++ Makefile.dc390 2000/12/02 12:22:04 1.1.2.4 @@ -12,11 +12,21 @@ include $(KDIR)/Makefile TOPDIR := $(KDIR) -CFLAGS := -I. -I $(KDIR)/drivers/scsi $(CFLAGS) -DMODULE +CFLAGS := -I. -I $(KDIR)/drivers/scsi -I $(KDIR)/include $(CFLAGS) -DMODULE +ifdef CONFIG_MODVERSIONS +CFLAGS += -DMODVERSIONS -include $(KDIR)/include/linux/modversions.h +endif + tmscsim.o: dc390.h tmscsim.h scsiiom.c tmscsim.c arch Rules.make +# 2.4 and later define PERL in the Makefile +#ifdef PERL +ifeq ($(PATCHLEVEL),4) +MODLIB := $(DESTDIR)$(INSTALL_MOD_PATH)/lib/modules/$(KERNELRELEASE)/kernel/drivers +else MODLIB := $(DESTDIR)$(INSTALL_MOD_PATH)/lib/modules/$(KERNELRELEASE) +endif install_mod: $(MODLIB)/$(TARGETMODDIR)/tmscsim.o Index: README.tmscsim =================================================================== RCS file: /home/cvsroot/dc390/README.tmscsim,v retrieving revision 2.25.2.4 retrieving revision 2.25.2.7 diff -u -r2.25.2.4 -r2.25.2.7 --- README.tmscsim 2000/05/24 14:31:23 2.25.2.4 +++ README.tmscsim 2000/12/20 01:07:12 2.25.2.7 @@ -131,8 +131,8 @@ * Uniform source code for Linux-2.x.y * Support for dyn. addition/removal of devices via add/remove-single-device (Try: echo "scsi add-single-device C B T U" >/proc/scsi/scsi - C = Controller, B = Bus, T = Target SCSI ID, U = Unit SCSI LUN.) Use - with care! + C = Controller, B = Bus, T = Target SCSI ID, U = Unit SCSI LUN.) + Use with care! * Try to use the partition table for the determination of the mapping @@ -147,7 +147,7 @@ Here's an example: garloff@kurt:/home/garloff > cat /proc/scsi/tmscsim/0 -Tekram DC390/AM53C974 PCI SCSI Host Adapter, Driver Version 2.0e 1999/08/30 +Tekram DC390/AM53C974 PCI SCSI Host Adapter, Driver Version 2.0e7 2000-11-28 SCSI Host Nr 1, AM53C974 Adapter Nr 0 IOPortBase 0xb000, IRQ 10 MaxID 8, MaxLUN 8, AdapterID 6, SelTimeout 250 ms, DelayReset 1 s @@ -258,18 +258,20 @@ 5. Configuration via boot/module parameters ------------------------------------------- -With the DC390, the driver reads its EEPROM settings and IGNORES boot / -module parameters. If you want to override the EEPROM settings of a DC390, -you have to use the /proc/scsi/tmscsim/? interface described in the above -chapter. - -However, if you do have another AM53C974 based adapter you might want to -adjust some settings before you are able to write to the /proc/scsi/tmscsim/? -pseudo-file, e.g. if you want to use another adapter ID than 7. (Note that -the log message "DC390: No EEPROM found!" is normal without a DC390.) +With the DC390, the driver reads its EEPROM settings and tries to use them. +But you may want to override the settings prior to being able to change the +driver configuration via /proc/scsi/tmscsim/?. +If you do have another AM53C974 based adapter, that's even the only +possibility to adjust settings before you are able to write to the +/proc/scsi/tmscsim/? pseudo-file, e.g. if you want to use another +adapter ID than 7. +(BTW, the log message "DC390: No EEPROM found!" is normal without a DC390.) For this purpose, you can pass options to the driver before it is initialised by using kernel or module parameters. See lilo(8) or modprobe(1) manual pages on how to pass params to the kernel or a module. +[NOTE: Formerly, it was not possible to override the EEPROM supplied + settings of the DC390 with cmd line parameters. This has changed since + 2.0e7] The syntax of the params is much shorter than the syntax of the /proc/... interface. This makes it a little bit more difficult to use. However, long @@ -289,7 +291,7 @@ * SpdIdx: The index of the maximum speed as in the DC390 BIOS. The values 0..7 mean 10, 8.0, 6.7, 5.7, 5.0, 4.0, 3.1 and 2 MHz resp. Default is - 1 (8.0 MHz). + 0 (10.0 MHz). * DevMode is a bit mapped value describing the per-device features. It applies to all devices. (Sync, Disc and TagQ will only apply, if the @@ -336,10 +338,12 @@ and the Delay after a reset to the defaults. As you can see, you don't need to specify all of the six params. +If you want values to be ignored (i.e. the EEprom settings or the defaults +will be used), you may pass -2 (not 0!) at the corresponding position. -The defaults (7,1,31,15,3,1) are aggressive to allow good performance. You can -use tmscsim=7,0,31,63,4,0 for maximum performance, if your SCSI chain is -perfect. If you meet problems, you can use tmscsim=-1 which is a shortcut +The defaults (7,0,31,15,3,1) are aggressive to allow good performance. You +can use tmscsim=7,0,31,63,4,0 for maximum performance, if your SCSI chain +allows it. If you meet problems, you can use tmscsim=-1 which is a shortcut for tmscsim=7,4,9,15,2,10. @@ -384,10 +388,10 @@ partition table and used a H/S = 64/32 or 255/63 translation. So if you want to be compatible to those, use this old mapping when creating partition tables. Even worse, on bootup the DC390 might complain if other - mappings are found, so auto rebooting will fail. + mappings are found, so auto rebooting may fail. * In some situations, the driver will get stuck in an abort loop. This is a bad interaction between the Mid-Layer of Linux' SCSI code and the driver. - Try to disable DsCn, if you meet this problem. Please contact me for + Try to disable DsCn, if you meet this problem. Please contact me for further debugging. @@ -401,7 +405,7 @@ maybe the DC390 log messages to the report. Bug reports should be send to me (Kurt Garloff ) as well -as to the linux-scsi list (), as sometimes bugs +as to the linux-scsi list (), as sometimes bugs are caused by the SCSI mid-level code. I will ask you for some more details and probably I will also ask you to @@ -418,11 +422,11 @@ 8. Acknowledgements ------------------- -Thanks to Linus Torvalds, Alan Cox, David Miller, the FSF people, the -XFree86 team and all the others for the wonderful OS and software. +Thanks to Linus Torvalds, Alan Cox, the FSF people, the XFree86 team and +all the others for the wonderful OS and software. Thanks to C.L. Huang and Philip Giang (Tekram) for the initial driver release and support. -Thanks to Doug Ledford, Gerard Roudier for support with SCSI coding. +Thanks to Doug Ledford, Gérard Roudier for support with SCSI coding. Thanks to a lot of people (espec. Chiaki Ishikawa, Andreas Haumer, Hubert Tonneau) for intensively testing the driver (and even risking data loss doing this during early revisions). @@ -441,5 +445,5 @@ ------------------------------------------------------------------------- Written by Kurt Garloff 1998/06/11 -Last updated 2000/01/17, driver revision 2.0d25 -$Id: README.tmscsim,v 2.25.2.4 2000/05/24 14:31:23 garloff Exp $ +Last updated 2000/11/28, driver revision 2.0e7 +$Id: README.tmscsim,v 2.25.2.7 2000/12/20 01:07:12 garloff Exp $ Index: dc390.h =================================================================== RCS file: /home/cvsroot/dc390/dc390.h,v retrieving revision 2.43.2.13 retrieving revision 2.43.2.22 diff -u -r2.43.2.13 -r2.43.2.22 --- dc390.h 2000/05/23 13:12:55 2.43.2.13 +++ dc390.h 2000/12/20 00:39:36 2.43.2.22 @@ -4,7 +4,7 @@ * Description: Device Driver for Tekram DC-390(T) PCI SCSI * * Bus Master Host Adapter * ***********************************************************************/ -/* $Id: dc390.h,v 2.43.2.13 2000/05/23 13:12:55 garloff Exp $ */ +/* $Id: dc390.h,v 2.43.2.22 2000/12/20 00:39:36 garloff Exp $ */ /* * DC390/AMD 53C974 driver, header file @@ -19,7 +19,7 @@ #endif #define DC390_BANNER "Tekram DC390/AM53C974" -#define DC390_VERSION "2.0e 2000/05/23" +#define DC390_VERSION "2.0f 2000-12-20" /* We don't have eh_abort_handler, eh_device_reset_handler, * eh_bus_reset_handler, eh_host_reset_handler yet! @@ -33,7 +33,7 @@ # define USE_NEW_EH #endif -#if defined(HOSTS_C) || defined(MODULE) +#if defined(HOSTS_C) || defined(MODULE) || LINUX_VERSION_CODE > KERNEL_VERSION(2,3,99) extern int DC390_detect(Scsi_Host_Template *psht); extern int DC390_queue_command(Scsi_Cmnd *cmd, void (*done)(Scsi_Cmnd *)); @@ -47,9 +47,6 @@ # define DC390_release NULL #endif -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,3,30) -extern struct proc_dir_entry DC390_proc_scsi_tmscsim; -#endif extern int DC390_proc_info(char *buffer, char **start, off_t offset, int length, int hostno, int inout); #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,3,30) @@ -72,6 +69,7 @@ use_clustering: DISABLE_CLUSTERING \ } #else +extern struct proc_dir_entry DC390_proc_scsi_tmscsim; #define DC390_T { \ proc_dir: &DC390_proc_scsi_tmscsim, \ proc_info: DC390_proc_info, \ Index: scsiiom.c =================================================================== RCS file: /home/cvsroot/dc390/scsiiom.c,v retrieving revision 2.55.2.10 retrieving revision 2.55.2.17 diff -u -r2.55.2.10 -r2.55.2.17 --- scsiiom.c 2000/05/22 19:26:47 2.55.2.10 +++ scsiiom.c 2000/12/20 00:39:37 2.55.2.17 @@ -4,7 +4,7 @@ * Description: Device Driver for Tekram DC-390 (T) PCI SCSI * * Bus Master Host Adapter * ***********************************************************************/ -/* $Id: scsiiom.c,v 2.55.2.10 2000/05/22 19:26:47 garloff Exp $ */ +/* $Id: scsiiom.c,v 2.55.2.17 2000/12/20 00:39:37 garloff Exp $ */ static void __inline__ dc390_freetag (PDCB pDCB, PSRB pSRB) @@ -56,7 +56,7 @@ * (pSRB->pcmd->cmnd[0] == TEST_UNIT_READY)) && pACB->scan_devices) ||*/ (pSRB->SRBFlag & AUTO_REQSENSE) ) disc_allowed = 0; - if ( (pDCB->SyncMode & SYNC_ENABLE) && (pDCB->TargetLUN == 0) && + if ( (pDCB->SyncMode & SYNC_ENABLE) && (pDCB->TargetLUN == 0) && (pDCB->Inquiry7 & 0x10) && ( ( ( (pSRB->pcmd->cmnd[0] == REQUEST_SENSE) || (pSRB->SRBFlag & AUTO_REQSENSE) ) && !(pDCB->SyncMode & SYNC_NEGO_DONE) ) || (pSRB->pcmd->cmnd[0] == INQUIRY) ) ) try_sync_nego = 1; @@ -1366,6 +1366,10 @@ pcmd = pSRB->pcmd; DCB_removed = 0; status = pSRB->TargetStatus; + ptr = (PSCSI_INQDATA) (pcmd->request_buffer); + if( pcmd->use_sg ) + ptr = (PSCSI_INQDATA) (((PSGL) ptr)->address); + DEBUG0(printk (" SRBdone (%02x,%08x), SRB %p, pid %li\n", status, pcmd->result,\ pSRB, pcmd->pid);) if(pSRB->SRBFlag & AUTO_REQSENSE) @@ -1491,7 +1495,7 @@ /* Devices are removed below ... */ } else if (status_byte(status) == BUSY && - (pSRB->pcmd->cmnd[0] == TEST_UNIT_READY || pSRB->pcmd->cmnd[0] == INQUIRY) && + (pcmd->cmnd[0] == TEST_UNIT_READY || pcmd->cmnd[0] == INQUIRY) && pACB->scan_devices) { pSRB->AdaptStatus = 0; @@ -1503,6 +1507,7 @@ pSRB->AdaptStatus = 0; if( pSRB->RetryCnt ) { /* Retry */ + //printk ("DC390: retry\n"); pSRB->RetryCnt--; pSRB->TargetStatus = 0; pSRB->SGIndex = 0; @@ -1553,14 +1558,24 @@ SET_RES_DID(pcmd->result,DID_OK); } } + if ((pcmd->result & RES_DID) == 0 && + pcmd->cmnd[0] == INQUIRY && + pcmd->cmnd[2] == 0 && + pcmd->request_bufflen >= 8 && + ptr && + (ptr->Vers & 0x07) >= 2) + pDCB->Inquiry7 = ptr->Flags; ckc_e: if( pACB->scan_devices ) { - if( pSRB->pcmd->cmnd[0] == TEST_UNIT_READY ) + if( pcmd->cmnd[0] == TEST_UNIT_READY || + pcmd->cmnd[0] == INQUIRY) { #ifdef DC390_DEBUG0 - printk (KERN_INFO "DC390: Test_Unit_Ready: result: %08x", pcmd->result); + printk (KERN_INFO "DC390: %s: result: %08x", + (pcmd->cmnd[0] == INQUIRY? "INQUIRY": "TEST_UNIT_READY"), + pcmd->result); if (pcmd->result & (DRIVER_SENSE << 24)) printk (" (sense: %02x %02x %02x %02x)\n", pcmd->sense_buffer[0], pcmd->sense_buffer[1], pcmd->sense_buffer[2], pcmd->sense_buffer[3]); @@ -1571,6 +1586,7 @@ (pcmd->sense_buffer[2] & 0xf) == ILLEGAL_REQUEST) || host_byte(pcmd->result) & DID_ERROR ) { /* device not present: remove */ + //dc390_Going_remove (pDCB, pSRB); dc390_remove_dev (pACB, pDCB); DCB_removed = 1; if( (pcmd->target == pACB->pScsiHost->max_id - 1) && @@ -1590,15 +1606,14 @@ //if( pSRB->pcmd->cmnd[0] == INQUIRY && // (host_byte(pcmd->result) == DID_OK || status_byte(pcmd->result) & CHECK_CONDITION) ) - if( pSRB->pcmd->cmnd[0] == INQUIRY && + if( pcmd->cmnd[0] == INQUIRY && (pcmd->result == (DID_OK << 16) || status_byte(pcmd->result) & CHECK_CONDITION) ) { - ptr = (PSCSI_INQDATA) (pcmd->request_buffer); - if( pcmd->use_sg ) - ptr = (PSCSI_INQDATA) (((PSGL) ptr)->address); - if ((ptr->DevType & SCSI_DEVTYPE) == TYPE_NODEV) + if ((ptr->DevType & SCSI_DEVTYPE) == TYPE_NODEV && !DCB_removed) { + //printk ("DC390: Type = nodev! (%02i-%i)\n", pcmd->target, pcmd->lun); /* device not present: remove */ + //dc390_Going_remove (pDCB, pSRB); dc390_remove_dev (pACB, pDCB); DCB_removed = 1; } else @@ -1613,7 +1628,7 @@ }; #if LINUX_VERSION_CODE > KERNEL_VERSION(2,3,30) - pcmd->resid = pSRB->request_bufflen - pSRB->TotalXferredLen; + pcmd->resid = pcmd->request_bufflen - pSRB->TotalXferredLen; #endif if (!DCB_removed) dc390_Going_remove (pDCB, pSRB); Index: tmscsim.c =================================================================== RCS file: /home/cvsroot/dc390/tmscsim.c,v retrieving revision 2.60.2.19 retrieving revision 2.60.2.30 diff -u -r2.60.2.19 -r2.60.2.30 --- tmscsim.c 2000/05/23 13:12:04 2.60.2.19 +++ tmscsim.c 2000/12/20 01:07:12 2.60.2.30 @@ -7,7 +7,7 @@ ***********************************************************************/ /* (C) Copyright: put under GNU GPL in 10/96 (see README.tmscsim) * *************************************************************************/ -/* $Id: tmscsim.c,v 2.60.2.19 2000/05/23 13:12:04 garloff Exp $ */ +/* $Id: tmscsim.c,v 2.60.2.30 2000/12/20 01:07:12 garloff Exp $ */ /* Enhancements and bugfixes by * * Kurt Garloff * ***********************************************************************/ @@ -153,6 +153,17 @@ * Reset: Unlock, but refuse to queue * * 2.3 __setup function * * 2.0e 00/05/22 KG Return residual for 2.3 * + * 2.0e1 00/05/25 KG Compile fixes for 2.3.99 * + * 2.0e2 00/05/27 KG Jeff Garzik's pci_enable_device() * + * 2.0e3 00/09/29 KG Some 2.4 changes. Don't try Sync Nego * + * before INQUIRY has reported ability. * + * Recognise INQUIRY as scanning command. * + * 2.0e4 00/10/13 KG Allow compilation into 2.4 kernel * + * 2.0e5 00/11/17 KG Store Inq.flags in DCB * + * 2.0e6 00/11/22 KG 2.4 init function (Thx to O.Schumann) * + * 2.4 PCI device table (Thx to A.Richter) * + * 2.0e7 00/11/28 KG Allow overriding of BIOS settings * + * 2.0f 00/12/20 KG Handle failed INQUIRYs during scan * ***********************************************************************/ /* Uncomment SA_INTERRUPT, if the driver refuses to share its IRQ with other devices */ @@ -268,11 +279,24 @@ # endif #endif +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,3,99) +static struct pci_device_id tmscsim_pci_tbl[] __initdata = { + { + vendor: PCI_VENDOR_ID_AMD, + device: PCI_DEVICE_ID_AMD53C974, + subvendor: PCI_ANY_ID, + subdevice: PCI_ANY_ID, + }, + { } /* Terminating entry */ +}; +MODULE_DEVICE_TABLE(pci, tmscsim_pci_tbl); +#endif + #ifdef USE_SPINLOCKS # if USE_SPINLOCKS == 3 /* both */ -# if defined (__SMP__) || DEBUG_SPINLOCKS > 0 +# if defined (CONFIG_SMP) || DEBUG_SPINLOCKS > 0 # define DC390_LOCKA_INIT { spinlock_t __unlocked = SPIN_LOCK_UNLOCKED; pACB->lock = __unlocked; }; # else # define DC390_LOCKA_INIT @@ -460,25 +484,14 @@ static UINT dc390_laststatus = 0; static UCHAR dc390_adapterCnt = 0; -#ifndef CONFIG_SCSI_DC390T_NOGENSUPP /* Startup values, to be overriden on the commandline */ -int tmscsim[] = {7, 1 /* 8MHz */, - PARITY_CHK_ | SEND_START_ | EN_DISCONNECT_ - | SYNC_NEGO_ | TAG_QUEUEING_, - MORE2_DRV | GREATER_1G | RST_SCSI_BUS | ACTIVE_NEGATION - /* | NO_SEEK */ -# ifdef CONFIG_SCSI_MULTI_LUN - | LUN_CHECK -# endif - , 3 /* 16 Tags per LUN */, 1 /* s delay after Reset */ }; +int tmscsim[] = {-2, -2, -2, -2, -2, -2}; # if defined(MODULE) && LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,30) MODULE_PARM(tmscsim, "1-6i"); MODULE_PARM_DESC(tmscsim, "Host SCSI ID, Speed (0=10MHz), Device Flags, Adapter Flags, Max Tags (log2(tags)-1), DelayReset (s)"); # endif -#endif /* CONFIG_SCSI_DC390T_NOGENSUPP */ - #if defined(MODULE) && LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,30) MODULE_AUTHOR("C.L. Huang / Kurt Garloff"); MODULE_DESCRIPTION("SCSI host adapter driver for Tekram DC390 and other AMD53C974A based PCI SCSI adapters"); @@ -544,6 +557,7 @@ static char* dc390_adapname = "DC390"; UCHAR dc390_eepromBuf[MAX_ADAPTER_NUM][EE_LEN]; UCHAR dc390_clock_period1[] = {4, 5, 6, 7, 8, 10, 13, 20}; +UCHAR dc390_clock_speed[] = {100,80,67,57,50, 40, 31, 20}; #if LINUX_VERSION_CODE < KERNEL_VERSION(2,3,30) struct proc_dir_entry DC390_proc_scsi_tmscsim ={ @@ -574,53 +588,92 @@ udelay(160); } -#ifndef CONFIG_SCSI_DC390T_NOGENSUPP -static void __init dc390_EEpromDefaults (UCHAR index) + +/* Override EEprom values with explicitly set values */ +static void __init dc390_EEprom_Override (UCHAR index) { PUCHAR ptr; UCHAR id; ptr = (PUCHAR) dc390_eepromBuf[index]; /* Adapter Settings */ - ptr[EE_ADAPT_SCSI_ID] = (UCHAR)tmscsim[0]; /* Adapter ID */ - ptr[EE_MODE2] = (UCHAR)tmscsim[3]; - ptr[EE_DELAY] = tmscsim[5]; /* Reset delay */ - ptr[EE_TAG_CMD_NUM] = (UCHAR)tmscsim[4]; /* Tagged Cmds */ + if (tmscsim[0] != -2) + ptr[EE_ADAPT_SCSI_ID] = (UCHAR)tmscsim[0]; /* Adapter ID */ + if (tmscsim[3] != -2) + ptr[EE_MODE2] = (UCHAR)tmscsim[3]; + if (tmscsim[5] != -2) + ptr[EE_DELAY] = tmscsim[5]; /* Reset delay */ + if (tmscsim[4] != -2) + ptr[EE_TAG_CMD_NUM] = (UCHAR)tmscsim[4]; /* Tagged Cmds */ /* Device Settings */ for (id = 0; id < MAX_SCSI_ID; id++) { - ptr[id<<2] = (UCHAR)tmscsim[2]; /* EE_MODE1 */ - ptr[(id<<2) + 1] = (UCHAR)tmscsim[1]; /* EE_Speed */ + if (tmscsim[2] != -2) + ptr[id<<2] = (UCHAR)tmscsim[2]; /* EE_MODE1 */ + if (tmscsim[1] != -2) + ptr[(id<<2) + 1] = (UCHAR)tmscsim[1]; /* EE_Speed */ }; - dc390_adapname = "AM53C974"; } -static void __init dc390_checkparams (void) +/* Handle "-1" case */ +static void __init dc390_check_for_safe_settings (void) { - PARSEDEBUG(printk(KERN_INFO "DC390: setup %08x %08x %08x %08x %08x %08x\n", tmscsim[0],\ - tmscsim[1], tmscsim[2], tmscsim[3], tmscsim[4], tmscsim[5]);) - if (tmscsim[0] < 0 || tmscsim[0] > 7) /* modules-2.0.0 passes -1 as string */ + if (tmscsim[0] == -1 || tmscsim[0] > 15) /* modules-2.0.0 passes -1 as string */ { - tmscsim[0] = 7; tmscsim[1] = 4; - tmscsim[2] = 9; tmscsim[3] = 15; + tmscsim[0] = 7; tmscsim[1] = 4; + tmscsim[2] = 0x09; tmscsim[3] = 0x0f; tmscsim[4] = 2; tmscsim[5] = 10; printk (KERN_INFO "DC390: Using safe settings.\n"); } - else +} + + +#ifndef CONFIG_SCSI_DC390T_NOGENSUPP +int __initdata tmscsim_def[] = {7, 0 /* 10MHz */, + PARITY_CHK_ | SEND_START_ | EN_DISCONNECT_ + | SYNC_NEGO_ | TAG_QUEUEING_, + MORE2_DRV | GREATER_1G | RST_SCSI_BUS | ACTIVE_NEGATION + /* | NO_SEEK */ +# ifdef CONFIG_SCSI_MULTI_LUN + | LUN_CHECK +# endif + , 3 /* 16 Tags per LUN */, 1 /* s delay after Reset */ }; + +/* Copy defaults over set values where missing */ +static void __init dc390_fill_with_defaults (void) +{ + int i; + PARSEDEBUG(printk(KERN_INFO "DC390: setup %08x %08x %08x %08x %08x %08x\n", tmscsim[0],\ + tmscsim[1], tmscsim[2], tmscsim[3], tmscsim[4], tmscsim[5]);) + for (i = 0; i < 6; i++) { - /* if (tmscsim[0] < 0 || tmscsim[0] > 7) tmscsim[0] = 7; */ - if (tmscsim[1] < 0 || tmscsim[1] > 7) tmscsim[1] = 4; - if (tmscsim[4] < 0 || tmscsim[4] > 5) tmscsim[4] = 4; - if (tmscsim[5] > 180) tmscsim[5] = 180; - }; + if (tmscsim[i] < 0 || tmscsim[i] > 255) + tmscsim[i] = tmscsim_def[i]; + } + /* Sanity checks */ + if (tmscsim[0] > 7) tmscsim[0] = 7; + if (tmscsim[1] > 7) tmscsim[1] = 4; + if (tmscsim[4] > 5) tmscsim[4] = 4; + if (tmscsim[5] > 180) tmscsim[5] = 180; }; +#endif + /* Override defaults on cmdline: * tmscsim: AdaptID, MaxSpeed (Index), DevMode (Bitmapped), AdaptMode (Bitmapped) */ +#if LINUX_VERSION_CODE > KERNEL_VERSION(2,3,13) +void __init dc390_setup (char *str) +{ + int ints[8]; + int i, im; + (void)get_options (str, ARRAY_SIZE(ints), ints); +#else void __init dc390_setup (char *str, int *ints) { - int i, im = ints[0]; + int i, im; +#endif + im = ints[0]; if (im > 6) { printk (KERN_NOTICE "DC390: ignore extra params!\n"); @@ -630,7 +683,6 @@ tmscsim[i] = ints[i+1]; /* dc390_checkparams (); */ }; -#endif /* CONFIG_SCSI_DC390T_NOGENSUPP */ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,3,13) #ifndef MODULE @@ -1198,7 +1250,8 @@ return (0); } - if( (pACB->scan_devices || cmd->cmnd[0] == TEST_UNIT_READY) && !(pACB->DCBmap[cmd->target] & (1 << cmd->lun)) ) + if( (pACB->scan_devices || cmd->cmnd[0] == TEST_UNIT_READY || cmd->cmnd[0] == INQUIRY) && + !(pACB->DCBmap[cmd->target] & (1 << cmd->lun)) ) { pACB->scan_devices = 1; @@ -1208,7 +1261,7 @@ printk (KERN_ERR "DC390: kmalloc for DCB failed, target %02x lun %02x\n", cmd->target, cmd->lun); DC390_UNLOCK_ACB; - printk ("DC390: No DCB in queuecommand!\n"); + printk ("DC390: No DCB in queue_command!\n"); #ifdef USE_NEW_EH return (1); #else @@ -1828,6 +1881,7 @@ pDCB->CtrlR3 = pDCB2->CtrlR3; pDCB->CtrlR4 = pDCB2->CtrlR4; + pDCB->Inquiry7 = pDCB2->Inquiry7; } else { @@ -1842,6 +1896,7 @@ pDCB->CtrlR4 = pACB->glitch_cfg | CTRL4_RESERVED; if( dc390_eepromBuf[index][EE_MODE2] & ACTIVE_NEGATION) pDCB->CtrlR4 |= NEGATE_REQACKDATA | NEGATE_REQACK; + pDCB->Inquiry7 = 0; } pACB->DCBmap[id] |= (1 << lun); @@ -1948,7 +2003,11 @@ psh->io_port = io_port; psh->n_io_port = 0x80; psh->irq = Irq; +#if LINUX_VERSION_CODE > KERNEL_VERSION(2,3,50) + psh->base = io_port; +#else psh->base = (char*)io_port; +#endif psh->unique_id = io_port; psh->dma_channel = -1; psh->last_reset = jiffies; @@ -2117,18 +2176,24 @@ printk (KERN_ERR "DC390_init: No EEPROM found!\n"); return( -1 ); #else - int period; - printk (KERN_INFO "DC390_init: No EEPROM found!\n"); - printk (KERN_INFO "DC390_init: Trying default EEPROM settings:\n"); - dc390_checkparams (); - period = dc390_clock_period1[tmscsim[1]]; + int speed; + dc390_adapname = "AM53C974"; + printk (KERN_INFO "DC390_init: No EEPROM found! Trying default settings ...\n"); + dc390_check_for_safe_settings (); + dc390_fill_with_defaults (); + dc390_EEprom_Override (index); + speed = dc390_clock_speed[tmscsim[1]]; printk (KERN_INFO "DC390: Used defaults: AdaptID=%i, SpeedIdx=%i (%i.%i MHz)," " DevMode=0x%02x, AdaptMode=0x%02x, TaggedCmnds=%i (%i), DelayReset=%is\n", - tmscsim[0], tmscsim[1], 40 / period, ((40%period)*10 + period/2) / period, + tmscsim[0], tmscsim[1], speed/10, speed%10, (UCHAR)tmscsim[2], (UCHAR)tmscsim[3], tmscsim[4], 2 << (tmscsim[4]), tmscsim[5]); - dc390_EEpromDefaults (index); #endif - }; + } + else + { + dc390_check_for_safe_settings (); + dc390_EEprom_Override (index); + } psh = scsi_register( psht, sizeof(DC390_ACB) ); if( !psh ) return( -1 ); @@ -2242,6 +2307,10 @@ if ( PCI_PRESENT ) while (PCI_FIND_DEVICE (PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD53C974)) { +#if LINUX_VERSION_CODE > KERNEL_VERSION(2,3,30) + if (pci_enable_device (pdev)) + continue; +#endif //DC390_LOCK_IO; /* Remove this when going to new eh */ PCI_GET_IO_AND_IRQ; DEBUG0(printk(KERN_INFO "DC390(%i): IO_PORT=%04x,IRQ=%x\n", dc390_adapterCnt, (UINT) io_port, irq);) @@ -2980,7 +3049,12 @@ DC390_UNLOCK_IO; return( 1 ); } +#endif /* def MODULE */ +#if LINUX_VERSION_CODE > KERNEL_VERSION(2,3,99) +static Scsi_Host_Template driver_template = DC390_T; +#include "scsi_module.c" +#elif defined(MODULE) Scsi_Host_Template driver_template = DC390_T; #include "scsi_module.c" -#endif /* def MODULE */ +#endif Index: tmscsim.h =================================================================== RCS file: /home/cvsroot/dc390/tmscsim.h,v retrieving revision 2.15.2.1 retrieving revision 2.15.2.3 diff -u -r2.15.2.1 -r2.15.2.3 --- tmscsim.h 2000/02/08 21:53:57 2.15.2.1 +++ tmscsim.h 2000/11/17 20:52:27 2.15.2.3 @@ -3,12 +3,22 @@ ;* TEKRAM DC-390(T) PCI SCSI Bus Master Host Adapter * ;* Device Driver * ;***********************************************************************/ -/* $Id: tmscsim.h,v 2.15.2.1 2000/02/08 21:53:57 garloff Exp $ */ +/* $Id: tmscsim.h,v 2.15.2.3 2000/11/17 20:52:27 garloff Exp $ */ #ifndef _TMSCSIM_H #define _TMSCSIM_H #include +#include +/* 2.0 compat */ +#if defined(__SMP__) && !defined(CONFIG_SMP) +# if LINUX_VERSION_CODE < KERNEL_VERSION (2,2,0) +# define CONFIG_SMP +# else +# error __SMP__ defined but not CONFIG_SMP +# endif +#endif + #define IRQ_NONE 255 @@ -163,7 +173,7 @@ UCHAR CtrlR1; UCHAR CtrlR3; UCHAR CtrlR4; -UCHAR pad; +UCHAR Inquiry7; /* 0x2c: */ UCHAR SyncMode; /*; 0:async mode */ @@ -222,7 +232,7 @@ UCHAR pad; /* 0x3c: */ -#if defined(USE_SPINLOCKS) && USE_SPINLOCKS > 1 && (defined(__SMP__) || DEBUG_SPINLOCKS > 0) +#if defined(USE_SPINLOCKS) && USE_SPINLOCKS > 1 && (defined(CONFIG_SMP) || DEBUG_SPINLOCKS > 0) spinlock_t lock; #endif UCHAR sel_timeout; @@ -438,8 +448,12 @@ /* Peripheral Device Type definitions */ /* see include/scsi/scsi.h for the rest */ -#define TYPE_PRINTER 0x02 /* Printer device */ -#define TYPE_COMM 0x09 /* Communications device */ +#ifndef TYPE_PRINTER +# define TYPE_PRINTER 0x02 /* Printer device */ +#endif +#ifndef TYPE_COMM +# define TYPE_COMM 0x09 /* Communications device */ +#endif /* ** Inquiry flag definitions (Inq data byte 7)