io.h 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644
  1. /*
  2. * This file is subject to the terms and conditions of the GNU General Public
  3. * License. See the file "COPYING" in the main directory of this archive
  4. * for more details.
  5. *
  6. * Copyright (C) 1994, 1995 Waldorf GmbH
  7. * Copyright (C) 1994 - 2000, 06 Ralf Baechle
  8. * Copyright (C) 1999, 2000 Silicon Graphics, Inc.
  9. * Copyright (C) 2004, 2005 MIPS Technologies, Inc. All rights reserved.
  10. * Author: Maciej W. Rozycki <macro@mips.com>
  11. */
  12. #ifndef _ASM_IO_H
  13. #define _ASM_IO_H
  14. #define ARCH_HAS_IOREMAP_WC
  15. #include <linux/compiler.h>
  16. #include <linux/kernel.h>
  17. #include <linux/types.h>
  18. #include <linux/irqflags.h>
  19. #include <asm/addrspace.h>
  20. #include <asm/bug.h>
  21. #include <asm/byteorder.h>
  22. #include <asm/cpu.h>
  23. #include <asm/cpu-features.h>
  24. #include <asm-generic/iomap.h>
  25. #include <asm/page.h>
  26. #include <asm/pgtable-bits.h>
  27. #include <asm/processor.h>
  28. #include <asm/string.h>
  29. #include <ioremap.h>
  30. #include <mangle-port.h>
  31. /*
  32. * Slowdown I/O port space accesses for antique hardware.
  33. */
  34. #undef CONF_SLOWDOWN_IO
  35. /*
  36. * Raw operations are never swapped in software. OTOH values that raw
  37. * operations are working on may or may not have been swapped by the bus
  38. * hardware. An example use would be for flash memory that's used for
  39. * execute in place.
  40. */
  41. # define __raw_ioswabb(a, x) (x)
  42. # define __raw_ioswabw(a, x) (x)
  43. # define __raw_ioswabl(a, x) (x)
  44. # define __raw_ioswabq(a, x) (x)
  45. # define ____raw_ioswabq(a, x) (x)
  46. /* ioswab[bwlq], __mem_ioswab[bwlq] are defined in mangle-port.h */
  47. #define IO_SPACE_LIMIT 0xffff
  48. /*
  49. * On MIPS I/O ports are memory mapped, so we access them using normal
  50. * load/store instructions. mips_io_port_base is the virtual address to
  51. * which all ports are being mapped. For sake of efficiency some code
  52. * assumes that this is an address that can be loaded with a single lui
  53. * instruction, so the lower 16 bits must be zero. Should be true on
  54. * on any sane architecture; generic code does not use this assumption.
  55. */
  56. extern unsigned long mips_io_port_base;
  57. static inline void set_io_port_base(unsigned long base)
  58. {
  59. mips_io_port_base = base;
  60. }
  61. /*
  62. * Thanks to James van Artsdalen for a better timing-fix than
  63. * the two short jumps: using outb's to a nonexistent port seems
  64. * to guarantee better timings even on fast machines.
  65. *
  66. * On the other hand, I'd like to be sure of a non-existent port:
  67. * I feel a bit unsafe about using 0x80 (should be safe, though)
  68. *
  69. * Linus
  70. *
  71. */
  72. #define __SLOW_DOWN_IO \
  73. __asm__ __volatile__( \
  74. "sb\t$0,0x80(%0)" \
  75. : : "r" (mips_io_port_base));
  76. #ifdef CONF_SLOWDOWN_IO
  77. #ifdef REALLY_SLOW_IO
  78. #define SLOW_DOWN_IO { __SLOW_DOWN_IO; __SLOW_DOWN_IO; __SLOW_DOWN_IO; __SLOW_DOWN_IO; }
  79. #else
  80. #define SLOW_DOWN_IO __SLOW_DOWN_IO
  81. #endif
  82. #else
  83. #define SLOW_DOWN_IO
  84. #endif
  85. /*
  86. * virt_to_phys - map virtual addresses to physical
  87. * @address: address to remap
  88. *
  89. * The returned physical address is the physical (CPU) mapping for
  90. * the memory address given. It is only valid to use this function on
  91. * addresses directly mapped or allocated via kmalloc.
  92. *
  93. * This function does not give bus mappings for DMA transfers. In
  94. * almost all conceivable cases a device driver should not be using
  95. * this function
  96. */
  97. static inline unsigned long virt_to_phys(volatile const void *address)
  98. {
  99. return __pa(address);
  100. }
  101. /*
  102. * phys_to_virt - map physical address to virtual
  103. * @address: address to remap
  104. *
  105. * The returned virtual address is a current CPU mapping for
  106. * the memory address given. It is only valid to use this function on
  107. * addresses that have a kernel mapping
  108. *
  109. * This function does not handle bus mappings for DMA transfers. In
  110. * almost all conceivable cases a device driver should not be using
  111. * this function
  112. */
  113. static inline void * phys_to_virt(unsigned long address)
  114. {
  115. return (void *)(address + PAGE_OFFSET - PHYS_OFFSET);
  116. }
  117. /*
  118. * ISA I/O bus memory addresses are 1:1 with the physical address.
  119. */
  120. static inline unsigned long isa_virt_to_bus(volatile void *address)
  121. {
  122. return virt_to_phys(address);
  123. }
  124. static inline void *isa_bus_to_virt(unsigned long address)
  125. {
  126. return phys_to_virt(address);
  127. }
  128. #define isa_page_to_bus page_to_phys
  129. /*
  130. * However PCI ones are not necessarily 1:1 and therefore these interfaces
  131. * are forbidden in portable PCI drivers.
  132. *
  133. * Allow them for x86 for legacy drivers, though.
  134. */
  135. #define virt_to_bus virt_to_phys
  136. #define bus_to_virt phys_to_virt
  137. /*
  138. * Change "struct page" to physical address.
  139. */
  140. #define page_to_phys(page) ((dma_addr_t)page_to_pfn(page) << PAGE_SHIFT)
  141. extern void __iomem * __ioremap(phys_addr_t offset, phys_addr_t size, unsigned long flags);
  142. extern void __iounmap(const volatile void __iomem *addr);
  143. #ifndef CONFIG_PCI
  144. struct pci_dev;
  145. static inline void pci_iounmap(struct pci_dev *dev, void __iomem *addr) {}
  146. #endif
  147. static inline void __iomem * __ioremap_mode(phys_addr_t offset, unsigned long size,
  148. unsigned long flags)
  149. {
  150. void __iomem *addr = plat_ioremap(offset, size, flags);
  151. if (addr)
  152. return addr;
  153. #define __IS_LOW512(addr) (!((phys_addr_t)(addr) & (phys_addr_t) ~0x1fffffffULL))
  154. if (cpu_has_64bit_addresses) {
  155. u64 base = UNCAC_BASE;
  156. /*
  157. * R10000 supports a 2 bit uncached attribute therefore
  158. * UNCAC_BASE may not equal IO_BASE.
  159. */
  160. if (flags == _CACHE_UNCACHED)
  161. base = (u64) IO_BASE;
  162. return (void __iomem *) (unsigned long) (base + offset);
  163. } else if (__builtin_constant_p(offset) &&
  164. __builtin_constant_p(size) && __builtin_constant_p(flags)) {
  165. phys_addr_t phys_addr, last_addr;
  166. phys_addr = fixup_bigphys_addr(offset, size);
  167. /* Don't allow wraparound or zero size. */
  168. last_addr = phys_addr + size - 1;
  169. if (!size || last_addr < phys_addr)
  170. return NULL;
  171. /*
  172. * Map uncached objects in the low 512MB of address
  173. * space using KSEG1.
  174. */
  175. if (__IS_LOW512(phys_addr) && __IS_LOW512(last_addr) &&
  176. flags == _CACHE_UNCACHED)
  177. return (void __iomem *)
  178. (unsigned long)CKSEG1ADDR(phys_addr);
  179. }
  180. return __ioremap(offset, size, flags);
  181. #undef __IS_LOW512
  182. }
  183. /*
  184. * ioremap - map bus memory into CPU space
  185. * @offset: bus address of the memory
  186. * @size: size of the resource to map
  187. *
  188. * ioremap performs a platform specific sequence of operations to
  189. * make bus memory CPU accessible via the readb/readw/readl/writeb/
  190. * writew/writel functions and the other mmio helpers. The returned
  191. * address is not guaranteed to be usable directly as a virtual
  192. * address.
  193. */
  194. #define ioremap(offset, size) \
  195. __ioremap_mode((offset), (size), _CACHE_UNCACHED)
  196. /*
  197. * ioremap_nocache - map bus memory into CPU space
  198. * @offset: bus address of the memory
  199. * @size: size of the resource to map
  200. *
  201. * ioremap_nocache performs a platform specific sequence of operations to
  202. * make bus memory CPU accessible via the readb/readw/readl/writeb/
  203. * writew/writel functions and the other mmio helpers. The returned
  204. * address is not guaranteed to be usable directly as a virtual
  205. * address.
  206. *
  207. * This version of ioremap ensures that the memory is marked uncachable
  208. * on the CPU as well as honouring existing caching rules from things like
  209. * the PCI bus. Note that there are other caches and buffers on many
  210. * busses. In particular driver authors should read up on PCI writes
  211. *
  212. * It's useful if some control registers are in such an area and
  213. * write combining or read caching is not desirable:
  214. */
  215. #define ioremap_nocache(offset, size) \
  216. __ioremap_mode((offset), (size), _CACHE_UNCACHED)
  217. #define ioremap_uc ioremap_nocache
  218. /*
  219. * ioremap_cachable - map bus memory into CPU space
  220. * @offset: bus address of the memory
  221. * @size: size of the resource to map
  222. *
  223. * ioremap_nocache performs a platform specific sequence of operations to
  224. * make bus memory CPU accessible via the readb/readw/readl/writeb/
  225. * writew/writel functions and the other mmio helpers. The returned
  226. * address is not guaranteed to be usable directly as a virtual
  227. * address.
  228. *
  229. * This version of ioremap ensures that the memory is marked cachable by
  230. * the CPU. Also enables full write-combining. Useful for some
  231. * memory-like regions on I/O busses.
  232. */
  233. #define ioremap_cachable(offset, size) \
  234. __ioremap_mode((offset), (size), _page_cachable_default)
  235. #define ioremap_cache ioremap_cachable
  236. /*
  237. * ioremap_wc - map bus memory into CPU space
  238. * @offset: bus address of the memory
  239. * @size: size of the resource to map
  240. *
  241. * ioremap_wc performs a platform specific sequence of operations to
  242. * make bus memory CPU accessible via the readb/readw/readl/writeb/
  243. * writew/writel functions and the other mmio helpers. The returned
  244. * address is not guaranteed to be usable directly as a virtual
  245. * address.
  246. *
  247. * This version of ioremap ensures that the memory is marked uncachable
  248. * but accelerated by means of write-combining feature. It is specifically
  249. * useful for PCIe prefetchable windows, which may vastly improve a
  250. * communications performance. If it was determined on boot stage, what
  251. * CPU CCA doesn't support UCA, the method shall fall-back to the
  252. * _CACHE_UNCACHED option (see cpu_probe() method).
  253. */
  254. #define ioremap_wc(offset, size) \
  255. __ioremap_mode((offset), (size), boot_cpu_data.writecombine)
  256. static inline void iounmap(const volatile void __iomem *addr)
  257. {
  258. if (plat_iounmap(addr))
  259. return;
  260. #define __IS_KSEG1(addr) (((unsigned long)(addr) & ~0x1fffffffUL) == CKSEG1)
  261. if (cpu_has_64bit_addresses ||
  262. (__builtin_constant_p(addr) && __IS_KSEG1(addr)))
  263. return;
  264. __iounmap(addr);
  265. #undef __IS_KSEG1
  266. }
  267. #if defined(CONFIG_CPU_CAVIUM_OCTEON) || defined(CONFIG_LOONGSON3_ENHANCEMENT)
  268. #define war_io_reorder_wmb() wmb()
  269. #else
  270. #define war_io_reorder_wmb() barrier()
  271. #endif
  272. #define __BUILD_MEMORY_SINGLE(pfx, bwlq, type, irq) \
  273. \
  274. static inline void pfx##write##bwlq(type val, \
  275. volatile void __iomem *mem) \
  276. { \
  277. volatile type *__mem; \
  278. type __val; \
  279. \
  280. war_io_reorder_wmb(); \
  281. \
  282. __mem = (void *)__swizzle_addr_##bwlq((unsigned long)(mem)); \
  283. \
  284. __val = pfx##ioswab##bwlq(__mem, val); \
  285. \
  286. if (sizeof(type) != sizeof(u64) || sizeof(u64) == sizeof(long)) \
  287. *__mem = __val; \
  288. else if (cpu_has_64bits) { \
  289. unsigned long __flags; \
  290. type __tmp; \
  291. \
  292. if (irq) \
  293. local_irq_save(__flags); \
  294. __asm__ __volatile__( \
  295. ".set arch=r4000" "\t\t# __writeq""\n\t" \
  296. "dsll32 %L0, %L0, 0" "\n\t" \
  297. "dsrl32 %L0, %L0, 0" "\n\t" \
  298. "dsll32 %M0, %M0, 0" "\n\t" \
  299. "or %L0, %L0, %M0" "\n\t" \
  300. "sd %L0, %2" "\n\t" \
  301. ".set mips0" "\n" \
  302. : "=r" (__tmp) \
  303. : "0" (__val), "m" (*__mem)); \
  304. if (irq) \
  305. local_irq_restore(__flags); \
  306. } else \
  307. BUG(); \
  308. } \
  309. \
  310. static inline type pfx##read##bwlq(const volatile void __iomem *mem) \
  311. { \
  312. volatile type *__mem; \
  313. type __val; \
  314. \
  315. __mem = (void *)__swizzle_addr_##bwlq((unsigned long)(mem)); \
  316. \
  317. if (sizeof(type) != sizeof(u64) || sizeof(u64) == sizeof(long)) \
  318. __val = *__mem; \
  319. else if (cpu_has_64bits) { \
  320. unsigned long __flags; \
  321. \
  322. if (irq) \
  323. local_irq_save(__flags); \
  324. __asm__ __volatile__( \
  325. ".set arch=r4000" "\t\t# __readq" "\n\t" \
  326. "ld %L0, %1" "\n\t" \
  327. "dsra32 %M0, %L0, 0" "\n\t" \
  328. "sll %L0, %L0, 0" "\n\t" \
  329. ".set mips0" "\n" \
  330. : "=r" (__val) \
  331. : "m" (*__mem)); \
  332. if (irq) \
  333. local_irq_restore(__flags); \
  334. } else { \
  335. __val = 0; \
  336. BUG(); \
  337. } \
  338. \
  339. /* prevent prefetching of coherent DMA data prematurely */ \
  340. rmb(); \
  341. return pfx##ioswab##bwlq(__mem, __val); \
  342. }
  343. #define __BUILD_IOPORT_SINGLE(pfx, bwlq, type, p, slow) \
  344. \
  345. static inline void pfx##out##bwlq##p(type val, unsigned long port) \
  346. { \
  347. volatile type *__addr; \
  348. type __val; \
  349. \
  350. war_io_reorder_wmb(); \
  351. \
  352. __addr = (void *)__swizzle_addr_##bwlq(mips_io_port_base + port); \
  353. \
  354. __val = pfx##ioswab##bwlq(__addr, val); \
  355. \
  356. /* Really, we want this to be atomic */ \
  357. BUILD_BUG_ON(sizeof(type) > sizeof(unsigned long)); \
  358. \
  359. *__addr = __val; \
  360. slow; \
  361. } \
  362. \
  363. static inline type pfx##in##bwlq##p(unsigned long port) \
  364. { \
  365. volatile type *__addr; \
  366. type __val; \
  367. \
  368. __addr = (void *)__swizzle_addr_##bwlq(mips_io_port_base + port); \
  369. \
  370. BUILD_BUG_ON(sizeof(type) > sizeof(unsigned long)); \
  371. \
  372. __val = *__addr; \
  373. slow; \
  374. \
  375. /* prevent prefetching of coherent DMA data prematurely */ \
  376. rmb(); \
  377. return pfx##ioswab##bwlq(__addr, __val); \
  378. }
  379. #define __BUILD_MEMORY_PFX(bus, bwlq, type) \
  380. \
  381. __BUILD_MEMORY_SINGLE(bus, bwlq, type, 1)
  382. #define BUILDIO_MEM(bwlq, type) \
  383. \
  384. __BUILD_MEMORY_PFX(__raw_, bwlq, type) \
  385. __BUILD_MEMORY_PFX(, bwlq, type) \
  386. __BUILD_MEMORY_PFX(__mem_, bwlq, type) \
  387. BUILDIO_MEM(b, u8)
  388. BUILDIO_MEM(w, u16)
  389. BUILDIO_MEM(l, u32)
  390. BUILDIO_MEM(q, u64)
  391. #define __BUILD_IOPORT_PFX(bus, bwlq, type) \
  392. __BUILD_IOPORT_SINGLE(bus, bwlq, type, ,) \
  393. __BUILD_IOPORT_SINGLE(bus, bwlq, type, _p, SLOW_DOWN_IO)
  394. #define BUILDIO_IOPORT(bwlq, type) \
  395. __BUILD_IOPORT_PFX(, bwlq, type) \
  396. __BUILD_IOPORT_PFX(__mem_, bwlq, type)
  397. BUILDIO_IOPORT(b, u8)
  398. BUILDIO_IOPORT(w, u16)
  399. BUILDIO_IOPORT(l, u32)
  400. #ifdef CONFIG_64BIT
  401. BUILDIO_IOPORT(q, u64)
  402. #endif
  403. #define __BUILDIO(bwlq, type) \
  404. \
  405. __BUILD_MEMORY_SINGLE(____raw_, bwlq, type, 0)
  406. __BUILDIO(q, u64)
  407. #define readb_relaxed readb
  408. #define readw_relaxed readw
  409. #define readl_relaxed readl
  410. #define readq_relaxed readq
  411. #define writeb_relaxed writeb
  412. #define writew_relaxed writew
  413. #define writel_relaxed writel
  414. #define writeq_relaxed writeq
  415. #define readb_be(addr) \
  416. __raw_readb((__force unsigned *)(addr))
  417. #define readw_be(addr) \
  418. be16_to_cpu(__raw_readw((__force unsigned *)(addr)))
  419. #define readl_be(addr) \
  420. be32_to_cpu(__raw_readl((__force unsigned *)(addr)))
  421. #define readq_be(addr) \
  422. be64_to_cpu(__raw_readq((__force unsigned *)(addr)))
  423. #define writeb_be(val, addr) \
  424. __raw_writeb((val), (__force unsigned *)(addr))
  425. #define writew_be(val, addr) \
  426. __raw_writew(cpu_to_be16((val)), (__force unsigned *)(addr))
  427. #define writel_be(val, addr) \
  428. __raw_writel(cpu_to_be32((val)), (__force unsigned *)(addr))
  429. #define writeq_be(val, addr) \
  430. __raw_writeq(cpu_to_be64((val)), (__force unsigned *)(addr))
  431. /*
  432. * Some code tests for these symbols
  433. */
  434. #define readq readq
  435. #define writeq writeq
  436. #define __BUILD_MEMORY_STRING(bwlq, type) \
  437. \
  438. static inline void writes##bwlq(volatile void __iomem *mem, \
  439. const void *addr, unsigned int count) \
  440. { \
  441. const volatile type *__addr = addr; \
  442. \
  443. while (count--) { \
  444. __mem_write##bwlq(*__addr, mem); \
  445. __addr++; \
  446. } \
  447. } \
  448. \
  449. static inline void reads##bwlq(volatile void __iomem *mem, void *addr, \
  450. unsigned int count) \
  451. { \
  452. volatile type *__addr = addr; \
  453. \
  454. while (count--) { \
  455. *__addr = __mem_read##bwlq(mem); \
  456. __addr++; \
  457. } \
  458. }
  459. #define __BUILD_IOPORT_STRING(bwlq, type) \
  460. \
  461. static inline void outs##bwlq(unsigned long port, const void *addr, \
  462. unsigned int count) \
  463. { \
  464. const volatile type *__addr = addr; \
  465. \
  466. while (count--) { \
  467. __mem_out##bwlq(*__addr, port); \
  468. __addr++; \
  469. } \
  470. } \
  471. \
  472. static inline void ins##bwlq(unsigned long port, void *addr, \
  473. unsigned int count) \
  474. { \
  475. volatile type *__addr = addr; \
  476. \
  477. while (count--) { \
  478. *__addr = __mem_in##bwlq(port); \
  479. __addr++; \
  480. } \
  481. }
  482. #define BUILDSTRING(bwlq, type) \
  483. \
  484. __BUILD_MEMORY_STRING(bwlq, type) \
  485. __BUILD_IOPORT_STRING(bwlq, type)
  486. BUILDSTRING(b, u8)
  487. BUILDSTRING(w, u16)
  488. BUILDSTRING(l, u32)
  489. #ifdef CONFIG_64BIT
  490. BUILDSTRING(q, u64)
  491. #endif
  492. #ifdef CONFIG_CPU_CAVIUM_OCTEON
  493. #define mmiowb() wmb()
  494. #else
  495. /* Depends on MIPS II instruction set */
  496. #define mmiowb() asm volatile ("sync" ::: "memory")
  497. #endif
  498. static inline void memset_io(volatile void __iomem *addr, unsigned char val, int count)
  499. {
  500. memset((void __force *) addr, val, count);
  501. }
  502. static inline void memcpy_fromio(void *dst, const volatile void __iomem *src, int count)
  503. {
  504. memcpy(dst, (void __force *) src, count);
  505. }
  506. static inline void memcpy_toio(volatile void __iomem *dst, const void *src, int count)
  507. {
  508. memcpy((void __force *) dst, src, count);
  509. }
  510. /*
  511. * The caches on some architectures aren't dma-coherent and have need to
  512. * handle this in software. There are three types of operations that
  513. * can be applied to dma buffers.
  514. *
  515. * - dma_cache_wback_inv(start, size) makes caches and coherent by
  516. * writing the content of the caches back to memory, if necessary.
  517. * The function also invalidates the affected part of the caches as
  518. * necessary before DMA transfers from outside to memory.
  519. * - dma_cache_wback(start, size) makes caches and coherent by
  520. * writing the content of the caches back to memory, if necessary.
  521. * The function also invalidates the affected part of the caches as
  522. * necessary before DMA transfers from outside to memory.
  523. * - dma_cache_inv(start, size) invalidates the affected parts of the
  524. * caches. Dirty lines of the caches may be written back or simply
  525. * be discarded. This operation is necessary before dma operations
  526. * to the memory.
  527. *
  528. * This API used to be exported; it now is for arch code internal use only.
  529. */
  530. #ifdef CONFIG_DMA_NONCOHERENT
  531. extern void (*_dma_cache_wback_inv)(unsigned long start, unsigned long size);
  532. extern void (*_dma_cache_wback)(unsigned long start, unsigned long size);
  533. extern void (*_dma_cache_inv)(unsigned long start, unsigned long size);
  534. #define dma_cache_wback_inv(start, size) _dma_cache_wback_inv(start, size)
  535. #define dma_cache_wback(start, size) _dma_cache_wback(start, size)
  536. #define dma_cache_inv(start, size) _dma_cache_inv(start, size)
  537. #else /* Sane hardware */
  538. #define dma_cache_wback_inv(start,size) \
  539. do { (void) (start); (void) (size); } while (0)
  540. #define dma_cache_wback(start,size) \
  541. do { (void) (start); (void) (size); } while (0)
  542. #define dma_cache_inv(start,size) \
  543. do { (void) (start); (void) (size); } while (0)
  544. #endif /* CONFIG_DMA_NONCOHERENT */
  545. /*
  546. * Read a 32-bit register that requires a 64-bit read cycle on the bus.
  547. * Avoid interrupt mucking, just adjust the address for 4-byte access.
  548. * Assume the addresses are 8-byte aligned.
  549. */
  550. #ifdef __MIPSEB__
  551. #define __CSR_32_ADJUST 4
  552. #else
  553. #define __CSR_32_ADJUST 0
  554. #endif
  555. #define csr_out32(v, a) (*(volatile u32 *)((unsigned long)(a) + __CSR_32_ADJUST) = (v))
  556. #define csr_in32(a) (*(volatile u32 *)((unsigned long)(a) + __CSR_32_ADJUST))
  557. /*
  558. * Convert a physical pointer to a virtual kernel pointer for /dev/mem
  559. * access
  560. */
  561. #define xlate_dev_mem_ptr(p) __va(p)
  562. /*
  563. * Convert a virtual cached pointer to an uncached pointer
  564. */
  565. #define xlate_dev_kmem_ptr(p) p
  566. void __ioread64_copy(void *to, const void __iomem *from, size_t count);
  567. #endif /* _ASM_IO_H */