summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sys/scsi/ses.c18
-rw-r--r--sys/scsi/ses.h15
2 files changed, 31 insertions, 2 deletions
diff --git a/sys/scsi/ses.c b/sys/scsi/ses.c
index b7c1f245810..c5f123d0e0f 100644
--- a/sys/scsi/ses.c
+++ b/sys/scsi/ses.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ses.c,v 1.11 2005/08/03 15:00:26 dlg Exp $ */
+/* $OpenBSD: ses.c,v 1.12 2005/08/03 15:34:13 dlg Exp $ */
/*
* Copyright (c) 2005 David Gwynne <dlg@openbsd.org>
@@ -90,6 +90,7 @@ int ses_read_status(struct ses_softc *, int refresh);
int ses_make_sensors(struct ses_softc *, struct ses_type_desc *, int);
int ses_refresh_sensors(struct ses_softc *);
+void ses_psu2sensor(struct ses_sensor *);
void ses_cool2sensor(struct ses_sensor *);
void ses_temp2sensor(struct ses_sensor *);
@@ -344,6 +345,11 @@ ses_make_sensors(struct ses_softc *sc, struct ses_type_desc *types, int ntypes)
continue;
switch (types[i].type) {
+ case SES_T_POWERSUPPLY:
+ stype = SENSOR_INDICATOR;
+ fmt = "psu%d";
+ break;
+
case SES_T_COOLING:
stype = SENSOR_FANRPM;
fmt = "fan%d";
@@ -430,6 +436,10 @@ ses_refresh_sensors(struct ses_softc *sc)
}
switch (sensor->se_type) {
+ case SES_T_POWERSUPPLY:
+ ses_psu2sensor(sensor);
+ break;
+
case SES_T_COOLING:
ses_cool2sensor(sensor);
break;
@@ -448,6 +458,12 @@ ses_refresh_sensors(struct ses_softc *sc)
}
void
+ses_psu2sensor(struct ses_sensor *s)
+{
+ s->se_sensor.value = SES_S_PSU_OFF(s->se_stat) ? 0 : 1;
+}
+
+void
ses_cool2sensor(struct ses_sensor *s)
{
s->se_sensor.value = (int64_t)SES_S_COOL_SPEED(s->se_stat);
diff --git a/sys/scsi/ses.h b/sys/scsi/ses.h
index cd54668f0ee..3b6cc5c9028 100644
--- a/sys/scsi/ses.h
+++ b/sys/scsi/ses.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: ses.h,v 1.4 2005/08/02 03:35:14 dlg Exp $ */
+/* $OpenBSD: ses.h,v 1.5 2005/08/03 15:34:13 dlg Exp $ */
/*
* Copyright (c) 2005 Marco Peereboom
* All rights reserved.
@@ -149,6 +149,19 @@ struct ses_status {
#define SES_S_DEV_DONOTREM(d) ((d)->f2 & (1<<6)) /* no not remove */
/* XXX FINISH THIS */
+/* power supply element */
+#define SES_S_PSU_IDENT(d) ((d)->f1 & (1<<6)) /* identify */
+#define SES_S_PSU_DCOC(d) ((d)->f2 & (1<<1)) /* DC over current */
+#define SES_S_PSU_DCUV(d) ((d)->f2 & (1<<2)) /* DC under voltage */
+#define SES_S_PSU_DCOV(d) ((d)->f2 & (1<<3)) /* DC over voltage */
+#define SES_S_PSU_DCFAIL(d) ((d)->f3 & (1<<0)) /* DC fail */
+#define SES_S_PSU_ACFAIL(d) ((d)->f3 & (1<<1)) /* AC fail */
+#define SES_S_PSU_TEMPWARN(d) ((d)->f3 & (1<<2)) /* Temp warn */
+#define SES_S_PSU_OVERTEMP(d) ((d)->f3 & (1<<3)) /* over temp fail */
+#define SES_S_PSU_OFF(d) ((d)->f3 & (1<<4)) /* is the unit off */
+#define SES_S_PSU_RQSTON(d) ((d)->f3 & (1<<5)) /* manually on */
+#define SES_S_PSU_FAIL(d) ((d)->f3 & (1<<6)) /* fail is set on */
+
/* cooling element */
#define SES_S_COOL_IDENT(d) ((d)->f1 & (1<<6)) /* identify */
#define SES_S_COOL_SPEED_MASK 0x03