patch-2.1.8 linux/include/asm-m68k/ide.h

Next file: linux/include/asm-mips/checksum.h
Previous file: linux/include/asm-i386/ide.h
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.1.7/linux/include/asm-m68k/ide.h linux/include/asm-m68k/ide.h
@@ -1,8 +1,35 @@
+/*
+ *  linux/include/asm-m68k/ide.h
+ *
+ *  Copyright (C) 1994-1996  Linus Torvalds & authors
+ */
+ 
+/* Copyright(c) 1996 Kars de Jong */
+/* Based on the ide driver from 1.2.13pl8 */
+
+/*
+ * Credits (alphabetical):
+ *
+ *  - Bjoern Brauel
+ *  - Kars de Jong
+ *  - Torsten Ebeling
+ *  - Dwight Engen
+ *  - Thorsten Floeck
+ *  - Roman Hodek
+ *  - Guenther Kelleter
+ *  - Chris Lawrence
+ *  - Michael Rausch
+ *  - Christian Sauer
+ *  - Michael Schmitz
+ *  - Jes Soerensen
+ *  - Michael Thurm
+ *  - Geert Uytterhoeven
+ */
+
 #ifndef _M68K_IDE_H
 #define _M68K_IDE_H
 
-/* Copyright(c) 1996 Kars de Jong */
-/* Based on the ide driver from 1.2.13pl8 */
+#ifdef __KERNEL__
 
 #include <linux/config.h>
 
@@ -19,42 +46,132 @@
 #include <asm/atari_stdma.h>
 #endif /* CONFIG_ATARI */
 
-#include <asm/bootinfo.h>
+#include <asm/setup.h>
+#include <asm/io.h>
+#include <asm/irq.h>
 
