beaf7e15a63b6f2e231161c607f2795bf614ce35
[linux-flexiantxendom0-3.2.10.git] / drivers / net / sk98lin / h / skgei2c.h
1 /******************************************************************************
2  *
3  * Name:        skgei2c.h
4  * Project:     GEnesis, PCI Gigabit Ethernet Adapter
5  * Version:     $Revision: 1.17 $
6  * Date:        $Date: 1999/11/22 13:55:25 $
7  * Purpose:     Special genesis defines for I2C
8  *              (taken from Monalisa (taken from Concentrator))
9  *
10  ******************************************************************************/
11
12 /******************************************************************************
13  *
14  *      (C)Copyright 1998,1999 SysKonnect,
15  *      a business unit of Schneider & Koch & Co. Datensysteme GmbH.
16  *
17  *      This program is free software; you can redistribute it and/or modify
18  *      it under the terms of the GNU General Public License as published by
19  *      the Free Software Foundation; either version 2 of the License, or
20  *      (at your option) any later version.
21  *
22  *      The information in this file is provided "AS IS" without warranty.
23  *
24  ******************************************************************************/
25
26 /******************************************************************************
27  *
28  * History:
29  *
30  *      $Log: skgei2c.h,v $
31  *      Revision 1.17  1999/11/22 13:55:25  cgoos
32  *      Changed license header to GPL.
33  *      
34  *      Revision 1.16  1999/11/12 08:24:10  malthoff
35  *      Change voltage warning and error limits
36  *      (warning +-5%, error +-10%).
37  *      
38  *      Revision 1.15  1999/09/14 14:14:43  malthoff
39  *      The 1000BT Dual Link adapter has got only one Fan.
40  *      The second Fan has been removed.
41  *      
42  *      Revision 1.14  1999/05/27 13:40:50  malthoff
43  *      Fan Divisor = 1. Assuming fan with 6500 rpm.
44  *      
45  *      Revision 1.13  1999/05/20 14:56:55  malthoff
46  *      Bug Fix: Missing brace in SK_LM80_FAN_FAKTOR.
47  *      
48  *      Revision 1.12  1999/05/20 09:22:00  cgoos
49  *      Changes for 1000Base-T (Fan sensors).
50  *      
51  *      Revision 1.11  1998/10/14 05:57:22  cgoos
52  *      Fixed compilation warnings.
53  *      
54  *      Revision 1.10  1998/09/04 08:37:00  malthoff
55  *      bugfix: correct the SK_I2C_GET_CTL() macro.
56  *      
57  *      Revision 1.9  1998/08/25 06:10:03  gklug
58  *      add: thresholds for all sensors
59  *
60  *      Revision 1.8  1998/08/20 11:37:42  gklug
61  *      chg: change Ioc to IoC
62  *      
63  *      Revision 1.7  1998/08/20 08:53:11  gklug
64  *      fix: compiler errors
65  *      add: Threshold values
66  *      
67  *      Revision 1.6  1998/08/17 11:37:09  malthoff
68  *      Bugfix in SK_I2C_CTL macro. The parameter 'dev'
69  *      has to be shifted 9 bits.
70  *      
71  *      Revision 1.5  1998/08/17 06:52:21  malthoff
72  *      Remove unrequired macros.
73  *      Add macros for accessing I2C SW register.
74  *      
75  *      Revision 1.4  1998/08/13 08:30:18  gklug
76  *      add: conversion factors for read values
77  *      add: new state SEN_VALEXT to read extension value of temperature sensor
78  *
79  *      Revision 1.3  1998/08/12 13:37:56  gklug
80  *      rmv: error numbers and messages
81  *
82  *      Revision 1.2  1998/08/11 07:54:38  gklug
83  *      add: sensor states for GE sensors
84  *      add: Macro to access I2c hardware register
85  *      chg: Error messages for I2c errors
86  *
87  *      Revision 1.1  1998/07/17 11:27:56  gklug
88  *      Created.
89  *
90  *
91  *
92  ******************************************************************************/
93
94 /*
95  * SKGEI2C.H    contains all SK-98xx specific defines for the I2C handling
96  */
97
98 #ifndef _INC_SKGEI2C_H_
99 #define _INC_SKGEI2C_H_
100
101 /*
102  * Macros to access the B2_I2C_CTRL
103  */
104 #define SK_I2C_CTL(IoC,flag,dev,reg,burst) \
105         SK_OUT32(IoC,B2_I2C_CTRL,\
106                 (flag ? 0x80000000UL : 0x0L ) | \
107                 (((SK_U32) reg << 16) & I2C_ADDR) | \
108                 (((SK_U32) dev << 9) & I2C_DEV_SEL) | \
109                 (( burst << 4) & I2C_BURST_LEN) )
110
111 #define SK_I2C_STOP(IoC) {                              \
112         SK_U32  I2cCtrl;                                \
113         SK_IN32(IoC, B2_I2C_CTRL, &I2cCtrl);            \
114         SK_OUT32(IoC, B2_I2C_CTRL, I2cCtrl | I2C_STOP); \
115 }
116
117 #define SK_I2C_GET_CTL(Ioc,pI2cCtrl)    SK_IN32(Ioc,B2_I2C_CTRL,pI2cCtrl)
118
119 /*
120  * Macros to access the I2C SW Registers
121  */
122 #define SK_I2C_SET_BIT(IoC, SetBits) {                  \
123         SK_U8   OrgBits;                                \
124         SK_IN8(IoC, B2_I2C_SW, &OrgBits);               \
125         SK_OUT8(IoC, B2_I2C_SW, OrgBits | (SetBits));   \
126 }
127
128 #define SK_I2C_CLR_BIT(IoC,ClrBits) {                   \
129         SK_U8   OrgBits;                                \
130         SK_IN8(IoC, B2_I2C_SW, &OrgBits);               \
131         SK_OUT8(IoC, B2_I2C_SW, OrgBits & ~(ClrBits));  \
132 }
133
134 #define SK_I2C_GET_SW(IoC,pI2cSw)       SK_IN8(IoC,B2_I2C_SW,pI2cSw)
135
136 /*
137  * define the possible sensor states
138  */
139 #define SK_SEN_IDLE     0       /* Idle: sensor not read */
140 #define SK_SEN_VALUE    1       /* Value Read cycle */
141 #define SK_SEN_VALEXT   2       /* Extended Value Read cycle */
142
143 /*
144  * Conversion factor to convert read Voltage sensor to milli Volt
145  * Conversion factor to convert read Temperature sensor to 10th degree Celsius
146  */
147 #define SK_LM80_VT_LSB          22      /* 22mV LSB resolution */
148 #define SK_LM80_TEMP_LSB        10      /* 1 degree LSB resolution */
149 #define SK_LM80_TEMPEXT_LSB     5       /* 0.5 degree LSB resolution for the
150                                          * extension value 
151                                          */
152 #define SK_LM80_FAN_FAKTOR      ((22500L*60)/(1*2))
153 /* formula: counter = (22500*60)/(rpm * divisor * pulses/2)
154  * assuming: 6500rpm, 4 pulses, divisor 1
155  */
156
157 /*
158  * Define sensor management data
159  * Maximum is reached on copperfield with dual Broadcom.
160  * Board specific maximum is in pAC->I2c.MaxSens
161  */
162 #define SK_MAX_SENSORS  8       /* maximal no. of installed sensors */
163 #define SK_MIN_SENSORS  5       /* minimal no. of installed sensors */
164
165 /*
166  * Defines for the individual Thresholds
167  */
168
169 /* Temperature sensor */
170 #define SK_SEN_ERRHIGH0         800     /* Temperature High Err Threshold */
171 #define SK_SEN_WARNHIGH0        700     /* Temperature High Warn Threshold */
172 #define SK_SEN_WARNLOW0         100     /* Temperature Low Err Threshold */
173 #define SK_SEN_ERRLOW0          0       /* Temperature Low Warn Threshold */
174
175 /* VCC which should be 5 V */
176 #define SK_SEN_ERRHIGH1         5588    /* Voltage PCI High Err Threshold */
177 #define SK_SEN_WARNHIGH1        5346    /* Voltage PCI High Warn Threshold */
178 #define SK_SEN_WARNLOW1         4664    /* Voltage PCI Low Err Threshold */
179 #define SK_SEN_ERRLOW1          4422    /* Voltage PCI Low Warn Threshold */
180
181 /*
182  * VIO may be 5 V or 3.3 V. Initialization takes two parts:
183  * 1. Initialize lowest lower limit and highest higher limit.
184  * 2. After the first value is read correct the upper or the lower limit to
185  *    the appropriate C constant.
186  *
187  * Warning limits are +-5% of the exepected voltage.
188  * Error limits are +-10% of the expected voltage.
189  */
190 #define SK_SEN_ERRHIGH2         5588    /* Voltage PCI-IO High Err Threshold */
191 #define SK_SEN_WARNHIGH2        5346    /* Voltage PCI-IO High Warn Threshold */
192 #define SK_SEN_WARNLOW2         3146    /* Voltage PCI-IO Low Err Threshold */
193 #define SK_SEN_ERRLOW2          2970    /* Voltage PCI-IO Low Warn Threshold */
194
195 /* correction values for the second pass */
196 #define SK_SEN_ERRHIGH2C        3630    /* Voltage PCI-IO High Err Threshold */
197 #define SK_SEN_WARNHIGH2C       3476    /* Voltage PCI-IO High Warn Threshold */
198 #define SK_SEN_WARNLOW2C        4664    /* Voltage PCI-IO Low Err Threshold */
199 #define SK_SEN_ERRLOW2C         4422    /* Voltage PCI-IO Low Warn Threshold */
200
201 /*
202  * VDD voltage
203  */
204 #define SK_SEN_ERRHIGH3         3630    /* Voltage ASIC High Err Threshold */
205 #define SK_SEN_WARNHIGH3        3476    /* Voltage ASIC High Warn Threshold */
206 #define SK_SEN_WARNLOW3         3146    /* Voltage ASIC Low Err Threshold */
207 #define SK_SEN_ERRLOW3          2970    /* Voltage ASIC Low Warn Threshold */
208
209 /*
210  * PLC_3V3 voltage
211  * PHY_PLL_A_3V3 voltage
212  */
213 #define SK_SEN_ERRHIGH4         3630    /* Voltage PMA High Err Threshold */
214 #define SK_SEN_WARNHIGH4        3476    /* Voltage PMA High Warn Threshold */
215 #define SK_SEN_WARNLOW4         3146    /* Voltage PMA Low Err Threshold */
216 #define SK_SEN_ERRLOW4          2970    /* Voltage PMA Low Warn Threshold */
217
218 /*
219  * PHY_2V5 voltage
220  */
221 #define SK_SEN_ERRHIGH5         2750    /* Voltage PHY High Err Threshold */
222 #define SK_SEN_WARNHIGH5        2640    /* Voltage PHY High Warn Threshold */
223 #define SK_SEN_WARNLOW5         2376    /* Voltage PHY Low Err Threshold */
224 #define SK_SEN_ERRLOW5          2222    /* Voltage PHY Low Warn Threshold */
225
226 /*
227  * PHY_PLL_B_3V3 voltage
228  */
229 #define SK_SEN_ERRHIGH6         3630    /* Voltage PMA High Err Threshold */
230 #define SK_SEN_WARNHIGH6        3476    /* Voltage PMA High Warn Threshold */
231 #define SK_SEN_WARNLOW6         3146    /* Voltage PMA Low Err Threshold */
232 #define SK_SEN_ERRLOW6          2970    /* Voltage PMA Low Warn Threshold */
233
234 /*
235  * FAN 1 speed
236  */
237 /* assuming: 6500rpm +-15%, 4 pulses,
238  * warning at:  80 %
239  * error at:    70 %
240  * no upper limit
241  */
242 #define SK_SEN_ERRHIGH          20000   /* FAN Speed High Err Threshold */
243 #define SK_SEN_WARNHIGH         20000   /* FAN Speed High Warn Threshold */
244 #define SK_SEN_WARNLOW          5200    /* FAN Speed Low Err Threshold */
245 #define SK_SEN_ERRLOW           4550    /* FAN Speed Low Warn Threshold */
246
247 extern  int SkLm80ReadSensor(SK_AC *pAC, SK_IOC IoC, SK_SENSOR *pSen);
248 #endif  /* n_INC_SKGEI2C_H */