1 /******************************************************************************
2  *
3  * Name:	skgei2c.h
4  * Project:	Gigabit Ethernet Adapters, TWSI-Module
5  * Purpose:	Special defines for TWSI
6  *
7  ******************************************************************************/
8 
9 /******************************************************************************
10  *
11  *	(C)Copyright 1998-2002 SysKonnect.
12  *	(C)Copyright 2002-2003 Marvell.
13  *
14  *	This program is free software; you can redistribute it and/or modify
15  *	it under the terms of the GNU General Public License as published by
16  *	the Free Software Foundation; either version 2 of the License, or
17  *	(at your option) any later version.
18  *
19  *	The information in this file is provided "AS IS" without warranty.
20  *
21  ******************************************************************************/
22 
23 /*
24  * SKGEI2C.H	contains all SK-98xx specific defines for the TWSI handling
25  */
26 
27 #ifndef _INC_SKGEI2C_H_
28 #define _INC_SKGEI2C_H_
29 
30 /*
31  * Macros to access the B2_I2C_CTRL
32  */
33 #define SK_I2C_CTL(IoC, flag, dev, dev_size, reg, burst) \
34 	SK_OUT32(IoC, B2_I2C_CTRL,\
35 		(flag ? 0x80000000UL : 0x0L) | \
36 		(((SK_U32)reg << 16) & I2C_ADDR) | \
37 		(((SK_U32)dev << 9) & I2C_DEV_SEL) | \
38 		(dev_size & I2C_DEV_SIZE) | \
39 		((burst << 4) & I2C_BURST_LEN))
40 
41 #define SK_I2C_STOP(IoC) {				\
42 	SK_U32	I2cCtrl;				\
43 	SK_IN32(IoC, B2_I2C_CTRL, &I2cCtrl);		\
44 	SK_OUT32(IoC, B2_I2C_CTRL, I2cCtrl | I2C_STOP);	\
45 }
46 
47 #define SK_I2C_GET_CTL(IoC, pI2cCtrl)	SK_IN32(IoC, B2_I2C_CTRL, pI2cCtrl)
48 
49 /*
50  * Macros to access the TWSI SW Registers
51  */
52 #define SK_I2C_SET_BIT(IoC, SetBits) {			\
53 	SK_U8	OrgBits;				\
54 	SK_IN8(IoC, B2_I2C_SW, &OrgBits);		\
55 	SK_OUT8(IoC, B2_I2C_SW, OrgBits | (SK_U8)(SetBits));	\
56 }
57 
58 #define SK_I2C_CLR_BIT(IoC, ClrBits) {			\
59 	SK_U8	OrgBits;				\
60 	SK_IN8(IoC, B2_I2C_SW, &OrgBits);		\
61 	SK_OUT8(IoC, B2_I2C_SW, OrgBits & ~((SK_U8)(ClrBits)));	\
62 }
63 
64 #define SK_I2C_GET_SW(IoC, pI2cSw)	SK_IN8(IoC, B2_I2C_SW, pI2cSw)
65 
66 /*
67  * define the possible sensor states
68  */
69 #define	SK_SEN_IDLE		0	/* Idle: sensor not read */
70 #define	SK_SEN_VALUE	1	/* Value Read cycle */
71 #define	SK_SEN_VALEXT	2	/* Extended Value Read cycle */
72 
73 /*
74  * Conversion factor to convert read Voltage sensor to milli Volt
75  * Conversion factor to convert read Temperature sensor to 10th degree Celsius
76  */
77 #define	SK_LM80_VT_LSB		22	/* 22mV LSB resolution */
78 #define	SK_LM80_TEMP_LSB	10	/* 1 degree LSB resolution */
79 #define	SK_LM80_TEMPEXT_LSB	 5	/* 0.5 degree LSB resolution for ext. val. */
80 
81 /*
82  * formula: counter = (22500*60)/(rpm * divisor * pulses/2)
83  * assuming: 6500rpm, 4 pulses, divisor 1
84  */
85 #define SK_LM80_FAN_FAKTOR	((22500L*60)/(1*2))
86 
87 /*
88  * Define sensor management data
89  * Maximum is reached on Genesis copper dual port and Yukon-64
90  * Board specific maximum is in pAC->I2c.MaxSens
91  */
92 #define	SK_MAX_SENSORS	8	/* maximal no. of installed sensors */
93 #define	SK_MIN_SENSORS	5	/* minimal no. of installed sensors */
94 
95 /*
96  * To watch the state machine (SM) use the timer in two ways
97  * instead of one as hitherto
98  */
99 #define	SK_TIMER_WATCH_SM		0	/* Watch the SM to finish in a spec. time */
100 #define	SK_TIMER_NEW_GAUGING	1	/* Start a new gauging when timer expires */
101 
102 /*
103  * Defines for the individual thresholds
104  */
105 
106 /* Temperature sensor */
107 #define	SK_SEN_TEMP_HIGH_ERR	800	/* Temperature High Err  Threshold */
108 #define	SK_SEN_TEMP_HIGH_WARN	700	/* Temperature High Warn Threshold */
109 #define	SK_SEN_TEMP_LOW_WARN	100	/* Temperature Low  Warn Threshold */
110 #define	SK_SEN_TEMP_LOW_ERR		  0	/* Temperature Low  Err  Threshold */
111 
112 /* VCC which should be 5 V */
113 #define	SK_SEN_PCI_5V_HIGH_ERR		5588	/* Voltage PCI High Err  Threshold */
114 #define	SK_SEN_PCI_5V_HIGH_WARN		5346	/* Voltage PCI High Warn Threshold */
115 #define	SK_SEN_PCI_5V_LOW_WARN		4664	/* Voltage PCI Low  Warn Threshold */
116 #define	SK_SEN_PCI_5V_LOW_ERR		4422	/* Voltage PCI Low  Err  Threshold */
117 
118 /*
119  * VIO may be 5 V or 3.3 V. Initialization takes two parts:
120  * 1. Initialize lowest lower limit and highest higher limit.
121  * 2. After the first value is read correct the upper or the lower limit to
122  *    the appropriate C constant.
123  *
124  * Warning limits are +-5% of the exepected voltage.
125  * Error limits are +-10% of the expected voltage.
126  */
127 
128 /* Bug fix AF: 16.Aug.2001: Correct the init base of LM80 sensor */
129 
130 #define	SK_SEN_PCI_IO_5V_HIGH_ERR	5566	/* + 10% V PCI-IO High Err Threshold */
131 #define	SK_SEN_PCI_IO_5V_HIGH_WARN	5324	/* +  5% V PCI-IO High Warn Threshold */
132 					/*		5000	mVolt */
133 #define	SK_SEN_PCI_IO_5V_LOW_WARN	4686	/* -  5% V PCI-IO Low Warn Threshold */
134 #define	SK_SEN_PCI_IO_5V_LOW_ERR	4444	/* - 10% V PCI-IO Low Err Threshold */
135 
136 #define	SK_SEN_PCI_IO_RANGE_LIMITER	4000	/* 4000 mV range delimiter */
137 
138 /* correction values for the second pass */
139 #define	SK_SEN_PCI_IO_3V3_HIGH_ERR	3850	/* + 15% V PCI-IO High Err Threshold */
140 #define	SK_SEN_PCI_IO_3V3_HIGH_WARN	3674	/* + 10% V PCI-IO High Warn Threshold */
141 					/*		3300	mVolt */
142 #define	SK_SEN_PCI_IO_3V3_LOW_WARN	2926	/* - 10% V PCI-IO Low Warn Threshold */
143 #define	SK_SEN_PCI_IO_3V3_LOW_ERR	2772	/* - 15% V PCI-IO Low Err  Threshold */
144 
145 /*
146  * VDD voltage
147  */
148 #define	SK_SEN_VDD_HIGH_ERR		3630	/* Voltage ASIC High Err  Threshold */
149 #define	SK_SEN_VDD_HIGH_WARN	3476	/* Voltage ASIC High Warn Threshold */
150 #define	SK_SEN_VDD_LOW_WARN		3146	/* Voltage ASIC Low  Warn Threshold */
151 #define	SK_SEN_VDD_LOW_ERR		2970	/* Voltage ASIC Low  Err  Threshold */
152 
153 /*
154  * PHY PLL 3V3 voltage
155  */
156 #define	SK_SEN_PLL_3V3_HIGH_ERR		3630	/* Voltage PMA High Err  Threshold */
157 #define	SK_SEN_PLL_3V3_HIGH_WARN	3476	/* Voltage PMA High Warn Threshold */
158 #define	SK_SEN_PLL_3V3_LOW_WARN		3146	/* Voltage PMA Low  Warn Threshold */
159 #define	SK_SEN_PLL_3V3_LOW_ERR		2970	/* Voltage PMA Low  Err  Threshold */
160 
161 /*
162  * VAUX (YUKON only)
163  */
164 #define	SK_SEN_VAUX_3V3_HIGH_ERR	3630	/* Voltage VAUX High Err Threshold */
165 #define	SK_SEN_VAUX_3V3_HIGH_WARN	3476	/* Voltage VAUX High Warn Threshold */
166 #define	SK_SEN_VAUX_3V3_LOW_WARN	3146	/* Voltage VAUX Low Warn Threshold */
167 #define	SK_SEN_VAUX_3V3_LOW_ERR		2970	/* Voltage VAUX Low Err Threshold */
168 #define	SK_SEN_VAUX_0V_WARN_ERR		   0	/* if VAUX not present */
169 #define	SK_SEN_VAUX_RANGE_LIMITER	1000	/* 1000 mV range delimiter */
170 
171 /*
172  * PHY 2V5 voltage
173  */
174 #define	SK_SEN_PHY_2V5_HIGH_ERR		2750	/* Voltage PHY High Err Threshold */
175 #define	SK_SEN_PHY_2V5_HIGH_WARN	2640	/* Voltage PHY High Warn Threshold */
176 #define	SK_SEN_PHY_2V5_LOW_WARN		2376	/* Voltage PHY Low Warn Threshold */
177 #define	SK_SEN_PHY_2V5_LOW_ERR		2222	/* Voltage PHY Low Err Threshold */
178 
179 /*
180  * ASIC Core 1V5 voltage (YUKON only)
181  */
182 #define	SK_SEN_CORE_1V5_HIGH_ERR	1650	/* Voltage ASIC Core High Err Threshold */
183 #define	SK_SEN_CORE_1V5_HIGH_WARN	1575	/* Voltage ASIC Core High Warn Threshold */
184 #define	SK_SEN_CORE_1V5_LOW_WARN	1425	/* Voltage ASIC Core Low Warn Threshold */
185 #define	SK_SEN_CORE_1V5_LOW_ERR 	1350	/* Voltage ASIC Core Low Err Threshold */
186 
187 /*
188  * FAN 1 speed
189  */
190 /* assuming: 6500rpm +-15%, 4 pulses,
191  * warning at:	80 %
192  * error at:	70 %
193  * no upper limit
194  */
195 #define	SK_SEN_FAN_HIGH_ERR		20000	/* FAN Speed High Err Threshold */
196 #define	SK_SEN_FAN_HIGH_WARN	20000	/* FAN Speed High Warn Threshold */
197 #define	SK_SEN_FAN_LOW_WARN		 5200	/* FAN Speed Low Warn Threshold */
198 #define	SK_SEN_FAN_LOW_ERR		 4550	/* FAN Speed Low Err Threshold */
199 
200 /*
201  * Some Voltages need dynamic thresholds
202  */
203 #define	SK_SEN_DYN_INIT_NONE		 0  /* No dynamic init of thresholds */
204 #define	SK_SEN_DYN_INIT_PCI_IO		10  /* Init PCI-IO with new thresholds */
205 #define	SK_SEN_DYN_INIT_VAUX		11  /* Init VAUX with new thresholds */
206 
207 extern	int SkLm80ReadSensor(SK_AC *pAC, SK_IOC IoC, SK_SENSOR *pSen);
208 #endif	/* n_INC_SKGEI2C_H */
209