]> git.ipfire.org Git - people/ms/u-boot.git/blob - drivers/net/sk98lin/h/ski2c.h
85xx: Drop FIT support to allow u-boot image to fit in 512k
[people/ms/u-boot.git] / drivers / net / sk98lin / h / ski2c.h
1 /******************************************************************************
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
150 typedef 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 #undef I2C_READ /* just in case */
165 #undef I2C_WRITE /* just in case */
166 #define I2C_READ 0
167 #define I2C_WRITE 1
168 #define I2C_BURST 1
169 #define I2C_SINGLE 0
170
171 #define SKERR_I2C_E001 (SK_ERRBASE_I2C+0)
172 #define SKERR_I2C_E001MSG "Sensor index unknown"
173 #define SKERR_I2C_E002 (SKERR_I2C_E001+1)
174 #define SKERR_I2C_E002MSG "TWSI: transfer does not complete"
175 #define SKERR_I2C_E003 (SKERR_I2C_E002+1)
176 #define SKERR_I2C_E003MSG "LM80: NAK on device send"
177 #define SKERR_I2C_E004 (SKERR_I2C_E003+1)
178 #define SKERR_I2C_E004MSG "LM80: NAK on register send"
179 #define SKERR_I2C_E005 (SKERR_I2C_E004+1)
180 #define SKERR_I2C_E005MSG "LM80: NAK on device (2) send"
181 #define SKERR_I2C_E006 (SKERR_I2C_E005+1)
182 #define SKERR_I2C_E006MSG "Unknown event"
183 #define SKERR_I2C_E007 (SKERR_I2C_E006+1)
184 #define SKERR_I2C_E007MSG "LM80 read out of state"
185 #define SKERR_I2C_E008 (SKERR_I2C_E007+1)
186 #define SKERR_I2C_E008MSG "Unexpected sensor read completed"
187 #define SKERR_I2C_E009 (SKERR_I2C_E008+1)
188 #define SKERR_I2C_E009MSG "WARNING: temperature sensor out of range"
189 #define SKERR_I2C_E010 (SKERR_I2C_E009+1)
190 #define SKERR_I2C_E010MSG "WARNING: voltage sensor out of range"
191 #define SKERR_I2C_E011 (SKERR_I2C_E010+1)
192 #define SKERR_I2C_E011MSG "ERROR: temperature sensor out of range"
193 #define SKERR_I2C_E012 (SKERR_I2C_E011+1)
194 #define SKERR_I2C_E012MSG "ERROR: voltage sensor out of range"
195 #define SKERR_I2C_E013 (SKERR_I2C_E012+1)
196 #define SKERR_I2C_E013MSG "ERROR: couldn't init sensor"
197 #define SKERR_I2C_E014 (SKERR_I2C_E013+1)
198 #define SKERR_I2C_E014MSG "WARNING: fan sensor out of range"
199 #define SKERR_I2C_E015 (SKERR_I2C_E014+1)
200 #define SKERR_I2C_E015MSG "ERROR: fan sensor out of range"
201 #define SKERR_I2C_E016 (SKERR_I2C_E015+1)
202 #define SKERR_I2C_E016MSG "TWSI: active transfer does not complete"
203
204 /*
205 * Define Timeout values
206 */
207 #define SK_I2C_TIM_LONG 2000000L /* 2 seconds */
208 #define SK_I2C_TIM_SHORT 100000L /* 100 milliseconds */
209 #define SK_I2C_TIM_WATCH 1000000L /* 1 second */
210
211 /*
212 * Define trap and error log hold times
213 */
214 #ifndef SK_SEN_ERR_TR_HOLD
215 #define SK_SEN_ERR_TR_HOLD (4*SK_TICKS_PER_SEC)
216 #endif
217 #ifndef SK_SEN_ERR_LOG_HOLD
218 #define SK_SEN_ERR_LOG_HOLD (60*SK_TICKS_PER_SEC)
219 #endif
220 #ifndef SK_SEN_WARN_TR_HOLD
221 #define SK_SEN_WARN_TR_HOLD (15*SK_TICKS_PER_SEC)
222 #endif
223 #ifndef SK_SEN_WARN_LOG_HOLD
224 #define SK_SEN_WARN_LOG_HOLD (15*60*SK_TICKS_PER_SEC)
225 #endif
226
227 /*
228 * Defines for SenType
229 */
230 #define SK_SEN_UNKNOWN 0
231 #define SK_SEN_TEMP 1
232 #define SK_SEN_VOLT 2
233 #define SK_SEN_FAN 3
234
235 /*
236 * Define for the SenErrorFlag
237 */
238 #define SK_SEN_ERR_NOT_PRESENT 0 /* Error Flag: Sensor not present */
239 #define SK_SEN_ERR_OK 1 /* Error Flag: O.K. */
240 #define SK_SEN_ERR_WARN 2 /* Error Flag: Warning */
241 #define SK_SEN_ERR_ERR 3 /* Error Flag: Error */
242 #define SK_SEN_ERR_FAULTY 4 /* Error Flag: Faulty */
243
244 /*
245 * Define the Sensor struct
246 */
247 struct s_Sensor {
248 char *SenDesc; /* Description */
249 int SenType; /* Voltage or Temperature */
250 SK_I32 SenValue; /* Current value of the sensor */
251 SK_I32 SenThreErrHigh; /* High error Threshhold of this sensor */
252 SK_I32 SenThreWarnHigh; /* High warning Threshhold of this sensor */
253 SK_I32 SenThreErrLow; /* Lower error Threshold of the sensor */
254 SK_I32 SenThreWarnLow; /* Lower warning Threshold of the sensor */
255 int SenErrFlag; /* Sensor indicated an error */
256 SK_BOOL SenInit; /* Is sensor initialized ? */
257 SK_U64 SenErrCts; /* Error trap counter */
258 SK_U64 SenWarnCts; /* Warning trap counter */
259 SK_U64 SenBegErrTS; /* Begin error timestamp */
260 SK_U64 SenBegWarnTS; /* Begin warning timestamp */
261 SK_U64 SenLastErrTrapTS; /* Last error trap timestamp */
262 SK_U64 SenLastErrLogTS; /* Last error log timestamp */
263 SK_U64 SenLastWarnTrapTS; /* Last warning trap timestamp */
264 SK_U64 SenLastWarnLogTS; /* Last warning log timestamp */
265 int SenState; /* Sensor State (see HW specific include) */
266 int (*SenRead)(SK_AC *pAC, SK_IOC IoC, struct s_Sensor *pSen);
267 /* Sensors read function */
268 SK_U16 SenReg; /* Register Address for this sensor */
269 SK_U8 SenDev; /* Device Selection for this sensor */
270 };
271
272 typedef struct s_I2c {
273 SK_SENSOR SenTable[SK_MAX_SENSORS]; /* Sensor Table */
274 int CurrSens; /* Which sensor is currently queried */
275 int MaxSens; /* Max. number of sensors */
276 int TimerMode; /* Use the timer also to watch the state machine */
277 int InitLevel; /* Initialized Level */
278 #ifndef SK_DIAG
279 int DummyReads; /* Number of non-checked dummy reads */
280 SK_TIMER SenTimer; /* Sensors timer */
281 #endif /* !SK_DIAG */
282 } SK_I2C;
283
284 extern int SkI2cReadSensor(SK_AC *pAC, SK_IOC IoC, SK_SENSOR *pSen);
285 #ifndef SK_DIAG
286 extern int SkI2cEvent(SK_AC *pAC, SK_IOC IoC, SK_U32 Event, SK_EVPARA Para);
287 extern int SkI2cInit(SK_AC *pAC, SK_IOC IoC, int Level);
288 extern void SkI2cWaitIrq(SK_AC *pAC, SK_IOC IoC);
289 extern void SkI2cIsr(SK_AC *pAC, SK_IOC IoC);
290
291 #endif
292 #endif /* n_SKI2C_H */