io_no.h 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. #ifndef _M68KNOMMU_IO_H
  2. #define _M68KNOMMU_IO_H
  3. #ifdef __KERNEL__
  4. #include <asm/virtconvert.h>
  5. #include <asm-generic/iomap.h>
  6. /*
  7. * These are for ISA/PCI shared memory _only_ and should never be used
  8. * on any other type of memory, including Zorro memory. They are meant to
  9. * access the bus in the bus byte order which is little-endian!.
  10. *
  11. * readX/writeX() are used to access memory mapped devices. On some
  12. * architectures the memory mapped IO stuff needs to be accessed
  13. * differently. On the m68k architecture, we just read/write the
  14. * memory location directly.
  15. */
  16. /* ++roman: The assignments to temp. vars avoid that gcc sometimes generates
  17. * two accesses to memory, which may be undesirable for some devices.
  18. */
  19. /*
  20. * swap functions are sometimes needed to interface little-endian hardware
  21. */
  22. static inline unsigned short _swapw(volatile unsigned short v)
  23. {
  24. return ((v << 8) | (v >> 8));
  25. }
  26. static inline unsigned int _swapl(volatile unsigned long v)
  27. {
  28. return ((v << 24) | ((v & 0xff00) << 8) | ((v & 0xff0000) >> 8) | (v >> 24));
  29. }
  30. #define readb(addr) \
  31. ({ unsigned char __v = (*(volatile unsigned char *) (addr)); __v; })
  32. #define readw(addr) \
  33. ({ unsigned short __v = (*(volatile unsigned short *) (addr)); __v; })
  34. #define readl(addr) \
  35. ({ unsigned int __v = (*(volatile unsigned int *) (addr)); __v; })
  36. #define readb_relaxed(addr) readb(addr)
  37. #define readw_relaxed(addr) readw(addr)
  38. #define readl_relaxed(addr) readl(addr)
  39. #define writeb(b,addr) (void)((*(volatile unsigned char *) (addr)) = (b))
  40. #define writew(b,addr) (void)((*(volatile unsigned short *) (addr)) = (b))
  41. #define writel(b,addr) (void)((*(volatile unsigned int *) (addr)) = (b))
  42. #define __raw_readb readb
  43. #define __raw_readw readw
  44. #define __raw_readl readl
  45. #define __raw_writeb writeb
  46. #define __raw_writew writew
  47. #define __raw_writel writel
  48. static inline void io_outsb(unsigned int addr, void *buf, int len)
  49. {
  50. volatile unsigned char *ap = (volatile unsigned char *) addr;
  51. unsigned char *bp = (unsigned char *) buf;
  52. while (len--)
  53. *ap = *bp++;
  54. }
  55. static inline void io_outsw(unsigned int addr, void *buf, int len)
  56. {
  57. volatile unsigned short *ap = (volatile unsigned short *) addr;
  58. unsigned short *bp = (unsigned short *) buf;
  59. while (len--)
  60. *ap = _swapw(*bp++);
  61. }
  62. static inline void io_outsl(unsigned int addr, void *buf, int len)
  63. {
  64. volatile unsigned int *ap = (volatile unsigned int *) addr;
  65. unsigned int *bp = (unsigned int *) buf;
  66. while (len--)
  67. *ap = _swapl(*bp++);
  68. }
  69. static inline void io_insb(unsigned int addr, void *buf, int len)
  70. {
  71. volatile unsigned char *ap = (volatile unsigned char *) addr;
  72. unsigned char *bp = (unsigned char *) buf;
  73. while (len--)
  74. *bp++ = *ap;
  75. }
  76. static inline void io_insw(unsigned int addr, void *buf, int len)
  77. {
  78. volatile unsigned short *ap = (volatile unsigned short *) addr;
  79. unsigned short *bp = (unsigned short *) buf;
  80. while (len--)
  81. *bp++ = _swapw(*ap);
  82. }
  83. static inline void io_insl(unsigned int addr, void *buf, int len)
  84. {
  85. volatile unsigned int *ap = (volatile unsigned int *) addr;
  86. unsigned int *bp = (unsigned int *) buf;
  87. while (len--)
  88. *bp++ = _swapl(*ap);
  89. }
  90. #define mmiowb()
  91. /*
  92. * make the short names macros so specific devices
  93. * can override them as required
  94. */
  95. #define memset_io(a,b,c) memset((void *)(a),(b),(c))
  96. #define memcpy_fromio(a,b,c) memcpy((a),(void *)(b),(c))
  97. #define memcpy_toio(a,b,c) memcpy((void *)(a),(b),(c))
  98. #define inb(addr) readb(addr)
  99. #define inw(addr) readw(addr)
  100. #define inl(addr) readl(addr)
  101. #define outb(x,addr) ((void) writeb(x,addr))
  102. #define outw(x,addr) ((void) writew(x,addr))
  103. #define outl(x,addr) ((void) writel(x,addr))
  104. #define inb_p(addr) inb(addr)
  105. #define inw_p(addr) inw(addr)
  106. #define inl_p(addr) inl(addr)
  107. #define outb_p(x,addr) outb(x,addr)
  108. #define outw_p(x,addr) outw(x,addr)
  109. #define outl_p(x,addr) outl(x,addr)
  110. #define outsb(a,b,l) io_outsb(a,b,l)
  111. #define outsw(a,b,l) io_outsw(a,b,l)
  112. #define outsl(a,b,l) io_outsl(a,b,l)
  113. #define insb(a,b,l) io_insb(a,b,l)
  114. #define insw(a,b,l) io_insw(a,b,l)
  115. #define insl(a,b,l) io_insl(a,b,l)
  116. #define IO_SPACE_LIMIT 0xffffffff
  117. /* Values for nocacheflag and cmode */
  118. #define IOMAP_FULL_CACHING 0
  119. #define IOMAP_NOCACHE_SER 1
  120. #define IOMAP_NOCACHE_NONSER 2
  121. #define IOMAP_WRITETHROUGH 3
  122. static inline void *__ioremap(unsigned long physaddr, unsigned long size, int cacheflag)
  123. {
  124. return (void *) physaddr;
  125. }
  126. static inline void *ioremap(unsigned long physaddr, unsigned long size)
  127. {
  128. return __ioremap(physaddr, size, IOMAP_NOCACHE_SER);
  129. }
  130. static inline void *ioremap_nocache(unsigned long physaddr, unsigned long size)
  131. {
  132. return __ioremap(physaddr, size, IOMAP_NOCACHE_SER);
  133. }
  134. static inline void *ioremap_writethrough(unsigned long physaddr, unsigned long size)
  135. {
  136. return __ioremap(physaddr, size, IOMAP_WRITETHROUGH);
  137. }
  138. static inline void *ioremap_fullcache(unsigned long physaddr, unsigned long size)
  139. {
  140. return __ioremap(physaddr, size, IOMAP_FULL_CACHING);
  141. }
  142. #define iounmap(addr) do { } while(0)
  143. /*
  144. * Convert a physical pointer to a virtual kernel pointer for /dev/mem
  145. * access
  146. */
  147. #define xlate_dev_mem_ptr(p) __va(p)
  148. /*
  149. * Convert a virtual cached pointer to an uncached pointer
  150. */
  151. #define xlate_dev_kmem_ptr(p) p
  152. #endif /* __KERNEL__ */
  153. #endif /* _M68KNOMMU_IO_H */