io.c 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. /*
  2. * I/O routines for Titan
  3. */
  4. #include <linux/pci.h>
  5. #include <asm/machvec.h>
  6. #include <asm/addrspace.h>
  7. #include <mach/titan.h>
  8. #include <asm/io.h>
  9. static inline unsigned int port2adr(unsigned int port)
  10. {
  11. maybebadio((unsigned long)port);
  12. return port;
  13. }
  14. u8 titan_inb(unsigned long port)
  15. {
  16. if (PXSEG(port))
  17. return ctrl_inb(port);
  18. else if (is_pci_ioaddr(port))
  19. return ctrl_inb(pci_ioaddr(port));
  20. return ctrl_inw(port2adr(port)) & 0xff;
  21. }
  22. u8 titan_inb_p(unsigned long port)
  23. {
  24. u8 v;
  25. if (PXSEG(port))
  26. v = ctrl_inb(port);
  27. else if (is_pci_ioaddr(port))
  28. v = ctrl_inb(pci_ioaddr(port));
  29. else
  30. v = ctrl_inw(port2adr(port)) & 0xff;
  31. ctrl_delay();
  32. return v;
  33. }
  34. u16 titan_inw(unsigned long port)
  35. {
  36. if (PXSEG(port))
  37. return ctrl_inw(port);
  38. else if (is_pci_ioaddr(port))
  39. return ctrl_inw(pci_ioaddr(port));
  40. else if (port >= 0x2000)
  41. return ctrl_inw(port2adr(port));
  42. else
  43. maybebadio(port);
  44. return 0;
  45. }
  46. u32 titan_inl(unsigned long port)
  47. {
  48. if (PXSEG(port))
  49. return ctrl_inl(port);
  50. else if (is_pci_ioaddr(port))
  51. return ctrl_inl(pci_ioaddr(port));
  52. else if (port >= 0x2000)
  53. return ctrl_inw(port2adr(port));
  54. else
  55. maybebadio(port);
  56. return 0;
  57. }
  58. void titan_outb(u8 value, unsigned long port)
  59. {
  60. if (PXSEG(port))
  61. ctrl_outb(value, port);
  62. else if (is_pci_ioaddr(port))
  63. ctrl_outb(value, pci_ioaddr(port));
  64. else
  65. ctrl_outw(value, port2adr(port));
  66. }
  67. void titan_outb_p(u8 value, unsigned long port)
  68. {
  69. if (PXSEG(port))
  70. ctrl_outb(value, port);
  71. else if (is_pci_ioaddr(port))
  72. ctrl_outb(value, pci_ioaddr(port));
  73. else
  74. ctrl_outw(value, port2adr(port));
  75. ctrl_delay();
  76. }
  77. void titan_outw(u16 value, unsigned long port)
  78. {
  79. if (PXSEG(port))
  80. ctrl_outw(value, port);
  81. else if (is_pci_ioaddr(port))
  82. ctrl_outw(value, pci_ioaddr(port));
  83. else if (port >= 0x2000)
  84. ctrl_outw(value, port2adr(port));
  85. else
  86. maybebadio(port);
  87. }
  88. void titan_outl(u32 value, unsigned long port)
  89. {
  90. if (PXSEG(port))
  91. ctrl_outl(value, port);
  92. else if (is_pci_ioaddr(port))
  93. ctrl_outl(value, pci_ioaddr(port));
  94. else
  95. maybebadio(port);
  96. }
  97. void titan_insl(unsigned long port, void *dst, unsigned long count)
  98. {
  99. maybebadio(port);
  100. }
  101. void titan_outsl(unsigned long port, const void *src, unsigned long count)
  102. {
  103. maybebadio(port);
  104. }
  105. void __iomem *titan_ioport_map(unsigned long port, unsigned int size)
  106. {
  107. if (PXSEG(port) || is_pci_memaddr(port))
  108. return (void __iomem *)port;
  109. else if (is_pci_ioaddr(port))
  110. return (void __iomem *)pci_ioaddr(port);
  111. return (void __iomem *)port2adr(port);
  112. }