Skip to contentSkip to conversation

powerpc: Thermal control for dual core G5s

PATCH In review Benjamin Herrenschmidt 3 participants 4 messages Feb 8, 2006 Linux for power macintosh

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 powerpc: Thermal control for dual core G5s

This patch adds a windfarm module, windfarm_pm112, for the dual core G5s (both 2 and 4 core models), keeping the machine from getting into vacuum-cleaner mode ;) For proper credits, the patch was initially written by Paul Mackerras, and slightly reworked by me to add overtemp handling among others. The patch also removes the sysfs attributes from windfarm_pm81 and windfarm_pm91 and instead adds code to the windfarm core to automagically expose attributes for sensor & controls.

Signed-off-by; Benjamin Herrenschmidt <[email protected]>

drivers/macintosh/Kconfig +8 -0
Index: linux-work/drivers/macintosh/Kconfig
===================================================================
@@ -187,6 +187,14 @@ config WINDFARM_PM91
 	  This driver provides thermal control for the PowerMac9,1
           which is the recent (SMU based) single CPU desktop G5
 
+config WINDFARM_PM112
+	tristate "Support for thermal management on PowerMac11,2"
+	depends on WINDFARM && I2C && PMAC_SMU
+	select I2C_PMAC_SMU
+	help
+	  This driver provides thermal control for the PowerMac11,2
+	  which are the recent dual and quad G5 machines using the
+	  970MP dual-core processor.
 
 config ANSLCD
 	tristate "Support for ANS LCD display"
drivers/macintosh/Makefile +5 -0
Index: linux-work/drivers/macintosh/Makefile
===================================================================
@@ -35,3 +35,8 @@ obj-$(CONFIG_WINDFARM_PM91)     += windf
 				   windfarm_smu_sensors.o \
 				   windfarm_lm75_sensor.o windfarm_pid.o \
 				   windfarm_cpufreq_clamp.o windfarm_pm91.o
+obj-$(CONFIG_WINDFARM_PM112)	+= windfarm_pm112.o windfarm_smu_sat.o \
+				   windfarm_smu_controls.o \
+				   windfarm_smu_sensors.o \
+				   windfarm_max6690_sensor.o \
+				   windfarm_lm75_sensor.o windfarm_pid.o
drivers/macintosh/windfarm.h +3 -0
Index: linux-work/drivers/macintosh/windfarm.h
===================================================================
@@ -14,6 +14,7 @@
 #include <linux/list.h>
 #include <linux/module.h>
 #include <linux/notifier.h>
+#include <linux/device.h>
 
 /* Display a 16.16 fixed point value */
 #define FIX32TOPRINT(f)	((f) >> 16),((((f) & 0xffff) * 1000) >> 16)
@@ -39,6 +40,7 @@ struct wf_control {
 	char			*name;
 	int			type;
 	struct kref		ref;
+	struct device_attribute	attr;
 };
 
 #define WF_CONTROL_TYPE_GENERIC		0
@@ -87,6 +89,7 @@ struct wf_sensor {
 	struct wf_sensor_ops	*ops;
 	char			*name;
 	struct kref		ref;
+	struct device_attribute	attr;
 };
 
 /* Same lifetime rules as controls */
drivers/macintosh/windfarm_core.c +65 -4

105 lines not on this page · raw message

drivers/macintosh/windfarm_max6690_sensor.c new file +169 -0

169 lines not on this page · raw message

