blob: db2d4e65caf862b9722a83fb104bf49a89e28ed1 [file] [log] [blame]
wdenk7152b1d2003-09-05 23:19:14 +00001/******************************************************************************
2 *
3 * Name: ski2c.h
4 * Project: GEnesis, PCI Gigabit Ethernet Adapter
5 * Version: $Revision: 1.34 $
6 * Date: $Date: 2003/01/28 09:11:21 $
7 * Purpose: Defines to access Voltage and Temperature Sensor
8 *
9 ******************************************************************************/
10
11/******************************************************************************
12 *
13 * (C)Copyright 1998-2003 SysKonnect GmbH.
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/******************************************************************************
25 *
26 * History:
27 *
28 * $Log: ski2c.h,v $
29 * Revision 1.34 2003/01/28 09:11:21 rschmidt
30 * Editorial changes
31 *
32 * Revision 1.33 2002/10/14 16:40:50 rschmidt
33 * Editorial changes (TWSI)
34 *
35 * Revision 1.32 2002/08/13 08:55:07 rschmidt
36 * Editorial changes
37 *
38 * Revision 1.31 2002/08/06 09:44:22 jschmalz
39 * Extensions and changes for Yukon
40 *
41 * Revision 1.30 2001/04/05 11:38:09 rassmann
42 * Set SenState to idle in SkI2cWaitIrq().
43 * Changed error message in SkI2cWaitIrq().
44 *
45 * Revision 1.29 2000/08/03 14:28:17 rassmann
46 * - Added function to wait for I2C being ready before resetting the board.
47 * - Replaced one duplicate "out of range" message with correct one.
48 *
49 * Revision 1.28 1999/11/22 13:55:46 cgoos
50 * Changed license header to GPL.
51 *
52 * Revision 1.27 1999/05/20 09:23:10 cgoos
53 * Changes for 1000Base-T (Fan sensors).
54 *
55 * Revision 1.26 1998/12/01 13:45:47 gklug
56 * add: InitLevel to I2c struct
57 *
58 * Revision 1.25 1998/11/03 06:55:16 gklug
59 * add: Dummy Reads to I2c struct
60 *
61 * Revision 1.24 1998/10/02 14:28:59 cgoos
62 * Added prototype for SkI2cIsr.
63 *
64 * Revision 1.23 1998/09/08 12:20:11 gklug
65 * add: prototypes for init and read functions
66 *
67 * Revision 1.22 1998/09/08 07:37:56 gklug
68 * add: log error if PCI_IO voltage sensor could not be initialized
69 *
70 * Revision 1.21 1998/09/04 08:38:05 malthoff
71 * Change the values for I2C_READ and I2C_WRITE
72 *
73 * Revision 1.20 1998/08/25 07:52:22 gklug
74 * chg: Timestamps (last) added for logging
75 *
76 * Revision 1.19 1998/08/25 06:09:00 gklug
77 * rmv: warning and error levels of the individual sensors.
78 * add: timing definitions for sending traps and logging errors
79 *
80 * Revision 1.18 1998/08/20 11:41:15 gklug
81 * chg: omit STRCPY macro by using char * as Sensor Description
82 *
83 * Revision 1.17 1998/08/20 11:37:43 gklug
84 * chg: change Ioc to IoC
85 *
86 * Revision 1.16 1998/08/20 11:30:38 gklug
87 * fix: SenRead declaration
88 *
89 * Revision 1.15 1998/08/20 11:27:53 gklug
90 * fix: Compile bugs with new awrning constants
91 *
92 * Revision 1.14 1998/08/20 08:53:12 gklug
93 * fix: compiler errors
94 * add: Threshold values
95 *
96 * Revision 1.13 1998/08/19 12:21:16 gklug
97 * fix: remove struct from C files (see CCC)
98 * add: typedefs for all structs
99 *
100 * Revision 1.12 1998/08/19 10:57:41 gklug
101 * add: Warning levels
102 *
103 * Revision 1.11 1998/08/18 08:37:02 malthoff
104 * Prototypes not required for SK_DIAG.
105 *
106 * Revision 1.10 1998/08/17 13:54:00 gklug
107 * fix: declaration of event function
108 *
109 * Revision 1.9 1998/08/17 06:48:39 malthoff
110 * Remove some unrequired macros.
111 * Fix the compiler errors.
112 *
113 * Revision 1.8 1998/08/14 06:47:19 gklug
114 * fix: Values are intergers
115 *
116 * Revision 1.7 1998/08/14 06:26:05 gklug
117 * add: Init error message
118 *
119 * Revision 1.6 1998/08/13 08:31:08 gklug
120 * add: Error message
121 *
122 * Revision 1.5 1998/08/12 14:32:04 gklug
123 * add: new error code/message
124 *
125 * Revision 1.4 1998/08/12 13:39:08 gklug
126 * chg: names of error messages
127 * add: defines for Sensor type and thresholds
128 *
129 * Revision 1.3 1998/08/11 07:57:16 gklug
130 * add: sensor struct
131 * add: Timeout defines
132 * add: I2C control struct for pAC
133 *
134 * Revision 1.2 1998/07/17 11:29:02 gklug
135 * rmv: Microwire and SMTPANIC
136 *
137 * Revision 1.1 1998/06/19 14:30:10 malthoff
138 * Created. Sources taken from ML Project.
139 *
140 *
141 ******************************************************************************/
142
143/*
144 * SKI2C.H contains all I2C specific defines
145 */
146
147#ifndef _SKI2C_H_
148#define _SKI2C_H_
149
150typedef struct s_Sensor SK_SENSOR;
151
152#include "h/skgei2c.h"
153
154/*
155 * Define the I2C events.
156 */
157#define SK_I2CEV_IRQ 1 /* IRQ happened Event */
158#define SK_I2CEV_TIM 2 /* Timeout event */
159#define SK_I2CEV_CLEAR 3 /* Clear MIB Values */
160
161/*
162 * Define READ and WRITE Constants.
163 */
164#define I2C_READ 0
165#define I2C_WRITE 1
166#define I2C_BURST 1
167#define I2C_SINGLE 0
168
169#define SKERR_I2C_E001 (SK_ERRBASE_I2C+0)
170#define SKERR_I2C_E001MSG "Sensor index unknown"
171#define SKERR_I2C_E002 (SKERR_I2C_E001+1)
172#define SKERR_I2C_E002MSG "TWSI: transfer does not complete"
173#define SKERR_I2C_E003 (SKERR_I2C_E002+1)
174#define SKERR_I2C_E003MSG "LM80: NAK on device send"
175#define SKERR_I2C_E004 (SKERR_I2C_E003+1)
176#define SKERR_I2C_E004MSG "LM80: NAK on register send"
177#define SKERR_I2C_E005 (SKERR_I2C_E004+1)
178#define SKERR_I2C_E005MSG "LM80: NAK on device (2) send"
179#define SKERR_I2C_E006 (SKERR_I2C_E005+1)
180#define SKERR_I2C_E006MSG "Unknown event"
181#define SKERR_I2C_E007 (SKERR_I2C_E006+1)
182#define SKERR_I2C_E007MSG "LM80 read out of state"
183#define SKERR_I2C_E008 (SKERR_I2C_E007+1)
184#define SKERR_I2C_E008MSG "Unexpected sensor read completed"
185#define SKERR_I2C_E009 (SKERR_I2C_E008+1)
186#define SKERR_I2C_E009MSG "WARNING: temperature sensor out of range"
187#define SKERR_I2C_E010 (SKERR_I2C_E009+1)
188#define SKERR_I2C_E010MSG "WARNING: voltage sensor out of range"
189#define SKERR_I2C_E011 (SKERR_I2C_E010+1)
190#define SKERR_I2C_E011MSG "ERROR: temperature sensor out of range"
191#define SKERR_I2C_E012 (SKERR_I2C_E011+1)
192#define SKERR_I2C_E012MSG "ERROR: voltage sensor out of range"
193#define SKERR_I2C_E013 (SKERR_I2C_E012+1)
194#define SKERR_I2C_E013MSG "ERROR: couldn't init sensor"
195#define SKERR_I2C_E014 (SKERR_I2C_E013+1)
196#define SKERR_I2C_E014MSG "WARNING: fan sensor out of range"
197#define SKERR_I2C_E015 (SKERR_I2C_E014+1)
198#define SKERR_I2C_E015MSG "ERROR: fan sensor out of range"
199#define SKERR_I2C_E016 (SKERR_I2C_E015+1)
200#define SKERR_I2C_E016MSG "TWSI: active transfer does not complete"
201
202/*
203 * Define Timeout values
204 */
205#define SK_I2C_TIM_LONG 2000000L /* 2 seconds */
206#define SK_I2C_TIM_SHORT 100000L /* 100 milliseconds */
207#define SK_I2C_TIM_WATCH 1000000L /* 1 second */
208
209/*
210 * Define trap and error log hold times
211 */
212#ifndef SK_SEN_ERR_TR_HOLD
213#define SK_SEN_ERR_TR_HOLD (4*SK_TICKS_PER_SEC)
214#endif
215#ifndef SK_SEN_ERR_LOG_HOLD
216#define SK_SEN_ERR_LOG_HOLD (60*SK_TICKS_PER_SEC)
217#endif
218#ifndef SK_SEN_WARN_TR_HOLD
219#define SK_SEN_WARN_TR_HOLD (15*SK_TICKS_PER_SEC)
220#endif
221#ifndef SK_SEN_WARN_LOG_HOLD
222#define SK_SEN_WARN_LOG_HOLD (15*60*SK_TICKS_PER_SEC)
223#endif
224
225/*
226 * Defines for SenType
227 */
228#define SK_SEN_UNKNOWN 0
229#define SK_SEN_TEMP 1
230#define SK_SEN_VOLT 2
231#define SK_SEN_FAN 3
232
233/*
234 * Define for the SenErrorFlag
235 */
236#define SK_SEN_ERR_NOT_PRESENT 0 /* Error Flag: Sensor not present */
237#define SK_SEN_ERR_OK 1 /* Error Flag: O.K. */
238#define SK_SEN_ERR_WARN 2 /* Error Flag: Warning */
239#define SK_SEN_ERR_ERR 3 /* Error Flag: Error */
240#define SK_SEN_ERR_FAULTY 4 /* Error Flag: Faulty */
241
242/*
243 * Define the Sensor struct
244 */
245struct s_Sensor {
246 char *SenDesc; /* Description */
247 int SenType; /* Voltage or Temperature */
248 SK_I32 SenValue; /* Current value of the sensor */
249 SK_I32 SenThreErrHigh; /* High error Threshhold of this sensor */
250 SK_I32 SenThreWarnHigh; /* High warning Threshhold of this sensor */
251 SK_I32 SenThreErrLow; /* Lower error Threshold of the sensor */
252 SK_I32 SenThreWarnLow; /* Lower warning Threshold of the sensor */
253 int SenErrFlag; /* Sensor indicated an error */
254 SK_BOOL SenInit; /* Is sensor initialized ? */
255 SK_U64 SenErrCts; /* Error trap counter */
256 SK_U64 SenWarnCts; /* Warning trap counter */
257 SK_U64 SenBegErrTS; /* Begin error timestamp */
258 SK_U64 SenBegWarnTS; /* Begin warning timestamp */
259 SK_U64 SenLastErrTrapTS; /* Last error trap timestamp */
260 SK_U64 SenLastErrLogTS; /* Last error log timestamp */
261 SK_U64 SenLastWarnTrapTS; /* Last warning trap timestamp */
262 SK_U64 SenLastWarnLogTS; /* Last warning log timestamp */
263 int SenState; /* Sensor State (see HW specific include) */
264 int (*SenRead)(SK_AC *pAC, SK_IOC IoC, struct s_Sensor *pSen);
265 /* Sensors read function */
266 SK_U16 SenReg; /* Register Address for this sensor */
267 SK_U8 SenDev; /* Device Selection for this sensor */
268};
269
270typedef struct s_I2c {
271 SK_SENSOR SenTable[SK_MAX_SENSORS]; /* Sensor Table */
272 int CurrSens; /* Which sensor is currently queried */
273 int MaxSens; /* Max. number of sensors */
274 int TimerMode; /* Use the timer also to watch the state machine */
275 int InitLevel; /* Initialized Level */
276#ifndef SK_DIAG
277 int DummyReads; /* Number of non-checked dummy reads */
278 SK_TIMER SenTimer; /* Sensors timer */
279#endif /* !SK_DIAG */
280} SK_I2C;
281
282extern int SkI2cReadSensor(SK_AC *pAC, SK_IOC IoC, SK_SENSOR *pSen);
283#ifndef SK_DIAG
284extern int SkI2cEvent(SK_AC *pAC, SK_IOC IoC, SK_U32 Event, SK_EVPARA Para);
285extern int SkI2cInit(SK_AC *pAC, SK_IOC IoC, int Level);
286extern void SkI2cWaitIrq(SK_AC *pAC, SK_IOC IoC);
287extern void SkI2cIsr(SK_AC *pAC, SK_IOC IoC);
288
289#endif
290#endif /* n_SKI2C_H */
291