io.c 2.7 KB

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