Date: Mon, 23 Feb 1998 11:01:03 GMT
From: Jesper Skov <jskov@cygnus.co.uk>
To: linux-m68k@lists.linux-m68k.org
cc: Jes.Sorensen@cern.ch
Subject: L68K: Blz1230 MKI/II diffs
Sender: owner-linux-m68k@phil.uni-sb.de


Here's the diff for the driver.

diff -u --recursive -B --exclude-from=/home/jskov/lib/diff-excludes -P /home/jskov/kernel/dist/linux-2.1.85/arch/m68k/config.in ./arch/m68k/config.in
--- /home/jskov/kernel/dist/linux-2.1.85/arch/m68k/config.in	Fri Feb  6 11:17:55 1998
+++ ./arch/m68k/config.in	Sun Feb 22 11:38:17 1998
@@ -183,6 +183,10 @@
   bool 'CyberStorm SCSI Mk II support' CONFIG_CYBERSTORMII_SCSI
   bool 'Blizzard 2060 SCSI support' CONFIG_BLZ2060_SCSI
   bool 'Blizzard 1230IV/1260 SCSI support' CONFIG_BLZ1230_SCSI
+  if [ "$CONFIG_BLZ1230_SCSI" = "n" ]; then
+    define_bool CONFIG_BLZ1230_SCSI y
+    bool 'Blizzard 1230I/II SCSI support' CONFIG_BLZII1230_SCSI
+  fi
   bool 'Fastlane SCSI support' CONFIG_FASTLANE_SCSI
   if [ "$CONFIG_EXPERIMENTAL" = "y" ]; then
     bool 'A4000T SCSI support' CONFIG_A4000T_SCSI
diff -u --recursive -B --exclude-from=/home/jskov/lib/diff-excludes -P /home/jskov/kernel/dist/linux-2.1.85/drivers/scsi/blz1230.c ./drivers/scsi/blz1230.c
--- /home/jskov/kernel/dist/linux-2.1.85/drivers/scsi/blz1230.c	Thu Nov 13 11:56:32 1997
+++ ./drivers/scsi/blz1230.c	Sun Feb 22 11:48:37 1998
@@ -4,6 +4,11 @@
  *
  * This driver is based on the CyberStorm driver, hence the occasional
  * reference to CyberStorm.
+ *
+ * Depending on the CONFIG_BLZ1230II_SCSI flag, this driver will be
+ * configured to run either MK I/II (true) or MK IV (false) controllers.
+ *
+ * Added support for MK I and II on 22.02.98
  */
 
 /* TODO:
@@ -14,6 +19,7 @@
  *    routines in this file used to be inline!
  */
 
+#include <linux/config.h>
 #include <linux/kernel.h>
 #include <linux/delay.h>
 #include <linux/types.h>
@@ -35,8 +41,6 @@
 
 #include <asm/pgtable.h>
 
-#define MKIV 1
-
 static int  dma_bytes_sent(struct NCR_ESP *esp, int fifo_count);
 static int  dma_can_transfer(struct NCR_ESP *esp, Scsi_Cmnd *sp);
 static void dma_dump_state(struct NCR_ESP *esp);
@@ -63,7 +67,7 @@
 	unsigned long address;
 	struct ESP_regs *eregs;
 
