summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorPete Zaitcev <zaitcev@redhat.com>2002-09-17 03:25:16 -0700
committerDavid S. Miller <davem@nuts.ninka.net>2002-09-17 03:25:16 -0700
commit9730c0eeb638b33da6f2adbc9f4b8e6a80ce6586 (patch)
treed3d4a0bbcb55a19003e94b65f48e9351a92d6a8f /include
parent48d85404d602ca5fbd4b7cdaa87328b7b5a320e9 (diff)
[SPARC32]: Fix console, sunsu, and IO macros.
Diffstat (limited to 'include')
-rw-r--r--include/asm-sparc/io.h52
1 files changed, 18 insertions, 34 deletions
diff --git a/include/asm-sparc/io.h b/include/asm-sparc/io.h
index d42fa22ece83..848111d7980b 100644
--- a/include/asm-sparc/io.h
+++ b/include/asm-sparc/io.h
@@ -25,38 +25,17 @@ static __inline__ u16 flip_word (u16 d)
/*
* Memory mapped I/O to PCI
+ *
+ * Observe that ioremap returns void* cookie, but accessors, such
+ * as readb, take unsigned long as address, by API. This mismatch
+ * happened historically. The ioremap is much older than accessors,
+ * so at one time ioremap's cookie was used as address (*a = val).
+ * When accessors came about, they were designed to be compatible across
+ * buses, so that drivers can select proper ones like sunhme.c did.
+ * To make that easier, they use same aruments (ulong) for sbus, pci, isa.
+ * The offshot is, we must cast readb et. al. arguments with a #define.
*/
-static __inline__ u8 readb(unsigned long addr)
-{
- return *(volatile u8 *)addr;
-}
-
-static __inline__ u16 readw(unsigned long addr)
-{
- return flip_word(*(volatile u16 *)addr);
-}
-
-static __inline__ u32 readl(unsigned long addr)
-{
- return flip_dword(*(volatile u32 *)addr);
-}
-
-static __inline__ void writeb(u8 b, unsigned long addr)
-{
- *(volatile u8 *)addr = b;
-}
-
-static __inline__ void writew(u16 b, unsigned long addr)
-{
- *(volatile u16 *)addr = flip_word(b);
-}
-static __inline__ void writel(u32 b, unsigned long addr)
-{
- *(volatile u32 *)addr = flip_dword(b);
-}
-
-/* Now the 'raw' versions. */
static __inline__ u8 __raw_readb(unsigned long addr)
{
return *(volatile u8 *)addr;
@@ -87,6 +66,14 @@ static __inline__ void __raw_writel(u32 b, unsigned long addr)
*(volatile u32 *)addr = b;
}
+#define readb(addr) (*(volatile u8 *)(addr))
+#define readw(addr) flip_word(*(volatile u16 *)(addr))
+#define readl(addr) flip_dword(*(volatile u32 *)(addr))
+
+#define writeb(b, a) (*(volatile u8 *)(a) = b)
+#define writew(b, a) (*(volatile u16 *)(a) = flip_word(b))
+#define writel(b, a) (*(volatile u32 *)(a) = flip_dword(b))
+
/*
* I/O space operations
*
@@ -163,7 +150,6 @@ static __inline__ void _sbus_writel(u32 b, unsigned long addr)
/*
* The only reason for #define's is to hide casts to unsigned long.
- * XXX Rewrite drivers without structures for registers.
*/
#define sbus_readb(a) _sbus_readb((unsigned long)(a))
#define sbus_readw(a) _sbus_readw((unsigned long)(a))
@@ -193,13 +179,11 @@ extern void *ioremap(unsigned long offset, unsigned long size);
#define ioremap_nocache(X,Y) ioremap((X),(Y))
extern void iounmap(void *addr);
-/* P3: talk davem into dropping "name" argument in favor of res->name */
/*
* Bus number may be in res->flags... somewhere.
*/
extern unsigned long sbus_ioremap(struct resource *res, unsigned long offset,
unsigned long size, char *name);
-/* XXX Partial deallocations? I think not! */
extern void sbus_iounmap(unsigned long vaddr, unsigned long size);
@@ -215,7 +199,7 @@ extern void sbus_iounmap(unsigned long vaddr, unsigned long size);
#define RTC_ALWAYS_BCD 0
/* Nothing to do */
-/* P3: Only IDE DMA may need these. */
+/* P3: Only IDE DMA may need these. XXX Verify that it still does... */
#define dma_cache_inv(_start,_size) do { } while (0)
#define dma_cache_wback(_start,_size) do { } while (0)