1 /* $Id: envctrl.h,v 1.3 2000/11/03 00:37:40 davem Exp $
2  *
3  * envctrl.h: Definitions for access to the i2c environment
4  *            monitoring on Ultrasparc systems.
5  *
6  * Copyright (C) 1998  Eddie C. Dost  (ecd@skynet.be)
7  * Copyright (C) 2000  Vinh Truong  (vinh.truong@eng.sun.com)
8  * VT - Add all ioctl commands and environment status definitions
9  * VT - Add application note
10  */
11 #ifndef _SPARC64_ENVCTRL_H
12 #define _SPARC64_ENVCTRL_H 1
13 
14 #include <linux/ioctl.h>
15 
16 /* Application note:
17  *
18  * The driver supports 4 operations: open(), close(), ioctl(), read()
19  * The device name is /dev/envctrl.
20  * Below is sample usage:
21  *
22  *	fd = open("/dev/envtrl", O_RDONLY);
23  *	if (ioctl(fd, ENVCTRL_READ_SHUTDOWN_TEMPERATURE, 0) < 0)
24  *		printf("error\n");
25  *	ret = read(fd, buf, 10);
26  *	close(fd);
27  *
28  * Notice in the case of cpu voltage and temperature, the default is
29  * cpu0.  If we need to know the info of cpu1, cpu2, cpu3, we need to
30  * pass in cpu number in ioctl() last parameter.  For example, to
31  * get the voltage of cpu2:
32  *
33  *	ioctlbuf[0] = 2;
34  *	if (ioctl(fd, ENVCTRL_READ_CPU_VOLTAGE, ioctlbuf) < 0)
35  *		printf("error\n");
36  *	ret = read(fd, buf, 10);
37  *
38  * All the return values are in ascii.  So check read return value
39  * and do appropriate conversions in your application.
40  */
41 
42 /* IOCTL commands */
43 
44 /* Note: these commands reflect possible monitor features.
45  * Some boards choose to support some of the features only.
46  */
47 #define ENVCTRL_RD_CPU_TEMPERATURE	_IOR('p', 0x40, int)
48 #define ENVCTRL_RD_CPU_VOLTAGE		_IOR('p', 0x41, int)
49 #define ENVCTRL_RD_FAN_STATUS		_IOR('p', 0x42, int)
50 #define ENVCTRL_RD_WARNING_TEMPERATURE	_IOR('p', 0x43, int)
51 #define ENVCTRL_RD_SHUTDOWN_TEMPERATURE	_IOR('p', 0x44, int)
52 #define ENVCTRL_RD_VOLTAGE_STATUS	_IOR('p', 0x45, int)
53 #define ENVCTRL_RD_SCSI_TEMPERATURE	_IOR('p', 0x46, int)
54 #define ENVCTRL_RD_ETHERNET_TEMPERATURE	_IOR('p', 0x47, int)
55 #define ENVCTRL_RD_MTHRBD_TEMPERATURE	_IOR('p', 0x48, int)
56 
57 #define ENVCTRL_RD_GLOBALADDRESS	_IOR('p', 0x49, int)
58 
59 /* Read return values for a voltage status request. */
60 #define ENVCTRL_VOLTAGE_POWERSUPPLY_GOOD	0x01
61 #define ENVCTRL_VOLTAGE_BAD			0x02
62 #define ENVCTRL_POWERSUPPLY_BAD			0x03
63 #define ENVCTRL_VOLTAGE_POWERSUPPLY_BAD		0x04
64 
65 /* Read return values for a fan status request.
66  * A failure match means either the fan fails or
67  * the fan is not connected.  Some boards have optional
68  * connectors to connect extra fans.
69  *
70  * There are maximum 8 monitor fans.  Some are cpu fans
71  * some are system fans.  The mask below only indicates
72  * fan by order number.
73  * Below is a sample application:
74  *
75  *	if (ioctl(fd, ENVCTRL_READ_FAN_STATUS, 0) < 0) {
76  *		printf("ioctl fan failed\n");
77  *	}
78  *	if (read(fd, rslt, 1) <= 0) {
79  *		printf("error or fan not monitored\n");
80  *	} else {
81  *		if (rslt[0] == ENVCTRL_ALL_FANS_GOOD) {
82  *			printf("all fans good\n");
83  *	} else if (rslt[0] == ENVCTRL_ALL_FANS_BAD) {
84  *		printf("all fans bad\n");
85  *	} else {
86  *		if (rslt[0] & ENVCTRL_FAN0_FAILURE_MASK) {
87  *			printf("fan 0 failed or not connected\n");
88  *	}
89  *	......
90  */
91 
92 #define ENVCTRL_ALL_FANS_GOOD			0x00
93 #define ENVCTRL_FAN0_FAILURE_MASK		0x01
94 #define ENVCTRL_FAN1_FAILURE_MASK		0x02
95 #define ENVCTRL_FAN2_FAILURE_MASK		0x04
96 #define ENVCTRL_FAN3_FAILURE_MASK		0x08
97 #define ENVCTRL_FAN4_FAILURE_MASK		0x10
98 #define ENVCTRL_FAN5_FAILURE_MASK		0x20
99 #define ENVCTRL_FAN6_FAILURE_MASK		0x40
100 #define ENVCTRL_FAN7_FAILURE_MASK		0x80
101 #define ENVCTRL_ALL_FANS_BAD 			0xFF
102 
103 #endif /* !(_SPARC64_ENVCTRL_H) */
104