io.h 17.0 KB
Newer Older
L
Linus Torvalds 已提交
1 2 3 4 5 6
/*
 * 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) 1994, 1995 Waldorf GmbH
7
 * Copyright (C) 1994 - 2000, 06 Ralf Baechle
L
Linus Torvalds 已提交
8 9
 * Copyright (C) 1999, 2000 Silicon Graphics, Inc.
 * Copyright (C) 2004, 2005  MIPS Technologies, Inc.  All rights reserved.
R
Ralf Baechle 已提交
10
 *	Author: Maciej W. Rozycki <macro@mips.com>
L
Linus Torvalds 已提交
11 12 13 14
 */
#ifndef _ASM_IO_H
#define _ASM_IO_H

15 16
#define ARCH_HAS_IOREMAP_WC

L
Linus Torvalds 已提交
17 18 19
#include <linux/compiler.h>
#include <linux/kernel.h>
#include <linux/types.h>
20
#include <linux/irqflags.h>
L
Linus Torvalds 已提交
21 22

#include <asm/addrspace.h>
23
#include <asm/barrier.h>
Y
Yoichi Yuasa 已提交
24
#include <asm/bug.h>
L
Linus Torvalds 已提交
25 26 27
#include <asm/byteorder.h>
#include <asm/cpu.h>
#include <asm/cpu-features.h>
R
Ralf Baechle 已提交
28
#include <asm-generic/iomap.h>
L
Linus Torvalds 已提交
29 30 31
#include <asm/page.h>
#include <asm/pgtable-bits.h>
#include <asm/processor.h>
R
Ralf Baechle 已提交
32
#include <asm/string.h>
L
Linus Torvalds 已提交
33 34 35
#include <mangle-port.h>

/*
36
 * Raw operations are never swapped in software.  OTOH values that raw
L
Linus Torvalds 已提交
37 38 39 40
 * operations are working on may or may not have been swapped by the bus
 * hardware.  An example use would be for flash memory that's used for
 * execute in place.
 */
41 42 43 44 45
# define __raw_ioswabb(a, x)	(x)
# define __raw_ioswabw(a, x)	(x)
# define __raw_ioswabl(a, x)	(x)
# define __raw_ioswabq(a, x)	(x)
# define ____raw_ioswabq(a, x)	(x)
L
Linus Torvalds 已提交
46

47 48 49 50 51
# define __relaxed_ioswabb ioswabb
# define __relaxed_ioswabw ioswabw
# define __relaxed_ioswabl ioswabl
# define __relaxed_ioswabq ioswabq

52
/* ioswab[bwlq], __mem_ioswab[bwlq] are defined in mangle-port.h */
L
Linus Torvalds 已提交
53 54 55 56 57 58 59

/*
 * On MIPS I/O ports are memory mapped, so we access them using normal
 * load/store instructions. mips_io_port_base is the virtual address to
 * which all ports are being mapped.  For sake of efficiency some code
 * assumes that this is an address that can be loaded with a single lui
 * instruction, so the lower 16 bits must be zero.  Should be true on
60
 * any sane architecture; generic code does not use this assumption.
L
Linus Torvalds 已提交
61
 */
62
extern unsigned long mips_io_port_base;
L
Linus Torvalds 已提交
63

64 65
static inline void set_io_port_base(unsigned long base)
{
66
	mips_io_port_base = base;
67
}
L
Linus Torvalds 已提交
68

P
Paul Burton 已提交
69 70 71 72 73
/*
 * Provide the necessary definitions for generic iomap. We make use of
 * mips_io_port_base for iomap(), but we don't reserve any low addresses for
 * use with I/O ports.
 */
74

P
Paul Burton 已提交
75 76 77 78
#define HAVE_ARCH_PIO_SIZE
#define PIO_OFFSET	mips_io_port_base
#define PIO_MASK	IO_SPACE_LIMIT
#define PIO_RESERVED	0x0UL
79 80 81 82 83 84 85 86 87 88 89

/*
 * Enforce in-order execution of data I/O.  In the MIPS architecture
 * these are equivalent to corresponding platform-specific memory
 * barriers defined in <asm/barrier.h>.  API pinched from PowerPC,
 * with sync additionally defined.
 */
#define iobarrier_rw() mb()
#define iobarrier_r() rmb()
#define iobarrier_w() wmb()
#define iobarrier_sync() iob()
P
Paul Burton 已提交
90

