summaryrefslogtreecommitdiff
path: root/usr/src/uts/common/sys/sensors.h
diff options
context:
space:
mode:
authorDan McDonald <danmcd@joyent.com>2020-09-22 10:39:49 -0400
committerDan McDonald <danmcd@joyent.com>2020-09-22 10:39:49 -0400
commit267e12a7d9bf6e5fcefb9cc00f46bfff0dc5226e (patch)
tree19a3941920d0039c35d53a5cbee189b5ca51995a /usr/src/uts/common/sys/sensors.h
parent517abc5c668925e6092495bf332233c3599980d2 (diff)
parente9faba760cdf80d7dfa110fe0830917ab94668c2 (diff)
downloadillumos-joyent-vpc.tar.gz
Merge branch 'master' into vpcvpc
Diffstat (limited to 'usr/src/uts/common/sys/sensors.h')
-rw-r--r--usr/src/uts/common/sys/sensors.h62
1 files changed, 36 insertions, 26 deletions
diff --git a/usr/src/uts/common/sys/sensors.h b/usr/src/uts/common/sys/sensors.h
index a39dfca239..a5d830a933 100644
--- a/usr/src/uts/common/sys/sensors.h
+++ b/usr/src/uts/common/sys/sensors.h
@@ -33,6 +33,8 @@ extern "C" {
*/
#define SENSOR_KIND_UNKNOWN 0x00
#define SENSOR_KIND_TEMPERATURE 0x01
+#define SENSOR_KIND_VOLTAGE 0x02
+#define SENSOR_KIND_CURRENT 0x03
/*
* Lists of units that senors may have.
@@ -41,52 +43,60 @@ extern "C" {
#define SENSOR_UNIT_CELSIUS 0x01
#define SENSOR_UNIT_FAHRENHEIT 0x02
#define SENSOR_UNIT_KELVIN 0x03
+#define SENSOR_UNIT_VOLTS 0x04
+#define SENSOR_UNIT_AMPS 0x05
#define SENSOR_IOCTL (('s' << 24) | ('e' << 16) | ('n' << 8))
/*
* Ask the sensor what kind of sensor it is.
*/
-#define SENSOR_IOCTL_TYPE (SENSOR_IOCTL | 0x01)
+#define SENSOR_IOCTL_KIND (SENSOR_IOCTL | 0x01)
typedef struct sensor_ioctl_kind {
uint64_t sik_kind;
} sensor_ioctl_kind_t;
/*
- * Ask the sensor for a temperature measurement. The sensor is responsible for
- * returning the units it's in. A temperature measurement is broken down into a
+ * Ask the sensor for a scalar measurement. The sensor is responsible for
+ * returning the units it's in. A scalar measurement is broken down into a
* signed value and a notion of its granularity. The sit_gran member indicates
- * the granularity: the number of increments per degree in the temperature
- * measurement (the sit_temp member). sit_gran is signed and the sign indicates
- * whether one needs to multiply or divide the granularity. For example, a
- * value that set sit_gran to 10 would mean that the value in sit_temp was in
- * 10ths of a degree and that to get the actual value in degrees, one would
- * divide by 10. On the other hand, a negative value means that we effectively
- * have to multiply to get there. For example, a value of -2 would indicate that
- * each value in sit_temp indicated two degrees and to get the temperature in
- * degrees you would multiply sit_temp by two.
+ * the granularity: the number of increments per unit in the measurement (the
+ * sit_value member). sit_gran is signed and the sign indicates whether one
+ * needs to multiply or divide the granularity. The sit_prec member describes a
+ * +/- value (taking sit_gran into account) that describes the precision of the
+ * sensor.
+ *
+ * For example, consider a temperature sensor that set sit_gran to 10. This
+ * would mean that the value in sit_value was in 10ths of a degree and that to
+ * get the actual value in degrees, one would divide by 10. On the other hand, a
+ * negative value means that we effectively have to multiply to get there. For
+ * example, a value of -2 would indicate that each value in sit_value indicated
+ * two degrees and to get the temperature in degrees you would multiply
+ * sit_value * by two.
*/
-#define SENSOR_IOCTL_TEMPERATURE (SENSOR_IOCTL | 0x02)
+#define SENSOR_IOCTL_SCALAR (SENSOR_IOCTL | 0x02)
-typedef struct sensor_ioctl_temperature {
- uint32_t sit_unit;
- int32_t sit_gran;
- uint32_t sit_prec;
- uint32_t sit_pad;
- int64_t sit_temp;
-} sensor_ioctl_temperature_t;
+typedef struct sensor_ioctl_scalar {
+ uint32_t sis_unit;
+ int32_t sis_gran;
+ uint32_t sis_prec;
+ uint32_t sis_pad;
+ int64_t sis_value;
+} sensor_ioctl_scalar_t;
#ifdef _KERNEL
typedef int (*ksensor_kind_f)(void *, sensor_ioctl_kind_t *);
-typedef int (*ksensor_temp_f)(void *, sensor_ioctl_temperature_t *);
+typedef int (*ksensor_scalar_f)(void *, sensor_ioctl_scalar_t *);
typedef struct {
- ksensor_kind_f kso_kind;
- ksensor_temp_f kso_temp;
+ ksensor_kind_f kso_kind;
+ ksensor_scalar_f kso_scalar;
} ksensor_ops_t;
extern int ksensor_kind_temperature(void *, sensor_ioctl_kind_t *);
+extern int ksensor_kind_voltage(void *, sensor_ioctl_kind_t *);
+extern int ksensor_kind_current(void *, sensor_ioctl_kind_t *);
/*
* Create a sensor where the class and name is supplied.
@@ -95,11 +105,11 @@ extern int ksensor_create(dev_info_t *, const ksensor_ops_t *, void *,
const char *, const char *, id_t *);
/*
- * Create a temperature sensor for a PCI device. If this is not a device-wide
+ * Create a scalar sensor for a PCI device. If this is not a device-wide
* (e.g. per-function) sensor, this should not be used.
*/
-extern int ksensor_create_temp_pcidev(dev_info_t *, const ksensor_ops_t *,
- void *, const char *, id_t *);
+extern int ksensor_create_scalar_pcidev(dev_info_t *, uint_t,
+ const ksensor_ops_t *, void *, const char *, id_t *);
/*
* Remove a named or all sensors from this driver.