summaryrefslogtreecommitdiff
path: root/usr/src/uts/common/sys/lom_io.h
blob: 089e5575ed85babdda1062dd2845a832e5788ba9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*
 * Copyright 1999-2002 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 */

#ifndef	_SYS_LOM_IO_H
#define	_SYS_LOM_IO_H

#pragma ident	"%Z%%M%	%I%	%E% SMI"

/*
 * I/O header file for LOMlite Driver.
 */

#ifdef __cplusplus
extern "C" {
#endif

#include <sys/ioccom.h>

/* ioctls for the TSalarm card */

/*
 * commands to access the alarm monitor node
 */

#define	TSIOCNBMON	_IOR('a', 1, int)
#define	TSIOCWTMON	_IOWR('a', 2, int)
#define	TSIOCGETMASK	_IOR('a', 3, int)

/*
 * commands to manipulate the control node
 */

#define	TSIOCALCTL	_IOW('a', 4, ts_aldata_t)
#define	TSIOCALSTATE	_IOWR('a', 5, ts_aldata_t)
#define	TSIOCDOGSTATE	_IOR('a', 6, ts_dogstate_t)
#define	TSIOCDOGCTL	_IOW('a', 7, ts_dogctl_t)
#define	TSIOCDOGTIME	_IOW('a', 8, uint_t)
#define	TSIOCDOGPAT	_IO('a', 9)
#define	TSIOCUNLOCK	_IO('a', 10)

/*
 * Defines for the number of the three alarms
 */

#define	ALARM_NUM_1	1
#define	ALARM_NUM_2	2
#define	ALARM_NUM_3	3

/*
 * command to tell the driver to output debug information. This information
 * includes :
 * - the hardware monitor port (R/O)
 * - in-core monitor status byte
 * - the in-core control port
 * - the watchdog timeout setting
 */
#define	TSIOCDUMP	_IO('a', 11)
#define	TSIOCDBCTL	_IOW('a', 12, ts_dbctl_t)

/*
 * typedefs used in alarm ioctl definitions
 */

typedef
struct {
	int alarm_no;
	int alarm_state;
} ts_aldata_t;

typedef
struct {
	int reset_enable;
	int dog_enable;
} ts_dogctl_t;

typedef
struct {
	int reset_enable;
	int dog_enable;
	uint_t dog_timeout;
} ts_dogstate_t;


typedef
struct {
	int db_timing;
	int db_debug;
} ts_dbctl_t;

#define	MAX_PSUS	3
#define	MAX_FANS	4
#define	NUM_EVENTS	10
#define	NUM_ALARMS	3

/*
 * Defines for the lom_ctl_t events/fault led flag.
 */

#define	OFF	1
#define	ON	2

/*
 * Defines for a3mode.
 */

#define	WATCHDOG	0x02
#define	USER		0x01

/*
 * Defines for PSUSTATE
 */
#define	LOM_PSU_NOACCESS	0x20

/* ioctls for the LOMlite card */

/*
 * old commands to access the monitor node
 */

#define	LOMIOCNBMON	TSIOCNBMON
#define	LOMIOCWTMON	TSIOCWTMON
#define	LOMIOCGETMASK	TSIOCGETMASK

/*
 * old commands to manipulate the control node
 */

#define	LOMIOCALCTL	TSIOCALCTL
#define	LOMIOCALSTATE	TSIOCALSTATE
#define	LOMIOCDOGSTATE	TSIOCDOGSTATE
#define	LOMIOCDOGCTL	TSIOCDOGCTL
#define	LOMIOCDOGTIME	TSIOCDOGTIME
#define	LOMIOCDOGPAT	TSIOCDOGPAT
#define	LOMIOCUNLOCK	TSIOCUNLOCK

/*
 * new commands to access the monitor node
 */

#define	LOMIOCPSUSTATE	_IOR('a', 21, lom_psudata_t)
#define	LOMIOCEVENTLOG	_IOR('a', 22, lom_eventlog_t)
#define	LOMIOCFANSTATE	_IOR('a', 23, lom_fandata_t)
#define	LOMIOCFLEDSTATE _IOR('a', 24, lom_fled_info_t)
#define	LOMIOCINFO	_IOR('a', 25, lom_info_t)

/*
 * new commands to manipulate the control node
 */

#define	LOMIOCCLEARLOG	_IO('a', 26)
#define	LOMIOCCTL	_IOW('a', 27, lom_ctl_t)
#define	LOMIOCPROG	_IOWR('a', 28, lom_prog_t)
#define	LOMIOCDAEMON	_IOWR('a', 29, int)
#define	LOMIOCDMON	_IOWR('a', 30, int)

/*
 * Command to read general purpose LOMlite inputs.
 * There are only 3 bits to general purpose inputs.
 */

#define	LOMIOCGPINPUTS	_IOWR('a', 31, int)

/*
 * Manufacture programming command.
 */

#define	LOMIOCMPROG	_IOW('a', 32, lom_mprog_t)
#define	LOMIOCMREAD	_IOR('a', 33, lom_mprog_t)

#define	LOMIOCLEDSTATE 	_IOR('a', 34, lom_led_state_t)

/*
 * command to tell the driver to output debug information. This information
 * includes :
 * - the hardware monitor port (R/O)
 * - in-core monitor status byte
 * - the in-core control port
 * - the watchdog timeout setting
 */
#define	LOMIOCDUMP	TSIOCDUMP
#define	LOMIOCDBCTL	TSIOCDBCTL

/*
 * typedefs used in LOMlite ioctl definitions
 */

typedef
struct {
	int alarm_no;
	int state;
} lom_aldata_t;

typedef
struct {
	int reset_enable;
	int dog_enable;
} lom_dogctl_t;

typedef
struct {
	int reset_enable;
	int dog_enable;
	uint_t dog_timeout;
} lom_dogstate_t;


typedef
struct {
	int db_timing;
	int db_debug;
} lom_dbctl_t;


typedef
struct {
	int fitted[MAX_PSUS];
	int output[MAX_PSUS];
	int supplya[MAX_PSUS];
	int supplyb[MAX_PSUS];
	int standby[MAX_PSUS];
} lom_psudata_t;

typedef
struct {
	int fitted[MAX_FANS];
	int speed[MAX_FANS];
	int minspeed[MAX_FANS];
} lom_fandata_t;

typedef
struct {
	int events[NUM_EVENTS];
	int fatalevent;
} lom_eventlog_t;

/*
 * The event codes as used in lom_eventlog_t are coded as described here:
 *
 * Event codes encode, in a single byte, the source and type
 * of event/failure in the system.
 *
 * There are two types of failure - fan and PSU.
 *
 * Other events need to be stored but do not constitue faults.
 */
#define	LOM_EVENT_NONE		0x00	/* No fault */
#define	LOM_EVENT_LOST		0x01	/* Event lost due to buffer overflow */
#define	LOM_EVENT_RESET		0x02	/* Reset is asserted by the LOM */
#define	LOM_EVENT_PWR_ON	0x03	/* Power is turned on by the LOM */
#define	LOM_EVENT_PWR_OFF	0x04	/* Power is turned off by the LOM */
#define	LOM_EVENT_WDOG_ON	0x05	/* Host watchdog enabled */
#define	LOM_EVENT_WDOG_OFF	0x06	/* Host watchdog disabled */
#define	LOM_EVENT_WDOG_TRIG	0x07	/* Host watchdog triggered */
#define	LOM_EVENT_LOM_RESET	0x08	/* LOMlite has been reset */
#define	LOM_EVENT_CHECKSUM	0x09	/* ROM checksum failure */
#define	LOM_EVENT_BUSY		0x0a	/* Event not ready yet (being read) */

/*
 * Fault LED events
 */
#define	LOM_EVENT_FAULT		0x20	/* Fault events - codes 0x20-0x2f */
#define	LOM_EVENT_FAULT_MASK	0xf0	/* Fault events - codes 0x20-0x2f */

/*
 * Fault LED events are encoded thus
 *
 *  7	 4 3		       0
 *  ----------------------------
 * | 0010 | Fault LED frequency |
 *  ----------------------------
 *
 * The "Fault LED frequency" is a 4 bit code allowing for LED
 * falshing rates of 0 to 14 Hz with a rate of 15 signifying off.
 *
 * For example the event code for the assertion of a fault LED rate of 2Hz is:
 *    LOM_EVENT_FAULT_ENCODE(2);
 */
#define	LOM_EVENT_FAULT_ENCODE(faultRate) \
	(LOM_EVENT_FAULT | ((faultRate)&0xf))

/*
 * Alarm events
 */
#define	LOM_EVENT_ALARM		0x30	/* Alarm events - codes 0x30-0x3f */
#define	LOM_EVENT_ALARM_MASK	0xf0	/* Alarm events - codes 0x30-0x3f */

/*
 * Alarm events are encoded thus
 *
 *  7	 4 3		1    0
 *  --------------------------
 * | 0011 | Alarm number | On |
 *  --------------------------
 *
 * The "Alarm number" is a 3 bit code allowing for up to 8 alarms
 *
 * For example the event code for the assertion of alarm 2 is:
 *    LOM_EVENT_ALARM_ENCODE(2, 1);
 */
#define	LOM_EVENT_ALARM_ENCODE(alarmNum, alarmOn) \
	(LOM_EVENT_ALARM | (alarmNum<<1) | ((alarmOn)&0x1))

/*
 * These alarms are considered fatal errors
 */

#define	LOM_EVENT_FAN		0x40	/* Fan failure - codes 0x40-0x7f */
#define	LOM_EVENT_FAN_MASK	0xc0	/* Fan failure - codes 0x40-0x7f */

/*
 * Fan events are encoded thus
 *
 *  7  6 5	    3 2	     0
 *  --------------------------
 * | 01 | Fan number | Status |
 *  --------------------------
 *
 * The "Fan number" is a 3 bit code allowing for up to 8 fans
 *
 * As yet there are no defined fan statuses.
 *
 * For example the event code for a failure on fan 3 is:
 *    LOM_EVENT_FAN_ENCODE(3, 0);
 */
#define	LOM_EVENT_FAN_ENCODE(fanNum, fanStatus) \
	(LOM_EVENT_FAN | (fanNum<<3) | ((fanStatus)&0x7))

#define	LOM_EVENT_PSU		0x80	/* PSU failure - codes 0x80-0xbf */
#define	LOM_EVENT_PSU_MASK	0xc0	/* PSU failure - codes 0x80-0xbf */

/*
 * These definitions will be picked up elsewhere in embedded code
 */
#ifndef LOM_PSU_PRESENT
/*
 * PSU status flags
 */
#define	LOM_PSU_PRESENT		0x08
#define	LOM_PSU_INPUT_A_OK	0x01
#define	LOM_PSU_INPUT_B_OK	0x02
#define	LOM_PSU_OUTPUT_OK	0x04
#define	LOM_PSU_STATUS_MASK	(LOM_PSU_INPUT_A_OK | LOM_PSU_INPUT_B_OK | \
				LOM_PSU_OUTPUT_OK)
