svn commit: r208430 - stable/8/sys/powerpc/powermac

Nathan Whitehorn nwhitehorn at FreeBSD.org
Sun May 23 02:32:53 UTC 2010


Author: nwhitehorn
Date: Sun May 23 02:32:52 2010
New Revision: 208430
URL: http://svn.freebsd.org/changeset/base/208430

Log:
  MFC r208167:
  
  Enable smu(4) to report fan speeds on late-model Powermac G5s.

Modified:
  stable/8/sys/powerpc/powermac/smu.c
Directory Properties:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)
  stable/8/sys/dev/xen/xenpci/   (props changed)
  stable/8/sys/geom/sched/   (props changed)

Modified: stable/8/sys/powerpc/powermac/smu.c
==============================================================================
--- stable/8/sys/powerpc/powermac/smu.c	Sun May 23 02:31:37 2010	(r208429)
+++ stable/8/sys/powerpc/powermac/smu.c	Sun May 23 02:32:52 2010	(r208430)
@@ -643,14 +643,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;
+
+		error = smu_run_cmd(smu, &cmd, 1);
+		if (error)
+			fan->old_style = 1;
+
+		rpm = (cmd.data[0] << 8) | cmd.data[1];
+	}
 
-	smu_run_cmd(smu, &cmd, 1);
+	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);
 
-	return ((cmd.data[fan->reg*2+1] << 8) | cmd.data[fan->reg*2+2]);
+		rpm = (cmd.data[fan->reg*2+1] << 8) | cmd.data[fan->reg*2+2];
+	}
+
+	return (rpm);
 }
 
 static int
@@ -666,6 +686,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)


More information about the svn-src-all mailing list