diff options
author | David Gwynne <dlg@cvs.openbsd.org> | 2005-08-02 03:35:15 +0000 |
---|---|---|
committer | David Gwynne <dlg@cvs.openbsd.org> | 2005-08-02 03:35:15 +0000 |
commit | 05d67ebf5c1ed3821fac7d4eaf1d7de89bbcefe8 (patch) | |
tree | f064f9da3f6600d6b18bcee0f75b869504f6fbdd | |
parent | 9c7082613d2d387082c3dd874d342712ba649e2d (diff) |
read the rpm of the fans
-rw-r--r-- | sys/scsi/ses.c | 39 | ||||
-rw-r--r-- | sys/scsi/ses.h | 21 |
2 files changed, 54 insertions, 6 deletions
diff --git a/sys/scsi/ses.c b/sys/scsi/ses.c index f1cb620ef7e..0d33388622e 100644 --- a/sys/scsi/ses.c +++ b/sys/scsi/ses.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ses.c,v 1.9 2005/08/01 23:14:31 dlg Exp $ */ +/* $OpenBSD: ses.c,v 1.10 2005/08/02 03:35:14 dlg Exp $ */ /* * Copyright (c) 2005 David Gwynne <dlg@openbsd.org> @@ -90,7 +90,8 @@ 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 *); -int64_t temp2uK(struct ses_status *); +int64_t ses_cool2rpm(struct ses_status *); +int64_t ses_temp2uK(struct ses_status *); #ifdef SES_DEBUG void ses_dump_enc_desc(struct ses_enc_desc *); @@ -343,10 +344,23 @@ ses_make_sensors(struct ses_softc *sc, struct ses_type_desc *types, int ntypes) continue; switch (types[i].type) { + case SES_T_COOLING: + /* + * if the fan is on but not showing an rpm + * then skip it + */ + if ((SES_S_COOL_CODE(status) != + SES_S_COOL_C_STOPPED) && + SES_S_COOL_SPEED(status) == 0) + continue; + + stype = SENSOR_FANRPM; + fmt = "fan%d"; + break; + case SES_T_TEMP: stype = SENSOR_TEMP; fmt = "temp%d"; - break; default: @@ -404,8 +418,12 @@ ses_refresh_sensors(struct ses_softc *sc) sensor->se_stat->f3); switch (sensor->se_type) { + case SES_T_COOLING: + sensor->se_sensor.value = ses_cool2rpm(sensor->se_stat); + break; + case SES_T_TEMP: - sensor->se_sensor.value = temp2uK(sensor->se_stat); + sensor->se_sensor.value = ses_temp2uK(sensor->se_stat); break; default: @@ -418,7 +436,18 @@ ses_refresh_sensors(struct ses_softc *sc) } int64_t -temp2uK(struct ses_status *status) +ses_cool2rpm(struct ses_status *status) +{ + int64_t rpm; + + rpm = (int64_t)SES_S_COOL_SPEED(status); + rpm *= SES_S_COOL_FACTOR; + + return (rpm); +} + +int64_t +ses_temp2uK(struct ses_status *status) { int64_t temp; diff --git a/sys/scsi/ses.h b/sys/scsi/ses.h index 12e6e62ed38..cd54668f0ee 100644 --- a/sys/scsi/ses.h +++ b/sys/scsi/ses.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ses.h,v 1.3 2005/08/01 23:14:31 dlg Exp $ */ +/* $OpenBSD: ses.h,v 1.4 2005/08/02 03:35:14 dlg Exp $ */ /* * Copyright (c) 2005 Marco Peereboom * All rights reserved. @@ -149,6 +149,25 @@ struct ses_status { #define SES_S_DEV_DONOTREM(d) ((d)->f2 & (1<<6)) /* no not remove */ /* XXX FINISH THIS */ +/* cooling element */ +#define SES_S_COOL_IDENT(d) ((d)->f1 & (1<<6)) /* identify */ +#define SES_S_COOL_SPEED_MASK 0x03 +#define SES_S_COOL_SPEED(d) ((d)->f2 + \ + ((u_int16_t)((d)->f2 & SES_S_COOL_SPEED_MASK) << 8)) +#define SES_S_COOL_FACTOR 10 +#define SES_S_COOL_CODE(d) ((d)->f3 & 0x7) /* actual speed code */ +#define SES_S_COOL_C_STOPPED 0x0 /* stopped */ +#define SES_S_COOL_C_LOW1 0x1 /* lowest speed */ +#define SES_S_COOL_C_LOW2 0x2 /* second lowest speed */ +#define SES_S_COOL_C_LOW3 0x3 /* third lowest speed */ +#define SES_S_COOL_C_INTER 0x4 /* intermediate speed */ +#define SES_S_COOL_C_HI3 0x5 /* third highest speed */ +#define SES_S_COOL_C_HI2 0x6 /* second highest speed */ +#define SES_S_COOL_C_HI1 0x7 /* highest speed */ +#define SES_S_COOL_OFF ((d)->f3 & (1<<4)) /* not cooling */ +#define SES_S_COOL_RQSTON ((d)->f3 & (1<<5)) /* manually on */ +#define SES_S_COOL_FAIL ((d)->f3 & (1<<6)) /* fail indic is on */ + /* temperature sensor */ #define SES_S_TEMP_IDENT(d) ((d)->f1 & (1<<7)) /* identify */ #define SES_S_TEMP(d) ((d)->f2) |