#endif

/*
 * PSU events are encoded thus
 *
 *  7  6 5	    3		    2		     1		      0
 *  -------------------------------------------------------------------
 * | 10 | PSU number | Output Status | Input B Status | Input A Status |
 *  -------------------------------------------------------------------
 *
 * The PSU number is a 3 bit code allowing for up to 8 PSUs
 *
 * The PSU status is derived from the LOM_PSU... definitions.
 *
 * For example the event code for an "Input B" failure on PSU 2 is:
 *    LOM_EVENT_PSU_ENCODE(2, LOM_PSU_INPUT_A_OK | LOM_PSU_OUTPUT_OK);
 */
#define	LOM_EVENT_PSU_ENCODE(psuNum, psuStatus) \
	(LOM_EVENT_PSU | (psuNum<<3) | ((psuStatus)&0x7))

#define	MAX_LOM2_NAME_STR	16

#define	LOM_LED_STATE_OFF		0x00
#define	LOM_LED_STATE_ON_STEADY		0x01
#define	LOM_LED_STATE_ON_FLASHING	0x02
#define	LOM_LED_STATE_ON_SLOWFLASH	0x03
#define	LOM_LED_STATE_INACCESSIBLE	0xfd
#define	LOM_LED_STATE_STANDBY		0xfe
#define	LOM_LED_STATE_NOT_PRESENT	0xff

