io.c 3.4 KB

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