L
Linus Torvalds 已提交
91 92 93 94 95 96 97 98 99 100 101 102
/*
 *     virt_to_phys    -       map virtual addresses to physical
 *     @address: address to remap
 *
 *     The returned physical address is the physical (CPU) mapping for
 *     the memory address given. It is only valid to use this function on
 *     addresses directly mapped or allocated via kmalloc.
 *
 *     This function does not give bus mappings for DMA transfers. In
 *     almost all conceivable cases a device driver should not be using
 *     this function
 */
103
static inline unsigned long __virt_to_phys_nodebug(volatile const void *address)
L
Linus Torvalds 已提交
104
{
105
	return __pa(address);
L
Linus Torvalds 已提交
106 107
}

108 109 110 111 112 113 114 115 116 117 118 119
#ifdef CONFIG_DEBUG_VIRTUAL
extern phys_addr_t __virt_to_phys(volatile const void *x);
#else
#define __virt_to_phys(x)	__virt_to_phys_nodebug(x)
#endif

#define virt_to_phys virt_to_phys
static inline phys_addr_t virt_to_phys(const volatile void *x)
{
	return __virt_to_phys(x);
}

L
Linus Torvalds 已提交
120 121 122 123 124 125 126 127 128 129 130 131 132 133
/*
 *     phys_to_virt    -       map physical address to virtual
 *     @address: address to remap
 *
 *     The returned virtual address is a current CPU mapping for
 *     the memory address given. It is only valid to use this function on
 *     addresses that have a kernel mapping
 *
 *     This function does not handle bus mappings for DMA transfers. In
 *     almost all conceivable cases a device driver should not be using
 *     this function
 */
static inline void * phys_to_virt(unsigned long address)
{
134
	return (void *)(address + PAGE_OFFSET - PHYS_OFFSET);
L
Linus Torvalds 已提交
135 136 137 138 139
}

/*
 * ISA I/O bus memory addresses are 1:1 with the physical address.
 */
140
static inline unsigned long isa_virt_to_bus(volatile void *address)
L
Linus Torvalds 已提交
141
{
142
	return virt_to_phys(address);
L
Linus Torvalds 已提交
143 144
}

145
static inline void *isa_bus_to_virt(unsigned long address)
L
Linus Torvalds 已提交
146
{
147
	return phys_to_virt(address);
L
Linus Torvalds 已提交
148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163
}

/*
 * However PCI ones are not necessarily 1:1 and therefore these interfaces
 * are forbidden in portable PCI drivers.
 *
 * Allow them for x86 for legacy drivers, though.
 */
#define virt_to_bus virt_to_phys
#define bus_to_virt phys_to_virt

/*
 * Change "struct page" to physical address.
 */
#define page_to_phys(page)	((dma_addr_t)page_to_pfn(page) << PAGE_SHIFT)

164 165 166
void __iomem *ioremap_prot(phys_addr_t offset, unsigned long size,
		unsigned long prot_val);
void iounmap(const volatile void __iomem *addr);
167

L
Linus Torvalds 已提交
168 169 170 171 172 173 174 175 176 177 178 179
/*
 * ioremap     -   map bus memory into CPU space
 * @offset:    bus address of the memory
 * @size:      size of the resource to map
 *
 * ioremap performs a platform specific sequence of operations to
 * make bus memory CPU accessible via the readb/readw/readl/writeb/
 * writew/writel functions and the other mmio helpers. The returned
 * address is not guaranteed to be usable directly as a virtual
 * address.
 */
#define ioremap(offset, size)						\
180
	ioremap_prot((offset), (size), _CACHE_UNCACHED)
181
#define ioremap_uc		ioremap
L
Linus Torvalds 已提交
182

183
/*
184
 * ioremap_cache -	map bus memory into CPU space
R
Ralf Baechle 已提交
185 186
 * @offset:	    bus address of the memory
 * @size:	    size of the resource to map
187
 *
188
 * ioremap_cache performs a platform specific sequence of operations to
189 190 191 192 193 194
 * make bus memory CPU accessible via the readb/readw/readl/writeb/
 * writew/writel functions and the other mmio helpers. The returned
 * address is not guaranteed to be usable directly as a virtual
 * address.
 *
 * This version of ioremap ensures that the memory is marked cachable by
R
Ralf Baechle 已提交
195
 * the CPU.  Also enables full write-combining.	 Useful for some
196 197
 * memory-like regions on I/O busses.
 */
198
#define ioremap_cache(offset, size)					\
199
	ioremap_prot((offset), (size), _page_cachable_default)
