io_32.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. #ifndef __SPARC_IO_H
  2. #define __SPARC_IO_H
  3. #include <linux/kernel.h>
  4. #include <linux/ioport.h> /* struct resource */
  5. #define readb_relaxed(__addr) readb(__addr)
  6. #define readw_relaxed(__addr) readw(__addr)
  7. #define readl_relaxed(__addr) readl(__addr)
  8. #define IO_SPACE_LIMIT 0xffffffff
  9. #define memset_io(d,c,sz) _memset_io(d,c,sz)
  10. #define memcpy_fromio(d,s,sz) _memcpy_fromio(d,s,sz)
  11. #define memcpy_toio(d,s,sz) _memcpy_toio(d,s,sz)
  12. #include <asm-generic/io.h>
  13. static inline void _memset_io(volatile void __iomem *dst,
  14. int c, __kernel_size_t n)
  15. {
  16. volatile void __iomem *d = dst;
  17. while (n--) {
  18. writeb(c, d);
  19. d++;
  20. }
  21. }
  22. static inline void _memcpy_fromio(void *dst, const volatile void __iomem *src,
  23. __kernel_size_t n)
  24. {
  25. char *d = dst;
  26. while (n--) {
  27. char tmp = readb(src);
  28. *d++ = tmp;
  29. src++;
  30. }
  31. }
  32. static inline void _memcpy_toio(volatile void __iomem *dst, const void *src,
  33. __kernel_size_t n)
  34. {
  35. const char *s = src;
  36. volatile void __iomem *d = dst;
  37. while (n--) {
  38. char tmp = *s++;
  39. writeb(tmp, d);
  40. d++;
  41. }
  42. }
  43. /*
  44. * SBus accessors.
  45. *
  46. * SBus has only one, memory mapped, I/O space.
  47. * We do not need to flip bytes for SBus of course.
  48. */
  49. static inline u8 sbus_readb(const volatile void __iomem *addr)
  50. {
  51. return *(__force volatile u8 *)addr;
  52. }
  53. static inline u16 sbus_readw(const volatile void __iomem *addr)
  54. {
  55. return *(__force volatile u16 *)addr;
  56. }
  57. static inline u32 sbus_readl(const volatile void __iomem *addr)
  58. {
  59. return *(__force volatile u32 *)addr;
  60. }
  61. static inline void sbus_writeb(u8 b, volatile void __iomem *addr)
  62. {
  63. *(__force volatile u8 *)addr = b;
  64. }
  65. static inline void sbus_writew(u16 w, volatile void __iomem *addr)
  66. {
  67. *(__force volatile u16 *)addr = w;
  68. }
  69. static inline void sbus_writel(u32 l, volatile void __iomem *addr)
  70. {
  71. *(__force volatile u32 *)addr = l;
  72. }
  73. static inline void sbus_memset_io(volatile void __iomem *__dst, int c,
  74. __kernel_size_t n)
  75. {
  76. while(n--) {
  77. sbus_writeb(c, __dst);
  78. __dst++;
  79. }
  80. }
  81. static inline void sbus_memcpy_fromio(void *dst,
  82. const volatile void __iomem *src,
  83. __kernel_size_t n)
  84. {
  85. char *d = dst;
  86. while (n--) {
  87. char tmp = sbus_readb(src);
  88. *d++ = tmp;
  89. src++;
  90. }
  91. }
  92. static inline void sbus_memcpy_toio(volatile void __iomem *dst,
  93. const void *src,
  94. __kernel_size_t n)
  95. {
  96. const char *s = src;
  97. volatile void __iomem *d = dst;
  98. while (n--) {
  99. char tmp = *s++;
  100. sbus_writeb(tmp, d);
  101. d++;
  102. }
  103. }
  104. #ifdef __KERNEL__
  105. /*
  106. * Bus number may be embedded in the higher bits of the physical address.
  107. * This is why we have no bus number argument to ioremap().
  108. */
  109. void __iomem *ioremap(unsigned long offset, unsigned long size);
  110. #define ioremap_nocache(X,Y) ioremap((X),(Y))
  111. #define ioremap_wc(X,Y) ioremap((X),(Y))
  112. void iounmap(volatile void __iomem *addr);
  113. /* Create a virtual mapping cookie for an IO port range */
  114. void __iomem *ioport_map(unsigned long port, unsigned int nr);
  115. void ioport_unmap(void __iomem *);
  116. /* Create a virtual mapping cookie for a PCI BAR (memory or IO) */
  117. struct pci_dev;
  118. void pci_iounmap(struct pci_dev *dev, void __iomem *);
  119. /*
  120. * At the moment, we do not use CMOS_READ anywhere outside of rtc.c,
  121. * so rtc_port is static in it. This should not change unless a new
  122. * hardware pops up.
  123. */
  124. #define RTC_PORT(x) (rtc_port + (x))
  125. #define RTC_ALWAYS_BCD 0
  126. static inline int sbus_can_dma_64bit(void)
  127. {
  128. return 0; /* actually, sparc_cpu_model==sun4d */
  129. }
  130. static inline int sbus_can_burst64(void)
  131. {
  132. return 0; /* actually, sparc_cpu_model==sun4d */
  133. }
  134. struct device;
  135. void sbus_set_sbus64(struct device *, int);
  136. #endif
  137. #define __ARCH_HAS_NO_PAGE_ZERO_MAPPED 1
  138. #endif /* !(__SPARC_IO_H) */