enum states {
	LOM_LED_OUTOFRANGE = -3,
	LOM_LED_NOT_IMPLEMENTED,
	LOM_LED_ACCESS_ERROR,
	LOM_LED_OFF,
	LOM_LED_ON,
	LOM_LED_BLINKING
};

enum colours {
	LOM_LED_COLOUR_NONE = -1,
	LOM_LED_COLOUR_ANY,
	LOM_LED_COLOUR_WHITE,
	LOM_LED_COLOUR_BLUE,
	LOM_LED_COLOUR_GREEN,
	LOM_LED_COLOUR_AMBER
};


typedef
struct {
	int on;
} lom_fled_info_t;

typedef
struct {
	int16_t index;
	int8_t state;
	int8_t colour;
	char label[MAX_LOM2_NAME_STR];
} lom_led_state_t;

typedef
struct {
	char ser_char;
	int a3mode;
	int fver;
	int fchksum;
	int prod_rev;
	char prod_id[12];
	int events;
} lom_info_t;

typedef
struct {
	char ser_char;
	int a3mode;
	int fault_led;
	int events;
	int check;
} lom_ctl_t;

/*
 * in mprog, config is:
 *  bits 5-7 no. fans
 *  bits 3-4 no.psus
 *  bit 2 tty_con
 *  bit 1 set to stop fault LED flashing
 *  bit 0 set if DC PSUs fitted
 *
 * fanhz is hz for 100% and fanmin is min speed as %.
 */

