[PATCH] Add 82077 FDC to sun4c

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi all,

The attached patch adds in code to support an 82077 FDC on sun4c systems. There is a problem with spurious interrupts but it does apear to work (very slowly).
Testing on my SS2 (82072A FDC) shows that the floppy driver is not 100% with
sun4c any way (any spurious interrupt kills it, requiring a reboot to recover). The disk drive may have a somthing to do with the failure as it has not been used/cleaned for some time.

My view is that floppy support on Sparc32 should be changed to be
'EXPERIMENTAL'. Maybe it works better on sun4m - anyone out there who can check this?

The floppy driver code in drivers/block/floppy.c is not easy work with so I do not plan to try to work out what the spurious interrupt problem is in the near future.

Regards
	Mark Fortescue.
From: Mark Fortescue <mark@xxxxxxxxxxxxxxxxxx>

Add in code to support an 82077 FDC on sun4c systems. There is a problem with
spurious interrupts but it does apear to work (very slowly).
Testing on my SS2 (82072A FDC) shows that the floppy driver is not 100% with
sun4c any way (any spurious interrupt kills it, requiring a reboot to recover).

Signed-off-by: Mark Fortescue <mark@xxxxxxxxxxxxxxxxxx>
---
diff -ruNpd -x .git -x .gitignore -x .mailmap linux-2.6/include/asm-sparc/floppy.h linux-test/include/asm-sparc/floppy.h
--- linux-2.6/include/asm-sparc/floppy.h	2007-07-21 03:26:52.000000000 +0100
+++ linux-test/include/asm-sparc/floppy.h	2007-07-25 11:05:42.000000000 +0100
@@ -154,6 +154,31 @@ static void sun_82072_fd_outb(unsigned c
 	return;
 }
 
+static unsigned char sun_82077_sun4c_fd_inb(int port)
+{
+	udelay(5);
+	switch(port & 7) {
+	default:
+		printk("floppy: Asked to read unknown port %d\n", port);
+		panic("floppy: Port bolixed.");
+	case 0: /* FD_STATUS_0 (RO)  */
+		return sun_fdc->status1_82077;
+	case 1: /* FD_STATUS_1 (RO)  */
+		return sun_fdc->status2_82077;
+	case 2: /* FD_DOR      (R/W) */
+		return sun_fdc->dor_82077;
+	case 3: /* FD_TDR      (R/W) */
+		return sun_fdc->tapectl_82077;
+	case 4: /* FD_STATUS   (RO)  */
+		return sun_fdc->status_82077 & ~STATUS_DMA;
+	case 5: /* FD_DATA     (R/W) */
+		return sun_fdc->data_82077;
+	case 7: /* FD_DIR      (RO)  */
+		return sun_fdc->dir_82077 | ((get_auxio() & AUXIO_FLPY_DCHG) ? 0x80 : 0);
+	};
+	panic("sun_82077_sun4c_fd_inb: How did I get here?");
+}
+
 static unsigned char sun_82077_fd_inb(int port)
 {
 	udelay(5);
@@ -161,15 +186,65 @@ static unsigned char sun_82077_fd_inb(in
 	default:
 		printk("floppy: Asked to read unknown port %d\n", port);
 		panic("floppy: Port bolixed.");
-	case 4: /* FD_STATUS */
+	case 0: /* FD_STATUS_0 (RO)  */
+		return sun_fdc->status1_82077;
+	case 1: /* FD_STATUS_1 (RO)  */
+		return sun_fdc->status2_82077;
+	case 2: /* FD_DOR      (R/W) */
+		return sun_fdc->dor_82077;
+	case 3: /* FD_TDR      (R/W) */
+		return sun_fdc->tapectl_82077;
+	case 4: /* FD_STATUS   (RO)  */
 		return sun_fdc->status_82077 & ~STATUS_DMA;
-	case 5: /* FD_DATA */
+	case 5: /* FD_DATA     (R/W) */
 		return sun_fdc->data_82077;
-	case 7: /* FD_DIR */
+	case 7: /* FD_DIR      (RO)  */
 		/* XXX: Is DCL on 0x80 in sun4m? */
 		return sun_fdc->dir_82077;
 	};
-	panic("sun_82072_fd_inb: How did I get here?");
+	panic("sun_82077_fd_inb: How did I get here?");
+}
+
+static void sun_82077_sun4c_fd_outb(unsigned char value, int port)
+{
+	udelay(5);
+	switch(port & 7) {
+	default:
+		printk("floppy: Asked to write to unknown port %d\n", port);
+		panic("floppy: Port bolixed.");
+	case 2: /* FD_DOR  (R/W) */
+		/* 82077 DOR register dose not apear to get used
+		 * for drive select/eject on sun4c.
+		 * The functionality is implemented via the AUXIO
+		 * I/O register.  So we must emulate the behavior.
+		 * We set the DOR so reset gets done.
+		 *
+		 * ASSUMPTIONS:  There will only ever be one floppy
+		 *               drive attached to a Sun controller
+		 *               and it will be at drive zero.
+		 */
+		{
+			unsigned bits = 0;
+			if (value & 0x10) bits |= AUXIO_FLPY_DSEL;
+			if ((value & 0x80) == 0) bits |= AUXIO_FLPY_EJCT;
+			set_auxio(bits, (~bits) & (AUXIO_FLPY_DSEL|AUXIO_FLPY_EJCT));
+		}
+		sun_fdc->dor_82077 = value;
+		break;
+	case 3: /* FD_TDR  (R/W) */
+		sun_fdc->tapectl_82077 = value;
+		break;
+	case 4: /* FD_DRS  (WO)  */
+		sun_fdc->drs_82077 = value;
+		break;
+	case 5: /* FD_DATA (R/W) */
+		sun_fdc->data_82077 = value;
+		break;
+	case 7: /* FD_DCR  (WO)  */
+		sun_fdc->dcr_82077 = value;
+		break;
+	};
+	return;
 }
 
 static void sun_82077_fd_outb(unsigned char value, int port)
