diff options
author | David Gwynne <dlg@cvs.openbsd.org> | 2013-05-03 02:46:29 +0000 |
---|---|---|
committer | David Gwynne <dlg@cvs.openbsd.org> | 2013-05-03 02:46:29 +0000 |
commit | b96ee01cff6107ce802a6cb064af95618434696d (patch) | |
tree | 4714dc281d0beeb40d02ef959eea8d0ffb2932cd /sys/dev/ic | |
parent | 098d9b4375e68e3bd2078f6cf4d512961f0fd731 (diff) |
break out the battery status into excruciating detail. makes it harder for
$VENDOR to complain about a lack of diagnostic material from their crappy
mgmt tools if you're not running an operating system they support.
Diffstat (limited to 'sys/dev/ic')
-rw-r--r-- | sys/dev/ic/mfi.c | 96 | ||||
-rw-r--r-- | sys/dev/ic/mfireg.h | 8 | ||||
-rw-r--r-- | sys/dev/ic/mfivar.h | 3 |
3 files changed, 88 insertions, 19 deletions
diff --git a/sys/dev/ic/mfi.c b/sys/dev/ic/mfi.c index b9b6ead958c..f4da5f89fbd 100644 --- a/sys/dev/ic/mfi.c +++ b/sys/dev/ic/mfi.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mfi.c,v 1.143 2013/05/02 04:35:44 dlg Exp $ */ +/* $OpenBSD: mfi.c,v 1.144 2013/05/03 02:46:28 dlg Exp $ */ /* * Copyright (c) 2006 Marco Peereboom <marco@peereboom.us> * @@ -2022,17 +2022,42 @@ freeme: #ifndef SMALL_KERNEL +static const char *mfi_bbu_indicators[] = { + "pack missing", + "voltage low", + "temp high", + "charge active", + "discharge active", + "learn cycle req'd", + "learn cycle active", + "learn cycle failed", + "learn cycle timeout", + "I2C errors", + "replace pack", + "low capacity", + "periodic learn req'd" +}; + +#define MFI_BBU_SENSORS 4 + int mfi_bbu(struct mfi_softc *sc) { struct mfi_bbu_status bbu; u_int32_t status; u_int32_t mask; + int i; if (mfi_mgmt(sc, MR_DCMD_BBU_GET_STATUS, MFI_DATA_IN, sizeof(bbu), &bbu, NULL) != 0) { - sc->sc_bbu->value = 0; - sc->sc_bbu->status = SENSOR_S_UNKNOWN; + for (i = 0; i < MFI_BBU_SENSORS; i++) { + sc->sc_bbu[i].value = 0; + sc->sc_bbu[i].status = SENSOR_S_UNKNOWN; + } + for (i = 0; i < nitems(mfi_bbu_indicators); i++) { + sc->sc_bbu_status[i].value = 0; + sc->sc_bbu_status[i].status = SENSOR_S_UNKNOWN; + } return (-1); } @@ -2046,15 +2071,34 @@ mfi_bbu(struct mfi_softc *sc) case MFI_BBU_TYPE_NONE: default: - sc->sc_bbu->value = 0; - sc->sc_bbu->status = SENSOR_S_CRIT; + sc->sc_bbu[0].value = 0; + sc->sc_bbu[0].status = SENSOR_S_CRIT; + for (i = 1; i < MFI_BBU_SENSORS; i++) { + sc->sc_bbu[i].value = 0; + sc->sc_bbu[i].status = SENSOR_S_UNKNOWN; + } + for (i = 0; i < nitems(mfi_bbu_indicators); i++) { + sc->sc_bbu_status[i].value = 0; + sc->sc_bbu_status[i].status = SENSOR_S_UNKNOWN; + } return (0); } status = letoh32(bbu.fw_status); - sc->sc_bbu->value = (status & MFI_BBU_STATE_PACK_MISSING) ? 0 : 1; - sc->sc_bbu->status = (status & mask) ? SENSOR_S_CRIT : SENSOR_S_OK; + sc->sc_bbu[0].value = (status & mask) ? 0 : 1; + sc->sc_bbu[0].status = (status & mask) ? SENSOR_S_CRIT : SENSOR_S_OK; + + sc->sc_bbu[1].value = letoh16(bbu.voltage) * 1000; + sc->sc_bbu[2].value = (int16_t)letoh16(bbu.current) * 1000; + sc->sc_bbu[3].value = letoh16(bbu.temperature) * 1000000 + 273150000; + for (i = 1; i < MFI_BBU_SENSORS; i++) + sc->sc_bbu[i].status = SENSOR_S_UNSPEC; + + for (i = 0; i < nitems(mfi_bbu_indicators); i++) { + sc->sc_bbu_status[i].value = (status & (1 << i)) ? 1 : 0; + sc->sc_bbu_status[i].status = SENSOR_S_UNSPEC; + } return (0); } @@ -2070,15 +2114,39 @@ mfi_create_sensors(struct mfi_softc *sc) sizeof(sc->sc_sensordev.xname)); if (ISSET(letoh32(sc->sc_info.mci_adapter_ops ), MFI_INFO_AOPS_BBU)) { - sc->sc_bbu = malloc(sizeof(*sc->sc_bbu), M_DEVBUF, - M_WAITOK | M_ZERO); + sc->sc_bbu = malloc(sizeof(*sc->sc_bbu) * 4, + M_DEVBUF, M_WAITOK | M_ZERO); + + sc->sc_bbu[0].type = SENSOR_INDICATOR; + sc->sc_bbu[0].status = SENSOR_S_UNKNOWN; + strlcpy(sc->sc_bbu[0].desc, "bbu ok", + sizeof(sc->sc_bbu[0].desc)); + sensor_attach(&sc->sc_sensordev, &sc->sc_bbu[0]); + + sc->sc_bbu[1].type = SENSOR_VOLTS_DC; + sc->sc_bbu[1].status = SENSOR_S_UNSPEC; + sc->sc_bbu[2].type = SENSOR_AMPS; + sc->sc_bbu[2].status = SENSOR_S_UNSPEC; + sc->sc_bbu[3].type = SENSOR_TEMP; + sc->sc_bbu[3].status = SENSOR_S_UNSPEC; + for (i = 1; i < MFI_BBU_SENSORS; i++) { + strlcpy(sc->sc_bbu[i].desc, "bbu", + sizeof(sc->sc_bbu[i].desc)); + sensor_attach(&sc->sc_sensordev, &sc->sc_bbu[i]); + } + + sc->sc_bbu_status = malloc(sizeof(*sc->sc_bbu_status) * + sizeof(mfi_bbu_indicators), M_DEVBUF, M_WAITOK | M_ZERO); - sc->sc_bbu->type = SENSOR_INDICATOR; - sc->sc_bbu->status = SENSOR_S_UNKNOWN; - strlcpy(sc->sc_bbu->desc, "Battery Presence", - sizeof(sc->sc_bbu->desc)); + for (i = 0; i < nitems(mfi_bbu_indicators); i++) { + sc->sc_bbu_status[i].type = SENSOR_INDICATOR; + sc->sc_bbu_status[i].status = SENSOR_S_UNSPEC; + strlcpy(sc->sc_bbu_status[i].desc, + mfi_bbu_indicators[i], + sizeof(sc->sc_bbu_status[i].desc)); - sensor_attach(&sc->sc_sensordev, sc->sc_bbu); + sensor_attach(&sc->sc_sensordev, &sc->sc_bbu_status[i]); + } } sc->sc_sensors = malloc(sizeof(struct ksensor) * sc->sc_ld_cnt, diff --git a/sys/dev/ic/mfireg.h b/sys/dev/ic/mfireg.h index 0a7aeffba7b..127f15098ee 100644 --- a/sys/dev/ic/mfireg.h +++ b/sys/dev/ic/mfireg.h @@ -1,4 +1,4 @@ -/* $OpenBSD: mfireg.h,v 1.39 2013/05/01 03:44:22 dlg Exp $ */ +/* $OpenBSD: mfireg.h,v 1.40 2013/05/03 02:46:28 dlg Exp $ */ /* * Copyright (c) 2006 Marco Peereboom <marco@peereboom.us> * @@ -1060,9 +1060,9 @@ struct mfi_bbu_status { #define MFI_BBU_TYPE_IBBU 1 #define MFI_BBU_TYPE_BBU 2 uint8_t reserved; - uint16_t voltage; - int16_t current; - uint16_t temperature; + uint16_t voltage; /* mV */ + int16_t current; /* mA */ + uint16_t temperature; /* degC */ uint32_t fw_status; #define MFI_BBU_STATE_PACK_MISSING (1 << 0) #define MFI_BBU_STATE_VOLTAGE_LOW (1 << 1) diff --git a/sys/dev/ic/mfivar.h b/sys/dev/ic/mfivar.h index 3263fb0d396..cca07c77d7f 100644 --- a/sys/dev/ic/mfivar.h +++ b/sys/dev/ic/mfivar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: mfivar.h,v 1.52 2013/05/01 03:44:22 dlg Exp $ */ +/* $OpenBSD: mfivar.h,v 1.53 2013/05/03 02:46:28 dlg Exp $ */ /* * Copyright (c) 2006 Marco Peereboom <marco@peereboom.us> * @@ -188,6 +188,7 @@ struct mfi_softc { /* sensors */ struct ksensordev sc_sensordev; struct ksensor *sc_bbu; + struct ksensor *sc_bbu_status; struct ksensor *sc_sensors; }; |