io.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  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. #include <asm/types.h>
  18. #define IO_SPACE_LIMIT 0xFFFFFFFF
  19. #define readb(addr) \
  20. ({ unsigned char __v = (*(volatile unsigned char *) (addr)); __v; })
  21. #define readw(addr) \
  22. ({ unsigned short __v = (*(volatile unsigned short *) (addr)); __v; })
  23. #define readl(addr) \
  24. ({ unsigned int __v = (*(volatile unsigned int *) (addr)); __v; })
  25. #define writeb(b, addr) \
  26. (void)((*(volatile unsigned char *) (addr)) = (b))
  27. #define writew(b, addr) \
  28. (void)((*(volatile unsigned short *) (addr)) = (b))
  29. #define writel(b, addr) \
  30. (void)((*(volatile unsigned int *) (addr)) = (b))
  31. #define memset_io(a,b,c) memset((void *)(a),(b),(c))
  32. #define memcpy_fromio(a,b,c) memcpy((a),(void *)(b),(c))
  33. #define memcpy_toio(a,b,c) memcpy((void *)(a),(b),(c))
  34. #define inb(addr) readb (addr)
  35. #define inw(addr) readw (addr)
  36. #define inl(addr) readl (addr)
  37. #define outb(x, addr) ((void) writeb (x, addr))
  38. #define outw(x, addr) ((void) writew (x, addr))
  39. #define outl(x, addr) ((void) writel (x, addr))
  40. /* Some #definitions to keep strange Xilinx code happy */
  41. #define in_8(addr) readb (addr)
  42. #define in_be16(addr) readw (addr)
  43. #define in_be32(addr) readl (addr)
  44. #define out_8(addr,x ) outb (x,addr)
  45. #define out_be16(addr,x ) outw (x,addr)
  46. #define out_be32(addr,x ) outl (x,addr)
  47. #define inb_p(port) inb((port))
  48. #define outb_p(val, port) outb((val), (port))
  49. #define inw_p(port) inw((port))
  50. #define outw_p(val, port) outw((val), (port))
  51. #define inl_p(port) inl((port))
  52. #define outl_p(val, port) outl((val), (port))
  53. /* Some defines to keep the MTD flash drivers happy */
  54. #define __raw_readb readb
  55. #define __raw_readw readw
  56. #define __raw_readl readl
  57. #define __raw_writeb writeb
  58. #define __raw_writew writew
  59. #define __raw_writel writel
  60. static inline void io_insb (unsigned long port, void *dst, unsigned long count)
  61. {
  62. unsigned char *p = dst;
  63. while (count--)
  64. *p++ = inb (port);
  65. }
  66. static inline void io_insw (unsigned long port, void *dst, unsigned long count)
  67. {
  68. unsigned short *p = dst;
  69. while (count--)
  70. *p++ = inw (port);
  71. }
  72. static inline void io_insl (unsigned long port, void *dst, unsigned long count)
  73. {
  74. unsigned long *p = dst;
  75. while (count--)
  76. *p++ = inl (port);
  77. }
  78. static inline void
  79. io_outsb (unsigned long port, const void *src, unsigned long count)
  80. {
  81. const unsigned char *p = src;
  82. while (count--)
  83. outb (*p++, port);
  84. }
  85. static inline void
  86. io_outsw (unsigned long port, const void *src, unsigned long count)
  87. {
  88. const unsigned short *p = src;
  89. while (count--)
  90. outw (*p++, port);
  91. }
  92. static inline void
  93. io_outsl (unsigned long port, const void *src, unsigned long count)
  94. {
  95. const unsigned long *p = src;
  96. while (count--)
  97. outl (*p++, port);
  98. }
  99. #define outsb(a,b,l) io_outsb(a,b,l)
  100. #define outsw(a,b,l) io_outsw(a,b,l)
  101. #define outsl(a,b,l) io_outsl(a,b,l)
  102. #define insb(a,b,l) io_insb(a,b,l)
  103. #define insw(a,b,l) io_insw(a,b,l)
  104. #define insl(a,b,l) io_insl(a,b,l)
  105. #define iounmap(addr) ((void)0)
  106. #define ioremap(physaddr, size) (physaddr)
  107. #define ioremap_nocache(physaddr, size) (physaddr)
  108. #define ioremap_writethrough(physaddr, size) (physaddr)
  109. #define ioremap_fullcache(physaddr, size) (physaddr)
  110. static inline void sync(void)
  111. {
  112. }
  113. /*
  114. * Given a physical address and a length, return a virtual address
  115. * that can be used to access the memory range with the caching
  116. * properties specified by "flags".
  117. */
  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. static inline phys_addr_t virt_to_phys(void * vaddr)
  134. {
  135. return (phys_addr_t)(vaddr);
  136. }
  137. #endif /* __MICROBLAZE_IO_H__ */