io_32.h 3.7 KB

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