Date: Sun, 16 May 2010 19:57:38 +0000 (UTC) From: Nathan Whitehorn <nwhitehorn@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r208167 - head/sys/powerpc/powermac Message-ID: <201005161957.o4GJvcVV099932@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: nwhitehorn Date: Sun May 16 19:57:38 2010 New Revision: 208167 URL: http://svn.freebsd.org/changeset/base/208167 Log: Enable smu(4) to report fan speeds on late-model Powermac G5s. Modified: head/sys/powerpc/powermac/smu.c Modified: head/sys/powerpc/powermac/smu.c ============================================================================== --- head/sys/powerpc/powermac/smu.c Sun May 16 19:44:08 2010 (r208166) +++ head/sys/powerpc/powermac/smu.c Sun May 16 19:57:38 2010 (r208167) @@ -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; + + 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 @@ -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)
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201005161957.o4GJvcVV099932>