Date: Thu, 05 Mar 1998 10:02:45 +0100
From: Alain Malek <Alain.Malek@dumbo.cryogen.ch>
To: linux68k <linux-m68k@phil.uni-sb.de>
Subject: L68K: apne patch
Sender: owner-linux-m68k@phil.uni-sb.de

Hi,

 Here is a small patch for the PCMCIA NE2000 driver (CNET 40BC).
The io macros for gayle access use readb and writeb from io.h.
There is support for non 16bit config address length.

This patch is for kernel 2.0.33. Now I will start to port this
driver to kernel 2.1.x. Hopefully it should be pretty easy.

Alain


diff -ruN linux-2.0.33/drivers/net/apne.c linux/drivers/net/apne.c
--- linux-2.0.33/drivers/net/apne.c	Wed Dec 17 17:23:26 1997
+++ linux/drivers/net/apne.c	Thu Mar  5 09:39:41 1998
@@ -123,28 +123,6 @@
 
 #define WORDSWAP(a) ( (((a)>>8)&0xff) | ((a)<<8) )
 
-/* word io */
-
-static inline unsigned short get_user_word_io(const short * addr)
-{
-	register unsigned short _v;
-
-	__asm__ __volatile__ ("movew %1,%0":"=dm" (_v):"m" (*addr));
-	return _v;
-}
-#define inw_p(addr) get_user_word_io((short *)(addr))
-#define inw(addr) get_user_word_io((short *)(addr))
-
-static inline void put_user_word_io(short val,short *addr)
-{
-	__asm__ __volatile__ ("movew %0,%1"
-			      : /* no outputs */
-			      :"idm" (val),"m" (*addr)
-			      : "memory");
-}
-#define outw_p(x,addr) put_user_word_io((x),(short *)(addr))
-#define outw(x,addr) put_user_word_io((x),(short *)(addr))
-
 static const char *version =
     "apne.c:v1.0 11/29/97 Alain Malek (Alain.Malek@cryogen.com)\n";
 
@@ -1357,11 +1335,12 @@
 
 static int init_pcmcia(void)
 {
-	unsigned char config;
+	u_char config;
 #ifndef MANUAL_CONFIG
-	unsigned char tuple[32];
+	u_char tuple[32];
+	int offset_len;
 #endif
-	unsigned short offset;
+	u_long offset;
 
 	pcmcia_reset();
 	pcmcia_program_voltage(PCMCIA_0V);
@@ -1384,7 +1363,11 @@
 	if (pcmcia_copy_tuple(CISTPL_CONFIG, tuple, 32) < 6)
 		return 0;
 
-	offset = (tuple[5] << 8) | tuple[4];
+	offset_len = (tuple[2] & 0x3) + 1;
+	offset = 0;
+	while(offset_len--) {
+		offset = (offset << 8) | tuple[4+offset_len];
+	}
 #endif
 
 	outb(config, GAYLE_ATTRIBUTE+offset);
diff -ruN linux-2.0.33/include/asm-m68k/amigayle.h linux/include/asm-m68k/amigayle.h
--- linux-2.0.33/include/asm-m68k/amigayle.h	Wed Dec 17 13:08:11 1997
+++ linux/include/asm-m68k/amigayle.h	Mon Jan  5 13:25:37 1998
@@ -19,6 +19,7 @@
 #define _ASMm68k_AMIGAYLE_H_
 
 #include <asm/amigahw.h>
+#include <asm/io.h>
 
 /* memory layout */
 
@@ -59,11 +60,11 @@
 
 #define gayle_attribute ((volatile u_char *)(GAYLE_ATTRIBUTE))
 
-#define gayle_inb(a) (*(volatile u_char *)(GAYLE_IO+(a)+(((a)&1)*GAYLE_ODD)))
-#define gayle_outb(v,a) ((*(volatile u_char *)(GAYLE_IO+(a)+(((a)&1)*GAYLE_ODD))) = (v))
+#define gayle_inb(a) readb( GAYLE_IO+(a)+(((a)&1)*GAYLE_ODD) )
+#define gayle_outb(v,a) writeb( v, GAYLE_IO+(a)+(((a)&1)*GAYLE_ODD) )
 
-#define gayle_inw(a) (*(volatile u_short *)(GAYLE_IO+(a)))
-#define gayle_outw(v,a) ((*(volatile u_short *)(GAYLE_IO+(a))) = (v))
+#define gayle_inw(a) readw( GAYLE_IO+(a) )
+#define gayle_outw(v,a) writew( v, GAYLE_IO+(a) )
 
 /* GAYLE_CARDSTATUS bit def */
