diff options
-rwxr-xr-x | Makefile | 15 | ||||
-rwxr-xr-x | README.tigerjet | 29 | ||||
-rwxr-xr-x | tigerjet.c | 1074 | ||||
-rwxr-xr-x | wcfxsusb.h (renamed from tigerjet.h) | 8 | ||||
-rwxr-xr-x | wct1xxp.c | 173 |
5 files changed, 123 insertions, 1176 deletions
@@ -35,10 +35,10 @@ MODCONF=$(shell if [ -f /etc/modules.conf ]; then echo /etc/modules.conf; else e TZOBJS=zonedata.lo tonezone.lo LIBTONEZONE=libtonezone.so.1.0 -MODULES=zaptel.o tor2.o torisa.o tigerjet.o wcfxo.o +MODULES=zaptel.o tor2.o torisa.o wcfxsusb.o wcfxo.o MODULES+=$(shell if [ -f wct1xxp.c ]; then echo wct1xxp.o; fi) -PRIMARY=tigerjet +PRIMARY=wcfxsusb #PRIMARY=torisa #PRIMARY=wcfxo @@ -57,8 +57,8 @@ zaptel.o: zaptel.c zaptel.h digits.h torisa.o: torisa.c zaptel.h torisa.h gcc $(KFLAGS) -c torisa.c -tigerjet.o: tigerjet.c tigerjet.h zaptel.h - gcc $(KFLAGS) -c tigerjet.c +wcfxsusb.o: wcfxsusb.c wcfxsusb.h zaptel.h + gcc $(KFLAGS) -c wcfxsusb.c wcfxo.o: wcfxo.c zaptel.h gcc $(KFLAGS) -c wcfxo.c @@ -133,15 +133,15 @@ install: all devices mv -f $(MODCONF) $(MODCONF).bak cat $(MODCONF).bak | grep -v "alias char-major-250" | \ grep -v "post-install torisa /sbin/ztcfg" | \ - grep -v "post-install tigerjet /sbin/ztcfg" > $(MODCONF) + grep -v "post-install wcfxsusb /sbin/ztcfg" > $(MODCONF) if ! grep "options torisa" $(MODCONF); then \ echo "options torisa base=$(BASEADDR)" >> $(MODCONF); \ fi if ! grep "alias char-major-196" $(MODCONF); then \ echo "alias char-major-196 $(PRIMARY)" >> $(MODCONF); \ fi - if ! grep "post-install tigerjet" $(MODCONF); then \ - echo "post-install tigerjet /sbin/ztcfg" >> $(MODCONF); \ + if ! grep "post-install wcfxsusb" $(MODCONF); then \ + echo "post-install wcfxsusb /sbin/ztcfg" >> $(MODCONF); \ fi if ! grep "post-install torisa" $(MODCONF); then \ echo "post-install torisa /sbin/ztcfg" >> $(MODCONF); \ @@ -156,6 +156,7 @@ install: all devices [ -f /etc/zaptel.conf ] || install -m 644 zaptel.conf.sample /etc/zaptel.conf clean: + rm -f torisatool makefw tor2fw.h rm -f *.o ztcfg tzdriver sethdlc rm -f $(TZOBJS) $(LIBTONEZONE) *.lo rm -f gendigits tones.h diff --git a/README.tigerjet b/README.tigerjet deleted file mode 100755 index 77f16b5..0000000 --- a/README.tigerjet +++ /dev/null @@ -1,29 +0,0 @@ -TIGERJET VoIP Demonstration Board - -I'd like to thank the people at Tigerjet for donating a USB FXS interface -board for testing with Asterisk. We now support their reference design -board using their Tigerjet 560 Interface chip and the Silicon Labs Si3210 -ProSLIC. - -I'd also like to think Silicon Labs for donating a development board of -their Si3034 and Tigerjet 320 based winmodem design which we now -support as an FXO - -To Configure ------------- -Do a "make" and a "make install". You will need to enable a single channel -in /etc/zaptel.conf by adding the following line somewhere near the top: - -fxoks=1 - -To create a single channel with FXO Kewlstart signalling. You may -substitute "fxols" or "fxogs" for Loopstart and Groundstart signalling -respectively. - -Currently known bugs: ---------------------- -* Don't even think about unplugging the card while it's in use, or bad -things will happen. - -* If PROSLIC_POWERSAVE is defined, the ability to send audio while on -hook is limited to four seconds after ring is turned off. diff --git a/tigerjet.c b/tigerjet.c deleted file mode 100755 index 743be44..0000000 --- a/tigerjet.c +++ /dev/null @@ -1,1074 +0,0 @@ -/* - * Tiger Jet USB VoIP Board, Zapata Telephony Driver - * - * Written by Mark Spencer <markster@linux-support.net> - * Matthew Fredrickson <creslin@linux-support.net> - * - * Copyright (C) 2001, Linux Support Services, Inc. - * Copyright (C) 2001, TigerJet Network, Inc. - * - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - */ - -/* Save power at the expense of not always being able to transmit on hook. If - this is set, we only transit on hook for some time after a ring - (POWERSAVE_TIMEOUT) */ - -#define PROSLIC_POWERSAVE -#define POWERSAVE_TIME 4000 - -#include <linux/kernel.h> -#include <linux/errno.h> -#include <linux/module.h> -#include <linux/pci.h> -#include <linux/init.h> -#include <linux/usb.h> -#include <linux/errno.h> -#ifdef STANDALONE_ZAPATA -#include "zaptel.h" -#else -#include <linux/zaptel.h> -#endif -#include "tigerjet.h" -#include "proslic.h" - -#ifdef DEBUG_TIGERJET -#define DPRINTK(x) printk x -#else -#define DPRINTK(x) -#endif - -// Function prototypes -static int readProSlicDirectReg(struct usb_device *dev, unsigned char address, unsigned char* data); -static int initializeIndirectRegisters(struct usb_device *dev); -static int verifyIndirectRegisters(struct usb_device *dev); -static int writeProSlicDirectReg(struct usb_device *dev, unsigned char address, unsigned char data); -static int writeProSlicInDirectReg(struct usb_device *dev, unsigned char address, unsigned short data); -static int readProSlicInDirectReg(struct usb_device *dev, unsigned char address, unsigned short *data); -static int writeProSlicInDirectReg(struct usb_device *dev, unsigned char address, unsigned short data); - -static alpha indirect_regs[] = -{ -{0,"DTMF_ROW_0_PEAK",0x55C2}, -{1,"DTMF_ROW_1_PEAK",0x51E6}, -{2,"DTMF_ROW2_PEAK",0x4B85}, -{3,"DTMF_ROW3_PEAK",0x4937}, -{4,"DTMF_COL1_PEAK",0x3333}, -{5,"DTMF_FWD_TWIST",0x0202}, -{6,"DTMF_RVS_TWIST",0x0202}, -{7,"DTMF_ROW_RATIO_TRES",0x0198}, -{8,"DTMF_COL_RATIO_TRES",0x0198}, -{9,"DTMF_ROW_2ND_ARM",0x0611}, -{10,"DTMF_COL_2ND_ARM",0x0202}, -{11,"DTMF_PWR_MIN_TRES",0x00E5}, -{12,"DTMF_OT_LIM_TRES",0x0A1C}, -{13,"OSC1_COEF",0x6D40}, -{14,"OSC1X",0x0470}, -{15,"OSC1Y",0x0000}, -{16,"OSC2_COEF",0x4A80}, -{17,"OSC2X",0x0830}, -{18,"OSC2Y",0x0000}, -{19,"RING_V_OFF",0x0000}, -{20,"RING_OSC",0x7EF0}, -{21,"RING_X",0x0160}, -{22,"RING_Y",0x0000}, -{23,"PULSE_ENVEL",0x2000}, -{24,"PULSE_X",0x2000}, -{25,"PULSE_Y",0x0000}, -//{26,"RECV_DIGITAL_GAIN",0x4000}, // playback volume set lower -{26,"RECV_DIGITAL_GAIN",0x2000}, // playback volume set lower -{27,"XMIT_DIGITAL_GAIN",0x4000}, -{28,"LOOP_CLOSE_TRES",0x1000}, -{29,"RING_TRIP_TRES",0x3600}, -{30,"COMMON_MIN_TRES",0x1000}, -{31,"COMMON_MAX_TRES",0x0200}, -{32,"PWR_ALARM_Q1Q2",0x0550}, -{33,"PWR_ALARM_Q3Q4",0x2600}, -{34,"PWR_ALARM_Q5Q6",0x1B80}, -{35,"LOOP_CLOSURE_FILTER",0x8000}, -{36,"RING_TRIP_FILTER",0x0320}, -{37,"TERM_LP_POLE_Q1Q2",0x0100}, -{38,"TERM_LP_POLE_Q3Q4",0x0100}, -{39,"TERM_LP_POLE_Q5Q6",0x0010}, -{40,"CM_BIAS_RINGING",0x0C00}, -{41,"DCDC_MIN_V",0x0C00}, -{42,"DCDC_XTRA",0x1000}, -}; - -#define TJ320_SPORT0 0x26 -#define TJ320_SPORT1 0x27 -#define TJ320_SPORT2 0x28 -#define TJ320_SPORT_CTRL 0x29 - -#define CONTROL_TIMEOUT_MS (500) /* msec */ -#define CONTROL_TIMEOUT_JIFFIES ((CONTROL_TIMEOUT_MS * HZ) / 1000) - -#define REQUEST_NORMAL 4 - -#define FLAG_RUNNING (1 << 0) - -static int debug = 0; - -struct stinky_urb { - urb_t urb; - iso_packet_descriptor_t isoframe[1]; -}; - -typedef enum { - STATE_TJREAD_WRITEREG, - STATE_TJREAD_READRES, - STATE_TJWRITE_WRITEREG, - STATE_TJWRITE_WRITERES, -} control_state_t; - -struct tj_usb_pvt { - struct usb_device *dev; - unsigned int readpipe; - unsigned int writepipe; - int usecount; - int dead; - int hardwareflags; - struct zt_span span; - struct zt_chan chan; - struct stinky_urb dataread[2]; - struct stinky_urb datawrite[2]; - urb_t control; - devrequest dr; - control_state_t controlstate; - int urbcount; - int flags; - int timer; - int lowpowertimer; - int idletxhookstate; - int hookstate; - __u8 newtxhook; - __u8 txhook; - int pos; - unsigned char auxstatus; - unsigned char tjregindex; - unsigned char tjregbuf[4]; - unsigned char tjregval; - short writechunk[ZT_MAX_CHUNKSIZE * 2]; - short readchunk[ZT_MAX_CHUNKSIZE * 2]; -}; - -struct tj_usb_desc { - char *name; - int flags; -}; - -#define FLAG_FLIP_RELAYS (1 << 0) - -static struct tj_usb_desc tjusb = { "Tigerjet USB Demo Board" }; -static struct tj_usb_desc eznetcomm = { "EzNetComm VoIP Board", FLAG_FLIP_RELAYS }; - -static struct tj_usb_pvt *ifaces[TJET_MAX_IFACES]; - -static int Tjusb_WriteTjRegs(struct usb_device *dev, unsigned char index, - unsigned char *data, int len) -{ - unsigned int pipe = usb_sndctrlpipe(dev, 0); - int requesttype; - int res; - - requesttype = USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE; - - res = usb_control_msg(dev, pipe, REQUEST_NORMAL, requesttype, - 0, index, data, len, CONTROL_TIMEOUT_JIFFIES); - if (res == -ETIMEDOUT) { - printk("tjusb: timeout on vendor write\n"); - return -1; - } else if (res < 0) { - printk("tjusb: Error executing control: status=%d\n", le32_to_cpu(res)); - return -1; - } - return 0; -} - -static int Tjusb_ReadTjRegs(struct usb_device *dev, unsigned char index, - unsigned char *data, int len) -{ - unsigned int pipe = usb_rcvctrlpipe(dev, 0); - int requesttype; - int res; - - requesttype = USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE; - - res = usb_control_msg(dev, pipe, REQUEST_NORMAL, requesttype, - 0, index, data, len, CONTROL_TIMEOUT_JIFFIES); - if (res == -ETIMEDOUT) { - printk("tjusb: timeout on vendor write\n"); - return -1; - } else if (res < 0) { - printk("tjusb: Error executing control: status=%d\n", le32_to_cpu(res)); - return -1; - } else { - DPRINTK(("tjusb: Executed read, result = %d (data = %04x)\n", le32_to_cpu(res), (int) *data)); - } - return 0; -} - -static int tjusb_async_read(struct tj_usb_pvt *p, unsigned char index, unsigned char *data, int len, int state); -static int tjusb_async_write(struct tj_usb_pvt *p, unsigned char index, unsigned char *data, int len, int state); - -static void proslic_read_direct_async(struct tj_usb_pvt *p, unsigned char address) -{ - p->tjregindex = address; - p->tjregbuf[0] = address | 0x80; - p->tjregbuf[1] = 0; - p->tjregbuf[2] = 0; - p->tjregbuf[3] = 0x67; - tjusb_async_write(p, TJ320_SPORT0, p->tjregbuf, 4, STATE_TJREAD_WRITEREG); -} - -static void proslic_write_direct_async(struct tj_usb_pvt *p, unsigned char address, unsigned char val) -{ - p->tjregindex = address; - p->tjregbuf[0] = address & 0x7f; - p->tjregbuf[1] = val; - p->tjregbuf[2] = 0; - p->tjregbuf[3] = 0x27; - tjusb_async_write(p, TJ320_SPORT0, p->tjregbuf, 4, STATE_TJWRITE_WRITERES); -} - -static void tjusb_async_control(urb_t *urb) -{ - struct tj_usb_pvt *p = urb->context; - p->urbcount--; - if (urb->status) { - printk("Error in transfer...\n"); - return; - } - if (!(p->flags & FLAG_RUNNING)) { - return; - } - switch (p->controlstate) { - case STATE_TJREAD_WRITEREG: - /* We've written the register to sport0, now read form sport 1 */ - tjusb_async_read(p, TJ320_SPORT1, &p->tjregval, 1, STATE_TJREAD_READRES); - return; - case STATE_TJREAD_READRES: - switch(p->tjregindex) { - case 68: - if (!p->hookstate && (p->tjregval & 1)) { - p->hookstate = 1; - if (debug) - printk("Going off hook...\n"); - zt_hooksig(&p->chan, ZT_RXSIG_OFFHOOK); - } else if (p->hookstate && !(p->tjregval & 1)) { - p->hookstate = 0; - if (debug) - printk("Going on hook...\n"); - zt_hooksig(&p->chan, ZT_RXSIG_ONHOOK); - } - /* Set outgoing hook state if necessary */ - if (p->txhook != p->newtxhook) { - if (debug) - printk("Really setting hook state to %d\n", p->newtxhook); - p->txhook = p->newtxhook; - proslic_write_direct_async(p, 64, p->newtxhook); - } else - p->timer = 50; - break; - case 64: - if (debug) - printk("Read hook state as %02x\n", p->tjregval); - p->timer = 50; - break; - default: - printk("dunno what to do with read/regindex %d\n", p->tjregindex); - p->tjregindex = 0; - } - return; - case STATE_TJWRITE_WRITERES: - switch(p->tjregindex) { - case 64: - if (debug) { - printk("Hook transition complete to %d\n", ((char *)(urb->transfer_buffer))[1]); -#ifdef BOOST_RINGER - } - if (p->txhook == 4) { - /* Ringing -- boost battery to 96V */ - proslic_write_direct_async(p, 74, 0x3f); - } else { - /* Leave battery at default 75V */ - proslic_write_direct_async(p, 74, 0x32); - } - break; - case 74: - if (debug) { - printk("Battery set to -%dV\n", ((char *)(urb->transfer_buffer))[1] * 3 / 2); -#endif - proslic_read_direct_async(p, 64); - } else - p->timer = 50; - break; - default: - printk("dunno what to do with write/regindex %d\n", p->tjregindex); - p->tjregindex = 0; - } - return; - default: - printk("async control in unknown state %d\n", p->controlstate); - } -} - -static void tjusb_check_interrupt(struct tj_usb_pvt *p) -{ - /* Start checking for interrupts */ - proslic_read_direct_async(p, 68); -} - -static int tjusb_async_read(struct tj_usb_pvt *p, unsigned char index, unsigned char *data, int len, int state) -{ - urb_t *urb = &p->control; - __u16 size = len; - __u16 ind = index; - - memset(urb, 0, sizeof(p->control)); - - p->dr.requesttype = USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE; - p->dr.request = REQUEST_NORMAL; - p->dr.value = 0; - p->dr.index = cpu_to_le16(ind); - p->dr.length = cpu_to_le16(size); - - FILL_CONTROL_URB(urb, p->dev, usb_rcvctrlpipe(p->dev, 0), (unsigned char *)&p->dr, data, len, tjusb_async_control, p); - if (usb_submit_urb(urb)) { - printk("tjusb_async_read: control URB died\n"); - return -1; - } - p->controlstate = state; - p->urbcount++; - return 0; -} - -static int tjusb_async_write(struct tj_usb_pvt *p, unsigned char index, unsigned char *data, int len, int state) -{ - urb_t *urb = &p->control; - __u16 size = len; - __u16 ind = index; - - memset(urb, 0, sizeof(p->control)); - - p->dr.requesttype = USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE; - p->dr.request = REQUEST_NORMAL; - p->dr.value = 0; - p->dr.index = cpu_to_le16(ind); - p->dr.length = cpu_to_le16(size); - - FILL_CONTROL_URB(urb, p->dev, usb_sndctrlpipe(p->dev, 0), (unsigned char *)&p->dr, data, len, tjusb_async_control, p); - if (usb_submit_urb(urb)) { - printk("tjusb_async_write: control URB died\n"); - return -1; - } - p->controlstate = state; - p->urbcount++; - return 0; -} - -/* -** Write register to Tj560 -*/ -static int tjoutp(struct usb_device *dev, unsigned char address, unsigned char data) -{ - if (!Tjusb_WriteTjRegs(dev, address, &data, 1)) - return 0; - - return -1; -} - -/* -** read register from Tj560 -*/ -static int tjinp(struct usb_device *dev, unsigned char address, unsigned char* data ) -{ - if (!Tjusb_ReadTjRegs(dev, address, data, 1)) - return 0; - - return -1; -} - -static int waitForProSlicIndirectRegAccess(struct usb_device *dev) -{ - unsigned char count, data; - count = 0; - while (count++ < 3) - { - data = 0; - readProSlicDirectReg(dev, I_STATUS, &data); - - if (!data) - return 0; - - } - - if(count > 2) printk(" ##### Loop error #####\n"); - - return -1; -} - -static int writeProSlicInDirectReg(struct usb_device *dev, unsigned char address, unsigned short data) -{ - - if(!waitForProSlicIndirectRegAccess(dev)) - { - if (!writeProSlicDirectReg(dev, IDA_LO,(unsigned char)(data & 0xFF))) - { - if(!writeProSlicDirectReg(dev, IDA_HI,(unsigned char)((data & 0xFF00)>>8))) - { - if(!writeProSlicDirectReg(dev, IAA,address)) - return 0; - } - } - } - - return -1; -} - -/* -** Read register from ProSlic -*/ -int readProSlicDirectReg(struct usb_device *dev, unsigned char address, unsigned char* dataRead) -{ - unsigned char data[4]; - - data[0] = address | 0x80; - data[1] = 0; - data[2] = 0; - data[3] = 0x67; - - // write to TJ560 register 0x26 - Tjusb_WriteTjRegs(dev, TJ320_SPORT0, data, 4); - Tjusb_ReadTjRegs(dev, TJ320_SPORT1, data, 1); - *dataRead = data[0]; - - return 0; -} - -/* -** Write register to ProSlic -*/ -int writeProSlicDirectReg(struct usb_device *dev, unsigned char address, unsigned char RegValue) -{ - unsigned char data[4]; - - data[0] = address & 0x7f; - data[1] = RegValue; - data[2] = 0; - data[3] = 0x27; - - // write to TJ560 register 0x26 - return Tjusb_WriteTjRegs(dev, TJ320_SPORT0, data, 4); -} - -static int readProSlicInDirectReg(struct usb_device *dev, unsigned char address, unsigned short *data) -{ - if (!waitForProSlicIndirectRegAccess(dev)) - { - if (!writeProSlicDirectReg(dev,IAA,address)) - { - if(!waitForProSlicIndirectRegAccess(dev)) - { - unsigned char data1, data2; - - if (!readProSlicDirectReg(dev,IDA_LO, &data1) && !readProSlicDirectReg (dev, IDA_HI, &data2)) - { - *data = data1 | (data2 << 8); - return 0; - } else - printk("Failed to read direct reg\n"); - } else - printk("Failed to wait inside\n"); - } else - printk("failed write direct IAA\n"); - } else - printk("failed to wait\n"); - - return -1; -} - -static int initializeIndirectRegisters(struct usb_device *dev) -{ - unsigned char i; - - for (i=0; i<43; i++) - { - if(writeProSlicInDirectReg(dev, i,indirect_regs[i].initial)) - return -1; - } - - return 0; -} - -static int verifyIndirectRegisters(struct usb_device *dev) -{ - int passed = 1; - unsigned short i,j, initial; - - for (i=0; i<43; i++) - { - if(readProSlicInDirectReg(dev, (unsigned char) i, &j)) { - printk("Failed to read indirect register %d\n", i); - return -1; - } - initial= indirect_regs[i].initial; - - if ( j != initial ) - { - printk("!!!!!!! %s iREG %X = %X should be %X\n", - indirect_regs[i].name,i,j,initial ); - passed = 0; - } - } - - if (passed) { - if (debug) - printk("Init Indirect Registers completed successfully.\n"); - } else { - printk(" !!!!! Init Indirect Registers UNSUCCESSFULLY.\n"); - } - - return 0; -} - -static int calibrateAndActivateProSlic(struct usb_device *dev) -{ - unsigned char x; - - if(writeProSlicDirectReg(dev, 92, 0xc8)) - return -1; - - if(writeProSlicDirectReg(dev, 97, 0)) - return -1; - - if(writeProSlicDirectReg(dev, 93, 0x19)) - return -1; - - if(writeProSlicDirectReg(dev, 14, 0)) - return -1; - - if(writeProSlicDirectReg(dev, 93, 0x99)) - return -1; - - if(!readProSlicDirectReg (dev, 93, &x)) - { - if (debug) - printk("DC Cal x=%x\n",x); - - if (!writeProSlicDirectReg(dev, 97, 0)) - { - if(!writeProSlicDirectReg(dev, CALIBR1, CALIBRATE_LINE)) - { - unsigned char data; - - if(!readProSlicDirectReg(dev, CALIBR1, &data)) - return writeProSlicDirectReg(dev, LINE_STATE,ACTIVATE_LINE); - } - } - } - - return -1; -} - -static int InitProSlic(struct usb_device *dev) -{ - if (writeProSlicDirectReg(dev, 67, 0x0e)) - /* Disable Auto Power Alarm Detect and other "features" */ - return -1; - if (initializeIndirectRegisters(dev)) { - printk(KERN_INFO "Indirect Registers failed to initialize.\n"); - return -1; - } - if (verifyIndirectRegisters(dev)) { - printk(KERN_INFO "Indirect Registers failed verification.\n"); - return -1; - } - if (calibrateAndActivateProSlic(dev)) { - printk(KERN_INFO "ProSlic Died on Activation.\n"); - return -1; - } - if (writeProSlicInDirectReg(dev, 97, 0x0)) { // Stanley: for the bad recording fix - printk(KERN_INFO "ProSlic IndirectReg Died.\n"); - return -1; - } - if (writeProSlicDirectReg(dev, 1, 0x2a)) { // U-Law GCI 8-bit interface - printk(KERN_INFO "ProSlic DirectReg Died.\n"); - return -1; - } - if (writeProSlicDirectReg(dev, 2, 0)) // Tx Start count low byte 0 - return -1; - if (writeProSlicDirectReg(dev, 3, 0)) // Tx Start count high byte 0 - return -1; - if (writeProSlicDirectReg(dev, 4, 0)) // Rx Start count low byte 0 - return -1; - if (writeProSlicDirectReg(dev, 5, 0)) // Rx Start count high byte 0 - return -1; - if (writeProSlicDirectReg(dev, 8, 0x0)) // disable loopback - return -1; - if (writeProSlicDirectReg(dev, 18, 0xff)) // clear all interrupt - return -1; - if (writeProSlicDirectReg(dev, 19, 0xff)) - return -1; - if (writeProSlicDirectReg(dev, 20, 0xff)) - return -1; - if (writeProSlicDirectReg(dev, 21, 0x00)) // enable interrupt - return -1; - if (writeProSlicDirectReg(dev, 22, 0x02)) // Loop detection interrupt - return -1; - if (writeProSlicDirectReg(dev, 23, 0x01)) // DTMF detection interrupt - return -1; - if (writeProSlicDirectReg(dev, 72, 0x20)) - return -1; -#ifdef BOOST_RINGER - /* Beef up Ringing voltage to 89V */ - if (writeProSlicInDirectReg(dev, 23, 0x1d1)) - return -1; -#endif - return 0; -} - -static int InitHardware(struct usb_device *dev) -{ - - DPRINTK((">>> Enter InitHardware\n")); - - // First initial Tiger560 - if (tjoutp(dev, 0x12, 0x00)) // AUX6 as output, set to low - return -1; - - if (tjoutp(dev, 0x13, 0x40)) // AUX6 is output - return -1; - - if (tjoutp(dev, 0, 0x50)) // extrst, AUX2 is suspend - return -1; - - if (tjoutp(dev, 0x29, 0x20)) // enable SerialUP AUX pin definition - return -1; - - if(tjoutp(dev, 0, 0x51)) // no extrst, AUX2 is suspend - return -1; - /* Make sure there is no gain */ - if (tjoutp(dev, 0x22, 0x00)) - return -1; - if (tjoutp(dev, 0x23, 0xf2)) - return -1; - if (tjoutp(dev, 0x24, 0x00)) - return -1; - if (tjoutp(dev, 0x25, 0xc9)) - return -1; - // Now initial Proslic - if(InitProSlic(dev)) { - printk("Failed to initialize proslic\n"); - return -1; - } - - if (debug) - printk("Setting up correct altsettings\n"); - - /* Setup correct settings (8000 Hz, signed linear) */ - if (usb_set_interface(dev, 2, 1)) - printk("Unable to setup USB interface 2 to altsetting 1\n"); - if (usb_set_interface(dev, 3, 1)) - printk("Unable to setup USB interface 3 to altsetting 1\n"); - - DPRINTK("<<< Exit InitHardware\n"); - return 0; -} - -static struct usb_device_id tj_dev_ids[] = { - /* This needs to be a USB audio device, and it needs to be made by tigerjet and have the right device ID */ - { match_flags: (USB_DEVICE_ID_MATCH_INT_CLASS | USB_DEVICE_ID_MATCH_INT_SUBCLASS | USB_DEVICE_ID_MATCH_DEVICE), - bInterfaceClass: USB_CLASS_AUDIO, - bInterfaceSubClass: 1, - idVendor: 0x06e6, /* Tigerjet */ - idProduct: 0x831c, /* Product ID / Chip configuration (you can't change this) */ - driver_info: (unsigned long)&tjusb, - }, - { match_flags: (USB_DEVICE_ID_MATCH_INT_CLASS | USB_DEVICE_ID_MATCH_INT_SUBCLASS | USB_DEVICE_ID_MATCH_DEVICE), - bInterfaceClass: USB_CLASS_AUDIO, - bInterfaceSubClass: 1, - idVendor: 0x06e6, /* Tigerjet */ - idProduct: 0x831e, /* Product ID / Chip configuration (you can't change this) */ - driver_info: (unsigned long)&eznetcomm, - }, - { } /* Terminating Entry */ -}; - - - -static void tjnet_read_complete(struct urb *q) -{ - struct tj_usb_pvt *p = q->context; - short *chunk = q->transfer_buffer; - int x; - - if (!p->flags & FLAG_RUNNING) { - /* Stop sending URBs since we're not running anymore */ - p->urbcount--; - return; - } - - for (x = 0; x < ZT_CHUNKSIZE; x++) { - p->chan.readchunk[x] = zt_lin2mu[chunk[x] + 32768]; - } - - zt_receive(&p->span); - - q->dev = p->dev; - - if (usb_submit_urb(q)) { - printk("tjnet: Read cycle failed\n"); - } - - if (p->timer && !--p->timer) - tjusb_check_interrupt(p); - -#ifdef PROSLIC_POWERSAVE - if (p->lowpowertimer && !--p->lowpowertimer) { - /* Switch back into low power mode */ - p->idletxhookstate = 1; - if (p->txhook == 2) - p->newtxhook = p->idletxhookstate; - } -#endif - return; -} - -static void tjnet_write_complete(struct urb *q) -{ - struct tj_usb_pvt *p = q->context; - short *chunk = q->transfer_buffer; - int x; - - if (!p->flags & FLAG_RUNNING) { - /* Stop sending URBs since we're not running anymore */ - p->urbcount--; - return; - } - - zt_transmit(&p->span); - for (x = 0; x < ZT_CHUNKSIZE; x++) { - chunk[x] = zt_mulaw[p->chan.writechunk[x]]; - } - q->dev = p->dev; - - if (usb_submit_urb(q)) { - printk("tjnet: Write cycle failed\n"); - } - - return; -} - -static int StopTransmit(struct tj_usb_pvt *p) -{ - p->flags &= ~FLAG_RUNNING; - while(p->urbcount) { - schedule_timeout(1); - } - return 0; -} - -static int flip_relays(struct tj_usb_pvt *p, int onoff) -{ - unsigned char ctl; - unsigned char data; - /* Read data */ - if (tjinp(p->dev, 0x12, &data)) - return -1; - /* Read control */ - if (tjinp(p->dev, 0x13, &ctl)) - return -1; - /* Setup values properly -- Pins AUX3 & AUX4 control the relays */ - ctl |= 0x18; - if (onoff) { - data |= 0x18; - } else { - data &= 0xe7; - } - if (tjoutp(p->dev, 0x12, data)) - return -1; - if (tjoutp(p->dev, 0x13, ctl)) - return -1; - return 0; -} - -static int InitPrivate(struct tj_usb_pvt *p) -{ - int x; - /* Endpoint 6 is the wave-in device */ - p->readpipe = usb_rcvisocpipe(p->dev, 0x06); - - /* Endpoint 7 is the wave-out device */ - p->writepipe = usb_sndisocpipe(p->dev, 0x07); - - - for (x=0;x<2;x++) { - p->dataread[x].urb.dev = p->dev; - p->dataread[x].urb.pipe = p->readpipe; - p->dataread[x].urb.transfer_flags = USB_ISO_ASAP; - p->dataread[x].urb.number_of_packets = 1; - p->dataread[x].urb.context = p; - p->dataread[x].urb.complete = tjnet_read_complete; - p->dataread[x].urb.iso_frame_desc[0].length = ZT_CHUNKSIZE * 2; - p->dataread[x].urb.iso_frame_desc[0].offset = 0; - p->dataread[x].urb.transfer_buffer = p->readchunk + ZT_CHUNKSIZE * x; - p->dataread[x].urb.transfer_buffer_length = ZT_CHUNKSIZE * 2; - - p->datawrite[x].urb.dev = p->dev; - p->datawrite[x].urb.pipe = p->writepipe; - p->datawrite[x].urb.transfer_flags = USB_ISO_ASAP; - p->datawrite[x].urb.number_of_packets = 1; - p->datawrite[x].urb.context = p; - p->datawrite[x].urb.complete = tjnet_write_complete; - p->datawrite[x].urb.iso_frame_desc[0].length = ZT_CHUNKSIZE * 2; - p->datawrite[x].urb.iso_frame_desc[0].offset = 0; - p->datawrite[x].urb.transfer_buffer = p->writechunk + ZT_CHUNKSIZE * x; - p->datawrite[x].urb.transfer_buffer_length = ZT_CHUNKSIZE * 2; - - } - - - return 0; -} - -static int InitTransfer(struct tj_usb_pvt *p) -{ - - int x; - p->urbcount = 4; - p->flags |= FLAG_RUNNING; - - for (x=0;x<2;x++) { - if (usb_submit_urb(&p->dataread[x].urb)) { - printk(KERN_ERR "tjusb: Read submit failed\n"); - return -1; - } - if (usb_submit_urb(&p->datawrite[x].urb)) { - printk(KERN_ERR "tjusb: Write submit failed\n"); - return -1; - } - } - /* Start checking for interrupts */ - tjusb_check_interrupt(p); - return 0; -} - -static int tj_usb_hooksig(struct zt_chan *chan, zt_txsig_t txsig) -{ - struct tj_usb_pvt *p = chan->pvt; -#ifdef PROSLIC_POWERSAVE - if (p->txhook == 4) { - /* Switching out of ring... Be sure we idle at 2, not 1 at least - for a bit so we can transmit caller*ID */ - p->idletxhookstate = 2; - p->lowpowertimer = POWERSAVE_TIME; - } -#endif - - p->txhook = -1; - switch(txsig) { - case ZT_TXSIG_ONHOOK: - switch(chan->sig) { - case ZT_SIG_FXOKS: - case ZT_SIG_FXOLS: - p->newtxhook = p->idletxhookstate; - break; - case ZT_SIG_FXOGS: - p->newtxhook = 3; - break; - } - break; - case ZT_TXSIG_OFFHOOK: - p->newtxhook = p->idletxhookstate; - break; - case ZT_TXSIG_START: - p->newtxhook = 4; - break; - case ZT_TXSIG_KEWL: - p->newtxhook = 0; - break; - } - return 0; -} - -static int tj_usb_open(struct zt_chan *chan) -{ - struct tj_usb_pvt *p = chan->pvt; - if (p->dead) - return -1; - MOD_INC_USE_COUNT; - p->usecount++; - return 0; -} - -static int tj_usb_close(struct zt_chan *chan) -{ - struct tj_usb_pvt *p = chan->pvt; - p->usecount--; - if (!p->usecount && p->dead) { - /* Someone unplugged us while we were running, so now - that the program exited, we can release our resources */ - zt_unregister(&p->span); - ifaces[p->pos] = NULL; - kfree(p); - } - MOD_DEC_USE_COUNT; - return 0; -} - -static void *tj_usb_probe(struct usb_device *dev, unsigned int ifnum, const struct usb_device_id *id) -{ - struct usb_config_descriptor *config = dev->actconfig; - struct tj_usb_pvt *p=NULL; - struct tj_usb_desc *d = (struct tj_usb_desc *)id->driver_info; - - int x; - for (x=0;x<TJET_MAX_IFACES;x++) - if (!ifaces[x]) break; - if (x >= TJET_MAX_IFACES) { - printk("Too many interfaces\n"); - goto fail; - } - - p = kmalloc(sizeof(struct tj_usb_pvt), GFP_KERNEL); - - if (!p) - goto fail; - - memset(p, 0, sizeof(struct tj_usb_pvt)); - p->hardwareflags = d->flags; - sprintf(p->span.name, "TjUSB/%d", x); - sprintf(p->span.desc,"%s %d", d->name, x); - sprintf(p->chan.name, "TjUSB/%d/%d", x, 0); -#if 0 /* Make them choose with zaptel.conf */ - p->chan.sig = ZT_SIG_FXOKS; /* Assume FXOKS signalling for starters */ -#endif - p->chan.sigcap = ZT_SIG_FXOKS | ZT_SIG_FXOLS | ZT_SIG_FXOGS; /* We're capabable of both FXOKS and FXOLS */ - p->chan.chanpos = 1; - p->span.chans = &p->chan; - p->span.channels = 1; - p->span.hooksig = tj_usb_hooksig; - p->span.open = tj_usb_open; - p->span.close = tj_usb_close; - p->dev = dev; - p->pos = x; - p->span.flags = ZT_FLAG_RBS; - init_waitqueue_head(&p->span.maintq); - p->span.pvt = p; - p->chan.pvt = p; -#ifdef PROSLIC_POWERSAVE - /* By default we can't send on hook */ - p->idletxhookstate = 1; -#else - /* By default we can always send on hook */ - p->idletxhookstate = 2; -#endif - ifaces[x] = p; - - - - if (usb_set_configuration(dev, dev->config[0].bConfigurationValue) < 0) { - printk(KERN_ERR "tjusb: set_configuration failed (ConfigValue 0x%x)\n", config->bConfigurationValue); - goto fail; - } - if (InitHardware(dev)) { - printk(KERN_ERR "tjusb: Hardware initialization failed\n"); - goto fail; - } - - if (InitPrivate(p)) { - printk(KERN_ERR "tjusb: Unable to initialize private data structure\n"); - goto fail; - } - if (p->hardwareflags & FLAG_FLIP_RELAYS) { - flip_relays(p, 1); - } -#if 1 - if (zt_register(&p->span, 0)) { - printk("Unable to register span %s\n", p->span.name); - goto fail; - } -#endif - - if (InitTransfer(p)) { - printk(KERN_ERR "tjusb: Unable to begin data flow\n"); - goto fail; - } - printk("tjusb: Found a %s\n", d->name); - - return p; -fail: - if (x < TJET_MAX_IFACES) - ifaces[x] = NULL; - if (p) - kfree(p); - return NULL; -} - -static void tj_usb_disconnect(struct usb_device *dev, void *ptr) -{ - /* Doesn't handle removal if we're in use right */ - struct tj_usb_pvt *p = ptr; - if (ptr) { - StopTransmit(p); - if (!p->usecount) { - zt_unregister(&p->span); - ifaces[p->pos] = NULL; - kfree(ptr); - } else - p->dead = 1; - } - printk("tjusb: Removed a TigerJet USB device\n"); - return; -} - -static struct usb_driver tj_usb_driver = -{ - name: "tjusb", - probe: tj_usb_probe, - disconnect: tj_usb_disconnect, - fops: NULL, - minor: 0, - id_table: tj_dev_ids, -}; - -static int __init tj_init (void) -{ - int res; - res = usb_register(&tj_usb_driver); - if (res) - return res; - printk("Tiger Jet USB VoIP Board Driver Registered\n"); - return 0; -} - -static void __exit tj_cleanup(void) -{ - usb_deregister(&tj_usb_driver); -} - -MODULE_AUTHOR("Mark Spencer <markster@linux-support.net>"); -MODULE_DESCRIPTION("Tigerjet VoIP USB interface"); -MODULE_PARM(debug, "i"); - -MODULE_DEVICE_TABLE(usb, tj_dev_ids); - -module_init(tj_init); -module_exit(tj_cleanup); - @@ -1,5 +1,5 @@ /* - * Tiger Jet USB VoIP Board, Zapata Telephony Driver + * Wildcard FXS USB Interface Zapata Telephony Driver * * Written by Mark Spencer <markster@linux-support.net> * @@ -23,10 +23,10 @@ * */ -#ifndef _TIGERJET_H -#define _TIGERJET_H +#ifndef _WCFXSUSB_H +#define _WCFXSUSB_H -#define TJET_MAX_IFACES 128 +#define WC_MAX_IFACES 128 /* Tigerjet VoIP board hardware definitions */ @@ -57,6 +57,7 @@ #define WC_CURPOS 0x24 #define WC_SERC 0x2d +#define WC_FSCDELAY 0x2f #define WC_USERREG 0xc0 @@ -64,6 +65,9 @@ #define WC_LEDTEST 0x1 #define WC_VERSION 0x2 +/* Offset between transmit and receive */ +#define WC_OFFSET 4 + #define BIT_CS (1 << 5) #define BIT_OK (1 << 0) @@ -71,6 +75,16 @@ #define BIT_ERROR (1 << 2) #define BIT_ALARM (1 << 3) +static int chanmap[] = +{ 1,2,3, + 5,6,7, + 9,10,11, + 13,14,15, + 17,18,19, + 21,22,23, + 25,26,27, + 29,30,31 }; + struct t1xxp { struct pci_dev *dev; char *variety; @@ -84,8 +98,8 @@ struct t1xxp { unsigned long ioaddr; dma_addr_t readdma; dma_addr_t writedma; - volatile int *writechunk; /* Double-word aligned write memory */ - volatile int *readchunk; /* Double-word aligned read memory */ + volatile unsigned char *writechunk; /* Double-word aligned write memory */ + volatile unsigned char *readchunk; /* Double-word aligned read memory */ struct zt_span span; /* Span */ struct zt_chan chans[24]; /* Channels */ }; @@ -183,28 +197,74 @@ static int t1xxp_close(struct zt_chan *chan) static inline void handle_leds(struct t1xxp *wc) { if (wc->alarm) { +#ifdef FANCY_ALARM + if (wc->alarmtimer == wc->alarmthreshold << 1) { + wc->ledtestreg = wc->ledtestreg & ~BIT_ALARM; + control_set_reg(wc, WC_LEDTEST, wc->ledtestreg); + } + if (wc->alarmtimer == 0x1f) { + wc->ledtestreg = wc->ledtestreg | BIT_ALARM; + control_set_reg(wc, WC_LEDTEST, wc->ledtestreg); + wc->alarmtimer = -1; + wc->alarmthreshold = (wc->alarmthreshold + 1 & 0x1f); + } wc->alarmtimer++; - if (wc->alarmtimer == 40) { +#else + wc->alarmtimer++; + if (wc->alarmtimer == 160) { wc->ledtestreg = wc->ledtestreg | BIT_ALARM; control_set_reg(wc, WC_LEDTEST, wc->ledtestreg); - } else if (wc->alarmtimer == 160) { + } else if (wc->alarmtimer == 480) { wc->ledtestreg = wc->ledtestreg & ~BIT_ALARM; control_set_reg(wc, WC_LEDTEST, wc->ledtestreg); wc->alarmtimer = 0; } +#endif } -#if 0 - if (wc->alarmtimer == wc->alarmthreshold >> 2) { - wc->ledtestreg = wc->ledtestreg ^ BIT_ALARM; - control_set_reg(wc, WC_LEDTEST, wc->ledtestreg); - } - if (wc->alarmtimer == 0xf) { - wc->ledtestreg = wc->ledtestreg ^ BIT_ALARM; - control_set_reg(wc, WC_LEDTEST, wc->ledtestreg); - wc->alarmtimer = -1; - wc->alarmthreshold = (wc->alarmthreshold + 1 & 0x1f); +} + +static void t1xxp_transmitprep(struct t1xxp *wc, int ints) +{ + volatile unsigned char *txbuf; + int x,y; + if (ints & 0x01) { + /* We just finished sending the first buffer, start filling it + now */ + txbuf = wc->writechunk; + } else { + /* Just finished sending second buffer, fill it now */ + txbuf = wc->writechunk + 32 * ZT_CHUNKSIZE; + } + for (y=0;y<ZT_CHUNKSIZE;y++) { + for (x=0;x<24;x++) { + /* Put channel number as outgoing data */ + txbuf[y * 32 + chanmap[x]] = (unsigned char)x; } -#endif + } +} + +static void t1xxp_receiveprep(struct t1xxp *wc, int ints) +{ + volatile unsigned char *rxbuf; + static int looper=0; + int x; + unsigned char tmpbuf[32]; + if (ints & 0x08) { + /* Just received first buffer */ + rxbuf = wc->readchunk; + } else { + rxbuf = wc->readchunk + ZT_CHUNKSIZE * 32; + } + for (x=0;x<24;x++) { + /* Must map received channels into appropriate data */ + tmpbuf[x] = rxbuf[(chanmap[x] + WC_OFFSET) & 0x1f]; + } + if (!(looper++ % 1000)) { + memcpy(tmpbuf, rxbuf, 32); + for (x=0;x<24;x++) + printk("%d: %d\n", x, (int)tmpbuf[x]); + } + } static void t1xxp_interrupt(int irq, void *dev_id, struct pt_regs *regs) @@ -220,17 +280,13 @@ static void t1xxp_interrupt(int irq, void *dev_id, struct pt_regs *regs) printk("Got interrupt: 0x%04x\n", ints); gotint++; } - /* Initialize Write/Buffers to all blank data */ - memset((void *)wc->writechunk,0x55,ZT_MAX_CHUNKSIZE * 2 * 2 * 24 * 4); + if (ints & 0x0f) { + t1xxp_transmitprep(wc, ints); + t1xxp_receiveprep(wc, ints); + } handle_leds(wc); -#if 0 - if (ints & 0x0f) { - tjmodem_transmitprep(wc, ints); - tjmodem_receiveprep(wc, ints); - } -#endif if (ints & 0x10) printk("PCI Master abort\n"); @@ -264,8 +320,8 @@ static int t1xxp_reset(struct t1xxp *wc) static int t1xxp_hardware_init(struct t1xxp *wc) { int x; - /* Hardware Tigerjet stuff */ - /* Reset TJ chip and registers */ + /* Hardware PCI stuff */ + /* Reset chip and registers */ outb(DELAY | 0x0e, wc->ioaddr + WC_CNTL); /* Set all outputs to 0 */ outb(0x00, wc->ioaddr + WC_AUXD); @@ -276,7 +332,7 @@ static int t1xxp_hardware_init(struct t1xxp *wc) outb(0xc8, wc->ioaddr + WC_SERC); /* Internally delay FSC by one */ - outb(0x01, wc->ioaddr + 0x2f); + outb(0x01, wc->ioaddr + WC_FSCDELAY); /* Back to normal, with automatic DMA wrap around */ outb(DELAY | 0x01, wc->ioaddr + WC_CNTL); @@ -285,13 +341,18 @@ static int t1xxp_hardware_init(struct t1xxp *wc) outb(inb(wc->ioaddr + WC_CNTL) & 0xf9, WC_CNTL); /* Setup DMA Addresses */ + /* Start at writedma */ outl(wc->writedma, wc->ioaddr + WC_DMAWS); /* Write start */ - outl(wc->writedma + ZT_CHUNKSIZE * 96, wc->ioaddr + WC_DMAWI); /* Middle (interrupt) */ - outl(wc->writedma + ZT_CHUNKSIZE * 192 - 4, wc->ioaddr + WC_DMAWE); /* End */ + /* First frame */ + outl(wc->writedma + ZT_CHUNKSIZE * 32, wc->ioaddr + WC_DMAWI); /* Middle (interrupt) */ + /* Second frame */ + outl(wc->writedma + ZT_CHUNKSIZE * 32 * 2 - 4, wc->ioaddr + WC_DMAWE); /* End */ outl(wc->readdma, wc->ioaddr + WC_DMARS); /* Read start */ - outl(wc->readdma + ZT_CHUNKSIZE * 96, wc->ioaddr + WC_DMARI); /* Middle (interrupt) */ - outl(wc->readdma + ZT_CHUNKSIZE * 192 - 4, wc->ioaddr + WC_DMARE); /* End */ + /* First frame */ + outl(wc->readdma + ZT_CHUNKSIZE * 32, wc->ioaddr + WC_DMARI); /* Middle (interrupt) */ + /* Second frame */ + outl(wc->readdma + ZT_CHUNKSIZE * 32 * 2 - 4, wc->ioaddr + WC_DMARE); /* End */ printk("Setting up DMA (write/read = %08lx/%08lx)\n", wc->writedma, wc->readdma); @@ -300,20 +361,10 @@ static int t1xxp_hardware_init(struct t1xxp *wc) /* Check out the controller */ printk("Controller version: %02x\n", control_get_reg(wc, WC_VERSION)); - control_set_reg(wc, WC_LEDTEST, 0xff); + control_set_reg(wc, WC_LEDTEST, 0x00); control_set_reg(wc, WC_CLOCK, 0x00); /* Pretend we're in alarm */ wc->alarm = 1; -#if 0 - printk("LED/Test Reg test: expected %02x, got %02x\n", 0x55, control_get_reg(wc, WC_LEDTEST)); - control_set_reg(wc, WC_LEDTEST, 0xAA); - printk("LED/Test Reg test: expected %02x, got %02x\n", 0xAA, control_get_reg(wc, WC_LEDTEST)); - - control_set_reg(wc, WC_CLOCK, 0x55); - printk("Clock Reg test: expected %02x, got %02x\n", 0x55, control_get_reg(wc, WC_CLOCK)); - control_set_reg(wc, WC_CLOCK, 0xAA); - printk("Clock Reg test: expected %02x, got %02x\n", 0xAA, control_get_reg(wc, WC_CLOCK)); -#endif return 0; #if 0 /* Reset all registers on the 2151 */ @@ -366,18 +417,6 @@ static void t1xxp_start_dma(struct t1xxp *wc) outb(DELAY | 0x01, wc->ioaddr + WC_CNTL); outb(0x01, wc->ioaddr + WC_OPER); printk("Started DMA\n"); - { int x; - for (x=0;x<10;x++) { - printk("%d) Read at %08lx\n", x, inl(wc->ioaddr + WC_CURPOS)); - udelay(10000); - } } - printk("0x0: %02x\n", (unsigned int)inb(wc->ioaddr + 0x0)); - printk("0x1: %02x\n", (unsigned int)inb(wc->ioaddr + 0x1)); - printk("0x2b: %02x\n", (unsigned int)inb(wc->ioaddr + 0x2b)); - printk("0x2c: %02x\n", (unsigned int)inb(wc->ioaddr + 0x2c)); - printk("0x2d: %02x\n", (unsigned int)inb(wc->ioaddr + 0x2d)); - printk("0x2e: %02x\n", (unsigned int)inb(wc->ioaddr + 0x2e)); - printk("0x2f: %02x\n", (unsigned int)inb(wc->ioaddr + 0x2f)); } static void t1xxp_stop_dma(struct t1xxp *wc) @@ -408,20 +447,21 @@ static int __devinit t1xxp_init_one(struct pci_dev *pdev, const struct pci_devic wc->variety = (char *)(ent->driver_data); wc->writechunk = - (int *)pci_alloc_consistent(pdev, ZT_MAX_CHUNKSIZE * 2 * 2 * 24 * 4, &wc->writedma); + /* 32 channels, Double-buffer, Read/Write */ + (unsigned char *)pci_alloc_consistent(pdev, ZT_MAX_CHUNKSIZE * 32 * 2 * 2, &wc->writedma); if (!wc->writechunk) { printk("wcmodem: Unable to allocate DMA-able memory\n"); return -ENOMEM; } - /* Read is after the whole write piece (in double words) */ - wc->readchunk = wc->writechunk + ZT_CHUNKSIZE * 48; + /* Read is after the whole write piece (in bytes) */ + wc->readchunk = wc->writechunk + ZT_CHUNKSIZE * 32 * 2; - /* Same thing, but in bytes */ - wc->readdma = wc->writedma + ZT_CHUNKSIZE * 192; + /* Same thing... */ + wc->readdma = wc->writedma + ZT_CHUNKSIZE * 32 * 2; /* Initialize Write/Buffers to all blank data */ - memset((void *)wc->writechunk,0xff,ZT_MAX_CHUNKSIZE * 2 * 2 * 24 * 4); + memset((void *)wc->writechunk,0x00,ZT_MAX_CHUNKSIZE * 2 * 2 * 32); /* Enable bus mastering */ pci_set_master(pdev); @@ -440,8 +480,6 @@ static int __devinit t1xxp_init_one(struct pci_dev *pdev, const struct pci_devic /* Enable interrupts */ t1xxp_enable_interrupts(wc); - /* Initialize Write/Buffers to all blank data */ - memset((void *)wc->writechunk,0,ZT_MAX_CHUNKSIZE * 2 * 2 * 24 * 4); /* Start DMA */ t1xxp_start_dma(wc); @@ -453,6 +491,15 @@ static int __devinit t1xxp_init_one(struct pci_dev *pdev, const struct pci_devic return res; } +static void t1xxp_stop_stuff(struct t1xxp *wc) +{ + /* Kill clock */ + control_set_reg(wc, WC_CLOCK, 0); + + /* Turn off LED's */ + control_set_reg(wc, WC_LEDTEST, 0); +} + static void __devexit t1xxp_remove_one(struct pci_dev *pdev) { struct t1xxp *wc = pci_get_drvdata(pdev); @@ -464,11 +511,13 @@ static void __devexit t1xxp_remove_one(struct pci_dev *pdev) /* In case hardware is still there */ t1xxp_disable_interrupts(wc); + t1xxp_stop_stuff(wc); + /* Immediately free resources */ pci_free_consistent(pdev, ZT_MAX_CHUNKSIZE * 2 * 2 * 24 * 4, (void *)wc->writechunk, wc->writedma); free_irq(pdev->irq, wc); - /* Reset TJ chip and registers */ + /* Reset PCI chip and registers */ outb(DELAY | 0x0e, wc->ioaddr + WC_CNTL); /* Release span, possibly delayed */ |