[Pkg-voip-commits] r4705 - in /zaptel/trunk: debian/copyright wcopenpci.c
ron at alioth.debian.org
ron at alioth.debian.org
Sun Oct 7 14:19:47 UTC 2007
Author: ron
Date: Sun Oct 7 14:19:47 2007
New Revision: 4705
URL: http://svn.debian.org/wsvn/pkg-voip/?sc=1&rev=4705
Log:
Update to the latest wcopenpci release
Modified:
zaptel/trunk/debian/copyright
zaptel/trunk/wcopenpci.c
Modified: zaptel/trunk/debian/copyright
URL: http://svn.debian.org/wsvn/pkg-voip/zaptel/trunk/debian/copyright?rev=4705&op=diff
==============================================================================
--- zaptel/trunk/debian/copyright (original)
+++ zaptel/trunk/debian/copyright Sun Oct 7 14:19:47 2007
@@ -71,10 +71,10 @@
http://www.openvox.com.cn/members_downloads.php
(requires no login. Does require javascript)
-wcopenpci.c is from the vt zaptel distribution at
-http://www.voicetronix.com/Downloads/asterisk/ .
+wcopenpci.c is from the Voicetronix zaptel distribution at
+http://www.voicetronix.com/Downloads/asterisk/
Copyright (C) 2001, Linux Support Services, Inc.
-Copyright (C) 2005, 2006, VoiceTronix
+Copyright (C) 2005 - 2007, Voicetronix
Files in oslec/ subdirectory and oslec patches:
Modified: zaptel/trunk/wcopenpci.c
URL: http://svn.debian.org/wsvn/pkg-voip/zaptel/trunk/wcopenpci.c?rev=4705&op=diff
==============================================================================
--- zaptel/trunk/wcopenpci.c (original)
+++ zaptel/trunk/wcopenpci.c Sun Oct 7 14:19:47 2007
@@ -1,5 +1,5 @@
/*
- * VoiceTronix OpenPCI Interface Driver for Zapata Telephony interface
+ * Voicetronix OpenPCI Interface Driver for Zapata Telephony interface
*
* Written by Mark Spencer <markster at linux-support.net>
* Matthew Fredrickson <creslin at linux-support.net>
@@ -7,7 +7,7 @@
* Ron Lee <ron at voicetronix.com.au>
*
* Copyright (C) 2001, Linux Support Services, Inc.
- * Copyright (C) 2005, 2006, VoiceTronix
+ * Copyright (C) 2005 - 2007, Voicetronix
*
* All rights reserved.
*
@@ -31,9 +31,9 @@
#define VERBOSE_TIMING 0
/* Driver constants */
-#define DRIVER_DESCRIPTION "VoiceTronix OpenPCI zaptel driver"
-#define DRIVER_AUTHOR "Mark Spencer <markster at digium.com>"\
- "VoiceTronix <support at voicetronix.com.au>"
+#define DRIVER_DESCRIPTION "Voicetronix OpenPCI zaptel driver"
+#define DRIVER_AUTHOR "Mark Spencer <markster at digium.com> "\
+ "Voicetronix <support at voicetronix.com.au>"
#define NAME "wcopenpci"
#define MAX_PORTS 8 /* Maximum number of ports on each carrier */
@@ -50,7 +50,7 @@
#ifdef STANDALONE_ZAPATA
#include "zaptel.h"
#else
- #include <linux/zaptel.h>
+ #include <zaptel/zaptel.h>
#endif
#include "version.h"
@@ -92,55 +92,6 @@
#include <linux/mutex.h>
#endif
-
-static alpha indirect_regs[] =
-{
-{0,255,"DTMF_ROW_0_PEAK",0x55C2},
-{1,255,"DTMF_ROW_1_PEAK",0x51E6},
-{2,255,"DTMF_ROW2_PEAK",0x4B85},
-{3,255,"DTMF_ROW3_PEAK",0x4937},
-{4,255,"DTMF_COL1_PEAK",0x3333},
-{5,255,"DTMF_FWD_TWIST",0x0202},
-{6,255,"DTMF_RVS_TWIST",0x0202},
-{7,255,"DTMF_ROW_RATIO_TRES",0x0198},
-{8,255,"DTMF_COL_RATIO_TRES",0x0198},
-{9,255,"DTMF_ROW_2ND_ARM",0x0611},
-{10,255,"DTMF_COL_2ND_ARM",0x0202},
-{11,255,"DTMF_PWR_MIN_TRES",0x00E5},
-{12,255,"DTMF_OT_LIM_TRES",0x0A1C},
-{13,0,"OSC1_COEF",0x7B30},
-{14,1,"OSC1X",0x0063},
-{15,2,"OSC1Y",0x0000},
-{16,3,"OSC2_COEF",0x7870},
-{17,4,"OSC2X",0x007D},
-{18,5,"OSC2Y",0x0000},
-{19,6,"RING_V_OFF",0x0000},
-{20,7,"RING_OSC",0x7EF0},
-{21,8,"RING_X",0x0160},
-{22,9,"RING_Y",0x0000},
-{23,255,"PULSE_ENVEL",0x2000},
-{24,255,"PULSE_X",0x2000},
-{25,255,"PULSE_Y",0x0000},
-{26,13,"RECV_DIGITAL_GAIN",0x2000}, // playback volume set lower
-{27,14,"XMIT_DIGITAL_GAIN",0x4000},
-{28,15,"LOOP_CLOSE_TRES",0x1000},
-{29,16,"RING_TRIP_TRES",0x3600},
-{30,17,"COMMON_MIN_TRES",0x1000},
-{31,18,"COMMON_MAX_TRES",0x0200},
-{32,19,"PWR_ALARM_Q1Q2",0x0FF4},
-{33,20,"PWR_ALARM_Q3Q4",0x6E7E},
-{34,21,"PWR_ALARM_Q5Q6",0x0FF4}, // Recommmeded in AN47 for SOT89 or si3201)
-//{34,21,"PWR_ALARM_Q5Q6",0x150D}, // Recommened in AN47 for SOT223
-{35,22,"LOOP_CLOSURE_FILTER",0x8000},
-{36,23,"RING_TRIP_FILTER",0x0320},
-{37,24,"TERM_LP_POLE_Q1Q2",0x0012},
-{38,25,"TERM_LP_POLE_Q3Q4",0x0012},
-{39,26,"TERM_LP_POLE_Q5Q6",0x0012},
-{40,27,"CM_BIAS_RINGING",0x0C00},
-{41,64,"DCDC_MIN_V",0x0C00},
-{42,255,"DCDC_XTRA",0x1000},
-{43,66,"LOOP_CLOSE_TRES_LOW",0x1000},
-};
static struct fxo_mode {
char *name;
@@ -377,12 +328,14 @@
#define DSP_CODEC_HKOFF 22 /* station port off hook */
#define DSP_CODEC_HKON 23 /* station port on hook */
#define DSP_RING_OFF 24 /* RING falling edge detected */
+#define DSP_DROP 25
#define DSP_CODEC_FLASH 26 /* station port hook flash */
#define DSP_LOOP_OFFHOOK 38 /* Loop Off hook from OpenPCI */
#define DSP_LOOP_ONHOOK 39 /* Loop On hook from OpenPCI */
#define DSP_LOOP_POLARITY 40 /* Loop Polarity from OpenPCI */
+#define DSP_LOOP_NOBATT 41
#define DSP_PROSLIC_SANITY 50 /* Sanity alert from a ProSLIC port */
#define DSP_PROSLIC_PWR_ALARM 51 /* Power Alarm from a ProSLIC port */
@@ -418,15 +371,15 @@
} \
REPORT_WAIT(locked,i)
-#define HTXF_WAIT() BUSY_WAIT(i,HTXF_READY,5,50,RET_FAIL)
-#define HRXF_WAIT() BUSY_WAIT(i,!HRXF_READY,5,300,RET_FAIL)
-#define HTXF_WAIT_RET(failret) BUSY_WAIT(i,HTXF_READY,5,50,failret)
-#define HRXF_WAIT_RET(failret) BUSY_WAIT(i,!HRXF_READY,5,100,failret)
-
-#define HTXF_WAIT_LOCKED() LOCKED_WAIT(i,HTXF_READY,5,50,RET_FAIL)
-#define HRXF_WAIT_LOCKED() LOCKED_WAIT(i,!HRXF_READY,5,100,RET_FAIL)
-#define HTXF_WAIT_LOCKED_RET(failret) LOCKED_WAIT(i,HTXF_READY,5,50,failret)
-#define HRXF_WAIT_LOCKED_RET(failret) LOCKED_WAIT(i,!HRXF_READY,5,100,failret)
+#define HTXF_WAIT() BUSY_WAIT(i,HTXF_READY,5,500,RET_FAIL)
+#define HRXF_WAIT() BUSY_WAIT(i,!HRXF_READY,5,70000,RET_FAIL)
+#define HTXF_WAIT_RET(failret) BUSY_WAIT(i,HTXF_READY,5,500,failret)
+#define HRXF_WAIT_RET(failret) BUSY_WAIT(i,!HRXF_READY,5,1000,failret)
+
+#define HTXF_WAIT_LOCKED() LOCKED_WAIT(i,HTXF_READY,5,500,RET_FAIL)
+#define HRXF_WAIT_LOCKED() LOCKED_WAIT(i,!HRXF_READY,5,1000,RET_FAIL)
+#define HTXF_WAIT_LOCKED_RET(failret) LOCKED_WAIT(i,HTXF_READY,5,500,failret)
+#define HRXF_WAIT_LOCKED_RET(failret) LOCKED_WAIT(i,!HRXF_READY,5,1000,failret)
struct openpci {
@@ -455,11 +408,11 @@
} fxs;
} mod[MAX_PORTS];
- unsigned long ioaddr;
- dma_addr_t readdma;
- dma_addr_t writedma;
- volatile int *writechunk; /* Double-word aligned write memory */
- volatile int *readchunk; /* Double-word aligned read memory */
+ unsigned long ioaddr;
+ dma_addr_t readdma;
+ dma_addr_t writedma;
+ volatile unsigned int *writechunk; /* Double-word aligned write memory */
+ volatile unsigned int *readchunk; /* Double-word aligned read memory */
struct zt_chan chans[MAX_PORTS];
struct zt_span span;
@@ -470,7 +423,7 @@
static unsigned char fxo_port_lookup[8] = { 0x0, 0x8, 0x4, 0xc, 0x10, 0x18, 0x14, 0x1c};
static unsigned char fxs_port_lookup[8] = { 0x0, 0x1, 0x2, 0x3, 0x10, 0x11, 0x12, 0x13};
-static char wcopenpci[] = "VoiceTronix OpenPCI";
+static char wcopenpci[] = "Voicetronix OpenPCI";
static char *country = DEFAULT_COUNTRY;
static int reversepolarity; // = 0
@@ -785,6 +738,10 @@
case DSP_CODEC_FLASH:
zt_qevent_lock(&wc->chans[port], ZT_EVENT_WINKFLASH);
dbginfo(wc->boardnum, "Port %d Station Flash", port);
+ break;
+
+ case DSP_DROP:
+ case DSP_LOOP_NOBATT:
break;
//XXX What to do to recover from these?
@@ -864,9 +821,9 @@
static void openpci_arm_work( void *cardptr )
{ //{{{
struct openpci *wc = (struct openpci*)cardptr;
- unsigned char armmsg[3];
-
- if( read_arm_msg(wc, armmsg) ) arm_event(wc, armmsg);
+ unsigned char armmsg[4];
+
+ if( read_arm_msg(wc, armmsg) ) arm_event(wc, armmsg);
} //}}}
@@ -976,7 +933,11 @@
zt_receive(&wc->span);
} //}}}
-ZAP_IRQ_HANDLER(openpci_isr)
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)
+static irqreturn_t openpci_isr(int irq, void *dev_id, struct pt_regs *regs)
+#else
+static irqreturn_t openpci_isr(int irq, void *dev_id)
+#endif
{ //{{{
struct openpci *wc = dev_id;
unsigned long flags;
@@ -1015,6 +976,7 @@
}
if (status & 0x0c){
#ifdef DEBUG_LOOP_VOLTAGE
+ //{{{
static int counter[MAX_CARDS];
int card = wc->boardnum;
int port = ++counter[card] & 0x07;
@@ -1026,6 +988,7 @@
cardinfo(wc->boardnum, "Port %d loop voltage %d",
port, lv < 128 ? lv : lv - 256);
}
+ //}}}
#endif
openpci_read(wc, status);
}
@@ -1054,14 +1017,15 @@
wc->mod[port].fxs.idletxhookstate = 0x6; /* OHT mode when idle */
else
wc->mod[port].fxs.idletxhookstate = 0x2;
- if (wc->mod[port].fxs.lasttxhook == 0x1) {
- /* Apply the change if appropriate */
- if (reversepolarity)
- wc->mod[port].fxs.lasttxhook = 0x6;
- else
- wc->mod[port].fxs.lasttxhook = 0x2;
- if( ! write_reg_fxs(wc, port, 64, wc->mod[port].fxs.lasttxhook) )
- return -EIO;
+ switch(wc->mod[port].fxs.lasttxhook) {
+ case 0x1:
+ case 0x5:
+ if (reversepolarity)
+ wc->mod[port].fxs.lasttxhook = 0x6;
+ else
+ wc->mod[port].fxs.lasttxhook = 0x2;
+ if( ! write_reg_fxs(wc, port, 64, wc->mod[port].fxs.lasttxhook) )
+ return -EIO;
}
break;
case ZT_SETPOLARITY:
@@ -1070,8 +1034,8 @@
if (wc->porttype[port] != VT_PORT_PROSLIC)
return -EINVAL;
/* Can't change polarity while ringing or when open */
- if ((wc->mod[chan->chanpos -1 ].fxs.lasttxhook == 0x04) ||
- (wc->mod[chan->chanpos -1 ].fxs.lasttxhook == 0x00))
+ if ((wc->mod[port].fxs.lasttxhook == 0x04) ||
+ (wc->mod[port].fxs.lasttxhook == 0x00))
return -EINVAL;
if ((x && !reversepolarity) || (!x && reversepolarity))
@@ -1084,15 +1048,15 @@
case WCTDM_GET_STATS:
if (wc->porttype[port] == VT_PORT_PROSLIC) {
unsigned char linevolt;
- if( read_reg_fxs(wc, chan->chanpos-1, 80, &linevolt) )
+ if( read_reg_fxs(wc, port, 80, &linevolt) )
stats.tipvolt = linevolt * -376;
else
return -EIO;
- if( read_reg_fxs(wc, chan->chanpos-1, 81, &linevolt) )
+ if( read_reg_fxs(wc, port, 81, &linevolt) )
stats.ringvolt = linevolt * -376;
else
return -EIO;
- if( read_reg_fxs(wc, chan->chanpos-1, 82, &linevolt) )
+ if( read_reg_fxs(wc, port, 82, &linevolt) )
stats.batvolt = linevolt * -376;
else
return -EIO;
@@ -1110,15 +1074,15 @@
case WCTDM_GET_REGS:
if (wc->porttype[port] == VT_PORT_PROSLIC) {
for (x=0;x<NUM_INDIRECT_REGS;x++)
- if( ! read_indreg_fxs(wc, chan->chanpos-1, x, ®s.indirect[x]) )
+ if( ! read_indreg_fxs(wc, port, x, ®s.indirect[x]) )
return -EIO;
for (x=0;x<NUM_REGS;x++)
- if( ! read_reg_fxs(wc, chan->chanpos-1, x, ®s.direct[x]) )
+ if( ! read_reg_fxs(wc, port, x, ®s.direct[x]) )
return -EIO;
} else {
memset(®s, 0, sizeof(regs));
for (x=0;x<NUM_FXO_REGS;x++){
- if( ! read_reg_fxo(wc, chan->chanpos-1, x, ®s.direct[x]) )
+ if( ! read_reg_fxo(wc, port, x, ®s.direct[x]) )
return -EIO;
}
}
@@ -1131,12 +1095,14 @@
if (regop.indirect) {
if (wc->porttype[port] != VT_PORT_PROSLIC)
return -EINVAL;
- printk("Setting indirect %d to 0x%04x on %d\n", regop.reg, regop.val, chan->chanpos);
+ printk("Setting indirect %d to 0x%04x on %d\n",
+ regop.reg, regop.val, chan->chanpos);
if( ! write_indreg_fxs(wc, port, regop.reg, regop.val) )
return -EIO;
} else {
regop.val &= 0xff;
- printk("Setting direct %d to %04x on %d\n", regop.reg, regop.val, chan->chanpos);
+ printk("Setting direct %d to %04x on %d\n",
+ regop.reg, regop.val, chan->chanpos);
if (wc->porttype[port] == VT_PORT_PROSLIC) {
if( ! write_reg_fxs(wc, port, regop.reg, regop.val) )
return -EIO;
@@ -1182,7 +1148,7 @@
struct openpci *wc = chan->pvt;
if( ! wc->porttype[chan->chanpos-1] )
return -ENODEV;
-
+
//XXX This is WRONG and can prang in a race. We must pass THIS_MODULE
// as the owner of the span that holds the pointer to this function,
// then bump the refcount in the zaptel code _BEFORE_ the potentially
@@ -1380,6 +1346,7 @@
{ //{{{
int i = 0;
+ wc->portcount = 0;
for(; i < MAX_PORTS; ++i ){
wc->porttype[i] = get_port_type(wc, i);
dbginfo(wc->boardnum,"%d: %s", i, porttype(wc,i));
@@ -1396,7 +1363,6 @@
++wc->portcount;
}
}
- cardinfo(wc->boardnum, "found %d active ports", wc->portcount);
// we 'succeed' if any ports were discovered.
return wc->portcount ? RET_OK : RET_FAIL;
} //}}}
@@ -1408,7 +1374,7 @@
for (i=0; i < sizeof(fxo_modes)/sizeof(struct fxo_mode); ++i){
if(!strcmp(fxo_modes[i].name, name)){
- cardinfo(wc->boardnum, "Setting country to %s", name);
+ dbginfo(wc->boardnum, "%d: Setting country to %s", port, name);
goto part2;
}
}
@@ -1446,303 +1412,23 @@
return RET_FAIL;
} //}}}
-static int configure_vdaa_tdm(struct openpci *wc, int port)
-{ //{{{
- int tmp;
-
- /* Set the Receive/Transmit slot on the TDM bus */
- /* On the OpenPCI4/8 card we have two groups of 4 slots */
- if (port < 4) {
- tmp = port * ZT_CHUNKSIZE;
- //cardinfo(wc->boardnum, "Set port %d RX-TDM time slot to %d.",port,tmp);
- if( ! write_reg_fxo(wc, port, 36, tmp) ) goto hell;
- if( ! write_reg_fxo(wc, port, 37, 0x0) ) goto hell;
- //cardinfo(wc->boardnum, "Set port %d TX-TDM time slot to %d.",port,tmp);
- if( ! write_reg_fxo(wc, port, 34, tmp) ) goto hell;
- if( ! write_reg_fxo(wc, port, 35, 0x0) ) goto hell;
- }
- else if ( port < 8 ){
- tmp = (port -4) * ZT_CHUNKSIZE;
- //cardinfo(wc->boardnum, "Set port %d TDM time slot to %d.",port,tmp+512);
- if( ! write_reg_fxo(wc, port, 34, tmp) ) goto hell;
- if( ! write_reg_fxo(wc, port, 35, 0x2) ) goto hell;
- if( ! write_reg_fxo(wc, port, 36, tmp) ) goto hell;
- if( ! write_reg_fxo(wc, port, 37, 0x2) ) goto hell;
- }
- return RET_OK;
-
- hell:
- cardcrit(wc->boardnum, "configure vdaa tdm failed for port %d", port);
- return RET_FAIL;
-} //}}}
-
// Do not call this from an interrupt context, it may sleep.
static void configure_vdaa_port(struct openpci *wc, int port)
{ //{{{
- unsigned char value;
- int i, count=3;
-
- do {
- /* Reset the port */
- if( ! write_reg_fxo(wc, port, 1, 0x80) ) goto hell;
- /* Enable the ISO-cap (Line Side) */
- if( ! write_reg_fxo(wc, port, 6, 0x00) ) goto hell;
- /* Check that Line Side came up by reading its type */
- i = 0;
- do {
- msleep(1);
- if( read_reg_fxo(wc, port, 11, &value) ){
- if( value & 0xf0 ) goto part2;
- } else goto hell;
- } while (++i < 10);
- cardwarn(wc->boardnum, "Line Side failed to start on port %d, retrying", port);
-
- } while(--count > 0);
-
- cardwarn(wc->boardnum, "Line Side failed to start on port %d, marking as empty.", port);
- goto hell;
-
- part2:
- /* Set Country - default to Austrlia */
- /* Set to Mu-Law */
- /* Enable on-hook Line montoring - CID etc */
- if( configure_vdaa_country(wc, port, country)
- && write_reg_fxo(wc, port, 33, 0x28)
- && configure_vdaa_tdm(wc, port)
- && write_reg_fxo(wc, port, 5, 0x08) )
- {
+ /* Set Country - default to Australia */
+ if( configure_vdaa_country(wc, port, country) )
++wc->portcount;
- return;
- }
-
- hell:
- cardcrit(wc->boardnum, "FAILED to configure vdaa port %d. Disabled.", port);
- wc->porttype[port] = VT_PORT_EMPTY;
-} //}}}
-
-// Do not call this from an interrupt context, it may sleep.
-static int proslic_dcdc_calibration(struct openpci *wc, int port)
-{ //{{{
- const int tst_vbat = VBAT - (5 * 376/1000);
- unsigned char value=0;
- int tmp=0;
-
- /* Set DC-DC Convertor PWM Period */
- if( ! write_reg_fxs(wc, port, 92, 0xff) ) goto hell;
-
- /* Set the DC-DC Convertor Switching Delay */
- /* 0x14 is infact the reset/default value */
- if( ! write_reg_fxs(wc, port, 93, 0x19) ) goto hell;
-
- /* Turn on DC-DC Convertor */
- if( ! write_reg_fxs(wc, port, 14, 0x00) ) goto hell;
-
- /* Wait till PS_VBAT_VOLT1 is upto VBAT volts */
- while (++tmp < 50 && value < tst_vbat){
- msleep(1);
- if( ! read_reg_fxs(wc, port, 82, &value) ) goto hell;
- }
- if (value < tst_vbat){
- cardcrit(wc->boardnum, "proslic_dcdc_calibration: "
- "failed to power up!(%d < %d), retried %d times",
- value * 376/1000, tst_vbat * 376/1000, tmp);
- if( ! write_reg_fxs(wc, port, 14, 1<<4) ){
- cardcrit(wc->boardnum, "dcdc cal failed to reset PS_PWR_DN_CTRL1");
- }
- return RET_FAIL;
- }
- cardinfo(wc->boardnum, "power up %d >= %d after %d times",
- value * 376/1000, tst_vbat * 376/1000, tmp);
-
- /* Start the DC-DC Converter Peak Current Monitor Calibration */
- if( ! write_reg_fxs(wc, port, 93, (0x19|(1<<7))) ) goto hell;
-
- tmp = 0;
- do {
- msleep(1);
- if( ! read_reg_fxs(wc, port, 93, &value) ) goto hell;
- } while( (value & (1<<7)) && (++tmp < 500) );
- if(tmp == 500){
- cardcrit(wc->boardnum,
- "proslic_dcdc_calibration: failed after %d attempts",tmp);
- return RET_FAIL;
- }
-
- cardinfo(wc->boardnum, "calibration completed after %d attempts",tmp);
- return RET_OK;
-
- hell:
- cardcrit(wc->boardnum, "proslic dcdc calibration failed for port %d", port);
- return RET_FAIL;
-} //}}}
-
-// Do not call this from an interrupt context, it may sleep.
-static int proslic_power_leak_test(struct openpci *wc, int port)
-{ //{{{
- unsigned char vbat;
-
- if( ! write_reg_fxs(wc, port, 64, 0x00) ) goto hell;
- if( ! write_reg_fxs(wc, port, 14, 0x10) ) goto hell;
- msleep(1000);
-
- if( ! read_reg_fxs(wc, port, 82, &vbat) ) goto hell;
- if (vbat < 0x4){
- cardcrit(wc->boardnum, "FAILED proslic leakage test (%d)",vbat);
- return RET_FAIL;
- }
- return RET_OK;
-
- hell:
- cardcrit(wc->boardnum, "%d: FAILED to perform proslic leakdown test", port);
- return RET_FAIL;
-} //}}}
-
-// Do not call this from an interrupt context, it may sleep.
-static int proslic_slic_calibration(struct openpci *wc, int port)
-{ //{{{
- unsigned char value=1;
- int tmp=0;
- int reg96 = 0x47;
- int reg97 = 0x1E; // From AN35
-
- #if 0
- /* disable interrupts */
- if( ! write_reg_fxs(wc, port, 21, 0x0) ) goto hell;
- if( ! write_reg_fxs(wc, port, 22, 0x0) ) goto hell;
- if( ! write_reg_fxs(wc, port, 23, 0x0) ) goto hell;
- #endif
-
- /* set open */
- if( ! write_reg_fxs(wc, port, 64, 0x0) ) goto hell;
-
- if( ! write_reg_fxs(wc, port, 97, reg97) ) goto hell;
- if( ! write_reg_fxs(wc, port, 96, reg96) ) goto hell;
- while( value && ++tmp < 10){
- msleep(160);
- if( ! read_reg_fxs(wc, port, 96, &value) ) goto hell;
- }
- if(tmp == 10){
- cardcrit(wc->boardnum,
- "proslic_slic_calibration: FAILED after %d attempts",tmp);
- return RET_FAIL;
- }
-
- cardinfo(wc->boardnum, "slic calibration completed after %d attempts",tmp);
- return RET_OK;
-
- hell:
- cardcrit(wc->boardnum, "%d: FAILED slic calibration", port);
- return RET_FAIL;
-} //}}}
-
-// Do not call this from an interrupt context, it may sleep.
-static int proslic_manual_calibration(struct openpci *wc, int port)
-{ //{{{
- unsigned char value=1;
- int reg98 = 0x1F;
- int reg99 = 0x1F;
-
- #if 0
- /* setting some indirect registers, from sample program, not documented! */
- if( ! write_indreg_fxs(wc, port, 88, 0) ) goto hell;
- if( ! write_indreg_fxs(wc, port, 89, 0) ) goto hell;
- if( ! write_indreg_fxs(wc, port, 90, 0) ) goto hell;
- if( ! write_indreg_fxs(wc, port, 91, 0) ) goto hell;
- if( ! write_indreg_fxs(wc, port, 92, 0) ) goto hell;
- if( ! write_indreg_fxs(wc, port, 93, 0) ) goto hell;
-
- /* From sample program */
- // This is necessary if the calibration occurs other than at reset time
- if( ! write_reg_fxs(wc, port, 98, 0x10) ) goto hell;
- if( ! write_reg_fxs(wc, port, 99, 0x10) ) goto hell;
- #endif
-
- if( ! write_reg_fxs(wc, port, 98, reg98) ) goto hell;
- while(value > 0 && reg98 > 0){
- msleep(40);
- if( ! read_reg_fxs(wc, port, 88, &value) ) goto hell;
- if (value > 0){
- --reg98;
- if( ! write_reg_fxs(wc, port, 98, reg98) ) goto hell;
- }
- }
- if (reg98 == 0){
- cardcrit(wc->boardnum,
- "proslic_manual_calibration: Failed to calibrate RING gain (%d)",value);
- return RET_FAIL;
- }
- value=1;
- if( ! write_reg_fxs(wc, port, 99, reg99) ) goto hell;
- while(value > 0 && reg99 > 0){
- msleep(40);
- if( ! read_reg_fxs(wc, port, 89, &value) ) goto hell;
- if (value > 0){
- --reg99;
- if( ! write_reg_fxs(wc, port, 99, reg99) ) goto hell;
- }
- }
- if (reg99 == 0){
- cardcrit(wc->boardnum,
- "proslic_manual_calibration: Failed to calibrate TIP gain (%d)",value);
- return RET_FAIL;
- }
-
- return RET_OK;
-
- hell:
- cardcrit(wc->boardnum, "proslic manual calibration failed for port %d", port);
- return RET_FAIL;
-} //}}}
-
-// Do not call this from an interrupt context, it may sleep.
-static int proslic_longitudinal_balance_calibration(struct openpci *wc, int port)
-{ //{{{
- unsigned char value;
- int tmp = 0;
-
- /* Change to Active mode */
- if( ! write_reg_fxs(wc, port, 64, 1) ) goto hell;
- if( ! read_reg_fxs(wc, port, 68, &value) ) goto hell;
- if(!(value & 0x04)){
- cardcrit(wc->boardnum,
- "proslic_longitudinal_balance_calibration: Off-hook!(0x%02x)\n",value);
- goto hell;
- }
- /* Open Port */
- if( ! write_reg_fxs(wc, port, 64, 0) ) goto hell;
-
- /* Turn on common mode calibration error interrupt */
- if( ! write_reg_fxs(wc, port, 23, 1<<2) ) goto hell;
- if( ! write_reg_fxs(wc, port, 97, 0x01) ) goto hell;
- if( ! write_reg_fxs(wc, port, 96, 0x40) ) goto hell;
-
- while( value && ++tmp < 20 ){
- msleep(100);
- if( ! read_reg_fxs(wc, port, 20, &value) ) goto hell;
- if( value & 0x04 ) {
- cardcrit(wc->boardnum,
- "common mode calibration error, interrupt %#x", value);
- goto hell;
- }
- if( ! read_reg_fxs(wc, port, 96, &value) ) goto hell;
- }
- if( tmp == 20 ){
- cardcrit(wc->boardnum,"FAILED lb calibration after %d attempts",tmp);
- goto hell;
- }
- dbginfo(wc->boardnum,"lb calibration succeeded after %d attempts", tmp);
- return RET_OK;
-
- hell:
- cardcrit(wc->boardnum, "longitudinal balance calibration failed for port %d", port);
- return RET_FAIL;
+ else {
+ cardcrit(wc->boardnum, "FAILED to configure vdaa port %d. Disabled.", port);
+ wc->porttype[port] = VT_PORT_EMPTY;
+ }
} //}}}
static int configure_proslic_country(struct openpci *wc, int port, const char *name)
{ //{{{
int i;
- for (i=0; i < sizeof(ps_country_regs)/sizeof(struct ps_country_reg); ++i){
+ for(i=0; i < sizeof(ps_country_regs)/sizeof(struct ps_country_reg); ++i) {
if(!strcmp(ps_country_regs[i].country, name)){
dbginfo(wc->boardnum, "%d: Setting country to %s", port, name);
goto part2;
@@ -1762,131 +1448,6 @@
// Do not call this from an interrupt context, it may sleep.
static void configure_proslic_port(struct openpci *wc, int port)
{ //{{{
- int i = 0;
- unsigned char value;
-
- /* Write the initial indirect registers */
- for(; i < sizeof(indirect_regs)/sizeof(indirect_regs[0]); ++i) {
- if( ! write_indreg_fxs(wc, port, indirect_regs[i].address,
- indirect_regs[i].initial)) {
- cardcrit(wc->boardnum,
- "failed to init proslic ind regs on port %d!", port);
- goto hell;
- }
- }
- for (i=35; i < 40; ++i)
- if( ! write_indreg_fxs(wc, port, i, 0x8000) ) goto hell;
-
- if( ! write_reg_fxs(wc, port, 8, 0) ) goto hell;
- if( ! write_reg_fxs(wc, port, 108, 0xEB) ) goto hell;
-
- // Taken from sample program
- // Make VBat switch not automatic
- if( ! write_reg_fxs(wc, port, 67, 0x17) ) goto hell;
-
- // The above is a saftey measure to prevent Q7 from accidentaly turning on and burning out.
- // It works in combination with the statement below. Pin 34 DCDRV which is used for the
- // battery switch on the Si3211 & Si3212
- // Q7 should be set to OFF for si3210
- if( ! write_reg_fxs(wc, port, 66, 0x01) ) goto hell;
-
- /* Take it out of loop back */
- /* Not done in sample program
- if( ! write_reg_fxs(card, port, 8, 0) ) goto hell;
- */
-
- if( ! write_reg_fxs(wc, port, 108, 0xEB) ) goto hell;
-
- // 0x32 => 75 volts
- // 0x2e => 69 volts
- // 0x21 => 49.5 volts
- if( ! write_reg_fxs(wc, port, 74, 0x32) ) goto hell;
- if( ! write_reg_fxs(wc, port, 75, 0x11) ) goto hell;
-
- /* Perform DC-DC Calibration */
- if( ! proslic_dcdc_calibration(wc, port) ) goto hell;
-
- /* Perform power leak test, as sugested in sample program */
- if( ! proslic_power_leak_test(wc, port) ) goto hell;
-
- /* Perform DC-DC Calibration again to bring power up */
- if( ! proslic_dcdc_calibration(wc, port) ) goto hell;
-
- /* Perform SLIC calibration 'off-hook' */
- if( ! proslic_slic_calibration(wc, port) ) goto hell;
- if( ! proslic_manual_calibration(wc, port) ) goto hell;
- if( ! proslic_longitudinal_balance_calibration(wc, port) ) goto hell;
-
- /* Flush out energy accumulators */
- for(i=88; i < 96; ++i){
- if( ! write_indreg_fxs(wc, port, i, 0x0000) ) goto hell;
- }
- if( ! write_indreg_fxs(wc, port, 97, 0x0000) ) goto hell;
- for(i=193; i < 212; ++i){
- if( ! write_indreg_fxs(wc, port, i, 0x0000) ) goto hell;
- }
-
- /* clear interrupts */
- for(i=18; i < 21; ++i){
- if( ! write_reg_fxs(wc, port, i, 0xFF) ) goto hell;
- }
- /* enable interrupts */
- for(i=21; i < 24; ++i){
- if( ! write_reg_fxs(wc, port, i, 0xFF) ) goto hell;
- }
-
- /* Set time slots */
- if (port < 4) {
- value = port * ZT_CHUNKSIZE;
- //cardinfo(card->boardnum, "Set port %d RX-TDM time slot to %d.",port,value);
- if( ! write_reg_fxs(wc, port, 2, value) ) goto hell;
- if( ! write_reg_fxs(wc, port, 3, 0x0) ) goto hell;
- //cardinfo(wc->boardnum, "Set port %d TX-TDM time slot to %d.",port,value);
- if( ! write_reg_fxs(wc, port, 4, value) ) goto hell;
- if( ! write_reg_fxs(wc, port, 5, 0x0) ) goto hell;
- }
- else if ( port < 8 ){
- value = (port -4) * ZT_CHUNKSIZE;
- //cardinfo(wc->boardnum, "Set port %d TDM time slot to %d.",port,value+512);
- if( ! write_reg_fxs(wc, port, 2, value) ) goto hell;
- if( ! write_reg_fxs(wc, port, 3, 0x02) ) goto hell;
- if( ! write_reg_fxs(wc, port, 4, value) ) goto hell;
- if( ! write_reg_fxs(wc, port, 5, 0x02) ) goto hell;
- }
-
- /* Turn on the audio and set to mu-law */
- if( ! write_reg_fxs(wc, port, 1, 0x28) ) goto hell;
-
- /* Set up audio path */
- if( ! write_reg_fxs(wc, port, 8, 0x0) ) goto hell;
- if( ! write_reg_fxs(wc, port, 9, 0x0) ) goto hell;
- if( ! write_reg_fxs(wc, port, 11, 0x33) ) goto hell;
-
- /* Initilize OSC1, OSC2, Ringing, Pulse Metering */
- /* Leaving at defaults */
-
- /* Write detect thresholds and filters */
- /* Leaving at defaults */
-
- /* Write DC feed parameters */
- /* Leaving 65,67 at defaults */
- if( ! write_reg_fxs(wc, port, 66, 0x01) ) goto hell;
- /* 20 mA */
- if( ! write_reg_fxs(wc, port, 71, 0x00) ) goto hell;
- /* -48 */
- if( ! write_reg_fxs(wc, port, 72, 0x20) ) goto hell;
- /* -6V */
- if( ! write_reg_fxs(wc, port, 73, 0x04) ) goto hell;
-
- /* Re-write Power Coefficients */
- for(i=35; i < 40; ++i){
- if( ! write_indreg_fxs(wc, port, i, indirect_regs[i].initial) ) goto hell;
- }
-
- /* Set operation mode */
- /* Forward active */
- if( ! write_reg_fxs(wc, port, 64, 0x01) ) goto hell;
-
/* Set Country - default to Australia */
switch( configure_proslic_country(wc, port, country) ){
case 0:
@@ -1912,6 +1473,7 @@
// Do not call this from an interrupt context, it may (indirectly) sleep.
static int configure_ports(struct openpci *wc)
{ //{{{
+ unsigned long flags;
int i;
wc->portcount = 0;
@@ -1921,7 +1483,13 @@
case VT_PORT_PROSLIC: configure_proslic_port(wc,i); break;
}
}
- // we 'succeed' if any ports were configured successfully.
+
+ spin_lock_irqsave(&wc->lock, flags);
+ outb(0x2c, PIB(1)); HTXF_WAIT_LOCKED();
+ outb(0xff, PIB(1)); HTXF_WAIT_LOCKED();
+ spin_unlock_irqrestore(&wc->lock, flags);
+
+ // otherwise we 'succeed' if any ports were configured successfully.
return wc->portcount ? RET_OK : RET_FAIL;
} //}}}
@@ -2016,6 +1584,7 @@
struct openpci *wc;
int boardnum = 0;
int failret = -ENOMEM;
+ int tmp = 0;
int i;
unsigned long flags;
@@ -2076,11 +1645,11 @@
failret = -EIO;
goto hell_3;
}
- if( wc->firmware < 9 ){
+ if( wc->firmware < 11 ){
cardcrit(boardnum,
"Firmware version %d not supported by this driver",
wc->firmware);
- cardcrit(boardnum, " contact VoiceTronix to have it updated");
+ cardcrit(boardnum, " contact Voicetronix to have it updated");
failret = -ENODEV;
goto hell_3;
}
@@ -2090,7 +1659,7 @@
goto hell_3;
}
- wc->writechunk = (int *)pci_alloc_consistent(pdev, VT_PCIDMA_BLOCKSIZE, &wc->writedma);
+ wc->writechunk = pci_alloc_consistent(pdev, VT_PCIDMA_BLOCKSIZE, &wc->writedma);
if (!wc->writechunk) {
cardcrit(boardnum, "Couldnt get DMA memory.");
goto hell_3;
@@ -2120,13 +1689,30 @@
failret = -EIO;
goto hell_4;
}
-
- /* Configure the ports */
+ msleep(1000);
+
+ i = 0;
+ while(tmp != 0x88 && ++i < 1000) {
+ outb(0x88, PIB(0));
+ msleep(250);
+ tmp = inb(PIB(1));
+ }
+ if(i>=1000) {
+ cardcrit(boardnum, "FAILED to initialise board");
+ goto hell_4;
+ }
+
+ if( ! check_ports(wc) ) {
+ cardcrit(boardnum, "FAILED to initialise ports");
+ failret = -EIO;
+ goto hell_4;
+ }
if( ! configure_ports(wc) ){
cardcrit(boardnum, "Failed to configure ports.");
failret = -EIO;
goto hell_4;
}
+ cardinfo(wc->boardnum, "have %d configured ports", wc->portcount);
if( ! span_initialize(wc) ) {
cardcrit(boardnum, "Failed to register with zaptel driver");
More information about the Pkg-voip-commits
mailing list