| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
#ifndef _WCTDM24XXP_H |
| 27 |
#define _WCTDM24XXP_H |
| 28 |
|
| 29 |
#include <dahdi/kernel.h> |
| 30 |
|
| 31 |
#include <linux/version.h> |
| 32 |
#include <linux/semaphore.h> |
| 33 |
|
| 34 |
#include "voicebus/voicebus.h" |
| 35 |
|
| 36 |
#define NUM_FXO_REGS 60 |
| 37 |
|
| 38 |
#define WC_MAX_IFACES 128 |
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
#define DEFAULT_RING_DEBOUNCE 1024 |
| 44 |
#define POLARITY_DEBOUNCE 64 |
| 45 |
|
| 46 |
#define OHT_TIMER 6000 |
| 47 |
|
| 48 |
#define FLAG_EXPRESS (1 << 0) |
| 49 |
|
| 50 |
#define EFRAME_SIZE 108L |
| 51 |
#define EFRAME_GAP 20L |
| 52 |
#define SFRAME_SIZE ((EFRAME_SIZE * DAHDI_CHUNKSIZE) + (EFRAME_GAP * (DAHDI_CHUNKSIZE - 1))) |
| 53 |
|
| 54 |
#define MAX_ALARMS 10 |
| 55 |
|
| 56 |
#define MINPEGTIME 10 * 8 |
| 57 |
#define PEGTIME 50 * 8 |
| 58 |
#define PEGCOUNT 5 |
| 59 |
|
| 60 |
#define SDI_CLK (0x00010000) |
| 61 |
#define SDI_DOUT (0x00020000) |
| 62 |
#define SDI_DREAD (0x00040000) |
| 63 |
#define SDI_DIN (0x00080000) |
| 64 |
|
| 65 |
#define __CMD_RD (1 << 20) |
| 66 |
#define __CMD_WR (1 << 21) |
| 67 |
#define __CMD_FIN (1 << 22) |
| 68 |
#define __CMD_TX (1 << 23) |
| 69 |
|
| 70 |
#define CMD_WR(a,b) (((a) << 8) | (b) | __CMD_WR) |
| 71 |
#define CMD_RD(a) (((a) << 8) | __CMD_RD) |
| 72 |
|
| 73 |
#if 0 |
| 74 |
#define CMD_BYTE(card,bit,altcs) (((((card) & 0x3) * 3 + (bit)) * 7) \ |
| 75 |
+ ((card) >> 2) + (altcs) + ((altcs) ? -21 : 0)) |
| 76 |
#endif |
| 77 |
#define NUM_MODULES 24 |
| 78 |
#define NUM_SLOTS 6 |
| 79 |
#define MAX_SPANS 9 |
| 80 |
|
| 81 |
#define NUM_CAL_REGS 12 |
| 82 |
|
| 83 |
#define QRV_DEBOUNCETIME 20 |
| 84 |
|
| 85 |
#define VPM150M_HPI_CONTROL 0x00 |
| 86 |
#define VPM150M_HPI_ADDRESS 0x02 |
| 87 |
#define VPM150M_HPI_DATA 0x03 |
| 88 |
|
| 89 |
#define VPM_SUPPORT |
| 90 |
#define VPM150M_SUPPORT |
| 91 |
|
| 92 |
#ifdef VPM150M_SUPPORT |
| 93 |
#include "voicebus/GpakCust.h" |
| 94 |
#endif |
| 95 |
|
| 96 |
#include "voicebus/vpmoct.h" |
| 97 |
|
| 98 |
struct calregs { |
| 99 |
unsigned char vals[NUM_CAL_REGS]; |
| 100 |
}; |
| 101 |
|
| 102 |
enum battery_state { |
| 103 |
BATTERY_UNKNOWN = 0, |
| 104 |
BATTERY_DEBOUNCING_PRESENT, |
| 105 |
BATTERY_DEBOUNCING_PRESENT_FROM_LOST_ALARM, |
| 106 |
BATTERY_DEBOUNCING_PRESENT_ALARM, |
| 107 |
BATTERY_PRESENT, |
| 108 |
BATTERY_DEBOUNCING_LOST, |
| 109 |
BATTERY_DEBOUNCING_LOST_FROM_PRESENT_ALARM, |
| 110 |
BATTERY_DEBOUNCING_LOST_ALARM, |
| 111 |
BATTERY_LOST, |
| 112 |
}; |
| 113 |
|
| 114 |
enum ring_detector_state { |
| 115 |
RINGOFF = 0, |
| 116 |
DEBOUNCING_RINGING_POSITIVE, |
| 117 |
DEBOUNCING_RINGING_NEGATIVE, |
| 118 |
RINGING, |
| 119 |
DEBOUNCING_RINGOFF, |
| 120 |
}; |
| 121 |
|
| 122 |
enum polarity_state { |
| 123 |
UNKNOWN_POLARITY = 0, |
| 124 |
POLARITY_DEBOUNCE_POSITIVE, |
| 125 |
POLARITY_POSITIVE, |
| 126 |
POLARITY_DEBOUNCE_NEGATIVE, |
| 127 |
POLARITY_NEGATIVE, |
| 128 |
}; |
| 129 |
|
| 130 |
struct wctdm_cmd { |
| 131 |
struct list_head node; |
| 132 |
struct completion *complete; |
| 133 |
u32 cmd; |
| 134 |
u8 ident; |
| 135 |
}; |
| 136 |
|
| 137 |
|
| 138 |
|
| 139 |
|
| 140 |
|
| 141 |
|
| 142 |
|
| 143 |
|
| 144 |
|
| 145 |
|
| 146 |
|
| 147 |
|
| 148 |
|
| 149 |
struct wctdm_span { |
| 150 |
struct dahdi_span span; |
| 151 |
int timing_priority; |
| 152 |
int spanno; |
| 153 |
struct wctdm *wc; |
| 154 |
struct b400m_span *bspan; |
| 155 |
}; |
| 156 |
|
| 157 |
struct wctdm_chan { |
| 158 |
struct dahdi_chan chan; |
| 159 |
struct dahdi_echocan_state ec; |
| 160 |
int timeslot; |
| 161 |
unsigned int hwpreec_enabled:1; |
| 162 |
}; |
| 163 |
|
| 164 |
struct fxo { |
| 165 |
enum ring_detector_state ring_state:4; |
| 166 |
enum battery_state battery_state:4; |
| 167 |
enum polarity_state polarity_state:4; |
| 168 |
u8 ring_polarity_change_count:4; |
| 169 |
u8 hook_ring_shadow; |
| 170 |
s8 line_voltage_status; |
| 171 |
int offhook; |
| 172 |
int neonmwi_state; |
| 173 |
int neonmwi_last_voltage; |
| 174 |
unsigned int neonmwi_debounce; |
| 175 |
unsigned int neonmwi_offcounter; |
| 176 |
unsigned long display_fxovoltage; |
| 177 |
unsigned long ringdebounce_timer; |
| 178 |
unsigned long battdebounce_timer; |
| 179 |
unsigned long poldebounce_timer; |
| 180 |
}; |
| 181 |
|
| 182 |
struct fxs { |
| 183 |
u8 oht_active:1; |
| 184 |
u8 off_hook:1; |
| 185 |
int idletxhookstate; |
| 186 |
|
| 187 |
|
| 188 |
|
| 189 |
|
| 190 |
|
| 191 |
|
| 192 |
|
| 193 |
|
| 194 |
|
| 195 |
int lasttxhook; |
| 196 |
u8 linefeed_control_shadow; |
| 197 |
u8 hook_state_shadow; |
| 198 |
int palarms; |
| 199 |
struct dahdi_vmwi_info vmwisetting; |
| 200 |
int vmwi_active_messages; |
| 201 |
int vmwi_linereverse; |
| 202 |
int reversepolarity; |
| 203 |
struct calregs calregs; |
| 204 |
unsigned long check_alarm; |
| 205 |
unsigned long check_proslic; |
| 206 |
unsigned long oppending_timeout; |
| 207 |
unsigned long ohttimer; |
| 208 |
}; |
| 209 |
|
| 210 |
struct qrv { |
| 211 |
#define RADMODE_INVERTCOR 1 |
| 212 |
#define RADMODE_IGNORECOR 2 |
| 213 |
#define RADMODE_EXTTONE 4 |
| 214 |
#define RADMODE_EXTINVERT 8 |
| 215 |
#define RADMODE_IGNORECT 16 |
| 216 |
#define RADMODE_PREEMP 32 |
| 217 |
#define RADMODE_DEEMP 64 |
| 218 |
char hook; |
| 219 |
unsigned short debouncetime; |
| 220 |
unsigned short debtime; |
| 221 |
int radmode; |
| 222 |
signed short rxgain; |
| 223 |
signed short txgain; |
| 224 |
u8 isrshadow[3]; |
| 225 |
}; |
| 226 |
|
| 227 |
enum module_type { |
| 228 |
NONE = 0, |
| 229 |
FXS, |
| 230 |
FXO, |
| 231 |
FXSINIT, |
| 232 |
QRV, |
| 233 |
BRI, |
| 234 |
}; |
| 235 |
|
| 236 |
struct wctdm_module { |
| 237 |
union modtypes { |
| 238 |
struct fxo fxo; |
| 239 |
struct fxs fxs; |
| 240 |
struct qrv qrv; |
| 241 |
struct b400m *bri; |
| 242 |
} mod; |
| 243 |
|
| 244 |
|
| 245 |
struct list_head pending_cmds; |
| 246 |
struct list_head active_cmds; |
| 247 |
u8 offsets[3]; |
| 248 |
u8 subaddr; |
| 249 |
u8 card; |
| 250 |
|
| 251 |
enum module_type type; |
| 252 |
int sethook; |
| 253 |
int dacssrc; |
| 254 |
}; |
| 255 |
|
| 256 |
struct wctdm { |
| 257 |
const struct wctdm_desc *desc; |
| 258 |
const char *board_name; |
| 259 |
|
| 260 |
spinlock_t frame_list_lock; |
| 261 |
struct list_head frame_list; |
| 262 |
|
| 263 |
unsigned long framecount; |
| 264 |
unsigned char txident; |
| 265 |
unsigned char rxident; |
| 266 |
|
| 267 |
u8 ctlreg; |
| 268 |
u8 tdm410leds; |
| 269 |
|
| 270 |
int mods_per_board; |
| 271 |
int digi_mods; |
| 272 |
int avchannels; |
| 273 |
|
| 274 |
spinlock_t reglock; |
| 275 |
wait_queue_head_t regq; |
| 276 |
struct list_head free_isr_commands; |
| 277 |
|
| 278 |
struct wctdm_module mods[NUM_MODULES]; |
| 279 |
|
| 280 |
struct vpmadt032 *vpmadt032; |
| 281 |
struct vpmoct *vpmoct; |
| 282 |
struct voicebus vb; |
| 283 |
struct wctdm_span *aspan; |
| 284 |
struct wctdm_span *spans[MAX_SPANS]; |
| 285 |
struct wctdm_chan *chans[NUM_MODULES]; |
| 286 |
#ifdef CONFIG_VOICEBUS_ECREFERENCE |
| 287 |
struct dahdi_fifo *ec_reference[NUM_MODULES]; |
| 288 |
#endif |
| 289 |
|
| 290 |
|
| 291 |
|
| 292 |
struct semaphore syncsem; |
| 293 |
int oldsync; |
| 294 |
|
| 295 |
int not_ready; |
| 296 |
unsigned long checkflag; |
| 297 |
int companding; |
| 298 |
struct dahdi_device *ddev; |
| 299 |
}; |
| 300 |
|
| 301 |
static inline bool is_initialized(struct wctdm *wc) |
| 302 |
{ |
| 303 |
WARN_ON(wc->not_ready < 0); |
| 304 |
return (wc->not_ready == 0); |
| 305 |
} |
| 306 |
|
| 307 |
|
| 308 |
#define WCTDM_CHECK_TIMING 0 |
| 309 |
|
| 310 |
int wctdm_getreg(struct wctdm *wc, struct wctdm_module *const mod, int addr); |
| 311 |
int wctdm_setreg(struct wctdm *wc, struct wctdm_module *const mod, |
| 312 |
int addr, int val); |
| 313 |
|
| 314 |
int wctdm_wait_for_ready(struct wctdm *wc); |
| 315 |
|
| 316 |
extern struct semaphore ifacelock; |
| 317 |
extern struct wctdm *ifaces[WC_MAX_IFACES]; |
| 318 |
|
| 319 |
#endif |