aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/macintosh/windfarm_pm81.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_pm81.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_pm81.c')
-rw-r--r--drivers/macintosh/windfarm_pm81.c87
1 files changed, 12 insertions, 75 deletions
diff --git a/drivers/macintosh/windfarm_pm81.c b/drivers/macintosh/windfarm_pm81.c
index eb69a601e765..f1df6efcbe68 100644
--- a/drivers/macintosh/windfarm_pm81.c
+++ b/drivers/macintosh/windfarm_pm81.c
@@ -538,45 +538,6 @@ static void wf_smu_cpu_fans_tick(struct wf_smu_cpu_fans_state *st)
538 } 538 }
539} 539}
540 540
541
542/*
543 * ****** Attributes ******
544 *
545 */
546
547#define BUILD_SHOW_FUNC_FIX(name, data) \
548static ssize_t show_##name(struct device *dev, \
549 struct device_attribute *attr, \
550 char *buf) \
551{ \
552 ssize_t r; \
553 s32 val = 0; \
554 data->ops->get_value(data, &val); \
555 r = sprintf(buf, "%d.%03d", FIX32TOPRINT(val)); \
556 return r; \
557} \
558static DEVICE_ATTR(name,S_IRUGO,show_##name, NULL);
559
560
561#define BUILD_SHOW_FUNC_INT(name, data) \
562static ssize_t show_##name(struct device *dev, \
563 struct device_attribute *attr, \
564 char *buf) \
565{ \
566 s32 val = 0; \
567 data->ops->get_value(data, &val); \
568 return sprintf(buf, "%d", val); \
569} \
570static DEVICE_ATTR(name,S_IRUGO,show_##name, NULL);
571
572BUILD_SHOW_FUNC_INT(cpu_fan, fan_cpu_main);
573BUILD_SHOW_FUNC_INT(sys_fan, fan_system);
574BUILD_SHOW_FUNC_INT(hd_fan, fan_hd);
575
576BUILD_SHOW_FUNC_FIX(cpu_temp, sensor_cpu_temp);
577BUILD_SHOW_FUNC_FIX(cpu_power, sensor_cpu_power);
578BUILD_SHOW_FUNC_FIX(hd_temp, sensor_hd_temp);
579
580/* 541/*
581 * ****** Setup / Init / Misc ... ****** 542 * ****** Setup / Init / Misc ... ******
582 * 543 *
@@ -654,17 +615,13 @@ static void wf_smu_new_control(struct wf_control *ct)
654 return; 615 return;
655 616
656 if (fan_cpu_main == NULL && !strcmp(ct->name, "cpu-fan")) { 617 if (fan_cpu_main == NULL && !strcmp(ct->name, "cpu-fan")) {
657 if (wf_get_control(ct) == 0) { 618 if (wf_get_control(ct) == 0)
658 fan_cpu_main = ct; 619 fan_cpu_main = ct;
659 device_create_file(wf_smu_dev, &dev_attr_cpu_fan);
660 }
661 } 620 }
662 621
663 if (fan_system == NULL && !strcmp(ct->name, "system-fan")) { 622 if (fan_system == NULL && !strcmp(ct->name, "system-fan")) {
664 if (wf_get_control(ct) == 0) { 623 if (wf_get_control(ct) == 0)
665 fan_system = ct; 624 fan_system = ct;
666 device_create_file(wf_smu_dev, &dev_attr_sys_fan);
667 }
668 } 625 }
669 626
670 if (cpufreq_clamp == NULL && !strcmp(ct->name, "cpufreq-clamp")) { 627 if (cpufreq_clamp == NULL && !strcmp(ct->name, "cpufreq-clamp")) {
@@ -683,10 +640,8 @@ static void wf_smu_new_control(struct wf_control *ct)
683 } 640 }
684 641
685 if (fan_hd == NULL && !strcmp(ct->name, "drive-bay-fan")) { 642 if (fan_hd == NULL && !strcmp(ct->name, "drive-bay-fan")) {
686 if (wf_get_control(ct) == 0) { 643 if (wf_get_control(ct) == 0)
687 fan_hd = ct; 644 fan_hd = ct;
688 device_create_file(wf_smu_dev, &dev_attr_hd_fan);
689 }
690 } 645 }
691 646
692 if (fan_system && fan_hd && fan_cpu_main && cpufreq_clamp) 647 if (fan_system && fan_hd && fan_cpu_main && cpufreq_clamp)
@@ -699,24 +654,18 @@ static void wf_smu_new_sensor(struct wf_sensor *sr)
699 return; 654 return;
700 655
701 if (sensor_cpu_power == NULL && !strcmp(sr->name, "cpu-power")) { 656 if (sensor_cpu_power == NULL && !strcmp(sr->name, "cpu-power")) {
702 if (wf_get_sensor(sr) == 0) { 657 if (wf_get_sensor(sr) == 0)
703 sensor_cpu_power = sr; 658 sensor_cpu_power = sr;
704 device_create_file(wf_smu_dev, &dev_attr_cpu_power);
705 }
706 } 659 }
707 660
708 if (sensor_cpu_temp == NULL && !strcmp(sr->name, "cpu-temp")) { 661 if (sensor_cpu_temp == NULL && !strcmp(sr->name, "cpu-temp")) {
709 if (wf_get_sensor(sr) == 0) { 662 if (wf_get_sensor(sr) == 0)
710 sensor_cpu_temp = sr; 663 sensor_cpu_temp = sr;
711 device_create_file(wf_smu_dev, &dev_attr_cpu_temp);
712 }
713 } 664 }
714 665
715 if (sensor_hd_temp == NULL && !strcmp(sr->name, "hd-temp")) { 666 if (sensor_hd_temp == NULL && !strcmp(sr->name, "hd-temp")) {
716 if (wf_get_sensor(sr) == 0) { 667 if (wf_get_sensor(sr) == 0)
717 sensor_hd_temp = sr; 668 sensor_hd_temp = sr;
718 device_create_file(wf_smu_dev, &dev_attr_hd_temp);
719 }
720 } 669 }
721 670
722 if (sensor_cpu_power && sensor_cpu_temp && sensor_hd_temp) 671 if (sensor_cpu_power && sensor_cpu_temp && sensor_hd_temp)
@@ -794,32 +743,20 @@ static int wf_smu_remove(struct device *ddev)
794 * with that except by adding locks all over... I'll do that 743 * with that except by adding locks all over... I'll do that
795 * eventually but heh, who ever rmmod this module anyway ? 744 * eventually but heh, who ever rmmod this module anyway ?
796 */ 745 */
797 if (sensor_cpu_power) { 746 if (sensor_cpu_power)
798 device_remove_file(wf_smu_dev, &dev_attr_cpu_power);
799 wf_put_sensor(sensor_cpu_power); 747 wf_put_sensor(sensor_cpu_power);
800 } 748 if (sensor_cpu_temp)
801 if (sensor_cpu_temp) {
802 device_remove_file(wf_smu_dev, &dev_attr_cpu_temp);
803 wf_put_sensor(sensor_cpu_temp); 749 wf_put_sensor(sensor_cpu_temp);
804 } 750 if (sensor_hd_temp)
805 if (sensor_hd_temp) {
806 device_remove_file(wf_smu_dev, &dev_attr_hd_temp);
807 wf_put_sensor(sensor_hd_temp); 751 wf_put_sensor(sensor_hd_temp);
808 }
809 752
810 /* Release all controls */ 753 /* Release all controls */
811 if (fan_cpu_main) { 754 if (fan_cpu_main)
812 device_remove_file(wf_smu_dev, &dev_attr_cpu_fan);
813 wf_put_control(fan_cpu_main); 755 wf_put_control(fan_cpu_main);
814 } 756 if (fan_hd)
815 if (fan_hd) {
816 device_remove_file(wf_smu_dev, &dev_attr_hd_fan);
817 wf_put_control(fan_hd); 757 wf_put_control(fan_hd);
818 } 758 if (fan_system)
819 if (fan_system) {
820 device_remove_file(wf_smu_dev, &dev_attr_sys_fan);
821 wf_put_control(fan_system); 759 wf_put_control(fan_system);
822 }
823 if (cpufreq_clamp) 760 if (cpufreq_clamp)
824 wf_put_control(cpufreq_clamp); 761 wf_put_control(cpufreq_clamp);
825 762