#include "sun3_scsi.h"
#include "NCR5380.h"
+/* #define OLDDMA */
+
#define USE_WRAPPER
-#define RESET_BOOT
+/*#define RESET_BOOT */
#define DRIVER_SETUP
#define NDEBUG 0
#undef DRIVER_SETUP
#endif
-#undef SUPPORT_TAGS
+/* #define SUPPORT_TAGS */
#define ENABLE_IRQ() enable_irq( IRQ_SUN3_SCSI );
static inline void sun3scsi_write(int reg, int value);
static int setup_can_queue = -1;
+MODULE_PARM(setup_can_queue, "i");
static int setup_cmd_per_lun = -1;
+MODULE_PARM(setup_cmd_per_lun, "i");
static int setup_sg_tablesize = -1;
+MODULE_PARM(setup_sg_tablesize, "i");
#ifdef SUPPORT_TAGS
static int setup_use_tagged_queuing = -1;
+MODULE_PARM(setup_use_tagged_queuing, "i");
#endif
static int setup_hostid = -1;
+MODULE_PARM(setup_hostid, "i");
static Scsi_Cmnd *sun3_dma_setup_done = NULL;
static volatile unsigned char *sun3_scsi_regp;
static volatile struct sun3_dma_regs *dregs;
+#ifdef OLDDMA
static unsigned char *dmabuf = NULL; /* dma memory buffer */
+#endif
static struct sun3_udc_regs *udc_regs = NULL;
static unsigned char *sun3_dma_orig_addr = NULL;
static unsigned long sun3_dma_orig_count = 0;
int sun3scsi_detect(Scsi_Host_Template * tpnt)
{
- unsigned long ioaddr, iopte;
- int count = 0;
+ unsigned long ioaddr;
static int called = 0;
struct Scsi_Host *instance;
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;
- }
-
+ 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)))
#endif
#ifdef SUPPORT_TAGS
if (setup_use_tagged_queuing < 0)
- setup_use_tagged_queuing = DEFAULT_USE_TAGGED_QUEUING;
+ setup_use_tagged_queuing = USE_TAGGED_QUEUING;
#endif
instance = scsi_register (tpnt, sizeof(struct NCR5380_hostdata));
dregs->fifo_count = 0;
called = 1;
+
+#ifdef RESET_BOOT
+ sun3_scsi_reset_boot(instance);
+#endif
+
return 1;
}
+#ifdef MODULE
int sun3scsi_release (struct Scsi_Host *shpnt)
{
if (shpnt->irq != IRQ_NONE)
free_irq (shpnt->irq, NULL);
+ iounmap(sun3_scsi_regp);
+
return 0;
}
+#endif
#ifdef RESET_BOOT
/*
printk( "Sun3 SCSI: resetting the SCSI bus..." );
/* switch off SCSI IRQ - catch an interrupt without IRQ bit set else */
- sun3_disable_irq( IRQ_SUN3_SCSI );
+// sun3_disable_irq( IRQ_SUN3_SCSI );
/* get in phase */
NCR5380_write( TARGET_COMMAND_REG,
barrier();
/* switch on SCSI IRQ again */
- sun3_enable_irq( IRQ_SUN3_SCSI );
+// sun3_enable_irq( IRQ_SUN3_SCSI );
printk( " done\n" );
}
#else
void *addr;
+ if(sun3_dma_orig_addr != NULL)
+ dvma_unmap(sun3_dma_orig_addr);
+
// addr = sun3_dvma_page((unsigned long)data, (unsigned long)dmabuf);
addr = (void *)dvma_map((unsigned long) data, count);
+
sun3_dma_orig_addr = addr;
sun3_dma_orig_count = count;
#endif
dregs->csr &= ~CSR_FIFO;
dregs->csr |= CSR_FIFO;
-
if(dregs->fifo_count != count) {
printk("scsi%d: fifo_mismatch %04x not %04x\n",
default_instance->host_no, dregs->fifo_count,
static inline unsigned long sun3scsi_dma_xfer_len(unsigned long wanted, Scsi_Cmnd *cmd,
int write_flag)
{
- if((cmd->request->cmd == 0) || (cmd->request->cmd == 1))
+ if(cmd->request->flags & REQ_CMD)
return wanted;
else
return 0;
int ret = 0;
sun3_dma_active = 0;
-
+#if 1
// check to empty the fifo on a read
if(!write_flag) {
int tmo = 200000; /* 2 sec */
if(dregs->csr & CSR_FIFO_EMPTY)
break;
- if(--tmo <= 0)
+ if(--tmo <= 0) {
+ printk("sun3scsi: fifo failed to empty!\n");
return 1;
-
+ }
udelay(10);
}
}
+#endif
count = sun3scsi_dma_count(default_instance);
#ifdef OLDDMA
}
dvma_unmap(sun3_dma_orig_addr);
+ sun3_dma_orig_addr = NULL;
#endif
sun3_udc_write(UDC_RESET, UDC_CSR);
dregs->fifo_count = 0;