drivers/macintosh/windfarm_pid.c +4 -4
Index: linux-work/drivers/macintosh/windfarm_pid.c
===================================================================
@@ -88,8 +88,8 @@ EXPORT_SYMBOL_GPL(wf_cpu_pid_init);
 
 s32 wf_cpu_pid_run(struct wf_cpu_pid_state *st, s32 new_power, s32 new_temp)
 {
-	s64	error, integ, deriv, prop;
-	s32	target, sval, adj;
+	s64	integ, deriv, prop;
+	s32	error, target, sval, adj;
 	int	i, hlen = st->param.history_len;
 
 	/* Calculate error term */
@@ -117,7 +117,7 @@ s32 wf_cpu_pid_run(struct wf_cpu_pid_sta
 		integ += st->errors[(st->index + hlen - i) % hlen];
 	integ *= st->param.interval;
 	integ *= st->param.gr;
-	sval = st->param.tmax - ((integ >> 20) & 0xffffffff);
+	sval = st->param.tmax - (s32)(integ >> 20);
 	adj = min(st->param.ttarget, sval);
 
 	DBG("integ: %lx, sval: %lx, adj: %lx\n", integ, sval, adj);
@@ -129,7 +129,7 @@ s32 wf_cpu_pid_run(struct wf_cpu_pid_sta
 	deriv *= st->param.gd;
 
 	/* Calculate proportional term */
-	prop = (new_temp - adj);
+	prop = st->last_delta = (new_temp - adj);
 	prop *= st->param.gp;
 
 	DBG("deriv: %lx, prop: %lx\n", deriv, prop);
drivers/macintosh/windfarm_pid.h +1 -0
Index: linux-work/drivers/macintosh/windfarm_pid.h
===================================================================
@@ -72,6 +72,7 @@ struct wf_cpu_pid_state {
 	int	index; 				/* index of current power */
 	int	tindex; 			/* index of current temp */
 	s32	target;				/* current target value */
+	s32	last_delta;			/* last Tactual - Ttarget */
 	s32	powers[WF_PID_MAX_HISTORY];	/* power history buffer */
 	s32	errors[WF_PID_MAX_HISTORY];	/* error history buffer */
 	s32	temps[2];			/* temp. history buffer */
drivers/macintosh/windfarm_pm112.c new file +698 -0

698 lines not on this page · raw message

drivers/macintosh/windfarm_smu_controls.c +54 -15

116 lines not on this page · raw message

drivers/macintosh/windfarm_smu_sensors.c +23 -20

89 lines not on this page · raw message

drivers/macintosh/windfarm_smu_sat.c new file +418 -0

418 lines not on this page · raw message

include/asm-powerpc/smu.h +5 -0
Index: linux-work/include/asm-powerpc/smu.h
===================================================================
@@ -521,6 +521,11 @@ struct smu_sdbp_cpupiddata {
 extern struct smu_sdbp_header *smu_get_sdb_partition(int id,
 					unsigned int *size);
 
+/* Get "sdb" partition data from an SMU satellite */
+extern struct smu_sdbp_header *smu_sat_get_sdb_partition(unsigned int sat_id,
+					int id, unsigned int *size);
+
+
 #endif /* __KERNEL__ */
 
 
drivers/macintosh/windfarm_pm91.c +14 -81

157 lines not on this page · raw message

drivers/macintosh/windfarm_pm81.c +12 -75

140 lines not on this page · raw message

#1 lore raw
Quoted 4 lines · Benjamin Herrenschmidt

This patch adds a windfarm module, windfarm_pm112, for the dual core G5s (both 2 and 4 core models), keeping the machine from getting into vacuum-cleaner mode ;)

This seems to introduce a new warning..

arch/powerpc/platforms/83xx/Kconfig:10:
warning: 'select' used by config symbol 'MPC834x_SYS' refer to undefined symbol 'DEFAULT_UIMAGE'

drivers/macintosh/Kconfig:193:
warning: 'select' used by config symbol 'WINDFARM_PM112' refer to undefined symbol 'I2C_PMAC_SMU'

Hmm?

Linus

#2 lore raw
Quoted 11 lines · Linus Torvalds
Quoted 4 lines · Benjamin Herrenschmidt

This patch adds a windfarm module, windfarm_pm112, for the dual core G5s (both 2 and 4 core models), keeping the machine from getting into vacuum-cleaner mode ;)

This seems to introduce a new warning..

arch/powerpc/platforms/83xx/Kconfig:10:
warning: 'select' used by config symbol 'MPC834x_SYS' refer to undefined symbol 'DEFAULT_UIMAGE'

Former is not mine...

Quoted 2 lines

drivers/macintosh/Kconfig:193:
warning: 'select' used by config symbol 'WINDFARM_PM112' refer to undefined symbol 'I2C_PMAC_SMU'

Ok, looks like I forgot to update the Kconfig for the new i2c driver, it should select I2C_POWERMAC instead. Do you want a new patch or can you just fix it there ?

Ben.

#3 lore raw
In reply to Linus Torvalds
Quoted 8 lines · Linus Torvalds
Quoted 4 lines · Benjamin Herrenschmidt

This patch adds a windfarm module, windfarm_pm112, for the dual core G5s (both 2 and 4 core models), keeping the machine from getting into vacuum-cleaner mode ;)

Quoted 5 lines

This seems to introduce a new warning..

arch/powerpc/platforms/83xx/Kconfig:10:
warning: 'select' used by config symbol 'MPC834x_SYS' refer to
undefined symbol 'DEFAULT_UIMAGE'

That's my fault. Paul did push a simple build system update. I'll ask him to do so.

http://ozlabs.org/pipermail/linuxppc-dev/2006-January/020980.html

- kumar