io.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. /* SPDX-License-Identifier: GPL-2.0+ */
  2. /*
  3. * include/asm-microblaze/io.h -- Misc I/O operations
  4. *
  5. * Copyright (C) 2003 John Williams <jwilliams@itee.uq.edu.au>
  6. * Copyright (C) 2001,02 NEC Corporation
  7. * Copyright (C) 2001,02 Miles Bader <miles@gnu.org>
  8. *
  9. * This file is subject to the terms and conditions of the GNU General
  10. * Public License. See the file COPYING in the main directory of this
  11. * archive for more details.
  12. *
  13. * Written by Miles Bader <miles@gnu.org>
  14. * Microblaze port by John Williams
  15. */
  16. #ifndef __MICROBLAZE_IO_H__
  17. #define __MICROBLAZE_IO_H__
  18. #include <asm/types.h>
  19. #define IO_SPACE_LIMIT 0xFFFFFFFF
  20. #define readb(addr) \
  21. ({ unsigned char __v = (*(volatile unsigned char *)(addr)); __v; })
  22. #define readw(addr) \
  23. ({ unsigned short __v = (*(volatile unsigned short *)(addr)); __v; })
  24. #define readl(addr) \
  25. ({ unsigned int __v = (*(volatile unsigned int *)(addr)); __v; })
  26. #define writeb(b, addr) \
  27. (void)((*(volatile unsigned char *)(addr)) = (b))
  28. #define writew(b, addr) \
  29. (void)((*(volatile unsigned short *)(addr)) = (b))
  30. #define writel(b, addr) \
  31. (void)((*(volatile unsigned int *)(addr)) = (b))
  32. #define memset_io(a, b, c) memset((void *)(a), (b), (c))
  33. #define memcpy_fromio(a, b, c) memcpy((a), (void *)(b), (c))
  34. #define memcpy_toio(a, b, c) memcpy((void *)(a), (b), (c))
  35. #define inb(addr) readb(addr)
  36. #define inw(addr) readw(addr)
  37. #define inl(addr) readl(addr)
  38. #define outb(x, addr) ((void)writeb(x, addr))
  39. #define outw(x, addr) ((void)writew(x, addr))
  40. #define outl(x, addr) ((void)writel(x, addr))
  41. #define out_arch(type, endian, addr, x) \
  42. __raw_write##type(cpu_to_##endian(x), addr)
  43. #define in_arch(type, endian, addr) \
  44. endian##_to_cpu(__raw_read##type(addr))
  45. #define out_le16(addr, x) out_arch(w, le16, addr, x)
  46. #define out_le32(addr, x) out_arch(l, le32, addr, x)
  47. #define in_le16(addr) in_arch(w, le16, addr)
  48. #define in_le32(addr) in_arch(l, le32, addr)
  49. #define in_8(addr) readb(addr)
  50. #define in_be16(addr) in_arch(w, be16, addr)
  51. #define in_be32(addr) in_arch(l, be32, addr)
  52. #define out_8(addr, x) outb(x, addr)
  53. #define out_be16(addr, x) out_arch(w, be16, addr, x)
  54. #define out_be32(addr, x) out_arch(l, be32, addr, x)
  55. #define inb_p(port) inb((port))
  56. #define outb_p(val, port) outb((val), (port))
  57. #define inw_p(port) inw((port))
  58. #define outw_p(val, port) outw((val), (port))
  59. #define inl_p(port) inl((port))
  60. #define outl_p(val, port) outl((val), (port))
  61. /* Some defines to keep the MTD flash drivers happy */
  62. #define __raw_readb readb
  63. #define __raw_readw readw
  64. #define __raw_readl readl
  65. #define __raw_writeb writeb
  66. #define __raw_writew writew
  67. #define __raw_writel writel
  68. static inline void io_insb(unsigned long port, void *dst, unsigned long count)
  69. {
  70. unsigned char *p = dst;
  71. while (count--)
  72. *p++ = inb(port);
  73. }
  74. static inline void io_insw(unsigned long port, void *dst, unsigned long count)
  75. {
  76. unsigned short *p = dst;
  77. while (count--)
  78. *p++ = inw(port);
  79. }
  80. static inline void io_insl(unsigned long port, void *dst, unsigned long count)
  81. {
  82. unsigned long *p = dst;
  83. while (count--)
  84. *p++ = inl(port);
  85. }
  86. static inline void
  87. io_outsb(unsigned long port, const void *src, unsigned long count)
  88. {
  89. const unsigned char *p = src;
  90. while (count--)
  91. outb(*p++, port);
  92. }
  93. static inline void
  94. io_outsw(unsigned long port, const void *src, unsigned long count)
  95. {
  96. const unsigned short *p = src;
  97. while (count--)
  98. outw(*p++, port);
  99. }
  100. static inline void
  101. io_outsl(unsigned long port, const void *src, unsigned long count)
  102. {
  103. const unsigned long *p = src;
  104. while (count--)
  105. outl(*p++, port);
  106. }
  107. #define outsb(a, b, l) io_outsb(a, b, l)
  108. #define outsw(a, b, l) io_outsw(a, b, l)
  109. #define outsl(a, b, l) io_outsl(a, b, l)
  110. #define insb(a, b, l) io_insb(a, b, l)
  111. #define insw(a, b, l) io_insw(a, b, l)
  112. #define insl(a, b, l) io_insl(a, b, l)
  113. #define ioremap_nocache(physaddr, size) (physaddr)
  114. #define ioremap_writethrough(physaddr, size) (physaddr)
  115. #define ioremap_fullcache(physaddr, size) (physaddr)
  116. static inline void sync(void)
  117. {
  118. }
  119. #include <asm-generic/io.h>
  120. #endif /* __MICROBLAZE_IO_H__ */