Skip to contentSkip to conversation

windfarm: add PowerMac 12,1 support

PATCH In review Étienne Bersac 3 participants 6 messages Dec 6, 2007 – Dec 10, 2007

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 windfarm: add PowerMac 12,1 support

From: Étienne Bersac <[email protected]>

Implement a new driver named windfarm_pm121 which drive fans on PowerMac 12,1 machine : iMac G5 iSight (rev C) 17" and 20". It's based on windfarm_pm81 driver from Benjamin Herrenschmidt.

---

Implement fan control for PowerMac 12,1 machines. This needs update to windfarm_lm75 and windfarm_max6690 sensors drivers in order to properly match sensors by their location. The code is based on windfarm_pm81 driver, adapted to the complexity of PowerMac 12,1 : 4 system control loops instead of one, per-control target correction and per-model control rubber-banding.

All the data are copied from Darwin 8.10 AppleMacRISC4PE-185.0.0 module as well as correction formula.

arch/powerpc/configs/g5_defconfig +1 -0
index 0a6fa1f..7125837 100644
@@ -656,6 +656,7 @@ CONFIG_WINDFARM=y
 CONFIG_WINDFARM_PM81=y
 CONFIG_WINDFARM_PM91=y
 CONFIG_WINDFARM_PM112=y
+CONFIG_WINDFARM_PM121=y
 # CONFIG_PMAC_RACKMETER is not set
 CONFIG_NETDEVICES=y
 # CONFIG_NETDEVICES_MULTIQUEUE is not set
drivers/macintosh/Kconfig +8 -0
index 77f50b6..2d028e6 100644
@@ -234,6 +234,14 @@ config WINDFARM_PM112
 	  which are the recent dual and quad G5 machines using the
 	  970MP dual-core processor.
 
+config WINDFARM_PM121
+	tristate "Support for thermal management on PowerMac12,1"
+	depends on WINDFARM && I2C && PMAC_SMU
+	select I2C_POWERMAC
+	help
+	  This driver provides thermal control for the PowerMac12,1
+	  which is the iMac G5 (iSight) 970MP
+
 config ANSLCD
 	tristate "Support for ANS LCD display"
 	depends on ADB_CUDA && PPC_PMAC
drivers/macintosh/Makefile +5 -0
index 2dfc3f4..e3132ef 100644
@@ -42,4 +42,9 @@ obj-$(CONFIG_WINDFARM_PM112)	+= windfarm_pm112.o windfarm_smu_sat.o \
 				   windfarm_smu_sensors.o \
 				   windfarm_max6690_sensor.o \
 				   windfarm_lm75_sensor.o windfarm_pid.o
+obj-$(CONFIG_WINDFARM_PM121)	+= windfarm_pm121.o windfarm_smu_sat.o \
+				   windfarm_smu_controls.o \
+				   windfarm_smu_sensors.o \
+				   windfarm_max6690_sensor.o \
+				   windfarm_lm75_sensor.o windfarm_pid.o
 obj-$(CONFIG_PMAC_RACKMETER)	+= rack-meter.o
