summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornwhitehorn <nwhitehorn@FreeBSD.org>2010-05-16 19:57:38 +0000
committernwhitehorn <nwhitehorn@FreeBSD.org>2010-05-16 19:57:38 +0000
commitea2ffba9d780b4f0c803feae0ebd3f305cd867f1 (patch)
tree7f80f2cf67fb9e8ae8f0b5677a1e3a070ae3f2f4
parent15e5afeb5bf05cd26d10c5fde972e85a1c99fda3 (diff)
downloadFreeBSD-src-ea2ffba9d780b4f0c803feae0ebd3f305cd867f1.zip
FreeBSD-src-ea2ffba9d780b4f0c803feae0ebd3f305cd867f1.tar.gz
Enable smu(4) to report fan speeds on late-model Powermac G5s.
-rw-r--r--sys/powerpc/powermac/smu.c33
1 files changed, 28 insertions, 5 deletions
diff --git a/sys/powerpc/powermac/smu.c b/sys/powerpc/powermac/smu.c
index 1001876..fb97456 100644
--- a/sys/powerpc/powermac/smu.c
+++ b/sys/powerpc/powermac/smu.c
@@ -662,14 +662,34 @@ static int
smu_fan_read_rpm(device_t smu, struct smu_fan *fan)
{
struct smu_cmd cmd;
+ int rpm, error;
- cmd.cmd = SMU_FAN;
- cmd.len = 1;
- cmd.data[0] = 1;
+ if (!fan->old_style) {
+ cmd.cmd = SMU_FAN;
+ cmd.len = 2;
+ cmd.data[0] = 0x31;
+ cmd.data[1] = fan->reg;
- smu_run_cmd(smu, &cmd, 1);
+ error = smu_run_cmd(smu, &cmd, 1);
+ if (error)
+ fan->old_style = 1;
+
+ rpm = (cmd.data[0] << 8) | cmd.data[1];
+ }
- return ((cmd.data[fan->reg*2+1] << 8) | cmd.data[fan->reg*2+2]);
+ if (fan->old_style) {
+ cmd.cmd = SMU_FAN;
+ cmd.len = 1;
+ cmd.data[0] = 1;
+
+ error = smu_run_cmd(smu, &cmd, 1);
+ if (error)
+ return (error);
+
+ rpm = (cmd.data[fan->reg*2+1] << 8) | cmd.data[fan->reg*2+2];
+ }
+
+ return (rpm);
}
static int
@@ -685,6 +705,9 @@ smu_fanrpm_sysctl(SYSCTL_HANDLER_ARGS)
fan = &sc->sc_fans[arg2];
rpm = smu_fan_read_rpm(smu, fan);
+ if (rpm < 0)
+ return (rpm);
+
error = sysctl_handle_int(oidp, &rpm, 0, req);
if (error || !req->newptr)
OpenPOWER on IntegriCloud