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