patch-2.4.21 linux-2.4.21/drivers/net/sk98lin/ski2c.c

Next file: linux-2.4.21/drivers/net/sk98lin/sklm80.c
Previous file: linux-2.4.21/drivers/net/sk98lin/skgesirq.c
Back to the patch index
Back to the overall index

diff -urN linux-2.4.20/drivers/net/sk98lin/ski2c.c linux-2.4.21/drivers/net/sk98lin/ski2c.c
@@ -2,16 +2,15 @@
  *
  * Name:	ski2c.c
  * Project:	GEnesis, PCI Gigabit Ethernet Adapter
- * Version:	$Revision: 1.47 $
- * Date:	$Date: 2001/04/05 11:38:09 $
+ * Version:	$Revision: 1.56 $
+ * Date:	$Date: 2002/12/19 14:20:41 $
  * Purpose:	Functions to access Voltage and Temperature Sensor
- *			(taken from Monalisa (taken from Concentrator))
  *
  ******************************************************************************/
 
 /******************************************************************************
  *
- *	(C)Copyright 1998-2001 SysKonnect GmbH.
+ *	(C)Copyright 1998-2002 SysKonnect GmbH.
  *
  *	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
@@ -27,6 +26,43 @@
  * History:
  *
  *	$Log: ski2c.c,v $
+ *	Revision 1.56  2002/12/19 14:20:41  rschmidt
+ *	Added debugging code in SkI2cWait().
+ *	Replaced all I2C-write operations with function SkI2cWrite().
+ *	Fixed compiler warning because of uninitialized 'Time' in SkI2cEvent().
+ *	Editorial changes.
+ *	
+ *	Revision 1.55  2002/10/15 07:23:55  rschmidt
+ *	Added setting of the GIYukon32Bit bool variable to distinguish
+ *	32-bit adapters.
+ *	Editorial changes (TWSI).
+ *	
+ *	Revision 1.54  2002/08/13 09:05:06  rschmidt
+ *	Added new thresholds if VAUX is not available (GIVauxAvail).
+ *	Merged defines for PHY PLL 3V3 voltage (A and B).
+ *	Editorial changes.
+ *	
+ *	Revision 1.53  2002/08/08 11:04:53  rwahl
+ *	Added missing comment for revision 1.51
+ *	
+ *	Revision 1.52  2002/08/08 10:09:02  jschmalz
+ *	Sensor init state caused wrong error log entry
+ *	
+ *	Revision 1.51  2002/08/06 09:43:03  jschmalz
+ *	Extensions and changes for Yukon
+ *	
+ *	Revision 1.50  2002/08/02 12:09:22  rschmidt
+ *	Added support for YUKON sensors.
+ *	Editorial changes.
+ *	
+ *	Revision 1.49  2002/07/30 11:07:52  rschmidt
+ *	Replaced MaxSens init by update for Copper in SkI2cInit1(),
+ *	because it was already initialized in SkI2cInit0().
+ *	Editorial changes.
+ *	
+ *	Revision 1.48  2001/08/16 12:44:33  afischer
+ *	LM80 sensor init values corrected
+ *	
  *	Revision 1.47  2001/04/05 11:38:09  rassmann
  *	Set SenState to idle in SkI2cWaitIrq().
  *	Changed error message in SkI2cWaitIrq().
@@ -178,7 +214,7 @@
  *	Revision 1.2  1998/08/11 07:27:15  gklug
  *	add: functions of the interface
  *	adapt rest of source to C coding Conventions
- *	rmv: unneccessary code taken from Mona Lisa
+ *	rmv: unnecessary code taken from Mona Lisa
  *
  *	Revision 1.1  1998/06/19 14:28:43  malthoff
  *	Created. Sources taken from ML Projekt.
@@ -192,7 +228,7 @@
  *	I2C Protocol
  */
 static const char SysKonnectFileId[] =
-	"$Id: ski2c.c,v 1.47 2001/04/05 11:38:09 rassmann Exp $";
+	"$Id: ski2c.c,v 1.56 2002/12/19 14:20:41 rschmidt Exp $";
 
 #include "h/skdrv1st.h"		/* Driver Specific Definitions */
 #include "h/lm80.h"
@@ -280,21 +316,21 @@
 #ifndef I2C_SLOW_TIMING
 #define	T_CLK_LOW		1300L	/* clock low time in ns */
 #define	T_CLK_HIGH		 600L	/* clock high time in ns */
-#define T_DATA_IN_SETUP		 100L	/* data in Set-UP Time */
+#define T_DATA_IN_SETUP		 100L	/* data in Set-up Time */
 #define T_START_HOLD		 600L	/* start condition hold time */
 #define T_START_SETUP		 600L	/* start condition Set-up time */
 #define	T_STOP_SETUP		 600L	/* stop condition Set-up time */
-#define T_BUS_IDLE		1300L	/* time the bus must free after tx */
+#define T_BUS_IDLE		1300L	/* time the bus must free after Tx */
 #define	T_CLK_2_DATA_OUT	 900L	/* max. clock low to data output valid */
 #else	/* I2C_SLOW_TIMING */
 /* I2C Standard Mode Timing */
 #define	T_CLK_LOW		4700L	/* clock low time in ns */
 #define	T_CLK_HIGH		4000L	/* clock high time in ns */
-#define T_DATA_IN_SETUP		 250L	/* data in Set-UP Time */
+#define T_DATA_IN_SETUP		 250L	/* data in Set-up Time */
 #define T_START_HOLD		4000L	/* start condition hold time */
-#define T_START_SETUP		4700L	/* start condition Set_up time */
+#define T_START_SETUP		4700L	/* start condition Set-up time */
 #define	T_STOP_SETUP		4000L	/* stop condition Set-up time */
-#define T_BUS_IDLE		4700L	/* time the bus must free after tx */
+#define T_BUS_IDLE		4700L	/* time the bus must free after Tx */
 #endif	/* !I2C_SLOW_TIMING */
 
 #define NS2BCLK(x)	(((x)*125)/10000)
@@ -312,9 +348,9 @@
 #define I2C_DATA_HIGH(IoC)	SK_I2C_SET_BIT(IoC, I2C_DATA)
 #define	I2C_DATA_LOW(IoC)	SK_I2C_CLR_BIT(IoC, I2C_DATA)
 #define	I2C_DATA_OUT(IoC)	SK_I2C_SET_BIT(IoC, I2C_DATA_DIR)
-#define	I2C_DATA_IN(IoC)	SK_I2C_CLR_BIT(IoC, I2C_DATA_DIR|I2C_DATA)
+#define	I2C_DATA_IN(IoC)	SK_I2C_CLR_BIT(IoC, I2C_DATA_DIR | I2C_DATA)
 #define	I2C_CLK_HIGH(IoC)	SK_I2C_SET_BIT(IoC, I2C_CLK)
