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