aboutsummaryrefslogtreecommitdiffstats
path: root/include/asm-mips/io.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/asm-mips/io.h')
-rw-r--r--include/asm-mips/io.h71
1 files changed, 50 insertions, 21 deletions
diff --git a/include/asm-mips/io.h b/include/asm-mips/io.h
index d42685747e7d..ba1d7bbc15d2 100644
--- a/include/asm-mips/io.h
+++ b/include/asm-mips/io.h
@@ -4,7 +4,7 @@
4 * for more details. 4 * for more details.
5 * 5 *
6 * Copyright (C) 1994, 1995 Waldorf GmbH 6 * Copyright (C) 1994, 1995 Waldorf GmbH
7 * Copyright (C) 1994 - 2000 Ralf Baechle 7 * Copyright (C) 1994 - 2000, 06 Ralf Baechle
8 * Copyright (C) 1999, 2000 Silicon Graphics, Inc. 8 * Copyright (C) 1999, 2000 Silicon Graphics, Inc.
9 * Copyright (C) 2004, 2005 MIPS Technologies, Inc. All rights reserved. 9 * Copyright (C) 2004, 2005 MIPS Technologies, Inc. All rights reserved.
10 * Author: Maciej W. Rozycki <macro@mips.com> 10 * Author: Maciej W. Rozycki <macro@mips.com>
@@ -18,7 +18,6 @@
18#include <linux/types.h> 18#include <linux/types.h>
19 19
20#include <asm/addrspace.h> 20#include <asm/addrspace.h>
21#include <asm/bug.h>
22#include <asm/byteorder.h> 21#include <asm/byteorder.h>
23#include <asm/cpu.h> 22#include <asm/cpu.h>
24#include <asm/cpu-features.h> 23#include <asm/cpu-features.h>
@@ -57,38 +56,38 @@
57 * variations of functions: non-prefixed ones that preserve the value 56 * variations of functions: non-prefixed ones that preserve the value
58 * and prefixed ones that preserve byte addresses. The latters are 57 * and prefixed ones that preserve byte addresses. The latters are
59 * typically used for moving raw data between a peripheral and memory (cf. 58 * typically used for moving raw data between a peripheral and memory (cf.
60 * string I/O functions), hence the "mem_" prefix. 59 * string I/O functions), hence the "__mem_" prefix.
61 */ 60 */
62#if defined(CONFIG_SWAP_IO_SPACE) 61#if defined(CONFIG_SWAP_IO_SPACE)
63 62
64# define ioswabb(x) (x) 63# define ioswabb(x) (x)
65# define mem_ioswabb(x) (x) 64# define __mem_ioswabb(x) (x)
66# ifdef CONFIG_SGI_IP22 65# ifdef CONFIG_SGI_IP22
67/* 66/*
68 * IP22 seems braindead enough to swap 16bits values in hardware, but 67 * IP22 seems braindead enough to swap 16bits values in hardware, but
69 * not 32bits. Go figure... Can't tell without documentation. 68 * not 32bits. Go figure... Can't tell without documentation.
70 */ 69 */
71# define ioswabw(x) (x) 70# define ioswabw(x) (x)
72# define mem_ioswabw(x) le16_to_cpu(x) 71# define __mem_ioswabw(x) le16_to_cpu(x)
73# else 72# else
74# define ioswabw(x) le16_to_cpu(x) 73# define ioswabw(x) le16_to_cpu(x)
75# define mem_ioswabw(x) (x) 74# define __mem_ioswabw(x) (x)
76# endif 75# endif
77# define ioswabl(x) le32_to_cpu(x) 76# define ioswabl(x) le32_to_cpu(x)
78# define mem_ioswabl(x) (x) 77# define __mem_ioswabl(x) (x)
79# define ioswabq(x) le64_to_cpu(x) 78# define ioswabq(x) le64_to_cpu(x)
80# define mem_ioswabq(x) (x) 79# define __mem_ioswabq(x) (x)
81 80
82#else 81#else
83 82
84# define ioswabb(x) (x) 83# define ioswabb(x) (x)
85# define mem_ioswabb(x) (x) 84# define __mem_ioswabb(x) (x)
86# define ioswabw(x) (x) 85# define ioswabw(x) (x)
87# define mem_ioswabw(x) cpu_to_le16(x) 86# define __mem_ioswabw(x) cpu_to_le16(x)
88# define ioswabl(x) (x) 87# define ioswabl(x) (x)
89# define mem_ioswabl(x) cpu_to_le32(x) 88# define __mem_ioswabl(x) cpu_to_le32(x)
90# define ioswabq(x) (x) 89# define ioswabq(x) (x)
91# define mem_ioswabq(x) cpu_to_le32(x) 90# define __mem_ioswabq(x) cpu_to_le32(x)
92 91
93#endif 92#endif
94 93
@@ -104,8 +103,20 @@
104 */ 103 */
105extern const unsigned long mips_io_port_base; 104extern const unsigned long mips_io_port_base;
106 105
107#define set_io_port_base(base) \ 106/*
108 do { * (unsigned long *) &mips_io_port_base = (base); } while (0) 107 * Gcc will generate code to load the value of mips_io_port_base after each
108 * function call which may be fairly wasteful in some cases. So we don't
109 * play quite by the book. We tell gcc mips_io_port_base is a long variable
110 * which solves the code generation issue. Now we need to violate the
111 * aliasing rules a little to make initialization possible and finally we
112 * will need the barrier() to fight side effects of the aliasing chat.
113 * This trickery will eventually collapse under gcc's optimizer. Oh well.
114 */
115static inline void set_io_port_base(unsigned long base)
116{
117 * (unsigned long *) &mips_io_port_base = base;
118 barrier();
119}
109 120
110/* 121/*
111 * Thanks to James van Artsdalen for a better timing-fix than 122 * Thanks to James van Artsdalen for a better timing-fix than
@@ -284,6 +295,24 @@ static inline void __iomem * __ioremap_mode(phys_t offset, unsigned long size,
284 __ioremap_mode((offset), (size), _CACHE_UNCACHED) 295 __ioremap_mode((offset), (size), _CACHE_UNCACHED)
285 296
286/* 297/*
298 * ioremap_cachable - map bus memory into CPU space
299 * @offset: bus address of the memory
300 * @size: size of the resource to map
301 *
302 * ioremap_nocache performs a platform specific sequence of operations to
303 * make bus memory CPU accessible via the readb/readw/readl/writeb/
304 * writew/writel functions and the other mmio helpers. The returned
305 * address is not guaranteed to be usable directly as a virtual
306 * address.
307 *
308 * This version of ioremap ensures that the memory is marked cachable by
309 * the CPU. Also enables full write-combining. Useful for some
310 * memory-like regions on I/O busses.
311 */
312#define ioremap_cachable(offset, size) \
313 __ioremap_mode((offset), (size), PAGE_CACHABLE_DEFAULT)
314
315/*
287 * These two are MIPS specific ioremap variant. ioremap_cacheable_cow 316 * These two are MIPS specific ioremap variant. ioremap_cacheable_cow
288 * requests a cachable mapping, ioremap_uncached_accelerated requests a 317 * requests a cachable mapping, ioremap_uncached_accelerated requests a
289 * mapping using the uncached accelerated mode which isn't supported on 318 * mapping using the uncached accelerated mode which isn't supported on
@@ -343,7 +372,7 @@ static inline void pfx##write##bwlq(type val, \
343 BUG(); \ 372 BUG(); \
344} \ 373} \
345 \ 374 \
346static inline type pfx##read##bwlq(volatile void __iomem *mem) \ 375static inline type pfx##read##bwlq(const volatile void __iomem *mem) \
347{ \ 376{ \
348 volatile type *__mem; \ 377 volatile type *__mem; \
349 type __val; \ 378 type __val; \
@@ -418,7 +447,7 @@ __BUILD_MEMORY_SINGLE(bus, bwlq, type, 1)
418 \ 447 \
419__BUILD_MEMORY_PFX(__raw_, bwlq, type) \ 448__BUILD_MEMORY_PFX(__raw_, bwlq, type) \
420__BUILD_MEMORY_PFX(, bwlq, type) \ 449__BUILD_MEMORY_PFX(, bwlq, type) \
421__BUILD_MEMORY_PFX(mem_, bwlq, type) \ 450__BUILD_MEMORY_PFX(__mem_, bwlq, type) \
422 451
423BUILDIO_MEM(b, u8) 452BUILDIO_MEM(b, u8)
424BUILDIO_MEM(w, u16) 453BUILDIO_MEM(w, u16)
@@ -431,7 +460,7 @@ BUILDIO_MEM(q, u64)
431 460
432#define BUILDIO_IOPORT(bwlq, type) \ 461#define BUILDIO_IOPORT(bwlq, type) \
433 __BUILD_IOPORT_PFX(, bwlq, type) \ 462 __BUILD_IOPORT_PFX(, bwlq, type) \
434 __BUILD_IOPORT_PFX(mem_, bwlq, type) 463 __BUILD_IOPORT_PFX(__mem_, bwlq, type)
435 464
436BUILDIO_IOPORT(b, u8) 465BUILDIO_IOPORT(b, u8)
437BUILDIO_IOPORT(w, u16) 466BUILDIO_IOPORT(w, u16)
@@ -465,7 +494,7 @@ static inline void writes##bwlq(volatile void __iomem *mem, \
465 const volatile type *__addr = addr; \ 494 const volatile type *__addr = addr; \
466 \ 495 \
467 while (count--) { \ 496 while (count--) { \
468 mem_write##bwlq(*__addr, mem); \ 497 __mem_write##bwlq(*__addr, mem); \
469 __addr++; \ 498 __addr++; \
470 } \ 499 } \
471} \ 500} \
@@ -476,7 +505,7 @@ static inline void reads##bwlq(volatile void __iomem *mem, void *addr, \
476 volatile type *__addr = addr; \ 505 volatile type *__addr = addr; \
477 \ 506 \
478 while (count--) { \ 507 while (count--) { \
479 *__addr = mem_read##bwlq(mem); \ 508 *__addr = __mem_read##bwlq(mem); \
480 __addr++; \ 509 __addr++; \
481 } \ 510 } \
482} 511}
@@ -489,7 +518,7 @@ static inline void outs##bwlq(unsigned long port, const void *addr, \
489 const volatile type *__addr = addr; \ 518 const volatile type *__addr = addr; \
490 \ 519 \
491 while (count--) { \ 520 while (count--) { \
492 mem_out##bwlq(*__addr, port); \ 521 __mem_out##bwlq(*__addr, port); \
493 __addr++; \ 522 __addr++; \
494 } \ 523 } \
495} \ 524} \
@@ -500,7 +529,7 @@ static inline void ins##bwlq(unsigned long port, void *addr, \
500 volatile type *__addr = addr; \ 529 volatile type *__addr = addr; \
501 \ 530 \
502 while (count--) { \ 531 while (count--) { \
503 *__addr = mem_in##bwlq(port); \ 532 *__addr = __mem_in##bwlq(port); \
504 __addr++; \ 533 __addr++; \
505 } \ 534 } \
506} 535}