xref: /linux/arch/sparc/include/uapi/asm/envctrl.h (revision 498495dba268b20e8eadd7fe93c140c68b6cc9d2)
1*6f52b16cSGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
254579826SDavid Howells /*
354579826SDavid Howells  *
454579826SDavid Howells  * envctrl.h: Definitions for access to the i2c environment
554579826SDavid Howells  *            monitoring on Ultrasparc systems.
654579826SDavid Howells  *
754579826SDavid Howells  * Copyright (C) 1998  Eddie C. Dost  (ecd@skynet.be)
854579826SDavid Howells  * Copyright (C) 2000  Vinh Truong  (vinh.truong@eng.sun.com)
954579826SDavid Howells  * VT - Add all ioctl commands and environment status definitions
1054579826SDavid Howells  * VT - Add application note
1154579826SDavid Howells  */
1254579826SDavid Howells #ifndef _SPARC64_ENVCTRL_H
1354579826SDavid Howells #define _SPARC64_ENVCTRL_H 1
1454579826SDavid Howells 
1554579826SDavid Howells #include <linux/ioctl.h>
1654579826SDavid Howells 
1754579826SDavid Howells /* Application note:
1854579826SDavid Howells  *
1954579826SDavid Howells  * The driver supports 4 operations: open(), close(), ioctl(), read()
2054579826SDavid Howells  * The device name is /dev/envctrl.
2154579826SDavid Howells  * Below is sample usage:
2254579826SDavid Howells  *
2354579826SDavid Howells  *	fd = open("/dev/envtrl", O_RDONLY);
2454579826SDavid Howells  *	if (ioctl(fd, ENVCTRL_READ_SHUTDOWN_TEMPERATURE, 0) < 0)
2554579826SDavid Howells  *		printf("error\n");
2654579826SDavid Howells  *	ret = read(fd, buf, 10);
2754579826SDavid Howells  *	close(fd);
2854579826SDavid Howells  *
2954579826SDavid Howells  * Notice in the case of cpu voltage and temperature, the default is
3054579826SDavid Howells  * cpu0.  If we need to know the info of cpu1, cpu2, cpu3, we need to
3154579826SDavid Howells  * pass in cpu number in ioctl() last parameter.  For example, to
3254579826SDavid Howells  * get the voltage of cpu2:
3354579826SDavid Howells  *
3454579826SDavid Howells  *	ioctlbuf[0] = 2;
3554579826SDavid Howells  *	if (ioctl(fd, ENVCTRL_READ_CPU_VOLTAGE, ioctlbuf) < 0)
3654579826SDavid Howells  *		printf("error\n");
3754579826SDavid Howells  *	ret = read(fd, buf, 10);
3854579826SDavid Howells  *
3954579826SDavid Howells  * All the return values are in ascii.  So check read return value
4054579826SDavid Howells  * and do appropriate conversions in your application.
4154579826SDavid Howells  */
4254579826SDavid Howells 
4354579826SDavid Howells /* IOCTL commands */
4454579826SDavid Howells 
4554579826SDavid Howells /* Note: these commands reflect possible monitor features.
4654579826SDavid Howells  * Some boards choose to support some of the features only.
4754579826SDavid Howells  */
4854579826SDavid Howells #define ENVCTRL_RD_CPU_TEMPERATURE	_IOR('p', 0x40, int)
4954579826SDavid Howells #define ENVCTRL_RD_CPU_VOLTAGE		_IOR('p', 0x41, int)
5054579826SDavid Howells #define ENVCTRL_RD_FAN_STATUS		_IOR('p', 0x42, int)
5154579826SDavid Howells #define ENVCTRL_RD_WARNING_TEMPERATURE	_IOR('p', 0x43, int)
5254579826SDavid Howells #define ENVCTRL_RD_SHUTDOWN_TEMPERATURE	_IOR('p', 0x44, int)
5354579826SDavid Howells #define ENVCTRL_RD_VOLTAGE_STATUS	_IOR('p', 0x45, int)
5454579826SDavid Howells #define ENVCTRL_RD_SCSI_TEMPERATURE	_IOR('p', 0x46, int)
5554579826SDavid Howells #define ENVCTRL_RD_ETHERNET_TEMPERATURE	_IOR('p', 0x47, int)
5654579826SDavid Howells #define ENVCTRL_RD_MTHRBD_TEMPERATURE	_IOR('p', 0x48, int)
5754579826SDavid Howells 
5854579826SDavid Howells #define ENVCTRL_RD_GLOBALADDRESS	_IOR('p', 0x49, int)
5954579826SDavid Howells 
6054579826SDavid Howells /* Read return values for a voltage status request. */
6154579826SDavid Howells #define ENVCTRL_VOLTAGE_POWERSUPPLY_GOOD	0x01
6254579826SDavid Howells #define ENVCTRL_VOLTAGE_BAD			0x02
6354579826SDavid Howells #define ENVCTRL_POWERSUPPLY_BAD			0x03
6454579826SDavid Howells #define ENVCTRL_VOLTAGE_POWERSUPPLY_BAD		0x04
6554579826SDavid Howells 
6654579826SDavid Howells /* Read return values for a fan status request.
6754579826SDavid Howells  * A failure match means either the fan fails or
6854579826SDavid Howells  * the fan is not connected.  Some boards have optional
6954579826SDavid Howells  * connectors to connect extra fans.
7054579826SDavid Howells  *
7154579826SDavid Howells  * There are maximum 8 monitor fans.  Some are cpu fans
7254579826SDavid Howells  * some are system fans.  The mask below only indicates
7354579826SDavid Howells  * fan by order number.
7454579826SDavid Howells  * Below is a sample application:
7554579826SDavid Howells  *
7654579826SDavid Howells  *	if (ioctl(fd, ENVCTRL_READ_FAN_STATUS, 0) < 0) {
7754579826SDavid Howells  *		printf("ioctl fan failed\n");
7854579826SDavid Howells  *	}
7954579826SDavid Howells  *	if (read(fd, rslt, 1) <= 0) {
8054579826SDavid Howells  *		printf("error or fan not monitored\n");
8154579826SDavid Howells  *	} else {
8254579826SDavid Howells  *		if (rslt[0] == ENVCTRL_ALL_FANS_GOOD) {
8354579826SDavid Howells  *			printf("all fans good\n");
8454579826SDavid Howells  *	} else if (rslt[0] == ENVCTRL_ALL_FANS_BAD) {
8554579826SDavid Howells  *		printf("all fans bad\n");
8654579826SDavid Howells  *	} else {
8754579826SDavid Howells  *		if (rslt[0] & ENVCTRL_FAN0_FAILURE_MASK) {
8854579826SDavid Howells  *			printf("fan 0 failed or not connected\n");
8954579826SDavid Howells  *	}
9054579826SDavid Howells  *	......
9154579826SDavid Howells  */
9254579826SDavid Howells 
9354579826SDavid Howells #define ENVCTRL_ALL_FANS_GOOD			0x00
9454579826SDavid Howells #define ENVCTRL_FAN0_FAILURE_MASK		0x01
9554579826SDavid Howells #define ENVCTRL_FAN1_FAILURE_MASK		0x02
9654579826SDavid Howells #define ENVCTRL_FAN2_FAILURE_MASK		0x04
9754579826SDavid Howells #define ENVCTRL_FAN3_FAILURE_MASK		0x08
9854579826SDavid Howells #define ENVCTRL_FAN4_FAILURE_MASK		0x10
9954579826SDavid Howells #define ENVCTRL_FAN5_FAILURE_MASK		0x20
10054579826SDavid Howells #define ENVCTRL_FAN6_FAILURE_MASK		0x40
10154579826SDavid Howells #define ENVCTRL_FAN7_FAILURE_MASK		0x80
10254579826SDavid Howells #define ENVCTRL_ALL_FANS_BAD 			0xFF
10354579826SDavid Howells 
10454579826SDavid Howells #endif /* !(_SPARC64_ENVCTRL_H) */
105