Root/target/linux/coldfire/files-2.6.31/arch/m68k/include/asm/cf_io.h

1/*
2 * linux/include/asm-m68k/cf_io.h
3 *
4 * Copyright 2007-2009 Freescale Semiconductor, Inc. All Rights Reserved.
5 * 9/30/08 JKM - Separated Coldfire pieces out from m68k.
6 */
7
8#ifndef __CF_IO__
9#define __CF_IO__
10
11#ifdef __KERNEL__
12
13#include <linux/compiler.h>
14#include <asm/raw_io.h>
15#include <asm/virtconvert.h>
16
17#include <asm-generic/iomap.h>
18
19/*
20 * These should be valid on any ioremap()ed region
21 */
22#define readb(addr) in_8(addr)
23#define writeb(val,addr) out_8((addr),(val))
24#define readw(addr) in_le16(addr)
25#define writew(val,addr) out_le16((addr),(val))
26#define readl(addr) in_le32(addr)
27#define writel(val,addr) out_le32((addr),(val))
28
29#define readb_relaxed(addr) readb(addr)
30#define readw_relaxed(addr) readw(addr)
31#define readl_relaxed(addr) readl(addr)
32
33#ifdef CONFIG_PCI
34
35/*
36 * IO space in Coldfire
37 */
38/*#define HAVE_ARCH_PIO_SIZE 1
39#define PIO_OFFSET 0x00000000UL
40#define PIO_RESERVED 0x100000000UL
41#define PIO_MASK (PIO_RESERVED - 1)
42*/
43#define inb_p inb
44#define inw_p inw
45#define inl_p inl
46#define outb_p outb
47#define outw_p outw
48#define outl_p outl
49
50#ifndef CONFIG_COLDFIRE
51#define inb(port) in_8(port)
52#define outb(val,port) out_8((port),(val))
53#define inw(port) in_le16(port)
54#define outw(val,port) out_le16((port),(val))
55#define inl(port) in_le32(port)
56#define outl(val,port) out_le32((port),(val))
57#define insb(port, buf, nr) \
58        raw_insb((u8 *)(port), (u8 *)(buf), (nr))
59#define outsb(port, buf, nr) \
60        raw_outsb((u8 *)(port), (u8 *)(buf), (nr))
61#define insw(port, buf, nr) \
62        raw_insw_swapw((u16 *)(port), (u16 *)(buf), (nr))
63#define outsw(port, buf, nr) \
64        raw_outsw_swapw((u16 *)(port), (u16 *)(buf), (nr))
65#define insl(port, buf, nr) \
66        raw_insw_swapw((u16 *)(port), (u16 *)(buf), (nr)<<1)
67#define outsl(port, buf, nr) \
68        raw_outsw_swapw((u16 *)(port), (u16 *)(buf), (nr)<<1)
69#else
70#define inb(port) pci_inb(port)
71#define outb(val, port) pci_outb((val), (port))
72#define inw(port) pci_inw(port)
73#define outw(val, port) pci_outw((val), (port))
74#define insb(a, b, c) \
75    pci_insb((volatile unsigned char *)a, (unsigned char *)b, c)
76#define insw(a, b, c) \
77    pci_insw((volatile unsigned short *)a, (const unsigned short *)b, c)
78#define insl(a, b, c) \
79    pci_insl((volatile unsigned long *)a, (const unsigned long *)b, c)
80#define outsb(a, b, c) \
81    pci_outsb((volatile unsigned char *)a, (const unsigned char *)b, c)
82#define outsw(a, b, c) \
83    pci_outsw((volatile unsigned short *)a, (const unsigned short *)b, c)
84#define outsl(a, b, c) \
85    pci_outsl((volatile unsigned long *)a, (const unsigned long *)b, c)
86#define inl(port) pci_inl(port)
87#define outl(val, port) pci_outl((val), (port))
88#endif
89
90#else
91/* no pci */
92
93#define inb(port) in_8(port)
94#define outb(val, port) out_8((port), (val))
95#define inw(port) in_le16(port)
96#define outw(val, port) out_le16((port), (val))
97#define inl(port) in_le32(port)
98#define outl(val, port) out_le32((port), (val))
99#define insb(port, buf, nr) \
100        raw_insb((u8 *)(port), (u8 *)(buf), (nr))
101#define outsb(port, buf, nr) \
102        raw_outsb((u8 *)(port), (u8 *)(buf), (nr))
103#define insw(port, buf, nr) \
104        raw_insw_swapw((u16 *)(port), (u16 *)(buf), (nr))
105#define outsw(port, buf, nr) \
106        raw_outsw_swapw((u16 *)(port), (u16 *)(buf), (nr))
107#define insl(port, buf, nr) \
108        raw_insw_swapw((u16 *)(port), (u16 *)(buf), (nr)<<1)
109#define outsl(port, buf, nr) \
110        raw_outsw_swapw((u16 *)(port), (u16 *)(buf), (nr)<<1)
111
112#endif /* CONFIG_PCI */
113
114#define mmiowb()
115
116static inline void __iomem *ioremap(unsigned long physaddr, unsigned long size)
117{
118    return __ioremap(physaddr, size, IOMAP_NOCACHE_SER);
119}
120static inline void __iomem *ioremap_nocache(unsigned long physaddr, unsigned long size)
121{
122    return __ioremap(physaddr, size, IOMAP_NOCACHE_SER);
123}
124static inline void __iomem *ioremap_writethrough(unsigned long physaddr,
125                     unsigned long size)
126{
127    return __ioremap(physaddr, size, IOMAP_WRITETHROUGH);
128}
129static inline void __iomem *ioremap_fullcache(unsigned long physaddr,
130                      unsigned long size)
131{
132    return __ioremap(physaddr, size, IOMAP_FULL_CACHING);
133}
134
135static inline void memset_io(volatile void __iomem *addr, unsigned char val, int count)
136{
137    __builtin_memset((void __force *) addr, val, count);
138}
139static inline void memcpy_fromio(void *dst, const volatile void __iomem *src, int count)
140{
141    __builtin_memcpy(dst, (void __force *) src, count);
142}
143static inline void memcpy_toio(volatile void __iomem *dst, const void *src, int count)
144{
145    __builtin_memcpy((void __force *) dst, src, count);
146}
147
148#define IO_SPACE_LIMIT 0xffffffff
149
150#endif /* __KERNEL__ */
151
152#define __ARCH_HAS_NO_PAGE_ZERO_MAPPED 1
153
154/*
155 * Convert a physical pointer to a virtual kernel pointer for /dev/mem
156 * access
157 */
158#define xlate_dev_mem_ptr(p) __va(p)
159
160/*
161 * Convert a virtual cached pointer to an uncached pointer
162 */
163#define xlate_dev_kmem_ptr(p) p
164
165#define __raw_readb(addr) \
166    ({ unsigned char __v = (*(volatile unsigned char *) (addr)); __v; })
167#define __raw_readw(addr) \
168    ({ unsigned short __v = (*(volatile unsigned short *) (addr)); __v; })
169#define __raw_readl(addr) \
170    ({ unsigned long __v = (*(volatile unsigned long *) (addr)); __v; })
171#define __raw_writeb(b,addr) (void)((*(volatile unsigned char *) (addr)) = (b))
172#define __raw_writew(b,addr) (void)((*(volatile unsigned short *) (addr)) = (b))
173#define __raw_writel(b,addr) (void)((*(volatile unsigned int *) (addr)) = (b))
174
175#define memset_io(a, b, c) memset((void *)(a), (b), (c))
176#define memcpy_fromio(a, b, c) memcpy((a), (void *)(b), (c))
177#define memcpy_toio(a, b, c) memcpy((void *)(a), (b), (c))
178
179#if !defined(readb)
180#define readb(addr) \
181    ({ unsigned char __v = (*(volatile unsigned char *) (addr)); __v; })
182#define readw(addr) \
183    ({ unsigned short __v = (*(volatile unsigned short *) (addr)); __v; })
184#define readl(addr) \
185    ({ unsigned int __v = (*(volatile unsigned int *) (addr)); __v; })
186#define writeb(b, addr) (void)((*(volatile unsigned char *) (addr)) = (b))
187#define writew(b, addr) (void)((*(volatile unsigned short *) (addr)) = (b))
188#define writel(b, addr) (void)((*(volatile unsigned int *) (addr)) = (b))
189#endif /* readb */
190
191#endif /* _IO_H */
192

Archive Download this file



interactive