Author: sruffell
Date: Tue Feb 5 12:15:03 2008
New Revision: 3799
URL: http://svn.digium.com/view/zaptel?view=rev&rev=3799
a>
Log:
Moving my work on refactoring the common voicebus parts of
the wcte12xp and
wctdm24xxp drivers into a public branch to facilitate beta
testing.
- These drivers can now adjust to systems that do not
exhibit good real-time
characteristics. The driver will dynamically increase
it's latency on
systems that cannot service the interrupt in a timely
manner up to a maximum
of 32ms.
Modified:
team/sruffell/voicebus/ (props changed)
team/sruffell/voicebus/wctdm24xxp/GpakApi.c
team/sruffell/voicebus/wctdm24xxp/GpakCust.c
team/sruffell/voicebus/wctdm24xxp/Kbuild
team/sruffell/voicebus/wctdm24xxp/base.c
team/sruffell/voicebus/wctdm24xxp/wctdm24xxp.h
team/sruffell/voicebus/wcte12xp/Kbuild
team/sruffell/voicebus/wcte12xp/base.c
team/sruffell/voicebus/wcte12xp/vpmadt032.c
team/sruffell/voicebus/wcte12xp/wcte12xp.h
team/sruffell/voicebus/zaptel.h
Propchange: team/sruffell/voicebus/
------------------------------------------------------------
------------------
svnmerge-integrated = /branches/1.4:1-3783
Modified: team/sruffell/voicebus/wctdm24xxp/GpakApi.c
URL: http://svn.digium.com/view/zaptel/team/sruffell/
voicebus/wctdm24xxp/GpakApi.c?view=diff&rev=3799&r1=
3798&r2=3799
============================================================
==================
--- team/sruffell/voicebus/wctdm24xxp/GpakApi.c (original)
+++ team/sruffell/voicebus/wctdm24xxp/GpakApi.c Tue Feb 5
12:15:03 2008
 -130,11
+130,6 
DSP_WORD DspStatus; /* DSP Status */
DSP_WORD DspChannels; /* number of DSP channels */
DSP_WORD Temp[2];
-#if 0
- DSP_WORD DspConfs; /* number of DSP conferences
*/
- DSP_ADDRESS PktBufrMem; /* address of Packet Buffer
*/
- unsigned short int i; /* loop index / counter */
-#endif
/* Read the pointer to the Interface Block. */
gpakReadDspMemory(DspId, DSP_IFBLK_ADDRESS, 2, Temp);
Modified: team/sruffell/voicebus/wctdm24xxp/GpakCust.c
URL: http://svn.digium.com/view/zaptel/team/sruffell
/voicebus/wctdm24xxp/GpakCust.c?view=diff&rev=3799&r
1=3798&r2=3799
============================================================
==================
--- team/sruffell/voicebus/wctdm24xxp/GpakCust.c (original)
+++ team/sruffell/voicebus/wctdm24xxp/GpakCust.c Tue Feb 5
12:15:03 2008
 -89,13
+89,12 
{
int i;
struct wctdm *ret = NULL;
- unsigned long flags;
-
- spin_lock_irqsave(&ifacelock, flags);
+
+ spin_lock(&ifacelock);
for (i = 0; i < WC_MAX_IFACES; i++)
if (ifaces[i] && ifaces[i]->vpm150m &&
(ifaces[i]->vpm150m->dspid == dspid))
ret = ifaces[i];
- spin_unlock_irqrestore(&ifacelock, flags);
+ spin_unlock(&ifacelock);
return ret;
}
 -288,6
