tor2-hw.h 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. /*
  2. * Tormenta 2 Quad-T1 PCI Driver
  3. *
  4. * Written by Mark Spencer <markster@linux-suppot.net>
  5. *
  6. * Copyright (C) 2001 Jim Dixon / Zapata Telephony.
  7. * Copyright (C) 2001-2008, Digium, Inc.
  8. *
  9. * All rights reserved.
  10. *
  11. */
  12. /*
  13. * See http://www.asterisk.org for more information about
  14. * the Asterisk project. Please do not directly contact
  15. * any of the maintainers of this project for assistance;
  16. * the project provides a web site, mailing lists and IRC
  17. * channels for your use.
  18. *
  19. * This program is free software, distributed under the terms of
  20. * the GNU General Public License Version 2 as published by the
  21. * Free Software Foundation. See the LICENSE file included with
  22. * this program for more details.
  23. */
  24. #ifndef _TOR2_HW_H
  25. #define _TOR2_HW_H
  26. /*
  27. * The Tormenta two consists of the following block architecture:
  28. *
  29. * [ Spartan ] --- [ DS 21Q352 ] -- Xfrms -- Span 1
  30. * | | | | | | |
  31. * Local Bus +----- Span 2
  32. * | | | |
  33. * [ PCI 9030 ] +----- Span 3
  34. * | | | | | |
  35. * PCI BUS +----- Span 4
  36. *
  37. * All communicatiosn to the framer (21Q352) are performed
  38. * through the PCI 9030 part using memory mapped I/O.
  39. *
  40. * The Tormenta 2 requires a 2 2k wondows memory space
  41. * which is mapped as follows:
  42. *
  43. * First (32 bit) space:
  44. *
  45. * 0x0000 -> 0x07FF: Memory map of Tx and Rx buffers. They are stored
  46. * with increasing channel number, with each span in
  47. * a byte of a 32-bit long word:
  48. * Bits 31-24: Span 1
  49. * Bits 23-16: Span 2
  50. * Bits 16- 8: Span 3
  51. * Bits 7- 0: Span 4
  52. *
  53. *
  54. * Second (8 bit) space:
  55. *
  56. * 0x0000 -> 0x00FF: Registers for Transceiver 1
  57. * 0x0100 -> 0x01FF: Registers for Transceiver 2
  58. * 0x0200 -> 0x02FF: Registers for Transceiver 3
  59. * 0x0300 -> 0x03FF: Registers for Transceiver 4
  60. *
  61. * 0x400 Write -> Firmware load location for Xilinx. This is the only valid
  62. * register until the Xilinx is programmed to decode
  63. * the remainder!
  64. *
  65. * 0x400 Write -> clkreg (sync source)
  66. * 0=free run, 1=span 1, 2=span 2, 3=span 3, 4=span 4.
  67. *
  68. * 0x400 Read -> statreg
  69. * bit 0 - Interrupt Enabled
  70. * bit 1 - Interrupt Active
  71. * bit 2 - Dallas Interrupt Active
  72. *
  73. * 0x401 Write -> ctlreg as follows:
  74. * bit 0 - Interrupt Enable
  75. * bit 1 - Drives "TEST1" signal ("Interrupt" outbit)
  76. * bit 2 - Dallas Interrupt Enable (Allows DINT signal to drive INT)
  77. * bit 3 - External Syncronization Enable (MASTER signal).
  78. * bit 4 - Select E1 Divisor Mode (0 for T1, 1 for E1).
  79. * bit 5 - Remote serial loopback (When set to 1, TSER is driven from RSER)
  80. * bit 6 - Local serial loopback (When set to 1, Rx buffers are driven from Tx buffers)
  81. * bit 7 - Interrupt Acknowledge (set to 1 to acknowledge interrupt)
  82. *
  83. * 0x402 Write -> LED register as follows:
  84. * bit 0 - Span 1 Green
  85. * bit 1 - Span 1 Red
  86. * bit 2 - Span 2 Green
  87. * bit 3 - Span 2 Red
  88. * bit 4 - Span 3 Green
  89. * bit 5 - Span 3 Red
  90. * bit 6 - Span 4 Green
  91. * bit 7 - Span 4 Red
  92. * NOTE: turning on both red and green yields yellow.
  93. *
  94. * 0x403 Write -> TEST2, writing to bit 0 drives TEST2 pin.
  95. *
  96. * 0x404 Write -> ctlreg1 as follows:
  97. * bit 0 - Non-REV.A Mode (Set this bit for Dallas chips later then Rev. A)
  98. */
  99. #ifdef NEED_PCI_IDS
  100. /*
  101. * Provide routines for identifying a tormenta card
  102. */
  103. #define PCI_VENDOR_ID_PLX 0x10b5
  104. #ifdef __KERNEL__
  105. static DEFINE_PCI_DEVICE_TABLE(tor2_pci_ids) =
  106. #else
  107. #define PCI_ANY_ID -1
  108. static struct tor2_pci_id {
  109. int vendor;
  110. int device;
  111. int subvendor;
  112. int subdevice;
  113. int class;
  114. int classmask;
  115. unsigned long driver_data;
  116. } tor2_pci_ids[] =
  117. #endif /* __KERNEL__ */
  118. {
  119. { PCI_VENDOR_ID_PLX, 0x9030, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (unsigned long)"PLX 9030" }, /* PLX 9030 Development board */
  120. { PCI_VENDOR_ID_PLX, 0x3001, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (unsigned long)"PLX Development Board" }, /* PLX 9030 Development board */
  121. { PCI_VENDOR_ID_PLX, 0xD00D, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (unsigned long)"Tormenta 2 Quad T1/PRI or E1/PRA" }, /* Tormenta 2 */
  122. { PCI_VENDOR_ID_PLX, 0x4000, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (unsigned long)"Tormenta 2 Quad T1/E1 (non-Digium clone)" }, /* Tormenta 2 clone */
  123. { 0, }
  124. };
  125. #ifndef __KERNEL__
  126. /* We provide a simple routine to match the given ID's */
  127. static inline int tor2_pci_match(int vendorid, int deviceid, char **variant)
  128. {
  129. /* Returns 1 if this is a tormenta card or 0 if it isn't */
  130. int x;
  131. for (x = 0; x< sizeof(tor2_pci_ids) / sizeof(tor2_pci_ids[0]); x++)
  132. if (((tor2_pci_ids[x].vendor == PCI_ANY_ID) ||
  133. (tor2_pci_ids[x].vendor == vendorid)) &&
  134. ((tor2_pci_ids[x].device == PCI_ANY_ID) ||
  135. (tor2_pci_ids[x].device == deviceid))) {
  136. *variant = (char *)tor2_pci_ids[x].driver_data;
  137. return 1;
  138. }
  139. if (variant)
  140. *variant = NULL;
  141. return 0;
  142. }
  143. #endif /* __KERNEL__ */
  144. #endif /* NEED_PCI_IDS */
  145. /*
  146. * PLX PCI9030 PCI Configuration Registers
  147. *
  148. * This is not an all-inclusive list, just some interesting ones
  149. * that we need and that are not standard.
  150. *
  151. */
  152. #define PLX_PCI_VPD_ADDR 0x4e /* Set address here */
  153. #define PLX_PCI_VPD_DATA 0x50 /* Read/Write data here */
  154. #define PLX_LOC_WP_BOUNDARY 0x4e /* Bits 6-0 here */
  155. #define PLX_LOC_GPIOC 0x54 /* GPIO control register */
  156. /* The 4 GPIO data bits we are interested in */
  157. #define LOC_GPIOC_GPIO4 0x4000 /* GPIO4 data */
  158. #define LOC_GPIOC_GPIO5 0x20000 /* GPIO5 data */
  159. #define LOC_GPIOC_GPIO6 0x100000 /* GPIO6 data */
  160. #define LOC_GPIOC_GPIO7 0x800000 /* GPIO7 data */
  161. /* define the initialization of the GPIOC register */
  162. #define LOC_GPIOC_INIT_VALUE 0x2036000 /* GPIO 4&5 in write and
  163. both high and GPIO 8 in write low */
  164. /* The defines by what they actually do */
  165. #define GPIO_WRITE LOC_GPIOC_GPIO4
  166. #define GPIO_PROGRAM LOC_GPIOC_GPIO5
  167. #define GPIO_INIT LOC_GPIOC_GPIO6
  168. #define GPIO_DONE LOC_GPIOC_GPIO7
  169. #endif /* _TOR2_HW_H */