200

201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219
/*
 * ioremap_wc     -   map bus memory into CPU space
 * @offset:    bus address of the memory
 * @size:      size of the resource to map
 *
 * ioremap_wc performs a platform specific sequence of operations to
 * make bus memory CPU accessible via the readb/readw/readl/writeb/
 * writew/writel functions and the other mmio helpers. The returned
 * address is not guaranteed to be usable directly as a virtual
 * address.
 *
 * This version of ioremap ensures that the memory is marked uncachable
 * but accelerated by means of write-combining feature. It is specifically
 * useful for PCIe prefetchable windows, which may vastly improve a
 * communications performance. If it was determined on boot stage, what
 * CPU CCA doesn't support UCA, the method shall fall-back to the
 * _CACHE_UNCACHED option (see cpu_probe() method).
 */
#define ioremap_wc(offset, size)					\
220
	ioremap_prot((offset), (size), boot_cpu_data.writecombine)
221

J
Jiaxun Yang 已提交
222
#if defined(CONFIG_CPU_CAVIUM_OCTEON) || defined(CONFIG_CPU_LOONGSON64)
223
#define war_io_reorder_wmb()		wmb()
224
#else
225
#define war_io_reorder_wmb()		barrier()
226 227
#endif

228
#define __BUILD_MEMORY_SINGLE(pfx, bwlq, type, barrier, relax, irq)	\
L
Linus Torvalds 已提交
229 230 231 232 233 234 235
									\
static inline void pfx##write##bwlq(type val,				\
				    volatile void __iomem *mem)		\
{									\
	volatile type *__mem;						\
	type __val;							\
									\
236 237 238 239
	if (barrier)							\
		iobarrier_rw();						\
	else								\
		war_io_reorder_wmb();					\
240
									\
L
Linus Torvalds 已提交
241 242
	__mem = (void *)__swizzle_addr_##bwlq((unsigned long)(mem));	\
									\
243
	__val = pfx##ioswab##bwlq(__mem, val);				\
L
Linus Torvalds 已提交
244
									\
R
Ralf Baechle 已提交
245
	if (sizeof(type) != sizeof(u64) || sizeof(u64) == sizeof(long)) \
L
Linus Torvalds 已提交
246 247 248 249 250 251 252 253
		*__mem = __val;						\
	else if (cpu_has_64bits) {					\
		unsigned long __flags;					\
		type __tmp;						\
									\
		if (irq)						\
			local_irq_save(__flags);			\
		__asm__ __volatile__(					\
254 255
			".set	push"		"\t\t# __writeq""\n\t"	\
			".set	arch=r4000"			"\n\t"	\
R
Ralf Baechle 已提交
256 257 258
			"dsll32 %L0, %L0, 0"			"\n\t"	\
			"dsrl32 %L0, %L0, 0"			"\n\t"	\
			"dsll32 %M0, %M0, 0"			"\n\t"	\
L
Linus Torvalds 已提交
259 260
			"or	%L0, %L0, %M0"			"\n\t"	\
			"sd	%L0, %2"			"\n\t"	\
261
			".set	pop"				"\n"	\
L
Linus Torvalds 已提交
262
			: "=r" (__tmp)					\
263
			: "0" (__val), "m" (*__mem));			\
L
Linus Torvalds 已提交
264 265 266 267 268 269
		if (irq)						\
			local_irq_restore(__flags);			\
	} else								\
		BUG();							\
}									\
									\
270
static inline type pfx##read##bwlq(const volatile void __iomem *mem)	\
L
Linus Torvalds 已提交
271 272 273 274 275 276
{									\
	volatile type *__mem;						\
	type __val;							\
									\
	__mem = (void *)__swizzle_addr_##bwlq((unsigned long)(mem));	\
									\
277 278 279
	if (barrier)							\
		iobarrier_rw();						\
									\
R
Ralf Baechle 已提交
280
	if (sizeof(type) != sizeof(u64) || sizeof(u64) == sizeof(long)) \
L
Linus Torvalds 已提交
281 282 283 284
		__val = *__mem;						\
	else if (cpu_has_64bits) {					\
		unsigned long __flags;					\
									\
285 286
		if (irq)						\
			local_irq_save(__flags);			\
L
Linus Torvalds 已提交
287
		__asm__ __volatile__(					\
288 289
			".set	push"		"\t\t# __readq" "\n\t"	\
			".set	arch=r4000"			"\n\t"	\
L
Linus Torvalds 已提交
290
			"ld	%L0, %1"			"\n\t"	\
R
Ralf Baechle 已提交
291
			"dsra32 %M0, %L0, 0"			"\n\t"	\
L
Linus Torvalds 已提交
292
			"sll	%L0, %L0, 0"			"\n\t"	\
293
			".set	pop"				"\n"	\
L
Linus Torvalds 已提交
294
			: "=r" (__val)					\
295
			: "m" (*__mem));				\
296 297
		if (irq)						\
			local_irq_restore(__flags);			\
L
Linus Torvalds 已提交
298 299 300 301 302
	} else {							\
		__val = 0;						\
		BUG();							\
	}								\
									\
303
	/* prevent prefetching of coherent DMA data prematurely */	\
304 305
	if (!relax)							\
		rmb();							\
306
	return pfx##ioswab##bwlq(__mem, __val);				\
L
Linus Torvalds 已提交
307 308
}