+287,7 
int transcount;
int ret;
+ BUG_ON(!wc);
vpm150m_io_wait(wc);
if ( NumWords < VPM150M_MAX_COMMANDS ) {
struct vpm150m_cmd* cmds[VPM150M_MAX_COMMANDS] = ;
Modified: team/sruffell/voicebus/wctdm24xxp/Kbuild
URL: http://svn.digium.com/view/zaptel/team/sruffell/voi
cebus/wctdm24xxp/Kbuild?view=diff&rev=3799&r1=3798&a
mp;r2=3799
============================================================
==================
--- team/sruffell/voicebus/wctdm24xxp/Kbuild (original)
+++ team/sruffell/voicebus/wctdm24xxp/Kbuild Tue Feb 5
12:15:03 2008
 -6,7
+6,7 
EXTRA_CFLAGS+=-DHOTPLUG_FIRMWARE
endif
-wctdm24xxp-objs := base.o GpakCust.o GpakApi.o
+wctdm24xxp-objs := base.o GpakCust.o GpakApi.o
../voicebus.o
ifneq ($(HOTPLUG_FIRMWARE),yes)
wctdm24xxp-objs += ../firmware/zaptel-fw-vpmadt032.o
Modified: team/sruffell/voicebus/wctdm24xxp/base.c
URL: http://svn.digium.com/view/zaptel/team/sruffell/voi
cebus/wctdm24xxp/base.c?view=diff&rev=3799&r1=3798&a
mp;r2=3799
============================================================
==================
--- team/sruffell/voicebus/wctdm24xxp/base.c (original)
+++ team/sruffell/voicebus/wctdm24xxp/base.c Tue Feb 5
12:15:03 2008
 -4,7
+4,7 
* Written by Mark Spencer <markster digium.com>
* Support for TDM800P and VPM150M by Matthew Fredrickson
<creslin digium.com>
*
- * Copyright (C) 2005,2006, Digium, Inc.
+ * Copyright (C) 2005 - 2008 Digium, Inc.
* All rights reserved.
*
* Sections for QRV cards written by Jim Dixon <jim lambdatel.com>
 -281,6
+281,7 
static int nativebridge = 0;
static int ringdebounce = DEFAULT_RING_DEBOUNCE;
static int fwringdetect = 0;
+static int latency=3;
#ifdef VPM_SUPPORT
static int vpmsupport = 1;
static int vpmdtmfsupport = 0;
 -746,29
+747,26 
}
}
-static inline void wctdm_transmitprep(struct wctdm *wc, int
dbl)
-{
- volatile unsigned char *writechunk;
+static inline void wctdm_transmitprep(struct wctdm *wc,
unsigned char *writechunk)
+{
int x,y;
- dbl = dbl % 2;
-
- writechunk = (volatile unsigned char
*)(wc->writechunk);
- if (dbl)
- /* Write is at interrupt address. Start writing from
normal offset */
- writechunk += SFRAME_SIZE;
-
/* Calculate Transmission */
- zt_transmit(&wc->span);
+ if (likely(wc->initialized)) {
+ zt_transmit(&wc->span);
+ }
for (x=0;x<ZT_CHUNKSIZE;x++) {
/* Send a sample, as a 32-bit word */
for (y=0;y < wc->cards;y++) {
- if (!x)
+ if (!x) {
cmd_checkisr(wc, y);
-
- if (y < wc->type)
- writechunk[y] = wc->chans[y].writechunk[x];
+ }
+
+ if (likely(wc->initialized)) {
+ if (y < wc->type)
+ writechunk[y] = wc->chans[y].writechunk[x];
+ }
cmd_dequeue(wc, writechunk, y, x);
}
#ifdef VPM_SUPPORT
 -776,8
+774,9 
wc->blinktimer++;
if (wc->vpm) {
for (y=24;y<28;y++) {
- if (!x)
+ if (!x) {
cmd_checkisr(wc, y);
+ }
cmd_dequeue(wc, writechunk, y, x);
}
#ifdef FANCY_ECHOCAN
 -808,24
+807,6 
}
}
-static inline void __wctdm_setctl(struct wctdm *wc,
unsigned int addr, unsigned int val)
-{
- outl(val, wc->iobase + addr);
-}
-
-static inline unsigned int __wctdm_getctl(struct wctdm *wc,
unsigned int addr)
-{
- return inl(wc->iobase + addr);
-}
-
-static inline void wctdm_setctl(struct wctdm *wc, unsigned
int addr, unsigned int val)
-{
- unsigned long flags;
- spin_lock_irqsave(&wc->reglock, flags);
- __wctdm_setctl(wc, addr, val);
- spin_unlock_irqrestore(&wc->reglock, flags);
-}
-
static inline int wctdm_setreg_full(struct wctdm *wc, int
card, int addr, int val, int inisr)
{
unsigned long flags;
 -900,96
+881,6 
}
} while (hit > -1);
return ret;
-}
-
-static inline unsigned int wctdm_getctl(struct wctdm *wc,
unsigned int addr)
-{
- unsigned long flags;
- unsigned int val;
- spin_lock_irqsave(&wc->reglock, flags);
- val = __wctdm_getctl(wc, addr);
- spin_unlock_irqrestore(&wc->reglock, flags);
- return val;
-}
-
-static inline int __wctdm_sdi_clk(struct wctdm *wc)
-{
- unsigned int ret;
- wc->sdi &= ~SDI_CLK;
- __wctdm_setctl(wc, 0x0048, wc->sdi);
- ret = __wctdm_getctl(wc, 0x0048);
- wc->sdi |= SDI_CLK;
- __wctdm_setctl(wc, 0x0048, wc->sdi);
- return ret & SDI_DIN;
-}
-
-static inline void __wctdm_sdi_sendbits(struct wctdm *wc,
unsigned int bits, int count)
-{
- wc->sdi &= ~SDI_DREAD;
- __wctdm_setctl(wc, 0x0048, wc->sdi);
- while(count--) {
- if (bits & (1 << count))
- wc->sdi |= SDI_DOUT;
- else
- wc->sdi &= ~SDI_DOUT;
- __wctdm_sdi_clk(wc);
- }
-}
-
-static inline unsigned int __wctdm_sdi_recvbits(struct
wctdm *wc, int count)
-{
- unsigned int bits=0;
- wc->sdi |= SDI_DREAD;
- __wctdm_setctl(wc, 0x0048, wc->sdi);
- while(count--) {
- bits <<= 1;
- if (__wctdm_sdi_clk(wc))
- bits |= 1;
- else
- bits &= ~1;
- }
- return bits;
-}
-
-static inline void __wctdm_setsdi(struct wctdm *wc,
unsigned char addr, unsigned short value)
-{
- unsigned int bits;
- /* Send preamble */
- bits = 0xffffffff;
- __wctdm_sdi_sendbits(wc, bits, 32);
- bits = (0x5 << 12) | (1 << 7) | (addr <<
2) | 0x2;
- __wctdm_sdi_sendbits(wc, bits, 16);
- __wctdm_sdi_sendbits(wc, value, 16);
-
-}
-
-static inline unsigned short __wctdm_getsdi(struct wctdm
*wc, unsigned char addr)
-{
- unsigned int bits;
- /* Send preamble */
- bits = 0xffffffff;
- __wctdm_sdi_sendbits(wc, bits, 32);
- bits = (0x6 << 10) | (1 << 5) | (addr);
- __wctdm_sdi_sendbits(wc, bits, 14);
- return __wctdm_sdi_recvbits(wc, 18);
-}
-
-static inline void wctdm_setsdi(struct wctdm *wc, unsigned
char addr, unsigned short value)
-{
- unsigned long flags;
- spin_lock_irqsave(&wc->reglock, flags);
- __wctdm_setsdi(wc, addr, value);
- spin_unlock_irqrestore(&wc->reglock, flags);
-}
-
-static inline unsigned short wctdm_getsdi(struct wctdm *wc,
unsigned char addr)
-{
- unsigned long flags;
- unsigned short val;
- spin_lock_irqsave(&wc->reglock, flags);
- val = __wctdm_getsdi(wc, addr);
- spin_unlock_irqrestore(&wc->reglock, flags);
- return val;
}
#ifdef VPM_SUPPORT
 -1039,17
