blob: bb5efd1b4b7d09a4782df938a73d6a4f10a4ba89 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * include/asm-v850/io.h -- Misc I/O operations
3 *
4 * Copyright (C) 2001,02,03,04 NEC Electronics Corporation
5 * Copyright (C) 2001,02,03,04 Miles Bader <miles@gnu.org>
6 *
7 * This file is subject to the terms and conditions of the GNU General
8 * Public License. See the file COPYING in the main directory of this
9 * archive for more details.
10 *
11 * Written by Miles Bader <miles@gnu.org>
12 */
13
14#ifndef __V850_IO_H__
15#define __V850_IO_H__
16
17#define IO_SPACE_LIMIT 0xFFFFFFFF
18
19#define readb(addr) \
20 ({ unsigned char __v = (*(volatile unsigned char *) (addr)); __v; })
21#define readw(addr) \
22 ({ unsigned short __v = (*(volatile unsigned short *) (addr)); __v; })
23#define readl(addr) \
24 ({ unsigned long __v = (*(volatile unsigned long *) (addr)); __v; })
25
26#define readb_relaxed(a) readb(a)
27#define readw_relaxed(a) readw(a)
28#define readl_relaxed(a) readl(a)
29
30#define writeb(b, addr) \
31 (void)((*(volatile unsigned char *) (addr)) = (b))
32#define writew(b, addr) \
33 (void)((*(volatile unsigned short *) (addr)) = (b))
34#define writel(b, addr) \
35 (void)((*(volatile unsigned int *) (addr)) = (b))
36
37#define __raw_readb readb
38#define __raw_readw readw
39#define __raw_readl readl
40#define __raw_writeb writeb
41#define __raw_writew writew
42#define __raw_writel writel
43
44#define inb(addr) readb (addr)
45#define inw(addr) readw (addr)
46#define inl(addr) readl (addr)
47#define outb(x, addr) ((void) writeb (x, addr))
48#define outw(x, addr) ((void) writew (x, addr))
49#define outl(x, addr) ((void) writel (x, addr))
50
51#define inb_p(port) inb((port))
52#define outb_p(val, port) outb((val), (port))
53#define inw_p(port) inw((port))
54#define outw_p(val, port) outw((val), (port))
55#define inl_p(port) inl((port))
56#define outl_p(val, port) outl((val), (port))
57
58static inline void insb (unsigned long port, void *dst, unsigned long count)
59{
60 unsigned char *p = dst;
61 while (count--)
62 *p++ = inb (port);
63}
64static inline void insw (unsigned long port, void *dst, unsigned long count)
65{
66 unsigned short *p = dst;
67 while (count--)
68 *p++ = inw (port);
69}
70static inline void insl (unsigned long port, void *dst, unsigned long count)
71{
72 unsigned long *p = dst;
73 while (count--)
74 *p++ = inl (port);
75}
76
77static inline void
78outsb (unsigned long port, const void *src, unsigned long count)
79{
80 const unsigned char *p = src;
81 while (count--)
82 outb (*p++, port);
83}
84static inline void
85outsw (unsigned long port, const void *src, unsigned long count)
86{
87 const unsigned short *p = src;
88 while (count--)
89 outw (*p++, port);
90}
91static inline void
92outsl (unsigned long port, const void *src, unsigned long count)
93{
94 const unsigned long *p = src;
95 while (count--)
96 outl (*p++, port);
97}
98
99#define iounmap(addr) ((void)0)
100#define ioremap(physaddr, size) (physaddr)
101#define ioremap_nocache(physaddr, size) (physaddr)
102#define ioremap_writethrough(physaddr, size) (physaddr)
103#define ioremap_fullcache(physaddr, size) (physaddr)
104
105#define mmiowb()
106
107#define page_to_phys(page) ((page - mem_map) << PAGE_SHIFT)
108#if 0
109/* This is really stupid; don't define it. */
110#define page_to_bus(page) page_to_phys (page)
111#endif
112
113/* Conversion between virtual and physical mappings. */
114#define mm_ptov(addr) ((void *)__phys_to_virt (addr))
115#define mm_vtop(addr) ((unsigned long)__virt_to_phys (addr))
116#define phys_to_virt(addr) ((void *)__phys_to_virt (addr))
117#define virt_to_phys(addr) ((unsigned long)__virt_to_phys (addr))
118
119#define memcpy_fromio(dst, src, len) memcpy (dst, (void *)src, len)
120#define memcpy_toio(dst, src, len) memcpy ((void *)dst, src, len)
121
122/*
123 * Convert a physical pointer to a virtual kernel pointer for /dev/mem
124 * access
125 */
126#define xlate_dev_mem_ptr(p) __va(p)
127
128/*
129 * Convert a virtual cached pointer to an uncached pointer
130 */
131#define xlate_dev_kmem_ptr(p) p
132
133#endif /* __V850_IO_H__ */