io.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. /*
  2. * include/asm-microblaze/io.h -- Misc I/O operations
  3. *
  4. * Copyright (C) 2003 John Williams <jwilliams@itee.uq.edu.au>
  5. * Copyright (C) 2001,02 NEC Corporation
  6. * Copyright (C) 2001,02 Miles Bader <miles@gnu.org>
  7. *
  8. * This file is subject to the terms and conditions of the GNU General
  9. * Public License. See the file COPYING in the main directory of this
  10. * archive for more details.
  11. *
  12. * Written by Miles Bader <miles@gnu.org>
  13. * Microblaze port by John Williams
  14. */
  15. #ifndef __MICROBLAZE_IO_H__
  16. #define __MICROBLAZE_IO_H__
  17. #define IO_SPACE_LIMIT 0xFFFFFFFF
  18. #define readb(addr) \
  19. ({ unsigned char __v = (*(volatile unsigned char *) (addr)); __v; })
  20. #define readw(addr) \
  21. ({ unsigned short __v = (*(volatile unsigned short *) (addr)); __v; })
  22. #define readl(addr) \
  23. ({ unsigned long __v = (*(volatile unsigned long *) (addr)); __v; })
  24. #define writeb(b, addr) \
  25. (void)((*(volatile unsigned char *) (addr)) = (b))
  26. #define writew(b, addr) \
  27. (void)((*(volatile unsigned short *) (addr)) = (b))
  28. #define writel(b, addr) \
  29. (void)((*(volatile unsigned int *) (addr)) = (b))
  30. #define memset_io(a,b,c) memset((void *)(a),(b),(c))
  31. #define memcpy_fromio(a,b,c) memcpy((a),(void *)(b),(c))
  32. #define memcpy_toio(a,b,c) memcpy((void *)(a),(b),(c))
  33. #define inb(addr) readb (addr)
  34. #define inw(addr) readw (addr)
  35. #define inl(addr) readl (addr)
  36. #define outb(x, addr) ((void) writeb (x, addr))
  37. #define outw(x, addr) ((void) writew (x, addr))
  38. #define outl(x, addr) ((void) writel (x, addr))
  39. /* Some #definitions to keep strange Xilinx code happy */
  40. #define in_8(addr) readb (addr)
  41. #define in_be16(addr) readw (addr)
  42. #define in_be32(addr) readl (addr)
  43. #define out_8(addr,x ) outb (x,addr)
  44. #define out_be16(addr,x ) outw (x,addr)
  45. #define out_be32(addr,x ) outl (x,addr)
  46. #define inb_p(port) inb((port))
  47. #define outb_p(val, port) outb((val), (port))
  48. #define inw_p(port) inw((port))
  49. #define outw_p(val, port) outw((val), (port))
  50. #define inl_p(port) inl((port))
  51. #define outl_p(val, port) outl((val), (port))
  52. /* Some defines to keep the MTD flash drivers happy */
  53. #define __raw_readb readb
  54. #define __raw_readw readw
  55. #define __raw_readl readl
  56. #define __raw_writeb writeb
  57. #define __raw_writew writew
  58. #define __raw_writel writel
  59. static inline void io_insb (unsigned long port, void *dst, unsigned long count)
  60. {
  61. unsigned char *p = dst;
  62. while (count--)
  63. *p++ = inb (port);
  64. }
  65. static inline void io_insw (unsigned long port, void *dst, unsigned long count)
  66. {
  67. unsigned short *p = dst;
  68. while (count--)
  69. *p++ = inw (port);
  70. }
  71. static inline void io_insl (unsigned long port, void *dst, unsigned long count)
  72. {
  73. unsigned long *p = dst;
  74. while (count--)
  75. *p++ = inl (port);
  76. }
  77. static inline void
  78. io_outsb (unsigned long port, const void *src, unsigned long count)
  79. {
  80. const unsigned char *p = src;
  81. while (count--)
  82. outb (*p++, port);
  83. }
  84. static inline void
  85. io_outsw (unsigned long port, const void *src, unsigned long count)
  86. {
  87. const unsigned short *p = src;
  88. while (count--)
  89. outw (*p++, port);
  90. }
  91. static inline void
  92. io_outsl (unsigned long port, const void *src, unsigned long count)
  93. {
  94. const unsigned long *p = src;
  95. while (count--)
  96. outl (*p++, port);
  97. }
  98. #define outsb(a,b,l) io_outsb(a,b,l)
  99. #define outsw(a,b,l) io_outsw(a,b,l)
  100. #define outsl(a,b,l) io_outsl(a,b,l)
  101. #define insb(a,b,l) io_insb(a,b,l)
  102. #define insw(a,b,l) io_insw(a,b,l)
  103. #define insl(a,b,l) io_insl(a,b,l)
  104. #define iounmap(addr) ((void)0)
  105. #define ioremap(physaddr, size) (physaddr)
  106. #define ioremap_nocache(physaddr, size) (physaddr)
  107. #define ioremap_writethrough(physaddr, size) (physaddr)
  108. #define ioremap_fullcache(physaddr, size) (physaddr)
  109. static inline void sync(void)
  110. {
  111. }
  112. /*
  113. * Given a physical address and a length, return a virtual address
  114. * that can be used to access the memory range with the caching
  115. * properties specified by "flags".
  116. */
  117. typedef unsigned long phys_addr_t;
  118. #define MAP_NOCACHE (0)
  119. #define MAP_WRCOMBINE (0)
  120. #define MAP_WRBACK (0)
  121. #define MAP_WRTHROUGH (0)
  122. static inline void *
  123. map_physmem(phys_addr_t paddr, unsigned long len, unsigned long flags)
  124. {
  125. return (void *)paddr;
  126. }
  127. /*
  128. * Take down a mapping set up by map_physmem().
  129. */
  130. static inline void unmap_physmem(void *vaddr, unsigned long flags)
  131. {
  132. }
  133. #endif /* __MICROBLAZE_IO_H__ */