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