drivers/macintosh/windfarm_lm75_sensor.c +6 -0
index 7e10c3a..b92b959 100644
@@ -127,6 +127,12 @@ static struct wf_lm75_sensor *wf_lm75_create(struct i2c_adapter *adapter,
 	 */
 	if (!strcmp(loc, "Hard drive") || !strcmp(loc, "DRIVE BAY"))
 		lm->sens.name = "hd-temp";
+	else if (!strcmp(loc, "Incoming Air Temp"))
+		lm->sens.name = "incoming-air-temp";
+	else if (!strcmp(loc, "ODD Temp"))
+		lm->sens.name = "optical-drive-temp";
+	else if (!strcmp(loc, "HD Temp"))
+		lm->sens.name = "hard-drive-temp";
 	else
 		goto fail;
 
drivers/macintosh/windfarm_max6690_sensor.c +13 -5
index 5f03aab..c2b6d1c 100644
@@ -77,10 +77,11 @@ static struct wf_sensor_ops wf_max6690_ops = {
 	.owner		= THIS_MODULE,
 };
 
-static void wf_max6690_create(struct i2c_adapter *adapter, u8 addr)
+static void wf_max6690_create(struct i2c_adapter *adapter, u8 addr,
+			      const char *loc)
 {
 	struct wf_6690_sensor *max;
-	char *name = "backside-temp";
+	char *name = NULL;
 
 	max = kzalloc(sizeof(struct wf_6690_sensor), GFP_KERNEL);
 	if (max == NULL) {
@@ -89,6 +90,15 @@ static void wf_max6690_create(struct i2c_adapter *adapter, u8 addr)
 		return;
 	}
 
+	if (!strcmp(loc, "BACKSIDE"))
+		name = "backside-temp";
+	else if (!strcmp(loc, "NB Ambient"))
+		name = "north-bridge-temp";
+	else if (!strcmp(loc, "GPU Ambient"))
+		name = "gpu-temp";
+	else
+		goto fail;
+
 	max->sens.ops = &wf_max6690_ops;
 	max->sens.name = name;
 	max->i2c.addr = addr >> 1;
@@ -138,9 +148,7 @@ static int wf_max6690_attach(struct i2c_adapter *adapter)
 		if (loc == NULL || addr == 0)
 			continue;
 		printk("found max6690, loc=%s addr=0x%02x\n", loc, addr);
-		if (strcmp(loc, "BACKSIDE"))
-			continue;
-		wf_max6690_create(adapter, addr);
+		wf_max6690_create(adapter, addr, loc);
 	}
 
 	return 0;
drivers/macintosh/windfarm_pm121.c new file +1052 -0

1,052 lines not on this page · raw message

drivers/macintosh/windfarm_smu_controls.c +4 -0
index 58c2590..961fa0e 100644
@@ -218,6 +218,10 @@ static struct smu_fan_control *smu_fan_create(struct device_node *node,
 		fct->ctrl.name = "cpu-fan";
 	else if (!strcmp(l, "Hard Drive") || !strcmp(l, "Hard drive"))
 		fct->ctrl.name = "drive-bay-fan";
+	else if (!strcmp(l, "HDD Fan")) /* seen on iMac G5 iSight */
+		fct->ctrl.name = "hard-drive-fan";
+	else if (!strcmp(l, "ODD Fan")) /* same */
+		fct->ctrl.name = "optical-drive-fan";
 
 	/* Unrecognized fan, bail out */
 	if (fct->ctrl.name == NULL)
#1 lore raw

Hi,

Quoted 4 lines
drivers/macintosh/windfarm_pm121.c new file +4 -0
+	/* First, locate the params for this model */
+	for (i = 0; i < PM121_NUM_CONFIGS; i++) {
+		param = &(pm121_sys_all_params[loop_id][i]);
+		if (param->model_id == pm121_mach_model)

drivers/macintosh/windfarm_pm121.c line 543

Quoted 10 lines
drivers/macintosh/windfarm_pm121.c new file +10 -0
+			break;
+	}
+
+	/* No params found, put fans to max */
+	if (param == NULL) {
+		printk(KERN_WARNING "pm121: %s fan config not found "
+		       " for this machine model\n",
+		       loop_names[loop_id]);
+		goto fail;
+	}

This part might be buggy. param NULL only when PM121_NUM_CONFIGS is 0. The original code was :

+ for (i = 0; i < PM121_NUM_CONFIGS; i++) {
+ if (pm121_sys_all_params[loop_id][i].model_id == pm121_mach_model) {
+ param = &(pm121_sys_all_params[loop_id][i]);
+ break;
+ }
+ }

But the line is wider than 80 chars. An alternative would be :

+ for (i = 0; i < PM121_NUM_CONFIGS; i++) {
+ param = &(pm121_sys_all_params[loop_id][i]);
+ if (param->model_id == pm121_mach_model)
+ break;
+ else
+ param = NULL;
+ }

I wonder if that's more readable.

Regards,
Étienne.

Signature · 1 line
E Ultreïa !
#2 lore raw

From: Étienne Bersac <[email protected]>

Hi,

Here is an updated patch that fix the potential bug, CPU param detection failure might not be detected. Please review it.

Regards,
Étienne.

---
Implement fan control for PowerMac 12,1 machines. This needs update to windfarm_lm75 and windfarm_max6690 sensors drivers in order to properly match sensors by their location. The code is based on windfarm_pm81 driver, adapted to the complexity of PowerMac 12,1 : 4 system control loops instead of one, per-control target correction and per-model control rubber-banding.

All the data are copied from Darwin 8.10 AppleMacRISC4PE-185.0.0 module as well as correction formula.

arch/powerpc/configs/g5_defconfig +1 -0
index 0a6fa1f..7125837 100644
@@ -656,6 +656,7 @@ CONFIG_WINDFARM=y
 CONFIG_WINDFARM_PM81=y
 CONFIG_WINDFARM_PM91=y
 CONFIG_WINDFARM_PM112=y
+CONFIG_WINDFARM_PM121=y
 # CONFIG_PMAC_RACKMETER is not set
 CONFIG_NETDEVICES=y
 # CONFIG_NETDEVICES_MULTIQUEUE is not set
drivers/macintosh/Kconfig +8 -0
index 77f50b6..2d028e6 100644
@@ -234,6 +234,14 @@ config WINDFARM_PM112
 	  which are the recent dual and quad G5 machines using the
 	  970MP dual-core processor.
 
+config WINDFARM_PM121
+	tristate "Support for thermal management on PowerMac12,1"
+	depends on WINDFARM && I2C && PMAC_SMU
+	select I2C_POWERMAC
+	help
+	  This driver provides thermal control for the PowerMac12,1
+	  which is the iMac G5 (iSight) 970MP
+
 config ANSLCD
 	tristate "Support for ANS LCD display"
 	depends on ADB_CUDA && PPC_PMAC
drivers/macintosh/Makefile +5 -0
index 2dfc3f4..e3132ef 100644
@@ -42,4 +42,9 @@ obj-$(CONFIG_WINDFARM_PM112)	+= windfarm_pm112.o windfarm_smu_sat.o \
 				   windfarm_smu_sensors.o \
 				   windfarm_max6690_sensor.o \
 				   windfarm_lm75_sensor.o windfarm_pid.o
+obj-$(CONFIG_WINDFARM_PM121)	+= windfarm_pm121.o windfarm_smu_sat.o \
+				   windfarm_smu_controls.o \
+				   windfarm_smu_sensors.o \
+				   windfarm_max6690_sensor.o \
+				   windfarm_lm75_sensor.o windfarm_pid.o
 obj-$(CONFIG_PMAC_RACKMETER)	+= rack-meter.o
drivers/macintosh/windfarm_lm75_sensor.c +6 -0
index 7e10c3a..b92b959 100644
@@ -127,6 +127,12 @@ static struct wf_lm75_sensor *wf_lm75_create(struct i2c_adapter *adapter,
 	 */
 	if (!strcmp(loc, "Hard drive") || !strcmp(loc, "DRIVE BAY"))
 		lm->sens.name = "hd-temp";
+	else if (!strcmp(loc, "Incoming Air Temp"))
+		lm->sens.name = "incoming-air-temp";
+	else if (!strcmp(loc, "ODD Temp"))
+		lm->sens.name = "optical-drive-temp";
+	else if (!strcmp(loc, "HD Temp"))
+		lm->sens.name = "hard-drive-temp";
 	else
 		goto fail;
 
drivers/macintosh/windfarm_max6690_sensor.c +13 -5
index 5f03aab..c2b6d1c 100644
@@ -77,10 +77,11 @@ static struct wf_sensor_ops wf_max6690_ops = {
 	.owner		= THIS_MODULE,
 };
 
-static void wf_max6690_create(struct i2c_adapter *adapter, u8 addr)
+static void wf_max6690_create(struct i2c_adapter *adapter, u8 addr,
+			      const char *loc)
 {
 	struct wf_6690_sensor *max;
-	char *name = "backside-temp";
+	char *name = NULL;
 
 	max = kzalloc(sizeof(struct wf_6690_sensor), GFP_KERNEL);
 	if (max == NULL) {
@@ -89,6 +90,15 @@ static void wf_max6690_create(struct i2c_adapter *adapter, u8 addr)
 		return;
 	}
 
+	if (!strcmp(loc, "BACKSIDE"))
+		name = "backside-temp";
+	else if (!strcmp(loc, "NB Ambient"))
+		name = "north-bridge-temp";
+	else if (!strcmp(loc, "GPU Ambient"))
+		name = "gpu-temp";
+	else
+		goto fail;
+
 	max->sens.ops = &wf_max6690_ops;
 	max->sens.name = name;
 	max->i2c.addr = addr >> 1;
@@ -138,9 +148,7 @@ static int wf_max6690_attach(struct i2c_adapter *adapter)
 		if (loc == NULL || addr == 0)
 			continue;
 		printk("found max6690, loc=%s addr=0x%02x\n", loc, addr);
-		if (strcmp(loc, "BACKSIDE"))
-			continue;
-		wf_max6690_create(adapter, addr);
+		wf_max6690_create(adapter, addr, loc);
 	}
 
 	return 0;
drivers/macintosh/windfarm_pm121.c new file +1053 -0

1,053 lines not on this page · raw message

drivers/macintosh/windfarm_smu_controls.c +4 -0
index 58c2590..961fa0e 100644
@@ -218,6 +218,10 @@ static struct smu_fan_control *smu_fan_create(struct device_node *node,
 		fct->ctrl.name = "cpu-fan";
 	else if (!strcmp(l, "Hard Drive") || !strcmp(l, "Hard drive"))
 		fct->ctrl.name = "drive-bay-fan";
+	else if (!strcmp(l, "HDD Fan")) /* seen on iMac G5 iSight */
+		fct->ctrl.name = "hard-drive-fan";
+	else if (!strcmp(l, "ODD Fan")) /* same */
+		fct->ctrl.name = "optical-drive-fan";
 
 	/* Unrecognized fan, bail out */
 	if (fct->ctrl.name == NULL)
#3 lore raw
Quoted 4 lines · On Monday 10 December 2007, =C3=89tienne Bersac wrote:

From: =C3=89tienne Bersac <[email protected]>
=20
Here is an updated patch that fix the potential bug, CPU param detection failure might not be detected. Please review it.=20

I didn't find much interesting to complain about, just a few style issues that could be improved. Good work!

Quoted 8 lines
drivers/macintosh/windfarm_max6690_sensor.c +3 -2
-static void wf_max6690_create(struct i2c_adapter *adapter, u8 addr)
+static void wf_max6690_create(struct i2c_adapter *adapter, u8 addr,
+			      const char *loc)
 {
 	struct wf_6690_sensor *max;
-	char *name =3D "backside-temp";
+	char *name =3D NULL;

=20

It's better not to initialize local variables like this one, instead of assigning them to 0 or NULL. When it's not initialized, gcc is able to warn about cases where you don't assign a meaningful value before using it.

drivers/macintosh/windfarm_pm121.c line 231

Quoted 7 lines
drivers/macintosh/windfarm_pm121.c new file +7 -0
+#undef	DEBUG
+
+#ifdef DEBUG
+#define DBG(args...)	printk(args)
+#else
+#define DBG(args...)	do { } while (0)
+#endif

Don't define your own macros like these, but instead use the ones that are there. If possible, use 'dev_dbg()', otherwise 'pr_debug()'.

Quoted 7 lines
drivers/macintosh/windfarm_pm121.c new file +7 -0
+static int pm121_mach_model;	/* machine model id */
+
+/* Controls & sensors */
+static struct wf_sensor	*sensor_cpu_power;
+static struct wf_sensor	*sensor_cpu_temp;
+static struct wf_sensor	*sensor_cpu_voltage;
+static struct wf_sensor	*sensor_cpu_current;

drivers/macintosh/windfarm_pm121.c line 286

Quoted 10 lines
drivers/macintosh/windfarm_pm121.c new file +10 -0
+static struct wf_sensor	*sensor_gpu_temp;
+static struct wf_sensor	*sensor_north_bridge_temp;
+static struct wf_sensor	*sensor_hard_drive_temp;
+static struct wf_sensor	*sensor_optical_drive_temp;
+static struct wf_sensor	*sensor_incoming_air_temp; /* unused ! */
+static struct wf_control *controls[N_CONTROLS] =3D {};
+
+static unsigned int pm121_failure_state;
+static int pm121_readjust, pm121_skipping;
+static s32 average_power;

Having many global variables is typically a sign that you are doing something wrong. It's better to attach all the data you have to your device structure.

Have you checked that you are doing the right locking when accessing these variables from concurrent threads?

drivers/macintosh/windfarm_pm121.c

Quoted 6 lines
drivers/macintosh/windfarm_pm121.c new file +6 -0
+struct pm121_correction {
+	int	offset;
+	int	slope;
+};
+
+struct pm121_correction corrections[N_CONTROLS][PM121_NUM_CONFIGS] =3D {

This looks like it could be 'const'. 'static const' variables are better because it becomes obvious that you don't need locking to access them.

Quoted 1 line

+static struct pm121_connection pm121_connections[] =3D {

same here.

Review

Quoted 2 lines
(quoted diff) +2 -0
+static struct pm121_sys_param
+pm121_sys_all_params[N_LOOPS][PM121_NUM_CONFIGS] =3D {

and here.

drivers/macintosh/windfarm_pm121.c line 766

Quoted 9 lines
drivers/macintosh/windfarm_pm121.c new file +9 -0
+#ifdef HACKED_OVERTEMP
+#define	MAX	0x4a0000
+#else
+#define	MAX	st->pid.param.tmax
+#endif
+	if (temp > MAX)
+		pm121_failure_state |=3D FAILURE_OVERTEMP;
+
+#undef	MAX

You don't define HACKED_OVERTEMP anywhere, so you basicall have dead code here. It's probably better to remove that for the upstream version, even if it was helpful for your debugging.

Review

Quoted 7 lines
(quoted diff) +7 -0
+
+#define	pm121_register_control(control, match, id)			\
+	if (controls[id] =3D=3D NULL && !strcmp(control->name,match)) {	\
+		if (wf_get_control(control) =3D=3D 0)			\
+			controls[id] =3D control;				\
+	}								\
+	all =3D all && controls[id];

Does this need to be a macro? If possible, use static functions for this kind of stuff. They will normally be inlined, which gives you the same object code in the end.

Quoted 12 lines
drivers/macintosh/windfarm_pm121.c new file +12 -0
+static int __init pm121_init(void)
+{
+	int rc =3D -ENODEV;
+
+	if (machine_is_compatible("PowerMac12,1"))
+		rc =3D pm121_init_pm();
+
+	if (rc =3D=3D 0) {
+#ifdef MODULE
+		request_module("windfarm_smu_controls");
+		request_module("windfarm_smu_sensors");
+		request_module("windfarm_smu_sat");

drivers/macintosh/windfarm_pm121.c line 1038

Quoted 10 lines
drivers/macintosh/windfarm_pm121.c new file +10 -0
+		request_module("windfarm_lm75_sensor");
+		request_module("windfarm_max6690_sensor");
+		request_module("windfarm_cpufreq_clamp");
+
+#endif /* MODULE */
+		platform_driver_register(&pm121_driver);
+	}
+
+	return rc;
+}

Why the #ifdef MODULE here? It's normally better to have identical code for modular and built-in cases.

	Arnd <><
#4 lore raw

Hi,

Thanks for reviewing the patch. I fix most of your comment excepts some thing which i think are not mine. This is about the global variable. I wrote this driver willing to be as more consistent with existing windfarm_pm* drivers. All uses DBG(), global variable, etc. You'll see that i dropped DBG in favor to pr_debug() ; thanks for pointing this.

windfarm drivers are plateform driver. This is why it uses global variable, etc. This driver is never unloaded. (except for development issues). Anyway, if Benjamin Herrenschmidt or Paul Mackerras tells to use per module struct, i'll do so. The same goes for #ifdef MODULE. That's just a copy paste from windfarm_pm81.c.

Appended the new patch, please review it.

Thanks,
Étienne.

---

Implement fan control for PowerMac 12,1 machines. This needs update to windfarm_lm75 and windfarm_max6690 sensors drivers in order to properly match sensors by their location. The code is based on windfarm_pm81 driver, adapted to the complexity of PowerMac 12,1 : 4 system control loops instead of one, per-control target correction and per-model control rubber-banding.

All the data are copied from Darwin 8.10 AppleMacRISC4PE-185.0.0 module as well as correction formula.

arch/powerpc/configs/g5_defconfig +1 -0
index 3673dd2..4c048b3 100644
@@ -667,6 +667,7 @@ CONFIG_WINDFARM=y
 CONFIG_WINDFARM_PM81=y
 CONFIG_WINDFARM_PM91=y
 CONFIG_WINDFARM_PM112=y
+CONFIG_WINDFARM_PM121=y
 # CONFIG_PMAC_RACKMETER is not set
 CONFIG_NETDEVICES=y
 # CONFIG_NETDEVICES_MULTIQUEUE is not set
drivers/macintosh/Kconfig +8 -0
index 77f50b6..2d028e6 100644
@@ -234,6 +234,14 @@ config WINDFARM_PM112
 	  which are the recent dual and quad G5 machines using the
 	  970MP dual-core processor.
 
+config WINDFARM_PM121
+	tristate "Support for thermal management on PowerMac12,1"
+	depends on WINDFARM && I2C && PMAC_SMU
+	select I2C_POWERMAC
+	help
+	  This driver provides thermal control for the PowerMac12,1
+	  which is the iMac G5 (iSight) 970MP
+
 config ANSLCD
 	tristate "Support for ANS LCD display"
 	depends on ADB_CUDA && PPC_PMAC
drivers/macintosh/Makefile +5 -0
index 2dfc3f4..e3132ef 100644
@@ -42,4 +42,9 @@ obj-$(CONFIG_WINDFARM_PM112)	+= windfarm_pm112.o windfarm_smu_sat.o \
 				   windfarm_smu_sensors.o \
 				   windfarm_max6690_sensor.o \
 				   windfarm_lm75_sensor.o windfarm_pid.o
+obj-$(CONFIG_WINDFARM_PM121)	+= windfarm_pm121.o windfarm_smu_sat.o \
+				   windfarm_smu_controls.o \
+				   windfarm_smu_sensors.o \
+				   windfarm_max6690_sensor.o \
+				   windfarm_lm75_sensor.o windfarm_pid.o
 obj-$(CONFIG_PMAC_RACKMETER)	+= rack-meter.o
drivers/macintosh/windfarm_lm75_sensor.c +6 -0
index 7e10c3a..b92b959 100644
@@ -127,6 +127,12 @@ static struct wf_lm75_sensor *wf_lm75_create(struct i2c_adapter *adapter,
 	 */
 	if (!strcmp(loc, "Hard drive") || !strcmp(loc, "DRIVE BAY"))
 		lm->sens.name = "hd-temp";
+	else if (!strcmp(loc, "Incoming Air Temp"))
+		lm->sens.name = "incoming-air-temp";
+	else if (!strcmp(loc, "ODD Temp"))
+		lm->sens.name = "optical-drive-temp";
+	else if (!strcmp(loc, "HD Temp"))
+		lm->sens.name = "hard-drive-temp";
 	else
 		goto fail;
 
drivers/macintosh/windfarm_max6690_sensor.c +14 -6
index 5f03aab..e207a90 100644
@@ -77,18 +77,28 @@ static struct wf_sensor_ops wf_max6690_ops = {
 	.owner		= THIS_MODULE,
 };
 
-static void wf_max6690_create(struct i2c_adapter *adapter, u8 addr)
+static void wf_max6690_create(struct i2c_adapter *adapter, u8 addr,
+			      const char *loc)
 {
 	struct wf_6690_sensor *max;
-	char *name = "backside-temp";
+	char *name;
 
 	max = kzalloc(sizeof(struct wf_6690_sensor), GFP_KERNEL);
 	if (max == NULL) {
 		printk(KERN_ERR "windfarm: Couldn't create MAX6690 sensor %s: "
-		       "no memory\n", name);
+		       "no memory\n", loc);
 		return;
 	}
 
+	if (!strcmp(loc, "BACKSIDE"))
+		name = "backside-temp";
+	else if (!strcmp(loc, "NB Ambient"))
+		name = "north-bridge-temp";
+	else if (!strcmp(loc, "GPU Ambient"))
+		name = "gpu-temp";
+	else
+		goto fail;
+
 	max->sens.ops = &wf_max6690_ops;
 	max->sens.name = name;
 	max->i2c.addr = addr >> 1;
@@ -138,9 +148,7 @@ static int wf_max6690_attach(struct i2c_adapter *adapter)
 		if (loc == NULL || addr == 0)
 			continue;
 		printk("found max6690, loc=%s addr=0x%02x\n", loc, addr);
-		if (strcmp(loc, "BACKSIDE"))
-			continue;
-		wf_max6690_create(adapter, addr);
+		wf_max6690_create(adapter, addr, loc);
 	}
 
 	return 0;
drivers/macintosh/windfarm_pm121.c new file +1041 -0

1,041 lines not on this page · raw message

drivers/macintosh/windfarm_smu_controls.c +4 -0
index 58c2590..961fa0e 100644
@@ -218,6 +218,10 @@ static struct smu_fan_control *smu_fan_create(struct device_node *node,
 		fct->ctrl.name = "cpu-fan";
 	else if (!strcmp(l, "Hard Drive") || !strcmp(l, "Hard drive"))
 		fct->ctrl.name = "drive-bay-fan";
+	else if (!strcmp(l, "HDD Fan")) /* seen on iMac G5 iSight */
+		fct->ctrl.name = "hard-drive-fan";
+	else if (!strcmp(l, "ODD Fan")) /* same */
+		fct->ctrl.name = "optical-drive-fan";
 
 	/* Unrecognized fan, bail out */
 	if (fct->ctrl.name == NULL)
#5 lore raw

Hi,

Appended a patch which builds without warnings due to struct declared const. Please review it.

Thanks,
Étienne

---
Implement fan control for PowerMac 12,1 machines. This needs update to windfarm_lm75 and windfarm_max6690 sensors drivers in order to properly match sensors by their location. The code is based on windfarm_pm81 driver, adapted to the complexity of PowerMac 12,1 : 4 system control loops instead of one, per-control target correction and per-model control rubber-banding.

All the data are copied from Darwin 8.10 AppleMacRISC4PE-185.0.0 module as well as correction formula.

arch/powerpc/configs/g5_defconfig +1 -0
index 3673dd2..4c048b3 100644
@@ -667,6 +667,7 @@ CONFIG_WINDFARM=y
 CONFIG_WINDFARM_PM81=y
 CONFIG_WINDFARM_PM91=y
 CONFIG_WINDFARM_PM112=y
+CONFIG_WINDFARM_PM121=y
 # CONFIG_PMAC_RACKMETER is not set
 CONFIG_NETDEVICES=y
 # CONFIG_NETDEVICES_MULTIQUEUE is not set
drivers/macintosh/Kconfig +8 -0
index 77f50b6..2d028e6 100644
@@ -234,6 +234,14 @@ config WINDFARM_PM112
 	  which are the recent dual and quad G5 machines using the
 	  970MP dual-core processor.
 
+config WINDFARM_PM121
+	tristate "Support for thermal management on PowerMac12,1"
+	depends on WINDFARM && I2C && PMAC_SMU
+	select I2C_POWERMAC
+	help
+	  This driver provides thermal control for the PowerMac12,1
+	  which is the iMac G5 (iSight) 970MP
+
 config ANSLCD
 	tristate "Support for ANS LCD display"
 	depends on ADB_CUDA && PPC_PMAC
drivers/macintosh/Makefile +5 -0
index 2dfc3f4..e3132ef 100644
@@ -42,4 +42,9 @@ obj-$(CONFIG_WINDFARM_PM112)	+= windfarm_pm112.o windfarm_smu_sat.o \
 				   windfarm_smu_sensors.o \
 				   windfarm_max6690_sensor.o \
 				   windfarm_lm75_sensor.o windfarm_pid.o
+obj-$(CONFIG_WINDFARM_PM121)	+= windfarm_pm121.o windfarm_smu_sat.o \
+				   windfarm_smu_controls.o \
+				   windfarm_smu_sensors.o \
+				   windfarm_max6690_sensor.o \
+				   windfarm_lm75_sensor.o windfarm_pid.o
 obj-$(CONFIG_PMAC_RACKMETER)	+= rack-meter.o
drivers/macintosh/windfarm_lm75_sensor.c +6 -0
index 7e10c3a..b92b959 100644
@@ -127,6 +127,12 @@ static struct wf_lm75_sensor *wf_lm75_create(struct i2c_adapter *adapter,
 	 */
 	if (!strcmp(loc, "Hard drive") || !strcmp(loc, "DRIVE BAY"))
 		lm->sens.name = "hd-temp";
+	else if (!strcmp(loc, "Incoming Air Temp"))
+		lm->sens.name = "incoming-air-temp";
+	else if (!strcmp(loc, "ODD Temp"))
+		lm->sens.name = "optical-drive-temp";
+	else if (!strcmp(loc, "HD Temp"))
+		lm->sens.name = "hard-drive-temp";
 	else
 		goto fail;
 
drivers/macintosh/windfarm_max6690_sensor.c +14 -6
index 5f03aab..e207a90 100644
@@ -77,18 +77,28 @@ static struct wf_sensor_ops wf_max6690_ops = {
 	.owner		= THIS_MODULE,
 };
 
-static void wf_max6690_create(struct i2c_adapter *adapter, u8 addr)
+static void wf_max6690_create(struct i2c_adapter *adapter, u8 addr,
+			      const char *loc)
 {
 	struct wf_6690_sensor *max;
-	char *name = "backside-temp";
+	char *name;
 
 	max = kzalloc(sizeof(struct wf_6690_sensor), GFP_KERNEL);
 	if (max == NULL) {
 		printk(KERN_ERR "windfarm: Couldn't create MAX6690 sensor %s: "
-		       "no memory\n", name);
+		       "no memory\n", loc);
 		return;
 	}
 
+	if (!strcmp(loc, "BACKSIDE"))
+		name = "backside-temp";
+	else if (!strcmp(loc, "NB Ambient"))
+		name = "north-bridge-temp";
+	else if (!strcmp(loc, "GPU Ambient"))
+		name = "gpu-temp";
+	else
+		goto fail;
+
 	max->sens.ops = &wf_max6690_ops;
 	max->sens.name = name;
 	max->i2c.addr = addr >> 1;
@@ -138,9 +148,7 @@ static int wf_max6690_attach(struct i2c_adapter *adapter)
 		if (loc == NULL || addr == 0)
 			continue;
 		printk("found max6690, loc=%s addr=0x%02x\n", loc, addr);
-		if (strcmp(loc, "BACKSIDE"))
-			continue;
-		wf_max6690_create(adapter, addr);
+		wf_max6690_create(adapter, addr, loc);
 	}
 
 	return 0;
drivers/macintosh/windfarm_pm121.c new file +1040 -0

1,040 lines not on this page · raw message

drivers/macintosh/windfarm_smu_controls.c +4 -0
index 58c2590..961fa0e 100644
@@ -218,6 +218,10 @@ static struct smu_fan_control *smu_fan_create(struct device_node *node,
 		fct->ctrl.name = "cpu-fan";
 	else if (!strcmp(l, "Hard Drive") || !strcmp(l, "Hard drive"))
 		fct->ctrl.name = "drive-bay-fan";
+	else if (!strcmp(l, "HDD Fan")) /* seen on iMac G5 iSight */
+		fct->ctrl.name = "hard-drive-fan";
+	else if (!strcmp(l, "ODD Fan")) /* same */
+		fct->ctrl.name = "optical-drive-fan";
 
 	/* Unrecognized fan, bail out */
 	if (fct->ctrl.name == NULL)