···2222#include <linux/stat.h>232324242525+#define CHECK_WD33C932626+2527static irqreturn_t gvp11_intr(int irq, void *data)2628{2729 struct Scsi_Host *instance = data;···169167 }170168}171169172172-#define CHECK_WD33C93170170+static int __init check_wd33c93(gvp11_scsiregs *regs)171171+{172172+#ifdef CHECK_WD33C93173173+ volatile unsigned char *sasr_3393, *scmd_3393;174174+ unsigned char save_sasr;175175+ unsigned char q, qq;176176+177177+ /*178178+ * These darn GVP boards are a problem - it can be tough to tell179179+ * whether or not they include a SCSI controller. This is the180180+ * ultimate Yet-Another-GVP-Detection-Hack in that it actually181181+ * probes for a WD33c93 chip: If we find one, it's extremely182182+ * likely that this card supports SCSI, regardless of Product_183183+ * Code, Board_Size, etc.184184+ */185185+186186+ /* Get pointers to the presumed register locations and save contents */187187+188188+ sasr_3393 = ®s->SASR;189189+ scmd_3393 = ®s->SCMD;190190+ save_sasr = *sasr_3393;191191+192192+ /* First test the AuxStatus Reg */193193+194194+ q = *sasr_3393; /* read it */195195+ if (q & 0x08) /* bit 3 should always be clear */196196+ return -ENODEV;197197+ *sasr_3393 = WD_AUXILIARY_STATUS; /* setup indirect address */198198+ if (*sasr_3393 == WD_AUXILIARY_STATUS) { /* shouldn't retain the write */199199+ *sasr_3393 = save_sasr; /* Oops - restore this byte */200200+ return -ENODEV;201201+ }202202+ if (*sasr_3393 != q) { /* should still read the same */203203+ *sasr_3393 = save_sasr; /* Oops - restore this byte */204204+ return -ENODEV;205205+ }206206+ if (*scmd_3393 != q) /* and so should the image at 0x1f */207207+ return -ENODEV;208208+209209+ /*210210+ * Ok, we probably have a wd33c93, but let's check a few other places211211+ * for good measure. Make sure that this works for both 'A and 'B212212+ * chip versions.213213+ */214214+215215+ *sasr_3393 = WD_SCSI_STATUS;216216+ q = *scmd_3393;217217+ *sasr_3393 = WD_SCSI_STATUS;218218+ *scmd_3393 = ~q;219219+ *sasr_3393 = WD_SCSI_STATUS;220220+ qq = *scmd_3393;221221+ *sasr_3393 = WD_SCSI_STATUS;222222+ *scmd_3393 = q;223223+ if (qq != q) /* should be read only */224224+ return -ENODEV;225225+ *sasr_3393 = 0x1e; /* this register is unimplemented */226226+ q = *scmd_3393;227227+ *sasr_3393 = 0x1e;228228+ *scmd_3393 = ~q;229229+ *sasr_3393 = 0x1e;230230+ qq = *scmd_3393;231231+ *sasr_3393 = 0x1e;232232+ *scmd_3393 = q;233233+ if (qq != q || qq != 0xff) /* should be read only, all 1's */234234+ return -ENODEV;235235+ *sasr_3393 = WD_TIMEOUT_PERIOD;236236+ q = *scmd_3393;237237+ *sasr_3393 = WD_TIMEOUT_PERIOD;238238+ *scmd_3393 = ~q;239239+ *sasr_3393 = WD_TIMEOUT_PERIOD;240240+ qq = *scmd_3393;241241+ *sasr_3393 = WD_TIMEOUT_PERIOD;242242+ *scmd_3393 = q;243243+ if (qq != (~q & 0xff)) /* should be read/write */244244+ return -ENODEV;245245+#endif /* CHECK_WD33C93 */246246+247247+ return 0;248248+}173249174250int __init gvp11_detect(struct scsi_host_template *tpnt)175251{···261181 gvp11_scsiregs *regs;262182 wd33c93_regs wdregs;263183 int num_gvp11 = 0;264264-#ifdef CHECK_WD33C93265265- volatile unsigned char *sasr_3393, *scmd_3393;266266- unsigned char save_sasr;267267- unsigned char q, qq;268268-#endif269184270185 if (!MACH_IS_AMIGA || called)271186 return 0;···301226 if (!request_mem_region(address, 256, "wd33c93"))302227 continue;303228304304-#ifdef CHECK_WD33C93305305-306306- /*307307- * These darn GVP boards are a problem - it can be tough to tell308308- * whether or not they include a SCSI controller. This is the309309- * ultimate Yet-Another-GVP-Detection-Hack in that it actually310310- * probes for a WD33c93 chip: If we find one, it's extremely311311- * likely that this card supports SCSI, regardless of Product_312312- * Code, Board_Size, etc.313313- */314314-315315- /* Get pointers to the presumed register locations and save contents */316316-317317- sasr_3393 = &(((gvp11_scsiregs *)(ZTWO_VADDR(address)))->SASR);318318- scmd_3393 = &(((gvp11_scsiregs *)(ZTWO_VADDR(address)))->SCMD);319319- save_sasr = *sasr_3393;320320-321321- /* First test the AuxStatus Reg */322322-323323- q = *sasr_3393; /* read it */324324- if (q & 0x08) /* bit 3 should always be clear */229229+ regs = (gvp11_scsiregs *)(ZTWO_VADDR(address));230230+ if (check_wd33c93(regs))325231 goto release;326326- *sasr_3393 = WD_AUXILIARY_STATUS; /* setup indirect address */327327- if (*sasr_3393 == WD_AUXILIARY_STATUS) { /* shouldn't retain the write */328328- *sasr_3393 = save_sasr; /* Oops - restore this byte */329329- goto release;330330- }331331- if (*sasr_3393 != q) { /* should still read the same */332332- *sasr_3393 = save_sasr; /* Oops - restore this byte */333333- goto release;334334- }335335- if (*scmd_3393 != q) /* and so should the image at 0x1f */336336- goto release;337337-338338- /*339339- * Ok, we probably have a wd33c93, but let's check a few other places340340- * for good measure. Make sure that this works for both 'A and 'B341341- * chip versions.342342- */343343-344344- *sasr_3393 = WD_SCSI_STATUS;345345- q = *scmd_3393;346346- *sasr_3393 = WD_SCSI_STATUS;347347- *scmd_3393 = ~q;348348- *sasr_3393 = WD_SCSI_STATUS;349349- qq = *scmd_3393;350350- *sasr_3393 = WD_SCSI_STATUS;351351- *scmd_3393 = q;352352- if (qq != q) /* should be read only */353353- goto release;354354- *sasr_3393 = 0x1e; /* this register is unimplemented */355355- q = *scmd_3393;356356- *sasr_3393 = 0x1e;357357- *scmd_3393 = ~q;358358- *sasr_3393 = 0x1e;359359- qq = *scmd_3393;360360- *sasr_3393 = 0x1e;361361- *scmd_3393 = q;362362- if (qq != q || qq != 0xff) /* should be read only, all 1's */363363- goto release;364364- *sasr_3393 = WD_TIMEOUT_PERIOD;365365- q = *scmd_3393;366366- *sasr_3393 = WD_TIMEOUT_PERIOD;367367- *scmd_3393 = ~q;368368- *sasr_3393 = WD_TIMEOUT_PERIOD;369369- qq = *scmd_3393;370370- *sasr_3393 = WD_TIMEOUT_PERIOD;371371- *scmd_3393 = q;372372- if (qq != (~q & 0xff)) /* should be read/write */373373- goto release;374374-#endif375232376233 instance = scsi_register(tpnt, sizeof(struct WD33C93_hostdata));377234 if (instance == NULL)···318311 else319312 hdata->dma_xfer_mask = default_dma_xfer_mask;320313321321- regs = (gvp11_scsiregs *)(instance->base);322314 regs->secret2 = 1;323315 regs->secret1 = 0;324316 regs->secret3 = 15;