typedef
struct {
	char mod_id[12];
	int mod_rev;
	int config;
	int fanhz[4];
	int fanmin[4];
} lom_mprog_t;

typedef
struct {
	int index;	    /* top bit should be set if last buffer */
	uint8_t data[0x400];
	int size;
} lom_prog_t;

/*
 * LOMlite2 specific support.
 */

#define	LOMIOCCTL2	_IOW('a', 40, lom_ctl2_t)

typedef
struct {
	char  escape_chars[6];
	int   serial_events;
} lom_ctl2_t;

#define	LOM_EVENT_NOREP	0
#define	LOM_EVENT_FATAL	1
#define	LOM_EVENT_WARN	2
#define	LOM_EVENT_INFO	3
#define	LOM_EVENT_USER	4
#define	LOM_SER_EVENTS_ON	0x100
#define	LOM_SER_EVENTS_OFF	0x200
#define	LOM_SER_EVENTS_DEF	0x300
#define	DEFAULT_NUM_EVENTS	10

#define	LOMIOCVOLTS	_IOR('a', 41, lom_volts_t)
#define	MAX_VOLTS	16

typedef
struct {
	int   num;  /* No. of voltage lines being monitored on that system */
	char  name[MAX_VOLTS][MAX_LOM2_NAME_STR];
	int   status[MAX_VOLTS]; /* 0=ok 1=faulty */
	int   shutdown_enabled[MAX_VOLTS];
} lom_volts_t;

/* status flags (circuit breakers) */

#define	LOMIOCSTATS	_IOR('a', 42, lom_sflags_t)
#define	MAX_STATS	8

typedef
struct {
	int   num;  /* No. of status flags being monitored on that system */
	char  name[MAX_STATS][MAX_LOM2_NAME_STR];
	int   status[MAX_STATS]; /* 0=ok 1=faulty */
} lom_sflags_t;

#define	LOMIOCTEMP	_IOR('a', 43, lom_temp_t)
#define	MAX_TEMPS	8

