• Home
  • History
  • Annotate
  • Line#
  • Navigate
  • Raw
  • Download
  • only in /netgear-R7000-V1.0.7.12_1.2.5/components/opensource/linux/linux-2.6.36/arch/microblaze/include/asm/
1/*
2 * Copyright (C) 2007-2009 Michal Simek <monstr@monstr.eu>
3 * Copyright (C) 2007-2009 PetaLogix
4 * Copyright (C) 2006 Atmark Techno, Inc.
5 *
6 * This file is subject to the terms and conditions of the GNU General Public
7 * License. See the file "COPYING" in the main directory of this archive
8 * for more details.
9 */
10
11#ifndef _ASM_MICROBLAZE_IO_H
12#define _ASM_MICROBLAZE_IO_H
13
14#include <asm/byteorder.h>
15#include <asm/page.h>
16#include <linux/types.h>
17#include <linux/mm.h>          /* Get struct page {...} */
18#include <asm-generic/iomap.h>
19
20#ifndef CONFIG_PCI
21#define _IO_BASE	0
22#define _ISA_MEM_BASE	0
23#define PCI_DRAM_OFFSET	0
24#else
25#define _IO_BASE	isa_io_base
26#define _ISA_MEM_BASE	isa_mem_base
27#define PCI_DRAM_OFFSET	pci_dram_offset
28#endif
29
30extern unsigned long isa_io_base;
31extern unsigned long pci_io_base;
32extern unsigned long pci_dram_offset;
33
34extern resource_size_t isa_mem_base;
35
36#define IO_SPACE_LIMIT (0xFFFFFFFF)
37
38static inline unsigned char __raw_readb(const volatile void __iomem *addr)
39{
40	return *(volatile unsigned char __force *)addr;
41}
42static inline unsigned short __raw_readw(const volatile void __iomem *addr)
43{
44	return *(volatile unsigned short __force *)addr;
45}
46static inline unsigned int __raw_readl(const volatile void __iomem *addr)
47{
48	return *(volatile unsigned int __force *)addr;
49}
50static inline unsigned long __raw_readq(const volatile void __iomem *addr)
51{
52	return *(volatile unsigned long __force *)addr;
53}
54static inline void __raw_writeb(unsigned char v, volatile void __iomem *addr)
55{
56	*(volatile unsigned char __force *)addr = v;
57}
58static inline void __raw_writew(unsigned short v, volatile void __iomem *addr)
59{
60	*(volatile unsigned short __force *)addr = v;
61}
62static inline void __raw_writel(unsigned int v, volatile void __iomem *addr)
63{
64	*(volatile unsigned int __force *)addr = v;
65}
66static inline void __raw_writeq(unsigned long v, volatile void __iomem *addr)
67{
68	*(volatile unsigned long __force *)addr = v;
69}
70
71/*
72 * read (readb, readw, readl, readq) and write (writeb, writew,
73 * writel, writeq) accessors are for PCI and thus littel endian.
74 * Linux 2.4 for Microblaze had this wrong.
75 */
76static inline unsigned char readb(const volatile void __iomem *addr)
77{
78	return *(volatile unsigned char __force *)addr;
79}
80static inline unsigned short readw(const volatile void __iomem *addr)
81{
82	return le16_to_cpu(*(volatile unsigned short __force *)addr);
83}
84static inline unsigned int readl(const volatile void __iomem *addr)
85{
86	return le32_to_cpu(*(volatile unsigned int __force *)addr);
87}
88static inline void writeb(unsigned char v, volatile void __iomem *addr)
89{
90	*(volatile unsigned char __force *)addr = v;
91}
92static inline void writew(unsigned short v, volatile void __iomem *addr)
93{
94	*(volatile unsigned short __force *)addr = cpu_to_le16(v);
95}
96static inline void writel(unsigned int v, volatile void __iomem *addr)
97{
98	*(volatile unsigned int __force *)addr = cpu_to_le32(v);
99}
100
101/* ioread and iowrite variants. thease are for now same as __raw_
102 * variants of accessors. we might check for endianess in the feature
103 */
104#define ioread8(addr)		__raw_readb((u8 *)(addr))
105#define ioread16(addr)		__raw_readw((u16 *)(addr))
106#define ioread32(addr)		__raw_readl((u32 *)(addr))
107#define iowrite8(v, addr)	__raw_writeb((u8)(v), (u8 *)(addr))
108#define iowrite16(v, addr)	__raw_writew((u16)(v), (u16 *)(addr))
109#define iowrite32(v, addr)	__raw_writel((u32)(v), (u32 *)(addr))
110
111#define ioread16be(addr)	__raw_readw((u16 *)(addr))
112#define ioread32be(addr)	__raw_readl((u32 *)(addr))
113#define iowrite16be(v, addr)	__raw_writew((u16)(v), (u16 *)(addr))
114#define iowrite32be(v, addr)	__raw_writel((u32)(v), (u32 *)(addr))
115
116/* These are the definitions for the x86 IO instructions
117 * inb/inw/inl/outb/outw/outl, the "string" versions
118 * insb/insw/insl/outsb/outsw/outsl, and the "pausing" versions
119 * inb_p/inw_p/...
120 * The macros don't do byte-swapping.
121 */
122#define inb(port)		readb((u8 *)((port)))
123#define outb(val, port)		writeb((val), (u8 *)((unsigned long)(port)))
124#define inw(port)		readw((u16 *)((port)))
125#define outw(val, port)		writew((val), (u16 *)((unsigned long)(port)))
126#define inl(port)		readl((u32 *)((port)))
127#define outl(val, port)		writel((val), (u32 *)((unsigned long)(port)))
128
129#define inb_p(port)		inb((port))
130#define outb_p(val, port)	outb((val), (port))
131#define inw_p(port)		inw((port))
132#define outw_p(val, port)	outw((val), (port))
133#define inl_p(port)		inl((port))
134#define outl_p(val, port)	outl((val), (port))
135
136#define memset_io(a, b, c)	memset((void *)(a), (b), (c))
137#define memcpy_fromio(a, b, c)	memcpy((a), (void *)(b), (c))
138#define memcpy_toio(a, b, c)	memcpy((void *)(a), (b), (c))
139
140#ifdef CONFIG_MMU
141
142#define phys_to_virt(addr)	((void *)__phys_to_virt(addr))
143#define virt_to_phys(addr)	((unsigned long)__virt_to_phys(addr))
144#define virt_to_bus(addr)	((unsigned long)__virt_to_phys(addr))
145
146#define page_to_bus(page)	(page_to_phys(page))
147#define bus_to_virt(addr)	(phys_to_virt(addr))
148
149extern void iounmap(void *addr);
150/*extern void *__ioremap(phys_addr_t address, unsigned long size,
151		unsigned long flags);*/
152extern void __iomem *ioremap(phys_addr_t address, unsigned long size);
153#define ioremap_writethrough(addr, size) ioremap((addr), (size))
154#define ioremap_nocache(addr, size)      ioremap((addr), (size))
155#define ioremap_fullcache(addr, size)    ioremap((addr), (size))
156
157#else /* CONFIG_MMU */
158
159/**
160 *	virt_to_phys - map virtual addresses to physical
161 *	@address: address to remap
162 *
163 *	The returned physical address is the physical (CPU) mapping for
164 *	the memory address given. It is only valid to use this function on
165 *	addresses directly mapped or allocated via kmalloc.
166 *
167 *	This function does not give bus mappings for DMA transfers. In
168 *	almost all conceivable cases a device driver should not be using
169 *	this function
170 */
171static inline unsigned long __iomem virt_to_phys(volatile void *address)
172{
173	return __pa((unsigned long)address);
174}
175
176#define virt_to_bus virt_to_phys
177
178/**
179 *	phys_to_virt - map physical address to virtual
180 *	@address: address to remap
181 *
182 *	The returned virtual address is a current CPU mapping for
183 *	the memory address given. It is only valid to use this function on
184 *	addresses that have a kernel mapping
185 *
186 *	This function does not handle bus mappings for DMA transfers. In
187 *	almost all conceivable cases a device driver should not be using
188 *	this function
189 */
190static inline void *phys_to_virt(unsigned long address)
191{
192	return (void *)__va(address);
193}
194
195#define bus_to_virt(a) phys_to_virt(a)
196
197static inline void __iomem *__ioremap(phys_addr_t address, unsigned long size,
198			unsigned long flags)
199{
200	return (void *)address;
201}
202
203#define ioremap(physaddr, size)	((void __iomem *)(unsigned long)(physaddr))
204#define iounmap(addr)		((void)0)
205#define ioremap_nocache(physaddr, size)	ioremap(physaddr, size)
206
207#endif /* CONFIG_MMU */
208
209/*
210 * Convert a physical pointer to a virtual kernel pointer for /dev/mem
211 * access
212 */
213#define xlate_dev_mem_ptr(p)	__va(p)
214
215/*
216 * Convert a virtual cached pointer to an uncached pointer
217 */
218#define xlate_dev_kmem_ptr(p)	p
219
220/*
221 * Big Endian
222 */
223#define out_be32(a, v) __raw_writel((v), (void __iomem __force *)(a))
224#define out_be16(a, v) __raw_writew((v), (a))
225
226#define in_be32(a) __raw_readl((const void __iomem __force *)(a))
227#define in_be16(a) __raw_readw(a)
228
229#define writel_be(v, a)	out_be32((__force unsigned *)a, v)
230#define readl_be(a)	in_be32((__force unsigned *)a)
231
232/*
233 * Little endian
234 */
235
236#define out_le32(a, v) __raw_writel(__cpu_to_le32(v), (a))
237#define out_le16(a, v) __raw_writew(__cpu_to_le16(v), (a))
238
239#define in_le32(a) __le32_to_cpu(__raw_readl(a))
240#define in_le16(a) __le16_to_cpu(__raw_readw(a))
241
242/* Byte ops */
243#define out_8(a, v) __raw_writeb((v), (a))
244#define in_8(a) __raw_readb(a)
245
246#define ioport_map(port, nr)	((void __iomem *)(port))
247#define ioport_unmap(addr)
248
249#endif /* _ASM_MICROBLAZE_IO_H */
250