4 #include <asm/page.h> /* for __va, __pa */
5 #include <asm/arch/io.h>
6 #include <linux/kernel.h>
8 struct cris_io_operations
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
);
17 extern struct cris_io_operations
*cris_iops
;
19 #define cris_iops ((struct cris_io_operations*)NULL)
23 * Change virtual addresses to physical addresses and vv.
26 extern inline unsigned long virt_to_phys(volatile void * address
)
31 extern inline void * phys_to_virt(unsigned long address
)
36 extern void __iomem
* __ioremap(unsigned long offset
, unsigned long size
, unsigned long flags
);
37 extern void __iomem
* __ioremap_prot(unsigned long phys_addr
, unsigned long size
, pgprot_t prot
);
39 extern inline void __iomem
* ioremap (unsigned long offset
, unsigned long size
)
41 return __ioremap(offset
, size
, 0);
44 extern void iounmap(volatile void * __iomem addr
);
46 extern void __iomem
* ioremap_nocache(unsigned long offset
, unsigned long size
);
49 * IO bus memory addresses are also 1:1 with the physical address
51 #define virt_to_bus virt_to_phys
52 #define bus_to_virt phys_to_virt
55 * readX/writeX() are used to access memory mapped devices. On some
56 * architectures the memory mapped IO stuff needs to be accessed
57 * differently. On the CRIS architecture, we just read/write the
58 * memory location directly.
61 #define PCI_SPACE(x) ((((unsigned)(x)) & 0x10000000) == 0x10000000)
63 #define PCI_SPACE(x) 0
65 static inline unsigned char readb(const volatile void __iomem
*addr
)
67 if (PCI_SPACE(addr
) && cris_iops
)
68 return cris_iops
->read_mem((void*)addr
, 1);
70 return *(volatile unsigned char __force
*) addr
;
72 static inline unsigned short readw(const volatile void __iomem
*addr
)
74 if (PCI_SPACE(addr
) && cris_iops
)
75 return cris_iops
->read_mem((void*)addr
, 2);
77 return *(volatile unsigned short __force
*) addr
;
79 static inline unsigned int readl(const volatile void __iomem
*addr
)
81 if (PCI_SPACE(addr
) && cris_iops
)
82 return cris_iops
->read_mem((void*)addr
, 4);
84 return *(volatile unsigned int __force
*) addr
;
86 #define readb_relaxed(addr) readb(addr)
87 #define readw_relaxed(addr) readw(addr)
88 #define readl_relaxed(addr) readl(addr)
89 #define __raw_readb readb
90 #define __raw_readw readw
91 #define __raw_readl readl
93 static inline void writeb(unsigned char b
, volatile void __iomem
*addr
)
95 if (PCI_SPACE(addr
) && cris_iops
)
96 cris_iops
->write_mem(b
, 1, (void*)addr
);
98 *(volatile unsigned char __force
*) addr
= b
;
100 static inline void writew(unsigned short b
, volatile void __iomem
*addr
)
102 if (PCI_SPACE(addr
) && cris_iops
)
103 cris_iops
->write_mem(b
, 2, (void*)addr
);
105 *(volatile unsigned short __force
*) addr
= b
;
107 static inline void writel(unsigned int b
, volatile void __iomem
*addr
)
109 if (PCI_SPACE(addr
) && cris_iops
)
110 cris_iops
->write_mem(b
, 4, (void*)addr
);
112 *(volatile unsigned int __force
*) addr
= b
;
114 #define __raw_writeb writeb
115 #define __raw_writew writew
116 #define __raw_writel writel
120 #define memset_io(a,b,c) memset((void *)(a),(b),(c))
121 #define memcpy_fromio(a,b,c) memcpy((a),(void *)(b),(c))
122 #define memcpy_toio(a,b,c) memcpy((void *)(a),(b),(c))
125 * Again, CRIS does not require mem IO specific function.
128 #define eth_io_copy_and_sum(a,b,c,d) eth_copy_and_sum((a),(void __force *)(b),(c),(d))
130 /* The following is junk needed for the arch-independent code but which
131 * we never use in the CRIS port
134 #define IO_SPACE_LIMIT 0xffff
135 #define inb(port) (cris_iops ? cris_iops->read_io(port,NULL,1,1) : 0)
136 #define inw(port) (cris_iops ? cris_iops->read_io(port,NULL,2,1) : 0)
137 #define inl(port) (cris_iops ? cris_iops->read_io(port,NULL,4,1) : 0)
138 #define insb(port,addr,count) (cris_iops ? cris_iops->read_io(port,addr,1,count) : 0)
139 #define insw(port,addr,count) (cris_iops ? cris_iops->read_io(port,addr,2,count) : 0)
140 #define insl(port,addr,count) (cris_iops ? cris_iops->read_io(port,addr,4,count) : 0)
141 #define outb(data,port) if (cris_iops) cris_iops->write_io(port,(void*)(unsigned)data,1,1)
142 #define outw(data,port) if (cris_iops) cris_iops->write_io(port,(void*)(unsigned)data,2,1)
143 #define outl(data,port) if (cris_iops) cris_iops->write_io(port,(void*)(unsigned)data,4,1)
144 #define outsb(port,addr,count) if(cris_iops) cris_iops->write_io(port,(void*)addr,1,count)
145 #define outsw(port,addr,count) if(cris_iops) cris_iops->write_io(port,(void*)addr,2,count)
146 #define outsl(port,addr,count) if(cris_iops) cris_iops->write_io(port,(void*)addr,3,count)
149 * Convert a physical pointer to a virtual kernel pointer for /dev/mem
152 #define xlate_dev_mem_ptr(p) __va(p)
155 * Convert a virtual cached pointer to an uncached pointer
157 #define xlate_dev_kmem_ptr(p) p