aboutsummaryrefslogtreecommitdiffstats
path: root/include/asm-cris/io.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/asm-cris/io.h')
-rw-r--r--include/asm-cris/io.h103
1 files changed, 81 insertions, 22 deletions
diff --git a/include/asm-cris/io.h b/include/asm-cris/io.h
index 1d2b51701e8d..16e791b3c721 100644
--- a/include/asm-cris/io.h
+++ b/include/asm-cris/io.h
@@ -3,6 +3,21 @@
3 3
4#include <asm/page.h> /* for __va, __pa */ 4#include <asm/page.h> /* for __va, __pa */
5#include <asm/arch/io.h> 5#include <asm/arch/io.h>
6#include <linux/kernel.h>
7
8struct cris_io_operations
9{
10 u32 (*read_mem)(void *addr, int size);
11 void (*write_mem)(u32 val, int size, void *addr);
12 u32 (*read_io)(u32 port, void *addr, int size, int count);
13 void (*write_io)(u32 port, void *addr, int size, int count);
14};
15
16#ifdef CONFIG_PCI
17extern struct cris_io_operations *cris_iops;
18#else
19#define cris_iops ((struct cris_io_operations*)NULL)
20#endif
6 21
7/* 22/*
8 * Change virtual addresses to physical addresses and vv. 23 * Change virtual addresses to physical addresses and vv.
@@ -18,14 +33,17 @@ extern inline void * phys_to_virt(unsigned long address)
18 return __va(address); 33 return __va(address);
19} 34}
20 35
21extern void * __ioremap(unsigned long offset, unsigned long size, unsigned long flags); 36extern void __iomem * __ioremap(unsigned long offset, unsigned long size, unsigned long flags);
37extern void __iomem * __ioremap_prot(unsigned long phys_addr, unsigned long size, pgprot_t prot);
22 38
23extern inline void * ioremap (unsigned long offset, unsigned long size) 39extern inline void __iomem * ioremap (unsigned long offset, unsigned long size)
24{ 40{
25 return __ioremap(offset, size, 0); 41 return __ioremap(offset, size, 0);
26} 42}
27 43
28extern void iounmap(void *addr); 44extern void iounmap(volatile void * __iomem addr);
45
46extern void __iomem * ioremap_nocache(unsigned long offset, unsigned long size);
29 47
30/* 48/*
31 * IO bus memory addresses are also 1:1 with the physical address 49 * IO bus memory addresses are also 1:1 with the physical address
@@ -39,9 +57,32 @@ extern void iounmap(void *addr);
39 * differently. On the CRIS architecture, we just read/write the 57 * differently. On the CRIS architecture, we just read/write the
40 * memory location directly. 58 * memory location directly.
41 */ 59 */
42#define readb(addr) (*(volatile unsigned char *) (addr)) 60#ifdef CONFIG_PCI
43#define readw(addr) (*(volatile unsigned short *) (addr)) 61#define PCI_SPACE(x) ((((unsigned)(x)) & 0x10000000) == 0x10000000)
44#define readl(addr) (*(volatile unsigned int *) (addr)) 62#else
63#define PCI_SPACE(x) 0
64#endif
65static inline unsigned char readb(const volatile void __iomem *addr)
66{
67 if (PCI_SPACE(addr) && cris_iops)
68 return cris_iops->read_mem((void*)addr, 1);
69 else
70 return *(volatile unsigned char __force *) addr;
71}
72static inline unsigned short readw(const volatile void __iomem *addr)
73{
74 if (PCI_SPACE(addr) && cris_iops)
75 return cris_iops->read_mem((void*)addr, 2);
76 else
77 return *(volatile unsigned short __force *) addr;
78}
79static inline unsigned int readl(const volatile void __iomem *addr)
80{
81 if (PCI_SPACE(addr) && cris_iops)
82 return cris_iops->read_mem((void*)addr, 4);
83 else
84 return *(volatile unsigned int __force *) addr;
85}
45#define readb_relaxed(addr) readb(addr) 86#define readb_relaxed(addr) readb(addr)
46#define readw_relaxed(addr) readw(addr) 87#define readw_relaxed(addr) readw(addr)
47#define readl_relaxed(addr) readl(addr) 88#define readl_relaxed(addr) readl(addr)
@@ -49,9 +90,27 @@ extern void iounmap(void *addr);
49#define __raw_readw readw 90#define __raw_readw readw
50#define __raw_readl readl 91#define __raw_readl readl
51 92
52#define writeb(b,addr) ((*(volatile unsigned char *) (addr)) = (b)) 93static inline void writeb(unsigned char b, volatile void __iomem *addr)
53#define writew(b,addr) ((*(volatile unsigned short *) (addr)) = (b)) 94{
54#define writel(b,addr) ((*(volatile unsigned int *) (addr)) = (b)) 95 if (PCI_SPACE(addr) && cris_iops)
96 cris_iops->write_mem(b, 1, (void*)addr);
97 else
98 *(volatile unsigned char __force *) addr = b;
99}
100static inline void writew(unsigned short b, volatile void __iomem *addr)
101{
102 if (PCI_SPACE(addr) && cris_iops)
103 cris_iops->write_mem(b, 2, (void*)addr);
104 else
105 *(volatile unsigned short __force *) addr = b;
106}
107static inline void writel(unsigned int b, volatile void __iomem *addr)
108{
109 if (PCI_SPACE(addr) && cris_iops)
110 cris_iops->write_mem(b, 4, (void*)addr);
111 else
112 *(volatile unsigned int __force *) addr = b;
113}
55#define __raw_writeb writeb 114#define __raw_writeb writeb
56#define __raw_writew writew 115#define __raw_writew writew
57#define __raw_writel writel 116#define __raw_writel writel
@@ -66,25 +125,25 @@ extern void iounmap(void *addr);
66 * Again, CRIS does not require mem IO specific function. 125 * Again, CRIS does not require mem IO specific function.
67 */ 126 */
68 127
69#define eth_io_copy_and_sum(a,b,c,d) eth_copy_and_sum((a),(void *)(b),(c),(d)) 128#define eth_io_copy_and_sum(a,b,c,d) eth_copy_and_sum((a),(void __force *)(b),(c),(d))
70 129
71/* The following is junk needed for the arch-independent code but which 130/* The following is junk needed for the arch-independent code but which
72 * we never use in the CRIS port 131 * we never use in the CRIS port
73 */ 132 */
74 133
75#define IO_SPACE_LIMIT 0xffff 134#define IO_SPACE_LIMIT 0xffff
76#define inb(x) (0) 135#define inb(port) (cris_iops ? cris_iops->read_io(port,NULL,1,1) : 0)
77#define inw(x) (0) 136#define inw(port) (cris_iops ? cris_iops->read_io(port,NULL,2,1) : 0)
78#define inl(x) (0) 137#define inl(port) (cris_iops ? cris_iops->read_io(port,NULL,4,1) : 0)
79#define outb(x,y) 138#define insb(port,addr,count) (cris_iops ? cris_iops->read_io(port,addr,1,count) : 0)
80#define outw(x,y) 139#define insw(port,addr,count) (cris_iops ? cris_iops->read_io(port,addr,2,count) : 0)
81#define outl(x,y) 140#define insl(port,addr,count) (cris_iops ? cris_iops->read_io(port,addr,4,count) : 0)
82#define insb(x,y,z) 141#define outb(data,port) if (cris_iops) cris_iops->write_io(port,(void*)(unsigned)data,1,1)
83#define insw(x,y,z) 142#define outw(data,port) if (cris_iops) cris_iops->write_io(port,(void*)(unsigned)data,2,1)
84#define insl(x,y,z) 143#define outl(data,port) if (cris_iops) cris_iops->write_io(port,(void*)(unsigned)data,4,1)
85#define outsb(x,y,z) 144#define outsb(port,addr,count) if(cris_iops) cris_iops->write_io(port,(void*)addr,1,count)
86#define outsw(x,y,z) 145#define outsw(port,addr,count) if(cris_iops) cris_iops->write_io(port,(void*)addr,2,count)
87#define outsl(x,y,z) 146#define outsl(port,addr,count) if(cris_iops) cris_iops->write_io(port,(void*)addr,3,count)
88 147
89/* 148/*
90 * Convert a physical pointer to a virtual kernel pointer for /dev/mem 149 * Convert a physical pointer to a virtual kernel pointer for /dev/mem