-#define	I2C_CLK_LOW(IoC)	SK_I2C_CLR_BIT(IoC, I2C_CLK|I2C_DATA_DIR)
+#define	I2C_CLK_LOW(IoC)	SK_I2C_CLR_BIT(IoC, I2C_CLK | I2C_DATA_DIR)
 #define	I2C_START_COND(IoC)	SK_I2C_CLR_BIT(IoC, I2C_CLK)
 
 #define NS2CLKT(x)	((x*125L)/10000)
@@ -331,7 +367,8 @@
 	I2C_DATA_OUT(IoC);
 	if (Bit) {
 		I2C_DATA_HIGH(IoC);
-	} else {
+	}
+	else {
 		I2C_DATA_LOW(IoC);
 	}
 	SkDgWaitTime(IoC, NS2BCLK(T_DATA_IN_SETUP));
@@ -428,11 +465,8 @@
 	SkDgWaitTime(IoC, NS2BCLK(T_CLK_HIGH));
 
 	SK_I2C_GET_SW(IoC, &I2cSwCtrl);
-	if (I2cSwCtrl & I2C_DATA) {
-		Bit = 1;
-	} else {
-		Bit = 0;
-	}
+	
+	Bit = (I2cSwCtrl & I2C_DATA) ? 1 : 0;
 
 	I2C_CLK_LOW(IoC);
 	SkDgWaitTime(IoC, NS2BCLK(T_CLK_LOW-T_CLK_2_DATA_OUT));
@@ -444,16 +478,16 @@
 /*
  * Receive an ACK.
  *
- * returns	0 If acknoledged
+ * returns	0 If acknowledged
  *		1 in case of an error
  */
 int SkI2cRcvAck(
-SK_IOC IoC)	/* I/O Context */
+SK_IOC	IoC)	/* I/O Context */
 {
 	/*
 	 * Received bit must be zero.
 	 */
-	return (SkI2cRcvBit(IoC) != 0);
+	return(SkI2cRcvBit(IoC) != 0);
 }	/* SkI2cRcvAck */
 
 
@@ -461,7 +495,7 @@
  * Send an NACK.
  */
 void SkI2cSndNAck(
-SK_IOC IoC)	/* I/O Context */
+SK_IOC	IoC)	/* I/O Context */
 {
 	/*
 	 * Received bit must be zero.
@@ -487,18 +521,19 @@
 /*
  * Send one byte to the I2C device and wait for ACK.
  *
- * Return acknoleged status.
+ * Return acknowleged status.
  */
 int SkI2cSndByte(
 SK_IOC	IoC,	/* I/O Context */
-int	Byte)		/* byte to send */
+int		Byte)	/* byte to send */
 {
 	int	i;
 
 	for (i = 0; i < 8; i++) {
 		if (Byte & (1<<(7-i))) {
 			SkI2cSndBit(IoC, 1);
-		} else {
+		}
+		else {
 			SkI2cSndBit(IoC, 0);
 		}
 	}
@@ -514,7 +549,7 @@
  */
 int SkI2cRcvByte(
 SK_IOC	IoC,	/* I/O Context */
-int	Last)		/* Last Byte Flag */
+int		Last)	/* Last Byte Flag */
 {
 	int	i;
 	int	Byte = 0;
@@ -526,7 +561,8 @@
 
 	if (Last) {
 		SkI2cSndNAck(IoC);
-	} else {
+	}
+	else {
 		SkI2cSndAck(IoC);
 	}
 
@@ -537,7 +573,7 @@
 /*
  * Start dialog and send device address
  *
- * Return 0 if acknoleged, 1 in case of an error
+ * Return 0 if acknowleged, 1 in case of an error
  */
 int	SkI2cSndDev(
 SK_IOC	IoC,	/* I/O Context */
@@ -545,7 +581,7 @@
 int		Rw)		/* Read / Write Flag */
 {
 	SkI2cStart(IoC);
-	Rw = ~Rw; 
+	Rw = ~Rw;
 	Rw &= I2C_WRITE;
 	return(SkI2cSndByte(IoC, (Addr<<1) | Rw));
 }	/* SkI2cSndDev */
@@ -567,18 +603,33 @@
 int		Event)	/* complete event to wait for (I2C_READ or I2C_WRITE) */
 {
 	SK_U64	StartTime;
+	SK_U64	CurrentTime;
 	SK_U32	I2cCtrl;
 
 	StartTime = SkOsGetTime(pAC);
+	
 	do {
-		if (SkOsGetTime(pAC) - StartTime > SK_TICKS_PER_SEC / 8) {
+		CurrentTime = SkOsGetTime(pAC);
+
+		if (CurrentTime - StartTime > SK_TICKS_PER_SEC / 8) {
+			
 			SK_I2C_STOP(IoC);
 #ifndef SK_DIAG
 			SK_ERR_LOG(pAC, SK_ERRCL_SW, SKERR_I2C_E002, SKERR_I2C_E002MSG);
 #endif	/* !SK_DIAG */
 			return(1);
 		}
+		
 		SK_I2C_GET_CTL(IoC, &I2cCtrl);
+
+#ifdef xYUKON_DBG
+		printf("StartTime=%lu, CurrentTime=%lu\n",
+			StartTime, CurrentTime);
+		if (kbhit()) {
+			return(1);
+		}
+#endif /* YUKON_DBG */
+	
 	} while ((I2cCtrl & I2C_FLAG) == (SK_U32)Event << 31);
 
 	return(0);
@@ -591,7 +642,7 @@
  * Returns
  *	Nothing
  */
-void	SkI2cWaitIrq(
+void SkI2cWaitIrq(
 SK_AC	*pAC,	/* Adapter Context */
 SK_IOC	IoC)	/* I/O Context */
 {
@@ -621,8 +672,6 @@
 	return;
 }	/* SkI2cWaitIrq */
 
-#ifdef	SK_DIAG
-
 /*
  * writes a single byte or 4 bytes into the I2C device
  *
@@ -635,14 +684,17 @@
 SK_U32	I2cData,	/* I2C Data to write */
 int		I2cDev,		/* I2C Device Address */
 int		I2cReg,		/* I2C Device Register Address */
-int		I2cBurst)	/* I2C Burst Flag ( 0 || I2C_BURST ) */
+int		I2cBurst)	/* I2C Burst Flag */
 {
 	SK_OUT32(IoC, B2_I2C_DATA, I2cData);
 	SK_I2C_CTL(IoC, I2C_WRITE, I2cDev, I2cReg, I2cBurst);
+	
 	return(SkI2cWait(pAC, IoC, I2C_WRITE));
 }	/* SkI2cWrite*/
 
 
+#ifdef	SK_DIAG
+
 /*
  * reads a single byte or 4 bytes from the I2C device
  *
@@ -653,15 +705,17 @@
 SK_IOC	IoC,		/* I/O Context */
 int		I2cDev,		/* I2C Device Address */
 int		I2cReg,		/* I2C Device Register Address */
-int		I2cBurst)	/* I2C Burst Flag ( 0 || I2C_BURST ) */
+int		I2cBurst)	/* I2C Burst Flag */
 {
 	SK_U32	Data;
 
 	SK_OUT32(IoC, B2_I2C_DATA, 0);
 	SK_I2C_CTL(IoC, I2C_READ, I2cDev, I2cReg, I2cBurst);
-	if (SkI2cWait(pAC, IoC, I2C_READ)) {
-		w_print("I2C Transfer Timeout!\n"); 
+	
+	if (SkI2cWait(pAC, IoC, I2C_READ) != 0) {
+		w_print("%s\n", SKERR_I2C_E002MSG);
 	}
+	
 	SK_IN32(IoC, B2_I2C_DATA, &Data);
 	return(Data);
 }	/* SkI2cRead */
@@ -684,13 +738,17 @@
 SK_IOC		IoC,	/* I/O Context */
 SK_SENSOR	*pSen)	/* Sensor to be read */
 {
-	return((*pSen->SenRead)(pAC, IoC, pSen));
+    if (pSen->SenRead != NULL) {
+        return((*pSen->SenRead)(pAC, IoC, pSen));
+    }
+    else
+        return(0); /* no success */
 }	/* SkI2cReadSensor*/
 
 /*
  * Do the Init state 0 initialization
  */
