io.h 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630
  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 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. #include <linux/config.h>
  15. #include <linux/compiler.h>
  16. #include <linux/kernel.h>
  17. #include <linux/types.h>
  18. #include <asm/addrspace.h>
  19. #include <asm/bug.h>
  20. #include <asm/byteorder.h>
  21. #include <asm/cpu.h>
  22. #include <asm/cpu-features.h>
  23. #include <asm/page.h>
  24. #include <asm/pgtable-bits.h>
  25. #include <asm/processor.h>
  26. #include <mangle-port.h>
  27. /*
  28. * Slowdown I/O port space accesses for antique hardware.
  29. */
  30. #undef CONF_SLOWDOWN_IO
  31. /*
  32. * Raw operations are never swapped in software. Otoh values that raw
  33. * operations are working on may or may not have been swapped by the bus
  34. * hardware. An example use would be for flash memory that's used for
  35. * execute in place.
  36. */
  37. # define __raw_ioswabb(x) (x)
  38. # define __raw_ioswabw(x) (x)
  39. # define __raw_ioswabl(x) (x)
  40. # define __raw_ioswabq(x) (x)
  41. /*
  42. * Sane hardware offers swapping of PCI/ISA I/O space accesses in hardware;
  43. * less sane hardware forces software to fiddle with this...
  44. */
  45. #if defined(CONFIG_SWAP_IO_SPACE)
  46. # define ioswabb(x) (x)
  47. # ifdef CONFIG_SGI_IP22
  48. /*
  49. * IP22 seems braindead enough to swap 16bits values in hardware, but
  50. * not 32bits. Go figure... Can't tell without documentation.
  51. */
  52. # define ioswabw(x) (x)
  53. # else
  54. # define ioswabw(x) le16_to_cpu(x)
  55. # endif
  56. # define ioswabl(x) le32_to_cpu(x)
  57. # define ioswabq(x) le64_to_cpu(x)
  58. #else
  59. # define ioswabb(x) (x)
  60. # define ioswabw(x) (x)
  61. # define ioswabl(x) (x)
  62. # define ioswabq(x) (x)
  63. #endif
  64. /*
  65. * Native bus accesses never swapped.
  66. */
  67. #define bus_ioswabb(x) (x)
  68. #define bus_ioswabw(x) (x)
  69. #define bus_ioswabl(x) (x)
  70. #define bus_ioswabq(x) (x)
  71. #define __bus_ioswabq bus_ioswabq
  72. #define IO_SPACE_LIMIT 0xffff
  73. /*
  74. * On MIPS I/O ports are memory mapped, so we access them using normal
  75. * load/store instructions. mips_io_port_base is the virtual address to
  76. * which all ports are being mapped. For sake of efficiency some code
  77. * assumes that this is an address that can be loaded with a single lui
  78. * instruction, so the lower 16 bits must be zero. Should be true on
  79. * on any sane architecture; generic code does not use this assumption.
  80. */
  81. extern const unsigned long mips_io_port_base;
  82. #define set_io_port_base(base) \
  83. do { * (unsigned long *) &mips_io_port_base = (base); } while (0)
  84. /*
  85. * Thanks to James van Artsdalen for a better timing-fix than
  86. * the two short jumps: using outb's to a nonexistent port seems
  87. * to guarantee better timings even on fast machines.
  88. *
  89. * On the other hand, I'd like to be sure of a non-existent port:
  90. * I feel a bit unsafe about using 0x80 (should be safe, though)
  91. *
  92. * Linus
  93. *
  94. */
  95. #define __SLOW_DOWN_IO \
  96. __asm__ __volatile__( \
  97. "sb\t$0,0x80(%0)" \
  98. : : "r" (mips_io_port_base));
  99. #ifdef CONF_SLOWDOWN_IO
  100. #ifdef REALLY_SLOW_IO
  101. #define SLOW_DOWN_IO { __SLOW_DOWN_IO; __SLOW_DOWN_IO; __SLOW_DOWN_IO; __SLOW_DOWN_IO; }
  102. #else
  103. #define SLOW_DOWN_IO __SLOW_DOWN_IO
  104. #endif
  105. #else
  106. #define SLOW_DOWN_IO
  107. #endif
  108. /*
  109. * virt_to_phys - map virtual addresses to physical
  110. * @address: address to remap
  111. *
  112. * The returned physical address is the physical (CPU) mapping for
  113. * the memory address given. It is only valid to use this function on
  114. * addresses directly mapped or allocated via kmalloc.
  115. *
  116. * This function does not give bus mappings for DMA transfers. In
  117. * almost all conceivable cases a device driver should not be using
  118. * this function
  119. */
  120. static inline unsigned long virt_to_phys(volatile void * address)
  121. {
  122. return (unsigned long)address - PAGE_OFFSET;
  123. }
  124. /*
  125. * phys_to_virt - map physical address to virtual
  126. * @address: address to remap
  127. *
  128. * The returned virtual address is a current CPU mapping for
  129. * the memory address given. It is only valid to use this function on
  130. * addresses that have a kernel mapping
  131. *
  132. * This function does not handle bus mappings for DMA transfers. In
  133. * almost all conceivable cases a device driver should not be using
  134. * this function
  135. */
  136. static inline void * phys_to_virt(unsigned long address)
  137. {
  138. return (void *)(address + PAGE_OFFSET);
  139. }
  140. /*
  141. * ISA I/O bus memory addresses are 1:1 with the physical address.
  142. */
  143. static inline unsigned long isa_virt_to_bus(volatile void * address)
  144. {
  145. return (unsigned long)address - PAGE_OFFSET;
  146. }
  147. static inline void * isa_bus_to_virt(unsigned long address)
  148. {
  149. return (void *)(address + PAGE_OFFSET);
  150. }
  151. #define isa_page_to_bus page_to_phys
  152. /*
  153. * However PCI ones are not necessarily 1:1 and therefore these interfaces
  154. * are forbidden in portable PCI drivers.
  155. *
  156. * Allow them for x86 for legacy drivers, though.
  157. */
  158. #define virt_to_bus virt_to_phys
  159. #define bus_to_virt phys_to_virt
  160. /*
  161. * isa_slot_offset is the address where E(ISA) busaddress 0 is mapped
  162. * for the processor. This implies the assumption that there is only
  163. * one of these busses.
  164. */
  165. extern unsigned long isa_slot_offset;
  166. /*
  167. * Change "struct page" to physical address.
  168. */
  169. #define page_to_phys(page) ((dma_addr_t)page_to_pfn(page) << PAGE_SHIFT)
  170. extern void * __ioremap(phys_t offset, phys_t size, unsigned long flags);
  171. extern void __iounmap(volatile void __iomem *addr);
  172. static inline void * __ioremap_mode(phys_t offset, unsigned long size,
  173. unsigned long flags)
  174. {
  175. if (cpu_has_64bit_addresses) {
  176. u64 base = UNCAC_BASE;
  177. /*
  178. * R10000 supports a 2 bit uncached attribute therefore
  179. * UNCAC_BASE may not equal IO_BASE.
  180. */
  181. if (flags == _CACHE_UNCACHED)
  182. base = (u64) IO_BASE;
  183. return (void *) (unsigned long) (base + offset);
  184. }
  185. return __ioremap(offset, size, flags);
  186. }
  187. /*
  188. * ioremap - map bus memory into CPU space
  189. * @offset: bus address of the memory
  190. * @size: size of the resource to map
  191. *
  192. * ioremap performs a platform specific sequence of operations to
  193. * make bus memory CPU accessible via the readb/readw/readl/writeb/
  194. * writew/writel functions and the other mmio helpers. The returned
  195. * address is not guaranteed to be usable directly as a virtual
  196. * address.
  197. */
  198. #define ioremap(offset, size) \
  199. __ioremap_mode((offset), (size), _CACHE_UNCACHED)
  200. /*
  201. * ioremap_nocache - map bus memory into CPU space
  202. * @offset: bus address of the memory
  203. * @size: size of the resource to map
  204. *
  205. * ioremap_nocache performs a platform specific sequence of operations to
  206. * make bus memory CPU accessible via the readb/readw/readl/writeb/
  207. * writew/writel functions and the other mmio helpers. The returned
  208. * address is not guaranteed to be usable directly as a virtual
  209. * address.
  210. *
  211. * This version of ioremap ensures that the memory is marked uncachable
  212. * on the CPU as well as honouring existing caching rules from things like
  213. * the PCI bus. Note that there are other caches and buffers on many
  214. * busses. In paticular driver authors should read up on PCI writes
  215. *
  216. * It's useful if some control registers are in such an area and
  217. * write combining or read caching is not desirable:
  218. */
  219. #define ioremap_nocache(offset, size) \
  220. __ioremap_mode((offset), (size), _CACHE_UNCACHED)
  221. /*
  222. * These two are MIPS specific ioremap variant. ioremap_cacheable_cow
  223. * requests a cachable mapping, ioremap_uncached_accelerated requests a
  224. * mapping using the uncached accelerated mode which isn't supported on
  225. * all processors.
  226. */
  227. #define ioremap_cacheable_cow(offset, size) \
  228. __ioremap_mode((offset), (size), _CACHE_CACHABLE_COW)
  229. #define ioremap_uncached_accelerated(offset, size) \
  230. __ioremap_mode((offset), (size), _CACHE_UNCACHED_ACCELERATED)
  231. static inline void iounmap(volatile void __iomem *addr)
  232. {
  233. if (cpu_has_64bit_addresses)
  234. return;
  235. __iounmap(addr);
  236. }
  237. #define __BUILD_MEMORY_SINGLE(pfx, bwlq, type, irq) \
  238. \
  239. static inline void pfx##write##bwlq(type val, \
  240. volatile void __iomem *mem) \
  241. { \
  242. volatile type *__mem; \
  243. type __val; \
  244. \
  245. __mem = (void *)__swizzle_addr_##bwlq((unsigned long)(mem)); \
  246. \
  247. __val = pfx##ioswab##bwlq(val); \
  248. \
  249. if (sizeof(type) != sizeof(u64) || sizeof(u64) == sizeof(long)) \
  250. *__mem = __val; \
  251. else if (cpu_has_64bits) { \
  252. unsigned long __flags; \
  253. type __tmp; \
  254. \
  255. if (irq) \
  256. local_irq_save(__flags); \
  257. __asm__ __volatile__( \
  258. ".set mips3" "\t\t# __writeq""\n\t" \
  259. "dsll32 %L0, %L0, 0" "\n\t" \
  260. "dsrl32 %L0, %L0, 0" "\n\t" \
  261. "dsll32 %M0, %M0, 0" "\n\t" \
  262. "or %L0, %L0, %M0" "\n\t" \
  263. "sd %L0, %2" "\n\t" \
  264. ".set mips0" "\n" \
  265. : "=r" (__tmp) \
  266. : "0" (__val), "m" (*__mem)); \
  267. if (irq) \
  268. local_irq_restore(__flags); \
  269. } else \
  270. BUG(); \
  271. } \
  272. \
  273. static inline type pfx##read##bwlq(volatile void __iomem *mem) \
  274. { \
  275. volatile type *__mem; \
  276. type __val; \
  277. \
  278. __mem = (void *)__swizzle_addr_##bwlq((unsigned long)(mem)); \
  279. \
  280. if (sizeof(type) != sizeof(u64) || sizeof(u64) == sizeof(long)) \
  281. __val = *__mem; \
  282. else if (cpu_has_64bits) { \
  283. unsigned long __flags; \
  284. \
  285. local_irq_save(__flags); \
  286. __asm__ __volatile__( \
  287. ".set mips3" "\t\t# __readq" "\n\t" \
  288. "ld %L0, %1" "\n\t" \
  289. "dsra32 %M0, %L0, 0" "\n\t" \
  290. "sll %L0, %L0, 0" "\n\t" \
  291. ".set mips0" "\n" \
  292. : "=r" (__val) \
  293. : "m" (*__mem)); \
  294. local_irq_restore(__flags); \
  295. } else { \
  296. __val = 0; \
  297. BUG(); \
  298. } \
  299. \
  300. return pfx##ioswab##bwlq(__val); \
  301. }
  302. #define __BUILD_IOPORT_SINGLE(pfx, bwlq, type, p, slow) \
  303. \
  304. static inline void pfx##out##bwlq##p(type val, unsigned long port) \
  305. { \
  306. volatile type *__addr; \
  307. type __val; \
  308. \
  309. port = __swizzle_addr_##bwlq(port); \
  310. __addr = (void *)(mips_io_port_base + port); \
  311. \
  312. __val = pfx##ioswab##bwlq(val); \
  313. \
  314. if (sizeof(type) != sizeof(u64)) { \
  315. *__addr = __val; \
  316. slow; \
  317. } else \
  318. BUILD_BUG(); \
  319. } \
  320. \
  321. static inline type pfx##in##bwlq##p(unsigned long port) \
  322. { \
  323. volatile type *__addr; \
  324. type __val; \
  325. \
  326. port = __swizzle_addr_##bwlq(port); \
  327. __addr = (void *)(mips_io_port_base + port); \
  328. \
  329. if (sizeof(type) != sizeof(u64)) { \
  330. __val = *__addr; \
  331. slow; \
  332. } else { \
  333. __val = 0; \
  334. BUILD_BUG(); \
  335. } \
  336. \
  337. return pfx##ioswab##bwlq(__val); \
  338. }
  339. #define __BUILD_MEMORY_PFX(bus, bwlq, type) \
  340. \
  341. __BUILD_MEMORY_SINGLE(bus, bwlq, type, 1)
  342. #define __BUILD_IOPORT_PFX(bus, bwlq, type) \
  343. \
  344. __BUILD_IOPORT_SINGLE(bus, bwlq, type, ,) \
  345. __BUILD_IOPORT_SINGLE(bus, bwlq, type, _p, SLOW_DOWN_IO)
  346. #define BUILDIO(bwlq, type) \
  347. \
  348. __BUILD_MEMORY_PFX(, bwlq, type) \
  349. __BUILD_MEMORY_PFX(__raw_, bwlq, type) \
  350. __BUILD_MEMORY_PFX(bus_, bwlq, type) \
  351. __BUILD_IOPORT_PFX(, bwlq, type) \
  352. __BUILD_IOPORT_PFX(__raw_, bwlq, type)
  353. #define __BUILDIO(bwlq, type) \
  354. \
  355. __BUILD_MEMORY_SINGLE(__bus_, bwlq, type, 0)
  356. BUILDIO(b, u8)
  357. BUILDIO(w, u16)
  358. BUILDIO(l, u32)
  359. BUILDIO(q, u64)
  360. __BUILDIO(q, u64)
  361. #define readb_relaxed readb
  362. #define readw_relaxed readw
  363. #define readl_relaxed readl
  364. #define readq_relaxed readq
  365. /*
  366. * Some code tests for these symbols
  367. */
  368. #define readq readq
  369. #define writeq writeq
  370. #define __BUILD_MEMORY_STRING(bwlq, type) \
  371. \
  372. static inline void writes##bwlq(volatile void __iomem *mem, void *addr, \
  373. unsigned int count) \
  374. { \
  375. volatile type *__addr = addr; \
  376. \
  377. while (count--) { \
  378. __raw_write##bwlq(*__addr, mem); \
  379. __addr++; \
  380. } \
  381. } \
  382. \
  383. static inline void reads##bwlq(volatile void __iomem *mem, void *addr, \
  384. unsigned int count) \
  385. { \
  386. volatile type *__addr = addr; \
  387. \
  388. while (count--) { \
  389. *__addr = __raw_read##bwlq(mem); \
  390. __addr++; \
  391. } \
  392. }
  393. #define __BUILD_IOPORT_STRING(bwlq, type) \
  394. \
  395. static inline void outs##bwlq(unsigned long port, void *addr, \
  396. unsigned int count) \
  397. { \
  398. volatile type *__addr = addr; \
  399. \
  400. while (count--) { \
  401. __raw_out##bwlq(*__addr, port); \
  402. __addr++; \
  403. } \
  404. } \
  405. \
  406. static inline void ins##bwlq(unsigned long port, void *addr, \
  407. unsigned int count) \
  408. { \
  409. volatile type *__addr = addr; \
  410. \
  411. while (count--) { \
  412. *__addr = __raw_in##bwlq(port); \
  413. __addr++; \
  414. } \
  415. }
  416. #define BUILDSTRING(bwlq, type) \
  417. \
  418. __BUILD_MEMORY_STRING(bwlq, type) \
  419. __BUILD_IOPORT_STRING(bwlq, type)
  420. BUILDSTRING(b, u8)
  421. BUILDSTRING(w, u16)
  422. BUILDSTRING(l, u32)
  423. BUILDSTRING(q, u64)
  424. /* Depends on MIPS II instruction set */
  425. #define mmiowb() asm volatile ("sync" ::: "memory")
  426. #define memset_io(a,b,c) memset((void *)(a),(b),(c))
  427. #define memcpy_fromio(a,b,c) memcpy((a),(void *)(b),(c))
  428. #define memcpy_toio(a,b,c) memcpy((void *)(a),(b),(c))
  429. /*
  430. * Memory Mapped I/O
  431. */
  432. #define ioread8(addr) readb(addr)
  433. #define ioread16(addr) readw(addr)
  434. #define ioread32(addr) readl(addr)
  435. #define iowrite8(b,addr) writeb(b,addr)
  436. #define iowrite16(w,addr) writew(w,addr)
  437. #define iowrite32(l,addr) writel(l,addr)
  438. #define ioread8_rep(a,b,c) readsb(a,b,c)
  439. #define ioread16_rep(a,b,c) readsw(a,b,c)
  440. #define ioread32_rep(a,b,c) readsl(a,b,c)
  441. #define iowrite8_rep(a,b,c) writesb(a,b,c)
  442. #define iowrite16_rep(a,b,c) writesw(a,b,c)
  443. #define iowrite32_rep(a,b,c) writesl(a,b,c)
  444. /* Create a virtual mapping cookie for an IO port range */
  445. extern void __iomem *ioport_map(unsigned long port, unsigned int nr);
  446. extern void ioport_unmap(void __iomem *);
  447. /* Create a virtual mapping cookie for a PCI BAR (memory or IO) */
  448. struct pci_dev;
  449. extern void __iomem *pci_iomap(struct pci_dev *dev, int bar, unsigned long max);
  450. extern void pci_iounmap(struct pci_dev *dev, void __iomem *);
  451. /*
  452. * ISA space is 'always mapped' on currently supported MIPS systems, no need
  453. * to explicitly ioremap() it. The fact that the ISA IO space is mapped
  454. * to PAGE_OFFSET is pure coincidence - it does not mean ISA values
  455. * are physical addresses. The following constant pointer can be
  456. * used as the IO-area pointer (it can be iounmapped as well, so the
  457. * analogy with PCI is quite large):
  458. */
  459. #define __ISA_IO_base ((char *)(isa_slot_offset))
  460. #define isa_readb(a) readb(__ISA_IO_base + (a))
  461. #define isa_readw(a) readw(__ISA_IO_base + (a))
  462. #define isa_readl(a) readl(__ISA_IO_base + (a))
  463. #define isa_readq(a) readq(__ISA_IO_base + (a))
  464. #define isa_writeb(b,a) writeb(b,__ISA_IO_base + (a))
  465. #define isa_writew(w,a) writew(w,__ISA_IO_base + (a))
  466. #define isa_writel(l,a) writel(l,__ISA_IO_base + (a))
  467. #define isa_writeq(q,a) writeq(q,__ISA_IO_base + (a))
  468. #define isa_memset_io(a,b,c) memset_io(__ISA_IO_base + (a),(b),(c))
  469. #define isa_memcpy_fromio(a,b,c) memcpy_fromio((a),__ISA_IO_base + (b),(c))
  470. #define isa_memcpy_toio(a,b,c) memcpy_toio(__ISA_IO_base + (a),(b),(c))
  471. /*
  472. * We don't have csum_partial_copy_fromio() yet, so we cheat here and
  473. * just copy it. The net code will then do the checksum later.
  474. */
  475. #define eth_io_copy_and_sum(skb,src,len,unused) memcpy_fromio((skb)->data,(src),(len))
  476. #define isa_eth_io_copy_and_sum(a,b,c,d) eth_copy_and_sum((a),(b),(c),(d))
  477. /*
  478. * check_signature - find BIOS signatures
  479. * @io_addr: mmio address to check
  480. * @signature: signature block
  481. * @length: length of signature
  482. *
  483. * Perform a signature comparison with the mmio address io_addr. This
  484. * address should have been obtained by ioremap.
  485. * Returns 1 on a match.
  486. */
  487. static inline int check_signature(char __iomem *io_addr,
  488. const unsigned char *signature, int length)
  489. {
  490. int retval = 0;
  491. do {
  492. if (readb(io_addr) != *signature)
  493. goto out;
  494. io_addr++;
  495. signature++;
  496. length--;
  497. } while (length);
  498. retval = 1;
  499. out:
  500. return retval;
  501. }
  502. /*
  503. * The caches on some architectures aren't dma-coherent and have need to
  504. * handle this in software. There are three types of operations that
  505. * can be applied to dma buffers.
  506. *
  507. * - dma_cache_wback_inv(start, size) makes caches and coherent by
  508. * writing the content of the caches back to memory, if necessary.
  509. * The function also invalidates the affected part of the caches as
  510. * necessary before DMA transfers from outside to memory.
  511. * - dma_cache_wback(start, size) makes caches and coherent by
  512. * writing the content of the caches back to memory, if necessary.
  513. * The function also invalidates the affected part of the caches as
  514. * necessary before DMA transfers from outside to memory.
  515. * - dma_cache_inv(start, size) invalidates the affected parts of the
  516. * caches. Dirty lines of the caches may be written back or simply
  517. * be discarded. This operation is necessary before dma operations
  518. * to the memory.
  519. */
  520. #ifdef CONFIG_DMA_NONCOHERENT
  521. extern void (*_dma_cache_wback_inv)(unsigned long start, unsigned long size);
  522. extern void (*_dma_cache_wback)(unsigned long start, unsigned long size);
  523. extern void (*_dma_cache_inv)(unsigned long start, unsigned long size);
  524. #define dma_cache_wback_inv(start, size) _dma_cache_wback_inv(start,size)
  525. #define dma_cache_wback(start, size) _dma_cache_wback(start,size)
  526. #define dma_cache_inv(start, size) _dma_cache_inv(start,size)
  527. #else /* Sane hardware */
  528. #define dma_cache_wback_inv(start,size) \
  529. do { (void) (start); (void) (size); } while (0)
  530. #define dma_cache_wback(start,size) \
  531. do { (void) (start); (void) (size); } while (0)
  532. #define dma_cache_inv(start,size) \
  533. do { (void) (start); (void) (size); } while (0)
  534. #endif /* CONFIG_DMA_NONCOHERENT */
  535. /*
  536. * Read a 32-bit register that requires a 64-bit read cycle on the bus.
  537. * Avoid interrupt mucking, just adjust the address for 4-byte access.
  538. * Assume the addresses are 8-byte aligned.
  539. */
  540. #ifdef __MIPSEB__
  541. #define __CSR_32_ADJUST 4
  542. #else
  543. #define __CSR_32_ADJUST 0
  544. #endif
  545. #define csr_out32(v,a) (*(volatile u32 *)((unsigned long)(a) + __CSR_32_ADJUST) = (v))
  546. #define csr_in32(a) (*(volatile u32 *)((unsigned long)(a) + __CSR_32_ADJUST))
  547. /*
  548. * Convert a physical pointer to a virtual kernel pointer for /dev/mem
  549. * access
  550. */
  551. #define xlate_dev_mem_ptr(p) __va(p)
  552. /*
  553. * Convert a virtual cached pointer to an uncached pointer
  554. */
  555. #define xlate_dev_kmem_ptr(p) p
  556. #endif /* _ASM_IO_H */