Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/macppc/dev make thermal zone parameters configurabl...
details: https://anonhg.NetBSD.org/src/rev/d72b744eb00f
branches: trunk
changeset: 984906:d72b744eb00f
user: macallan <macallan%NetBSD.org@localhost>
date: Fri Jul 30 22:07:14 2021 +0000
description:
make thermal zone parameters configurable by sysctl
diffstat:
sys/arch/macppc/dev/fancontrol.c | 45 +++++++++++++++++++++++++++++++++++-
sys/arch/macppc/dev/fancontrolvar.h | 3 +-
sys/arch/macppc/dev/fcu.c | 32 ++++++++++++++++++--------
3 files changed, 67 insertions(+), 13 deletions(-)
diffs (188 lines):
diff -r a75ee87d93d8 -r d72b744eb00f sys/arch/macppc/dev/fancontrol.c
--- a/sys/arch/macppc/dev/fancontrol.c Fri Jul 30 21:29:00 2021 +0000
+++ b/sys/arch/macppc/dev/fancontrol.c Fri Jul 30 22:07:14 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: fancontrol.c,v 1.2 2021/07/28 00:36:00 macallan Exp $ */
+/* $NetBSD: fancontrol.c,v 1.3 2021/07/30 22:07:14 macallan Exp $ */
/*-
* Copyright (c) 2021 Michael Lorenz
@@ -27,13 +27,14 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: fancontrol.c,v 1.2 2021/07/28 00:36:00 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fancontrol.c,v 1.3 2021/07/30 22:07:14 macallan Exp $");
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/device.h>
#include <sys/conf.h>
#include <sys/bus.h>
+#include <sys/sysctl.h>
#include <dev/sysmon/sysmonvar.h>
#include <macppc/dev/fancontrolvar.h>
@@ -60,6 +61,10 @@
return -1;
}
+ if (z->Tmin < 30) z->Tmin = 30;
+ if (z->Tmin > 60) z->Tmin = 60;
+ if (z->Tmax > 95) z->Tmax = 95;
+ if (z->Tmax < (z->Tmin + 10)) z->Tmax = z->Tmin + 10;
temp = (temp - 273150000) / 1000000;
diff = temp - z->Tmin;
DPRINTF("%s %d %d\n", z->name, temp, z->Tmin);
@@ -76,3 +81,39 @@
}
return 0;
}
+
+int
+fancontrol_init_zone(fancontrol_zone_t *z, struct sysctlnode *me)
+{
+ struct sysctlnode *zone_node, *node;
+
+ if (z->nfans <= 0) return 0;
+
+ sysctl_createv(NULL, 0, NULL, (void *) &zone_node,
+ CTLFLAG_READWRITE | CTLFLAG_OWNDESC,
+ CTLTYPE_NODE, z->name, NULL,
+ NULL, 0, NULL, 0,
+ CTL_MACHDEP,
+ me->sysctl_num,
+ CTL_CREATE, CTL_EOL);
+
+ sysctl_createv(NULL, 0, NULL, (void *) &node,
+ CTLFLAG_READWRITE | CTLFLAG_OWNDESC,
+ CTLTYPE_INT, "Tmin", "minimum temperature",
+ NULL, 0, (void *)&z->Tmin, 0,
+ CTL_MACHDEP,
+ me->sysctl_num,
+ zone_node->sysctl_num,
+ CTL_CREATE, CTL_EOL);
+
+ sysctl_createv(NULL, 0, NULL, (void *) &node,
+ CTLFLAG_READWRITE | CTLFLAG_OWNDESC,
+ CTLTYPE_INT, "Tmax", "maximum temperature",
+ NULL, 0, (void *)&z->Tmax, 0,
+ CTL_MACHDEP,
+ me->sysctl_num,
+ zone_node->sysctl_num,
+ CTL_CREATE, CTL_EOL);
+
+ return 0;
+}
diff -r a75ee87d93d8 -r d72b744eb00f sys/arch/macppc/dev/fancontrolvar.h
--- a/sys/arch/macppc/dev/fancontrolvar.h Fri Jul 30 21:29:00 2021 +0000
+++ b/sys/arch/macppc/dev/fancontrolvar.h Fri Jul 30 22:07:14 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: fancontrolvar.h,v 1.1 2021/07/27 23:38:42 macallan Exp $ */
+/* $NetBSD: fancontrolvar.h,v 1.2 2021/07/30 22:07:14 macallan Exp $ */
/*-
* Copyright (c) 2021 Michael Lorenz
@@ -48,5 +48,6 @@
} fancontrol_zone_t;
int fancontrol_adjust_zone(fancontrol_zone_t *);
+int fancontrol_init_zone(fancontrol_zone_t *, struct sysctlnode *);
#endif /* FANCONTROLVAR_H */
diff -r a75ee87d93d8 -r d72b744eb00f sys/arch/macppc/dev/fcu.c
--- a/sys/arch/macppc/dev/fcu.c Fri Jul 30 21:29:00 2021 +0000
+++ b/sys/arch/macppc/dev/fcu.c Fri Jul 30 22:07:14 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: fcu.c,v 1.3 2021/07/28 00:59:10 macallan Exp $ */
+/* $NetBSD: fcu.c,v 1.4 2021/07/30 22:07:14 macallan Exp $ */
/*-
* Copyright (c) 2018 Michael Lorenz
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: fcu.c,v 1.3 2021/07/28 00:59:10 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fcu.c,v 1.4 2021/07/30 22:07:14 macallan Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -35,6 +35,7 @@
#include <sys/conf.h>
#include <sys/bus.h>
#include <sys/kthread.h>
+#include <sys/sysctl.h>
#include <dev/i2c/i2cvar.h>
@@ -78,8 +79,8 @@
device_t sc_dev;
i2c_tag_t sc_i2c;
i2c_addr_t sc_addr;
-
- struct sysmon_envsys *sc_sme;
+ struct sysctlnode *sc_sysctl_me;
+ struct sysmon_envsys *sc_sme;
envsys_data_t sc_sensors[32];
int sc_nsensors;
fancontrol_zone_t sc_zones[FCU_ZONE_COUNT];
@@ -132,7 +133,7 @@
{
struct fcu_softc *sc = device_private(self);
struct i2c_attach_args *ia = aux;
- int have_eeprom1 = 1;
+ int have_eeprom1 = 1, i;
sc->sc_dev = self;
sc->sc_i2c = ia->ia_tag;
@@ -141,6 +142,12 @@
aprint_naive("\n");
aprint_normal(": Fan Control Unit\n");
+ sysctl_createv(NULL, 0, NULL, (void *) &sc->sc_sysctl_me,
+ CTLFLAG_READWRITE,
+ CTLTYPE_NODE, device_xname(sc->sc_dev), NULL,
+ NULL, 0, NULL, 0,
+ CTL_MACHDEP, CTL_CREATE, CTL_EOL);
+
if (get_cpuid(0, sc->sc_eeprom0) < 160) {
/*
* XXX this should never happen, we depend on the EEPROM for
@@ -164,19 +171,19 @@
sc->sc_zones[FCU_ZONE_CPU].nfans = 0;
sc->sc_zones[FCU_ZONE_CASE].name = "Slots";
sc->sc_zones[FCU_ZONE_CASE].filter = is_case;
+ sc->sc_zones[FCU_ZONE_CASE].cookie = sc;
sc->sc_zones[FCU_ZONE_CASE].Tmin = 50;
- sc->sc_zones[FCU_ZONE_CASE].cookie = sc;
+ sc->sc_zones[FCU_ZONE_CASE].Tmax = 75;
+ sc->sc_zones[FCU_ZONE_CASE].nfans = 0;
sc->sc_zones[FCU_ZONE_CASE].get_rpm = fcu_get_rpm;
sc->sc_zones[FCU_ZONE_CASE].set_rpm = fcu_set_rpm;
- sc->sc_zones[FCU_ZONE_CASE].Tmax = 75;
- sc->sc_zones[FCU_ZONE_CASE].nfans = 0;
- sc->sc_zones[FCU_ZONE_DRIVEBAY].name = "Drive bays";
+ sc->sc_zones[FCU_ZONE_DRIVEBAY].name = "Drivebays";
sc->sc_zones[FCU_ZONE_DRIVEBAY].filter = is_drive;
sc->sc_zones[FCU_ZONE_DRIVEBAY].cookie = sc;
sc->sc_zones[FCU_ZONE_DRIVEBAY].get_rpm = fcu_get_rpm;
sc->sc_zones[FCU_ZONE_DRIVEBAY].set_rpm = fcu_set_rpm;
sc->sc_zones[FCU_ZONE_DRIVEBAY].Tmin = 30;
- sc->sc_zones[FCU_ZONE_DRIVEBAY].Tmax = 60;
+ sc->sc_zones[FCU_ZONE_DRIVEBAY].Tmax = 50;
sc->sc_zones[FCU_ZONE_DRIVEBAY].nfans = 0;
sc->sc_sme = sysmon_envsys_create();
@@ -318,6 +325,11 @@
}
sysmon_envsys_register(sc->sc_sme);
+ /* setup sysctls for our zones etc. */
+ for (i = 0; i < FCU_ZONE_COUNT; i++) {
+ fancontrol_init_zone(&sc->sc_zones[i], sc->sc_sysctl_me);
+ }
+
sc->sc_dying = FALSE;
kthread_create(PRI_NONE, 0, curcpu(), fcu_adjust, sc, &sc->sc_thread,
"fan control");
Home |
Main Index |
Thread Index |
Old Index