xref: /titanic_41/usr/src/cmd/picl/plugins/sun4u/psvc/psvcobj/psvc_objects.h (revision 298b7f4ca426d69789dddfabc7fd2863cf7a0ea4)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef	_PSVC_OBJECTS_H
28 #define	_PSVC_OBJECTS_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #ifdef	__cplusplus
33 extern "C" {
34 #endif
35 
36 /*
37  * Platform Services Framework definitions
38  */
39 
40 #include <sys/types.h>
41 #include <pthread.h>
42 
43 typedef struct psvc_opaque *psvc_opaque_t;
44 
45 /* Return values */
46 #define	PSVC_SUCCESS 0
47 #define	PSVC_FAILURE -1
48 #define	PSVC_NOT_USED -1
49 
50 /* Class definitions */
51 #define	PSVC_TEMPERATURE_SENSOR_CLASS 0
52 #define	PSVC_FAN_CLASS 1
53 #define	PSVC_LED_CLASS 2
54 #define	PSVC_SYSTEM_CLASS 3
55 #define	PSVC_DIGITAL_SENSOR_CLASS 4
56 #define	PSVC_DIGITAL_CONTROL_CLASS 5
57 #define	PSVC_BOOLEAN_GPIO_CLASS 6
58 #define	PSVC_FAN_TACHOMETER_CLASS 7
59 #define	PSVC_ON_OFF_SWITCH_CLASS 8
60 #define	PSVC_KEYSWITCH_CLASS 9
61 #define	PSVC_8BIT_GPIO_CLASS 10
62 #define	PSVC_PHYSICAL_DEVICE_CLASS 11
63 
64 #define	PSVC_CHASSIS "SYSTEM"
65 
66 /* Associations */
67 #define	PSVC_PRESENCE_SENSOR 0
68 #define	PSVC_FAN_ONOFF_SENSOR 1
69 #define	PSVC_FAN_SPEED_TACHOMETER 2
70 #define	PSVC_FAN_PRIM_SEC_SELECTOR 3
71 #define	PSVC_DEV_TEMP_SENSOR 4
72 #define	PSVC_FAN_DRIVE_CONTROL 5
73 #define	PSVC_KS_NORMAL_POS_SENSOR 6
74 #define	PSVC_KS_DIAG_POS_SENSOR 7
75 #define	PSVC_KS_LOCK_POS_SENSOR 8
76 #define	PSVC_KS_OFF_POS_SENSOR 9
77 #define	PSVC_SLOT_FAULT_LED 10
78 #define	PSVC_SLOT_REMOVE_LED 11
79 #define	PSVC_TS_OVERTEMP_LED 12
80 #define	PSVC_PS_I_SENSOR 13
81 #define	PSVC_DEV_FAULT_SENSOR 14
82 #define	PSVC_DEV_FAULT_LED 15
83 #define	PSVC_TABLE 16
84 #define	PSVC_PARENT 17
85 #define	PSVC_CPU 18
86 #define	PSVC_ALTERNATE 19
87 #define	PSVC_HOTPLUG_ENABLE_SWITCH 20
88 #define	PSVC_PS 21
89 #define	PSVC_FAN 22
90 #define	PSVC_TS 23
91 #define	PSVC_DISK 24
92 #define	PSVC_LED 25
93 #define	PSVC_FSP_LED 26
94 #define	PSVC_KEYSWITCH 27
95 #define	PSVC_PCI_CARD 28
96 #define	PSVC_PHYSICAL_DEVICE 29
97 #define	PSVC_DEV_TYPE_SENSOR 30
98 #define	PSVC_FAN_TRAY_FANS 31
99 #define	PSVC_FRU 32
100 
101 
102 /* Device "feature" definitions */
103 #define	PSVC_DEV_PERM		0x0000000000000001ULL /* Permanently in sys */
104 #define	PSVC_DEV_HOTPLUG	0x0000000000000002ULL /* Hot-pluggable device */
105 #define	PSVC_DEV_OPTION	0x0000000000000004ULL /* Option (not hot-pluggable) */
106 #define	PSVC_DEV_PRIMARY	0x0000000000000010ULL /* Primary device */
107 #define	PSVC_DEV_SECONDARY	0x0000000000000020ULL /* Secondary device */
108 #define	PSVC_DEV_RDONLY    	0x0000000000000100ULL /* Read only device */
109 #define	PSVC_DEV_RDWR		0x0000000000000400ULL /* read/write device */
110 #define	PSVC_DEV_FRU		0x0000000000000800ULL /* device is a FRU */
111 #define	PSVC_LOW_WARN		0x0000000000001000ULL
112 #define	PSVC_LOW_SHUT		0x0000000000002000ULL
113 #define	PSVC_HIGH_WARN		0x0000000000004000ULL
114 #define	PSVC_HIGH_SHUT		0x0000000000008000ULL
115 #define	PSVC_CONVERSION_TABLE	0x0000000000010000ULL /* Conversion table */
116 #define	PSVC_OPT_TEMP		0x0000000000020000ULL /* Optimal Temperature */
117 #define	PSVC_HW_LOW_SHUT	0x0000000000040000ULL
118 #define	PSVC_HW_HIGH_SHUT	0x0000000000080000ULL
119 #define	PSVC_FAN_DRIVE_PR	0x0001000000000000ULL
120 #define	PSVC_TEMP_DRIVEN	0x0002000000000000ULL /* Temperature driven */
121 #define	PSVC_SPEED_CTRL_PR	0x0004000000000000ULL /* Variable speed ctrl */
122 #define	PSVC_FAN_ON_OFF		0x0008000000000000ULL /* On/off fans */
123 #define	PSVC_CLOSED_LOOP_CTRL	0x0010000000000000ULL /* Closed loop control */
124 #define	PSVC_FAN_DRIVE_TABLE_PR 0x0010000000000000ULL /* oC to fan input tbl */
125 #define	PSVC_DIE_TEMP		0x0001000000000000ULL
126 #define	PSVC_AMB_TEMP		0x0002000000000000ULL
127 #define	PSVC_DIGI_SENSOR	0x0100000000000000ULL /* A to D converter */
128 #define	PSVC_BI_STATE		0x0001000000000000ULL
129 #define	PSVC_TRI_STATE		0x0002000000000000ULL
130 #define	PSVC_GREEN		0x0010000000000000ULL
131 #define	PSVC_AMBER		0x0020000000000000ULL
132 #define	PSVC_OUTPUT		0x0100000000000000ULL
133 #define	PSVC_INPUT		0x0200000000000000ULL
134 #define	PSVC_BIDIR		0x0400000000000000ULL
135 #define	PSVC_BIT_POS	0x0001000000000000ULL /* One bit per key positon */
136 #define	PSVC_VAL_POS	0x0002000000000000ULL /* One value per key position */
137 #define	PSVC_NORMAL_POS_AV	0x0010000000000000ULL
138 #define	PSVC_DIAG_POS_AV	0x0020000000000000ULL
139 #define	PSVC_LOCK_POS_AV	0x0040000000000000ULL
140 #define	PSVC_OFF_POS_AV		0x0080000000000000ULL
141 #define	PSVC_GPIO_PORT		0x0001000000000000ULL
142 #define	PSVC_GPIO_REG		0x0002000000000000ULL
143 
144 
145 /* LED colors */
146 #define	PSVC_LED_GREEN "GREEN"
147 #define	PSVC_LED_AMBER "AMBER"
148 #define	PSVC_LED_WHITE "WHITE"
149 #define	PSVC_LED_RED "RED"
150 
151 /* States */
152 #define	PSVC_OK	"OK"
153 #define	PSVC_ERROR	"ERROR"
154 #define	PSVC_DEGRADED "DEGRADED"
155 #define	PSVC_STOPPED "STOPPED"
156 #define	PSVC_OVERHEATING "OVERHEATING"
157 #define	PSVC_OFF "OFF"
158 #define	PSVC_ON "ON"
159 #define	PSVC_HOTPLUGGED "HOTPLUGGED"	/* hotplugged, but not yet enabled */
160 
161 /*
162  * The Following States are for the Locking Object created by PSARC 2002/003
163  */
164 #define	PSVC_LOCK_RUNNING "running"
165 #define	PSVC_LOCK_ENABLED "enabled"
166 #define	PSVC_LOCK_DISABLED "disabled"
167 
168 /* LED states */
169 #define	PSVC_LED_OFF PSVC_OFF
170 #define	PSVC_LED_ON PSVC_ON
171 #define	PSVC_LED_SLOW_BLINK "SLOW_BLINK"
172 #define	PSVC_LED_FAST_BLINK "FAST_BLINK"
173 
174 /* On/Off switch states */
175 #define	PSVC_SWITCH_OFF PSVC_OFF
176 #define	PSVC_SWITCH_ON PSVC_ON
177 
178 /* Keyswitch positions */
179 #define	PSVC_OFF_POS PSVC_OFF
180 #define	PSVC_NORMAL_POS "NORMAL"
181 #define	PSVC_LOCKED_POS "LOCKED"
182 #define	PSVC_DIAG_POS "DIAG"
183 
184 /* Fault strings */
185 #define	PSVC_NO_FAULT "NO_FAULT"
186 #define	PSVC_GEN_FAULT "DEVICE_FAULT"
187 #define	PSVC_PS_LLO_FLT "PS_LLO_FAULT"
188 #define	PSVC_PS_FAN_FLT "PS_FAN_FAULT"
189 #define	PSVC_PS_TEMP_FLT "PS_TEMP_FAULT"
190 #define	PSVC_PS_ISHARE_FLT "PS_ISHARE_FAULT"
191 #define	PSVC_PS_TYPE_FLT "PS_TYPE_FLT"
192 #define	PSVC_TEMP_LO_WARN "TEMP_LOW_WARNING"
193 #define	PSVC_TEMP_LO_SHUT "TEMP_LOW_SHUTDOWN"
194 #define	PSVC_TEMP_HI_WARN "TEMP_HIGH_WARNING"
195 #define	PSVC_TEMP_HI_SHUT "TEMP_HIGH_SHUTDOWN"
196 
197 /*
198  * When Adding Attributes be sure to add the string value of the
199  * Attribute to attr_str_tab in psvc_objects_class.h
200  */
201 
202 /* Attribute names */
203 #define	PSVC_CLASS_ATTR				0	/* "_class" */
204 #define	PSVC_SUBCLASS_ATTR			1	/* "Subclass" */
205 #define	PSVC_PRESENCE_ATTR			2	/* "Presence" */
206 #define	PSVC_PREV_PRESENCE_ATTR			3	/* Previous-presence */
207 #define	PSVC_STATE_ATTR				4	/* "State" */
208 #define	PSVC_PREV_STATE_ATTR			5	/* "Previous-state" */
209 #define	PSVC_ENABLE_ATTR			6	/* "Enabled" */
210 #define	PSVC_FAULTID_ATTR			7	/* "FaultInformation" */
211 #define	PSVC_FEATURES_ATTR			8	/* "Features" */
212 #define	PSVC_LABEL_ATTR				9	/* "Label" */
213 #define	PSVC_FRUID_ATTR				10	/* "Fruid" */
214 #define	PSVC_INSTANCE_ATTR			11	/* "Instance" */
215 #define	PSVC_LED_COLOR_ATTR			12	/* "Led-color" */
216 #define	PSVC_LO_WARN_ATTR			13	/* "Lo-warn" */
217 #define	PSVC_LO_SHUT_ATTR			14	/* "Lo-shut" */
218 #define	PSVC_HI_WARN_ATTR			15	/* "Hi-warn" */
219 #define	PSVC_HI_SHUT_ATTR			16	/* "Hi-shut" */
220 #define	PSVC_OPTIMAL_TEMP_ATTR			17	/* "Opt-temp" */
221 #define	PSVC_HW_HI_SHUT_ATTR			18	/* "Hw-hi-shut" */
222 #define	PSVC_HW_LO_SHUT_ATTR			19	/* "Hw-lo-shut" */
223 #define	PSVC_SETPOINT_ATTR			20	/* "Setpoint" */
224 #define	PSVC_HYSTERESIS_ATTR			21	/* "Hysteresis" */
225 #define	PSVC_LOOPGAIN_ATTR			22	/* "Loopgain" */
226 #define	PSVC_LOOPBIAS_ATTR			23	/* "Loopbias" */
227 #define	PSVC_TEMP_DIFFERENTIAL_ATTR		24 /* "Temp_differential" */
228 #define	PSVC_TEMP_DIFFERENTIAL_INDEX_ATTR	25 /* Temp_differential_index */
229 #define	PSVC_SENSOR_VALUE_ATTR			26	/* "Sensor-value" */
230 #define	PSVC_GPIO_VALUE_ATTR			27	/* "Gpio-value" */
231 #define	PSVC_GPIO_BITS				28	/* "#Bits" */
232 #define	PSVC_CONTROL_VALUE_ATTR			29	/* "Control-value" */
233 #define	PSVC_LED_STATE_ATTR			30	/* "Led-state" */
234 #define	PSVC_SWITCH_STATE_ATTR			31	/* "Switch-state" */
235 #define	PSVC_PROBE_RESULT_ATTR			32	/* "Probe-result" */
236 #define	PSVC_TABLE_VALUE_ATTR			33	/* "Table_value" */
237 #define	PSVC_ASSOC_ID_ATTR			34	/* "Assoc_id" */
238 #define	PSVC_ASSOC_MATCHES_ATTR			35	/* "Assoc_matches" */
239 #define	PSVC_ADDR_SPEC_ATTR			36	/* "Addr-spec" */
240 #define	PSVC_OBJECT_ID_ATTR			37	/* "Object-id" */
241 #define	PSVC_LIT_COUNT_ATTR			38	/* "Led-lit-count" */
242 #define	PSVC_FRU_INFO_ATTR			39	/* "FRU-info" */
243 
244 #define	PSVC_LED_IS_LOCATOR_ATTR		40	/* "IsLocator" */
245 #define	PSVC_LED_LOCATOR_NAME_ATTR		41	/* "LocatorName" */
246 #define	PSVC_LOCATOR_TRUE	"true"
247 
248 /* PSVC_PRESENCE_ATTR values */
249 #define	PSVC_ABSENT 0
250 #define	PSVC_PRESENT 1
251 
252 /* PSVC_ENABLE_ATTR values */
253 #define	PSVC_DISABLED 0
254 #define	PSVC_ENABLED 1
255 
256 /* PSVC_PROBE_RESULT_ATTR values */
257 #define	PSVC_DEV_PROBE_SUCCESS PSVC_SUCCESS
258 #define	PSVC_DEV_PROBE_FAILED  PSVC_FAILURE
259 
260 /* Size of fan temperature differential array */
261 #define	PSVC_MAXERRORS 2
262 
263 /* Address specification macros */
264 #define	PSVC_VERSION 0		/* Current version */
265 
266 #define	PSVC_VERSION_SHIFT 0
267 #define	PSVC_ACTIVE_LOW_SHIFT 7
268 #define	PSVC_BIT_NUM_SHIFT 4
269 #define	PSVC_INVERT_SHIFT 4
270 #define	PSVC_PORT_SHIFT 8
271 #define	PSVC_BITSHIFT_SHIFT 12
272 #define	PSVC_BYTEMASK_SHIFT 16
273 #define	PSVC_REG_SHIFT 24
274 #define	PSVC_TYPE_SHIFT 32
275 #define	PSVC_BUSADDR_SHIFT 40
276 #define	PSVC_BUSNUM_SHIFT 48
277 #define	PSVC_CNTLR_SHIFT 56
278 
279 #define	PSVC_GET_VERSION(X) ((X >> PSVC_VERSION_SHIFT) & 0xF)
280 #define	PSVC_IS_ACTIVE_LOW(X) ((X >> PSVC_ACTIVE_LOW_SHIFT) & 0x1)
281 #define	PSVC_GET_BIT_NUM(X)  ((X >> PSVC_BIT_NUM_SHIFT) & 0x7)
282 #define	PSVC_HP_INVERT(X) (((X >> PSVC_INVERT_SHIFT) & 0x7) == 1)
283 #define	PSVC_GET_ASPEC_PORT(X) ((X >> PSVC_PORT_SHIFT) & 0xF)
284 #define	PSVC_GET_ASPEC_BITSHIFT(X) ((X >> PSVC_BITSHIFT_SHIFT) & 0xF)
285 #define	PSVC_GET_ASPEC_BYTEMASK(X) ((X >> PSVC_BYTEMASK_SHIFT) & 0xFF)
286 #define	PSVC_GET_ASPEC_REG(X) ((X >> PSVC_REG_SHIFT) & 0xFF)
287 #define	PSVC_GET_ASPEC_TYPE(X) ((X >> PSVC_TYPE_SHIFT) & 0xFF)
288 #define	PSVC_GET_ASPEC_BUSADDR(X) ((X >> PSVC_BUSADDR_SHIFT) & 0xFF)
289 #define	PSVC_GET_ASPEC_BUSNUM(X) ((X >> PSVC_BUSNUM_SHIFT) & 0xFF)
290 #define	PSVC_GET_ASPEC_CNTLR(X) ((X >> PSVC_CNTLR_SHIFT) & 0xFF)
291 
292 
293 /* Address spec device_types */
294 #define	PSVC_I2C_AT24		0
295 #define	PSVC_I2C_HPC3130	1
296 #define	PSVC_I2C_LM75		2
297 #define	PSVC_I2C_LTC1427	3
298 #define	PSVC_I2C_MAX1617	4
299 #define	PSVC_I2C_PCF8574	5
300 #define	PSVC_I2C_PCF8591	6
301 #define	PSVC_I2C_SSC050		7
302 #define	PSVC_I2C_TDA8444	8
303 #define	PSVC_I2C_SSC100		9
304 
305 /* numbers of attempts for retrying requests over the I2C bus */
306 #define	PSVC_NUM_OF_RETRIES	5
307 #define	PSVC_THRESHOLD_COUNTER	5
308 
309 /* Prototypes */
310 #ifndef LIBRARY_BUILD
311 int32_t psvc_init(psvc_opaque_t *);
312 int32_t psvc_fini(psvc_opaque_t);
313 int32_t psvc_get_attr(psvc_opaque_t, char *, int32_t, void *, ...);
314 int32_t psvc_set_attr(psvc_opaque_t, char *, int32_t, void *);
315 void psvcplugin_add_children(char *parent_path);
316 void psvcplugin_lookup(char *name, char *parent, picl_nodehdl_t *node);
317 #endif
318 
319 /* FRU reading structure */
320 typedef struct {
321 	int32_t buf_start;
322 	char *buf;
323 	int32_t read_size;
324 }fru_info_t;
325 
326 /* Mutex used for Daktari Fan speed reading */
327 extern pthread_mutex_t fan_mutex;
328 
329 #ifdef	__cplusplus
330 }
331 #endif
332 
333 #endif /* _PSVC_OBJECTS_H */
334