ski2c.h 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. /******************************************************************************
  2. *
  3. * Name: ski2c.h
  4. * Project: Gigabit Ethernet Adapters, TWSI-Module
  5. * Version: $Revision: 1.35 $
  6. * Date: $Date: 2003/10/20 09:06:30 $
  7. * Purpose: Defines to access Voltage and Temperature Sensor
  8. *
  9. ******************************************************************************/
  10. /******************************************************************************
  11. *
  12. * (C)Copyright 1998-2002 SysKonnect.
  13. * (C)Copyright 2002-2003 Marvell.
  14. *
  15. * This program is free software; you can redistribute it and/or modify
  16. * it under the terms of the GNU General Public License as published by
  17. * the Free Software Foundation; either version 2 of the License, or
  18. * (at your option) any later version.
  19. *
  20. * The information in this file is provided "AS IS" without warranty.
  21. *
  22. ******************************************************************************/
  23. /*
  24. * SKI2C.H contains all I2C specific defines
  25. */
  26. #ifndef _SKI2C_H_
  27. #define _SKI2C_H_
  28. typedef struct s_Sensor SK_SENSOR;
  29. #include "h/skgei2c.h"
  30. /*
  31. * Define the I2C events.
  32. */
  33. #define SK_I2CEV_IRQ 1 /* IRQ happened Event */
  34. #define SK_I2CEV_TIM 2 /* Timeout event */
  35. #define SK_I2CEV_CLEAR 3 /* Clear MIB Values */
  36. /*
  37. * Define READ and WRITE Constants.
  38. */
  39. #define I2C_READ 0
  40. #define I2C_WRITE 1
  41. #define I2C_BURST 1
  42. #define I2C_SINGLE 0
  43. #define SKERR_I2C_E001 (SK_ERRBASE_I2C+0)
  44. #define SKERR_I2C_E001MSG "Sensor index unknown"
  45. #define SKERR_I2C_E002 (SKERR_I2C_E001+1)
  46. #define SKERR_I2C_E002MSG "TWSI: transfer does not complete"
  47. #define SKERR_I2C_E003 (SKERR_I2C_E002+1)
  48. #define SKERR_I2C_E003MSG "LM80: NAK on device send"
  49. #define SKERR_I2C_E004 (SKERR_I2C_E003+1)
  50. #define SKERR_I2C_E004MSG "LM80: NAK on register send"
  51. #define SKERR_I2C_E005 (SKERR_I2C_E004+1)
  52. #define SKERR_I2C_E005MSG "LM80: NAK on device (2) send"
  53. #define SKERR_I2C_E006 (SKERR_I2C_E005+1)
  54. #define SKERR_I2C_E006MSG "Unknown event"
  55. #define SKERR_I2C_E007 (SKERR_I2C_E006+1)
  56. #define SKERR_I2C_E007MSG "LM80 read out of state"
  57. #define SKERR_I2C_E008 (SKERR_I2C_E007+1)
  58. #define SKERR_I2C_E008MSG "Unexpected sensor read completed"
  59. #define SKERR_I2C_E009 (SKERR_I2C_E008+1)
  60. #define SKERR_I2C_E009MSG "WARNING: temperature sensor out of range"
  61. #define SKERR_I2C_E010 (SKERR_I2C_E009+1)
  62. #define SKERR_I2C_E010MSG "WARNING: voltage sensor out of range"
  63. #define SKERR_I2C_E011 (SKERR_I2C_E010+1)
  64. #define SKERR_I2C_E011MSG "ERROR: temperature sensor out of range"
  65. #define SKERR_I2C_E012 (SKERR_I2C_E011+1)
  66. #define SKERR_I2C_E012MSG "ERROR: voltage sensor out of range"
  67. #define SKERR_I2C_E013 (SKERR_I2C_E012+1)
  68. #define SKERR_I2C_E013MSG "ERROR: couldn't init sensor"
  69. #define SKERR_I2C_E014 (SKERR_I2C_E013+1)
  70. #define SKERR_I2C_E014MSG "WARNING: fan sensor out of range"
  71. #define SKERR_I2C_E015 (SKERR_I2C_E014+1)
  72. #define SKERR_I2C_E015MSG "ERROR: fan sensor out of range"
  73. #define SKERR_I2C_E016 (SKERR_I2C_E015+1)
  74. #define SKERR_I2C_E016MSG "TWSI: active transfer does not complete"
  75. /*
  76. * Define Timeout values
  77. */
  78. #define SK_I2C_TIM_LONG 2000000L /* 2 seconds */
  79. #define SK_I2C_TIM_SHORT 100000L /* 100 milliseconds */
  80. #define SK_I2C_TIM_WATCH 1000000L /* 1 second */
  81. /*
  82. * Define trap and error log hold times
  83. */
  84. #ifndef SK_SEN_ERR_TR_HOLD
  85. #define SK_SEN_ERR_TR_HOLD (4*SK_TICKS_PER_SEC)
  86. #endif
  87. #ifndef SK_SEN_ERR_LOG_HOLD
  88. #define SK_SEN_ERR_LOG_HOLD (60*SK_TICKS_PER_SEC)
  89. #endif
  90. #ifndef SK_SEN_WARN_TR_HOLD
  91. #define SK_SEN_WARN_TR_HOLD (15*SK_TICKS_PER_SEC)
  92. #endif
  93. #ifndef SK_SEN_WARN_LOG_HOLD
  94. #define SK_SEN_WARN_LOG_HOLD (15*60*SK_TICKS_PER_SEC)
  95. #endif
  96. /*
  97. * Defines for SenType
  98. */
  99. #define SK_SEN_UNKNOWN 0
  100. #define SK_SEN_TEMP 1
  101. #define SK_SEN_VOLT 2
  102. #define SK_SEN_FAN 3
  103. /*
  104. * Define for the SenErrorFlag
  105. */
  106. #define SK_SEN_ERR_NOT_PRESENT 0 /* Error Flag: Sensor not present */
  107. #define SK_SEN_ERR_OK 1 /* Error Flag: O.K. */
  108. #define SK_SEN_ERR_WARN 2 /* Error Flag: Warning */
  109. #define SK_SEN_ERR_ERR 3 /* Error Flag: Error */
  110. #define SK_SEN_ERR_FAULTY 4 /* Error Flag: Faulty */
  111. /*
  112. * Define the Sensor struct
  113. */
  114. struct s_Sensor {
  115. char *SenDesc; /* Description */
  116. int SenType; /* Voltage or Temperature */
  117. SK_I32 SenValue; /* Current value of the sensor */
  118. SK_I32 SenThreErrHigh; /* High error Threshhold of this sensor */
  119. SK_I32 SenThreWarnHigh; /* High warning Threshhold of this sensor */
  120. SK_I32 SenThreErrLow; /* Lower error Threshold of the sensor */
  121. SK_I32 SenThreWarnLow; /* Lower warning Threshold of the sensor */
  122. int SenErrFlag; /* Sensor indicated an error */
  123. SK_BOOL SenInit; /* Is sensor initialized ? */
  124. SK_U64 SenErrCts; /* Error trap counter */
  125. SK_U64 SenWarnCts; /* Warning trap counter */
  126. SK_U64 SenBegErrTS; /* Begin error timestamp */
  127. SK_U64 SenBegWarnTS; /* Begin warning timestamp */
  128. SK_U64 SenLastErrTrapTS; /* Last error trap timestamp */
  129. SK_U64 SenLastErrLogTS; /* Last error log timestamp */
  130. SK_U64 SenLastWarnTrapTS; /* Last warning trap timestamp */
  131. SK_U64 SenLastWarnLogTS; /* Last warning log timestamp */
  132. int SenState; /* Sensor State (see HW specific include) */
  133. int (*SenRead)(SK_AC *pAC, SK_IOC IoC, struct s_Sensor *pSen);
  134. /* Sensors read function */
  135. SK_U16 SenReg; /* Register Address for this sensor */
  136. SK_U8 SenDev; /* Device Selection for this sensor */
  137. };
  138. typedef struct s_I2c {
  139. SK_SENSOR SenTable[SK_MAX_SENSORS]; /* Sensor Table */
  140. int CurrSens; /* Which sensor is currently queried */
  141. int MaxSens; /* Max. number of sensors */
  142. int TimerMode; /* Use the timer also to watch the state machine */
  143. int InitLevel; /* Initialized Level */
  144. #ifndef SK_DIAG
  145. int DummyReads; /* Number of non-checked dummy reads */
  146. SK_TIMER SenTimer; /* Sensors timer */
  147. #endif /* !SK_DIAG */
  148. } SK_I2C;
  149. extern int SkI2cInit(SK_AC *pAC, SK_IOC IoC, int Level);
  150. #ifdef SK_DIAG
  151. extern SK_U32 SkI2cRead(SK_AC *pAC, SK_IOC IoC, int Dev, int Size, int Reg,
  152. int Burst);
  153. #else /* !SK_DIAG */
  154. extern int SkI2cEvent(SK_AC *pAC, SK_IOC IoC, SK_U32 Event, SK_EVPARA Para);
  155. extern void SkI2cWaitIrq(SK_AC *pAC, SK_IOC IoC);
  156. extern void SkI2cIsr(SK_AC *pAC, SK_IOC IoC);
  157. #endif /* !SK_DIAG */
  158. #endif /* n_SKI2C_H */