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