-struct hd_regs_struct {
-  unsigned int hd_error,
-  hd_nsector,
-  hd_sector,
-  hd_lcyl,
-  hd_hcyl,
-  hd_select,
-  hd_status;
-};
+typedef unsigned char * ide_ioreg_t;
+
+#ifndef MAX_HWIFS
+#define MAX_HWIFS	1
+#endif
+
+static __inline int ide_default_irq (ide_ioreg_t base)
+{
+	return 0;
+}
+
+static __inline__ ide_ioreg_t ide_default_io_base (int index)
+{
+	if (index)
+		return NULL;
+#ifdef CONFIG_AMIGA
+	if (MACH_IS_AMIGA) {
+		if (AMIGAHW_PRESENT(A4000_IDE)) {
+			printk("Gayle IDE interface (A%d style)\n", 4000);
+			return ((ide_ioreg_t)ZTWO_VADDR(HD_BASE_A4000));
+		}
+		if (AMIGAHW_PRESENT(A1200_IDE)) {
+			printk("Gayle IDE interface (A%d style)\n", 1200);
+			return ((ide_ioreg_t)ZTWO_VADDR(HD_BASE_A1200));
+		}
+	}
+#endif /* CONFIG_AMIGA */
+#ifdef CONFIG_ATARI
+	if (MACH_IS_ATARI) {
+		if (ATARIHW_PRESENT(IDE)) {
+			printk("Falcon IDE interface\n");
+			return ((ide_ioreg_t) ATA_HD_BASE);
+		}
+	}
+#endif /* CONFIG_ATARI */
+	return NULL;
+}
+
+static __inline__ void ide_init_hwif_ports (ide_ioreg_t *p, ide_ioreg_t base, int *irq)
+{
+	*p++ = base;
+#ifdef CONFIG_AMIGA
+	if (MACH_IS_AMIGA) {
+		*p++ = base + AMI_HD_ERROR;
+		*p++ = base + AMI_HD_NSECTOR;
+		*p++ = base + AMI_HD_SECTOR;
+		*p++ = base + AMI_HD_LCYL;
+		*p++ = base + AMI_HD_HCYL;
+		*p++ = base + AMI_HD_SELECT;
+		*p++ = base + AMI_HD_STATUS;
+		*p++ = base + AMI_HD_CMD;
+		if (AMIGAHW_PRESENT(A4000_IDE))
+			*p++ = (ide_ioreg_t) ZTWO_VADDR(HD_A4000_IRQ);
+		else if (AMIGAHW_PRESENT(A1200_IDE))
+			*p++ = (ide_ioreg_t) ZTWO_VADDR(HD_A1200_IRQ);
+		if (irq != NULL)
+			*irq = IRQ_AMIGA_PORTS;
+	}
+#endif /* CONFIG_AMIGA */
+#ifdef CONFIG_ATARI
+	if (MACH_IS_ATARI) {
+		*p++ = base + ATA_HD_ERROR;
+		*p++ = base + ATA_HD_NSECTOR;
+		*p++ = base + ATA_HD_SECTOR;
+		*p++ = base + ATA_HD_LCYL;
+		*p++ = base + ATA_HD_HCYL;
+		*p++ = base + ATA_HD_CURRENT;
+		*p++ = base + ATA_HD_STATUS;
+		*p++ = base + ATA_HD_CMD;
+		if (irq != NULL)
+			*irq = IRQ_MFP_IDE;
+	}
+#endif /* CONFIG_ATARI */
+}
+
+typedef union {
+	unsigned all			: 8;	/* all of the bits together */
+	struct {
+		unsigned bit7		: 1;	/* always 1 */
+		unsigned lba		: 1;	/* using LBA instead of CHS */
+		unsigned bit5		: 1;	/* always 1 */
+		unsigned unit		: 1;	/* drive select number, 0 or 1 */
+		unsigned head		: 4;	/* always zeros here */
+	} b;
+	} select_t;
+
+static __inline__ int ide_request_irq(unsigned int irq, void (*handler)(int, void *, struct pt_regs *),
+			unsigned long flags, const char *device, void *dev_id)
+{
+#ifdef CONFIG_AMIGA
+	if (MACH_IS_AMIGA)
+		return request_irq(irq, handler, 0, device, dev_id);
+#endif /* CONFIG_AMIGA */
+	return 0;
+}
+
+static __inline__ void ide_free_irq(unsigned int irq, void *dev_id)
+{
+#ifdef CONFIG_AMIGA
+	if (MACH_IS_AMIGA)
+		free_irq(irq, dev_id);
+#endif /* CONFIG_AMIGA */
+}
+
+/*
+ * We should really implement those some day.
+ */
+static __inline__ int ide_check_region (ide_ioreg_t from, unsigned int extent)
+{
+	return 0;
+}
 
-static struct hd_regs_struct hd_regs;
-static void probe_m68k_ide (void);
+static __inline__ void ide_request_region (ide_ioreg_t from, unsigned int extent, const char *name)
+{
+}
 
-/* Undefine these again, they were defined for the PC. */
-#undef IDE_ERROR_OFFSET
-#undef IDE_NSECTOR_OFFSET
-#undef IDE_SECTOR_OFFSET
-#undef IDE_LCYL_OFFSET
-#undef IDE_HCYL_OFFSET
-#undef IDE_SELECT_OFFSET
-#undef IDE_STATUS_OFFSET
-#undef IDE_FEATURE_OFFSET
-#undef IDE_COMMAND_OFFSET
-#undef SELECT_DRIVE
-
-#define IDE_ERROR_OFFSET	hd_regs.hd_error
-#define IDE_NSECTOR_OFFSET	hd_regs.hd_nsector
-#define IDE_SECTOR_OFFSET	hd_regs.hd_sector
-#define IDE_LCYL_OFFSET		hd_regs.hd_lcyl
-#define IDE_HCYL_OFFSET		hd_regs.hd_hcyl
-#define IDE_SELECT_OFFSET	hd_regs.hd_select
-#define IDE_STATUS_OFFSET	hd_regs.hd_status
-#define IDE_FEATURE_OFFSET	IDE_ERROR_OFFSET
-#define IDE_COMMAND_OFFSET	IDE_STATUS_OFFSET
+static __inline__ void ide_release_region (ide_ioreg_t from, unsigned int extent)
+{
+}
+
+#undef SUPPORT_SLOW_DATA_PORTS
+#define SUPPORT_SLOW_DATA_PORTS 0
 
 #undef SUPPORT_VLB_SYNC
 #define SUPPORT_VLB_SYNC 0
