powerpc/powermac: New windfarm driver for PowerMac G5 (AGP) and Xserve G5
PATCH v2 1/1 powerpc/powermac: New windfarm driver for PowerMac G5 (AGP) and Xserve G5
This replaces the old therm_pm72 using the same windfarm infrastructure that was used for other PowerMac G5 models. The fan speeds and sensors should now be visible in the same location in sysfs.
The driver is split into separate core modules for PowerMac7,2 (and 7,3) and RackMac3,1, with a lot of the shared code now in the separate sensor and control modules.
---
v2: - Use programmed value when reading back from FCU
(like therm_pm72, behaviour is preferable and appears more
in line with what OS X does)
- Remove tickle code, it's annoying. Instead, don't compare programmed values with previous values, which means that the normal loops should be enough to keep the FCU from timing out. That also means that it should now be possible to manually program the slots fan from sysfs.
drivers/macintosh/Kconfig | 23 +- drivers/macintosh/Makefile | 14 + drivers/macintosh/windfarm.h | 3 +- drivers/macintosh/windfarm_core.c | 10 +- drivers/macintosh/windfarm_cpufreq_clamp.c | 6 - drivers/macintosh/windfarm_fcu_controls.c | 10 +- drivers/macintosh/windfarm_mpu.h | 105 ++++ drivers/macintosh/windfarm_pm72.c | 847 ++++++++++++++++++++++++++++ drivers/macintosh/windfarm_rm31.c | 740 ++++++++++++++++++++++++ 9 files changed, 1736 insertions(+), 22 deletions(-) create mode 100644 drivers/macintosh/windfarm_mpu.h create mode 100644 drivers/macintosh/windfarm_pm72.c create mode 100644 drivers/macintosh/windfarm_rm31.c
drivers/macintosh/Kconfig +21 -2
@@ -204,11 +204,14 @@ config THERM_ADT746X better fan behaviour by default, and some manual control. config THERM_PM72 - tristate "Support for thermal management on PowerMac G5" + tristate "Support for thermal management on PowerMac G5 (AGP)" depends on I2C && I2C_POWERMAC && PPC_PMAC64 + default n help This driver provides thermostat and fan control for the desktop - G5 machines. + G5 machines. + + This is deprecated, use windfarm instead. config WINDFARM tristate "New PowerMac thermal control infrastructure"
@@ -221,6 +224,22 @@ config WINDFARM_PM81 help This driver provides thermal control for the iMacG5 +config WINDFARM_PM72 + tristate "Support for thermal management on PowerMac G5 (AGP)" + depends on WINDFARM && I2C && CPU_FREQ_PMAC64 && ADB_PMU + select I2C_POWERMAC + help + This driver provides thermal control for the PowerMac G5 + "AGP" variants (PowerMac 7,2 and 7,3) + +config WINDFARM_RM31 + tristate "Support for thermal management on Xserve G5" + depends on WINDFARM && I2C && CPU_FREQ_PMAC64 && ADB_PMU + select I2C_POWERMAC + help + This driver provides thermal control for the Xserve G5 + (RackMac3,1) + config WINDFARM_PM91 tristate "Support for thermal management on PowerMac9,1" depends on WINDFARM && I2C && CPU_FREQ_PMAC64 && PMAC_SMU
drivers/macintosh/Makefile +14 -0
@@ -29,6 +29,20 @@ obj-$(CONFIG_THERM_PM72) += therm_pm72.o obj-$(CONFIG_THERM_WINDTUNNEL) += therm_windtunnel.o obj-$(CONFIG_THERM_ADT746X) += therm_adt746x.o obj-$(CONFIG_WINDFARM) += windfarm_core.o +obj-$(CONFIG_WINDFARM_PM72) += windfarm_fcu_controls.o \ + windfarm_ad7417_sensor.o \ + windfarm_lm75_sensor.o \ + windfarm_max6690_sensor.o \ + windfarm_pid.o \ + windfarm_cpufreq_clamp.o \ + windfarm_pm72.o +obj-$(CONFIG_WINDFARM_RM31) += windfarm_fcu_controls.o \ + windfarm_ad7417_sensor.o \ + windfarm_lm75_sensor.o \ + windfarm_lm87_sensor.o \ + windfarm_pid.o \ + windfarm_cpufreq_clamp.o \ + windfarm_rm31.o obj-$(CONFIG_WINDFARM_PM81) += windfarm_smu_controls.o \ windfarm_smu_sensors.o \ windfarm_lm75_sensor.o windfarm_pid.o \
drivers/macintosh/windfarm.h +2 -1
@@ -17,7 +17,7 @@#include <linux/device.h> /* Display a 16.16 fixed point value */ -#define FIX32TOPRINT (f) ((f) >> 16),((((f) & 0xffff) * 1000) >> 16) +#define FIX32TOPRINT (f) (((s32)(f)) >> 16),(((((s32)(f)) & 0xffff) * 1000) >> 16)/* * Control objects
@@ -41,6 +41,7 @@ struct wf_control {int type;struct kref ref;struct device_attribute attr; +void *priv; };#define WF_CONTROL_TYPE_GENERIC 0
drivers/macintosh/windfarm_core.c +4 -6
@@ -169,8 +169,11 @@ static ssize_t wf_show_control(struct device *dev,int err; err = ctrl->ops->get_value (ctrl, &val); -if (err <0 ) +if (err <0 ) { +if (err == -EFAULT ) +return sprintf (buf,"<HW FAULT>\n" );return err; + }switch (ctrl->type) {case WF_CONTROL_RPM_FAN : typestr =" RPM" ;
@@ -481,11 +484,6 @@ static int __init windfarm_core_init(void) {DBG ("wf: core loaded\n" ); -/* Don't register on old machines that use therm_pm72 for now */ -if (of_machine_is_compatible ("PowerMac7,2" ) || -of_machine_is_compatible ("PowerMac7,3" ) || -of_machine_is_compatible ("RackMac3,1" )) -return -ENODEV ;platform_device_register (&wf_platform_device);return 0 ; }
drivers/macintosh/windfarm_cpufreq_clamp.c +0 -6
@@ -75,12 +75,6 @@ static int __init wf_cpufreq_clamp_init(void) {struct wf_control *clamp; -/* Don't register on old machines that use therm_pm72 for now */ -if (of_machine_is_compatible ("PowerMac7,2" ) || -of_machine_is_compatible ("PowerMac7,3" ) || -of_machine_is_compatible ("RackMac3,1" )) -return -ENODEV ; - clamp =kmalloc (sizeof (struct wf_control ),GFP_KERNEL );if (clamp ==NULL )return -ENOMEM ;
drivers/macintosh/windfarm_fcu_controls.c +3 -7
@@ -41,10 +41,10 @@* applied to the setpoint RPM speed, that is basically the * speed we proviously "asked" for. * -* I'm not sure which of these Apple's algorithm is supposed -* to use +* I'm using 0 for now which is what therm_pm72 used to do and +* what Darwin -apparently- does based on observed behaviour. */ -#define RPM_PID_USE_ACTUAL_SPEED 1 +#define RPM_PID_USE_ACTUAL_SPEED 0/* Default min/max for pumps */ #define CPU_PUMP_OUTPUT_MAX 3200
@@ -154,8 +154,6 @@ static int wf_fcu_fan_set_rpm(struct wf_control *ct, s32 value)if (value > fan->max) value = fan->max; -if (fan->target && fan->target == value) -return 0 ; fan->target = value; buf[0 ] = value >> (8 - shift);
@@ -213,8 +211,6 @@ static int wf_fcu_fan_set_pwm(struct wf_control *ct, s32 value)if (value > fan->max) value = fan->max; -if (fan->target && fan->target == value) -return 0 ; fan->target = value; value = (value *2559 ) /1000 ;
drivers/macintosh/windfarm_mpu.h new file +105 -0
105 lines not on this page · raw message
drivers/macintosh/windfarm_pm72.c new file +847 -0
847 lines not on this page · raw message
drivers/macintosh/windfarm_rm31.c new file +740 -0
740 lines not on this page · raw message