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

[PATCH] Atari ROM port (cartridge port) ISA adapter access



Hi all,

My first draft for the ROM port ISA implementation. Except for the 8 bit
operations, this will most likely not produce the expected result. I
submit this patch mainly for review, following up on our discussion on
debian-68k.

The code is untested - except for booting on ARAnyM. I will be able to
test it in a day or so, when glibc has finished building on hobbes.

Christian: if you can schedule testing time earlier than that, I can send
a kernel binary. Please note that the IO base selection for the RTL8019 is
hardwired in the adapter (address lines A5-A9 set to 00011), so the card
has to be configured right, or you'd have to play with the adapter itself
...

	Michael
--- arch/m68k/Kconfig.ms-ethernec.org	2006-10-18 10:06:15.000000000 +0200
+++ arch/m68k/Kconfig	2006-11-05 13:26:37.000000000 +0100
@@ -132,6 +132,16 @@
 	  information about which PCI hardware does work under Linux and which
 	  doesn't.
 
+config ATARI_ROM_ISA
+	bool "Atari ROM port ISA adapter support"
+	depends on ATARI
+	help
+	  This option enables support for the ROM port ISA adapter used to 
+	  operate ISA cards on Atari. Only 8  bit cards are supported, and
+	  no interrupt lines are connected. 
+	  The only driver currently using this adapter is the EtherNEC
+	  driver for RTL8019AS based NE2000 compatible network cards.
+
 config ARANYM
 	bool "ARAnyM emulator support "
 	depends on ATARI
--- include/asm-m68k/io.h.ms-ethernec.org	2006-09-23 22:45:43.000000000 +0200
+++ include/asm-m68k/io.h	2006-11-06 17:56:19.000000000 +0100
@@ -82,17 +82,31 @@
 #endif
 #endif /* AMIGA_PCMCIA */
 
+#ifdef CONFIG_ATARI_ROM_ISA
 
+#define enec_isa_read_base  0xfffa0000
+#define enec_isa_write_base 0xfffb0000
 
-#ifdef CONFIG_ISA
+#define ENEC_ISA_IO_B(ioaddr) (enec_isa_read_base+((((unsigned long)(ioaddr))<<9)&0x1F))
+#define ENEC_ISA_IO_W(ioaddr) (enec_isa_read_base+((((unsigned long)(ioaddr))<<9)&0x1F))
+#define ENEC_ISA_MEM_B(madr)  (enec_isa_read_base+((((unsigned long)(madr))<<9)&0x1F))
+#define ENEC_ISA_MEM_W(madr)  (enec_isa_read_base+((((unsigned long)(madr))<<9)&0x1F))
+
+#define MULTI_ISA 0
+#endif /* ATARI */
+
+
+
+#if defined(CONFIG_ISA) || defined(CONFIG_ATARI_ROM_ISA)
 
 #if MULTI_ISA == 0
 #undef MULTI_ISA
 #endif
 
-#define Q40_ISA (1)
-#define GG2_ISA (2)
-#define AG_ISA  (3)
+#define Q40_ISA  (1)
+#define GG2_ISA  (2)
+#define AG_ISA   (3)
+#define ENEC_ISA (4)
 
 #if defined(CONFIG_Q40) && !defined(MULTI_ISA)
 #define ISA_TYPE Q40_ISA
@@ -106,6 +120,10 @@
 #define ISA_TYPE GG2_ISA
 #define ISA_SEX  0
 #endif
+#if defined(CONFIG_ATARI_ROM_ISA) && !defined(MULTI_ISA)
+#define ISA_TYPE ENEC_ISA
+#define ISA_SEX  0
+#endif
 
 #ifdef MULTI_ISA
 extern int isa_type;
@@ -133,6 +151,9 @@
 #ifdef CONFIG_AMIGA_PCMCIA
     case AG_ISA: return (u8 __iomem *)AG_ISA_IO_B(addr);
 #endif
+#ifdef CONFIG_ATARI_ROM_ISA
+    case ENEC_ISA: return (u8 __iomem *)ENEC_ISA_IO_B(addr);
+#endif
     default: return NULL; /* avoid warnings, just in case */
     }
 }
