rio_linux.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  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. #include <linux/config.h>
  26. #define RIO_NBOARDS 4
  27. #define RIO_PORTSPERBOARD 128
  28. #define RIO_NPORTS (RIO_NBOARDS * RIO_PORTSPERBOARD)
  29. #define MODEM_SUPPORT
  30. #ifdef __KERNEL__
  31. #define RIO_MAGIC 0x12345678
  32. struct vpd_prom {
  33. unsigned short id;
  34. char hwrev;
  35. char hwass;
  36. int uniqid;
  37. char myear;
  38. char mweek;
  39. char hw_feature[5];
  40. char oem_id;
  41. char identifier[16];
  42. };
  43. #define RIO_DEBUG_ALL 0xffffffff
  44. #define O_OTHER(tty) \
  45. ((O_OLCUC(tty)) ||\
  46. (O_ONLCR(tty)) ||\
  47. (O_OCRNL(tty)) ||\
  48. (O_ONOCR(tty)) ||\
  49. (O_ONLRET(tty)) ||\
  50. (O_OFILL(tty)) ||\
  51. (O_OFDEL(tty)) ||\
  52. (O_NLDLY(tty)) ||\
  53. (O_CRDLY(tty)) ||\
  54. (O_TABDLY(tty)) ||\
  55. (O_BSDLY(tty)) ||\
  56. (O_VTDLY(tty)) ||\
  57. (O_FFDLY(tty)))
  58. /* Same for input. */
  59. #define I_OTHER(tty) \
  60. ((I_INLCR(tty)) ||\
  61. (I_IGNCR(tty)) ||\
  62. (I_ICRNL(tty)) ||\
  63. (I_IUCLC(tty)) ||\
  64. (L_ISIG(tty)))
  65. #endif /* __KERNEL__ */
  66. #define RIO_BOARD_INTR_LOCK 1
  67. #ifndef RIOCTL_MISC_MINOR
  68. /* Allow others to gather this into "major.h" or something like that */
  69. #define RIOCTL_MISC_MINOR 169
  70. #endif
  71. /* Allow us to debug "in the field" without requiring clients to
  72. recompile.... */
  73. #if 1
  74. #define rio_spin_lock_irqsave(sem, flags) do { \
  75. rio_dprintk (RIO_DEBUG_SPINLOCK, "spinlockirqsave: %p %s:%d\n", \
  76. sem, __FILE__, __LINE__);\
  77. spin_lock_irqsave(sem, flags);\
  78. } while (0)
  79. #define rio_spin_unlock_irqrestore(sem, flags) do { \
  80. rio_dprintk (RIO_DEBUG_SPINLOCK, "spinunlockirqrestore: %p %s:%d\n",\
  81. sem, __FILE__, __LINE__);\
  82. spin_unlock_irqrestore(sem, flags);\
  83. } while (0)
  84. #define rio_spin_lock(sem) do { \
  85. rio_dprintk (RIO_DEBUG_SPINLOCK, "spinlock: %p %s:%d\n",\
  86. sem, __FILE__, __LINE__);\
  87. spin_lock(sem);\
  88. } while (0)
  89. #define rio_spin_unlock(sem) do { \
  90. rio_dprintk (RIO_DEBUG_SPINLOCK, "spinunlock: %p %s:%d\n",\
  91. sem, __FILE__, __LINE__);\
  92. spin_unlock(sem);\
  93. } while (0)
  94. #else
  95. #define rio_spin_lock_irqsave(sem, flags) \
  96. spin_lock_irqsave(sem, flags)
  97. #define rio_spin_unlock_irqrestore(sem, flags) \
  98. spin_unlock_irqrestore(sem, flags)
  99. #define rio_spin_lock(sem) \
  100. spin_lock(sem)
  101. #define rio_spin_unlock(sem) \
  102. spin_unlock(sem)
  103. #endif
  104. #ifdef CONFIG_RIO_OLDPCI
  105. static inline void *rio_memcpy_toio(void *dummy, void *dest, void *source, int n)
  106. {
  107. char *dst = dest;
  108. char *src = source;
  109. while (n--) {
  110. writeb(*src++, dst++);
  111. (void) readb(dummy);
  112. }
  113. return dest;
  114. }
  115. static inline void *rio_memcpy_fromio(void *dest, void *source, int n)
  116. {
  117. char *dst = dest;
  118. char *src = source;
  119. while (n--)
  120. *dst++ = readb(src++);
  121. return dest;
  122. }
  123. #else
  124. #define rio_memcpy_toio(dummy,dest,source,n) memcpy_toio(dest, source, n)
  125. #define rio_memcpy_fromio memcpy_fromio
  126. #endif
  127. #define DEBUG 1
  128. /*
  129. This driver can spew a whole lot of debugging output at you. If you
  130. need maximum performance, you should disable the DEBUG define. To
  131. aid in debugging in the field, I'm leaving the compile-time debug
  132. features enabled, and disable them "runtime". That allows me to
  133. instruct people with problems to enable debugging without requiring
  134. them to recompile...
  135. */
  136. #ifdef DEBUG
  137. #define rio_dprintk(f, str...) do { if (rio_debug & f) printk (str);} while (0)
  138. #define func_enter() rio_dprintk (RIO_DEBUG_FLOW, "rio: enter %s\n", __FUNCTION__)
  139. #define func_exit() rio_dprintk (RIO_DEBUG_FLOW, "rio: exit %s\n", __FUNCTION__)
  140. #define func_enter2() rio_dprintk (RIO_DEBUG_FLOW, "rio: enter %s (port %d)\n",__FUNCTION__, port->line)
  141. #else
  142. #define rio_dprintk(f, str...) /* nothing */
  143. #define func_enter()
  144. #define func_exit()
  145. #define func_enter2()
  146. #endif