linux-mips
[Top] [All Lists]

new asm-mips/io.h

To: linux-mips@oss.sgi.com
Subject: new asm-mips/io.h
From: Atsushi Nemoto <nemoto@toshiba-tops.co.jp>
Date: Mon, 26 Nov 2001 12:35:45 +0900 (JST)
Cc: ralf@oss.sgi.com
Organization: TOSHIBA Personal Computer System Corporation
Sender: owner-linux-mips@oss.sgi.com
A last cleanups for io.h looks bit wrong.  Please apply.

--- linux-sgi-cvs/include/asm-mips/io.h Mon Nov 26 10:49:40 2001
+++ linux.new/include/asm-mips/io.h     Mon Nov 26 12:06:31 2001
@@ -283,7 +283,7 @@
 {
        while(count--) {
                outb(*(__u8 *)addr, port);
-               addr++; port++;
+               addr++;
        }
 }
 
@@ -291,7 +291,7 @@
 {
        while(count--) {
                *(__u8 *)addr = inb(port);
-               addr++; port++;
+               addr++;
        }
 }
 
@@ -299,7 +299,7 @@
 {
        while(count--) {
                outw(*(__u16 *)addr, port);
-               addr+=2; port+=2;
+               addr+=2;
        }
 }
 
@@ -307,7 +307,7 @@
 {
        while(count--) {
                *(__u16 *)addr = inw(port);
-               addr+=2; port+=2;
+               addr+=2;
        }
 }
 
@@ -315,7 +315,7 @@
 {
        while(count--) {
                outl(*(__u32 *)addr, port);
-               addr+=4; port+=4;
+               addr+=4;
        }
 }
 
@@ -323,7 +323,7 @@
 {
        while(count--) {
                *(__u32 *)addr = inw(port);
-               addr+=4; port+=4;
+               addr+=4;
        }
 }
 
---

By the way, I have some boards which require special I/O routines.
Some of these boards need byteswap on PCI I/O region but noswap on ISA
region.  And some of these boards do not require byteswap but need
swap the address ('port' values).  I added following codes to support
these boards.  Is it worth to apply?

--- linux-sgi-cvs/include/asm-mips/io.h Mon Nov 26 10:49:40 2001
+++ linux.new/include/asm-mips/io.h     Mon Nov 26 12:06:31 2001
@@ -352,5 +352,88 @@
 #define dma_cache_wback_inv(start,size)        _dma_cache_wback_inv(start,size)
 #define dma_cache_wback(start,size)    _dma_cache_wback(start,size)
 #define dma_cache_inv(start,size)      _dma_cache_inv(start,size)
+
+#ifdef CONFIG_HAVE_BOARD_IO_FUNCS
+/* redefine all I/O access routines */
+struct mips_io_funcs {
+       void (*writeb)(unsigned char b, volatile unsigned char *addr);
+       void (*writew)(unsigned short b, volatile unsigned short *addr);
+       void (*writel)(unsigned int b, volatile unsigned int *addr);
+       unsigned char (*readb)(volatile unsigned char *addr);
+       unsigned short (*readw)(volatile unsigned short *addr);
+       unsigned int (*readl)(volatile unsigned int *addr);
+       void (*outb)(unsigned int value, unsigned long port);
+       void (*outw)(unsigned int value, unsigned long port);
+       void (*outl)(unsigned int value, unsigned long port);
+       unsigned char (*inb)(unsigned long port);
+       unsigned short (*inw)(unsigned long port);
+       unsigned int (*inl)(unsigned long port);
+       void (*outsb)(unsigned long port, const void *addr, unsigned int count);
+       void (*outsw)(unsigned long port, const void *addr, unsigned int count);
+       void (*outsl)(unsigned long port, const void *addr, unsigned int count);
+       void (*insb)(unsigned long port, void *addr, unsigned int count);
+       void (*insw)(unsigned long port, void *addr, unsigned int count);
+       void (*insl)(unsigned long port, void *addr, unsigned int count);
+       void (*memset_io)(volatile void *addr, int c, int len);
+       void (*memcpy_fromio)(void *to, volatile void *from, int len);
+       void (*memcpy_toio)(volatile void *to, const void *from, int len);
+};
+/* board dependent part should declare this variable. */
+extern struct mips_io_funcs mips_io_funcs;
+#undef writeb
+#undef writew
+#undef writel
+#undef readb
+#undef readw
+#undef readl
+#undef outb
+#undef inb
+#undef outb_p
+#undef inb_p
+#undef outw
+#undef inw
+#undef outw_p
+#undef inw_p
+#undef outl
+#undef inl
+#undef outl_p
+#undef inl_p
+#undef outsb
+#undef insb
+#undef outsw
+#undef insw
+#undef outsl
+#undef insl
+#undef memset_io
+#undef memcpy_fromio
+#undef memcpy_toio
+#define writeb(b,addr) (*mips_io_funcs.writeb)(b, (volatile unsigned char 
*)(addr))
+#define writew(b,addr) (*mips_io_funcs.writew)(b, (volatile unsigned short 
*)(addr))
+#define writel(b,addr) (*mips_io_funcs.writel)(b, (volatile unsigned int 
*)(addr))
+#define readb(addr) (*mips_io_funcs.readb)((volatile unsigned char *)(addr))
+#define readw(addr) (*mips_io_funcs.readw)((volatile unsigned short *)(addr))
+#define readl(addr) (*mips_io_funcs.readl)((volatile unsigned int *)(addr))
+#define outb(val,port) (*mips_io_funcs.outb)((val),(port))
+#define inb(port)      (*mips_io_funcs.inb)(port)
+#define outb_p(val,port)       (*mips_io_funcs.outb)((val),(port))
+#define inb_p(port)    (*mips_io_funcs.inb)(port)
+#define outw(val,port) (*mips_io_funcs.outw)((val),(port))
+#define inw(port)      (*mips_io_funcs.inw)(port)
+#define outw_p(val,port)       (*mips_io_funcs.outw)((val),(port))
+#define inw_p(port)    (*mips_io_funcs.inw)(port)
+#define outl(val,port) (*mips_io_funcs.outl)((val),(port))
+#define inl(port)      (*mips_io_funcs.inl)(port)
+#define outl_p(val,port)       (*mips_io_funcs.outl)((val),(port))
+#define inl_p(port)    (*mips_io_funcs.inl)(port)
+#define outsb(port,addr,count) (*mips_io_funcs.outsb)((port),(addr),(count))
+#define insb(port,addr,count)  (*mips_io_funcs.insb)((port),(addr),(count))
+#define outsw(port,addr,count) (*mips_io_funcs.outsw)((port),(addr),(count))
+#define insw(port,addr,count)  (*mips_io_funcs.insw)((port),(addr),(count))
+#define outsl(port,addr,count) (*mips_io_funcs.outsl)((port),(addr),(count))
+#define insl(port,addr,count)  (*mips_io_funcs.insl)((port),(addr),(count))
+#define memset_io(a,b,c)       (*mips_io_funcs.memset_io)((volatile void 
*)(a),(b),(c))
+#define memcpy_fromio(a,b,c)   (*mips_io_funcs.memcpy_fromio)((a),(volatile 
void *)(b),(c))
+#define memcpy_toio(a,b,c)     (*mips_io_funcs.memcpy_toio)((volatile void 
*)(a),(b),(c))
+#endif /* CONFIG_HAVE_BOARD_IO_FUNCS */
 
 #endif /* _ASM_IO_H */
---
Atsushi Nemoto

<Prev in Thread] Current Thread [Next in Thread>