xref: /linux/arch/xtensa/include/asm/io.h (revision 07f0148aafe8c95a3a76cd59e9e75b4d78d1d31d)
1 /*
2  * include/asm-xtensa/io.h
3  *
4  * This file is subject to the terms and conditions of the GNU General Public
5  * License.  See the file "COPYING" in the main directory of this archive
6  * for more details.
7  *
8  * Copyright (C) 2001 - 2005 Tensilica Inc.
9  */
10 
11 #ifndef _XTENSA_IO_H
12 #define _XTENSA_IO_H
13 
14 #include <asm/byteorder.h>
15 #include <asm/page.h>
16 #include <asm/vectors.h>
17 #include <linux/bug.h>
18 #include <linux/kernel.h>
19 
20 #include <linux/types.h>
21 
22 #define IOADDR(x)		(XCHAL_KIO_BYPASS_VADDR + (x))
23 #define IO_SPACE_LIMIT ~0
24 #define PCI_IOBASE		((void __iomem *)XCHAL_KIO_BYPASS_VADDR)
25 
26 #ifdef CONFIG_MMU
27 
28 void __iomem *xtensa_ioremap_nocache(unsigned long addr, unsigned long size);
29 void __iomem *xtensa_ioremap_cache(unsigned long addr, unsigned long size);
30 void xtensa_iounmap(volatile void __iomem *addr);
31 
32 /*
33  * Return the virtual address for the specified bus memory.
34  */
35 static inline void __iomem *ioremap(unsigned long offset, unsigned long size)
36 {
37 	if (offset >= XCHAL_KIO_PADDR
38 	    && offset - XCHAL_KIO_PADDR < XCHAL_KIO_SIZE)
39 		return (void*)(offset-XCHAL_KIO_PADDR+XCHAL_KIO_BYPASS_VADDR);
40 	else
41 		return xtensa_ioremap_nocache(offset, size);
42 }
43 
44 static inline void __iomem *ioremap_cache(unsigned long offset,
45 		unsigned long size)
46 {
47 	if (offset >= XCHAL_KIO_PADDR
48 	    && offset - XCHAL_KIO_PADDR < XCHAL_KIO_SIZE)
49 		return (void*)(offset-XCHAL_KIO_PADDR+XCHAL_KIO_CACHED_VADDR);
50 	else
51 		return xtensa_ioremap_cache(offset, size);
52 }
53 #define ioremap_cache ioremap_cache
54 
55 static inline void iounmap(volatile void __iomem *addr)
56 {
57 	unsigned long va = (unsigned long) addr;
58 
59 	if (!(va >= XCHAL_KIO_CACHED_VADDR &&
60 	      va - XCHAL_KIO_CACHED_VADDR < XCHAL_KIO_SIZE) &&
61 	    !(va >= XCHAL_KIO_BYPASS_VADDR &&
62 	      va - XCHAL_KIO_BYPASS_VADDR < XCHAL_KIO_SIZE))
63 		xtensa_iounmap(addr);
64 }
65 
66 #endif /* CONFIG_MMU */
67 
68 #include <asm-generic/io.h>
69 
70 #endif	/* _XTENSA_IO_H */
71