io.h 2.15 KB
Newer Older
1
/*
2
 * include/asm-xtensa/io.h
3
4
5
6
7
8
9
10
11
12
13
14
 *
 * This file is subject to the terms and conditions of the GNU General Public
 * License.  See the file "COPYING" in the main directory of this archive
 * for more details.
 *
 * Copyright (C) 2001 - 2005 Tensilica Inc.
 */

#ifndef _XTENSA_IO_H
#define _XTENSA_IO_H

#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
21

#include <linux/types.h>

Chris Zankel's avatar
Chris Zankel committed
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
29
30
31
void __iomem *xtensa_ioremap_nocache(unsigned long addr, unsigned long size);
void __iomem *xtensa_ioremap_cache(unsigned long addr, unsigned long size);
void xtensa_iounmap(volatile void __iomem *addr);

32
/*
33
 * Return the virtual address for the specified bus memory.
34
 */
Max Filippov's avatar
Max Filippov committed
35
36
static inline void __iomem *ioremap_nocache(unsigned long offset,
		unsigned long size)
37
{
38
	if (offset >= XCHAL_KIO_PADDR
Max Filippov's avatar
Max Filippov committed
39
	    && offset - XCHAL_KIO_PADDR < XCHAL_KIO_SIZE)
40
41
		return (void*)(offset-XCHAL_KIO_PADDR+XCHAL_KIO_BYPASS_VADDR);
	else
42
		return xtensa_ioremap_nocache(offset, size);
43
44
}

Max Filippov's avatar
Max Filippov committed
45
46
static inline void __iomem *ioremap_cache(unsigned long offset,
		unsigned long size)
47
{
48
	if (offset >= XCHAL_KIO_PADDR
Max Filippov's avatar
Max Filippov committed
49
	    && offset - XCHAL_KIO_PADDR < XCHAL_KIO_SIZE)
50
51
		return (void*)(offset-XCHAL_KIO_PADDR+XCHAL_KIO_CACHED_VADDR);
	else
52
		return xtensa_ioremap_cache(offset, size);
53
}
Dan Williams's avatar
Dan Williams committed
54
#define ioremap_cache ioremap_cache
55
#define ioremap_nocache ioremap_nocache
56

Max Filippov's avatar
Max Filippov committed
57
#define ioremap_wc ioremap_nocache
58
#define ioremap_wt ioremap_nocache
Max Filippov's avatar
Max Filippov committed
59
60
61
62
63
64
65

static inline void __iomem *ioremap(unsigned long offset, unsigned long size)
{
	return ioremap_nocache(offset, size);
}

static inline void iounmap(volatile void __iomem *addr)
66
{
67
68
69
70
71
72
73
	unsigned long va = (unsigned long) addr;

	if (!(va >= XCHAL_KIO_CACHED_VADDR &&
	      va - XCHAL_KIO_CACHED_VADDR < XCHAL_KIO_SIZE) &&
	    !(va >= XCHAL_KIO_BYPASS_VADDR &&
	      va - XCHAL_KIO_BYPASS_VADDR < XCHAL_KIO_SIZE))
		xtensa_iounmap(addr);
74
}
75
76
77
78

#define virt_to_bus     virt_to_phys
#define bus_to_virt     phys_to_virt

79
#endif /* CONFIG_MMU */
80

81
82
#include <asm-generic/io.h>

83
#endif	/* _XTENSA_IO_H */