summaryrefslogtreecommitdiff
path: root/drivers/dahdi/wcb4xxp/base.c
diff options
context:
space:
mode:
authorTzafrir Cohen <tzafrir.cohen@xorcom.com>2009-07-02 20:18:59 +0000
committerTzafrir Cohen <tzafrir.cohen@xorcom.com>2009-07-02 20:18:59 +0000
commit298c78efc8c91a359bc7489578e3a144a33f4e8d (patch)
tree16251ac75348030f435259bc02a46b05956aa1d0 /drivers/dahdi/wcb4xxp/base.c
parent9e4ca300decee698ea432904df28c5a893f7343d (diff)
wcb4xxp: Fix LED handling in OpenVox cards (maybe also others)
This commit adds extra functions to handle LEDs in the non-B410P cards. Only tested on OpenVox cards. OpenVox cards are known to have slightly different LEDs so this is likely to be slightly broken for others. git-svn-id: http://svn.asterisk.org/svn/dahdi/linux/trunk@6821 a0bf4364-ded3-4de4-8d8a-66a801d63aff
Diffstat (limited to 'drivers/dahdi/wcb4xxp/base.c')
-rw-r--r--drivers/dahdi/wcb4xxp/base.c85
1 files changed, 85 insertions, 0 deletions
diff --git a/drivers/dahdi/wcb4xxp/base.c b/drivers/dahdi/wcb4xxp/base.c
index 137bddb..192303e 100644
--- a/drivers/dahdi/wcb4xxp/base.c
+++ b/drivers/dahdi/wcb4xxp/base.c
@@ -1937,6 +1937,79 @@ static void b4xxp_setleds(struct b4xxp *b4, unsigned char val)
ec_write(b4, 0, 0x1a8 + 3, val);
}
+static void b4xxp_update_leds_hfc_8s(struct b4xxp *b4)
+{
+ unsigned long lled = 0; /* A bit set is a led OFF */
+ unsigned long leddw;
+ int j;
+ struct b4xxp_span *bspan;
+
+ b4->blinktimer++;
+ for (j = 7; j >= 0; j--) {
+ bspan = &b4->spans[7 - j];
+ if (!(bspan->span.flags & DAHDI_FLAG_RUNNING) ||
+ bspan->span.alarms) {
+ BIT_SET(lled, j);
+ continue; /* Led OFF */
+ }
+
+ if (bspan->span.mainttimer || bspan->span.maintstat) {
+ /* Led Blinking in maint state */
+ if (b4->blinktimer >= 0x7f)
+ BIT_SET(lled, j);
+ }
+ /* Else: Led on */
+ }
+
+ /* Write Leds...*/
+ leddw = lled << 24 | lled << 16 | lled << 8 | lled;
+ b4xxp_setreg8(b4, R_BRG_PCM_CFG, 0x21);
+ iowrite16(0x4000, b4->ioaddr + 4);
+ iowrite32(leddw, b4->ioaddr);
+ b4xxp_setreg8(b4, R_BRG_PCM_CFG, 0x20);
+
+ if (b4->blinktimer == 0xff)
+ b4->blinktimer = -1;
+}
+
+/* So far only tested for OpenVox cards. Please test it for other hardware */
+static void b4xxp_update_leds_hfc(struct b4xxp *b4)
+{
+ int i;
+ int leds = 0, green_leds = 0; /* Default: off */
+ struct b4xxp_span *bspan;
+
+ b4->blinktimer++;
+ for (i=0; i < b4->numspans; i++) {
+ bspan = &b4->spans[i];
+
+ if (!(bspan->span.flags & DAHDI_FLAG_RUNNING))
+ continue; /* Leds are off */
+
+ if (bspan->span.alarms) {
+ /* Red blinking -> Alarm */
+ if (b4->blinktimer >= 0x7f)
+ BIT_SET(leds, i);
+ } else if (bspan->span.mainttimer || bspan->span.maintstat) {
+ /* Green blinking -> Maint status */
+ if (b4->blinktimer >= 0x7f)
+ BIT_SET(green_leds, i);
+ } else {
+ /* Steady grean -> No Alarm */
+ BIT_SET(green_leds, i);
+ }
+ }
+
+ /* Actually set them. for red: just set the bit in R_GPIO_EN1.
+ For green: in both R_GPIO_EN1 and R_GPIO_OUT1. */
+ leds |= green_leds;
+ b4xxp_setreg8(b4, R_GPIO_EN1, leds);
+ b4xxp_setreg8(b4, R_GPIO_OUT1, green_leds);
+
+ if (b4->blinktimer == 0xff)
+ b4->blinktimer = -1;
+}
+
static void b4xxp_set_span_led(struct b4xxp *b4, int span, unsigned char val)
{
int shift, spanmask;
@@ -1954,6 +2027,18 @@ static void b4xxp_update_leds(struct b4xxp *b4)
int i;
struct b4xxp_span *bspan;
+ if (b4->numspans == 8) {
+ /* Use the alternative function for non-Digium HFC-8S cards */
+ b4xxp_update_leds_hfc_8s(b4);
+ return;
+ }
+
+ if (b4->card_type != B410P) {
+ /* Use the alternative function for non-Digium HFC-4S cards */
+ b4xxp_update_leds_hfc(b4);
+ return;
+ }
+
b4->blinktimer++;
for (i=0; i < b4->numspans; i++) {
bspan = &b4->spans[i];