diff options
Diffstat (limited to 'wct4xxp.c')
-rwxr-xr-x | wct4xxp.c | 21 |
1 files changed, 17 insertions, 4 deletions
@@ -142,6 +142,7 @@ static int t4_rbsbits(struct zt_chan *chan, int bits); static int t4_maint(struct zt_span *span, int cmd); static int t4_reset_dma(struct t4 *wc); static int t4_ioctl(struct zt_chan *chan, unsigned int cmd, unsigned long data); +static void t4_set_timing_source_auto(struct t4 *wc); #define WC_RDADDR 0 #define WC_WRADDR 1 @@ -480,7 +481,6 @@ static int t4_spanconfig(struct zt_span *span, struct zt_lineconfig *lc) span->lineconfig = lc->lineconfig; span->txlevel = lc->lbo; span->rxlevel = 0; - span->syncsrc = wc->syncsrc; if (lc->sync < 0) lc->sync = 0; if (lc->sync > 4) @@ -502,6 +502,7 @@ static int t4_spanconfig(struct zt_span *span, struct zt_lineconfig *lc) /* If we're already running, then go ahead and apply the changes */ if (span->flags & ZT_FLAG_RUNNING) return t4_startup(span); + t4_set_timing_source_auto(wc); return 0; } @@ -644,7 +645,13 @@ static void t4_set_timing_source(struct t4 *wc, int unit) t4_framer_out(wc, 0, 0x85, 0xe0 | (unit << 2) | (unit)); } else t4_pci_out(wc, WC_DMACTRL, wc->dmactrl); - printk("TE410P: Timing from source %d\n", unit); + if (unit != wc->syncsrc) { + if ((unit > -1) && (unit < 4)) + printk("TE410P: Timing from source %d\n", unit); + else + printk("TE410P: Timing from internal timer\n"); + } + wc->syncsrc = unit; } static void t4_set_timing_source_auto(struct t4 *wc) @@ -1151,6 +1158,7 @@ static void __t4_do_counters(struct t4 *wc) if (wc->alarmtimer[span]) { if (!--wc->alarmtimer[span]) { wc->spans[span].alarms &= ~(ZT_ALARM_RECOVER); + t4_set_timing_source_auto(wc); zt_alarm_notify(&wc->spans[span]); } } @@ -1160,7 +1168,7 @@ static void __t4_do_counters(struct t4 *wc) static void __t4_check_alarms(struct t4 *wc, int span) { unsigned char c,d; - int alarms; + int alarms, oldalarms; int x,j; if (!(wc->spans[span].flags & ZT_FLAG_RUNNING)) @@ -1232,8 +1240,9 @@ static void __t4_check_alarms(struct t4 *wc, int span) if (c & 0x4) alarms |= ZT_ALARM_BLUE; /* Keep track of recovering */ - if ((!alarms) && wc->spans[span].alarms) + if ((!alarms) && wc->spans[span].alarms) wc->alarmtimer[span] = ZT_ALARMSETTLE_TIME; + /* If receiving alarms, go into Yellow alarm state */ if (alarms && (!wc->spans[span].alarms)) { @@ -1274,7 +1283,11 @@ 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) + t4_set_timing_source_auto(wc); zt_alarm_notify(&wc->spans[span]); } |