io.c 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  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
  37. return (*port2adr(port)) & 0xff;
  38. }
  39. unsigned char snapgear_inb_p(unsigned long port)
  40. {
  41. unsigned char v;
  42. if (PXSEG(port))
  43. v = *(volatile unsigned char *)port;
  44. else
  45. v = (*port2adr(port))&0xff;
  46. ctrl_delay();
  47. return v;
  48. }
  49. unsigned short snapgear_inw(unsigned long port)
  50. {
  51. if (PXSEG(port))
  52. return *(volatile unsigned short *)port;
  53. else if (port >= 0x2000)
  54. return *port2adr(port);
  55. else
  56. maybebadio(port);
  57. return 0;
  58. }
  59. unsigned int snapgear_inl(unsigned long port)
  60. {
  61. if (PXSEG(port))
  62. return *(volatile unsigned long *)port;
  63. else if (port >= 0x2000)
  64. return *port2adr(port);
  65. else
  66. maybebadio(port);
  67. return 0;
  68. }
  69. void snapgear_outb(unsigned char value, unsigned long port)
  70. {
  71. if (PXSEG(port))
  72. *(volatile unsigned char *)port = value;
  73. else
  74. *(port2adr(port)) = value;
  75. }
  76. void snapgear_outb_p(unsigned char value, unsigned long port)
  77. {
  78. if (PXSEG(port))
  79. *(volatile unsigned char *)port = value;
  80. else
  81. *(port2adr(port)) = value;
  82. ctrl_delay();
  83. }
  84. void snapgear_outw(unsigned short value, unsigned long port)
  85. {
  86. if (PXSEG(port))
  87. *(volatile unsigned short *)port = value;
  88. else if (port >= 0x2000)
  89. *port2adr(port) = value;
  90. else
  91. maybebadio(port);
  92. }
  93. void snapgear_outl(unsigned int value, unsigned long port)
  94. {
  95. if (PXSEG(port))
  96. *(volatile unsigned long *)port = value;
  97. else
  98. maybebadio(port);
  99. }
  100. void snapgear_insl(unsigned long port, void *addr, unsigned long count)
  101. {
  102. maybebadio(port);
  103. }
  104. void snapgear_outsl(unsigned long port, const void *addr, unsigned long count)
  105. {
  106. maybebadio(port);
  107. }