-static	int	SkI2cInit0(
+static int SkI2cInit0(
 SK_AC	*pAC)	/* Adapter Context */
 {
 	int	i;
@@ -698,109 +756,33 @@
 	/* Begin with first sensor */
 	pAC->I2c.CurrSens = 0;
 	
-	/* Set to mimimum sensor number */
-	pAC->I2c.MaxSens = SK_MIN_SENSORS;
+	/* Begin with timeout control for state machine */
+	pAC->I2c.TimerMode = SK_TIMER_WATCH_STATEMACHINE;
+	
+	/* Set sensor number to zero */
+	pAC->I2c.MaxSens = 0;
 
 #ifndef	SK_DIAG
 	/* Initialize Number of Dummy Reads */
 	pAC->I2c.DummyReads = SK_MAX_SENSORS;
 #endif
 
-	for (i = 0; i < SK_MAX_SENSORS; i ++) {
-		switch (i) {
-		case 0:
-			pAC->I2c.SenTable[i].SenDesc = "Temperature";
-			pAC->I2c.SenTable[i].SenType = SK_SEN_TEMP;
-			pAC->I2c.SenTable[i].SenThreErrHigh = SK_SEN_ERRHIGH0;
-			pAC->I2c.SenTable[i].SenThreErrLow = SK_SEN_ERRLOW0;
-			pAC->I2c.SenTable[i].SenThreWarnHigh = SK_SEN_WARNHIGH0;
-			pAC->I2c.SenTable[i].SenThreWarnLow = SK_SEN_WARNLOW0;
-			pAC->I2c.SenTable[i].SenReg = LM80_TEMP_IN;
-			pAC->I2c.SenTable[i].SenInit = SK_TRUE;
-			break;
-		case 1:
-			pAC->I2c.SenTable[i].SenDesc = "Voltage PCI";
-			pAC->I2c.SenTable[i].SenType = SK_SEN_VOLT;
-			pAC->I2c.SenTable[i].SenThreErrHigh = SK_SEN_ERRHIGH1;
-			pAC->I2c.SenTable[i].SenThreErrLow = SK_SEN_ERRLOW1;
-			pAC->I2c.SenTable[i].SenThreWarnHigh = SK_SEN_WARNHIGH1;
-			pAC->I2c.SenTable[i].SenThreWarnLow = SK_SEN_WARNLOW1;
-			pAC->I2c.SenTable[i].SenReg = LM80_VT0_IN;
-			pAC->I2c.SenTable[i].SenInit = SK_TRUE;
-			break;
-		case 2:
-			pAC->I2c.SenTable[i].SenDesc = "Voltage PCI-IO";
-			pAC->I2c.SenTable[i].SenType = SK_SEN_VOLT;
-			pAC->I2c.SenTable[i].SenThreErrHigh = SK_SEN_ERRHIGH2;
-			pAC->I2c.SenTable[i].SenThreErrLow = SK_SEN_ERRLOW2;
-			pAC->I2c.SenTable[i].SenThreWarnHigh = SK_SEN_WARNHIGH2;
-			pAC->I2c.SenTable[i].SenThreWarnLow = SK_SEN_WARNLOW2;
-			pAC->I2c.SenTable[i].SenReg = LM80_VT1_IN;
-			pAC->I2c.SenTable[i].SenInit = SK_FALSE;
-			break;
-		case 3:
-			pAC->I2c.SenTable[i].SenDesc = "Voltage ASIC";
-			pAC->I2c.SenTable[i].SenType = SK_SEN_VOLT;
-			pAC->I2c.SenTable[i].SenThreErrHigh = SK_SEN_ERRHIGH3;
-			pAC->I2c.SenTable[i].SenThreErrLow = SK_SEN_ERRLOW3;
-			pAC->I2c.SenTable[i].SenThreWarnHigh = SK_SEN_WARNHIGH3;
-			pAC->I2c.SenTable[i].SenThreWarnLow = SK_SEN_WARNLOW3;
-			pAC->I2c.SenTable[i].SenReg = LM80_VT2_IN;
-			pAC->I2c.SenTable[i].SenInit = SK_TRUE;
-			break;
-		case 4:
-			pAC->I2c.SenTable[i].SenDesc = "Voltage PMA";
-			pAC->I2c.SenTable[i].SenType = SK_SEN_VOLT;
-			pAC->I2c.SenTable[i].SenThreErrHigh = SK_SEN_ERRHIGH4;
-			pAC->I2c.SenTable[i].SenThreErrLow = SK_SEN_ERRLOW4;
-			pAC->I2c.SenTable[i].SenThreWarnHigh = SK_SEN_WARNHIGH4;
-			pAC->I2c.SenTable[i].SenThreWarnLow = SK_SEN_WARNLOW4;
-			pAC->I2c.SenTable[i].SenReg = LM80_VT3_IN;
-			pAC->I2c.SenTable[i].SenInit = SK_TRUE;
-			break;
-		case 5:
-			pAC->I2c.SenTable[i].SenDesc = "Voltage PHY 2V5";
-			pAC->I2c.SenTable[i].SenType = SK_SEN_VOLT;
-			pAC->I2c.SenTable[i].SenThreErrHigh = SK_SEN_ERRHIGH5;
-			pAC->I2c.SenTable[i].SenThreErrLow = SK_SEN_ERRLOW5;
-			pAC->I2c.SenTable[i].SenThreWarnHigh = SK_SEN_WARNHIGH5;
-			pAC->I2c.SenTable[i].SenThreWarnLow = SK_SEN_WARNLOW5;
-			pAC->I2c.SenTable[i].SenReg = LM80_VT4_IN;
-			pAC->I2c.SenTable[i].SenInit = SK_TRUE;
-			break;
-		case 6:
-			pAC->I2c.SenTable[i].SenDesc = "Voltage PHY B PLL";
-			pAC->I2c.SenTable[i].SenType = SK_SEN_VOLT;
-			pAC->I2c.SenTable[i].SenThreErrHigh = SK_SEN_ERRHIGH6;
-			pAC->I2c.SenTable[i].SenThreErrLow = SK_SEN_ERRLOW6;
-			pAC->I2c.SenTable[i].SenThreWarnHigh = SK_SEN_WARNHIGH6;
-			pAC->I2c.SenTable[i].SenThreWarnLow = SK_SEN_WARNLOW6;
-			pAC->I2c.SenTable[i].SenReg = LM80_VT5_IN;
-			pAC->I2c.SenTable[i].SenInit = SK_TRUE;
-			break;
-		case 7:
-			pAC->I2c.SenTable[i].SenDesc = "Speed Fan";
-			pAC->I2c.SenTable[i].SenType = SK_SEN_FAN;
-			pAC->I2c.SenTable[i].SenThreErrHigh = SK_SEN_ERRHIGH;
-			pAC->I2c.SenTable[i].SenThreErrLow = SK_SEN_ERRLOW;
-			pAC->I2c.SenTable[i].SenThreWarnHigh = SK_SEN_WARNHIGH;
-			pAC->I2c.SenTable[i].SenThreWarnLow = SK_SEN_WARNLOW;
-			pAC->I2c.SenTable[i].SenReg = LM80_FAN2_IN;
-			pAC->I2c.SenTable[i].SenInit = SK_TRUE;
-			break;
-		default:
-			SK_ERR_LOG(pAC, SK_ERRCL_INIT | SK_ERRCL_SW,
-				SKERR_I2C_E001, SKERR_I2C_E001MSG);
-			break;
-		}
-
+	for (i = 0; i < SK_MAX_SENSORS; i++) {
+		pAC->I2c.SenTable[i].SenDesc = "unknown";
+		pAC->I2c.SenTable[i].SenType = SK_SEN_UNKNOWN;
+		pAC->I2c.SenTable[i].SenThreErrHigh = 0;
+		pAC->I2c.SenTable[i].SenThreErrLow = 0;
+		pAC->I2c.SenTable[i].SenThreWarnHigh = 0;
+		pAC->I2c.SenTable[i].SenThreWarnLow = 0;
+		pAC->I2c.SenTable[i].SenReg = LM80_FAN2_IN;
+		pAC->I2c.SenTable[i].SenInit = SK_SEN_DYN_INIT_NONE;
 		pAC->I2c.SenTable[i].SenValue = 0;
-		pAC->I2c.SenTable[i].SenErrFlag = SK_SEN_ERR_OK;
+		pAC->I2c.SenTable[i].SenErrFlag = SK_SEN_ERR_NOT_PRESENT;
 		pAC->I2c.SenTable[i].SenErrCts = 0;
 		pAC->I2c.SenTable[i].SenBegErrTS = 0;
 		pAC->I2c.SenTable[i].SenState = SK_SEN_IDLE;
-		pAC->I2c.SenTable[i].SenRead = SkLm80ReadSensor;
-		pAC->I2c.SenTable[i].SenDev = LM80_ADDR;
+		pAC->I2c.SenTable[i].SenRead = NULL;
+		pAC->I2c.SenTable[i].SenDev = 0;
 	}
 
 	/* Now we are "INIT data"ed */
@@ -829,68 +811,211 @@
  * - all 0s
  *
  */
-static	int	SkI2cInit1(
+static int SkI2cInit1(
 SK_AC	*pAC,	/* Adapter Context */
 SK_IOC	IoC)	/* I/O Context */
 {
+    int i;
+    SK_U8 I2cSwCtrl;
+	SK_GEPORT *pPrt;	/* GIni Port struct pointer */
+
 	if (pAC->I2c.InitLevel != SK_INIT_DATA) {
 		/* ReInit not needed in I2C module */
 		return(0);
 	}
 
-	SK_OUT32(IoC, B2_I2C_DATA, 0);
-	SK_I2C_CTL(IoC, I2C_WRITE, LM80_ADDR, LM80_CFG, 0);
-	(void)SkI2cWait(pAC, IoC, I2C_WRITE);
-
-	SK_OUT32(IoC, B2_I2C_DATA, 0xff);
-	SK_I2C_CTL(IoC, I2C_WRITE, LM80_ADDR, LM80_IMSK_1, 0);
-	(void)SkI2cWait(pAC, IoC, I2C_WRITE);
-
-	SK_OUT32(IoC, B2_I2C_DATA, 0xff);
-	SK_I2C_CTL(IoC, I2C_WRITE, LM80_ADDR, LM80_IMSK_2, 0);
-	(void)SkI2cWait(pAC, IoC, I2C_WRITE);
-
-	SK_OUT32(IoC, B2_I2C_DATA, 0x0);
-	SK_I2C_CTL(IoC, I2C_WRITE, LM80_ADDR, LM80_FAN_CTRL, 0);
-	(void)SkI2cWait(pAC, IoC, I2C_WRITE);
-
-	SK_OUT32(IoC, B2_I2C_DATA, 0);
-	SK_I2C_CTL(IoC, I2C_WRITE, LM80_ADDR, LM80_TEMP_CTRL, 0);
-	(void)SkI2cWait(pAC, IoC, I2C_WRITE);
+    /* Set the Direction of I2C-Data Pin to IN */
+    SK_I2C_CLR_BIT(IoC, I2C_DATA_DIR | I2C_DATA);
+    /* Check for 32-Bit Yukon with Low at I2C-Data Pin */
+	SK_I2C_GET_SW(IoC, &I2cSwCtrl);
 
-	SK_OUT32(IoC, B2_I2C_DATA, LM80_CFG_START);
-	SK_I2C_CTL(IoC, I2C_WRITE, LM80_ADDR, LM80_CFG, 0);
-	(void)SkI2cWait(pAC, IoC, I2C_WRITE);
+	if ((I2cSwCtrl & I2C_DATA) == 0) {
+		/* this is a 32-Bit board */
+		pAC->GIni.GIYukon32Bit = SK_TRUE;
+        return(0);
+    }
+
+	/* Check for 64 Bit Yukon without sensors */
+	if (SkI2cWrite(pAC, IoC, 0, LM80_ADDR, LM80_CFG, 0) != 0) {
+        return(0);
+    }
 
+	(void)SkI2cWrite(pAC, IoC, 0xff, LM80_ADDR, LM80_IMSK_1, 0);
+	
+	(void)SkI2cWrite(pAC, IoC, 0xff, LM80_ADDR, LM80_IMSK_2, 0);
+	
+	(void)SkI2cWrite(pAC, IoC, 0, LM80_ADDR, LM80_FAN_CTRL, 0);
+	
+	(void)SkI2cWrite(pAC, IoC, 0, LM80_ADDR, LM80_TEMP_CTRL, 0);
+	
+	(void)SkI2cWrite(pAC, IoC, LM80_CFG_START, LM80_ADDR, LM80_CFG, 0);
+	
 	/*
-	 * MaxSens has to be initialized here, because PhyType is not
-	 * set when performing Init Level 1
+	 * MaxSens has to be updated here, because PhyType is not
+	 * set when performing Init Level 0
 	 */
-	switch (pAC->GIni.GP[0].PhyType) {
-	case SK_PHY_XMAC:
-		pAC->I2c.MaxSens = 5;
-		break;
+    pAC->I2c.MaxSens = 5;
+	
+	pPrt = &pAC->GIni.GP[0];
+	
+    switch (pPrt->PhyType) {
 	case SK_PHY_BCOM:
-		pAC->I2c.SenTable[4].SenDesc = "Voltage PHY A PLL";
 		if (pAC->GIni.GIMacsFound == 1) {
-			pAC->I2c.MaxSens = 6;
-		} 
+			pAC->I2c.MaxSens += 1;
+		}
 		else {
-			pAC->I2c.MaxSens = 8;
+			pAC->I2c.MaxSens += 3;
 		}
 		break;
-	case SK_PHY_LONE:
-		pAC->I2c.MaxSens = 5;
+	case SK_PHY_MARV_COPPER:
+		pAC->I2c.MaxSens += 3;
 		break;
 	}
 	
+	for (i = 0; i < pAC->I2c.MaxSens; i++) {
+		switch (i) {
+		case 0:
+			pAC->I2c.SenTable[i].SenDesc = "Temperature";
+			pAC->I2c.SenTable[i].SenType = SK_SEN_TEMP;
+			pAC->I2c.SenTable[i].SenThreErrHigh = SK_SEN_TEMP_HIGH_ERR;
+			pAC->I2c.SenTable[i].SenThreWarnHigh = SK_SEN_TEMP_HIGH_WARN;
+			pAC->I2c.SenTable[i].SenThreWarnLow = SK_SEN_TEMP_LOW_WARN;
+			pAC->I2c.SenTable[i].SenThreErrLow = SK_SEN_TEMP_LOW_ERR;
+			pAC->I2c.SenTable[i].SenReg = LM80_TEMP_IN;
+			break;
+		case 1:
+			pAC->I2c.SenTable[i].SenDesc = "Voltage PCI";
+			pAC->I2c.SenTable[i].SenType = SK_SEN_VOLT;
+			pAC->I2c.SenTable[i].SenThreErrHigh = SK_SEN_PCI_5V_HIGH_ERR;
+			pAC->I2c.SenTable[i].SenThreWarnHigh = SK_SEN_PCI_5V_HIGH_WARN;
+			pAC->I2c.SenTable[i].SenThreWarnLow = SK_SEN_PCI_5V_LOW_WARN;
+			pAC->I2c.SenTable[i].SenThreErrLow = SK_SEN_PCI_5V_LOW_ERR;
+			pAC->I2c.SenTable[i].SenReg = LM80_VT0_IN;
+			break;
+		case 2:
+			pAC->I2c.SenTable[i].SenDesc = "Voltage PCI-IO";
+			pAC->I2c.SenTable[i].SenType = SK_SEN_VOLT;
+			pAC->I2c.SenTable[i].SenThreErrHigh = SK_SEN_PCI_IO_5V_HIGH_ERR;
+			pAC->I2c.SenTable[i].SenThreWarnHigh = SK_SEN_PCI_IO_5V_HIGH_WARN;
+			pAC->I2c.SenTable[i].SenThreWarnLow = SK_SEN_PCI_IO_3V3_LOW_WARN;
+			pAC->I2c.SenTable[i].SenThreErrLow = SK_SEN_PCI_IO_3V3_LOW_ERR;
+			pAC->I2c.SenTable[i].SenReg = LM80_VT1_IN;
+			pAC->I2c.SenTable[i].SenInit = SK_SEN_DYN_INIT_PCI_IO;
+			break;
+		case 3:
+			pAC->I2c.SenTable[i].SenDesc = "Voltage ASIC";
+			pAC->I2c.SenTable[i].SenType = SK_SEN_VOLT;
+			pAC->I2c.SenTable[i].SenThreErrHigh = SK_SEN_VDD_HIGH_ERR;
+			pAC->I2c.SenTable[i].SenThreWarnHigh = SK_SEN_VDD_HIGH_WARN;
+			pAC->I2c.SenTable[i].SenThreWarnLow = SK_SEN_VDD_LOW_WARN;
+			pAC->I2c.SenTable[i].SenThreErrLow = SK_SEN_VDD_LOW_ERR;
+			pAC->I2c.SenTable[i].SenReg = LM80_VT2_IN;
+			break;
+		case 4:
+			if (pPrt->PhyType == SK_PHY_BCOM) {
+				pAC->I2c.SenTable[i].SenDesc = "Voltage PHY A PLL";
+				pAC->I2c.SenTable[i].SenThreErrHigh = SK_SEN_PLL_3V3_HIGH_ERR;
+				pAC->I2c.SenTable[i].SenThreWarnHigh = SK_SEN_PLL_3V3_HIGH_WARN;
+				pAC->I2c.SenTable[i].SenThreWarnLow = SK_SEN_PLL_3V3_LOW_WARN;
+				pAC->I2c.SenTable[i].SenThreErrLow = SK_SEN_PLL_3V3_LOW_ERR;
+			}
+			else if (pPrt->PhyType == SK_PHY_MARV_COPPER) {
+				pAC->I2c.SenTable[i].SenDesc = "Voltage VAUX";
+				pAC->I2c.SenTable[i].SenThreErrHigh = SK_SEN_VAUX_3V3_HIGH_ERR;
+				pAC->I2c.SenTable[i].SenThreWarnHigh = SK_SEN_VAUX_3V3_HIGH_WARN;
+				if (pAC->GIni.GIVauxAvail) {
+					pAC->I2c.SenTable[i].SenThreWarnLow = SK_SEN_VAUX_3V3_LOW_WARN;
+					pAC->I2c.SenTable[i].SenThreErrLow = SK_SEN_VAUX_3V3_LOW_ERR;
+				}
+				else {
+					pAC->I2c.SenTable[i].SenThreErrLow = SK_SEN_VAUX_0V_WARN_ERR;
+					pAC->I2c.SenTable[i].SenThreWarnLow = SK_SEN_VAUX_0V_WARN_ERR;
+				}
+			}
+			else {
+				pAC->I2c.SenTable[i].SenDesc = "Voltage PMA";
+				pAC->I2c.SenTable[i].SenThreErrHigh = SK_SEN_PLL_3V3_HIGH_ERR;
+				pAC->I2c.SenTable[i].SenThreWarnHigh = SK_SEN_PLL_3V3_HIGH_WARN;
+				pAC->I2c.SenTable[i].SenThreWarnLow = SK_SEN_PLL_3V3_LOW_WARN;
+				pAC->I2c.SenTable[i].SenThreErrLow = SK_SEN_PLL_3V3_LOW_ERR;
+			}
+			pAC->I2c.SenTable[i].SenType = SK_SEN_VOLT;
+			pAC->I2c.SenTable[i].SenReg = LM80_VT3_IN;
+			break;
+		case 5:
+			if (pPrt->PhyType == SK_PHY_MARV_COPPER) {
+				pAC->I2c.SenTable[i].SenDesc = "Voltage ASIC-Co 1V5";
+				pAC->I2c.SenTable[i].SenThreErrHigh = SK_SEN_CORE_1V5_HIGH_ERR;
+				pAC->I2c.SenTable[i].SenThreWarnHigh = SK_SEN_CORE_1V5_HIGH_WARN;
+				pAC->I2c.SenTable[i].SenThreWarnLow = SK_SEN_CORE_1V5_LOW_WARN;
+				pAC->I2c.SenTable[i].SenThreErrLow = SK_SEN_CORE_1V5_LOW_ERR;
+			}
+			else {
+				pAC->I2c.SenTable[i].SenDesc = "Voltage PHY 2V5";
+				pAC->I2c.SenTable[i].SenThreErrHigh = SK_SEN_PHY_2V5_HIGH_ERR;
+				pAC->I2c.SenTable[i].SenThreWarnHigh = SK_SEN_PHY_2V5_HIGH_WARN;
+				pAC->I2c.SenTable[i].SenThreWarnLow = SK_SEN_PHY_2V5_LOW_WARN;
+				pAC->I2c.SenTable[i].SenThreErrLow = SK_SEN_PHY_2V5_LOW_ERR;
+			}
+			pAC->I2c.SenTable[i].SenType = SK_SEN_VOLT;
+			pAC->I2c.SenTable[i].SenReg = LM80_VT4_IN;
+			break;
+		case 6:
+			if (pPrt->PhyType == SK_PHY_MARV_COPPER) {
+				pAC->I2c.SenTable[i].SenDesc = "Voltage PHY 3V3";
+			}
+			else {
+				pAC->I2c.SenTable[i].SenDesc = "Voltage PHY B PLL";
+			}
+			pAC->I2c.SenTable[i].SenType = SK_SEN_VOLT;
+			pAC->I2c.SenTable[i].SenThreErrHigh = SK_SEN_PLL_3V3_HIGH_ERR;
+			pAC->I2c.SenTable[i].SenThreWarnHigh = SK_SEN_PLL_3V3_HIGH_WARN;
+			pAC->I2c.SenTable[i].SenThreWarnLow = SK_SEN_PLL_3V3_LOW_WARN;
+			pAC->I2c.SenTable[i].SenThreErrLow = SK_SEN_PLL_3V3_LOW_ERR;
+			pAC->I2c.SenTable[i].SenReg = LM80_VT5_IN;
+			break;
+		case 7:
+			if (pPrt->PhyType == SK_PHY_MARV_COPPER) {
+				pAC->I2c.SenTable[i].SenDesc = "Voltage PHY 2V5";
+				pAC->I2c.SenTable[i].SenType = SK_SEN_VOLT;
+				pAC->I2c.SenTable[i].SenThreErrHigh = SK_SEN_PHY_2V5_HIGH_ERR;
+				pAC->I2c.SenTable[i].SenThreWarnHigh = SK_SEN_PHY_2V5_HIGH_WARN;
+				pAC->I2c.SenTable[i].SenThreWarnLow = SK_SEN_PHY_2V5_LOW_WARN;
+				pAC->I2c.SenTable[i].SenThreErrLow = SK_SEN_PHY_2V5_LOW_ERR;
+				pAC->I2c.SenTable[i].SenReg = LM80_VT6_IN;
+			}
+			else {
+				pAC->I2c.SenTable[i].SenDesc = "Speed Fan";
+				pAC->I2c.SenTable[i].SenType = SK_SEN_FAN;
+				pAC->I2c.SenTable[i].SenThreErrHigh = SK_SEN_FAN_HIGH_ERR;
+				pAC->I2c.SenTable[i].SenThreWarnHigh = SK_SEN_FAN_HIGH_WARN;
+				pAC->I2c.SenTable[i].SenThreWarnLow = SK_SEN_FAN_LOW_WARN;
+				pAC->I2c.SenTable[i].SenThreErrLow = SK_SEN_FAN_LOW_ERR;
+				pAC->I2c.SenTable[i].SenReg = LM80_FAN2_IN;
+			}
+			break;
+		default:
+			SK_ERR_LOG(pAC, SK_ERRCL_INIT | SK_ERRCL_SW,
+				SKERR_I2C_E001, SKERR_I2C_E001MSG);
+			break;
+		}
+
+		pAC->I2c.SenTable[i].SenValue = 0;
+		pAC->I2c.SenTable[i].SenErrFlag = SK_SEN_ERR_OK;
+		pAC->I2c.SenTable[i].SenErrCts = 0;
+		pAC->I2c.SenTable[i].SenBegErrTS = 0;
+		pAC->I2c.SenTable[i].SenState = SK_SEN_IDLE;
+		pAC->I2c.SenTable[i].SenRead = SkLm80ReadSensor;
+		pAC->I2c.SenTable[i].SenDev = LM80_ADDR;
+	}
+
 #ifndef	SK_DIAG
 	pAC->I2c.DummyReads = pAC->I2c.MaxSens;
-
-	/* Clear the interrupt source */
-	SK_OUT32(IoC, B2_I2C_IRQ, I2C_CLR_IRQ);
 #endif	/* !SK_DIAG */
 	
+	/* Clear I2C IRQ */
+	SK_OUT32(IoC, B2_I2C_IRQ, I2C_CLR_IRQ);
+	
 	/* Now we are I/O initialized */
 	pAC->I2c.InitLevel = SK_INIT_IO;
 	return(0);
@@ -900,7 +1025,7 @@
 /*
  * Init level 2: Start first sensor read.
  */
-static	int	SkI2cInit2(
+static int SkI2cInit2(
 SK_AC	*pAC,	/* Adapter Context */
 SK_IOC	IoC)	/* I/O Context */
 {
@@ -977,13 +1102,13 @@
  *
  * Starts the timer if necessary.
  */
-void	SkI2cIsr(
+void SkI2cIsr(
 SK_AC	*pAC,	/* Adapter Context */
 SK_IOC	IoC)	/* I/O Context */
 {
 	SK_EVPARA	Para;
 
-	/* Clear the interrupt source */
+	/* Clear I2C IRQ */
 	SK_OUT32(IoC, B2_I2C_IRQ, I2C_CLR_IRQ);
 
 	Para.Para64 = 0;
@@ -994,7 +1119,7 @@
 /*
  * Check this sensors Value against the threshold and send events.
  */
-static	void	SkI2cCheckSensor(
+static void SkI2cCheckSensor(
 SK_AC		*pAC,	/* Adapter Context */
 SK_SENSOR	*pSen)
 {
@@ -1008,7 +1133,7 @@
 
 	/* Check Dummy Reads first */
 	if (pAC->I2c.DummyReads > 0) {
-		pAC->I2c.DummyReads --;
+		pAC->I2c.DummyReads--;
 		return;
 	}
 
@@ -1016,7 +1141,7 @@
 	CurrTime = SkOsGetTime(pAC);
 
 	/* Set para to the most useful setting: The current sensor. */
-	ParaLocal.Para64 = (SK_U64) pAC->I2c.CurrSens;
+	ParaLocal.Para64 = (SK_U64)pAC->I2c.CurrSens;
 
 	/* Check the Value against the thresholds. First: Error Thresholds */
 	TooHigh = (pSen->SenValue > pSen->SenThreErrHigh);
@@ -1053,9 +1178,9 @@
 				 */
 				DoErrLog = SK_FALSE;
 			}
-		} else {
-			/* We came from a different state */
-			/* -> Set Begin Time Stamp */
+		}
+		else {
+			/* We came from a different state -> Set Begin Time Stamp */
 			pSen->SenBegErrTS = CurrTime;
 			pSen->SenErrFlag = SK_SEN_ERR_ERR;
 		}
@@ -1063,7 +1188,7 @@
 		if (DoTrapSend) {
 			/* Set current Time */
 			pSen->SenLastErrTrapTS = CurrTime;
-			pSen->SenErrCts ++;
+			pSen->SenErrCts++;
 
 			/* Queue PNMI Event */
 			SkEventQueue(pAC, SKGE_PNMI, (TooHigh ?
@@ -1095,7 +1220,6 @@
 	TooHigh = (pSen->SenValue > pSen->SenThreWarnHigh);
 	TooLow = (pSen->SenValue < pSen->SenThreWarnLow);
 		
-
 	if (!IsError && (TooHigh || TooLow)) {
 		/* Error condition is satisfied */
 		DoTrapSend = SK_TRUE;
@@ -1123,9 +1247,9 @@
 				 */
 				DoErrLog = SK_FALSE;
 			}
-		} else {
-			/* We came from a different state */
-			/* -> Set Begin Time Stamp */
+		}
+		else {
+			/* We came from a different state -> Set Begin Time Stamp */
 			pSen->SenBegWarnTS = CurrTime;
 			pSen->SenErrFlag = SK_SEN_ERR_WARN;
 		}
@@ -1133,7 +1257,7 @@
 		if (DoTrapSend) {
 			/* Set current Time */
 			pSen->SenLastWarnTrapTS = CurrTime;
-			pSen->SenWarnCts ++;
+			pSen->SenWarnCts++;
 
 			/* Queue PNMI Event */
 			SkEventQueue(pAC, SKGE_PNMI, (TooHigh ?
@@ -1168,6 +1292,43 @@
 
 	/* End of check against the thresholds */
 
+	/* Bug fix AF: 16.Aug.2001: Correct the init base
+	 * of LM80 sensor.
+	 */
+	if (pSen->SenInit == SK_SEN_DYN_INIT_PCI_IO) {
+
+        pSen->SenInit = SK_SEN_DYN_INIT_NONE;
+
+		if (pSen->SenValue > SK_SEN_PCI_IO_RANGE_LIMITER) {
+			/* 5V PCI-IO Voltage */
+			pSen->SenThreWarnLow = SK_SEN_PCI_IO_5V_LOW_WARN;
+			pSen->SenThreErrLow = SK_SEN_PCI_IO_5V_LOW_ERR;
+		}
+		else {
+			/* 3.3V PCI-IO Voltage */
+			pSen->SenThreWarnHigh = SK_SEN_PCI_IO_3V3_HIGH_WARN;
+			pSen->SenThreErrHigh = SK_SEN_PCI_IO_3V3_HIGH_ERR;
+		}
+	}
+	
+#if 0
+    /* Dynamic thresholds also for VAUX of LM80 sensor */
+	if (pSen->SenInit == SK_SEN_DYN_INIT_VAUX) {
+
+        pSen->SenInit = SK_SEN_DYN_INIT_NONE;
+
+		/* 3.3V VAUX Voltage */
+		if (pSen->SenValue > SK_SEN_VAUX_RANGE_LIMITER) {
+			pSen->SenThreWarnLow = SK_SEN_VAUX_3V3_LOW_WARN;
+			pSen->SenThreErrLow = SK_SEN_VAUX_3V3_LOW_ERR;
+		}
+		/* 0V VAUX Voltage */
+		else {
+			pSen->SenThreWarnHigh = SK_SEN_VAUX_0V_WARN_ERR;
+			pSen->SenThreErrHigh = SK_SEN_VAUX_0V_WARN_ERR;
+		}
+	}
+
 	/*
 	 * Check initialization state:
 	 * The VIO Thresholds need adaption
@@ -1175,20 +1336,21 @@
 	if (!pSen->SenInit && pSen->SenReg == LM80_VT1_IN &&
 	     pSen->SenValue > SK_SEN_WARNLOW2C &&
 	     pSen->SenValue < SK_SEN_WARNHIGH2) {
-		pSen->SenThreErrLow = SK_SEN_ERRLOW2C; 
-		pSen->SenThreWarnLow = SK_SEN_WARNLOW2C; 
+		pSen->SenThreErrLow = SK_SEN_ERRLOW2C;
+		pSen->SenThreWarnLow = SK_SEN_WARNLOW2C;
 		pSen->SenInit = SK_TRUE;
 	}
 
 	if (!pSen->SenInit && pSen->SenReg == LM80_VT1_IN &&
 	     pSen->SenValue > SK_SEN_WARNLOW2 &&
 	     pSen->SenValue < SK_SEN_WARNHIGH2C) {
-		pSen->SenThreErrHigh = SK_SEN_ERRHIGH2C; 
-		pSen->SenThreWarnHigh = SK_SEN_WARNHIGH2C; 
+		pSen->SenThreErrHigh = SK_SEN_ERRHIGH2C;
+		pSen->SenThreWarnHigh = SK_SEN_WARNHIGH2C;
 		pSen->SenInit = SK_TRUE;
 	}
+#endif
 
-	if (!pSen->SenInit) {
+	if (pSen->SenInit != SK_SEN_DYN_INIT_NONE) {
 		SK_ERR_LOG(pAC, SK_ERRCL_HW, SKERR_I2C_E013, SKERR_I2C_E013MSG);
 	}
 }	/* SkI2cCheckSensor*/
@@ -1210,9 +1372,13 @@
 	SK_EVPARA	ParaLocal;
 	int			i;
 
+	/* New case: no sensors */
+	if (pAC->I2c.MaxSens == 0) {
+		return(0);
+	}
+
 	switch (Event) {
 	case SK_I2CEV_IRQ:
-	case SK_I2CEV_TIM:
 		pSen = &pAC->I2c.SenTable[pAC->I2c.CurrSens];
 		ReadComplete = SkI2cReadSensor(pAC, IoC, pSen);
 
@@ -1220,23 +1386,92 @@
 			/* Check sensor against defined thresholds */
 			SkI2cCheckSensor (pAC, pSen);
 
-			/* Increment Current and set appropriate Timeout */
-			Time = SK_I2C_TIM_SHORT;
+			/* Increment Current sensor and set appropriate Timeout */
+			pAC->I2c.CurrSens++;
+			if (pAC->I2c.CurrSens >= pAC->I2c.MaxSens) {
+				pAC->I2c.CurrSens = 0;
+				Time = SK_I2C_TIM_LONG;
+			}
+			else {
+				Time = SK_I2C_TIM_SHORT;
+			}
+
+			/* Start Timer */
+			ParaLocal.Para64 = (SK_U64)0;
 
-			pAC->I2c.CurrSens ++;
+			pAC->I2c.TimerMode = SK_TIMER_NEW_GAUGING;
+			
+			SkTimerStart(pAC, IoC, &pAC->I2c.SenTimer, Time,
+				SKGE_I2C, SK_I2CEV_TIM, ParaLocal);
+		}
+        else {
+			/* Start Timer */
+			ParaLocal.Para64 = (SK_U64)0;
+
+			pAC->I2c.TimerMode = SK_TIMER_WATCH_STATEMACHINE;
+
+            SkTimerStart(pAC, IoC, &pAC->I2c.SenTimer, SK_I2C_TIM_WATCH,
+				SKGE_I2C, SK_I2CEV_TIM, ParaLocal);
+		}
+		break;
+	case SK_I2CEV_TIM:
+		if (pAC->I2c.TimerMode == SK_TIMER_NEW_GAUGING) {
+
+			ParaLocal.Para64 = (SK_U64)0;
+			SkTimerStop(pAC, IoC, &pAC->I2c.SenTimer);
+
+			pSen = &pAC->I2c.SenTable[pAC->I2c.CurrSens];
+			ReadComplete = SkI2cReadSensor(pAC, IoC, pSen);
+
+			if (ReadComplete) {
+				/* Check sensor against defined thresholds */
+				SkI2cCheckSensor (pAC, pSen);
+
+				/* Increment Current sensor and set appropriate Timeout */
+				pAC->I2c.CurrSens++;
+				if (pAC->I2c.CurrSens == pAC->I2c.MaxSens) {
+					pAC->I2c.CurrSens = 0;
+					Time = SK_I2C_TIM_LONG;
+				}
+				else {
+					Time = SK_I2C_TIM_SHORT;
+				}
+
+				/* Start Timer */
+				ParaLocal.Para64 = (SK_U64)0;
+
+				pAC->I2c.TimerMode = SK_TIMER_NEW_GAUGING;
+
+				SkTimerStart(pAC, IoC, &pAC->I2c.SenTimer, Time,
+					SKGE_I2C, SK_I2CEV_TIM, ParaLocal);
+			}
+		}
+		else {
+			pSen = &pAC->I2c.SenTable[pAC->I2c.CurrSens];
+			pSen->SenErrFlag = SK_SEN_ERR_FAULTY;
+			SK_I2C_STOP(IoC);
+
+			/* Increment Current sensor and set appropriate Timeout */
+			pAC->I2c.CurrSens++;
 			if (pAC->I2c.CurrSens == pAC->I2c.MaxSens) {
 				pAC->I2c.CurrSens = 0;
 				Time = SK_I2C_TIM_LONG;
 			}
+			else {
+				Time = SK_I2C_TIM_SHORT;
+			}
 
 			/* Start Timer */
-			ParaLocal.Para64 = (SK_U64) 0;
+			ParaLocal.Para64 = (SK_U64)0;
+
+			pAC->I2c.TimerMode = SK_TIMER_NEW_GAUGING;
+
 			SkTimerStart(pAC, IoC, &pAC->I2c.SenTimer, Time,
 				SKGE_I2C, SK_I2CEV_TIM, ParaLocal);
 		}
 		break;
 	case SK_I2CEV_CLEAR:
-		for (i = 0; i < SK_MAX_SENSORS; i ++) {
+		for (i = 0; i < SK_MAX_SENSORS; i++) {
 			pAC->I2c.SenTable[i].SenErrFlag = SK_SEN_ERR_OK;
 			pAC->I2c.SenTable[i].SenErrCts = 0;
 			pAC->I2c.SenTable[i].SenWarnCts = 0;
@@ -1255,4 +1490,4 @@
 	return(0);
 }	/* SkI2cEvent*/
 
-#endif	/* !SK_DIAG */ 
+#endif	/* !SK_DIAG */

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)