io.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. /*
  2. * include/asm-v850/io.h -- Misc I/O operations
  3. *
  4. * Copyright (C) 2001,02,03,04,05 NEC Electronics Corporation
  5. * Copyright (C) 2001,02,03,04,05 Miles Bader <miles@gnu.org>
  6. *
  7. * This file is subject to the terms and conditions of the GNU General
  8. * Public License. See the file COPYING in the main directory of this
  9. * archive for more details.
  10. *
  11. * Written by Miles Bader <miles@gnu.org>
  12. */
  13. #ifndef __V850_IO_H__
  14. #define __V850_IO_H__
  15. #define IO_SPACE_LIMIT 0xFFFFFFFF
  16. #define readb(addr) \
  17. ({ unsigned char __v = (*(volatile unsigned char *) (addr)); __v; })
  18. #define readw(addr) \
  19. ({ unsigned short __v = (*(volatile unsigned short *) (addr)); __v; })
  20. #define readl(addr) \
  21. ({ unsigned long __v = (*(volatile unsigned long *) (addr)); __v; })
  22. #define readb_relaxed(a) readb(a)
  23. #define readw_relaxed(a) readw(a)
  24. #define readl_relaxed(a) readl(a)
  25. #define writeb(val, addr) \
  26. (void)((*(volatile unsigned char *) (addr)) = (val))
  27. #define writew(val, addr) \
  28. (void)((*(volatile unsigned short *) (addr)) = (val))
  29. #define writel(val, addr) \
  30. (void)((*(volatile unsigned int *) (addr)) = (val))
  31. #define __raw_readb readb
  32. #define __raw_readw readw
  33. #define __raw_readl readl
  34. #define __raw_writeb writeb
  35. #define __raw_writew writew
  36. #define __raw_writel writel
  37. #define inb(addr) readb (addr)
  38. #define inw(addr) readw (addr)
  39. #define inl(addr) readl (addr)
  40. #define outb(x, addr) ((void) writeb (x, addr))
  41. #define outw(x, addr) ((void) writew (x, addr))
  42. #define outl(x, addr) ((void) writel (x, addr))
  43. #define inb_p(port) inb((port))
  44. #define outb_p(val, port) outb((val), (port))
  45. #define inw_p(port) inw((port))
  46. #define outw_p(val, port) outw((val), (port))
  47. #define inl_p(port) inl((port))
  48. #define outl_p(val, port) outl((val), (port))
  49. static inline void insb (unsigned long port, void *dst, unsigned long count)
  50. {
  51. unsigned char *p = dst;
  52. while (count--)
  53. *p++ = inb (port);
  54. }
  55. static inline void insw (unsigned long port, void *dst, unsigned long count)
  56. {
  57. unsigned short *p = dst;
  58. while (count--)
  59. *p++ = inw (port);
  60. }
  61. static inline void insl (unsigned long port, void *dst, unsigned long count)
  62. {
  63. unsigned long *p = dst;
  64. while (count--)
  65. *p++ = inl (port);
  66. }
  67. static inline void
  68. outsb (unsigned long port, const void *src, unsigned long count)
  69. {
  70. const unsigned char *p = src;
  71. while (count--)
  72. outb (*p++, port);
  73. }
  74. static inline void
  75. outsw (unsigned long port, const void *src, unsigned long count)
  76. {
  77. const unsigned short *p = src;
  78. while (count--)
  79. outw (*p++, port);
  80. }
  81. static inline void
  82. outsl (unsigned long port, const void *src, unsigned long count)
  83. {
  84. const unsigned long *p = src;
  85. while (count--)
  86. outl (*p++, port);
  87. }
  88. /* Some places try to pass in an loff_t for PHYSADDR (?!), so we cast it to
  89. long before casting it to a pointer to avoid compiler warnings. */
  90. #define ioremap(physaddr, size) ((void __iomem *)(unsigned long)(physaddr))
  91. #define iounmap(addr) ((void)0)
  92. #define ioremap_nocache(physaddr, size) ioremap (physaddr, size)
  93. #define ioremap_writethrough(physaddr, size) ioremap (physaddr, size)
  94. #define ioremap_fullcache(physaddr, size) ioremap (physaddr, size)
  95. #define ioread8(addr) readb (addr)
  96. #define ioread16(addr) readw (addr)
  97. #define ioread32(addr) readl (addr)
  98. #define iowrite8(val, addr) writeb (val, addr)
  99. #define iowrite16(val, addr) writew (val, addr)
  100. #define iowrite32(val, addr) writel (val, addr)
  101. #define mmiowb()
  102. #define page_to_phys(page) ((page - mem_map) << PAGE_SHIFT)
  103. #if 0
  104. /* This is really stupid; don't define it. */
  105. #define page_to_bus(page) page_to_phys (page)
  106. #endif
  107. /* Conversion between virtual and physical mappings. */
  108. #define mm_ptov(addr) ((void *)__phys_to_virt (addr))
  109. #define mm_vtop(addr) ((unsigned long)__virt_to_phys (addr))
  110. #define phys_to_virt(addr) ((void *)__phys_to_virt (addr))
  111. #define virt_to_phys(addr) ((unsigned long)__virt_to_phys (addr))
  112. #define memcpy_fromio(dst, src, len) memcpy (dst, (void *)src, len)
  113. #define memcpy_toio(dst, src, len) memcpy ((void *)dst, src, len)
  114. /*
  115. * Convert a physical pointer to a virtual kernel pointer for /dev/mem
  116. * access
  117. */
  118. #define xlate_dev_mem_ptr(p) __va(p)
  119. /*
  120. * Convert a virtual cached pointer to an uncached pointer
  121. */
  122. #define xlate_dev_kmem_ptr(p) p
  123. #endif /* __V850_IO_H__ */