io.c 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. /*
  2. * Copyright (C) 2002 David McCullough <davidm@snapgear.com>
  3. * Copyright (C) 2001 Ian da Silva, Jeremy Siegel
  4. * Based largely on io_se.c.
  5. *
  6. * I/O routine for Hitachi 7751 SolutionEngine.
  7. *
  8. * Initial version only to support LAN access; some
  9. * placeholder code from io_se.c left in with the
  10. * expectation of later SuperIO and PCMCIA access.
  11. */
  12. #include <linux/kernel.h>
  13. #include <linux/types.h>
  14. #include <linux/pci.h>
  15. #include <asm/io.h>
  16. #include <asm/addrspace.h>
  17. #ifdef CONFIG_SH_SECUREEDGE5410
  18. unsigned short secureedge5410_ioport;
  19. #endif
  20. static inline volatile __u16 *port2adr(unsigned int port)
  21. {
  22. maybebadio((unsigned long)port);
  23. return (volatile __u16*)port;
  24. }
  25. /*
  26. * General outline: remap really low stuff [eventually] to SuperIO,
  27. * stuff in PCI IO space (at or above window at pci.h:PCIBIOS_MIN_IO)
  28. * is mapped through the PCI IO window. Stuff with high bits (PXSEG)
  29. * should be way beyond the window, and is used w/o translation for
  30. * compatibility.
  31. */
  32. unsigned char snapgear_inb(unsigned long port)
  33. {
  34. if (PXSEG(port))
  35. return *(volatile unsigned char *)port;
  36. else if (is_pci_ioaddr(port))
  37. return *(volatile unsigned char *)pci_ioaddr(port);
  38. else
  39. return (*port2adr(port)) & 0xff;
  40. }
  41. unsigned char snapgear_inb_p(unsigned long port)
  42. {
  43. unsigned char v;
  44. if (PXSEG(port))
  45. v = *(volatile unsigned char *)port;
  46. else if (is_pci_ioaddr(port))
  47. v = *(volatile unsigned char *)pci_ioaddr(port);
  48. else
  49. v = (*port2adr(port))&0xff;
  50. ctrl_delay();
  51. return v;
  52. }
  53. unsigned short snapgear_inw(unsigned long port)
  54. {
  55. if (PXSEG(port))
  56. return *(volatile unsigned short *)port;
  57. else if (is_pci_ioaddr(port))
  58. return *(volatile unsigned short *)pci_ioaddr(port);
  59. else if (port >= 0x2000)
  60. return *port2adr(port);
  61. else
  62. maybebadio(port);
  63. return 0;
  64. }
  65. unsigned int snapgear_inl(unsigned long port)
  66. {
  67. if (PXSEG(port))
  68. return *(volatile unsigned long *)port;
  69. else if (is_pci_ioaddr(port))
  70. return *(volatile unsigned int *)pci_ioaddr(port);
  71. else if (port >= 0x2000)
  72. return *port2adr(port);
  73. else
  74. maybebadio(port);
  75. return 0;
  76. }
  77. void snapgear_outb(unsigned char value, unsigned long port)
  78. {
  79. if (PXSEG(port))
  80. *(volatile unsigned char *)port = value;
  81. else if (is_pci_ioaddr(port))
  82. *((unsigned char*)pci_ioaddr(port)) = value;
  83. else
  84. *(port2adr(port)) = value;
  85. }
  86. void snapgear_outb_p(unsigned char value, unsigned long port)
  87. {
  88. if (PXSEG(port))
  89. *(volatile unsigned char *)port = value;
  90. else if (is_pci_ioaddr(port))
  91. *((unsigned char*)pci_ioaddr(port)) = value;
  92. else
  93. *(port2adr(port)) = value;
  94. ctrl_delay();
  95. }
  96. void snapgear_outw(unsigned short value, unsigned long port)
  97. {
  98. if (PXSEG(port))
  99. *(volatile unsigned short *)port = value;
  100. else if (is_pci_ioaddr(port))
  101. *((unsigned short *)pci_ioaddr(port)) = value;
  102. else if (port >= 0x2000)
  103. *port2adr(port) = value;
  104. else
  105. maybebadio(port);
  106. }
  107. void snapgear_outl(unsigned int value, unsigned long port)
  108. {
  109. if (PXSEG(port))
  110. *(volatile unsigned long *)port = value;
  111. else if (is_pci_ioaddr(port))
  112. *((unsigned long*)pci_ioaddr(port)) = value;
  113. else
  114. maybebadio(port);
  115. }
  116. void snapgear_insl(unsigned long port, void *addr, unsigned long count)
  117. {
  118. maybebadio(port);
  119. }
  120. void snapgear_outsl(unsigned long port, const void *addr, unsigned long count)
  121. {
  122. maybebadio(port);
  123. }