+930,13 
#endif
}
-static inline void wctdm_receiveprep(struct wctdm *wc, int
dbl)
-{
- volatile unsigned char *readchunk;
+static inline void wctdm_receiveprep(struct wctdm *wc,
unsigned char *readchunk)
+{
int x,y;
unsigned char expected;
- dbl = dbl % 2;
-
- readchunk = (volatile unsigned char *)wc->readchunk;
- if (dbl)
- readchunk += SFRAME_SIZE;
+ BUG_ON(NULL == readchunk);
+
for (x=0;x<ZT_CHUNKSIZE;x++) {
if (x < ZT_CHUNKSIZE - 1) {
expected = wc->rxident+1;
 -1060,9
+947,11 
}
}
for (y=0;y < wc->cards;y++) {
- if (y < wc->type) {
- wc->chans[y].readchunk[x] = readchunk[y];
- }
+ if (likely(wc->initialized)) {
+ if (y < wc->type) {
+ wc->chans[y].readchunk[x] = readchunk[y];
+ }
+ }
cmd_decifer(wc, readchunk, y);
}
#ifdef VPM_SUPPORT
 -1072,25
+961,20 
} else if (wc->vpm150m)
cmd_decifer_vpm150m(wc, readchunk);
#endif
-#if 0
- if (cmddesc < 1024) {
- printk("RC Result: %02xn",
readchunk[EFRAME_SIZE+1]);
- }
-#endif
+
readchunk += (EFRAME_SIZE + EFRAME_GAP);
}
/* XXX We're wasting 8 taps. We should get closer :( */
- 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);
- }
- zt_receive(&wc->span);
+ if (likely(wc->initialized)) {
+ 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);
+ }
+ zt_receive(&wc->span);
+ }
/* Wake up anyone sleeping to read/write a new register
*/
wake_up_interruptible(&wc->regq);
}
-
-static void wctdm_stop_dma(struct wctdm *wc);
-static void wctdm_restart_dma(struct wctdm *wc);
static int wait_access(struct wctdm *wc, int card)
{
 -1342,6
+1226,7 
if (b != 0x8)
wctdm_setreg_intr(wc, card, 5, 0x8);
}
+
if (!wc->mods[card].fxo.offhook) {
if (fwringdetect) {
res = wc->cmdq[card].isrshadow[0] & 0x60;
 -1362,6
+1247,7 
printk("NO RING on %d/%d!n",
wc->span.spanno, card + 1);
zt_hooksig(&wc->chans[card],
ZT_RXSIG_OFFHOOK);
}
+ zt_hooksig(&wc->chans[card], ZT_RXSIG_RING);
}
} else if (res && (wc->mods[card].fxo.battery
== 1)) {
wc->mods[card].fxo.lastrdtx = res;
 -1379,6
+1265,7 
printk("RING on %d/%d!n",
wc->span.spanno, card + 1);
}
wc->mods[card].fxo.ringdebounce = ZT_CHUNKSIZE *
ringdebounce;
+ zt_hooksig(&wc->chans[card],
ZT_RXSIG_OFFHOOK);
}
} else {
wc->mods[card].fxo.ringdebounce -= ZT_CHUNKSIZE *
4;
 -1395,6
+1282,7 
}
}
}
+
b = wc->cmdq[card].isrshadow[1]; /* Voltage */
if (fxovoltage) {
 -1537,15
+1425,6 
}
-static inline void wctdm_reinit_descriptor(struct wctdm
*wc, int tx, int dbl, char *s)
-{
- int o2 = 0;
- o2 += dbl * 4;
- if (!tx)
- o2 += ERING_SIZE * 4;
- wc->descripchunk[o2] = 0x80000000;
-}
-
#ifdef VPM_SUPPORT
static inline void wctdm_vpm_check(struct wctdm *wc, int
x)
{
 -1615,6
+1494,10 
static inline void wctdm_isr_misc(struct wctdm *wc)
{
int x;
+
+ if (unlikely(!wc->initialized)) {
+ return;
+ }
for (x=0;x<wc->cards;x++) {
if (wc->cardflag & (1 << x)) {

-1661,122 +1544,22 
#endif
}
-static inline int wctdm_check_descriptor(struct wctdm *wc,
int tx)
-{
- int o2 = 0;
- if (!tx) {
- o2 += ERING_SIZE * 4;
- o2 += wc->rdbl * 4;
- } else {
- o2 += wc->tdbl * 4;
- }
- if (!(wc->descripchunk[o2] & 0x80000000)) {
- if (tx) {
- wc->txints++;
- wctdm_transmitprep(wc, wc->tdbl);
- wctdm_reinit_descriptor(wc, tx, wc->tdbl,
"txchk");
- wc->tdbl = (wc->tdbl + 1) % ERING_SIZE;
- wctdm_isr_misc(wc);
- wc->intcount++;
- } else {
- wc->rxints++;
- wctdm_receiveprep(wc, wc->rdbl);
- wctdm_reinit_descriptor(wc, tx, wc->rdbl,
"rxchk");
- wc->rdbl = (wc->rdbl + 1) % ERING_SIZE;
- }
- return 1;
- }
- return 0;
-}
-
-static void wctdm_init_descriptors(struct wctdm *wc)
-{
- volatile unsigned int *descrip;
- dma_addr_t descripdma;
- dma_addr_t writedma;
- dma_addr_t readdma;
- int x;
-
- descrip = wc->descripchunk;
- descripdma = wc->descripdma;
- writedma = wc->writedma;
- readdma = wc->readdma;
-
- for (x=0;x<ERING_SIZE;x++) {
- if (x < ERING_SIZE - 1)
- descripdma += 16;
- else
- descripdma = wc->descripdma;
-
- /* Transmit descriptor */
- descrip[0 ] = 0x80000000;
- descrip[1 ] = 0xe5800000 | (SFRAME_SIZE);
- if (x % 2)
- descrip[2 ] = writedma + SFRAME_SIZE;
- else
- descrip[2 ] = writedma;
- descrip[3 ] = descripdma;
-
- /* Receive descriptor */
- descrip[0 + ERING_SIZE * 4] = 0x80000000;
- descrip[1 + ERING_SIZE * 4] = 0x01000000 |
(SFRAME_SIZE);
- if (x % 2)
- descrip[2 + ERING_SIZE * 4] = readdma + SFRAME_SIZE;
- else
- descrip[2 + ERING_SIZE * 4] = readdma;
- descrip[3 + ERING_SIZE * 4] = descripdma + ERING_SIZE *
16;
-
- /* Advance descriptor */
- descrip += 4;
- }
-}
-
-ZAP_IRQ_HANDLER(wctdm_interrupt)
-{
- struct wctdm *wc = dev_id;
- unsigned int ints;
- int res;
-
- /* Read and clear interrupts */
- ints = wctdm_getctl(wc, 0x0028);
-
- if (!ints)
-#ifdef LINUX26
- return IRQ_NONE;
-#else
- return;
-#endif
-
- wctdm_setctl(wc, 0x0028, ints);
-
- ints &= wc->intmask;
- if (ints & 0x00000041) {
- do {
- res = wctdm_check_descriptor(wc, 0);
- res |= wctdm_check_descriptor(wc, 1);
- } while(res);
-#if 0
- while(wctdm_check_descriptor(wc, 0));
- wctdm_setctl(wc, 0x0010, 0x00000000);
- }
- if (ints & 0x00000005) {
- while(wctdm_check_descriptor(wc, 1));
- wctdm_setctl(wc, 0x0008, 0x00000000);
-#endif
- }
-
- if (ints & 0x0000a3ae) {
- /* This will allow us to recover if interrupts are held
for a long period of time */
- if (debug & DEBUG_CARD)
- printk("Abnormal interrupt %08x detectedn",
ints);
- wctdm_setctl(wc, 0x0008, 0x00000000);
- wctdm_setctl(wc, 0x0010, 0x00000000);
- }
-
-#ifdef LINUX26
- return IRQ_RETVAL(1);
-#endif
-
+void handle_receive(void* vbb, void* context)
+{
+ struct wctdm *wc = context;
+ wc->rxints++;
+ wctdm_receiveprep(wc, vbb);
+ voicebus_free(wc->vb, vbb);
+}
+
+void handle_transmit(void* vbb, void* context)
+{
+ struct wctdm *wc = context;
+ wc->txints++;
+ wctdm_transmitprep(wc, vbb);
+ wctdm_isr_misc(wc);
+ wc->intcount++;
+ voicebus_transmit(wc->vb, vbb);
}
static int wctdm_voicedaa_insane(struct wctdm *wc, int
card)
 -1808,6
+1591,7 
#endif
if (((blah & 0xf) == 0) || ((blah & 0xf) == 0xf))
{
/* SLIC not loaded */
+ // !!! printk(KERN_DEBUG "Here: %s:%d
blah=%xn", __FILE__, __LINE__, blah);
return -1;
}
if ((blah & 0xf) < 2) {
 -2149,6
+1933,10 
wctdm_setreg(wc, card, 18, 0);
wctdm_setreg(wc, card, 24, 0x19);
}
+
+ /* Enable ring detector full-wave rectifier mode */
+ wctdm_setreg(wc, card, 18, 2);
+ wctdm_setreg(wc, card, 24, 0);
/* Set DC Termination:
Tip/Ring voltage adjust, minimum operational current,
current limitation */
 -2590,33
+2378,6 
struct zt_radio_param p;
} stack;
-#if 0
- /* XXX */
- printk("RxInts: %d, TxInts: %dn",
wc->rxints, wc->txints);
- printk("RxIdent: %d, TxIdent: %dn",
wc->rxident, wc->txident);
- for (x=0;x<wc->cards;x++)
- printk("Card %d isrshadow: %02x/%02xn", x,
wc->cmdq[x].isrshadow[0], wc->cmdq[x].isrshadow[1]);
- cmddesc = 0;
-#endif
-#if 0
- if (wc->vpm) {
- char tmp[80];
- for (x=0;x<0x200;x++) {
- switch (x & 0xf) {
- case 0:
- sprintf(tmp, "%03x: %02x ", x,
wctdm_vpm_in(wc, 0, x));
- break;
- case 0xf:
- printk("%s%02xn", tmp, wctdm_vpm_in(wc, 0,
x));
- break;
- default:
- sprintf(tmp + strlen(tmp), "%02x ",
wctdm_vpm_in(wc, 0, x));
- break;
- }
- }
- }
-
-#endif
switch (cmd) {
case ZT_ONHOOKTRANSFER:
if (wc->modtype[chan->chanpos - 1] !=
MOD_TYPE_FXS)
 -2904,8
+2665,7 
static int wctdm_watchdog(struct zt_span *span, int event)
{
- printk("TDM: Restarting DMAn");
- wctdm_restart_dma(span->pvt);
+ printk("TDM: Called watchdogn");
return 0;
}
 -3129,13
+2889,14 
static int wctdm_initialize(struct wctdm *wc)
{
int x;
+ struct pci_dev *pdev = voicebus_get_pci_dev(wc->vb);
/* Zapata stuff */
sprintf(wc->span.name, "WCTDM/%d",
wc->pos);
snprintf(wc->span.desc, sizeof(wc->span.desc) - 1,
"%s Board %d", wc->variety, wc->pos + 1);
snprintf(wc->span.location,
sizeof(wc->span.location) - 1,
"PCI%s Bus %02d Slot %02d", (wc->flags[0]
& FLAG_EXPRESS) ? " Express" : "",
- wc->dev->bus->number,
PCI_SLOT(wc->dev->devfn) + 1);
+ pdev->bus->number, PCI_SLOT(pdev->devfn) + 1);
wc->span.manufacturer = "Digium";
strncpy(wc->span.devicetype, wc->variety,
sizeof(wc->span.devicetype) - 1);
if (alawoverride) {
 -3152,7
+2913,7 
}
wc->span.chans = wc->chans;
wc->span.channels = wc->type;
- wc->span.irq = wc->dev->irq;
+ wc->span.irq = pdev->irq;
wc->span.hooksig = wctdm_hooksig;
wc->span.open = wctdm_open;
wc->span.close = wctdm_close;
 -3166,10
+2927,6 
init_waitqueue_head(&wc->span.maintq);
wc->span.pvt = wc;
- if (zt_register(&wc->span, 0)) {
- printk("Unable to register span with
zapteln");
- return -1;
- }
return 0;
}

-3195,115 +2952,6 
strncat(wc->span.devicetype, " with
VPM100M", sizeof(wc->span.devicetype) - 1);
else if (wc->vpm150m)
strncat(wc->span.devicetype, " with
VPMADT032", sizeof(wc->span.devicetype) - 1);
-}
-
-static int wctdm_hardware_init(struct wctdm *wc)
-{
- /* Hardware stuff */
- unsigned int reg;
- unsigned long newjiffies;
-
- /* Initialize descriptors */
- wctdm_init_descriptors(wc);
-
- /* Enable I/O Access */
- pci_read_config_dword(wc->dev, 0x0004, ®);
- reg |= 0x00000007;
- pci_write_config_dword(wc->dev, 0x0004, reg);
- printk("PCI Config reg is %08xn", reg);
-
- wctdm_setctl(wc, 0x0000, 0xfff88001);
-
- newjiffies = jiffies + HZ/10;
- while(((reg = wctdm_getctl(wc,0x0000)) & 0x00000001)
&& (newjiffies > jiffies));
- printk("%s: New Reg: %08x!n", wc->variety,
reg);
- wctdm_setctl(wc, 0x0000, 0xfff88000);
-
-
- /* Configure watchdogs, access, etc */
- wctdm_setctl(wc, 0x0030, 0x00080048);
- wctdm_setctl(wc, 0x0078, 0x00000013 /* | (1 << 28)
*/);
-
-#if 0
- /* XXX Enable loopback XXX */
- reg = wctdm_getctl(wc, 0x0030);
- wctdm_setctl(wc, 0x0030, reg | 0x00000400);
-
-#else
- reg = wctdm_getctl(wc, 0x00fc);
- wctdm_setctl(wc, 0x00fc, (reg & ~0x7) | 0x7);
- wctdm_setsdi(wc, 0x00, 0x0100);
- wctdm_setsdi(wc, 0x16, 0x2100);
- printk("Detected REG0: %08xn", wctdm_getsdi(wc,
0x00));
- printk("Detected REG1: %08xn", wctdm_getsdi(wc,
0x01));
- printk("Detected REG2: %08xn", wctdm_getsdi(wc,
0x02));
-
- reg = wctdm_getctl(wc, 0x00fc);
- printk("(pre) Reg fc is %08xn", reg);
-
- wctdm_setctl(wc, 0x00fc, (reg & ~0x7) | 0x4);
- wctdm_setsdi(wc, 0x00, 0x0100);
- wctdm_setsdi(wc, 0x16, 0x2100);
- reg = wctdm_getctl(wc, 0x00fc);
- printk("(post) Reg fc is %08xn", reg);
- printk("Detected REG2: %08xn", wctdm_getsdi(wc,
0x02));
-#endif
- printk("wctdm24xxp: reg is %08xn",
wctdm_getctl(wc, 0x0088));
-
- return 0;
-}
-
-static void wctdm_setintmask(struct wctdm *wc, unsigned int
intmask)
-{
- wc->intmask = intmask;
- wctdm_setctl(wc, 0x0038, intmask);
-}
-
-static void wctdm_enable_interrupts(struct wctdm *wc)
-{
- /* Enable interrupts */
- wctdm_setintmask(wc, 0x00010041);
-}
-
-static void wctdm_restart_dma(struct wctdm *wc)
-
-
-static void wctdm_start_dma(struct wctdm *wc)
-{
- unsigned int reg;
- wmb();
- wctdm_setctl(wc, 0x0020, wc->descripdma);
- wctdm_setctl(wc, 0x0018, wc->descripdma + (16 *
ERING_SIZE));
- /* Start receiver/transmitter */
- reg = wctdm_getctl(wc, 0x0030);
- wctdm_setctl(wc, 0x0030, reg | 0x00002002);
- wctdm_setctl(wc, 0x0008, 0x00000000);
- wctdm_setctl(wc, 0x0010, 0x00000000);
- reg = wctdm_getctl(wc, 0x0028);
- wctdm_setctl(wc, 0x0028, reg);
-
-}
-
-static void wctdm_stop_dma(struct wctdm *wc)
-{
- /* Disable interrupts and reset */
- unsigned int reg;
- /* Disable interrupts */
- wctdm_setintmask(wc, 0x00000000);
- wctdm_setctl(wc, 0x0084, 0x00000000);
- wctdm_setctl(wc, 0x0048, 0x00000000);
- /* Reset the part to be on the safe side */
- reg = wctdm_getctl(wc, 0x0000);
- reg |= 0x00000001;
- wctdm_setctl(wc, 0x0000, reg);
-}
-
-static void wctdm_disable_interrupts(struct wctdm *wc)
-{
- /* Disable interrupts */
- wctdm_setintmask(wc, 0x00000000);
- wctdm_setctl(wc, 0x0084, 0x00000000);
}
#ifdef VPM_SUPPORT
 -3695,6
+3343,7 
struct vpm150m *vpm150m;
unsigned short reg;
unsigned long flags;
+ struct pci_dev* pdev = voicebus_get_pci_dev(wc->vb);
enum vpmadt032_init_result res = VPMADT032_FAILED;
#ifdef VPM150M_SUPPORT
 -3800,7
+3449,7 
if (pingstatus || (version != 0x106)) {
#endif
#if defined(HOTPLUG_FIRMWARE)
- if ((request_firmware(&firmware, vpmadt032_firmware,
&wc->dev->dev) != 0) ||
+ if ((request_firmware(&firmware, vpmadt032_firmware,
&pdev->dev) != 0) ||
!firmware) {
printk("VPMADT032: firmware %s not available from
userspacen", vpmadt032_firmware);
goto failed_exit;
 -4017,21
+3666,8 
{
int x;
unsigned long flags;
- printk("Resetting the modules...n");
- /* Initialize control register */
+ unsigned int startinglatency =
voicebus_current_latency(wc->vb);
wc->ctlreg = 0x00;
- /* Set Reset */
- wctdm_setctl(wc, 0x0048, 0x00000000);
- for (x=0;x<10;x++)
- schluffen(&wc->regq);
- printk("During Resetting the modules...n");
- /* Clear reset */
- wctdm_setctl(wc, 0x0048, 0x00010000);
- for (x=0;x<10;x++)
- schluffen(&wc->regq);
- printk("After resetting the modules...n");
-
- wctdm_setintmask(wc, 0x0001f7fe);
/* Make sure all units go into daisy chain mode */
spin_lock_irqsave(&wc->reglock, flags);
 -4065,6
+3701,9 
for (x=0;x<wc->cards;x++) {
int sane=0,ret=0,readi=0;
retry:
+ if (voicebus_current_latency(wc->vb) >
startinglatency) {
+ return -EAGAIN;
+ }
/* Init with Auto Calibration */
if (!(ret = wctdm_init_proslic(wc, x, 0, 0, sane))) {
wc->cardflag |= (1 << x);
 -4129,11
+3768,17 
printk("VPM: Present and operational (Rev
%c)n", 'A' + wc->vpm - 1);
wc->ctlreg |= 0x10;
} else {
+ enum vpmadt032_init_result res;
spin_lock_irqsave(&wc->reglock, flags);
for (x = NUM_CARDS; x < NUM_CARDS + NUM_EC; x++)
wc->modtype[x] = MOD_TYPE_NONE;
spin_unlock_irqrestore(&wc->reglock, flags);
- switch (wctdm_vpm150m_init(wc)) {
+ res = wctdm_vpm150m_init(wc);
+ /* In case there was an error while we were loading the
VPM module. */
+ if (voicebus_current_latency(wc->vb) >
startinglatency) {
+ return -EAGAIN;
+ }
+ switch (res) {
case VPMADT032_SUCCESS:
printk("VPMADT032: Present and operational
(Firmware version %x)n", wc->vpm150m->version);
wc->ctlreg |= 0x10;

-4143,173 +3788,139 
/* nothing */
break;
default:
- return -1;
- }
- }
-#endif
-
+ return -EIO;
+ }
+ }
+#endif
+ /* In case there was an error while we were loading the
VPM module. */
+ if (voicebus_current_latency(wc->vb) >
startinglatency) {
+ return -EAGAIN;
+ }
return 0;
}
+
+static struct pci_driver wctdm_driver;
static int __devinit wctdm_init_one(struct pci_dev *pdev,
const struct pci_device_id *ent)
{
struct wctdm *wc;
struct wctdm_desc *d = (struct wctdm_desc
*)ent->driver_data;
- int x;
+ int i;
int y;
-
- if (pci_enable_device(pdev))
- return -EIO;
-
- if (!(wc = kmalloc(sizeof(struct wctdm), GFP_KERNEL)))
+ int ret;
+
+retry:
+ wc = kmalloc(sizeof(struct wctdm), GFP_KERNEL);
+ if (!wc) {
+ /* todo Print debug message. */
return -ENOMEM;
-
- spin_lock(&ifacelock);
- for (x = 0; x < WC_MAX_IFACES; x++)
- if (!ifaces[x]) break;
-
- ifaces[x] = wc;
+ }
+ memset(wc, 0, sizeof(*wc));
+ spin_lock(&ifacelock);
+ /* todo this is a candidate for removal... */
+ for (i = 0; i < WC_MAX_IFACES; ++i) {
+ if (!ifaces[i]) {
+ ifaces[i] = wc;
+ break;
+ }
+ }
spin_unlock(&ifacelock);
-
- memset(wc, 0, sizeof(struct wctdm));
+
+ snprintf(wc->board_name, sizeof(wc->board_name)-1,
"%s%d",
+ wctdm_driver.name, i);
+ ret = voicebus_init(pdev, SFRAME_SIZE, wc->board_name,
+ handle_receive, handle_transmit, wc, &wc->vb);
+ if (ret) {
+ kfree(wc);
+ return ret;
+ }
+ BUG_ON(!wc->vb);
+
+ if (latency) {
+ voicebus_set_minlatency(wc->vb, latency);
+ }
+
spin_lock_init(&wc->reglock);
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->pos = i;
wc->variety = d->name;
+ wc->txident = 1;
for (y=0;y<NUM_CARDS;y++) {
wc->flags[y] = d->flags;
wc->dacssrc[y] = -1;
}
- /* Keep track of whether we need to free the region */
- if (request_region(wc->iobase, 0xff,
"wctdm24xxp"))
- wc->freeregion = 1;
-
- /* Allocate enough memory for two zt chunks, receive and
transmit. Each sample uses
- 32 bits. Allocate an extra set just for control too
*/
- wc->writechunk = pci_alloc_consistent(pdev,
PCI_WINDOW_SIZE, &wc->writedma);
- if (!wc->writechunk) {
- printk("wctdm: Unable to allocate DMA-able
memoryn");
- if (wc->freeregion)
- release_region(wc->iobase, 0xff);
- return -ENOMEM;
- }
-
- wc->readchunk = wc->writechunk + SFRAME_SIZE / 2; /*
in doublewords */
- wc->readdma = wc->writedma + SFRAME_SIZE * 2; /* in
bytes */
-
- wc->descripchunk = wc->readchunk + SFRAME_SIZE /
2; /* in doublewords */
- wc->descripdma = wc->readdma + SFRAME_SIZE * 2; /*
in bytes */
-
- /* Initialize Write/Buffers to all blank data */
- memset((void *)wc->writechunk,0x00, SFRAME_SIZE * 2);
- memset((void *)wc->readchunk, 0x00, SFRAME_SIZE * 2);
-
+
init_waitqueue_head(&wc->regq);
-
+
if (wctdm_initialize(wc)) {
- printk("%s: Unable to register span with
zapteln", wc->variety);
- /* Set Reset Low */
- wctdm_stop_dma(wc);
- /* Free Resources */
- if (wc->freeregion)
- release_region(wc->iobase, 0xff);
- pci_free_consistent(pdev, PCI_WINDOW_SIZE, (void
*)wc->writechunk, wc->writedma);
- zt_unregister(&wc->span);
+ voicebus_release(wc->vb);
+ wc->vb = NULL;
kfree(wc);
return -EIO;
}
-
- /* Enable bus mastering */
- pci_set_master(pdev);
-
+
+
/* Keep track of which device we are */
pci_set_drvdata(pdev, wc);
-
- if (request_irq(pdev->irq, wctdm_interrupt,
ZAP_IRQ_SHARED, wc->variety, wc)) {
- printk("wctdm24xxp: Unable to request IRQ
%dn", pdev->irq);
- /* Set Reset Low */
- wctdm_stop_dma(wc);
- /* Free Resources */
- if (wc->freeregion)
- release_region(wc->iobase, 0xff);
- pci_free_consistent(pdev, PCI_WINDOW_SIZE, (void
*)wc->writechunk, wc->writedma);
- pci_set_drvdata(pdev, NULL);
- zt_unregister(&wc->span);
- kfree(wc);
- return -EIO;
- }
-
-
- if (wctdm_hardware_init(wc)) {
- /* Set Reset Low */
- wctdm_stop_dma(wc);
- /* Free Resources */
- free_irq(pdev->irq, wc);
- if (wc->freeregion)
- release_region(wc->iobase, 0xff);
- pci_free_consistent(pdev, PCI_WINDOW_SIZE, (void
*)wc->writechunk, wc->writedma);
- pci_set_drvdata(pdev, NULL);
- zt_unregister(&wc->span);
- kfree(wc);
- return -EIO;
-
- }
-
- /* Enable interrupts */
- wctdm_enable_interrupts(wc);
-
- /* Start DMA */
- wctdm_start_dma(wc);
+
+ /* Start the hardware processing. */
+ if (voicebus_start(wc->vb)) {
+ BUG_ON(1);
+ }
/* Now track down what modules are installed */
- if (wctdm_locate_modules(wc)) {
- wctdm_disable_interrupts(wc);
- /* Set Reset Low */
- wctdm_stop_dma(wc);
- /* Free Resources */
- free_irq(pdev->irq, wc);
- if (wc->freeregion)
- release_region(wc->iobase, 0xff);
- pci_free_consistent(pdev, PCI_WINDOW_SIZE, (void
*)wc->writechunk, wc->writedma);
- pci_set_drvdata(pdev, NULL);
- zt_unregister(&wc->span);
- kfree(wc);
- return -EIO;
+ ret = wctdm_locate_modules(wc);
+ if (-EAGAIN == ret ) {
+ /* The voicebus library increased the latency during
+ * initialization. There is a chance that the hardware
is in
+ * an inconsistent state, so lets increase the default
latency
+ * and start the initialization over.
+ */
+ printk(KERN_NOTICE "%s: Restarting board
initialization "
+ "after increasing latency.n",
wc->board_name);
+ latency = voicebus_current_latency(wc->vb);
+ wctdm_release(wc);
+ goto retry;
}
/* Final initialization */
wctdm_post_initialize(wc);
+ /* We should be ready for zaptel to come in now. */
+ if (zt_register(&wc->span, 0)) {
+ printk("Unable to register span with
zapteln");
+ return -1;
+ }
+
+ wc->initialized = 1;
+
printk("Found a Wildcard TDM: %s (%d
modules)n", wc->variety, wc->type);
-
- return 0;
+ ret = 0;
+
+ return ret;
}
static void wctdm_release(struct wctdm *wc)
{
int i;
- zt_unregister(&wc->span);
-
- if (wc->freeregion)
- release_region(wc->iobase, 0xff);
+ if (wc->initialized) {
+ zt_unregister(&wc->span);
+ }
+
+ voicebus_release(wc->vb);
+ wc->vb = NULL;
spin_lock(&ifacelock);
-
for (i = 0; i < WC_MAX_IFACES; i++)
if (ifaces[i] == wc)
break;
-
ifaces[i] = NULL;
-
spin_unlock(&ifacelock);
kfree(wc);
- printk("Freed a Wildcardn");
}
static void __devexit wctdm_remove_one(struct pci_dev
*pdev)
 -4331,16
+3942,7 
destroy_workqueue(vpm150m->wq);
}
#endif
-
- /* Stop any DMA */
- wctdm_stop_dma(wc);
-
- /* In case hardware is still there */
- wctdm_disable_interrupts(wc);
-
- /* Immediately free resources */
- free_irq(pdev->irq, wc);
- pci_free_consistent(pdev, PCI_WINDOW_SIZE, (void
*)wc->writechunk, wc->writedma);
+ voicebus_stop(wc->vb);
#ifdef VPM150M_SUPPORT
if (vpm150m) {
 -4352,8
+3954,10 
}
#endif
/* Release span, possibly delayed */
- if (!wc->usecount)
+ if (!wc->usecount) {
wctdm_release(wc);
+ printk("Freed a Wildcardn");
+ }
else
wc->dead = 1;
}
 -4434,6
+4038,7 
module_param(fxsrxgain, int, 0600);
module_param(ringdebounce, int, 0600);
module_param(fwringdetect, int, 0600);
+module_param(latency, int, 0600);
#ifdef VPM_SUPPORT
module_param(vpmsupport, int, 0600);
module_param(vpmdtmfsupport, int, 0600);
Modified: team/sruffell/voicebus/wctdm24xxp/wctdm24xxp.h
URL: http://svn.digium.com/view/zaptel/team/sruffe
ll/voicebus/wctdm24xxp/wctdm24xxp.h?view=diff&rev=3799&a
mp;r1=3798&r2=3799
============================================================
==================
--- team/sruffell/voicebus/wctdm24xxp/wctdm24xxp.h
(original)
+++ team/sruffell/voicebus/wctdm24xxp/wctdm24xxp.h Tue Feb
5 12:15:03 2008
 -27,6
+27,10 
#ifndef _WCTDM24XXP_H
#define _WCTDM24XXP_H
+#include "../zaptel.h"
+#include "../voicebus.h"
+#include <asm/semaphore.h>
+
#define NUM_FXO_REGS 60
#define WC_MAX_IFACES 128
 -174,8
+178,8 
};
struct wctdm {
- struct pci_dev *dev;
char *variety;
+ char board_name[80];
struct zt_span span;
unsigned char ios;
unsigned int sdi;
 -183,16
+187,12 
unsigned int intcount;
unsigned int rxints;
unsigned int txints;
- unsigned int intmask;
unsigned char txident;
unsigned char rxident;
int dead;
int pos;
int flags[NUM_CARDS];
- int freeregion;
int alt;
- int rdbl;
- int tdbl;
int curcard;
unsigned char ctlreg;
int cards;
 -261,14
+261,9 
int blinktimer;
#endif
#endif
- unsigned long iobase;
- dma_addr_t readdma;
- dma_addr_t writedma;
- dma_addr_t descripdma;
- volatile unsigned int *writechunk; /* Double-word
aligned write memory */
- volatile unsigned int *readchunk; /* Double-word
aligned read memory */
- volatile unsigned int *descripchunk; /* Descriptors
*/
+ struct voicebus *vb;
struct zt_chan chans[NUM_CARDS];
+ int initialized;
};
Modified: team/sruffell/voicebus/wcte12xp/Kbuild
URL: http://svn.digium.com/view/zaptel/team/sruffell/voice
bus/wcte12xp/Kbuild?view=diff&rev=3799&r1=3798&r
2=3799
============================================================
==================
--- team/sruffell/voicebus/wcte12xp/Kbuild (original)
+++ team/sruffell/voicebus/wcte12xp/Kbuild Tue Feb 5
12:15:03 2008
 -6,7
+6,7 
EXTRA_CFLAGS+=-DHOTPLUG_FIRMWARE
endif
-wcte12xp-objs := base.o vpmadt032.o GpakApi.o
+wcte12xp-objs := base.o vpmadt032.o GpakApi.o
../voicebus.o
ifneq ($(HOTPLUG_FIRMWARE),yes)
wcte12xp-objs += ../firmware/zaptel-fw-vpmadt032.o
Modified: team/sruffell/voicebus/wcte12xp/base.c
URL: http://svn.digium.com/view/zaptel/team/sruffell/voice
bus/wcte12xp/base.c?view=diff&rev=3799&r1=3798&r
2=3799
============================================================
==================
--- team/sruffell/voicebus/wcte12xp/base.c (original)
+++ team/sruffell/voicebus/wcte12xp/base.c Tue Feb 5
12:15:03 2008
 -8,7
+8,7 
* Matthew Fredrickson <creslin digium.com>
* William Meadows <wmeadows digium.com>
*
- * Copyright (C) 2007, Digium, Inc.
+ * Copyright (C) 2007-2008, Digium, Inc.
*
* All rights reserved.
*
 -34,9
+34,7 
#include <linux/init.h>
#include <linux/errno.h>
#include <linux/pci.h>
-#include <linux/interrupt.h>
#include <linux/proc_fs.h>
-#include <linux/interrupt.h>
#ifdef LINUX26
#include <linux/moduleparam.h>
 -46,6
+44,7 
#include "../wct4xxp/wct4xxp.h" /* For certain
definitions */
+#include "../voicebus.h"
#include "wcte12xp.h"
#if defined(VPM_SUPPORT)
 -91,6
+90,7 
static int loopback = 0;
static int t1e1override = -1;
static int unchannelized = 0;
+static int latency = 0;
#ifdef VPM_SUPPORT
int vpmsupport = 1;
int vpmdtmfsupport = 0;
 -133,89
+133,6 
return x;
}
return -1;
-}
-
-static inline void __t1_setctl(struct t1 *wc, unsigned int
addr, unsigned int val)
-{
- outl(val, wc->iobase + addr);
-}
-
-static inline void t1_setctl(struct t1 *wc, unsigned int
addr, unsigned int val)
-{
- unsigned long flags;
-
- spin_lock_irqsave(&wc->reglock, flags);
- __t1_setctl(wc, addr, val);
- spin_unlock_irqrestore(&wc->reglock, flags);
-}
-
-static inline unsigned int __t1_getctl(struct t1 *wc,
unsigned int addr)
-{
- return inl(wc->iobase + addr);
-}
-
-static inline unsigned int t1_getctl(struct t1 *wc,
unsigned int addr)
-{
- unsigned long flags;
- unsigned int val;
-
- spin_lock_irqsave(&wc->reglock, flags);
- val = __t1_getctl(wc, addr);
- spin_unlock_irqrestore(&wc->reglock, flags);
-
- return val;
-}
-
-static void t1_init_descriptors(struct t1 *wc)
-{
- volatile unsigned int *descrip;
- dma_addr_t descripdma;
- dma_addr_t writedma;
- dma_addr_t readdma;
- int x;
-
- descrip = wc->descripchunk;
- descripdma = wc->descripdma;
- writedma = wc->writedma;
- readdma = wc->readdma;
-
- for (x = 0; x < ERING_SIZE; x++) {
- if (x < ERING_SIZE - 1)
- descripdma += 16;
- else
- descripdma = wc->descripdma;
-
- /* Transmit descriptor */
- descrip[0] = 0x80000000;
- descrip[1] = 0xe5800000 | (SFRAME_SIZE);
- if (x % 2)
- descrip[2] = writedma + SFRAME_SIZE;
- else
- descrip[2] = writedma;
- descrip[3] = descripdma;
-
- /* Receive descriptor */
- descrip[0 + ERING_SIZE * 4] = 0x80000000;
- descrip[1 + ERING_SIZE * 4] = 0x01000000 |
(SFRAME_SIZE);
- if (x % 2)
- descrip[2 + ERING_SIZE * 4] = readdma + SFRAME_SIZE;
- else
- descrip[2 + ERING_SIZE * 4] = readdma;
- descrip[3 + ERING_SIZE * 4] = descripdma + ERING_SIZE *
16;
-
- /* Advance descriptor */
- descrip += 4;
- }
-}
-
-static inline void t1_reinit_descriptor(struct t1 *wc, int
tx, int dbl, char *s)
-{
- int o2 = dbl * 4;
-
- if (!tx)
- o2 += ERING_SIZE * 4;
-
- wc->descripchunk[o2] = 0x80000000;
}
static inline void cmd_dequeue(struct t1 *wc, volatile
unsigned char *writechunk, int eframe, int slot)
 -290,93
+207,6 
}
}
-static inline unsigned int __t1_sdi_clk(struct t1 *wc)
-{
- unsigned int ret;
-
- wc->sdi &= ~SDI_CLK;
- __t1_setctl(wc, 0x0048, wc->sdi);
- ret = __t1_getctl(wc, 0x0048);
- wc->sdi |= SDI_CLK;
- __t1_setctl(wc, 0x0048, wc->sdi);
- return ret & SDI_DIN;
-}
-
-static inline void __t1_sdi_sendbits(struct t1 *wc,
unsigned int bits, int count)
-{
- wc->sdi &= ~SDI_DREAD;
- __t1_setctl(wc, 0x0048, wc->sdi);
- while (count--) {
- if (bits & (1 << count))
- wc->sdi |= SDI_DOUT;
- else
- wc->sdi &= ~SDI_DOUT;
- __t1_sdi_clk(wc);
- }
-}
-
-static inline unsigned int __t1_sdi_recvbits(struct t1 *wc,
int count)
-{
- unsigned int bits=0;
-
- wc->sdi |= SDI_DREAD;
- __t1_setctl(wc, 0x0048, wc->sdi);
- while (count--) {
- bits <<= 1;
- if (__t1_sdi_clk(wc))
- bits |= 1;
- else
- bits &= ~1;
- }
- return bits;
-}
-
-static inline unsigned short __t1_getsdi(struct t1 *wc,
unsigned char addr)
-{
- unsigned int bits;
-
- /* Send preamble */
- bits = 0xffffffff;
- __t1_sdi_sendbits(wc, bits, 32);
- bits = (0x6 << 10) | (1 << 5) | (addr);
- __t1_sdi_sendbits(wc, bits, 14);
-
- return __t1_sdi_recvbits(wc, 18);
-}
-
-static inline unsigned short t1_getsdi(struct t1 *wc,
unsigned char addr)
-{
- unsigned long flags;
- unsigned short val;
-
- spin_lock_irqsave(&wc->reglock, flags);
- val = __t1_getsdi(wc, addr);
- spin_unlock_irqrestore(&wc->reglock, flags);
-
- return val;
-}
-
-static inline void __t1_setsdi(struct t1 *wc, unsigned char
addr, unsigned short value)
-{
- unsigned int bits;
-
- /* Send preamble */
- bits = 0xffffffff;
- __t1_sdi_sendbits(wc, bits, 32);
- bits = (0x5 << 12) | (1 << 7) | (addr <<
2) | 0x2;
- __t1_sdi_sendbits(wc, bits, 16);
- __t1_sdi_sendbits(wc, value, 16);
-}
-
-static inline void t1_setsdi(struct t1 *wc, unsigned char
addr, unsigned short value)
-{
- unsigned long flags;
-
- spin_lock_irqsave(&wc->reglock, flags);
- __t1_setsdi(wc, addr, value);
- spin_unlock_irqrestore(&wc->reglock, flags);
-}
-
static inline int t1_setreg_full(struct t1 *wc, int addr,
int val, int inisr, int vpm_num)
{
unsigned long flags;
 -451,10
+281,16 
/* find our requested command */
for (x = 0;x < sizeof(wc->cmdq.cmds) /
sizeof(wc->cmdq.cmds[0]); x++) {
if ((wc->cmdq.cmds[x].flags & __CMD_RD)
&&
- (wc->cmdq.cmds[x].flags & __CMD_FIN)
&&
- (wc->cmdq.cmds[x].address==addr)) {
- hit = x;
- break;
+ (wc->cmdq.cmds[x].address==addr))
+ {
+ if (wc->cmdq.cmds[x].flags & __CMD_FIN) {
+ hit = x;
+ break;
+ }
+ else {
+ /* still in progress. */
+ return -1;
+ }
}
}
 -593,68
+429,6 
} while (hit > -1);
return ret;
-}
-
-static void t1_setintmask(struct t1 *wc, unsigned int
intmask)
-{
- wc->intmask = intmask;
- t1_setctl(wc, 0x0038, intmask);
-}
-
-static void t1_enable_interrupts(struct t1 *wc)
-{
- /* Enable interrupts */
- t1_setintmask(wc, 0x00010041); /* only RX */
-}
-
-static void t1_disable_interrupts(struct t1 *wc)
-{
- /* Disable interrupts */
- t1_setintmask(wc, 0x00000000);
- t1_setctl(wc, 0x0084, 0x00000000);
-}
-
-static void t1_start_dma(struct t1 *wc)
-{
- unsigned int reg;
- int x;
-
- wmb();
- t1_setctl(wc, 0x0020, wc->descripdma);
- t1_setctl(wc, 0x0018, wc->descripdma + (16 *
ERING_SIZE));
- /* Start receiver/transmitter */
- reg = t1_getctl(wc, 0x0030);
- t1_setctl(wc, 0x0030, reg | 0x00002002);
- t1_setctl(wc, 0x0008, 0x00000000);
- t1_setctl(wc, 0x0010, 0x00000000);
- reg = t1_getctl(wc, 0x0028);
- t1_setctl(wc, 0x0028, reg);
-
- /* Set Reset - now with MAGIC TIPS */
- t1_setctl(wc, 0x0048, 0x00000000);
- for (x = 0; x < 10; x++)
- schluffen(&wc->regq);
- /* Clear reset */
- t1_setctl(wc, 0x0048, 0x00010000);
- for (x = 0; x < 10; x++)
- schluffen(&wc->regq);
- /* Switch to caring only about receive interrupts */
- t1_setintmask(wc, 0x00010040);
-}
-
-static void t1_stop_dma(struct t1 *wc)
-{
- /* Disable interrupts and reset */
[... 727 lines stripped ...]
_______________________________________________
--Bandwidth and Colocation Provided by http://www.api-digital.c
om--
zaptel-commits mailing list
To UNSUBSCRIBE or update options visit:
http://lists.digium.com/mailman/listinfo/zaptel-commits
a>
|