@@ -183,15 +258,18 @@ static void sun_82077_fd_outb(unsigned c
 		/* Happily, the 82077 has a real DOR register. */
 		sun_fdc->dor_82077 = value;
 		break;
+	case 3: /* FD_TDR  (R/W) */
+		sun_fdc->tapectl_82077 = value;
+		break;
+	case 4: /* FD_DRS  (WO)  */
+		sun_fdc->drs_82077 = value;
+		break;
 	case 5: /* FD_DATA */
 		sun_fdc->data_82077 = value;
 		break;
 	case 7: /* FD_DCR */
 		sun_fdc->dcr_82077 = value;
 		break;
-	case 4: /* FD_STATUS */
-		sun_fdc->status_82077 = value;
-		break;
 	};
 	return;
 }
@@ -331,12 +409,25 @@ static int sun_floppy_init(void)
 		sun_fdc = NULL;
 		goto no_sun_fdc;
 	}
+	if (sparc_cpu_model == sun4c) {
+		/* extern unsigned char *auxio_register; */ /* P3 */
 
-        if(sparc_cpu_model == sun4c) {
-                sun_fdops.fd_inb = sun_82072_fd_inb;
-                sun_fdops.fd_outb = sun_82072_fd_outb;
-                fdc_status = &sun_fdc->status_82072;
-                /* printk("AUXIO @0x%lx\n", auxio_register); */ /* P3 */
+		/* Some sun4c clones have an 80277 FDC so do a simple test. */
+		if ((sun_fdc->dor_82077    == sun_fdc->status_82072) &&
+		    (sun_fdc->status_82077 == sun_fdc->status_82072)) {
+			/* printk ("FDC is 82072\n"); */
+                	sun_fdops.fd_inb = sun_82072_fd_inb;
+                	sun_fdops.fd_outb = sun_82072_fd_outb;
+                	fdc_status = &sun_fdc->status_82072;
+                	/* printk("AUXIO @0x%p\n", auxio_register); */ /* P3 */
+		} else {
+			/* printk ("FDC is 82077\n"); */
+	                sun_fdops.fd_inb = sun_82077_sun4c_fd_inb;
+	                sun_fdops.fd_outb = sun_82077_sun4c_fd_outb;
+	                fdc_status = &sun_fdc->status_82077;
+                	/* printk("AUXIO @0x%p %02x\n", auxio_register, *auxio_register); */ /* P3 */
+			/* printk("DOR @0x%p %02x\n", &sun_fdc->dor_82077, sun_fdc->dor_82077); */ /* P3 */
+		}
         } else {
                 sun_fdops.fd_inb = sun_82077_fd_inb;
                 sun_fdops.fd_outb = sun_82077_fd_outb;

[Index of Archives]     [Kernel Development]     [DCCP]     [Linux ARM Development]     [Linux]     [Photo]     [Yosemite Help]     [Linux ARM Kernel]     [Linux SCSI]     [Linux x86_64]     [Linux Hams]

  Powered by Linux