-#if MKIV
+#ifndef CONFIG_BLZ1230II_SCSI
 	if ((key = zorro_find(ZORRO_PROD_PHASE5_BLIZZARD_1230_IV_1260, 0, 0))){
 #else
 	if ((key = zorro_find(ZORRO_PROD_PHASE5_BLIZZARD_1230_II_FASTLANE_Z3_CYBERSCSI_CYBERSTORM060, 0, 0))){
@@ -74,7 +78,7 @@
 		 * equipped with a SCSI controller
 		 */
 		address = (unsigned long)ZTWO_VADDR(esp_dev->cd_BoardAddr);
-#if MKIV
+#ifndef CONFIG_BLZ1230II_SCSI
 		eregs = (struct ESP_regs *)(address + BLZ1230_ESP_ADDR);
 #else
 		eregs = (struct ESP_regs *)(address + BLZ1230II_ESP_ADDR);
@@ -120,7 +124,7 @@
 		 * relative to the device (i.e. in the same Zorro
 		 * I/O block).
 		 */
-#if MKIV
+#ifndef CONFIG_BLZ1230II_SCSI
 		esp->dregs = (void *)(address + BLZ1230_DMA_ADDR);
 #else
 		esp->dregs = (void *)(address + BLZ1230II_DMA_ADDR);
@@ -135,7 +139,7 @@
 
 		esp->irq = IRQ_AMIGA_PORTS;
 		request_irq(IRQ_AMIGA_PORTS, esp_intr, 0, 
-			    "Blizzard 1230 SCSI IV", esp_intr);
+			    BLZ1230_NAME, esp_intr);
 
 		/* Figure out our scsi ID on the bus */
 		esp->scsi_id = 7;
@@ -168,12 +172,21 @@
 
 static int dma_can_transfer(struct NCR_ESP *esp, Scsi_Cmnd *sp)
 {
-	/* I don't think there's any limit on the Blizzard DMA. So we use what
-	 * the ESP chip can handle (24 bit).
-	 */
 	unsigned long sz = sp->SCp.this_residual;
+#ifndef CONFIG_BLZ1230II_SCSI
+	/* There is no limit on the Blizzard IV DMA. */
 	if(sz > 0x1000000)
 		sz = 0x1000000;
+#else
+	/* Don't DMA across 1k boundaries on MK I/II. */
+	{
+		unsigned long mem_ptr = sp->SCp.ptr;
+		unsigned long next_limit = (mem_ptr + 0x400) & ~0x3ff;
+
+		if (sz > (next_limit - mem_ptr))
+			sz = next_limit - mem_ptr;
+	}
+#endif
 	return sz;
 }
 
@@ -185,7 +198,7 @@
 
 void dma_init_read(struct NCR_ESP *esp, __u32 addr, int length)
 {
-#if MKIV
+#ifndef CONFIG_BLZ1230II_SCSI
 	struct blz1230_dma_registers *dregs = 
 		(struct blz1230_dma_registers *) (esp->dregs);
 #else
@@ -202,7 +215,7 @@
 	dregs->dma_latch = (addr >> 24) & 0xff;
 
 	/* Then pump the address to the DMA address register */
-#if MKIV
+#ifndef CONFIG_BLZ1230II_SCSI
 	dregs->dma_addr = (addr >> 24) & 0xff;
 #endif
 	dregs->dma_addr = (addr >> 16) & 0xff;
@@ -212,7 +225,7 @@
 
 void dma_init_write(struct NCR_ESP *esp, __u32 addr, int length)
 {
-#if MKIV
+#ifndef CONFIG_BLZ1230II_SCSI
 	struct blz1230_dma_registers *dregs = 
 		(struct blz1230_dma_registers *) (esp->dregs);
 #else
@@ -229,7 +242,7 @@
 	dregs->dma_latch = (addr >> 24) & 0xff;
 
 	/* Then pump the address to the DMA address register */
-#if MKIV
+#ifndef CONFIG_BLZ1230II_SCSI
 	dregs->dma_addr = (addr >> 24) & 0xff;
 #endif
 	dregs->dma_addr = (addr >> 16) & 0xff;
diff -u --recursive -B --exclude-from=/home/jskov/lib/diff-excludes -P /home/jskov/kernel/dist/linux-2.1.85/drivers/scsi/blz1230.h ./drivers/scsi/blz1230.h
--- /home/jskov/kernel/dist/linux-2.1.85/drivers/scsi/blz1230.h	Tue Jan  6 17:20:19 1998
+++ ./drivers/scsi/blz1230.h	Sun Feb 22 11:48:16 1998
@@ -56,8 +56,14 @@
 extern int esp_proc_info(char *buffer, char **start, off_t offset, int length,
 			 int hostno, int inout);
 
+#ifndef CONFIG_BLZ1230II_SCSI
+#define BLZ1230_NAME "Blizzard1230 SCSI IV"
+#else
+#define BLZ1230_NAME "Blizzard1230 SCSI II"
+#endif
+
 #define SCSI_BLZ1230      { proc_dir:		&proc_scsi_esp, \
-			    name:		"Blizzard1230 SCSI IV", \
+			    name:		BLZ1230_NAME, \
 			    detect:		blz1230_esp_detect, \
 			    release:		NULL, \
 			    queuecommand:	esp_queue, \
diff -u --recursive -B --exclude-from=/home/jskov/lib/diff-excludes -P /home/jskov/kernel/dist/linux-2.1.85/drivers/scsi/fastlane.c ./drivers/scsi/fastlane.c
--- /home/jskov/kernel/dist/linux-2.1.85/drivers/scsi/fastlane.c	Sun Dec 14 21:36:58 1997
+++ ./drivers/scsi/fastlane.c	Sun Feb  8 10:19:38 1998
@@ -223,6 +223,15 @@
 		(struct fastlane_dma_registers *) (esp->dregs);
 	unsigned long *t;
 	
+	/* Verify that requested DMA transfer is correct aligned and
+	 * has a word-even length. The Fastlane DMA controller cannot
+	 * handle the transfer if this is not satisfied. -jskov
+	 */
+	if (addr & 3 || length & 3)
+		printk ("\n**** fastlane.c:dma_init_read:\n"
+			" Cannot handle requested address or length "
+			"(%08x, %08x)\n", addr, length);
+
 	cache_clear(addr, length);
 
 	dma_clear(esp);
@@ -241,6 +250,12 @@
 	struct fastlane_dma_registers *dregs = 
 		(struct fastlane_dma_registers *) (esp->dregs);
 	unsigned long *t;
+
+	/* See comment in dma_init_read. */
+	if (addr & 3 || length & 3)
+		printk ("\n**** fastlane.c:dma_init_write:\n"
+			" Cannot handle requested address or length "
+			"(%08x, %08x)\n", addr, length);
 
 	cache_push(addr, length);
 