@@ -62,38 +179,11 @@
 #undef HD_DATA
 #define HD_DATA NULL
 
-/* MSch: changed sti() to STI() wherever possible in ide.c; moved STI() def. 
- * to asm/ide.h 
- */
-/* The Atari interrupt structure strictly requires that the IPL isn't lowered
- * uncontrolled in an interrupt handler. In the concrete case, the IDE
- * interrupt is already a slow int, so the irq is already disabled at the time
- * the handler is called, and the IPL has been lowered to the minimum value
- * possible. To avoid going below that, STI() checks for being called inside
- * an interrupt, and in that case it does nothing. Hope that is reasonable and
- * works. (Roman)
- */
-#if defined(CONFIG_ATARI) && !defined(CONFIG_AMIGA)
-#define	STI()					\
-    do {					\
-	if (!intr_count) sti();			\
-    } while(0)
-#elif defined(CONFIG_ATARI)
-#define	STI()						\
-    do {						\
-	if (!MACH_IS_ATARI || !intr_count) sti();	\
-    } while(0)
-#else /* !defined(CONFIG_ATARI) */
-#define	STI()	sti()
-#endif
-
-#define SELECT_DRIVE(hwif,drive)  OUT_BYTE((drive)->select.all, hwif->io_base+IDE_SELECT_OFFSET);
-
-#define insl(data_reg, buffer, wcount) insw(data_reg, buffer, wcount<<1)
-#define outsl(data_reg, buffer, wcount) outsw(data_reg, buffer, wcount<<1)
+#define insl(data_reg, buffer, wcount) insw(data_reg, buffer, (wcount)<<1)
+#define outsl(data_reg, buffer, wcount) outsw(data_reg, buffer, (wcount)<<1)
 
 #define insw(port, buf, nr) \
-    if (nr % 16) \
+    if ((nr) % 16) \
 	__asm__ __volatile__ \
 	       ("movel %0,%/a0; \
 		 movel %1,%/a1; \
@@ -128,10 +218,10 @@
 		 movew %/a0@,%/a1@+; \
 		 dbra %/d6,1b" : \
 		: "g" (port), "g" (buf), "g" (nr) \
-		: "a0", "a1", "d6");
+		: "a0", "a1", "d6")
 
 #define outsw(port, buf, nr) \