309
#define __BUILD_IOPORT_SINGLE(pfx, bwlq, type, barrier, relax, p)	\
L
Linus Torvalds 已提交
310 311 312 313 314 315
									\
static inline void pfx##out##bwlq##p(type val, unsigned long port)	\
{									\
	volatile type *__addr;						\
	type __val;							\
									\
316 317 318 319
	if (barrier)							\
		iobarrier_rw();						\
	else								\
		war_io_reorder_wmb();					\
320
									\
321
	__addr = (void *)__swizzle_addr_##bwlq(mips_io_port_base + port); \
L
Linus Torvalds 已提交
322
									\
323
	__val = pfx##ioswab##bwlq(__addr, val);				\
L
Linus Torvalds 已提交
324
									\
325 326 327 328
	/* Really, we want this to be atomic */				\
	BUILD_BUG_ON(sizeof(type) > sizeof(unsigned long));		\
									\
	*__addr = __val;						\
L
Linus Torvalds 已提交
329 330 331 332 333 334 335
}									\
									\
static inline type pfx##in##bwlq##p(unsigned long port)			\
{									\
	volatile type *__addr;						\
	type __val;							\
									\
336
	__addr = (void *)__swizzle_addr_##bwlq(mips_io_port_base + port); \
L
Linus Torvalds 已提交
337
									\
338 339
	BUILD_BUG_ON(sizeof(type) > sizeof(unsigned long));		\
									\
340 341 342
	if (barrier)							\
		iobarrier_rw();						\
									\
343
	__val = *__addr;						\
L
Linus Torvalds 已提交
344
									\
345
	/* prevent prefetching of coherent DMA data prematurely */	\
346 347
	if (!relax)							\
		rmb();							\
348
	return pfx##ioswab##bwlq(__addr, __val);			\
L
Linus Torvalds 已提交
349 350
}

351
#define __BUILD_MEMORY_PFX(bus, bwlq, type, relax)			\
L
Linus Torvalds 已提交
352
									\
353
__BUILD_MEMORY_SINGLE(bus, bwlq, type, 1, relax, 1)
L
Linus Torvalds 已提交
354

355
#define BUILDIO_MEM(bwlq, type)						\
L
Linus Torvalds 已提交
356
									\
357 358 359 360
__BUILD_MEMORY_PFX(__raw_, bwlq, type, 0)				\
__BUILD_MEMORY_PFX(__relaxed_, bwlq, type, 1)				\
__BUILD_MEMORY_PFX(__mem_, bwlq, type, 0)				\
__BUILD_MEMORY_PFX(, bwlq, type, 0)
361 362 363 364

BUILDIO_MEM(b, u8)
BUILDIO_MEM(w, u16)
BUILDIO_MEM(l, u32)
365
#ifdef CONFIG_64BIT
366
BUILDIO_MEM(q, u64)
367 368 369 370
#else
__BUILD_MEMORY_PFX(__raw_, q, u64, 0)
__BUILD_MEMORY_PFX(__mem_, q, u64, 0)
#endif
371 372

#define __BUILD_IOPORT_PFX(bus, bwlq, type)				\
373 374
	__BUILD_IOPORT_SINGLE(bus, bwlq, type, 1, 0,)			\
	__BUILD_IOPORT_SINGLE(bus, bwlq, type, 1, 0, _p)
375 376 377

#define BUILDIO_IOPORT(bwlq, type)					\
	__BUILD_IOPORT_PFX(, bwlq, type)				\
378
	__BUILD_IOPORT_PFX(__mem_, bwlq, type)
