envctrl.h 3.4 KB

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