xref: /illumos-gate/usr/src/uts/common/sys/lom_io.h (revision 2d6eb4a5e0a47d30189497241345dc5466bb68ab)
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 1999-2002 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef	_SYS_LOM_IO_H
28 #define	_SYS_LOM_IO_H
29 
30 /*
31  * I/O header file for LOMlite Driver.
32  */
33 
34 #ifdef __cplusplus
35 extern "C" {
36 #endif
37 
38 #include <sys/ioccom.h>
39 
40 /* ioctls for the TSalarm card */
41 
42 /*
43  * commands to access the alarm monitor node
44  */
45 
46 #define	TSIOCNBMON	_IOR('a', 1, int)
47 #define	TSIOCWTMON	_IOWR('a', 2, int)
48 #define	TSIOCGETMASK	_IOR('a', 3, int)
49 
50 /*
51  * commands to manipulate the control node
52  */
53 
54 #define	TSIOCALCTL	_IOW('a', 4, ts_aldata_t)
55 #define	TSIOCALSTATE	_IOWR('a', 5, ts_aldata_t)
56 #define	TSIOCDOGSTATE	_IOR('a', 6, ts_dogstate_t)
57 #define	TSIOCDOGCTL	_IOW('a', 7, ts_dogctl_t)
58 #define	TSIOCDOGTIME	_IOW('a', 8, uint_t)
59 #define	TSIOCDOGPAT	_IO('a', 9)
60 #define	TSIOCUNLOCK	_IO('a', 10)
61 
62 /*
63  * Defines for the number of the three alarms
64  */
65 
66 #define	ALARM_NUM_1	1
67 #define	ALARM_NUM_2	2
68 #define	ALARM_NUM_3	3
69 
70 /*
71  * command to tell the driver to output debug information. This information
72  * includes :
73  * - the hardware monitor port (R/O)
74  * - in-core monitor status byte
75  * - the in-core control port
76  * - the watchdog timeout setting
77  */
78 #define	TSIOCDUMP	_IO('a', 11)
79 #define	TSIOCDBCTL	_IOW('a', 12, ts_dbctl_t)
80 
81 /*
82  * typedefs used in alarm ioctl definitions
83  */
84 
85 typedef
86 struct {
87 	int alarm_no;
88 	int alarm_state;
89 } ts_aldata_t;
90 
91 typedef
92 struct {
93 	int reset_enable;
94 	int dog_enable;
95 } ts_dogctl_t;
96 
97 typedef
98 struct {
99 	int reset_enable;
100 	int dog_enable;
101 	uint_t dog_timeout;
102 } ts_dogstate_t;
103 
104 
105 typedef
106 struct {
107 	int db_timing;
108 	int db_debug;
109 } ts_dbctl_t;
110 
111 #define	MAX_PSUS	3
112 #define	MAX_FANS	4
113 #define	NUM_EVENTS	10
114 #define	NUM_ALARMS	3
115 
116 /*
117  * Defines for the lom_ctl_t events/fault led flag.
118  */
119 
120 #define	OFF	1
121 #define	ON	2
122 
123 /*
124  * Defines for a3mode.
125  */
126 
127 #define	WATCHDOG	0x02
128 #define	USER		0x01
129 
130 /*
131  * Defines for PSUSTATE
132  */
133 #define	LOM_PSU_NOACCESS	0x20
134 
135 /* ioctls for the LOMlite card */
136 
137 /*
138  * old commands to access the monitor node
139  */
140 
141 #define	LOMIOCNBMON	TSIOCNBMON
142 #define	LOMIOCWTMON	TSIOCWTMON
143 #define	LOMIOCGETMASK	TSIOCGETMASK
144 
145 /*
146  * old commands to manipulate the control node
147  */
148 
149 #define	LOMIOCALCTL	TSIOCALCTL
150 #define	LOMIOCALSTATE	TSIOCALSTATE
151 #define	LOMIOCDOGSTATE	TSIOCDOGSTATE
152 #define	LOMIOCDOGCTL	TSIOCDOGCTL
153 #define	LOMIOCDOGTIME	TSIOCDOGTIME
154 #define	LOMIOCDOGPAT	TSIOCDOGPAT
155 #define	LOMIOCUNLOCK	TSIOCUNLOCK
156 
157 /*
158  * new commands to access the monitor node
159  */
160 
161 #define	LOMIOCPSUSTATE	_IOR('a', 21, lom_psudata_t)
162 #define	LOMIOCEVENTLOG	_IOR('a', 22, lom_eventlog_t)
163 #define	LOMIOCFANSTATE	_IOR('a', 23, lom_fandata_t)
164 #define	LOMIOCFLEDSTATE _IOR('a', 24, lom_fled_info_t)
165 #define	LOMIOCINFO	_IOR('a', 25, lom_info_t)
166 
167 /*
168  * new commands to manipulate the control node
169  */
170 
171 #define	LOMIOCCLEARLOG	_IO('a', 26)
172 #define	LOMIOCCTL	_IOW('a', 27, lom_ctl_t)
173 #define	LOMIOCPROG	_IOWR('a', 28, lom_prog_t)
174 #define	LOMIOCDAEMON	_IOWR('a', 29, int)
175 #define	LOMIOCDMON	_IOWR('a', 30, int)
176 
177 /*
178  * Command to read general purpose LOMlite inputs.
179  * There are only 3 bits to general purpose inputs.
180  */
181 
182 #define	LOMIOCGPINPUTS	_IOWR('a', 31, int)
183 
184 /*
185  * Manufacture programming command.
186  */
187 
188 #define	LOMIOCMPROG	_IOW('a', 32, lom_mprog_t)
189 #define	LOMIOCMREAD	_IOR('a', 33, lom_mprog_t)
190 
191 #define	LOMIOCLEDSTATE 	_IOR('a', 34, lom_led_state_t)
192 
193 /*
194  * command to tell the driver to output debug information. This information
195  * includes :
196  * - the hardware monitor port (R/O)
197  * - in-core monitor status byte
198  * - the in-core control port
199  * - the watchdog timeout setting
200  */
201 #define	LOMIOCDUMP	TSIOCDUMP
202 #define	LOMIOCDBCTL	TSIOCDBCTL
203 
204 /*
205  * typedefs used in LOMlite ioctl definitions
206  */
207 
208 typedef
209 struct {
210 	int alarm_no;
211 	int state;
212 } lom_aldata_t;
213 
214 typedef
215 struct {
216 	int reset_enable;
217 	int dog_enable;
218 } lom_dogctl_t;
219 
220 typedef
221 struct {
222 	int reset_enable;
223 	int dog_enable;
224 	uint_t dog_timeout;
225 } lom_dogstate_t;
226 
227 
228 typedef
229 struct {
230 	int db_timing;
231 	int db_debug;
232 } lom_dbctl_t;
233 
234 
235 typedef
236 struct {
237 	int fitted[MAX_PSUS];
238 	int output[MAX_PSUS];
239 	int supplya[MAX_PSUS];
240 	int supplyb[MAX_PSUS];
241 	int standby[MAX_PSUS];
242 } lom_psudata_t;
243 
244 typedef
245 struct {
246 	int fitted[MAX_FANS];
247 	int speed[MAX_FANS];
248 	int minspeed[MAX_FANS];
249 } lom_fandata_t;
250 
251 typedef
252 struct {
253 	int events[NUM_EVENTS];
254 	int fatalevent;
255 } lom_eventlog_t;
256 
257 /*
258  * The event codes as used in lom_eventlog_t are coded as described here:
259  *
260  * Event codes encode, in a single byte, the source and type
261  * of event/failure in the system.
262  *
263  * There are two types of failure - fan and PSU.
264  *
265  * Other events need to be stored but do not constitue faults.
266  */
267 #define	LOM_EVENT_NONE		0x00	/* No fault */
268 #define	LOM_EVENT_LOST		0x01	/* Event lost due to buffer overflow */
269 #define	LOM_EVENT_RESET		0x02	/* Reset is asserted by the LOM */
270 #define	LOM_EVENT_PWR_ON	0x03	/* Power is turned on by the LOM */
271 #define	LOM_EVENT_PWR_OFF	0x04	/* Power is turned off by the LOM */
272 #define	LOM_EVENT_WDOG_ON	0x05	/* Host watchdog enabled */
273 #define	LOM_EVENT_WDOG_OFF	0x06	/* Host watchdog disabled */
274 #define	LOM_EVENT_WDOG_TRIG	0x07	/* Host watchdog triggered */
275 #define	LOM_EVENT_LOM_RESET	0x08	/* LOMlite has been reset */
276 #define	LOM_EVENT_CHECKSUM	0x09	/* ROM checksum failure */
277 #define	LOM_EVENT_BUSY		0x0a	/* Event not ready yet (being read) */
278 
279 /*
280  * Fault LED events
281  */
282 #define	LOM_EVENT_FAULT		0x20	/* Fault events - codes 0x20-0x2f */
283 #define	LOM_EVENT_FAULT_MASK	0xf0	/* Fault events - codes 0x20-0x2f */
284 
285 /*
286  * Fault LED events are encoded thus
287  *
288  *  7	 4 3		       0
289  *  ----------------------------
290  * | 0010 | Fault LED frequency |
291  *  ----------------------------
292  *
293  * The "Fault LED frequency" is a 4 bit code allowing for LED
294  * falshing rates of 0 to 14 Hz with a rate of 15 signifying off.
295  *
296  * For example the event code for the assertion of a fault LED rate of 2Hz is:
297  *    LOM_EVENT_FAULT_ENCODE(2);
298  */
299 #define	LOM_EVENT_FAULT_ENCODE(faultRate) \
300 	(LOM_EVENT_FAULT | ((faultRate)&0xf))
301 
302 /*
303  * Alarm events
304  */
305 #define	LOM_EVENT_ALARM		0x30	/* Alarm events - codes 0x30-0x3f */
306 #define	LOM_EVENT_ALARM_MASK	0xf0	/* Alarm events - codes 0x30-0x3f */
307 
308 /*
309  * Alarm events are encoded thus
310  *
311  *  7	 4 3		1    0
312  *  --------------------------
313  * | 0011 | Alarm number | On |
314  *  --------------------------
315  *
316  * The "Alarm number" is a 3 bit code allowing for up to 8 alarms
317  *
318  * For example the event code for the assertion of alarm 2 is:
319  *    LOM_EVENT_ALARM_ENCODE(2, 1);
320  */
321 #define	LOM_EVENT_ALARM_ENCODE(alarmNum, alarmOn) \
322 	(LOM_EVENT_ALARM | (alarmNum<<1) | ((alarmOn)&0x1))
323 
324 /*
325  * These alarms are considered fatal errors
326  */
327 
328 #define	LOM_EVENT_FAN		0x40	/* Fan failure - codes 0x40-0x7f */
329 #define	LOM_EVENT_FAN_MASK	0xc0	/* Fan failure - codes 0x40-0x7f */
330 
331 /*
332  * Fan events are encoded thus
333  *
334  *  7  6 5	    3 2	     0
335  *  --------------------------
336  * | 01 | Fan number | Status |
337  *  --------------------------
338  *
339  * The "Fan number" is a 3 bit code allowing for up to 8 fans
340  *
341  * As yet there are no defined fan statuses.
342  *
343  * For example the event code for a failure on fan 3 is:
344  *    LOM_EVENT_FAN_ENCODE(3, 0);
345  */
346 #define	LOM_EVENT_FAN_ENCODE(fanNum, fanStatus) \
347 	(LOM_EVENT_FAN | (fanNum<<3) | ((fanStatus)&0x7))
348 
349 #define	LOM_EVENT_PSU		0x80	/* PSU failure - codes 0x80-0xbf */
350 #define	LOM_EVENT_PSU_MASK	0xc0	/* PSU failure - codes 0x80-0xbf */
351 
352 /*
353  * These definitions will be picked up elsewhere in embedded code
354  */
355 #ifndef LOM_PSU_PRESENT
356 /*
357  * PSU status flags
358  */
359 #define	LOM_PSU_PRESENT		0x08
360 #define	LOM_PSU_INPUT_A_OK	0x01
361 #define	LOM_PSU_INPUT_B_OK	0x02
362 #define	LOM_PSU_OUTPUT_OK	0x04
363 #define	LOM_PSU_STATUS_MASK	(LOM_PSU_INPUT_A_OK | LOM_PSU_INPUT_B_OK | \
364 				LOM_PSU_OUTPUT_OK)
365 #endif
366 
367 /*
368  * PSU events are encoded thus
369  *
370  *  7  6 5	    3		    2		     1		      0
371  *  -------------------------------------------------------------------
372  * | 10 | PSU number | Output Status | Input B Status | Input A Status |
373  *  -------------------------------------------------------------------
374  *
375  * The PSU number is a 3 bit code allowing for up to 8 PSUs
376  *
377  * The PSU status is derived from the LOM_PSU... definitions.
378  *
379  * For example the event code for an "Input B" failure on PSU 2 is:
380  *    LOM_EVENT_PSU_ENCODE(2, LOM_PSU_INPUT_A_OK | LOM_PSU_OUTPUT_OK);
381  */
382 #define	LOM_EVENT_PSU_ENCODE(psuNum, psuStatus) \
383 	(LOM_EVENT_PSU | (psuNum<<3) | ((psuStatus)&0x7))
384 
385 #define	MAX_LOM2_NAME_STR	16
386 
387 #define	LOM_LED_STATE_OFF		0x00
388 #define	LOM_LED_STATE_ON_STEADY		0x01
389 #define	LOM_LED_STATE_ON_FLASHING	0x02
390 #define	LOM_LED_STATE_ON_SLOWFLASH	0x03
391 #define	LOM_LED_STATE_INACCESSIBLE	0xfd
392 #define	LOM_LED_STATE_STANDBY		0xfe
393 #define	LOM_LED_STATE_NOT_PRESENT	0xff
394 
395 enum states {
396 	LOM_LED_OUTOFRANGE = -3,
397 	LOM_LED_NOT_IMPLEMENTED,
398 	LOM_LED_ACCESS_ERROR,
399 	LOM_LED_OFF,
400 	LOM_LED_ON,
401 	LOM_LED_BLINKING
402 };
403 
404 enum colours {
405 	LOM_LED_COLOUR_NONE = -1,
406 	LOM_LED_COLOUR_ANY,
407 	LOM_LED_COLOUR_WHITE,
408 	LOM_LED_COLOUR_BLUE,
409 	LOM_LED_COLOUR_GREEN,
410 	LOM_LED_COLOUR_AMBER
411 };
412 
413 
414 typedef
415 struct {
416 	int on;
417 } lom_fled_info_t;
418 
419 typedef
420 struct {
421 	int16_t index;
422 	int8_t state;
423 	int8_t colour;
424 	char label[MAX_LOM2_NAME_STR];
425 } lom_led_state_t;
426 
427 typedef
428 struct {
429 	char ser_char;
430 	int a3mode;
431 	int fver;
432 	int fchksum;
433 	int prod_rev;
434 	char prod_id[12];
435 	int events;
436 } lom_info_t;
437 
438 typedef
439 struct {
440 	char ser_char;
441 	int a3mode;
442 	int fault_led;
443 	int events;
444 	int check;
445 } lom_ctl_t;
446 
447 /*
448  * in mprog, config is:
449  *  bits 5-7 no. fans
450  *  bits 3-4 no.psus
451  *  bit 2 tty_con
452  *  bit 1 set to stop fault LED flashing
453  *  bit 0 set if DC PSUs fitted
454  *
455  * fanhz is hz for 100% and fanmin is min speed as %.
456  */
457 
458 typedef
459 struct {
460 	char mod_id[12];
461 	int mod_rev;
462 	int config;
463 	int fanhz[4];
464 	int fanmin[4];
465 } lom_mprog_t;
466 
467 typedef
468 struct {
469 	int index;	    /* top bit should be set if last buffer */
470 	uint8_t data[0x400];
471 	int size;
472 } lom_prog_t;
473 
474 /*
475  * LOMlite2 specific support.
476  */
477 
478 #define	LOMIOCCTL2	_IOW('a', 40, lom_ctl2_t)
479 
480 typedef
481 struct {
482 	char  escape_chars[6];
483 	int   serial_events;
484 } lom_ctl2_t;
485 
486 #define	LOM_EVENT_NOREP	0
487 #define	LOM_EVENT_FATAL	1
488 #define	LOM_EVENT_WARN	2
489 #define	LOM_EVENT_INFO	3
490 #define	LOM_EVENT_USER	4
491 #define	LOM_SER_EVENTS_ON	0x100
492 #define	LOM_SER_EVENTS_OFF	0x200
493 #define	LOM_SER_EVENTS_DEF	0x300
494 #define	DEFAULT_NUM_EVENTS	10
495 
496 #define	LOMIOCVOLTS	_IOR('a', 41, lom_volts_t)
497 #define	MAX_VOLTS	16
498 
499 typedef
500 struct {
501 	int   num;  /* No. of voltage lines being monitored on that system */
502 	char  name[MAX_VOLTS][MAX_LOM2_NAME_STR];
503 	int   status[MAX_VOLTS]; /* 0=ok 1=faulty */
504 	int   shutdown_enabled[MAX_VOLTS];
505 } lom_volts_t;
506 
507 /* status flags (circuit breakers) */
508 
509 #define	LOMIOCSTATS	_IOR('a', 42, lom_sflags_t)
510 #define	MAX_STATS	8
511 
512 typedef
513 struct {
514 	int   num;  /* No. of status flags being monitored on that system */
515 	char  name[MAX_STATS][MAX_LOM2_NAME_STR];
516 	int   status[MAX_STATS]; /* 0=ok 1=faulty */
517 } lom_sflags_t;
518 
519 #define	LOMIOCTEMP	_IOR('a', 43, lom_temp_t)
520 #define	MAX_TEMPS	8
521 
522 typedef
523 struct {
524 	int   num;  /* No. of temps being monitored on that system */
525 	char  name[MAX_TEMPS][MAX_LOM2_NAME_STR];
526 	int   temp[MAX_TEMPS]; /* degrees C */
527 	int   warning[MAX_TEMPS]; /* degrees C - zero if not enabled */
528 	int   shutdown[MAX_TEMPS]; /* degrees C - zero if not enabled */
529 	int   num_ov;  /* No. of overtemp sensors being monitored */
530 	char  name_ov[MAX_TEMPS][MAX_LOM2_NAME_STR];
531 	int   status_ov[MAX_TEMPS]; /* 0=ok 1=faulty */
532 } lom_temp_t;
533 
534 #define	LOMIOCCONS	_IOR('a', 44, lom_cbuf_t)
535 #define	CONS_BUF_SIZE	256
536 
537 typedef
538 struct {
539 	char  lrbuf[CONS_BUF_SIZE];
540 } lom_cbuf_t;
541 
542 #define	LOMIOCEVENTLOG2	_IOWR('a', 45, lom_eventlog2_t)
543 #define	MAX_EVENTS	128
544 #define	MAX_EVENT_STR	80
545 
546 /*
547  * NB no need for 1st fatal as the ioctl can ask for ONLY fatal events.
548  * The driver will return the whole event string, but include the code
549  * and time for mgmt applications.
550  */
551 
552 typedef
553 struct {
554 	int   num; /* no. events requested and no. returned */
555 	int   level; /* level of events requested */
556 	int   code[MAX_EVENTS];
557 	char  string[MAX_EVENTS][MAX_EVENT_STR];
558 	int   time[MAX_EVENTS];
559 } lom_eventlog2_t;
560 
561 #define	LOMIOCINFO2	_IOWR('a', 46, lom2_info_t)
562 
563 /*
564  * We may not display all these properties by default, but add them all
565  * into IOCTL structure to cover future enhancements.
566  */
567 
568 typedef
569 struct {
570 	char escape_chars[6];
571 	int  serial_events; /* as defined for LOMIOCCTL2 */
572 	int a3mode;
573 	int fver;
574 	int fchksum;
575 	int prod_rev;
576 	char prod_id[12];
577 	int serial_config; /* security, timeout, etc */
578 	int baud_rate;
579 	int serial_hw_config; /* stop bit, parity etc */
580 	int phone_home_config; /* TRUE is enabled */
581 	char phone_home_script[128];
582 	char fan_names[MAX_FANS][MAX_LOM2_NAME_STR];
583 } lom2_info_t;
584 
585 /* serial_config defn - bottom 8bits are serial return timeout */
586 #define	LOM_SER_SECURITY 0x10000
587 #define	LOM_SER_RETURN	 0x20000
588 #define	LOM_DISABLE_WDOG_BREAK 0x40000
589 
590 /*
591  * For test ioctl low byte is test number and 2nd byte is the argument supplied
592  * with the test.  Usually, it indicates the number of iterations to perform.
593  * The result is returned in the low byte.
594  */
595 #define	BSCV_LED_TEST			0x06
596 #define	BSCV_LED_TEST_FLASH_ALL		0x01
597 #define	BSCV_LED_TEST_SVC_REQD		0x02
598 #define	BSCV_LED_TEST_DONE		0x00
599 #define	LOMIOCTEST	_IOWR('a', 47, uint32_t)
600 
601 #define	LOMIOCMPROG2	_IOW('a', 48, lom2_mprog_t)
602 #define	LOMIOCMREAD2	_IOR('a', 49, lom2_mprog_t)
603 
604 typedef
605 struct {
606 	int   addr_space;
607 	uint8_t	data[255];
608 } lom2_mprog_t;
609 
610 #define	LOMIOCEVNT	_IOWR('a', 50, int)
611 
612 /*
613  * Due to poll being broken in S8su2 add in ioctl to sleep for arg microsecs
614  */
615 
616 #define	LOMIOCSLEEP	_IOWR('a', 51, int)
617 
618 /*
619  * IOCTL defines for lomp - LOMlite field programming driver.
620  */
621 
622 #define	LOMPIOCRESON	_IO('p', 1)
623 #define	LOMPIOCRESOFF	_IO('p', 2)
624 #define	LOMPIOCFVPPON	_IO('p', 3)
625 #define	LOMPIOCFVPPOFF	_IO('p', 4)
626 
627 
628 
629 #ifdef __cplusplus
630 }
631 #endif
632 
633 #endif	/* _SYS_LOM_IO_H */
634