From c88e65b25113ec3ceea2ffea1c6cb482c3977b07 Mon Sep 17 00:00:00 2001 From: markster Date: Fri, 2 Apr 2004 16:58:23 +0000 Subject: Various timing fixes... git-svn-id: http://svn.digium.com/svn/zaptel/trunk@339 5390a7c7-147a-4af0-8ec9-7488f05a26cb --- wct4xxp.c | 42 ++++++++++++++++++++++++------------------ 1 file changed, 24 insertions(+), 18 deletions(-) (limited to 'wct4xxp.c') diff --git a/wct4xxp.c b/wct4xxp.c index 43190a0..c2d0fc7 100755 --- a/wct4xxp.c +++ b/wct4xxp.c @@ -637,28 +637,32 @@ static void t4_set_timing_source(struct t4 *wc, int unit) int x; timing = 0x34; /* CMR1: RCLK unit, 8.192 Mhz TCLK, RCLK is 8.192 Mhz */ spin_lock_irqsave(&synclock, flags); - if ((unit > -1) && (unit < 4)) { - timing |= (unit << 6); - } else { - timing |= 0x1; /* Use TCLK timing */ - } - for (x=0;x<4;x++) - t4_framer_out(wc, x, 0x44, timing); - if ((unit > -1) && (unit < 4)) { - t4_pci_out(wc, WC_DMACTRL, wc->dmactrl | (1 << 29)); - /* GPC1: Multiplex mode enabled, FSC is output, active low, RCLK from proper channel, */ - t4_framer_out(wc, 0, 0x85, 0xe0 | (unit << 2) | (unit)); - } else - t4_pci_out(wc, WC_DMACTRL, wc->dmactrl); if (unit != wc->syncsrc) { + if ((unit > -1) && (unit < 4)) { + timing |= (unit << 6); + } else { + timing |= 0x1; /* Use TCLK timing */ + } + for (x=0;x<4;x++) + t4_framer_out(wc, x, 0x44, timing); + if ((unit > -1) && (unit < 4)) { + t4_pci_out(wc, WC_DMACTRL, wc->dmactrl | (1 << 29)); + /* GPC1: Multiplex mode enabled, FSC is output, active low, RCLK from proper channel, */ + t4_framer_out(wc, 0, 0x85, 0xe0 | (unit << 2) | (unit)); + } else + t4_pci_out(wc, WC_DMACTRL, wc->dmactrl); if ((unit > -1) && (unit < 4)) printk("TE410P: Timing from source %d\n", unit); else printk("TE410P: Timing from internal timer\n"); - } - wc->syncsrc = unit; - for (x=0;x<4;x++) - wc->spans[x].syncsrc = unit; + wc->syncsrc = unit; + if ((unit < 0) || (unit > 3)) + unit = 0; + else + unit++; + for (x=0;x<4;x++) + wc->spans[x].syncsrc = unit; + } spin_unlock_irqrestore(&synclock, flags); } @@ -873,6 +877,7 @@ static int t4_startup(struct zt_span *span) if (wc->syncs[1] == span->spanno) printk("SPAN %d: Secondary Sync Source\n",span->spanno); if (wc->syncs[2] == span->spanno) printk("SPAN %d: Tertiary Sync Source\n",span->spanno); if (wc->syncs[3] == span->spanno) printk("SPAN %d: Quaternary Sync Source\n",span->spanno); + t4_set_timing_source_auto(wc); return 0; } @@ -1187,6 +1192,8 @@ static void __t4_check_alarms(struct t4 *wc, int span) /* Assume no alarms */ alarms = 0; + + oldalarms = wc->spans[span].alarms; /* And consider only carrier alarms */ wc->spans[span].alarms &= (ZT_ALARM_RED | ZT_ALARM_BLUE | ZT_ALARM_NOTOPEN); @@ -1291,7 +1298,6 @@ static void __t4_check_alarms(struct t4 *wc, int span) if (wc->spans[span].mainttimer || wc->spans[span].maintstat) alarms |= ZT_ALARM_LOOPBACK; - oldalarms = wc->spans[span].alarms; wc->spans[span].alarms = alarms; /* Re-check the timing source when we enter alarm */ if (!oldalarms && alarms) -- cgit v1.2.3