7 #include <linux/types.h>
9 #include <linux/compiler.h>
12 * These are for ISA/PCI shared memory _only_ and should never be used
13 * on any other type of memory, including Zorro memory. They are meant to
14 * access the bus in the bus byte order which is little-endian!.
16 * readX/writeX() are used to access memory mapped devices. On some
17 * architectures the memory mapped IO stuff needs to be accessed
18 * differently. On the bfin architecture, we just read/write the
19 * memory location directly.
23 static inline unsigned char readb(const volatile void __iomem
*addr
)
28 __asm__
__volatile__ ("cli %1;\n\t"
29 "NOP; NOP; SSYNC;\n\t"
30 "%0 = b [%2] (z);\n\t"
32 : "=d"(val
), "=d"(tmp
): "a"(addr
)
35 return (unsigned char) val
;
38 static inline unsigned short readw(const volatile void __iomem
*addr
)
43 __asm__
__volatile__ ("cli %1;\n\t"
44 "NOP; NOP; SSYNC;\n\t"
45 "%0 = w [%2] (z);\n\t"
47 : "=d"(val
), "=d"(tmp
): "a"(addr
)
50 return (unsigned short) val
;
53 static inline unsigned int readl(const volatile void __iomem
*addr
)
58 __asm__
__volatile__ ("cli %1;\n\t"
59 "NOP; NOP; SSYNC;\n\t"
62 : "=d"(val
), "=d"(tmp
): "a"(addr
)
67 #endif /* __ASSEMBLY__ */
69 #define writeb(b,addr) (void)((*(volatile unsigned char *) (addr)) = (b))
70 #define writew(b,addr) (void)((*(volatile unsigned short *) (addr)) = (b))
71 #define writel(b,addr) (void)((*(volatile unsigned int *) (addr)) = (b))
73 #define __raw_readb readb
74 #define __raw_readw readw
75 #define __raw_readl readl
76 #define __raw_writeb writeb
77 #define __raw_writew writew
78 #define __raw_writel writel
79 #define memset_io(a,b,c) memset((void *)(a),(b),(c))
80 #define memcpy_fromio(a,b,c) memcpy((a),(void *)(b),(c))
81 #define memcpy_toio(a,b,c) memcpy((void *)(a),(b),(c))
83 #define inb(addr) readb(addr)
84 #define inw(addr) readw(addr)
85 #define inl(addr) readl(addr)
86 #define outb(x,addr) ((void) writeb(x,addr))
87 #define outw(x,addr) ((void) writew(x,addr))
88 #define outl(x,addr) ((void) writel(x,addr))
90 #define inb_p(addr) inb(addr)
91 #define inw_p(addr) inw(addr)
92 #define inl_p(addr) inl(addr)
93 #define outb_p(x,addr) outb(x,addr)
94 #define outw_p(x,addr) outw(x,addr)
95 #define outl_p(x,addr) outl(x,addr)
97 #define ioread8_rep(a,d,c) readsb(a,d,c)
98 #define ioread16_rep(a,d,c) readsw(a,d,c)
99 #define ioread32_rep(a,d,c) readsl(a,d,c)
100 #define iowrite8_rep(a,s,c) writesb(a,s,c)
101 #define iowrite16_rep(a,s,c) writesw(a,s,c)
102 #define iowrite32_rep(a,s,c) writesl(a,s,c)
104 #define ioread8(X) readb(X)
105 #define ioread16(X) readw(X)
106 #define ioread32(X) readl(X)
107 #define iowrite8(val,X) writeb(val,X)
108 #define iowrite16(val,X) writew(val,X)
109 #define iowrite32(val,X) writel(val,X)
111 #define mmiowb() wmb()
113 #define IO_SPACE_LIMIT 0xffffffff
115 /* Values for nocacheflag and cmode */
116 #define IOMAP_NOCACHE_SER 1
120 extern void outsb(unsigned long port
, const void *addr
, unsigned long count
);
121 extern void outsw(unsigned long port
, const void *addr
, unsigned long count
);
122 extern void outsw_8(unsigned long port
, const void *addr
, unsigned long count
);
123 extern void outsl(unsigned long port
, const void *addr
, unsigned long count
);
125 extern void insb(unsigned long port
, void *addr
, unsigned long count
);
126 extern void insw(unsigned long port
, void *addr
, unsigned long count
);
127 extern void insw_8(unsigned long port
, void *addr
, unsigned long count
);
128 extern void insl(unsigned long port
, void *addr
, unsigned long count
);
129 extern void insl_16(unsigned long port
, void *addr
, unsigned long count
);
131 extern void dma_outsb(unsigned long port
, const void *addr
, unsigned short count
);
132 extern void dma_outsw(unsigned long port
, const void *addr
, unsigned short count
);
133 extern void dma_outsl(unsigned long port
, const void *addr
, unsigned short count
);
135 extern void dma_insb(unsigned long port
, void *addr
, unsigned short count
);
136 extern void dma_insw(unsigned long port
, void *addr
, unsigned short count
);
137 extern void dma_insl(unsigned long port
, void *addr
, unsigned short count
);
139 static inline void readsl(const void __iomem
*addr
, void *buf
, int len
)
141 insl((unsigned long)addr
, buf
, len
);
144 static inline void readsw(const void __iomem
*addr
, void *buf
, int len
)
146 insw((unsigned long)addr
, buf
, len
);
149 static inline void readsb(const void __iomem
*addr
, void *buf
, int len
)
151 insb((unsigned long)addr
, buf
, len
);
154 static inline void writesl(const void __iomem
*addr
, const void *buf
, int len
)
156 outsl((unsigned long)addr
, buf
, len
);
159 static inline void writesw(const void __iomem
*addr
, const void *buf
, int len
)
161 outsw((unsigned long)addr
, buf
, len
);
164 static inline void writesb(const void __iomem
*addr
, const void *buf
, int len
)
166 outsb((unsigned long)addr
, buf
, len
);
170 * Map some physical address range into the kernel address space.
172 static inline void __iomem
*__ioremap(unsigned long physaddr
, unsigned long size
,
175 return (void __iomem
*)physaddr
;
179 * Unmap a ioremap()ed region again
181 static inline void iounmap(void *addr
)
186 * __iounmap unmaps nearly everything, so be careful
187 * it doesn't free currently pointer/page tables anymore but it
188 * wans't used anyway and might be added later.
190 static inline void __iounmap(void *addr
, unsigned long size
)
195 * Set new cache mode for some kernel address space.
196 * The caller must push data for that range itself, if such data may already
199 static inline void kernel_set_cachemode(void *addr
, unsigned long size
,
204 static inline void __iomem
*ioremap(unsigned long physaddr
, unsigned long size
)
206 return __ioremap(physaddr
, size
, IOMAP_NOCACHE_SER
);
208 static inline void __iomem
*ioremap_nocache(unsigned long physaddr
,
211 return __ioremap(physaddr
, size
, IOMAP_NOCACHE_SER
);
214 extern void blkfin_inv_cache_all(void);
218 #define ioport_map(port, nr) ((void __iomem*)(port))
219 #define ioport_unmap(addr)
221 /* Pages to physical address... */
222 #define page_to_phys(page) ((page - mem_map) << PAGE_SHIFT)
223 #define page_to_bus(page) ((page - mem_map) << PAGE_SHIFT)
225 #define phys_to_virt(vaddr) ((void *) (vaddr))
226 #define virt_to_phys(vaddr) ((unsigned long) (vaddr))
228 #define virt_to_bus virt_to_phys
229 #define bus_to_virt phys_to_virt
232 * Convert a physical pointer to a virtual kernel pointer for /dev/mem
235 #define xlate_dev_mem_ptr(p) __va(p)
238 * Convert a virtual cached pointer to an uncached pointer
240 #define xlate_dev_kmem_ptr(p) p
242 #endif /* __KERNEL__ */
244 #endif /* _BFIN_IO_H */