@@ -149,6 +170,9 @@
 #ifdef CONFIG_AMIGA_PCMCIA
     case AG_ISA: return (u16 __iomem *)AG_ISA_IO_W(addr);
 #endif
+#ifdef CONFIG_ATARI_ROM_ISA
+    case ENEC_ISA: return (u16 __iomem *)ENEC_ISA_IO_W(addr);
+#endif
     default: return NULL; /* avoid warnings, just in case */
     }
 }
@@ -165,6 +189,9 @@
 #ifdef CONFIG_AMIGA_PCMCIA
     case AG_ISA: return (u8 __iomem *)addr;
 #endif
+#ifdef CONFIG_ATARI_ROM_ISA
+    case ENEC_ISA: return (u8 __iomem *)ENEC_ISA_MEM_B(addr);
+#endif
     default: return NULL; /* avoid warnings, just in case */
     }
 }
@@ -181,6 +208,9 @@
 #ifdef CONFIG_AMIGA_PCMCIA
     case AG_ISA: return (u16 __iomem *)addr;
 #endif
+#ifdef CONFIG_ATARI_ROM_ISA
+    case ENEC_ISA: return (u16 __iomem *)ENEC_ISA_MEM_W(addr);
+#endif
     default: return NULL; /* avoid warnings, just in case */
     }
 }
@@ -200,6 +230,19 @@
 	(ISA_SEX ? out_be16(isa_mtw((unsigned long)(p)),(val))	\
 		 : out_le16(isa_mtw((unsigned long)(p)),(val)))
 
+#if defined(CONFIG_ATARI_ROM_ISA)
+#define isa_rom_inb(port)      rom_in_8(isa_itb(port))
+#define isa_rom_inw(port)      (ISA_SEX ? rom_in_be16(isa_itw(port)) : rom_in_le16(isa_itw(port)))
+
+#define isa_rom_outb(val,port) rom_out_8(isa_itb(port),(val))
+#define isa_rom_outw(val,port) (ISA_SEX ? rom_out_be16(isa_itw(port),(val)) : rom_out_le16(isa_itw(port),(val)))
+
+#define isa_rom_writeb(val,p)  rom_out_8(isa_mtb((unsigned long)(p)),(val))
+#define isa_rom_writew(val,p)  \
+	(ISA_SEX ? rom_out_be16(isa_mtw((unsigned long)(p)),(val))	\
+		 : rom_out_le16(isa_mtw((unsigned long)(p)),(val)))
+#endif
+
 static inline void isa_delay(void)
 {
   switch(ISA_TYPE)
@@ -213,6 +256,9 @@
 #ifdef CONFIG_AMIGA_PCMCIA
     case AG_ISA: break;
 #endif
+#ifdef CONFIG_ATARI_ROM_ISA
+    case ENEC_ISA: break;
+#endif
     default: break; /* avoid warnings */
     }
 }
@@ -234,10 +280,33 @@
 #define isa_outsw(port, buf, nr)    \
        (ISA_SEX ? raw_outsw(isa_itw(port), (u16 *)(buf), (nr)) :  \
                   raw_outsw_swapw(isa_itw(port), (u16 *)(buf), (nr)))
+
+#if defined(CONFIG_ATARI_ROM_ISA)
+#define isa_rom_inb_p(p)      ({u8 v=isa_rom_inb(p);isa_delay();v;})
+#define isa_rom_inw_p(p)      ({u16 v=isa_rom_inw(p);isa_delay();v;})
+#define isa_rom_inl_p(p)      ({u32 v=isa_rom_inl(p);isa_delay();v;})
+#define isa_rom_outb_p(v,p)   ({isa_rom_outb((v),(p));isa_delay();})
+#define isa_rom_outw_p(v,p)   ({isa_rom_outw((v),(p));isa_delay();})
+#define isa_rom_outl_p(v,p)   ({isa_rom_outl((v),(p));isa_delay();})
+
+#define isa_rom_insb(port, buf, nr) raw_rom_insb(isa_itb(port), (u8 *)(buf), (nr))
+
+#define isa_rom_insw(port, buf, nr)     \
+       (ISA_SEX ? raw_rom_insw(isa_itw(port), (u16 *)(buf), (nr)) :    \
+                  raw_rom_insw_swapw(isa_itw(port), (u16 *)(buf), (nr)))
+
+#define isa_rom_outsb(port, buf, nr) raw_rom_outsb(isa_itb(port), (u8 *)(buf), (nr))
+
+#define isa_rom_outsw(port, buf, nr)    \
+       (ISA_SEX ? raw_rom_outsw(isa_itw(port), (u16 *)(buf), (nr)) :  \
+                  raw_rom_outsw_swapw(isa_itw(port), (u16 *)(buf), (nr)))
+
+#endif
+
 #endif  /* CONFIG_ISA */
 
 