379 380 381 382 383 384 385

BUILDIO_IOPORT(b, u8)
BUILDIO_IOPORT(w, u16)
BUILDIO_IOPORT(l, u32)
#ifdef CONFIG_64BIT
BUILDIO_IOPORT(q, u64)
#endif
L
Linus Torvalds 已提交
386 387 388

#define __BUILDIO(bwlq, type)						\
									\
389
__BUILD_MEMORY_SINGLE(____raw_, bwlq, type, 1, 0, 0)
L
Linus Torvalds 已提交
390 391 392

__BUILDIO(q, u64)

393 394 395
#define readb_relaxed			__relaxed_readb
#define readw_relaxed			__relaxed_readw
#define readl_relaxed			__relaxed_readl
396
#ifdef CONFIG_64BIT
397
#define readq_relaxed			__relaxed_readq
398
#endif
L
Linus Torvalds 已提交
399

400 401 402
#define writeb_relaxed			__relaxed_writeb
#define writew_relaxed			__relaxed_writew
#define writel_relaxed			__relaxed_writel
403
#ifdef CONFIG_64BIT
404
#define writeq_relaxed			__relaxed_writeq
405
#endif
406

407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424
#define readb_be(addr)							\
	__raw_readb((__force unsigned *)(addr))
#define readw_be(addr)							\
	be16_to_cpu(__raw_readw((__force unsigned *)(addr)))
#define readl_be(addr)							\
	be32_to_cpu(__raw_readl((__force unsigned *)(addr)))
#define readq_be(addr)							\
	be64_to_cpu(__raw_readq((__force unsigned *)(addr)))

#define writeb_be(val, addr)						\
	__raw_writeb((val), (__force unsigned *)(addr))
#define writew_be(val, addr)						\
	__raw_writew(cpu_to_be16((val)), (__force unsigned *)(addr))
#define writel_be(val, addr)						\
	__raw_writel(cpu_to_be32((val)), (__force unsigned *)(addr))
#define writeq_be(val, addr)						\
	__raw_writeq(cpu_to_be64((val)), (__force unsigned *)(addr))

L
Linus Torvalds 已提交
425 426 427
/*
 * Some code tests for these symbols
 */
428
#ifdef CONFIG_64BIT
L
Linus Torvalds 已提交
429 430
#define readq				readq
#define writeq				writeq
431
#endif
L
Linus Torvalds 已提交
432 433 434

#define __BUILD_MEMORY_STRING(bwlq, type)				\
									\
435 436
static inline void writes##bwlq(volatile void __iomem *mem,		\
				const void *addr, unsigned int count)	\
L
Linus Torvalds 已提交
437
{									\
438
	const volatile type *__addr = addr;				\
L
Linus Torvalds 已提交
439 440
									\
	while (count--) {						\
441
		__mem_write##bwlq(*__addr, mem);			\
L
Linus Torvalds 已提交
442 443 444 445 446 447 448 449 450 451
		__addr++;						\
	}								\
}									\
									\
static inline void reads##bwlq(volatile void __iomem *mem, void *addr,	\
			       unsigned int count)			\
{									\
	volatile type *__addr = addr;					\
									\
	while (count--) {						\
452
		*__addr = __mem_read##bwlq(mem);			\
L
Linus Torvalds 已提交
453 454 455 456 457 458
		__addr++;						\
	}								\
}

#define __BUILD_IOPORT_STRING(bwlq, type)				\
									\
R
Ralf Baechle 已提交
459
static inline void outs##bwlq(unsigned long port, const void *addr,	\
L
Linus Torvalds 已提交
460 461
			      unsigned int count)			\
{									\
R
Ralf Baechle 已提交
462
	const volatile type *__addr = addr;				\
L
Linus Torvalds 已提交
463 464
									\
	while (count--) {						\
465
		__mem_out##bwlq(*__addr, port);				\
L
Linus Torvalds 已提交
466 467 468 469 470 471 472 473 474 475
		__addr++;						\
	}								\
}									\
									\
static inline void ins##bwlq(unsigned long port, void *addr,		\
			     unsigned int count)			\
{									\
	volatile type *__addr = addr;					\
									\
	while (count--) {						\
476
		*__addr = __mem_in##bwlq(port);				\
L
Linus Torvalds 已提交
477 478 479 480 481 482 483 484 485 486 487 488
		__addr++;						\
	}								\
}

#define BUILDSTRING(bwlq, type)						\
									\
