From 7849ef9b1f61e84c3246534477980a21abd50a1a Mon Sep 17 00:00:00 2001 From: markster Date: Thu, 25 Sep 2003 06:07:28 +0000 Subject: Work around slightly buggy framer when dealing with LMFA while FA is good git-svn-id: http://svn.digium.com/svn/zaptel/trunk@247 5390a7c7-147a-4af0-8ec9-7488f05a26cb --- wct4xxp.c | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) (limited to 'wct4xxp.c') diff --git a/wct4xxp.c b/wct4xxp.c index f1f1b15..f4ffbf3 100755 --- a/wct4xxp.c +++ b/wct4xxp.c @@ -68,6 +68,7 @@ static int altab[] = { #define MAX_SPANS 16 #define FLAG_STARTED (1 << 0) +#define FLAG_NMF (1 << 1) #define TYPE_T1 1 /* is a T1 card */ #define TYPE_E1 2 /* is an E1 card */ @@ -94,6 +95,7 @@ struct t4 { int irq; /* IRQ used by device */ int order; /* Order */ int flags; /* Device flags */ + int spanflags[4]; /* Span flags */ int syncpos[4]; /* span-relative sync sources */ int master; /* Are we master */ int ledreg; /* LED Register */ @@ -687,11 +689,11 @@ static void __t4_configure_e1(struct t4 *wc, int unit, int lineconfig) unsigned int fmr2, fmr1, fmr0; char *crc4 = ""; char *framing, *line; - fmr1 = 0x4c; /* FMR1: E1 mode, Automatic force resync, PCM30 mode, 8.192 Mhz backplane, no XAIS */ + fmr1 = 0x44; /* FMR1: E1 mode, Automatic force resync, PCM30 mode, 8.192 Mhz backplane, no XAIS */ fmr2 = 0x03 /* | 0x4 */; /* FMR2: Auto transmit remote alarm, auto loss of multiframe recovery, no payload loopback */ if (lineconfig & ZT_CONFIG_CRC4) { fmr1 |= 0x08; /* CRC4 transmit */ - fmr2 |= 0x80; /* CRC4 receive */ + fmr2 |= 0xc0; /* CRC4 receive */ crc4 = "/CRC4"; } __t4_framer_out(wc, unit, 0x1d, fmr1); @@ -741,8 +743,8 @@ static void __t4_configure_e1(struct t4 *wc, int unit, int lineconfig) /* Generate pulse mask for E1 */ - __t4_framer_out(wc, unit, 0x26, 0x9c); /* XPM0 */ - __t4_framer_out(wc, unit, 0x27, 0x03); /* XPM1 */ + __t4_framer_out(wc, unit, 0x26, 0x54); /* XPM0 */ + __t4_framer_out(wc, unit, 0x27, 0x02); /* XPM1 */ __t4_framer_out(wc, unit, 0x28, 0x00); /* XPM2 */ printk("TE410P: Span %d configured for %s/%s%s\n", unit + 1, framing, line, crc4); } @@ -1083,7 +1085,25 @@ static void __t4_check_alarms(struct t4 *wc, int span) wc->spans[span].alarms &= (ZT_ALARM_RED | ZT_ALARM_BLUE | ZT_ALARM_NOTOPEN); if (wc->spantype[span] == TYPE_E1) { - /* XXX Implement me XXX */ + if (c & 0x04) { + /* No multiframe found, force RAI high after 400ms only if + we haven't found a multiframe since last loss + of frame */ + if (!(wc->spanflags[span] & FLAG_NMF)) { + __t4_framer_out(wc, span, 0x20, 0x9f | 0x20); /* LIM0: Force RAI High */ + wc->spanflags[span] |= FLAG_NMF; + printk("NMF workaround on!\n"); + } + __t4_framer_out(wc, span, 0x1e, 0xc3); /* Reset to CRC4 mode */ + __t4_framer_out(wc, span, 0x1c, 0xf2); /* Force Resync */ + __t4_framer_out(wc, span, 0x1c, 0xf0); /* Force Resync */ + } else if (!(c & 0x02)) { + if ((wc->spanflags[span] & FLAG_NMF)) { + __t4_framer_out(wc, span, 0x20, 0x9f); /* LIM0: Clear forced RAI */ + wc->spanflags[span] &= ~FLAG_NMF; + printk("NMF workaround off!\n"); + } + } } else { /* Detect loopup code if we're not sending one */ if ((!wc->spans[span].mainttimer) && (d & 0x08)) { -- cgit v1.2.3