-#if defined(CONFIG_ISA) && !defined(CONFIG_PCI)
+#if defined(CONFIG_ISA) && !defined(CONFIG_PCI) && !defined(CONFIG_ATARI_ROM_ISA)
 #define inb     isa_inb
 #define inb_p   isa_inb_p
 #define outb    isa_outb
@@ -306,7 +375,34 @@
 #endif
 #endif /* CONFIG_PCI */
 
-#if !defined(CONFIG_ISA) && !defined(CONFIG_PCI) && defined(CONFIG_HP300)
+#if defined(CONFIG_ATARI_ROM_ISA)
+/*
+ * kernel with both ROM port ISA and IDE compiled in, those have
+ * conflicting defs for in/out. Simply consider port < 1024
+ * ROM port ISA and everything else regular ISA for IDE. read,write not defined
+ * in this case
+ */
+#define inb(port) ((port)<1024 ? isa_rom_inb(port) : in_8(port))
+#define inb_p(port) ((port)<1024 ? isa_rom_inb_p(port) : in_8(port))
+#define inw(port) ((port)<1024 ? isa_rom_inw(port) : in_le16(port))
+#define inw_p(port) ((port)<1024 ? isa_rom_inw_p(port) : in_le16(port))
+#define inl(port) ((port)<1024 ? isa_rom_inl(port) : in_le32(port))
+#define inl_p(port) ((port)<1024 ? isa_rom_inl_p(port) : in_le32(port))
+
+#define outb(val,port) ((port)<1024 ? isa_rom_outb((val),(port)) : out_8((port),(val)))
+#define outb_p(val,port) ((port)<1024 ? isa_rom_outb_p((val),(port)) : out_8((port),(val)))
+#define outw(val,port) ((port)<1024 ? isa_rom_outw((val),(port)) : out_le16((port),(val)))
+#define outw_p(val,port) ((port)<1024 ? isa_rom_outw_p((val),(port)) : out_le16((port),(val)))
+#define outl(val,port) ((port)<1024 ? isa_rom_outl((val),(port)) : out_le32((port),(val)))
+#define outl_p(val,port) ((port)<1024 ? isa_rom_outl_p((val),(port)) : out_le32((port),(val)))
+
+#define insb    isa_rom_insb
+#define insw    isa_rom_insw
+#define outsb   isa_rom_outsb
+#define outsw   isa_rom_outsw
+#endif
+
+#if !defined(CONFIG_ISA) && !defined(CONFIG_PCI) && !defined(CONFIG_ATARI_ROM_ISA) && defined(CONFIG_HP300)
 /*
  * We need to define dummy functions otherwise drivers/serial/8250.c doesn't link
  */
--- include/asm-m68k/raw_io.h.ms-ethernec.org	2006-04-09 18:58:34.000000000 +0200
+++ include/asm-m68k/raw_io.h	2006-11-06 17:55:44.000000000 +0100
@@ -54,6 +54,46 @@
 #define raw_outw(val,port) out_be16((port),(val))
 #define raw_outl(val,port) out_be32((port),(val))
 
