[Asterisk-cvs] zaptel wcfxs.c,1.20,1.21

wmeadows at lists.digium.com wmeadows at lists.digium.com
Wed Sep 24 21:00:36 CDT 2003


Update of /usr/cvsroot/zaptel
In directory mongoose.digium.com:/tmp/cvs-serv18388

Modified Files:
	wcfxs.c 
Log Message:
Try Both Auto and Manual Calibration 
Add sane and manual flag to init_proslic 
Set RESET to low if module fails to load


Index: wcfxs.c
===================================================================
RCS file: /usr/cvsroot/zaptel/wcfxs.c,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -d -r1.20 -r1.21
--- wcfxs.c	17 Sep 2003 16:26:48 -0000	1.20
+++ wcfxs.c	25 Sep 2003 02:01:46 -0000	1.21
@@ -179,7 +179,7 @@
 };
 
 static struct wcfxs_desc wcfxs = { "Wildcard S400P Prototype", 0 };
-static struct wcfxs_desc wcfxse = { "Wildcard TDM400P REV E", 0 };
+static struct wcfxs_desc wcfxse = { "Wildcard TDM400P REV E/F", 0 };
 
 static struct wcfxs *ifaces[WC_MAX_IFACES];
 
@@ -187,7 +187,7 @@
 
 static int debug = 0;
 
-static int wcfxs_init_proslic(struct wcfxs *wc, int card, int fast);
+static int wcfxs_init_proslic(struct wcfxs *wc, int card, int fast , int manual, int sane);
 
 static inline void wcfxs_transmitprep(struct wcfxs *wc, unsigned char ints)
 {
@@ -512,7 +512,8 @@
 
 static int wcfxs_proslic_insane(struct wcfxs *wc, int card)
 {
-	int blah;
+	int blah,insane_report;
+	insane_report=0;
 
 	blah = wcfxs_getreg(wc, card, 0);
 	if (debug) 
@@ -537,19 +538,22 @@
 	if (blah != 0x2) {
 		printk("ProSLIC on module %d insane (1) %d should be 2\n", card, blah);
 		return -1;
-	}
+	} else if ( insane_report)
+		printk("ProSLIC on module %d Reg 8 Reads %d Expected is 0x2\n",card,blah);
 
 	blah = wcfxs_getreg(wc, card, 64);
 	if (blah != 0x0) {
 		printk("ProSLIC on module %d insane (2)\n", card);
 		return -1;
-	}
+	} else if ( insane_report)
+		printk("ProSLIC on module %d Reg 64 Reads %d Expected is 0x0\n",card,blah);
 
 	blah = wcfxs_getreg(wc, card, 11);
 	if (blah != 0x33) {
 		printk("ProSLIC on module %d insane (3)\n", card);
 		return -1;
-	}
+	} else if ( insane_report)
+		printk("ProSLIC on module %d Reg 11 Reads %d Expected is 0x33\n",card,blah);
 
 	/* Just be sure it's setup right. */
 	wcfxs_setreg(wc, card, 30, 0);
@@ -724,7 +728,7 @@
 	return(0);
 
 }
-#if 0
+#if 1
 static int wcfxs_calibrate(struct wcfxs *wc, int card)
 {
 	unsigned long origjiffies;
@@ -754,7 +758,7 @@
 	return 0;
 }
 #endif
-static int wcfxs_init_proslic(struct wcfxs *wc, int card, int fast)
+static int wcfxs_init_proslic(struct wcfxs *wc, int card, int fast, int manual, int sane)
 {
 
 	unsigned short tmp[5];
@@ -764,8 +768,8 @@
 	wc->idletxhookstate [card] = 1;
 
 	/* Sanity check the ProSLIC */
-	if (wcfxs_proslic_insane(wc, card))
-		return -1;
+	if (!sane && wcfxs_proslic_insane(wc, card))
+		return -2;
 
 	if (wcfxs_init_indirect_regs(wc, card)) {
 		printk(KERN_INFO "Indirect Registers failed to initialize on module %d.\n", card);
@@ -814,9 +818,25 @@
 		}
 #ifndef NO_CALIBRATION
 		/* Perform calibration */
-		if (wcfxs_manual_calibrate(wc, card)) {
-			printk("ProSlic died on Calibration (try -DNO_CALIBRATION in Makefile).\n");
-			return -1;
+		if(manual) {
+			if (wcfxs_manual_calibrate(wc, card)) {
+				//printk("Proslic failed on Manual Calibration\n");
+				if (wcfxs_manual_calibrate(wc, card)) {
+					printk("Proslic Failed on Second Attempt to Calibrate Manually. (Try -DNO_CALIBRATION in Makefile)\n");
+					return -1;
+				}
+				printk("Proslic Passed Manual Calibration on Second Attempt\n");
+			}
+		}
+		else {
+			if(wcfxs_calibrate(wc, card))  {
+				//printk("ProSlic died on Auto Calibration.\n");
+				if (wcfxs_calibrate(wc, card)) {
+					printk("Proslic Failed on Second Attempt to Auto Calibrate\n");
+					return -1;
+				}
+				printk("Proslic Passed Auto Calibration on Second Attempt\n");
+			}
 		}
 #endif
 
@@ -891,7 +911,7 @@
 	res = wcfxs_getreg(wc, card, 8);
 	if (res) {
 		printk("Ouch, part reset, quickly restoring reality (%d)\n", card);
-		wcfxs_init_proslic(wc, card, 1);
+		wcfxs_init_proslic(wc, card, 1, 0, 1);
 	} else {
 		res = wcfxs_getreg(wc, card, 64);
 		if (!res && (res != wc->lasttxhook[card])) {
@@ -1105,8 +1125,10 @@
 	unsigned char x,y;
 	int failed;
 
-	/* Check Freshmaker chip */
+	/* Signal Reset */
 	outb(0x01, wc->ioaddr + WC_CNTL);
+
+	/* Check Freshmaker chip */
 	x=inb(wc->ioaddr + WC_CNTL);
 	ver = wcfxs_getcreg(wc, WC_VER);
 	failed = 0;
@@ -1177,11 +1199,20 @@
 	while(jiffies - oldjiffies < (HZ / 4) + 1);
 
 	for (x=0;x<wc->cards;x++) {
-		if (!wcfxs_init_proslic(wc, x, 0)) {
-			printk("Module %d: Initialized\n", x);
+		int sane=0,ret=0;
+		/* Init with Auto Calibration */
+		if (!(ret=wcfxs_init_proslic(wc, x, 0, 0, sane))) {
 			wc->cardflag |= (1 << x);
-		} else
-			printk("Module %d: Not installed\n", x);
+			printk("Module %d: Installed -- AUTO\n",x);
+		} else {
+			if(ret!=-2) sane=1;
+			/* Init with Manual Calibration */
+			if (!wcfxs_init_proslic(wc, x, 0, 1, sane)) {
+				wc->cardflag |= (1 << x);
+				printk("Module %d: Installed -- MANUAL\n",x);
+			} else 
+				printk("Module %d: Not installed\n", x);
+		}
 	}
 
 	/* Return error if nothing initialized okay. */
@@ -1311,6 +1342,11 @@
 
 
 			if (wcfxs_hardware_init(wc)) {
+				unsigned char x;
+				/* Set Reset Low */
+				x=inb(wc->ioaddr + WC_CNTL);
+				outb((~0x1)&x, wc->ioaddr + WC_CNTL);
+				/* Free Resources */
 				free_irq(pdev->irq, wc);
 				zt_unregister(&wc->span);
 				if (wc->freeregion)




More information about the svn-commits mailing list