envctrl.h 3.4 KB

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