Module Name: src Committed By: snj Date: Sat Jan 9 01:30:14 UTC 2010
Modified Files: src/share/man/man4/man4.sparc64 [netbsd-5]: lom.4 src/sys/arch/sparc64/dev [netbsd-5]: lom.c Log Message: Pull up following revision(s) (requested by nakayama in ticket #1216): share/man/man4/man4.sparc64/lom.4: revision 1.4 sys/arch/sparc64/dev/lom.c: revision 1.5 Make fault LED and alarms status changeable via sysctl(8). The sysctl entries are created under the hw.lomN MIB. To generate a diff of this commit: cvs rdiff -u -r1.2.2.3 -r1.2.2.4 src/share/man/man4/man4.sparc64/lom.4 cvs rdiff -u -r1.1.2.4 -r1.1.2.5 src/sys/arch/sparc64/dev/lom.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/share/man/man4/man4.sparc64/lom.4 diff -u src/share/man/man4/man4.sparc64/lom.4:1.2.2.3 src/share/man/man4/man4.sparc64/lom.4:1.2.2.4 --- src/share/man/man4/man4.sparc64/lom.4:1.2.2.3 Sat Nov 28 15:55:14 2009 +++ src/share/man/man4/man4.sparc64/lom.4 Sat Jan 9 01:30:13 2010 @@ -1,4 +1,4 @@ -.\" $NetBSD: lom.4,v 1.2.2.3 2009/11/28 15:55:14 bouyer Exp $ +.\" $NetBSD: lom.4,v 1.2.2.4 2010/01/09 01:30:13 snj Exp $ .\" $OpenBSD: lom.4,v 1.4 2009/09/23 22:08:07 kettenis Exp $ .\" .\" Copyright (c) 2009 Mark Kettenis <kette...@openbsd.org> @@ -15,7 +15,7 @@ .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd November 28, 2009 +.Dd December 28, 2009 .Dt LOM 4 sparc64 .Os .Sh NAME @@ -38,6 +38,15 @@ interface. The watchdog timer supports timeouts between 1 and 126 seconds. .Pp +Fault LED and alarms status can be changed through the +.Xr sysctl 8 +interface. +An entry for the +.Nm +driver is created under the +.Va hw.lom Ns Em N +MIB. +.Pp The .Nm driver will update the hostname stored in the LOM whenever the @@ -46,6 +55,7 @@ .Xr hostname 1 , .Xr envsys 4 , .Xr envstat 8 , +.Xr sysctl 8 , .Xr wdogctl 8 .Sh HISTORY The Index: src/sys/arch/sparc64/dev/lom.c diff -u src/sys/arch/sparc64/dev/lom.c:1.1.2.4 src/sys/arch/sparc64/dev/lom.c:1.1.2.5 --- src/sys/arch/sparc64/dev/lom.c:1.1.2.4 Fri Dec 18 06:03:51 2009 +++ src/sys/arch/sparc64/dev/lom.c Sat Jan 9 01:30:13 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: lom.c,v 1.1.2.4 2009/12/18 06:03:51 snj Exp $ */ +/* $NetBSD: lom.c,v 1.1.2.5 2010/01/09 01:30:13 snj Exp $ */ /* $OpenBSD: lom.c,v 1.20 2009/12/12 13:01:00 kettenis Exp $ */ /* * Copyright (c) 2009 Mark Kettenis @@ -17,7 +17,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: lom.c,v 1.1.2.4 2009/12/18 06:03:51 snj Exp $"); +__KERNEL_RCSID(0, "$NetBSD: lom.c,v 1.1.2.5 2010/01/09 01:30:13 snj Exp $"); #include <sys/param.h> #include <sys/device.h> @@ -26,6 +26,7 @@ #include <sys/envsys.h> #include <sys/systm.h> #include <sys/callout.h> +#include <sys/sysctl.h> #include <machine/autoconf.h> @@ -168,6 +169,8 @@ int sc_num_psu; int sc_num_temp; + int32_t sc_sysctl_num[LOM_MAX_ALARM]; + uint8_t sc_fan_cal[LOM_MAX_FAN]; uint8_t sc_fan_low[LOM_MAX_FAN]; @@ -222,6 +225,17 @@ static bool lom_shutdown(device_t, int); +SYSCTL_SETUP_PROTO(sysctl_lom_setup); +static int lom_sysctl_alarm(SYSCTLFN_PROTO); + +static int hw_node = CTL_EOL; +static const char *nodename[LOM_MAX_ALARM] = + { "fault_led", "alarm1", "alarm2", "alarm3" }; +#ifdef SYSCTL_INCLUDE_DESCR +static const char *nodedesc[LOM_MAX_ALARM] = + { "Fault LED status", "Alarm1 status", "Alarm2 status ", "Alarm3 status" }; +#endif + static int lom_match(device_t parent, cfdata_t match, void *aux) { @@ -242,6 +256,7 @@ uint8_t reg, fw_rev, config, config2, config3; uint8_t cal, low; int i; + const struct sysctlnode *node = NULL, *newnode; if (strcmp(ea->ea_name, "SUNW,lomh") == 0) { if (ea->ea_nintr < 1) { @@ -315,6 +330,12 @@ sc->sc_fan_low[i] = low; } + /* Setup our sysctl subtree, hw.lomN */ + if (hw_node != CTL_EOL) + sysctl_createv(NULL, 0, NULL, &node, + 0, CTLTYPE_NODE, device_xname(self), NULL, + NULL, 0, NULL, 0, CTL_HW, CTL_CREATE, CTL_EOL); + /* Initialize sensor data. */ sc->sc_sme = sysmon_envsys_create(); for (i = 0; i < sc->sc_num_alarm; i++) { @@ -326,6 +347,17 @@ aprint_error_dev(self, "can't attach alarm sensor\n"); return; } + if (node != NULL) { + sysctl_createv(NULL, 0, NULL, &newnode, + CTLFLAG_READWRITE, CTLTYPE_INT, nodename[i], + SYSCTL_DESCR(nodedesc[i]), + lom_sysctl_alarm, 0, sc, 0, + CTL_HW, node->sysctl_num, CTL_CREATE, CTL_EOL); + if (newnode != NULL) + sc->sc_sysctl_num[i] = newnode->sysctl_num; + else + sc->sc_sysctl_num[i] = 0; + } } for (i = 0; i < sc->sc_num_fan; i++) { sc->sc_fan[i].units = ENVSYS_SFANRPM; @@ -1084,3 +1116,62 @@ lom_write(sc, LOM_IDX_WDOG_CTL, sc->sc_wdog_ctl); return true; } + +SYSCTL_SETUP(sysctl_lom_setup, "sysctl hw.lom subtree setup") +{ + const struct sysctlnode *node; + + if (sysctl_createv(clog, 0, NULL, &node, + CTLFLAG_PERMANENT, CTLTYPE_NODE, "hw", NULL, + NULL, 0, NULL, 0, CTL_HW, CTL_EOL) != 0) + return; + + hw_node = node->sysctl_num; +} + +static int +lom_sysctl_alarm(SYSCTLFN_ARGS) +{ + struct sysctlnode node; + struct lom_softc *sc; + int i, tmp, error; + uint8_t val; + + node = *rnode; + sc = node.sysctl_data; + + for (i = 0; i < sc->sc_num_alarm; i++) { + if (node.sysctl_num == sc->sc_sysctl_num[i]) { + tmp = sc->sc_alarm[i].value_cur; + node.sysctl_data = &tmp; + error = sysctl_lookup(SYSCTLFN_CALL(&node)); + if (error || newp == NULL) + return error; + if (tmp < 0 || tmp > 1) + return EINVAL; + + if (lom_read(sc, LOM_IDX_ALARM, &val)) + return EINVAL; + if (i == 0) { + /* Fault LED */ + if (tmp != 0) + val &= ~LOM_ALARM_FAULT; + else + val |= LOM_ALARM_FAULT; + } else { + /* Alarms */ + if (tmp != 0) + val |= LOM_ALARM_1 << (i - 1); + else + val &= ~(LOM_ALARM_1 << (i - 1)); + } + if (lom_write(sc, LOM_IDX_ALARM, val)) + return EINVAL; + + sc->sc_alarm[i].value_cur = tmp; + return 0; + } + } + + return ENOENT; +}