From 79ad56bfa29cf2f90c167ea1b0ca86405a5e987b Mon Sep 17 00:00:00 2001 From: markster Date: Wed, 8 Sep 2004 03:48:56 +0000 Subject: Make loop current settable (bug #1200) git-svn-id: http://svn.digium.com/svn/zaptel/trunk@453 5390a7c7-147a-4af0-8ec9-7488f05a26cb --- wcfxs.c | 42 +++++++++++++++++++++++++++++++++++++++++- wctdm.c | 42 +++++++++++++++++++++++++++++++++++++++++- 2 files changed, 82 insertions(+), 2 deletions(-) diff --git a/wcfxs.c b/wcfxs.c index 48572e9..84fe9f6 100755 --- a/wcfxs.c +++ b/wcfxs.c @@ -40,6 +40,22 @@ */ /* #define AUDIO_RINGCHECK */ +/* + Experimental max loop current limit for the proslic + Loop current limit is from 20 mA to 41 mA in steps of 3 + (according to datasheet) + So set the value below to: + 0x00 : 20mA (default) + 0x01 : 23mA + 0x02 : 26mA + 0x03 : 29mA + 0x04 : 32mA + 0x05 : 35mA + 0x06 : 37mA + 0x07 : 41mA +*/ +static int loopcurrent = 20; + static alpha indirect_regs[] = { {0,"DTMF_ROW_0_PEAK",0x55C2}, @@ -941,6 +957,19 @@ static int wcfxs_powerup_proslic(struct wcfxs *wc, int card, int fast) card, vbat * 376 / 1000, vbat, (int)(((jiffies - origjiffies) * 1000 / HZ))); } + /* Proslic max allowed loop current, reg 71 LOOP_I_LIMIT */ + /* If out of range, just set it to the default value */ + int lim; + lim = (loopcurrent - 20) / 3; + if ( loopcurrent > 41 ) { + lim = 0; + if (debug) + printk("Loop current out of range! Setting to default 20mA!\n"); + } + else if (debug) + printk("Loop current set to %dmA!\n",(lim*3)+20); + wcfxs_setreg(wc,card,LOOP_I_LIMIT,lim); + /* Engage DC-DC converter */ wcfxs_setreg(wc, card, 93, 0x19 /* was 0x19 */); #if 0 @@ -1846,11 +1875,16 @@ static int wcfxs_hardware_init(struct wcfxs *wc) wait_just_a_bit(HZ/4); for (x=0;xcards;x++) { - int sane=0,ret=0; + int sane=0,ret=0,readi=0; #if 1 /* Init with Auto Calibration */ if (!(ret=wcfxs_init_proslic(wc, x, 0, 0, sane))) { wc->cardflag |= (1 << x); + if (debug) { + readi = wcfxs_getreg(wc,x,LOOP_I_LIMIT); + printk("Proslic module %d loop current is %dmA\n",x, + ((readi*3)+20)); + } printk("Module %d: Installed -- AUTO FXS/DPO\n",x); } else { if(ret!=-2) { @@ -1858,6 +1892,11 @@ static int wcfxs_hardware_init(struct wcfxs *wc) /* Init with Manual Calibration */ if (!wcfxs_init_proslic(wc, x, 0, 1, sane)) { wc->cardflag |= (1 << x); + if (debug) { + readi = wcfxs_getreg(wc,x,LOOP_I_LIMIT); + printk("Proslic module %d loop current is %dmA\n",x, + ((readi*3)+20)); + } printk("Module %d: Installed -- MANUAL FXS\n",x); } else { printk("Module %d: FAILED FXS (%s)\n", x, fxshonormode ? fxo_modes[_opermode].name : "FCC"); @@ -2126,6 +2165,7 @@ static void __exit wcfxs_cleanup(void) } MODULE_PARM(debug, "i"); +MODULE_PARM(loopcurrent, "i"); MODULE_PARM(robust, "i"); MODULE_PARM(_opermode, "i"); MODULE_PARM(opermode, "s"); diff --git a/wctdm.c b/wctdm.c index 48572e9..84fe9f6 100755 --- a/wctdm.c +++ b/wctdm.c @@ -40,6 +40,22 @@ */ /* #define AUDIO_RINGCHECK */ +/* + Experimental max loop current limit for the proslic + Loop current limit is from 20 mA to 41 mA in steps of 3 + (according to datasheet) + So set the value below to: + 0x00 : 20mA (default) + 0x01 : 23mA + 0x02 : 26mA + 0x03 : 29mA + 0x04 : 32mA + 0x05 : 35mA + 0x06 : 37mA + 0x07 : 41mA +*/ +static int loopcurrent = 20; + static alpha indirect_regs[] = { {0,"DTMF_ROW_0_PEAK",0x55C2}, @@ -941,6 +957,19 @@ static int wcfxs_powerup_proslic(struct wcfxs *wc, int card, int fast) card, vbat * 376 / 1000, vbat, (int)(((jiffies - origjiffies) * 1000 / HZ))); } + /* Proslic max allowed loop current, reg 71 LOOP_I_LIMIT */ + /* If out of range, just set it to the default value */ + int lim; + lim = (loopcurrent - 20) / 3; + if ( loopcurrent > 41 ) { + lim = 0; + if (debug) + printk("Loop current out of range! Setting to default 20mA!\n"); + } + else if (debug) + printk("Loop current set to %dmA!\n",(lim*3)+20); + wcfxs_setreg(wc,card,LOOP_I_LIMIT,lim); + /* Engage DC-DC converter */ wcfxs_setreg(wc, card, 93, 0x19 /* was 0x19 */); #if 0 @@ -1846,11 +1875,16 @@ static int wcfxs_hardware_init(struct wcfxs *wc) wait_just_a_bit(HZ/4); for (x=0;xcards;x++) { - int sane=0,ret=0; + int sane=0,ret=0,readi=0; #if 1 /* Init with Auto Calibration */ if (!(ret=wcfxs_init_proslic(wc, x, 0, 0, sane))) { wc->cardflag |= (1 << x); + if (debug) { + readi = wcfxs_getreg(wc,x,LOOP_I_LIMIT); + printk("Proslic module %d loop current is %dmA\n",x, + ((readi*3)+20)); + } printk("Module %d: Installed -- AUTO FXS/DPO\n",x); } else { if(ret!=-2) { @@ -1858,6 +1892,11 @@ static int wcfxs_hardware_init(struct wcfxs *wc) /* Init with Manual Calibration */ if (!wcfxs_init_proslic(wc, x, 0, 1, sane)) { wc->cardflag |= (1 << x); + if (debug) { + readi = wcfxs_getreg(wc,x,LOOP_I_LIMIT); + printk("Proslic module %d loop current is %dmA\n",x, + ((readi*3)+20)); + } printk("Module %d: Installed -- MANUAL FXS\n",x); } else { printk("Module %d: FAILED FXS (%s)\n", x, fxshonormode ? fxo_modes[_opermode].name : "FCC"); @@ -2126,6 +2165,7 @@ static void __exit wcfxs_cleanup(void) } MODULE_PARM(debug, "i"); +MODULE_PARM(loopcurrent, "i"); MODULE_PARM(robust, "i"); MODULE_PARM(_opermode, "i"); MODULE_PARM(opermode, "s"); -- cgit v1.2.3