-    if (nr % 16) \
+    if ((nr) % 16) \
 	__asm__ __volatile__ \
 	       ("movel %0,%/a0; \
 		 movel %1,%/a1; \
@@ -166,7 +256,128 @@
 		 movew %/a1@+,%/a0@; \
 		 dbra %/d6,1b" : \
 		: "g" (port), "g" (buf), "g" (nr) \
-		: "a0", "a1", "d6");
+		: "a0", "a1", "d6")
+
+#ifdef CONFIG_ATARI
+#define insl_swapw(data_reg, buffer, wcount) \
+    insw_swapw(data_reg, buffer, (wcount)<<1)
+#define outsl_swapw(data_reg, buffer, wcount) \
+    outsw_swapw(data_reg, buffer, (wcount)<<1)
+
+#define insw_swapw(port, buf, nr) \
+    if ((nr) % 8) \
+	__asm__ __volatile__ \
+	       ("movel %0,%/a0; \
+		 movel %1,%/a1; \
+		 movel %2,%/d6; \
+		 subql #1,%/d6; \
+	       1:movew %/a0@,%/d0; \
+		 rolw  #8,%/d0; \
+		 movew %/d0,%/a1@+; \
+		 dbra %/d6,1b" : \
+		: "g" (port), "g" (buf), "g" (nr) \
+		: "d0", "a0", "a1", "d6"); \
+    else \
+	__asm__ __volatile__ \
+	       ("movel %0,%/a0; \
+		 movel %1,%/a1; \
+		 movel %2,%/d6; \
+		 lsrl  #3,%/d6; \
+		 subql #1,%/d6; \
+	       1:movew %/a0@,%/d0; \
+		 rolw  #8,%/d0; \
+		 movew %/d0,%/a1@+; \
+		 movew %/a0@,%/d0; \
+		 rolw  #8,%/d0; \
+		 movew %/d0,%/a1@+; \
+		 movew %/a0@,%/d0; \
+		 rolw  #8,%/d0; \
+		 movew %/d0,%/a1@+; \
+		 movew %/a0@,%/d0; \
+		 rolw  #8,%/d0; \
+		 movew %/d0,%/a1@+; \
+		 movew %/a0@,%/d0; \
+		 rolw  #8,%/d0; \
+		 movew %/d0,%/a1@+; \
+		 movew %/a0@,%/d0; \
+		 rolw  #8,%/d0; \
+		 movew %/d0,%/a1@+; \
+		 movew %/a0@,%/d0; \
+		 rolw  #8,%/d0; \
+		 movew %/d0,%/a1@+; \
+		 movew %/a0@,%/d0; \
+		 rolw  #8,%/d0; \
+		 movew %/d0,%/a1@+; \
+		 dbra %/d6,1b" : \
+		: "g" (port), "g" (buf), "g" (nr) \
+		: "d0", "a0", "a1", "d6")
+
+#define outsw_swapw(port, buf, nr) \
+    if ((nr) % 8) \
+	__asm__ __volatile__ \
+	       ("movel %0,%/a0; \
+		 movel %1,%/a1; \
+		 movel %2,%/d6; \
+		 subql #1,%/d6; \
+	       1:movew %/a1@+,%/d0; \
+		 rolw  #8,%/d0; \
+		 movew %/d0,%/a0@; \
+		 dbra %/d6,1b" : \
+		: "g" (port), "g" (buf), "g" (nr) \
+		: "d0", "a0", "a1", "d6"); \
+    else \
+	__asm__ __volatile__ \
+	       ("movel %0,%/a0; \
+		 movel %1,%/a1; \
+		 movel %2,%/d6; \
+		 lsrl  #3,%/d6; \
+		 subql #1,%/d6; \
+	       1:movew %/a1@+,%/d0; \
+		 rolw  #8,%/d0; \
+		 movew %/d0,%/a0@; \
+		 movew %/a1@+,%/d0; \
+		 rolw  #8,%/d0; \
+		 movew %/d0,%/a0@; \
+		 movew %/a1@+,%/d0; \
+		 rolw  #8,%/d0; \
+		 movew %/d0,%/a0@; \
+		 movew %/a1@+,%/d0; \
+		 rolw  #8,%/d0; \
+		 movew %/d0,%/a0@; \
+		 movew %/a1@+,%/d0; \
+		 rolw  #8,%/d0; \
+		 movew %/d0,%/a0@; \
+		 movew %/a1@+,%/d0; \
+		 rolw  #8,%/d0; \
+		 movew %/d0,%/a0@; \
+		 movew %/a1@+,%/d0; \
+		 rolw  #8,%/d0; \
+		 movew %/d0,%/a0@; \
+		 movew %/a1@+,%/d0; \
+		 rolw  #8,%/d0; \
+		 movew %/d0,%/a0@; \
+		 dbra %/d6,1b" : \
+		: "g" (port), "g" (buf), "g" (nr) \
+		: "d0", "a0", "a1", "d6")
+
+#endif /* CONFIG_ATARI */
+
+static __inline__ int ide_ack_intr (ide_ioreg_t base_port, ide_ioreg_t irq_port)
+{
+#ifdef CONFIG_AMIGA
+	if (MACH_IS_AMIGA) {
+		unsigned char ch;
+		ch = inb(irq_port);
+		if (!(ch & 0x80))
+			return(0);
+		if (AMIGAHW_PRESENT(A1200_IDE)) {
+			(void) inb(base_port);
+			outb(0x7c | (ch & 0x03), irq_port);
+		}
+	}
+#endif /* CONFIG_AMIGA */
+	return(1);
+}
 
 #define T_CHAR          (0x0000)        /* char:  don't touch  */
 #define T_SHORT         (0x4000)        /* short: 12 -> 21     */
