aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/macintosh/windfarm_smu_sensors.c
diff options
context:
space:
mode:
authorBenjamin Herrenschmidt <benh@kernel.crashing.org>2006-02-08 00:42:51 -0500
committerLinus Torvalds <torvalds@g5.osdl.org>2006-02-08 01:05:14 -0500
commitac171c46667c1cb2ee9e22312291df6ed78e1b6e (patch)
tree86ca722abc1ddceb0887b3ed6a195d77bb200dc2 /drivers/macintosh/windfarm_smu_sensors.c
parent746f956beb534ddf73da4346de81f2941c8573f8 (diff)
[PATCH] 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 <benh@kernel.crashing.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'drivers/macintosh/windfarm_smu_sensors.c')
-rw-r--r--drivers/macintosh/windfarm_smu_sensors.c43
1 files changed, 23 insertions, 20 deletions
diff --git a/drivers/macintosh/windfarm_smu_sensors.c b/drivers/macintosh/windfarm_smu_sensors.c
index 1a00d9c75a23..bed25dcf8a1e 100644
--- a/drivers/macintosh/windfarm_smu_sensors.c
+++ b/drivers/macintosh/windfarm_smu_sensors.c
@@ -220,14 +220,29 @@ static struct smu_ad_sensor *smu_ads_create(struct device_node *node)
220 !strcmp(l, "CPU T-Diode")) { 220 !strcmp(l, "CPU T-Diode")) {
221 ads->sens.ops = &smu_cputemp_ops; 221 ads->sens.ops = &smu_cputemp_ops;
222 ads->sens.name = "cpu-temp"; 222 ads->sens.name = "cpu-temp";
223 if (cpudiode == NULL) {
224 DBG("wf: cpudiode partition (%02x) not found\n",
225 SMU_SDB_CPUDIODE_ID);
226 goto fail;
227 }
223 } else if (!strcmp(c, "current-sensor") && 228 } else if (!strcmp(c, "current-sensor") &&
224 !strcmp(l, "CPU Current")) { 229 !strcmp(l, "CPU Current")) {
225 ads->sens.ops = &smu_cpuamp_ops; 230 ads->sens.ops = &smu_cpuamp_ops;
226 ads->sens.name = "cpu-current"; 231 ads->sens.name = "cpu-current";
232 if (cpuvcp == NULL) {
233 DBG("wf: cpuvcp partition (%02x) not found\n",
234 SMU_SDB_CPUVCP_ID);
235 goto fail;
236 }
227 } else if (!strcmp(c, "voltage-sensor") && 237 } else if (!strcmp(c, "voltage-sensor") &&
228 !strcmp(l, "CPU Voltage")) { 238 !strcmp(l, "CPU Voltage")) {
229 ads->sens.ops = &smu_cpuvolt_ops; 239 ads->sens.ops = &smu_cpuvolt_ops;
230 ads->sens.name = "cpu-voltage"; 240 ads->sens.name = "cpu-voltage";
241 if (cpuvcp == NULL) {
242 DBG("wf: cpuvcp partition (%02x) not found\n",
243 SMU_SDB_CPUVCP_ID);
244 goto fail;
245 }
231 } else if (!strcmp(c, "power-sensor") && 246 } else if (!strcmp(c, "power-sensor") &&
232 !strcmp(l, "Slots Power")) { 247 !strcmp(l, "Slots Power")) {
233 ads->sens.ops = &smu_slotspow_ops; 248 ads->sens.ops = &smu_slotspow_ops;
@@ -365,29 +380,22 @@ smu_cpu_power_create(struct wf_sensor *volts, struct wf_sensor *amps)
365 return NULL; 380 return NULL;
366} 381}
367 382
368static int smu_fetch_param_partitions(void) 383static void smu_fetch_param_partitions(void)
369{ 384{
370 struct smu_sdbp_header *hdr; 385 struct smu_sdbp_header *hdr;
371 386
372 /* Get CPU voltage/current/power calibration data */ 387 /* Get CPU voltage/current/power calibration data */
373 hdr = smu_get_sdb_partition(SMU_SDB_CPUVCP_ID, NULL); 388 hdr = smu_get_sdb_partition(SMU_SDB_CPUVCP_ID, NULL);
374 if (hdr == NULL) { 389 if (hdr != NULL) {
375 DBG("wf: cpuvcp partition (%02x) not found\n", 390 cpuvcp = (struct smu_sdbp_cpuvcp *)&hdr[1];
376 SMU_SDB_CPUVCP_ID); 391 /* Keep version around */
377 return -ENODEV; 392 cpuvcp_version = hdr->version;
378 } 393 }
379 cpuvcp = (struct smu_sdbp_cpuvcp *)&hdr[1];
380 /* Keep version around */
381 cpuvcp_version = hdr->version;
382 394
383 /* Get CPU diode calibration data */ 395 /* Get CPU diode calibration data */
384 hdr = smu_get_sdb_partition(SMU_SDB_CPUDIODE_ID, NULL); 396 hdr = smu_get_sdb_partition(SMU_SDB_CPUDIODE_ID, NULL);
385 if (hdr == NULL) { 397 if (hdr != NULL)
386 DBG("wf: cpudiode partition (%02x) not found\n", 398 cpudiode = (struct smu_sdbp_cpudiode *)&hdr[1];
387 SMU_SDB_CPUDIODE_ID);
388 return -ENODEV;
389 }
390 cpudiode = (struct smu_sdbp_cpudiode *)&hdr[1];
391 399
392 /* Get slots power calibration data if any */ 400 /* Get slots power calibration data if any */
393 hdr = smu_get_sdb_partition(SMU_SDB_SLOTSPOW_ID, NULL); 401 hdr = smu_get_sdb_partition(SMU_SDB_SLOTSPOW_ID, NULL);
@@ -398,23 +406,18 @@ static int smu_fetch_param_partitions(void)
398 hdr = smu_get_sdb_partition(SMU_SDB_DEBUG_SWITCHES_ID, NULL); 406 hdr = smu_get_sdb_partition(SMU_SDB_DEBUG_SWITCHES_ID, NULL);
399 if (hdr != NULL) 407 if (hdr != NULL)
400 debugswitches = (u8 *)&hdr[1]; 408 debugswitches = (u8 *)&hdr[1];
401
402 return 0;
403} 409}
404 410
405static int __init smu_sensors_init(void) 411static int __init smu_sensors_init(void)
406{ 412{
407 struct device_node *smu, *sensors, *s; 413 struct device_node *smu, *sensors, *s;
408 struct smu_ad_sensor *volt_sensor = NULL, *curr_sensor = NULL; 414 struct smu_ad_sensor *volt_sensor = NULL, *curr_sensor = NULL;
409 int rc;
410 415
411 if (!smu_present()) 416 if (!smu_present())
412 return -ENODEV; 417 return -ENODEV;
413 418
414 /* Get parameters partitions */ 419 /* Get parameters partitions */
415 rc = smu_fetch_param_partitions(); 420 smu_fetch_param_partitions();
416 if (rc)
417 return rc;
418 421
419 smu = of_find_node_by_type(NULL, "smu"); 422 smu = of_find_node_by_type(NULL, "smu");
420 if (smu == NULL) 423 if (smu == NULL)