+/* 
+ * Atari ROM port (cartridge port) ISA adapter, used for the EtherNEC NE2000
+ * network card driver.
+ * The ISA adapter connects address lines A9-A13 to ISA address lines A0-A4, 
+ * and hardwires the rest of the ISA addresses for a base address of 0x300. 
+ *
+ * Data lines D8-D15 are connected to ISA data lines D0-D7 for reading. 
+ * For writes, address lines A1-A8 are latched to ISA data lines D0-D7 
+ * (meaning the bit pattern on A1-A8 can be read back as byte).
+ * 
+ * Reads and writes are byte only. 
+ */
+
+#if defined(CONFIG_ATARI_ROM_ISA)
+#define rom_in_8(addr) \
+    ({ u8 __v = (*(__force volatile u8 *) (addr)); __v >>= 8; __v; })
+#define rom_in_be16(addr) \
+    ({ u16 __v = (*(__force volatile u16 *) (addr)); __v >>= 8; __v; })
+#define rom_in_be32(addr) \
+    ({ u32 __v = (*(__force volatile u32 *) (addr)); __v >>= 8; __v; })
+#define rom_in_le16(addr) \
+    ({ u16 __v = le16_to_cpu(*(__force volatile u16 *) (addr)); __v >>= 8; __v; })
+#define rom_in_le32(addr) \
+    ({ u32 __v = le32_to_cpu(*(__force volatile u32 *) (addr)); __v >>= 8; __v; })
+
+#define rom_out_8(addr,b)     ({u8 __v = (b);            (void)((*(__force volatile u8 *)  ((addr) + 0x10000 + (__v<<1))) = __v);})
+#define rom_out_be16(addr,w) ({u16 __v = (w);            (void)((*(__force volatile u16 *) ((addr) + 0x10000 + (__v<<1))) = __v);})
+#define rom_out_be32(addr,l) ({u32 __v = (l);            (void)((*(__force volatile u32 *) ((addr) + 0x10000 + (__v<<1))) = __v);})
+#define rom_out_le16(addr,w) ({u16 __v = cpu_to_le16(w); (void)((*(__force volatile u16 *) ((addr) + 0x10000 + (__v<<1))) = __v);})
+#define rom_out_le32(addr,l) ({u32 __v = cpu_to_le32(l); (void)((*(__force volatile u32 *) ((addr) + 0x10000 + (__v<<1))) = __v);})
+
+#define raw_rom_inb rom_in_8
+#define raw_rom_inw rom_in_be16
+#define raw_rom_inl rom_in_be32
+
+#define raw_rom_outb(val,port) rom_out_8((port),(val))
+#define raw_rom_outw(val,port) rom_out_be16((port),(val))
+#define raw_rom_outl(val,port) rom_out_be32((port),(val))
+#endif /* CONFIG_ATARI_ROM_ISA */
+
 static inline void raw_insb(volatile u8 __iomem *port, u8 *buf, unsigned int len)
 {
 	unsigned int i;
@@ -336,6 +376,62 @@
 		: "d0", "a0", "a1", "d6");
 }
 
+
+#if defined(CONFIG_ATARI_ROM_ISA)
+static inline void raw_rom_insb(volatile u8 __iomem *port, u8 *buf, unsigned int len)
+{
+	unsigned int i;
+
+        for (i = 0; i < len; i++)
+		*buf++ = rom_in_8(port);
+}
+
+static inline void raw_rom_outsb(volatile u8 __iomem *port, const u8 *buf,
+			     unsigned int len)
+{
+	unsigned int i;
+
+        for (i = 0; i < len; i++)
+		rom_out_8(port, *buf++);
+}
+
+static inline void raw_rom_insw(volatile u16 __iomem *port, u16 *buf,
+				   unsigned int nr)
+{
+    unsigned int i;
+
+    for (i = 0; i < nr; i++)
+	*buf++ = rom_in_be16(port);
+}
+
+static inline void raw_rom_outsw(volatile u16 __iomem *port, const u16 *buf,
+				   unsigned int nr)
+{
+    unsigned int i;
+
+    for (i = 0; i < nr; i++)
+	rom_out_be16(port, *buf++);
+}
+
+static inline void raw_rom_insw_swapw(volatile u16 __iomem *port, u16 *buf,
+				   unsigned int nr)
+{
+    unsigned int i;
+
+    for (i = 0; i < nr; i++)
+	*buf++ = rom_in_le16(port);
+}
+
+static inline void raw_rom_outsw_swapw(volatile u16 __iomem *port, const u16 *buf,
+				   unsigned int nr)
+{
+    unsigned int i;
+
+    for (i = 0; i < nr; i++)
+	rom_out_le16(port, *buf++);
+}
+#endif /* CONFIG_ATARI_ROM_ISA */
+
 #define __raw_writel raw_outl
 
 #endif /* __KERNEL__ */

Reply to: