iomap.c 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. /*
  2. * ppc64 "iomap" interface implementation.
  3. *
  4. * (C) Copyright 2004 Linus Torvalds
  5. */
  6. #include <linux/pci.h>
  7. #include <linux/mm.h>
  8. #include <linux/export.h>
  9. #include <asm/io.h>
  10. #include <asm/pci-bridge.h>
  11. /*
  12. * Here comes the ppc64 implementation of the IOMAP
  13. * interfaces.
  14. */
  15. unsigned int ioread8(void __iomem *addr)
  16. {
  17. return readb(addr);
  18. }
  19. unsigned int ioread16(void __iomem *addr)
  20. {
  21. return readw(addr);
  22. }
  23. unsigned int ioread16be(void __iomem *addr)
  24. {
  25. return readw_be(addr);
  26. }
  27. unsigned int ioread32(void __iomem *addr)
  28. {
  29. return readl(addr);
  30. }
  31. unsigned int ioread32be(void __iomem *addr)
  32. {
  33. return readl_be(addr);
  34. }
  35. EXPORT_SYMBOL(ioread8);
  36. EXPORT_SYMBOL(ioread16);
  37. EXPORT_SYMBOL(ioread16be);
  38. EXPORT_SYMBOL(ioread32);
  39. EXPORT_SYMBOL(ioread32be);
  40. #ifdef __powerpc64__
  41. u64 ioread64(void __iomem *addr)
  42. {
  43. return readq(addr);
  44. }
  45. u64 ioread64be(void __iomem *addr)
  46. {
  47. return readq_be(addr);
  48. }
  49. EXPORT_SYMBOL(ioread64);
  50. EXPORT_SYMBOL(ioread64be);
  51. #endif /* __powerpc64__ */
  52. void iowrite8(u8 val, void __iomem *addr)
  53. {
  54. writeb(val, addr);
  55. }
  56. void iowrite16(u16 val, void __iomem *addr)
  57. {
  58. writew(val, addr);
  59. }
  60. void iowrite16be(u16 val, void __iomem *addr)
  61. {
  62. writew_be(val, addr);
  63. }
  64. void iowrite32(u32 val, void __iomem *addr)
  65. {
  66. writel(val, addr);
  67. }
  68. void iowrite32be(u32 val, void __iomem *addr)
  69. {
  70. writel_be(val, addr);
  71. }
  72. EXPORT_SYMBOL(iowrite8);
  73. EXPORT_SYMBOL(iowrite16);
  74. EXPORT_SYMBOL(iowrite16be);
  75. EXPORT_SYMBOL(iowrite32);
  76. EXPORT_SYMBOL(iowrite32be);
  77. #ifdef __powerpc64__
  78. void iowrite64(u64 val, void __iomem *addr)
  79. {
  80. writeq(val, addr);
  81. }
  82. void iowrite64be(u64 val, void __iomem *addr)
  83. {
  84. writeq_be(val, addr);
  85. }
  86. EXPORT_SYMBOL(iowrite64);
  87. EXPORT_SYMBOL(iowrite64be);
  88. #endif /* __powerpc64__ */
  89. /*
  90. * These are the "repeat read/write" functions. Note the
  91. * non-CPU byte order. We do things in "IO byteorder"
  92. * here.
  93. *
  94. * FIXME! We could make these do EEH handling if we really
  95. * wanted. Not clear if we do.
  96. */
  97. void ioread8_rep(void __iomem *addr, void *dst, unsigned long count)
  98. {
  99. readsb(addr, dst, count);
  100. }
  101. void ioread16_rep(void __iomem *addr, void *dst, unsigned long count)
  102. {
  103. readsw(addr, dst, count);
  104. }
  105. void ioread32_rep(void __iomem *addr, void *dst, unsigned long count)
  106. {
  107. readsl(addr, dst, count);
  108. }
  109. EXPORT_SYMBOL(ioread8_rep);
  110. EXPORT_SYMBOL(ioread16_rep);
  111. EXPORT_SYMBOL(ioread32_rep);
  112. void iowrite8_rep(void __iomem *addr, const void *src, unsigned long count)
  113. {
  114. writesb(addr, src, count);
  115. }
  116. void iowrite16_rep(void __iomem *addr, const void *src, unsigned long count)
  117. {
  118. writesw(addr, src, count);
  119. }
  120. void iowrite32_rep(void __iomem *addr, const void *src, unsigned long count)
  121. {
  122. writesl(addr, src, count);
  123. }
  124. EXPORT_SYMBOL(iowrite8_rep);
  125. EXPORT_SYMBOL(iowrite16_rep);
  126. EXPORT_SYMBOL(iowrite32_rep);
  127. void __iomem *ioport_map(unsigned long port, unsigned int len)
  128. {
  129. return (void __iomem *) (port + _IO_BASE);
  130. }
  131. void ioport_unmap(void __iomem *addr)
  132. {
  133. /* Nothing to do */
  134. }
  135. EXPORT_SYMBOL(ioport_map);
  136. EXPORT_SYMBOL(ioport_unmap);
  137. #ifdef CONFIG_PCI
  138. void pci_iounmap(struct pci_dev *dev, void __iomem *addr)
  139. {
  140. if (isa_vaddr_is_ioport(addr))
  141. return;
  142. if (pcibios_vaddr_is_ioport(addr))
  143. return;
  144. iounmap(addr);
  145. }
  146. EXPORT_SYMBOL(pci_iounmap);
  147. #endif /* CONFIG_PCI */