diff --git a/drivers/dahdi/wcte12xp/base.c b/drivers/dahdi/wcte12xp/base.c index 19ca58e..ad3b3df 100644 --- a/drivers/dahdi/wcte12xp/base.c +++ b/drivers/dahdi/wcte12xp/base.c @@ -851,6 +851,75 @@ static void free_wc(struct t1 *wc) kfree(wc); } +/** + * t1_reset_registers - Put register back to their default values + * + * Since the card does not have an ability to reset just the framer + * specifically, we need to write all the default values to the framer. + * + */ +static void t1_reset_registers(struct t1 *wc) +{ + int i; + struct t1_reg { + u8 address; + u8 value; + } __attribute__((packed)); + struct t1_reg *reg; + static struct t1_reg DEFAULT_REGS[] = { + {0x00, 0x7d}, {0x01, 0x7d}, {0x02, 0x00}, {0x03, 0x00}, + {0x04, 0xfd}, {0x05, 0xff}, {0x06, 0xff}, {0x07, 0xff}, + {0x08, 0x05}, {0x09, 0x00}, {0x0a, 0x00}, {0x0b, 0x00}, + {0x0c, 0x00}, {0x0d, 0x00}, {0x0e, 0x00}, {0x0f, 0x00}, + {0x10, 0x00}, {0x11, 0x00}, {0x12, 0x00}, {0x13, 0x00}, + {0x14, 0xff}, {0x15, 0xff}, {0x16, 0xff}, {0x17, 0xff}, + {0x18, 0xff}, {0x19, 0xff}, {0x1a, 0x00}, {0x1b, 0x00}, + {0x1c, 0x00}, {0x1d, 0x00}, {0x1e, 0x00}, {0x1f, 0x00}, + {0x20, 0x00}, {0x21, 0x00}, {0x22, 0x00}, {0x23, 0x04}, + {0x24, 0x00}, {0x25, 0x05}, {0x26, 0x7b}, {0x27, 0x03}, + {0x28, 0x40}, {0x29, 0x00}, {0x2a, 0x00}, {0x2b, 0x00}, + {0x2c, 0x00}, {0x2d, 0x00}, {0x2e, 0x00}, {0x2f, 0x00}, + {0x30, 0x00}, {0x31, 0x00}, {0x32, 0x00}, {0x33, 0x00}, + {0x34, 0x00}, {0x35, 0x00}, {0x36, 0x00}, {0x37, 0x80}, + {0x38, 0x00}, {0x39, 0x00}, {0x3a, 0x20}, {0x3b, 0x00}, + {0x3c, 0x00}, {0x3d, 0x00}, {0x3e, 0x0a}, {0x3f, 0x00}, + {0x40, 0x04}, {0x41, 0x00}, {0x42, 0x00}, {0x43, 0x00}, + {0x44, 0x30}, {0x45, 0x00}, {0x46, 0xc0}, {0x47, 0xff}, + {0x48, 0x00}, {0x49, 0x1c}, {0x4a, 0x05}, {0x4b, 0x03}, + {0x4c, 0xa3}, {0x4d, 0x28}, {0x4e, 0x00}, {0x4f, 0xc0}, + {0x50, 0x00}, {0x51, 0x00}, {0x52, 0x00}, {0x53, 0x00}, + {0x54, 0x00}, {0x55, 0x00}, {0x56, 0x00}, {0x57, 0x00}, + {0x58, 0x00}, {0x59, 0x00}, {0x5a, 0x00}, {0x5b, 0x00}, + {0x5c, 0x00}, {0x5d, 0x00}, {0x5e, 0x00}, {0x5f, 0x00}, + {0x60, 0x00}, {0x61, 0x20}, {0x62, 0x00}, {0x63, 0x00}, + {0x64, 0x5a}, {0x65, 0x02}, {0x66, 0x00}, {0x67, 0x00}, + {0x68, 0x10}, {0x69, 0x09}, {0x6a, 0x00}, {0x6b, 0x03}, + {0x6c, 0x00}, {0x6d, 0xc0}, {0x6e, 0x40}, {0x6f, 0x00}, + {0x70, 0x00}, {0x71, 0x00}, {0x72, 0x00}, {0x73, 0x00}, + {0x74, 0x00}, {0x75, 0x00}, {0x76, 0x00}, {0x77, 0x00}, + {0x78, 0x00}, {0x79, 0x00}, {0x7a, 0x00}, {0x7b, 0x00}, + {0x7c, 0x00}, {0x7d, 0x00}, {0x7e, 0x00}, {0x7f, 0x00}, + {0x80, 0x00}, {0x81, 0x22}, {0x82, 0x65}, {0x83, 0x35}, + {0x84, 0x31}, {0x85, 0x60}, {0x86, 0x03}, {0x87, 0x00}, + {0x88, 0x00}, {0x89, 0x00}, {0x8a, 0x00}, {0x8b, 0x00}, + {0x8c, 0x00}, {0x8d, 0x00}, {0x8e, 0x00}, {0x8f, 0x00}, + {0x90, 0x00}, {0x91, 0x00}, {0x92, 0x00}, {0x93, 0x18}, + {0x94, 0xfb}, {0x95, 0x0b}, {0x96, 0x00}, {0x97, 0x0b}, + {0x98, 0xdb}, {0x99, 0xdf}, {0x9a, 0x48}, {0x9b, 0x00}, + {0x9c, 0x3f}, {0x9d, 0x3f}, {0x9e, 0x77}, {0x9f, 0x77}, + {0xa0, 0x00}, {0xa1, 0xff}, {0xa2, 0xff}, {0xa3, 0xff}, + {0xa4, 0x00}, {0xa5, 0x00}, {0xa6, 0x00}, {0xa7, 0x00}, + {0xa8, 0x00} + }; + + for (i = 0; i < ARRAY_SIZE(DEFAULT_REGS); ++i) { + reg = &DEFAULT_REGS[i]; + t1_setreg(wc, reg->address, reg->value); + } + /* Flush previous writes. */ + t1_getreg(wc, 0x1d); +} + static void t4_serial_setup(struct t1 *wc) { t1_setreg(wc, 0x85, 0xe0); /* GPC1: Multiplex mode enabled, FSC is output, active low, RCLK from channel 0 */ @@ -2039,10 +2108,13 @@ static int t1xxp_set_linemode(struct dahdi_span *span, enum spantypes linemode) /* Stop the processing of the channels since we're going to change * them. */ clear_bit(INITIALIZED, &wc->bit_flags); + synchronize_irq(wc->vb.pdev->irq); smp_mb__after_clear_bit(); del_timer_sync(&wc->timer); flush_workqueue(wc->wq); + t1_reset_registers(wc); + switch (linemode) { case SPANTYPE_DIGITAL_T1: dev_info(&wc->vb.pdev->dev,