patch-2.4.0-test6 linux/arch/sh/kernel/io_generic.c

Next file: linux/arch/sh/kernel/io_hd64461.c
Previous file: linux/arch/sh/kernel/io.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.4.0-test5/linux/arch/sh/kernel/io_generic.c linux/arch/sh/kernel/io_generic.c
@@ -4,7 +4,8 @@
  *
  * Copyright (C) 2000  Niibe Yutaka
  *
- * Generic I/O routine.
+ * Generic I/O routine. These can be used where a machine specific version
+ * is not required.
  *
  * This file is subject to the terms and conditions of the GNU General Public
  * License.  See the file "COPYING" in the main directory of this archive
@@ -14,6 +15,7 @@
 
 #include <linux/config.h>
 #include <asm/io.h>
+#include <asm/machvec.h>
 
 #if defined(__sh3__)
 /* I'm not sure SH7709 has this kind of bug */
@@ -21,19 +23,31 @@
 #define DUMMY_READ_AREA6	  0xba000000
 #endif
 
-#define PORT2ADDR(x) (CONFIG_IOPORT_START+(x))
+#define PORT2ADDR(x) (sh_mv.mv_isa_port2addr(x))
+
+unsigned long generic_io_base;
 
 static inline void delay(void)
 {
 	ctrl_inw(0xa0000000);
 }
 
-unsigned long inb(unsigned int port)
+unsigned long generic_inb(unsigned int port)
 {
 	return *(volatile unsigned char*)PORT2ADDR(port);
 }
 
-unsigned long inb_p(unsigned int port)
+unsigned long generic_inw(unsigned int port)
+{
+	return *(volatile unsigned short*)PORT2ADDR(port);
+}
+
+unsigned long generic_inl(unsigned int port)
+{
+	return *(volatile unsigned long*)PORT2ADDR(port);
+}
+
+unsigned long generic_inb_p(unsigned int port)
 {
 	unsigned long v = *(volatile unsigned char*)PORT2ADDR(port);
 
@@ -41,23 +55,29 @@
 	return v;
 }
 
-unsigned long inw(unsigned int port)
+unsigned long generic_inw_p(unsigned int port)
 {
-	return *(volatile unsigned short*)PORT2ADDR(port);
+	unsigned long v = *(volatile unsigned short*)PORT2ADDR(port);
+
+	delay();
+	return v;
 }
 
-unsigned long inl(unsigned int port)
+unsigned long generic_inl_p(unsigned int port)
 {
-	return *(volatile unsigned long*)PORT2ADDR(port);
+	unsigned long v = *(volatile unsigned long*)PORT2ADDR(port);
+
+	delay();
+	return v;
 }
 
-void insb(unsigned int port, void *buffer, unsigned long count)
+void generic_insb(unsigned int port, void *buffer, unsigned long count)
 {
 	unsigned char *buf=buffer;
 	while(count--) *buf++=inb(port);
 }
 
-void insw(unsigned int port, void *buffer, unsigned long count)
+void generic_insw(unsigned int port, void *buffer, unsigned long count)
 {
 	unsigned short *buf=buffer;
 	while(count--) *buf++=inw(port);
@@ -66,7 +86,7 @@
 #endif
 }
 
-void insl(unsigned int port, void *buffer, unsigned long count)
+void generic_insl(unsigned int port, void *buffer, unsigned long count)
 {
 	unsigned long *buf=buffer;
 	while(count--) *buf++=inl(port);
@@ -75,34 +95,46 @@
 #endif
 }
 
-void outb(unsigned long b, unsigned int port)
+void generic_outb(unsigned long b, unsigned int port)
 {
 	*(volatile unsigned char*)PORT2ADDR(port) = b;
 }
 
-void outb_p(unsigned long b, unsigned int port)
+void generic_outw(unsigned long b, unsigned int port)
+{
+	*(volatile unsigned short*)PORT2ADDR(port) = b;
+}
+
+void generic_outl(unsigned long b, unsigned int port)
+{
+        *(volatile unsigned long*)PORT2ADDR(port) = b;
+}
+
+void generic_outb_p(unsigned long b, unsigned int port)
 {
 	*(volatile unsigned char*)PORT2ADDR(port) = b;
 	delay();
 }
 
-void outw(unsigned long b, unsigned int port)
+void generic_outw_p(unsigned long b, unsigned int port)
 {
 	*(volatile unsigned short*)PORT2ADDR(port) = b;
+	delay();
 }
 
-void outl(unsigned long b, unsigned int port)
+void generic_outl_p(unsigned long b, unsigned int port)
 {
-        *(volatile unsigned long*)PORT2ADDR(port) = b;
+	*(volatile unsigned long*)PORT2ADDR(port) = b;
+	delay();
 }
 
-void outsb(unsigned int port, const void *buffer, unsigned long count)
+void generic_outsb(unsigned int port, const void *buffer, unsigned long count)
 {
 	const unsigned char *buf=buffer;
 	while(count--) outb(*buf++, port);
 }
 
-void outsw(unsigned int port, const void *buffer, unsigned long count)
+void generic_outsw(unsigned int port, const void *buffer, unsigned long count)
 {
 	const unsigned short *buf=buffer;
 	while(count--) outw(*buf++, port);
@@ -111,11 +143,60 @@
 #endif
 }
 
-void outsl(unsigned int port, const void *buffer, unsigned long count)
+void generic_outsl(unsigned int port, const void *buffer, unsigned long count)
 {
 	const unsigned long *buf=buffer;
 	while(count--) outl(*buf++, port);
 #ifdef SH3_PCMCIA_BUG_WORKAROUND
 	ctrl_inb (DUMMY_READ_AREA6);
 #endif
+}
+
+unsigned long generic_readb(unsigned long addr)
+{
+	return *(volatile unsigned char*)addr;
+}
+
+unsigned long generic_readw(unsigned long addr)
+{
+	return *(volatile unsigned short*)addr;
+}
+
+unsigned long generic_readl(unsigned long addr)
+{
+	return *(volatile unsigned long*)addr;
+}
+
+void generic_writeb(unsigned char b, unsigned long addr)
+{
+	*(volatile unsigned char*)addr = b;
+}
+
+void generic_writew(unsigned short b, unsigned long addr)
+{
+	*(volatile unsigned short*)addr = b;
+}
+
+void generic_writel(unsigned int b, unsigned long addr)
+{
+        *(volatile unsigned long*)addr = b;
+}
+
+void * generic_ioremap(unsigned long offset, unsigned long size)
+{
+	return (void *) P2SEGADDR(offset);
+}
+
+void * generic_ioremap_nocache (unsigned long offset, unsigned long size)
+{
+	return (void *) P2SEGADDR(offset);
+}
+
+void generic_iounmap(void *addr)
+{
+}
+
+unsigned long generic_isa_port2addr(unsigned long offset)
+{
+	return offset + generic_io_base;
 }

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)