[zaptel-commits] mattf: branch 1.2 r1978 -
/branches/1.2/wctdm24xxp.c
zaptel-commits at lists.digium.com
zaptel-commits at lists.digium.com
Thu Jan 25 16:12:28 MST 2007
Author: mattf
Date: Thu Jan 25 17:12:27 2007
New Revision: 1978
URL: http://svn.digium.com/view/zaptel?view=rev&rev=1978
Log:
Add support for additional product.
Modified:
branches/1.2/wctdm24xxp.c
Modified: branches/1.2/wctdm24xxp.c
URL: http://svn.digium.com/view/zaptel/branches/1.2/wctdm24xxp.c?view=diff&rev=1978&r1=1977&r2=1978
==============================================================================
--- branches/1.2/wctdm24xxp.c (original)
+++ branches/1.2/wctdm24xxp.c Thu Jan 25 17:12:27 2007
@@ -2,6 +2,7 @@
* Wilcard TDM2400P TDM FXS/FXO Interface Driver for Zapata Telephony interface
*
* Written by Mark Spencer <markster at digium.com>
+ * Further modified to add support for the TDM800P by Matthew Fredrickson <creslin at digium.com>
*
* Copyright (C) 2005, 2006, Digium, Inc.
*
@@ -289,9 +290,9 @@
#define CMD_WR(a,b) (((a) << 8) | (b) | __CMD_WR)
#define CMD_RD(a) (((a) << 8) | __CMD_RD)
-#define CMD_BYTE(card,bit) (((((card) & 0x3) * 3 + (bit)) * 7) \
- + ((card) >> 2))
-
+
+#define CMD_BYTE(card,bit,altcs) (((((card) & 0x3) * 3 + (bit)) * 7) \
+ + ((card) >> 2) + (altcs) + ((altcs) ? -21 : 0))
struct calregs {
unsigned char vals[NUM_CAL_REGS];
@@ -326,6 +327,7 @@
unsigned char ctlreg;
int cards;
int cardflag; /* Bit-map of present cards */
+ int altcs[NUM_CARDS + NUM_EC];
spinlock_t reglock;
wait_queue_head_t regq;
/* FXO Stuff */
@@ -358,6 +360,7 @@
int modtype[NUM_CARDS + NUM_EC];
/* Set hook */
int sethook[NUM_CARDS + NUM_EC];
+ int type;
#ifdef VPM_SUPPORT
int vpm;
@@ -385,9 +388,11 @@
struct wctdm_desc {
char *name;
int flags;
+ int ports;
};
-static struct wctdm_desc wctdm = { "Wildcard TDM2400P", 0 };
+static struct wctdm_desc wctdm2400 = { "Wildcard TDM2400P", 0, 24 };
+static struct wctdm_desc wctdm800 = { "Wildcard TDM800P", 0, 8 };
static int acim2tiss[16] = { 0x0, 0x1, 0x4, 0x5, 0x7, 0x0, 0x0, 0x6, 0x0, 0x0, 0x0, 0x2, 0x0, 0x3 };
static struct wctdm *ifaces[WC_MAX_IFACES];
@@ -443,6 +448,7 @@
unsigned long flags;
unsigned int curcmd=0;
int x;
+ int subaddr = card & 0x3;
#ifdef FANCY_ECHOCAN
int ecval;
ecval = wc->echocanpos;
@@ -450,6 +456,9 @@
ecval = ecval % EC_SIZE;
#endif
+ if (wc->altcs[card])
+ subaddr = 0;
+
/* Skip audio */
writechunk += 24;
spin_lock_irqsave(&wc->reglock, flags);
@@ -485,43 +494,43 @@
}
}
if (wc->modtype[card] == MOD_TYPE_FXS) {
- writechunk[CMD_BYTE(card, 0)] = (1 << (card & 0x3));
+ writechunk[CMD_BYTE(card, 0, wc->altcs[card])] = (1 << (subaddr));
if (curcmd & __CMD_WR)
- writechunk[CMD_BYTE(card, 1)] = (curcmd >> 8) & 0x7f;
+ writechunk[CMD_BYTE(card, 1, wc->altcs[card])] = (curcmd >> 8) & 0x7f;
else
- writechunk[CMD_BYTE(card, 1)] = 0x80 | ((curcmd >> 8) & 0x7f);
- writechunk[CMD_BYTE(card, 2)] = curcmd & 0xff;
+ writechunk[CMD_BYTE(card, 1, wc->altcs[card])] = 0x80 | ((curcmd >> 8) & 0x7f);
+ writechunk[CMD_BYTE(card, 2, wc->altcs[card])] = curcmd & 0xff;
} else if (wc->modtype[card] == MOD_TYPE_FXO) {
if (curcmd & __CMD_WR)
- writechunk[CMD_BYTE(card, 0)] = 0x20 | fxo_addrs[card & 0x3];
+ writechunk[CMD_BYTE(card, 0, wc->altcs[card])] = 0x20 | fxo_addrs[subaddr];
else
- writechunk[CMD_BYTE(card, 0)] = 0x60 | fxo_addrs[card & 0x3];
- writechunk[CMD_BYTE(card, 1)] = (curcmd >> 8) & 0xff;
- writechunk[CMD_BYTE(card, 2)] = curcmd & 0xff;
+ writechunk[CMD_BYTE(card, 0, wc->altcs[card])] = 0x60 | fxo_addrs[subaddr];
+ writechunk[CMD_BYTE(card, 1, wc->altcs[card])] = (curcmd >> 8) & 0xff;
+ writechunk[CMD_BYTE(card, 2, wc->altcs[card])] = curcmd & 0xff;
} else if (wc->modtype[card] == MOD_TYPE_FXSINIT) {
/* Special case, we initialize the FXS's into the three-byte command mode then
switch to the regular mode. To send it into thee byte mode, treat the path as
6 two-byte commands and in the last one we initialize register 0 to 0x80. All modules
read this as the command to switch to daisy chain mode and we're done. */
- writechunk[CMD_BYTE(card, 0)] = 0x00;
- writechunk[CMD_BYTE(card, 1)] = 0x00;
+ writechunk[CMD_BYTE(card, 0, wc->altcs[card])] = 0x00;
+ writechunk[CMD_BYTE(card, 1, wc->altcs[card])] = 0x00;
if ((card & 0x1) == 0x1)
- writechunk[CMD_BYTE(card, 2)] = 0x80;
+ writechunk[CMD_BYTE(card, 2, wc->altcs[card])] = 0x80;
else
- writechunk[CMD_BYTE(card, 2)] = 0x00;
+ writechunk[CMD_BYTE(card, 2, wc->altcs[card])] = 0x00;
#ifdef VPM_SUPPORT
} else if (wc->modtype[card] == MOD_TYPE_VPM) {
if (curcmd & __CMD_WR)
- writechunk[CMD_BYTE(card, 0)] = ((card & 0x3) << 4) | 0xc | ((curcmd >> 16) & 0x1);
+ writechunk[CMD_BYTE(card, 0, wc->altcs[card])] = ((card & 0x3) << 4) | 0xc | ((curcmd >> 16) & 0x1);
else
- writechunk[CMD_BYTE(card, 0)] = ((card & 0x3) << 4) | 0xa | ((curcmd >> 16) & 0x1);
- writechunk[CMD_BYTE(card, 1)] = (curcmd >> 8) & 0xff;
- writechunk[CMD_BYTE(card, 2)] = curcmd & 0xff;
+ writechunk[CMD_BYTE(card, 0, wc->altcs[card])] = ((card & 0x3) << 4) | 0xa | ((curcmd >> 16) & 0x1);
+ writechunk[CMD_BYTE(card, 1, wc->altcs[card])] = (curcmd >> 8) & 0xff;
+ writechunk[CMD_BYTE(card, 2, wc->altcs[card])] = curcmd & 0xff;
#endif
} else if (wc->modtype[card] == MOD_TYPE_NONE) {
- writechunk[CMD_BYTE(card, 0)] = 0x00;
- writechunk[CMD_BYTE(card, 1)] = 0x00;
- writechunk[CMD_BYTE(card, 2)] = 0x00;
+ writechunk[CMD_BYTE(card, 0, wc->altcs[card])] = 0x00;
+ writechunk[CMD_BYTE(card, 1, wc->altcs[card])] = 0x00;
+ writechunk[CMD_BYTE(card, 2, wc->altcs[card])] = 0x00;
}
#if 0
/* XXX */
@@ -552,7 +561,7 @@
ident = (wc->cmdq[card].cmds[x] >> 24) & 0xff;
if (ident == wc->rxident) {
/* Store result */
- wc->cmdq[card].cmds[x] |= readchunk[CMD_BYTE(card, 2)];
+ wc->cmdq[card].cmds[x] |= readchunk[CMD_BYTE(card, 2, wc->altcs[card])];
wc->cmdq[card].cmds[x] |= __CMD_FIN;
if (wc->cmdq[card].cmds[x] & __CMD_WR) {
/* Go ahead and clear out writes since they need no acknowledgement */
@@ -624,9 +633,10 @@
for (x=0;x<ZT_CHUNKSIZE;x++) {
/* Send a sample, as a 32-bit word */
- for (y=0;y < wc->cards;y++) {
+ for (y=0;y < wc->type;y++) {
if (!x)
cmd_checkisr(wc, y);
+
writechunk[y] = wc->chans[y].writechunk[x];
cmd_dequeue(wc, writechunk, y, x);
}
@@ -877,7 +887,7 @@
cmd_retransmit(wc);
}
}
- for (y=0;y < wc->cards;y++) {
+ for (y=0;y < wc->type;y++) {
wc->chans[y].readchunk[x] = readchunk[y];
cmd_decifer(wc, readchunk, y);
}
@@ -895,7 +905,7 @@
readchunk += (EFRAME_SIZE + EFRAME_GAP);
}
/* XXX We're wasting 8 taps. We should get closer :( */
- for (x=0;x<wc->cards;x++) {
+ for (x=0;x<wc->type;x++) {
if (wc->cardflag & (1 << x))
zt_ec_chunk(&wc->chans[x], wc->chans[x].readchunk, wc->chans[x].writechunk);
}
@@ -1583,7 +1593,7 @@
}
if (vbat < 0xc0) {
- printk("ProSLIC on module %d failed to powerup within %d ms (%d mV only)\n\n -- DID YOU REMEMBER TO PLUG IN THE HD POWER CABLE TO THE TDM2400P??\n",
+ printk("ProSLIC on module %d failed to powerup within %d ms (%d mV only)\n\n -- DID YOU REMEMBER TO PLUG IN THE HD POWER CABLE TO THE TDM CARD??\n",
card, (int)(((jiffies - origjiffies) * 1000 / HZ)),
vbat * 375);
return -1;
@@ -2300,7 +2310,7 @@
wc->chans[x].pvt = wc;
}
wc->span.chans = wc->chans;
- wc->span.channels = wc->cards;
+ wc->span.channels = wc->type;
wc->span.hooksig = wctdm_hooksig;
wc->span.open = wctdm_open;
wc->span.close = wctdm_close;
@@ -2353,7 +2363,7 @@
newjiffies = jiffies + HZ/10;
while(((reg = wctdm_getctl(wc,0x0000)) & 0x00000001) && (newjiffies > jiffies));
- printk("WCTDM2400P: New Reg: %08x!\n", reg);
+ printk("%s: New Reg: %08x!\n", wc->variety, reg);
/* Configure watchdogs, access, etc */
@@ -2384,7 +2394,7 @@
printk("(post) Reg fc is %08x\n", reg);
printk("Detected REG2: %08x\n", wctdm_getsdi(wc, 0x02));
#endif
- printk("wctdm2400p: reg is %08x\n", wctdm_getctl(wc, 0x0088));
+ printk("wctdm24xxp: reg is %08x\n", wctdm_getctl(wc, 0x0088));
return 0;
}
@@ -2616,13 +2626,20 @@
for (x=0;x<wc->cards;x++)
wc->modtype[x] = MOD_TYPE_FXS;
spin_unlock_irqrestore(&wc->reglock, flags);
+
#if 0
/* XXX */
cmddesc = 0;
#endif
+ /* Now that all the cards have been reset, we can stop checking them all if there aren't as many */
+ spin_lock_irqsave(&wc->reglock, flags);
+ wc->cards = wc->type;
+ spin_unlock_irqrestore(&wc->reglock, flags);
+
/* Reset modules */
for (x=0;x<wc->cards;x++) {
int sane=0,ret=0,readi=0;
+retry:
/* Init with Auto Calibration */
if (!(ret = wctdm_init_proslic(wc, x, 0, 0, sane))) {
wc->cardflag |= (1 << x);
@@ -2650,8 +2667,25 @@
} else if (!(ret = wctdm_init_voicedaa(wc, x, 0, 0, sane))) {
wc->cardflag |= (1 << x);
printk("Port %d: Installed -- AUTO FXO (%s mode)\n",x + 1, fxo_modes[_opermode].name);
- } else
- printk("Port %d: Not installed\n", x + 1);
+ } else {
+ if ((wc->type == 8) && ((x & 0x3) == 1) && !wc->altcs[x]) {
+ spin_lock_irqsave(&wc->reglock, flags);
+ wc->modtype[x] = MOD_TYPE_FXSINIT;
+ wc->altcs[x] = 2;
+ spin_unlock_irqrestore(&wc->reglock, flags);
+ schluffen(&wc->regq);
+ spin_lock_irqsave(&wc->reglock, flags);
+ wc->modtype[x] = MOD_TYPE_FXS;
+ spin_unlock_irqrestore(&wc->reglock, flags);
+ if (debug)
+ printk("Trying port %d with alternate chip select\n", x + 1);
+ goto retry;
+ } else {
+ printk("Port %d: Not installed\n", x + 1);
+ wc->modtype[x] = MOD_TYPE_NONE;
+ wc->cardflag |= (1 << x);
+ }
+ }
}
}
#ifdef VPM_SUPPORT
@@ -2671,7 +2705,7 @@
int x;
int y;
static int initd_ifaces=0;
-
+
if(initd_ifaces){
memset((void *)ifaces,0,(sizeof(struct wctdm *))*WC_MAX_IFACES);
initd_ifaces=1;
@@ -2694,13 +2728,14 @@
wc->curcard = -1;
wc->cards = NUM_CARDS;
wc->iobase = pci_resource_start(pdev, 0);
+ wc->type = d->ports;
wc->dev = pdev;
wc->pos = x;
wc->variety = d->name;
for (y=0;y<NUM_CARDS;y++)
wc->flags[y] = d->flags;
/* Keep track of whether we need to free the region */
- if (request_region(wc->iobase, 0xff, "wctdm"))
+ if (request_region(wc->iobase, 0xff, "wctdm24xxp"))
wc->freeregion = 1;
/* Allocate enough memory for two zt chunks, receive and transmit. Each sample uses
@@ -2726,7 +2761,7 @@
init_waitqueue_head(&wc->regq);
if (wctdm_initialize(wc)) {
- printk("wctdm: Unable to intialize FXS\n");
+ printk("%s: Unable to register span with zaptel\n", wc->variety);
/* Set Reset Low */
wctdm_stop_dma(wc);
/* Free Resources */
@@ -2744,8 +2779,8 @@
/* Keep track of which device we are */
pci_set_drvdata(pdev, wc);
- if (request_irq(pdev->irq, wctdm_interrupt, SA_SHIRQ, "wctdm24xxp", wc)) {
- printk("wctdm: Unable to request IRQ %d\n", pdev->irq);
+ if (request_irq(pdev->irq, wctdm_interrupt, SA_SHIRQ, wc->variety, wc)) {
+ printk("wctdm24xxp: Unable to request IRQ %d\n", pdev->irq);
if (wc->freeregion)
release_region(wc->iobase, 0xff);
pci_free_consistent(pdev, PCI_WINDOW_SIZE, (void *)wc->writechunk, wc->writedma);
@@ -2783,7 +2818,7 @@
/* Final initialization */
wctdm_post_initialize(wc);
- printk("Found a Wildcard TDM: %s (%d modules)\n", wc->variety, wc->cards);
+ printk("Found a Wildcard TDM: %s (%d modules)\n", wc->variety, wc->type);
res = 0;
} else
res = -ENOMEM;
@@ -2824,14 +2859,15 @@
}
static struct pci_device_id wctdm_pci_tbl[] = {
- { 0xd161, 0x2400, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (unsigned long) &wctdm },
+ { 0xd161, 0x2400, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (unsigned long) &wctdm2400 },
+ { 0xd161, 0x0800, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (unsigned long) &wctdm800 },
{ 0 }
};
MODULE_DEVICE_TABLE(pci, wctdm_pci_tbl);
static struct pci_driver wctdm_driver = {
- name: "wctdm24xxp",
+ name: "wctdmxxp",
probe: wctdm_init_one,
#ifdef LINUX26
remove: __devexit_p(wctdm_remove_one),
@@ -2909,7 +2945,7 @@
MODULE_PARM(dtmfthreshold, "i");
#endif
#endif
-MODULE_DESCRIPTION("Wildcard TDM2400P Zaptel Driver");
+MODULE_DESCRIPTION("Wildcard TDM2400P/TDM800P Zaptel Driver");
MODULE_AUTHOR("Mark Spencer <markster at digium.com>");
#ifdef MODULE_LICENSE
MODULE_LICENSE("GPL");
More information about the zaptel-commits
mailing list