io.c 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. /* $Id: io.c,v 1.5 2004/02/22 23:08:43 kkojima Exp $
  2. *
  3. * linux/arch/sh/boards/se/7206/io.c
  4. *
  5. * Copyright (C) 2006 Yoshinori Sato
  6. *
  7. * I/O routine for Hitachi 7206 SolutionEngine.
  8. *
  9. */
  10. #include <linux/kernel.h>
  11. #include <linux/types.h>
  12. #include <asm/io.h>
  13. #include <asm/se7206.h>
  14. static inline void delay(void)
  15. {
  16. ctrl_inw(0x20000000); /* P2 ROM Area */
  17. }
  18. /* MS7750 requires special versions of in*, out* routines, since
  19. PC-like io ports are located at upper half byte of 16-bit word which
  20. can be accessed only with 16-bit wide. */
  21. static inline volatile __u16 *
  22. port2adr(unsigned int port)
  23. {
  24. if (port >= 0x2000)
  25. return (volatile __u16 *) (PA_MRSHPC + (port - 0x2000));
  26. else if (port >= 0x300 || port < 0x310)
  27. return (volatile __u16 *) (PA_SMSC + (port - 0x300));
  28. }
  29. unsigned char se7206_inb(unsigned long port)
  30. {
  31. return (*port2adr(port))&0xff;
  32. }
  33. unsigned char se7206_inb_p(unsigned long port)
  34. {
  35. unsigned long v;
  36. v = (*port2adr(port))&0xff;
  37. delay();
  38. return v;
  39. }
  40. unsigned short se7206_inw(unsigned long port)
  41. {
  42. return *port2adr(port);;
  43. }
  44. unsigned int se7206_inl(unsigned long port)
  45. {
  46. maybebadio(port);
  47. return 0;
  48. }
  49. void se7206_outb(unsigned char value, unsigned long port)
  50. {
  51. *(port2adr(port)) = value;
  52. }
  53. void se7206_outb_p(unsigned char value, unsigned long port)
  54. {
  55. *(port2adr(port)) = value;
  56. delay();
  57. }
  58. void se7206_outw(unsigned short value, unsigned long port)
  59. {
  60. *port2adr(port) = value;
  61. }
  62. void se7206_outl(unsigned int value, unsigned long port)
  63. {
  64. maybebadio(port);
  65. }
  66. void se7206_insb(unsigned long port, void *addr, unsigned long count)
  67. {
  68. volatile __u16 *p = port2adr(port);
  69. __u8 *ap = addr;
  70. while (count--)
  71. *ap++ = *p;
  72. }
  73. void se7206_insw(unsigned long port, void *addr, unsigned long count)
  74. {
  75. volatile __u16 *p = port2adr(port);
  76. __u16 *ap = addr;
  77. while (count--)
  78. *ap++ = *p;
  79. }
  80. void se7206_insl(unsigned long port, void *addr, unsigned long count)
  81. {
  82. maybebadio(port);
  83. }
  84. void se7206_outsb(unsigned long port, const void *addr, unsigned long count)
  85. {
  86. volatile __u16 *p = port2adr(port);
  87. const __u8 *ap = addr;
  88. while (count--)
  89. *p = *ap++;
  90. }
  91. void se7206_outsw(unsigned long port, const void *addr, unsigned long count)
  92. {
  93. volatile __u16 *p = port2adr(port);
  94. const __u16 *ap = addr;
  95. while (count--)
  96. *p = *ap++;
  97. }
  98. void se7206_outsl(unsigned long port, const void *addr, unsigned long count)
  99. {
  100. maybebadio(port);
  101. }