/* * Interrupt service function for the I2C Interface * * Clears the Interrupt source * * Reads the register and check it for sending a trap. * * Starts the timer if necessary. */ void SkI2cIsr( SK_AC *pAC, /* Adapter Context */ SK_IOC IoC) /* I/O Context */ { SK_EVPARA Para; /* Clear I2C IRQ */ SK_OUT32(IoC, B2_I2C_IRQ, I2C_CLR_IRQ); Para.Para64 = 0; SkEventQueue(pAC, SKGE_I2C, SK_I2CEV_IRQ, Para); } /* SkI2cIsr */
static void timer_done( SK_AC *pAC, /* Adapters context */ SK_IOC Ioc, /* IoContext */ int Restart) /* Do we need to restart the Hardware timer ? */ { SK_U32 Delta; SK_TIMER *pTm; SK_TIMER *pTComp; /* Timer completed now now */ SK_TIMER **ppLast; /* Next field of Last timer to be deq */ int Done = 0; Delta = SkHwtRead(pAC, Ioc); ppLast = &pAC->Tim.StQueue; pTm = pAC->Tim.StQueue; while (pTm && !Done) { if (Delta >= pTm->TmDelta) { /* Timer ran out */ pTm->TmActive = SK_FALSE; Delta -= pTm->TmDelta; ppLast = &pTm->TmNext; pTm = pTm->TmNext; } else { /* We found the first timer that did not run out */ pTm->TmDelta -= Delta; Delta = 0; Done = 1; } } *ppLast = 0; /* * pTm points to the first Timer that did not run out. * StQueue points to the first Timer that run out. */ for ( pTComp = pAC->Tim.StQueue; pTComp; pTComp = pTComp->TmNext) { SkEventQueue(pAC,pTComp->TmClass, pTComp->TmEvent, pTComp->TmPara); } /* Set head of timer queue to the first timer that did not run out */ pAC->Tim.StQueue = pTm; if (Restart && pAC->Tim.StQueue) { /* Restart HW timer */ SkHwtStart(pAC, Ioc, pAC->Tim.StQueue->TmDelta); } }
/* * Check this sensors Value against the threshold and send events. */ static void SkI2cCheckSensor( SK_AC *pAC, /* Adapter Context */ SK_SENSOR *pSen) { SK_EVPARA ParaLocal; SK_BOOL TooHigh; /* Is sensor too high? */ SK_BOOL TooLow; /* Is sensor too low? */ SK_U64 CurrTime; /* Current Time */ SK_BOOL DoTrapSend; /* We need to send a trap */ SK_BOOL DoErrLog; /* We need to log the error */ SK_BOOL IsError; /* We need to log the error */ /* Check Dummy Reads first */ if (pAC->I2c.DummyReads > 0) { pAC->I2c.DummyReads--; return; } /* Get the current time */ CurrTime = SkOsGetTime(pAC); /* Set para to the most useful setting: The current sensor. */ ParaLocal.Para64 = (SK_U64)pAC->I2c.CurrSens; /* Check the Value against the thresholds. First: Error Thresholds */ TooHigh = (pSen->SenValue > pSen->SenThreErrHigh); TooLow = (pSen->SenValue < pSen->SenThreErrLow); IsError = SK_FALSE; if (TooHigh || TooLow) { /* Error condition is satisfied */ DoTrapSend = SK_TRUE; DoErrLog = SK_TRUE; /* Now error condition is satisfied */ IsError = SK_TRUE; if (pSen->SenErrFlag == SK_SEN_ERR_ERR) { /* This state is the former one */ /* So check first whether we have to send a trap */ if (pSen->SenLastErrTrapTS + SK_SEN_ERR_TR_HOLD > CurrTime) { /* * Do NOT send the Trap. The hold back time * has to run out first. */ DoTrapSend = SK_FALSE; } /* Check now whether we have to log an Error */ if (pSen->SenLastErrLogTS + SK_SEN_ERR_LOG_HOLD > CurrTime) { /* * Do NOT log the error. The hold back time * has to run out first. */ DoErrLog = SK_FALSE; } } else { /* We came from a different state -> Set Begin Time Stamp */ pSen->SenBegErrTS = CurrTime; pSen->SenErrFlag = SK_SEN_ERR_ERR; } if (DoTrapSend) { /* Set current Time */ pSen->SenLastErrTrapTS = CurrTime; pSen->SenErrCts++; /* Queue PNMI Event */ SkEventQueue(pAC, SKGE_PNMI, (TooHigh ? SK_PNMI_EVT_SEN_ERR_UPP : SK_PNMI_EVT_SEN_ERR_LOW), ParaLocal); } if (DoErrLog) { /* Set current Time */ pSen->SenLastErrLogTS = CurrTime; if (pSen->SenType == SK_SEN_TEMP) { SK_ERR_LOG(pAC, SK_ERRCL_HW, SKERR_I2C_E011, SKERR_I2C_E011MSG); } else if (pSen->SenType == SK_SEN_VOLT) { SK_ERR_LOG(pAC, SK_ERRCL_HW, SKERR_I2C_E012, SKERR_I2C_E012MSG); } else { SK_ERR_LOG(pAC, SK_ERRCL_HW, SKERR_I2C_E015, SKERR_I2C_E015MSG); } } } /* Check the Value against the thresholds */ /* 2nd: Warning thresholds */ TooHigh = (pSen->SenValue > pSen->SenThreWarnHigh); TooLow = (pSen->SenValue < pSen->SenThreWarnLow); if (!IsError && (TooHigh || TooLow)) { /* Error condition is satisfied */ DoTrapSend = SK_TRUE; DoErrLog = SK_TRUE; if (pSen->SenErrFlag == SK_SEN_ERR_WARN) { /* This state is the former one */ /* So check first whether we have to send a trap */ if (pSen->SenLastWarnTrapTS + SK_SEN_WARN_TR_HOLD > CurrTime) { /* * Do NOT send the Trap. The hold back time * has to run out first. */ DoTrapSend = SK_FALSE; } /* Check now whether we have to log an Error */ if (pSen->SenLastWarnLogTS + SK_SEN_WARN_LOG_HOLD > CurrTime) { /* * Do NOT log the error. The hold back time * has to run out first. */ DoErrLog = SK_FALSE; } } else { /* We came from a different state -> Set Begin Time Stamp */ pSen->SenBegWarnTS = CurrTime; pSen->SenErrFlag = SK_SEN_ERR_WARN; } if (DoTrapSend) { /* Set current Time */ pSen->SenLastWarnTrapTS = CurrTime; pSen->SenWarnCts++; /* Queue PNMI Event */ SkEventQueue(pAC, SKGE_PNMI, (TooHigh ? SK_PNMI_EVT_SEN_WAR_UPP : SK_PNMI_EVT_SEN_WAR_LOW), ParaLocal); } if (DoErrLog) { /* Set current Time */ pSen->SenLastWarnLogTS = CurrTime; if (pSen->SenType == SK_SEN_TEMP) { SK_ERR_LOG(pAC, SK_ERRCL_HW, SKERR_I2C_E009, SKERR_I2C_E009MSG); } else if (pSen->SenType == SK_SEN_VOLT) { SK_ERR_LOG(pAC, SK_ERRCL_HW, SKERR_I2C_E010, SKERR_I2C_E010MSG); } else { SK_ERR_LOG(pAC, SK_ERRCL_HW, SKERR_I2C_E014, SKERR_I2C_E014MSG); } } } /* Check for NO error at all */ if (!IsError && !TooHigh && !TooLow) { /* Set o.k. Status if no error and no warning condition */ pSen->SenErrFlag = SK_SEN_ERR_OK; } /* 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; } } #ifdef TEST_ONLY /* 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 */ 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->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->SenInit = SK_TRUE; } #endif if (pSen->SenInit != SK_SEN_DYN_INIT_NONE) { SK_ERR_LOG(pAC, SK_ERRCL_HW, SKERR_I2C_E013, SKERR_I2C_E013MSG); } } /* SkI2cCheckSensor */