typedef
struct {
	int   num;  /* No. of temps being monitored on that system */
	char  name[MAX_TEMPS][MAX_LOM2_NAME_STR];
	int   temp[MAX_TEMPS]; /* degrees C */
	int   warning[MAX_TEMPS]; /* degrees C - zero if not enabled */
	int   shutdown[MAX_TEMPS]; /* degrees C - zero if not enabled */
	int   num_ov;  /* No. of overtemp sensors being monitored */
	char  name_ov[MAX_TEMPS][MAX_LOM2_NAME_STR];
	int   status_ov[MAX_TEMPS]; /* 0=ok 1=faulty */
} lom_temp_t;

#define	LOMIOCCONS	_IOR('a', 44, lom_cbuf_t)
#define	CONS_BUF_SIZE	256

typedef
struct {
	char  lrbuf[CONS_BUF_SIZE];
} lom_cbuf_t;

#define	LOMIOCEVENTLOG2	_IOWR('a', 45, lom_eventlog2_t)
#define	MAX_EVENTS	128
#define	MAX_EVENT_STR	80

/*
 * NB no need for 1st fatal as the ioctl can ask for ONLY fatal events.
 * The driver will return the whole event string, but include the code
 * and time for mgmt applications.
 */

typedef
struct {
	int   num; /* no. events requested and no. returned */
	int   level; /* level of events requested */
	int   code[MAX_EVENTS];
	char  string[MAX_EVENTS][MAX_EVENT_STR];
	int   time[MAX_EVENTS];
} lom_eventlog2_t;

#define	LOMIOCINFO2	_IOWR('a', 46, lom2_info_t)

/*
 * We may not display all these properties by default, but add them all
 * into IOCTL structure to cover future enhancements.
 */

typedef
struct {
	char escape_chars[6];
	int  serial_events; /* as defined for LOMIOCCTL2 */
	int a3mode;
	int fver;
	int fchksum;
	int prod_rev;
	char prod_id[12];
	int serial_config; /* security, timeout, etc */
	int baud_rate;
	int serial_hw_config; /* stop bit, parity etc */
	int phone_home_config; /* TRUE is enabled */
	char phone_home_script[128];
	char fan_names[MAX_FANS][MAX_LOM2_NAME_STR];
} lom2_info_t;

/* serial_config defn - bottom 8bits are serial return timeout */
#define	LOM_SER_SECURITY 0x10000
#define	LOM_SER_RETURN	 0x20000
#define	LOM_DISABLE_WDOG_BREAK 0x40000

/*
 * For test ioctl low byte is test number and 2nd byte is the argument supplied
 * with the test.  Usually, it indicates the number of iterations to perform.
 * The result is returned in the low byte.
 */
#define	BSCV_LED_TEST			0x06
#define	BSCV_LED_TEST_FLASH_ALL		0x01
#define	BSCV_LED_TEST_SVC_REQD		0x02
#define	BSCV_LED_TEST_DONE		0x00
#define	LOMIOCTEST	_IOWR('a', 47, uint32_t)

#define	LOMIOCMPROG2	_IOW('a', 48, lom2_mprog_t)
#define	LOMIOCMREAD2	_IOR('a', 49, lom2_mprog_t)

typedef
struct {
	int   addr_space;
	uint8_t	data[255];
} lom2_mprog_t;

#define	LOMIOCEVNT	_IOWR('a', 50, int)

/*
 * Due to poll being broken in S8su2 add in ioctl to sleep for arg microsecs
 */

#define	LOMIOCSLEEP	_IOWR('a', 51, int)

/*
 * IOCTL defines for lomp - LOMlite field programming driver.
 */

#define	LOMPIOCRESON	_IO('p', 1)
#define	LOMPIOCRESOFF	_IO('p', 2)
#define	LOMPIOCFVPPON	_IO('p', 3)
#define	LOMPIOCFVPPOFF	_IO('p', 4)



#ifdef __cplusplus
}
#endif

#endif	/* _SYS_LOM_IO_H */