iomap.c 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  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. void iowrite8(u8 val, void __iomem *addr)
  41. {
  42. writeb(val, addr);
  43. }
  44. void iowrite16(u16 val, void __iomem *addr)
  45. {
  46. writew(val, addr);
  47. }
  48. void iowrite16be(u16 val, void __iomem *addr)
  49. {
  50. writew_be(val, addr);
  51. }
  52. void iowrite32(u32 val, void __iomem *addr)
  53. {
  54. writel(val, addr);
  55. }
  56. void iowrite32be(u32 val, void __iomem *addr)
  57. {
  58. writel_be(val, addr);
  59. }
  60. EXPORT_SYMBOL(iowrite8);
  61. EXPORT_SYMBOL(iowrite16);
  62. EXPORT_SYMBOL(iowrite16be);
  63. EXPORT_SYMBOL(iowrite32);
  64. EXPORT_SYMBOL(iowrite32be);
  65. /*
  66. * These are the "repeat read/write" functions. Note the
  67. * non-CPU byte order. We do things in "IO byteorder"
  68. * here.
  69. *
  70. * FIXME! We could make these do EEH handling if we really
  71. * wanted. Not clear if we do.
  72. */
  73. void ioread8_rep(void __iomem *addr, void *dst, unsigned long count)
  74. {
  75. readsb(addr, dst, count);
  76. }
  77. void ioread16_rep(void __iomem *addr, void *dst, unsigned long count)
  78. {
  79. readsw(addr, dst, count);
  80. }
  81. void ioread32_rep(void __iomem *addr, void *dst, unsigned long count)
  82. {
  83. readsl(addr, dst, count);
  84. }
  85. EXPORT_SYMBOL(ioread8_rep);
  86. EXPORT_SYMBOL(ioread16_rep);
  87. EXPORT_SYMBOL(ioread32_rep);
  88. void iowrite8_rep(void __iomem *addr, const void *src, unsigned long count)
  89. {
  90. writesb(addr, src, count);
  91. }
  92. void iowrite16_rep(void __iomem *addr, const void *src, unsigned long count)
  93. {
  94. writesw(addr, src, count);
  95. }
  96. void iowrite32_rep(void __iomem *addr, const void *src, unsigned long count)
  97. {
  98. writesl(addr, src, count);
  99. }
  100. EXPORT_SYMBOL(iowrite8_rep);
  101. EXPORT_SYMBOL(iowrite16_rep);
  102. EXPORT_SYMBOL(iowrite32_rep);
  103. void __iomem *ioport_map(unsigned long port, unsigned int len)
  104. {
  105. return (void __iomem *) (port + _IO_BASE);
  106. }
  107. void ioport_unmap(void __iomem *addr)
  108. {
  109. /* Nothing to do */
  110. }
  111. EXPORT_SYMBOL(ioport_map);
  112. EXPORT_SYMBOL(ioport_unmap);
  113. #ifdef CONFIG_PCI
  114. void pci_iounmap(struct pci_dev *dev, void __iomem *addr)
  115. {
  116. if (isa_vaddr_is_ioport(addr))
  117. return;
  118. if (pcibios_vaddr_is_ioport(addr))
  119. return;
  120. iounmap(addr);
  121. }
  122. EXPORT_SYMBOL(pci_iounmap);
  123. #endif /* CONFIG_PCI */