__BUILD_MEMORY_STRING(bwlq, type)					\
__BUILD_IOPORT_STRING(bwlq, type)

BUILDSTRING(b, u8)
BUILDSTRING(w, u16)
BUILDSTRING(l, u32)
489
#ifdef CONFIG_64BIT
L
Linus Torvalds 已提交
490
BUILDSTRING(q, u64)
491
#endif
L
Linus Torvalds 已提交
492

R
Ralf Baechle 已提交
493 494 495 496 497 498 499 500 501 502 503 504
static inline void memset_io(volatile void __iomem *addr, unsigned char val, int count)
{
	memset((void __force *) addr, val, count);
}
static inline void memcpy_fromio(void *dst, const volatile void __iomem *src, int count)
{
	memcpy(dst, (void __force *) src, count);
}
static inline void memcpy_toio(volatile void __iomem *dst, const void *src, int count)
{
	memcpy((void __force *) dst, src, count);
}
L
Linus Torvalds 已提交
505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522

/*
 * The caches on some architectures aren't dma-coherent and have need to
 * handle this in software.  There are three types of operations that
 * can be applied to dma buffers.
 *
 *  - dma_cache_wback_inv(start, size) makes caches and coherent by
 *    writing the content of the caches back to memory, if necessary.
 *    The function also invalidates the affected part of the caches as
 *    necessary before DMA transfers from outside to memory.
 *  - dma_cache_wback(start, size) makes caches and coherent by
 *    writing the content of the caches back to memory, if necessary.
 *    The function also invalidates the affected part of the caches as
 *    necessary before DMA transfers from outside to memory.
 *  - dma_cache_inv(start, size) invalidates the affected parts of the
 *    caches.  Dirty lines of the caches may be written back or simply
 *    be discarded.  This operation is necessary before dma operations
 *    to the memory.
523 524
 *
 * This API used to be exported; it now is for arch code internal use only.
L
Linus Torvalds 已提交
525
 */
526
#ifdef CONFIG_DMA_NONCOHERENT
L
Linus Torvalds 已提交
527 528 529 530 531

extern void (*_dma_cache_wback_inv)(unsigned long start, unsigned long size);
extern void (*_dma_cache_wback)(unsigned long start, unsigned long size);
extern void (*_dma_cache_inv)(unsigned long start, unsigned long size);

532 533 534
#define dma_cache_wback_inv(start, size)	_dma_cache_wback_inv(start, size)
#define dma_cache_wback(start, size)		_dma_cache_wback(start, size)
#define dma_cache_inv(start, size)		_dma_cache_inv(start, size)
L
Linus Torvalds 已提交
535 536 537

#else /* Sane hardware */

R
Ralf Baechle 已提交
538
#define dma_cache_wback_inv(start,size) \
L
Linus Torvalds 已提交
539 540 541 542 543 544
	do { (void) (start); (void) (size); } while (0)
#define dma_cache_wback(start,size)	\
	do { (void) (start); (void) (size); } while (0)
#define dma_cache_inv(start,size)	\
	do { (void) (start); (void) (size); } while (0)

545
#endif /* CONFIG_DMA_NONCOHERENT */
L
Linus Torvalds 已提交
546 547 548 549 550 551 552 553 554 555 556 557

/*
 * Read a 32-bit register that requires a 64-bit read cycle on the bus.
 * Avoid interrupt mucking, just adjust the address for 4-byte access.
 * Assume the addresses are 8-byte aligned.
 */
#ifdef __MIPSEB__
#define __CSR_32_ADJUST 4
#else
#define __CSR_32_ADJUST 0
#endif

558
#define csr_out32(v, a) (*(volatile u32 *)((unsigned long)(a) + __CSR_32_ADJUST) = (v))
L
Linus Torvalds 已提交
559 560 561 562 563 564 565 566 567 568 569 570 571
#define csr_in32(a)    (*(volatile u32 *)((unsigned long)(a) + __CSR_32_ADJUST))

/*
 * Convert a physical pointer to a virtual kernel pointer for /dev/mem
 * access
 */
#define xlate_dev_mem_ptr(p)	__va(p)

/*
 * Convert a virtual cached pointer to an uncached pointer
 */
#define xlate_dev_kmem_ptr(p)	p

P
Paul Burton 已提交
572 573
void __ioread64_copy(void *to, const void __iomem *from, size_t count);

L
Linus Torvalds 已提交
574
#endif /* _ASM_IO_H */