rio_linux.h 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. /*
  2. * rio_linux.h
  3. *
  4. * Copyright (C) 1998,1999,2000 R.E.Wolff@BitWizard.nl
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, write to the Free Software
  18. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  19. *
  20. * RIO serial driver.
  21. *
  22. * Version 1.0 -- July, 1999.
  23. *
  24. */
  25. #define RIO_NBOARDS 4
  26. #define RIO_PORTSPERBOARD 128
  27. #define RIO_NPORTS (RIO_NBOARDS * RIO_PORTSPERBOARD)
  28. #define MODEM_SUPPORT
  29. #ifdef __KERNEL__
  30. #define RIO_MAGIC 0x12345678
  31. struct vpd_prom {
  32. unsigned short id;
  33. char hwrev;
  34. char hwass;
  35. int uniqid;
  36. char myear;
  37. char mweek;
  38. char hw_feature[5];
  39. char oem_id;
  40. char identifier[16];
  41. };
  42. #define RIO_DEBUG_ALL 0xffffffff
  43. #define O_OTHER(tty) \
  44. ((O_OLCUC(tty)) ||\
  45. (O_ONLCR(tty)) ||\
  46. (O_OCRNL(tty)) ||\
  47. (O_ONOCR(tty)) ||\
  48. (O_ONLRET(tty)) ||\
  49. (O_OFILL(tty)) ||\
  50. (O_OFDEL(tty)) ||\
  51. (O_NLDLY(tty)) ||\
  52. (O_CRDLY(tty)) ||\
  53. (O_TABDLY(tty)) ||\
  54. (O_BSDLY(tty)) ||\
  55. (O_VTDLY(tty)) ||\
  56. (O_FFDLY(tty)))
  57. /* Same for input. */
  58. #define I_OTHER(tty) \
  59. ((I_INLCR(tty)) ||\
  60. (I_IGNCR(tty)) ||\
  61. (I_ICRNL(tty)) ||\
  62. (I_IUCLC(tty)) ||\
  63. (L_ISIG(tty)))
  64. #endif /* __KERNEL__ */
  65. #define RIO_BOARD_INTR_LOCK 1
  66. #ifndef RIOCTL_MISC_MINOR
  67. /* Allow others to gather this into "major.h" or something like that */
  68. #define RIOCTL_MISC_MINOR 169
  69. #endif
  70. /* Allow us to debug "in the field" without requiring clients to
  71. recompile.... */
  72. #if 1
  73. #define rio_spin_lock_irqsave(sem, flags) do { \
  74. rio_dprintk (RIO_DEBUG_SPINLOCK, "spinlockirqsave: %p %s:%d\n", \
  75. sem, __FILE__, __LINE__);\
  76. spin_lock_irqsave(sem, flags);\
  77. } while (0)
  78. #define rio_spin_unlock_irqrestore(sem, flags) do { \
  79. rio_dprintk (RIO_DEBUG_SPINLOCK, "spinunlockirqrestore: %p %s:%d\n",\
  80. sem, __FILE__, __LINE__);\
  81. spin_unlock_irqrestore(sem, flags);\
  82. } while (0)
  83. #define rio_spin_lock(sem) do { \
  84. rio_dprintk (RIO_DEBUG_SPINLOCK, "spinlock: %p %s:%d\n",\
  85. sem, __FILE__, __LINE__);\
  86. spin_lock(sem);\
  87. } while (0)
  88. #define rio_spin_unlock(sem) do { \
  89. rio_dprintk (RIO_DEBUG_SPINLOCK, "spinunlock: %p %s:%d\n",\
  90. sem, __FILE__, __LINE__);\
  91. spin_unlock(sem);\
  92. } while (0)
  93. #else
  94. #define rio_spin_lock_irqsave(sem, flags) \
  95. spin_lock_irqsave(sem, flags)
  96. #define rio_spin_unlock_irqrestore(sem, flags) \
  97. spin_unlock_irqrestore(sem, flags)
  98. #define rio_spin_lock(sem) \
  99. spin_lock(sem)
  100. #define rio_spin_unlock(sem) \
  101. spin_unlock(sem)
  102. #endif
  103. #ifdef CONFIG_RIO_OLDPCI
  104. static inline void __iomem *rio_memcpy_toio(void __iomem *dummy, void __iomem *dest, void *source, int n)
  105. {
  106. char __iomem *dst = dest;
  107. char *src = source;
  108. while (n--) {
  109. writeb(*src++, dst++);
  110. (void) readb(dummy);
  111. }
  112. return dest;
  113. }
  114. static inline void __iomem *rio_copy_toio(void __iomem *dest, void *source, int n)
  115. {
  116. char __iomem *dst = dest;
  117. char *src = source;
  118. while (n--)
  119. writeb(*src++, dst++);
  120. return dest;
  121. }
  122. static inline void *rio_memcpy_fromio(void *dest, void __iomem *source, int n)
  123. {
  124. char *dst = dest;
  125. char __iomem *src = source;
  126. while (n--)
  127. *dst++ = readb(src++);
  128. return dest;
  129. }
  130. #else
  131. #define rio_memcpy_toio(dummy,dest,source,n) memcpy_toio(dest, source, n)
  132. #define rio_copy_toio memcpy_toio
  133. #define rio_memcpy_fromio memcpy_fromio
  134. #endif
  135. #define DEBUG 1
  136. /*
  137. This driver can spew a whole lot of debugging output at you. If you
  138. need maximum performance, you should disable the DEBUG define. To
  139. aid in debugging in the field, I'm leaving the compile-time debug
  140. features enabled, and disable them "runtime". That allows me to
  141. instruct people with problems to enable debugging without requiring
  142. them to recompile...
  143. */
  144. #ifdef DEBUG
  145. #define rio_dprintk(f, str...) do { if (rio_debug & f) printk (str);} while (0)
  146. #define func_enter() rio_dprintk (RIO_DEBUG_FLOW, "rio: enter %s\n", __FUNCTION__)
  147. #define func_exit() rio_dprintk (RIO_DEBUG_FLOW, "rio: exit %s\n", __FUNCTION__)
  148. #define func_enter2() rio_dprintk (RIO_DEBUG_FLOW, "rio: enter %s (port %d)\n",__FUNCTION__, port->line)
  149. #else
  150. #define rio_dprintk(f, str...) /* nothing */
  151. #define func_enter()
  152. #define func_exit()
  153. #define func_enter2()
  154. #endif