@@ -181,6 +392,7 @@
 #define D_INT(cnt)      (T_INT   | (cnt))
 #define D_TEXT(cnt)     (T_TEXT  | (cnt))
 
+#ifdef CONFIG_AMIGA
 static u_short driveid_types[] = {
 	D_SHORT(10),	/* config - vendor2 */
 	D_TEXT(20),	/* serial_no */
@@ -199,13 +411,17 @@
 };
 
 #define num_driveid_types       (sizeof(driveid_types)/sizeof(*driveid_types))
+#endif /* CONFIG_AMIGA */
 
-static __inline__ void big_endianize_driveid(struct hd_driveid *id)
+static __inline__ void ide_fix_driveid(struct hd_driveid *id)
 {
+#ifdef CONFIG_AMIGA
    u_char *p = (u_char *)id;
    int i, j, cnt;
    u_char t;
 
+   if (!MACH_IS_AMIGA)
+   	return;
    for (i = 0; i < num_driveid_types; i++) {
       cnt = driveid_types[i] & T_MASK_COUNT;
       switch (driveid_types[i] & T_MASK_TYPE) {
@@ -241,6 +457,66 @@
             break;
       }
    }
+#endif /* CONFIG_AMIGA */
+}
+
+static __inline__ void ide_release_lock (int *ide_lock)
+{
+#ifdef CONFIG_ATARI
+	if (MACH_IS_ATARI) {
+		if (*ide_lock == 0) {
+			printk("ide_release_lock: bug\n");
+			return;
+		}
+		*ide_lock = 0;
+		stdma_release();
+	}
+#endif /* CONFIG_ATARI */
 }
+
+static __inline__ void ide_get_lock (int *ide_lock, void (*handler)(int, void *, struct pt_regs *), void *data)
+{
+#ifdef CONFIG_ATARI
+	if (MACH_IS_ATARI) {
+		if (*ide_lock == 0) {
+			if (intr_count > 0)
+				panic( "Falcon IDE hasn't ST-DMA lock in interrupt" );
+			stdma_lock(handler, data);
+			*ide_lock = 1;
+		}
+	}
+#endif /* CONFIG_ATARI */
+}
+
+/*
+ * On the Atari, we sometimes can't enable interrupts:
+ */
+
+/* MSch: changed sti() to STI() wherever possible in ide.c; moved STI() def. 
+ * to asm/ide.h 
+ */
+/* The Atari interrupt structure strictly requires that the IPL isn't lowered
+ * uncontrolled in an interrupt handler. In the concrete case, the IDE
+ * interrupt is already a slow int, so the irq is already disabled at the time
+ * the handler is called, and the IPL has been lowered to the minimum value
+ * possible. To avoid going below that, STI() checks for being called inside
+ * an interrupt, and in that case it does nothing. Hope that is reasonable and
+ * works. (Roman)
+ */
+#if defined(CONFIG_ATARI) && !defined(CONFIG_AMIGA)
+#define	ide_sti()					\
+    do {						\
+	if (!intr_count) sti();				\
+    } while(0)
+#elif defined(CONFIG_ATARI)
+#define	ide_sti()					\
+    do {						\
+	if (!MACH_IS_ATARI || !intr_count) sti();	\
+    } while(0)
+#else /* !defined(CONFIG_ATARI) */
+#define	ide_sti()	sti()
+#endif
+
+#endif /* __KERNEL__ */
 
 #endif /* _M68K_IDE_H */

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov