Re: [PATCH] windfarm: add PowerMac 12,1 support

2007-12-06 Thread Étienne Bersac
Hi,

> + /* 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)
> + 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.
-- 
E Ultreïa !


signature.asc
Description: Ceci est une partie de message	numériquement signée
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev

Re: [PATCH] windfarm: add PowerMac 12,1 support

2007-12-10 Thread Étienne Bersac
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.

Signed-off-by: Étienne Bersac <[EMAIL PROTECTED]>
---
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.

diff --git a/arch/powerpc/configs/g5_defconfig 
b/arch/powerpc/configs/g5_defconfig
index 0a6fa1f..7125837 100644
--- a/arch/powerpc/configs/g5_defconfig
+++ b/arch/powerpc/configs/g5_defconfig
@@ -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
diff --git a/drivers/macintosh/Kconfig b/drivers/macintosh/Kconfig
index 77f50b6..2d028e6 100644
--- a/drivers/macintosh/Kconfig
+++ b/drivers/macintosh/Kconfig
@@ -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
diff --git a/drivers/macintosh/Makefile b/drivers/macintosh/Makefile
index 2dfc3f4..e3132ef 100644
--- a/drivers/macintosh/Makefile
+++ b/drivers/macintosh/Makefile
@@ -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
diff --git a/drivers/macintosh/windfarm_lm75_sensor.c 
b/drivers/macintosh/windfarm_lm75_sensor.c
index 7e10c3a..b92b959 100644
--- a/drivers/macintosh/windfarm_lm75_sensor.c
+++ b/drivers/macintosh/windfarm_lm75_sensor.c
@@ -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;
 
diff --git a/drivers/macintosh/windfarm_max6690_sensor.c 
b/drivers/macintosh/windfarm_max6690_sensor.c
index 5f03aab..c2b6d1c 100644
--- a/drivers/macintosh/windfarm_max6690_sensor.c
+++ b/drivers/macintosh/windfarm_max6690_sensor.c
@@ -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

Re: [PATCH] windfarm: add PowerMac 12,1 support

2007-12-10 Thread Étienne Bersac
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.

Signed-off-by: Étienne Bersac <[EMAIL PROTECTED]>
---

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.

diff --git a/arch/powerpc/configs/g5_defconfig 
b/arch/powerpc/configs/g5_defconfig
index 3673dd2..4c048b3 100644
--- a/arch/powerpc/configs/g5_defconfig
+++ b/arch/powerpc/configs/g5_defconfig
@@ -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
diff --git a/drivers/macintosh/Kconfig b/drivers/macintosh/Kconfig
index 77f50b6..2d028e6 100644
--- a/drivers/macintosh/Kconfig
+++ b/drivers/macintosh/Kconfig
@@ -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
diff --git a/drivers/macintosh/Makefile b/drivers/macintosh/Makefile
index 2dfc3f4..e3132ef 100644
--- a/drivers/macintosh/Makefile
+++ b/drivers/macintosh/Makefile
@@ -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
diff --git a/drivers/macintosh/windfarm_lm75_sensor.c 
b/drivers/macintosh/windfarm_lm75_sensor.c
index 7e10c3a..b92b959 100644
--- a/drivers/macintosh/windfarm_lm75_sensor.c
+++ b/drivers/macintosh/windfarm_lm75_sensor.c
@@ -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;
 
diff --git a/drivers/macintosh/windfarm_max6690_sensor.c 
b/drivers/macintosh/windfarm_max6690_sensor.c
index 5f03aab..e207a90 100644
--- a/drivers/macintosh/windfarm_max6690_sensor.c
+++ b/drivers/macintosh/windfarm_max6690_sensor.c
@@ -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

Re: [PATCH] windfarm: add PowerMac 12,1 support

2007-12-10 Thread Étienne Bersac
Hi,

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

Thanks,
Étienne

Signed-off-by: Étienne Bersac <[EMAIL PROTECTED]>
---
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.

diff --git a/arch/powerpc/configs/g5_defconfig 
b/arch/powerpc/configs/g5_defconfig
index 3673dd2..4c048b3 100644
--- a/arch/powerpc/configs/g5_defconfig
+++ b/arch/powerpc/configs/g5_defconfig
@@ -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
diff --git a/drivers/macintosh/Kconfig b/drivers/macintosh/Kconfig
index 77f50b6..2d028e6 100644
--- a/drivers/macintosh/Kconfig
+++ b/drivers/macintosh/Kconfig
@@ -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
diff --git a/drivers/macintosh/Makefile b/drivers/macintosh/Makefile
index 2dfc3f4..e3132ef 100644
--- a/drivers/macintosh/Makefile
+++ b/drivers/macintosh/Makefile
@@ -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
diff --git a/drivers/macintosh/windfarm_lm75_sensor.c 
b/drivers/macintosh/windfarm_lm75_sensor.c
index 7e10c3a..b92b959 100644
--- a/drivers/macintosh/windfarm_lm75_sensor.c
+++ b/drivers/macintosh/windfarm_lm75_sensor.c
@@ -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;
 
diff --git a/drivers/macintosh/windfarm_max6690_sensor.c 
b/drivers/macintosh/windfarm_max6690_sensor.c
index 5f03aab..e207a90 100644
--- a/drivers/macintosh/windfarm_max6690_sensor.c
+++ b/drivers/macintosh/windfarm_max6690_sensor.c
@@ -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 >> 

Re: any more patches for 2.6.24?

2007-12-14 Thread Étienne Bersac
Hi,

I posted a patch adding windfarm-pm121 driver, i wish it were included
in 2.6.24 . Can you review it ?

http://ozlabs.org/pipermail/linuxppc-dev/2007-December/047641.html

Regards,
Étienne.

___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev

[PATCH] windfarm: add PowerMac 12,1 support

2008-01-26 Thread Étienne Bersac
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.

Signed-off-by: Étienne Bersac <[EMAIL PROTECTED]>
---

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.

diff --git a/arch/powerpc/configs/g5_defconfig 
b/arch/powerpc/configs/g5_defconfig
index 3673dd2..4c048b3 100644
--- a/arch/powerpc/configs/g5_defconfig
+++ b/arch/powerpc/configs/g5_defconfig
@@ -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
diff --git a/drivers/macintosh/Kconfig b/drivers/macintosh/Kconfig
index 77f50b6..2d028e6 100644
--- a/drivers/macintosh/Kconfig
+++ b/drivers/macintosh/Kconfig
@@ -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
diff --git a/drivers/macintosh/Makefile b/drivers/macintosh/Makefile
index 2dfc3f4..e3132ef 100644
--- a/drivers/macintosh/Makefile
+++ b/drivers/macintosh/Makefile
@@ -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
diff --git a/drivers/macintosh/windfarm_lm75_sensor.c 
b/drivers/macintosh/windfarm_lm75_sensor.c
index 7e10c3a..b92b959 100644
--- a/drivers/macintosh/windfarm_lm75_sensor.c
+++ b/drivers/macintosh/windfarm_lm75_sensor.c
@@ -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;
 
diff --git a/drivers/macintosh/windfarm_max6690_sensor.c 
b/drivers/macintosh/windfarm_max6690_sensor.c
index 5f03aab..e207a90 100644
--- a/drivers/macintosh/windfarm_max6690_sensor.c
+++ b/drivers/macintosh/windfarm_max6690_sensor.c
@@ -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
+ 

Re: [patch] Windfarm plateform module for PowerMac12,1

2007-12-05 Thread Étienne Bersac
Sorry for my noobness, i though i wasn't allowed to sign my own
patches /o\

So …

Signed-off-by: Étienne Bersac <[EMAIL PROTECTED]>


If you want a re-submission, please tell me so.

Regards,
Étienne.
-- 
E Ultreïa !

___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev

[PATCH] windfarm: add PowerMac 12,1 support

2007-12-05 Thread Étienne Bersac
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.

Signed-off-by: Étienne Bersac <[EMAIL PROTECTED]>
---

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.

diff --git a/arch/powerpc/configs/g5_defconfig 
b/arch/powerpc/configs/g5_defconfig
index 0a6fa1f..7125837 100644
--- a/arch/powerpc/configs/g5_defconfig
+++ b/arch/powerpc/configs/g5_defconfig
@@ -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
diff --git a/drivers/macintosh/Kconfig b/drivers/macintosh/Kconfig
index 77f50b6..2d028e6 100644
--- a/drivers/macintosh/Kconfig
+++ b/drivers/macintosh/Kconfig
@@ -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
diff --git a/drivers/macintosh/Makefile b/drivers/macintosh/Makefile
index 2dfc3f4..e3132ef 100644
--- a/drivers/macintosh/Makefile
+++ b/drivers/macintosh/Makefile
@@ -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
diff --git a/drivers/macintosh/windfarm_lm75_sensor.c 
b/drivers/macintosh/windfarm_lm75_sensor.c
index 7e10c3a..b92b959 100644
--- a/drivers/macintosh/windfarm_lm75_sensor.c
+++ b/drivers/macintosh/windfarm_lm75_sensor.c
@@ -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;
 
diff --git a/drivers/macintosh/windfarm_max6690_sensor.c 
b/drivers/macintosh/windfarm_max6690_sensor.c
index 5f03aab..c2b6d1c 100644
--- a/drivers/macintosh/windfarm_max6690_sensor.c
+++ b/drivers/macintosh/windfarm_max6690_sensor.c
@@ -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

[patch] Windfarm plateform module for PowerMac12,1

2007-12-05 Thread Étienne Bersac
continue;
-   wf_max6690_create(adapter, addr);
+   wf_max6690_create(adapter, addr, loc);
}
 
return 0;
diff --git a/drivers/macintosh/windfarm_pm121.c 
b/drivers/macintosh/windfarm_pm121.c
new file mode 100644
index 000..0cb4b3e
--- /dev/null
+++ b/drivers/macintosh/windfarm_pm121.c
@@ -0,0 +1,1052 @@
+/*
+ * Windfarm PowerMac thermal control. iMac G5 iSight
+ *
+ * (c) Copyright 2007 Étienne Bersac <[EMAIL PROTECTED]>
+ *
+ * Bits & pieces from windfarm_pm81.c by (c) Copyright 2005 Benjamin
+ * Herrenschmidt, IBM Corp. <[EMAIL PROTECTED]>
+ *
+ * Released under the term of the GNU GPL v2.
+ *
+ *
+ *
+ * PowerMac12,1
+ * 
+ *
+ *
+ * The algorithm used is the PID control algorithm, used the same way
+ * the published Darwin code does, using the same values that are
+ * present in the Darwin 8.10 snapshot property lists (note however
+ * that none of the code has been re-used, it's a complete
+ * re-implementation
+ *
+ * There is two models using PowerMac12,1. Model 2 is iMac G5 iSight
+ * 17" while Model 3 is iMac G5 20". They do have both the same
+ * controls with a tiny difference. The control-ids of hard-drive-fan
+ * and cpu-fan is swapped.
+ *
+ *
+ * Target Correction :
+ *
+ * controls have a target correction calculated as :
+ *
+ * new_min = average_power * slope) >> 16) + offset) >> 16) + min_value
+ * new_value = max(new_value, max(new_min, 0))
+ *
+ * OD Fan control correction.
+ *
+ * # model_id: 2
+ *   offset: -19563152
+ *   slope :  1956315
+ *
+ * # model_id: 3
+ *   offset: -15650652
+ *   slope :  1565065
+ *
+ * HD Fan control correction.
+ *
+ * # model_id: 2
+ *   offset: -15650652
+ *   slope :  1565065
+ *
+ * # model_id: 3
+ *   offset: -19563152
+ *   slope :  1956315
+ *
+ * CPU Fan control correction.
+ *
+ * # model_id: 2
+ *   offset: -25431900
+ *   slope :  2543190
+ *
+ * # model_id: 3
+ *   offset: -15650652
+ *   slope :  1565065
+ *
+ *
+ * Target rubber-banding :
+ *
+ * Some controls have a target correction which depends on another
+ * control value. The correction is computed in the following way :
+ *
+ * new_min = ref_value * slope + offset
+ *
+ * ref_value is the value of the reference control. If new_min is
+ * greater than 0, then we correct the target value using :
+ *
+ * new_target = max (new_target, new_min >> 16)
+ *
+ *
+ * # model_id : 2
+ *   control   : cpu-fan
+ *   ref   : optical-drive-fan
+ *   offset: -15650652
+ *   slope : 1565065
+ *
+ * # model_id : 3
+ *   control   : optical-drive-fan
+ *   ref   : hard-drive-fan
+ *   offset: -32768000
+ *   slope : 65536
+ *
+ *
+ * In order to have the moste efficient correction with those
+ * dependencies, we must trigger HD loop before OD loop before CPU
+ * loop.
+ *
+ *
+ * The various control loops found in Darwin config file are:
+ *
+ * HD Fan control loop.
+ *
+ * # model_id: 2
+ *   control: hard-drive-fan
+ *   sensor : hard-drive-temp
+ *   PID params : G_d = 0x
+ *G_p = 0x002D70A3
+ *G_r = 0x0001
+ *History = 2 entries
+ *Input target = 0x37
+ *Interval = 5s
+ *
+ * # model_id: 3
+ *   control: hard-drive-fan
+ *   sensor : hard-drive-temp
+ *   PID params : G_d = 0x
+ *G_p = 0x002170A3
+ *G_r = 0x0001
+ *History = 2 entries
+ *Input target = 0x37
+ *Interval = 5s
+ *
+ * OD Fan control loop.
+ *
+ * # model_id: 2
+ *   control: optical-drive-fan
+ *   sensor : optical-drive-temp
+ *   PID params : G_d = 0x
+ *G_p = 0x001FAE14
+ *G_r = 0x0001
+ *History = 2 entries
+ *Input target = 0x32
+ *Interval = 5s
+ *
+ * # model_id: 3
+ *   control: optical-drive-fan
+ *   sensor : optical-drive-temp
+ *   PID params : G_d = 0x
+ *G_p = 0x001FAE14
+ *G_r = 0x0001
+ *History = 2 entries
+ *Input target = 0x32
+ *Interval = 5s
+ *
+ * GPU Fan control loop.
+ *
+ * # model_id: 2
+ *   control: hard-drive-fan
+ *   sensor : gpu-temp
+ *   PID params : G_d = 0x
+ *G_p = 0x002A
+ *G_r = 0x0001
+ *History = 2 entries
+ *Input target = 0x5A
+ *Interval = 5s
+ *
+ * # model_id: 3
+ *   control: cpu-fan
+ *   sensor : gpu-temp
+ *   PID params